├── Lombiq.Analyzers
├── NuGetIcon.png
├── build
│ └── Lombiq.Analyzers.props
├── Readme.md
├── stylecop.json
├── SonarLint.xml
├── .editorconfig
├── Lombiq.Analyzers.csproj
├── AnalyzerPackages.props
├── Lombiq.Analyzers.nuspec.template
├── Docs
│ ├── UsingAnalyzersDuringCommandLineBuilds.md
│ ├── UsingAnalyzersDuringDevelopment.md
│ ├── ConfiguringAnalyzers.md
│ └── AddingAnalyzers.md
├── Build.props
└── Lombiq.Analyzers.globalconfig
├── Lombiq.Analyzers.NetFx
├── NuGetIcon.png
├── build
│ └── Lombiq.Analyzers.NetFx.props
├── Readme.md
├── Lombiq.Analyzers.NetFx.globalconfig
├── Lombiq.Analyzers.NetFx.csproj
├── Lombiq.Analyzers.NetFx.nuspec.template
└── Build.props
├── Lombiq.Analyzers.Orchard1
├── NuGetIcon.png
├── build
│ └── Lombiq.Analyzers.Orchard1.props
├── Readme.md
├── Build.props
├── Lombiq.Analyzers.Orchard1.globalconfig
├── Lombiq.Analyzers.Orchard1.csproj
└── Lombiq.Analyzers.Orchard1.nuspec.template
├── Lombiq.Analyzers.OrchardCore
├── NuGetIcon.png
├── build
│ └── Lombiq.Analyzers.OrchardCore.props
├── Readme.md
├── Build.props
├── Lombiq.Analyzers.OrchardCore.globalconfig
├── Lombiq.Analyzers.OrchardCore.csproj
└── Lombiq.Analyzers.OrchardCore.nuspec.template
├── Lombiq.Analyzers.VisualStudioExtension
├── NuGetIcon.png
├── build
│ └── Lombiq.Analyzers.VisualStudioExtension.props
├── Readme.md
├── Build.props
├── Lombiq.Analyzers.VisualStudioExtension.globalconfig
├── Lombiq.Analyzers.VisualStudioExtension.csproj
└── Lombiq.Analyzers.VisualStudioExtension.nuspec.template
├── .github
└── workflows
│ ├── validate-pull-request.yml
│ ├── validate-nuget-publish.yml
│ ├── publish-nuget.yml
│ ├── create-jira-issues-for-community-activities.yml
│ └── test-analysis-failure.yml
├── .gitignore
├── .gitattributes
├── TestSolutions
├── Lombiq.Analyzers.ProjectReference
│ ├── Lombiq.Analyzers.ProjectReference.csproj
│ └── Lombiq.Analyzers.ProjectReference.sln
├── Directory.Build.props
├── Lombiq.Analyzers.PackageReference
│ ├── Lombiq.Analyzers.PackageReference.csproj
│ ├── IndirectPackageReference
│ │ └── IndirectPackageReference.csproj
│ └── Lombiq.Analyzers.PackageReference.sln
└── AnalyzerViolations.cs
├── ConvertTo-Nuspec.ps1
├── License.md
├── renovate.json5
├── Lombiq.Analyzers.sln
└── Readme.md
/Lombiq.Analyzers/NuGetIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lombiq/.NET-Analyzers/HEAD/Lombiq.Analyzers/NuGetIcon.png
--------------------------------------------------------------------------------
/Lombiq.Analyzers.NetFx/NuGetIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lombiq/.NET-Analyzers/HEAD/Lombiq.Analyzers.NetFx/NuGetIcon.png
--------------------------------------------------------------------------------
/Lombiq.Analyzers.Orchard1/NuGetIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lombiq/.NET-Analyzers/HEAD/Lombiq.Analyzers.Orchard1/NuGetIcon.png
--------------------------------------------------------------------------------
/Lombiq.Analyzers.OrchardCore/NuGetIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lombiq/.NET-Analyzers/HEAD/Lombiq.Analyzers.OrchardCore/NuGetIcon.png
--------------------------------------------------------------------------------
/Lombiq.Analyzers.VisualStudioExtension/NuGetIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lombiq/.NET-Analyzers/HEAD/Lombiq.Analyzers.VisualStudioExtension/NuGetIcon.png
--------------------------------------------------------------------------------
/Lombiq.Analyzers/build/Lombiq.Analyzers.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.NetFx/build/Lombiq.Analyzers.NetFx.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.Orchard1/build/Lombiq.Analyzers.Orchard1.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.OrchardCore/build/Lombiq.Analyzers.OrchardCore.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Readme.md:
--------------------------------------------------------------------------------
1 | # Lombiq .NET Analyzers
2 |
3 | ## About
4 |
5 | .NET code analyzers and code convention settings for general .NET projects. See [the root Readme](../Readme.md) for details on how to use the project.
6 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.VisualStudioExtension/build/Lombiq.Analyzers.VisualStudioExtension.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.github/workflows/validate-pull-request.yml:
--------------------------------------------------------------------------------
1 | name: Validate Pull Request
2 |
3 | on:
4 | pull_request_target:
5 |
6 | jobs:
7 | validate-pull-request:
8 | uses: Lombiq/GitHub-Actions/.github/workflows/validate-submodule-pull-request.yml@dev
9 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.NetFx/Readme.md:
--------------------------------------------------------------------------------
1 | # Lombiq .NET Analyzers for .NET Framework
2 |
3 | ## About
4 |
5 | .NET code analyzers and code convention settings for .NET Framework projects. See [the root Readme](../Readme.md) for details on how to use the project.
6 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.Orchard1/Readme.md:
--------------------------------------------------------------------------------
1 | # Lombiq .NET Analyzers for Orchard 1
2 |
3 | ## About
4 |
5 | .NET code analyzers and code convention settings for [Orchard 1](https://orchardcore.net/orchardcms) projects. See [the root Readme](../Readme.md) for details on how to use the project.
6 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.OrchardCore/Readme.md:
--------------------------------------------------------------------------------
1 | # Lombiq .NET Analyzers for Orchard Core
2 |
3 | ## About
4 |
5 | .NET code analyzers and code convention settings for [Orchard Core](https://orchardcore.net/) projects. See [the root Readme](../Readme.md) for details on how to use the project.
6 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.VisualStudioExtension/Readme.md:
--------------------------------------------------------------------------------
1 | # Lombiq .NET Analyzers for Visual Studio Extensions
2 |
3 | ## About
4 |
5 | .NET code analyzers and code convention settings for Visual Studio Extension projects. See [the root Readme](../Readme.md) for details on how to use the project.
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs/
2 | .idea/
3 | .vscode/
4 | obj/
5 | bin/
6 | artifacts/
7 | wwwroot/
8 | node_modules/
9 | *.user
10 | .pnpm-debug.log
11 | /.editorconfig
12 | /TestSolutions/**/.editorconfig
13 | /TestSolutions/Lombiq.Analyzers.*/**/AnalyzerViolations.cs
14 | /Lombiq.Analyzers/Lombiq.Analyzers.nuspec
15 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.OrchardCore/Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.VisualStudioExtension/Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
3 | # Enforce Windows newlines for C# files to avoid false positives with IDE0055 warning.
4 | # See https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions/issues/106 for more information.
5 | *.cs text eol=crlf
6 |
7 | # Keep LF line endings in pnpm-lock.yaml files to prevent Git from reporting this file as changed after pnpm touches it.
8 | pnpm-lock.yaml text eol=lf
9 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.Orchard1/Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "orderingRules": {
5 | "elementOrder": [
6 | "constant",
7 | "readonly"
8 | ]
9 | },
10 | "documentationRules": {
11 | "documentInterfaces": true,
12 | "documentExposedElements": false,
13 | "documentInternalElements": false
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net6.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.github/workflows/validate-nuget-publish.yml:
--------------------------------------------------------------------------------
1 | name: Validate NuGet Publish
2 |
3 | on:
4 | pull_request:
5 | push:
6 | branches:
7 | - dev
8 |
9 | jobs:
10 | validate-nuget-publish:
11 | name: Validate NuGet Publish
12 | uses: Lombiq/GitHub-Actions/.github/workflows/validate-nuget-publish.yml@dev
13 | with:
14 | # Don't generate any symbol package because we're not including the Lombiq.Analyzers.dll in the NuGet package
15 | # itself, either. See Invoke-BeforePack.ps1 for details.
16 | dotnet-pack-include-symbols: 'false'
17 |
--------------------------------------------------------------------------------
/.github/workflows/publish-nuget.yml:
--------------------------------------------------------------------------------
1 | name: Publish to NuGet
2 |
3 | on:
4 | push:
5 | tags:
6 | - v*
7 |
8 | jobs:
9 | publish-nuget:
10 | name: Publish to NuGet
11 | uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev
12 | with:
13 | # Don't generate any symbol package because we're not including the Lombiq.Analyzers.dll in the NuGet package
14 | # itself, either. See Invoke-BeforePack.ps1 for details.
15 | dotnet-pack-include-symbols: 'false'
16 | secrets:
17 | API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }}
18 |
--------------------------------------------------------------------------------
/TestSolutions/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
7 | true
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.VisualStudioExtension/Lombiq.Analyzers.VisualStudioExtension.globalconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | global_level = 20
3 |
4 | # Code analysis rules for Visual Studio extension projects, extending Lombiq.Analyzers.NetFx.globalconfig.
5 |
6 | # To get Visual Studio GUI support for configuring these rules, put it into the solution's startup project's folder and
7 | # rename it to .editorconfig. This should eventually not be necessary, see https://github.com/dotnet/roslyn/issues/70326.
8 |
9 | # Microsoft.VisualStudio.Threading.Analyzers rules
10 | dotnet_diagnostic.VSTHRD002.severity = warning
11 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.NetFx/Lombiq.Analyzers.NetFx.globalconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | global_level = 10
3 |
4 | # General code analysis rules for .NET Framework projects, extending Lombiq.Analyzers.globalconfig.
5 |
6 | # To get Visual Studio GUI support for configuring these rules, put it into the solution's startup project's folder and
7 | # rename it to .editorconfig. This should eventually not be necessary, see https://github.com/dotnet/roslyn/issues/70326.
8 |
9 | # Microsoft.CodeAnalysis.NetAnalyzers rules
10 | dotnet_diagnostic.CA1016.severity = none
11 |
12 | # SonarAnalyzer.CSharp rules
13 | dotnet_diagnostic.S3904.severity = none
14 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.Orchard1/Lombiq.Analyzers.Orchard1.globalconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | global_level = 20
3 |
4 | # Code analysis rules for Orchard 1 projects, extending Lombiq.Analyzers.NetFx.globalconfig and
5 | # Lombiq.Analyzers.OrchardCore.globalconfig.
6 |
7 | # To get Visual Studio GUI support for configuring these rules, put it into the solution's startup project's folder and
8 | # rename it to .editorconfig. This should eventually not be necessary, see https://github.com/dotnet/roslyn/issues/70326.
9 |
10 | # Microsoft.CodeAnalysis.NetAnalyzers rules
11 | dotnet_diagnostic.CA3147.severity = none
12 |
13 | # SecurityCodeScan.VS2019 rules
14 | dotnet_diagnostic.SCS0016.severity = none
15 |
16 | # SonarAnalyzer.CSharp rules
17 | dotnet_diagnostic.S4564.severity = none
18 |
--------------------------------------------------------------------------------
/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 |
6 |
7 |
8 |
9 | all
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/TestSolutions/AnalyzerViolations.cs:
--------------------------------------------------------------------------------
1 | namespace Lombiq.Analyzers.ProjectReference;
2 |
3 | // This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the
4 | // subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an
5 | // existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of
6 | // effect.) Also please commit the updated version everywhere, because if the file is not present before the build
7 | // starts then MSBuild won't include it despite the task. For this purpose the task is only there to
8 | // ensure that the changes propagate and get committed.
9 | public class Class1
10 | {
11 | private int Number;
12 | public Class1(int number)
13 | {
14 | Number = number;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/SonarLint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 | sonar.cs.analyzeRazorCode
9 | false
10 |
11 |
12 |
13 |
14 | S103
15 |
16 |
17 | maximumLineLength
18 | 150
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/.github/workflows/create-jira-issues-for-community-activities.yml:
--------------------------------------------------------------------------------
1 | name: Create Jira issues for community activities
2 |
3 | on:
4 | discussion:
5 | types: [created]
6 | issues:
7 | types: [opened]
8 | pull_request_target:
9 | types: [opened]
10 |
11 | jobs:
12 | create-jira-issues-for-community-activities:
13 | uses: Lombiq/GitHub-Actions/.github/workflows/create-jira-issues-for-community-activities.yml@dev
14 | secrets:
15 | JIRA_BASE_URL: ${{ secrets.DEFAULT_JIRA_BASE_URL }}
16 | JIRA_USER_EMAIL: ${{ secrets.DEFAULT_JIRA_USER_EMAIL }}
17 | JIRA_API_TOKEN: ${{ secrets.DEFAULT_JIRA_API_TOKEN }}
18 | JIRA_PROJECT_KEY: ${{ secrets.DEFAULT_JIRA_PROJECT_KEY }}
19 | DISCUSSION_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_DISCUSSION_JIRA_ISSUE_DESCRIPTION }}
20 | ISSUE_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_ISSUE_JIRA_ISSUE_DESCRIPTION }}
21 | PULL_REQUEST_JIRA_ISSUE_DESCRIPTION: ${{ secrets.DEFAULT_PULL_REQUEST_JIRA_ISSUE_DESCRIPTION }}
22 | with:
23 | issue-component: Lombiq.Analyzers
24 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/.editorconfig:
--------------------------------------------------------------------------------
1 | # WARNING: Only edit this file in the Lombiq .NET Analyzers repository's "Lombiq.Analyzers" folder. A copy of this file
2 | # anywhere else will be overwritten.
3 |
4 | # All files
5 | [*]
6 |
7 | # Basics
8 | charset = utf-8
9 | guidelines = 120 1px solid a0ffc000, 150 1px solid 80ff0000
10 |
11 | # Indentation and spacing
12 | indent_size = 4
13 | indent_style = space
14 | trim_trailing_whitespace = true
15 |
16 | # New line preferences
17 | end_of_line = crlf
18 | insert_final_newline = true
19 | tab_width = 4
20 |
21 | # Various config files
22 | [*.{config,csproj,json,props,targets}]
23 |
24 | indent_size = 2
25 |
26 | # Markdown files
27 | [*.md]
28 |
29 | trim_trailing_whitespace = false
30 |
31 | # JavaScript files
32 | [*.js]
33 |
34 | # Placeholder, no unique rules for JS files at the moment.
35 |
36 |
37 | # SCSS files
38 | [*.scss]
39 |
40 | # Placeholder, no unique rules for SCSS files at the moment.
41 |
42 | # PowerShell files
43 | [*.ps1]
44 |
45 | # Placeholder, no unique rules for PS files at the moment.
46 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.OrchardCore/Lombiq.Analyzers.OrchardCore.globalconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | global_level = 10
3 |
4 | # Code analysis rules for Orchard Core projects, extending Lombiq.Analyzers.globalconfig.
5 |
6 | # To get Visual Studio GUI support for configuring these rules, put it into the solution's startup project's folder and
7 | # rename it to .editorconfig. This should eventually not be necessary, see https://github.com/dotnet/roslyn/issues/70326.
8 |
9 |
10 | # Microsoft.CodeAnalysis.CSharp rules
11 | dotnet_diagnostic.CS1591.severity = none
12 |
13 | # Microsoft.CodeAnalysis.NetAnalyzers rules
14 | dotnet_diagnostic.CA1014.severity = none
15 | dotnet_diagnostic.CA1019.severity = silent
16 | dotnet_diagnostic.CA1062.severity = silent
17 | dotnet_diagnostic.CA1710.severity = silent
18 | dotnet_diagnostic.CA1711.severity = silent
19 | dotnet_diagnostic.CA1716.severity = silent
20 | dotnet_diagnostic.CA1724.severity = silent
21 | dotnet_diagnostic.CA1812.severity = silent
22 | dotnet_diagnostic.CA1848.severity = none
23 | dotnet_diagnostic.CA2007.severity = silent
24 | dotnet_diagnostic.CA5391.severity = silent
25 | dotnet_diagnostic.CA5395.severity = silent
26 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.OrchardCore/Lombiq.Analyzers.OrchardCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | $(DefaultItemExcludes);.git*;
6 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Lombiq.Analyzers.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | $(DefaultItemExcludes);.git*;
6 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.VisualStudioExtension/Lombiq.Analyzers.VisualStudioExtension.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | $(DefaultItemExcludes);.git*;
6 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.Orchard1/Lombiq.Analyzers.Orchard1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | $(DefaultItemExcludes);.git*;
6 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/AnalyzerPackages.props:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | all
20 | runtime; build; native; contentfiles; analyzers;
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ConvertTo-Nuspec.ps1:
--------------------------------------------------------------------------------
1 | param($Version)
2 |
3 | $packages = @(
4 | 'Lombiq.Analyzers',
5 | 'Lombiq.Analyzers.NetFx',
6 | 'Lombiq.Analyzers.OrchardCore',
7 | 'Lombiq.Analyzers.Orchard1',
8 | 'Lombiq.Analyzers.VisualStudioExtension'
9 | )
10 |
11 | # Iterate through the packages to replace
12 | foreach ($package in $packages)
13 | {
14 | $projectPath = Join-Path $PWD $package
15 | function Read-Xml([string]$File) { [xml](Get-Content $File) }
16 |
17 | $nuspec = Read-Xml (Join-Path $projectPath "$package.nuspec.template")
18 | $dependencies = $nuspec.package.metadata.dependencies
19 |
20 | $nuspec.package.metadata.GetElementsByTagName('version')[0].InnerXml = $Version
21 |
22 | # AnalyzerPackages.props is optional.
23 | $analyzerPackagesPropsFile = Join-Path $projectPath 'AnalyzerPackages.props'
24 | if (Test-Path $analyzerPackagesPropsFile)
25 | {
26 | foreach ($dependency in (Read-Xml $analyzerPackagesPropsFile).Project.ItemGroup.AnalyzerPackage)
27 | {
28 | $id = $dependency.Include
29 | if (-not $id) { continue }
30 |
31 | $node = $nuspec.CreateElement('dependency')
32 | $node.SetAttribute('id', $id)
33 | $node.SetAttribute('version', $dependency.Version)
34 |
35 | $dependencies.AppendChild($node)
36 | }
37 | }
38 |
39 | $outputPath = Join-Path $projectPath "$package.nuspec"
40 | $nuspec.Save($outputPath)
41 | }
42 |
--------------------------------------------------------------------------------
/License.md:
--------------------------------------------------------------------------------
1 | Copyright © 2020, [Lombiq Technologies Ltd.](https://lombiq.com)
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 |
9 | - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 |
11 | - Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 |
--------------------------------------------------------------------------------
/.github/workflows/test-analysis-failure.yml:
--------------------------------------------------------------------------------
1 | name: Test Analysis Failure
2 |
3 | # Runs for PRs opened for any branch, and pushes to the dev branch.
4 | on:
5 | pull_request:
6 | push:
7 | branches:
8 | - dev
9 |
10 | jobs:
11 | test-analysis-failure-nuget:
12 | name: Test Analysis Failure - NuGet PackageReference
13 | uses: Lombiq/GitHub-Actions/.github/workflows/test-analysis-failure.yml@dev
14 | with:
15 | machine-types: '["ubuntu-24.04", "windows-2025"]'
16 | build-directory: TestSolutions/Lombiq.Analyzers.PackageReference
17 | timeout-minutes: 30
18 | build-expected-code-analysis-errors: |
19 | IDE0021: Use expression body for constructors.
20 | IDE0044: Make field readonly.
21 | S2933: Make 'Number' 'readonly'.
22 | S4487: Remove this unread private field 'Number' or refactor the code to use its value.
23 |
24 | test-analysis-failure-local:
25 | name: Test Analysis Failure - Local ProjectReference
26 | uses: Lombiq/GitHub-Actions/.github/workflows/test-analysis-failure.yml@dev
27 | with:
28 | machine-types: '["ubuntu-24.04", "windows-2025"]'
29 | build-directory: TestSolutions/Lombiq.Analyzers.ProjectReference
30 | timeout-minutes: 30
31 | build-expected-code-analysis-errors: |
32 | IDE0021: Use expression body for constructors.
33 | IDE0044: Make field readonly.
34 | S2933: Fields that are only assigned in the constructor should be "readonly"
35 | S4487: Remove this unread private field 'Number' or refactor the code to use its value.
36 |
--------------------------------------------------------------------------------
/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 |
6 |
7 |
11 |
12 |
13 |
14 | all
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Lombiq.Analyzers
5 | $version$
6 | Lombiq .NET Analyzers
7 | Lombiq Technologies
8 | BSD-3-Clause
9 | NuGetIcon.png
10 | https://github.com/Lombiq/.NET-Analyzers/blob/dev/Lombiq.Analyzers
11 | Lombiq .NET Analyzers: .NET code analyzers and code convention settings for general .NET projects. See the project website for detailed documentation.
12 | Copyright © 2020, Lombiq Technologies Ltd.
13 | Lombiq CodeAnalysis DotNetAnalyzers Analyzer Analyzers Diagnostic Roslyn Refactoring AsyncFixer Meziantou.Analyzer StyleCop
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.NetFx/Lombiq.Analyzers.NetFx.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | $(DefaultItemExcludes);.git*;
6 |
7 |
8 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30114.105
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers.PackageReference", "Lombiq.Analyzers.PackageReference.csproj", "{431AE877-59B7-438C-91AE-825AC847B447}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0533C5D5-F4D0-4231-A810-80E7342F9C33}"
9 | ProjectSection(SolutionItems) = preProject
10 | ..\Directory.Build.props = ..\Directory.Build.props
11 | ..\AnalyzerViolations.cs = ..\AnalyzerViolations.cs
12 | EndProjectSection
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IndirectPackageReference", "IndirectPackageReference\IndirectPackageReference.csproj", "{B6108F6C-7B57-4475-932A-1124CD7CBF11}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(SolutionProperties) = preSolution
22 | HideSolutionNode = FALSE
23 | EndGlobalSection
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
25 | {431AE877-59B7-438C-91AE-825AC847B447}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {431AE877-59B7-438C-91AE-825AC847B447}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {431AE877-59B7-438C-91AE-825AC847B447}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {431AE877-59B7-438C-91AE-825AC847B447}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {B6108F6C-7B57-4475-932A-1124CD7CBF11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {B6108F6C-7B57-4475-932A-1124CD7CBF11}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {B6108F6C-7B57-4475-932A-1124CD7CBF11}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {B6108F6C-7B57-4475-932A-1124CD7CBF11}.Release|Any CPU.Build.0 = Release|Any CPU
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.OrchardCore/Lombiq.Analyzers.OrchardCore.nuspec.template:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Lombiq.Analyzers.OrchardCore
5 | $version$
6 | Lombiq .NET Analyzers for Orchard Core
7 | Lombiq Technologies
8 | BSD-3-Clause
9 | NuGetIcon.png
10 | https://github.com/Lombiq/.NET-Analyzers/blob/dev/Lombiq.Analyzers.OrchardCore
11 | Lombiq .NET Analyzers for Orchard Core: .NET code analyzers and code convention settings for Orchard Core (https://orchardcore.net/) apps. See the project website for detailed documentation.
12 | Copyright © 2020, Lombiq Technologies Ltd.
13 | OrchardCore Lombiq AspNetCore CodeAnalysis DotNetAnalyzers Analyzer Analyzers Diagnostic Roslyn Refactoring AsyncFixer Meziantou.Analyzer StyleCop
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.Orchard1/Lombiq.Analyzers.Orchard1.nuspec.template:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Lombiq.Analyzers.Orchard1
5 | $version$
6 | Lombiq .NET Analyzers for Orchard 1
7 | Lombiq Technologies
8 | BSD-3-Clause
9 | NuGetIcon.png
10 | https://github.com/Lombiq/.NET-Analyzers/blob/dev/Lombiq.Analyzers.Orchard1
11 | Lombiq .NET Analyzers for Orchard 1: .NET code analyzers and code convention settings for Orchard 1 (https://orchardcore.net/orchardcms) apps. See the project website for detailed documentation.
12 | Copyright © 2020, Lombiq Technologies Ltd.
13 | Orchard Lombiq AspNet CodeAnalysis DotNetAnalyzers Analyzer Analyzers Diagnostic Roslyn Refactoring AsyncFixer Meziantou.Analyzer StyleCop
14 |
15 |
16 |
17 |
18 |
19 | true
20 |
21 |
22 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/renovate.json5:
--------------------------------------------------------------------------------
1 | {
2 | $schema: 'https://docs.renovatebot.com/renovate-schema.json',
3 | extends: [
4 | 'github>Lombiq/renovate-config:default-dotnet.json5',
5 | 'github>Lombiq/Open-Source-Orchard-Core-Extensions:renovate-osoce-submodule.json5',
6 | ],
7 | customManagers: [
8 | {
9 | // AnalyzerPackages.props contains NuGet package references in a custom format. Supporting it here.
10 | customType: 'regex',
11 | managerFilePatterns: [
12 | '/(^|/)AnalyzerPackages\\.props$/',
13 | ],
14 | matchStrings: [
15 | // The capture group names are required as such.
16 | '',
17 | ],
18 | datasourceTemplate: 'nuget',
19 | versioningTemplate: 'nuget',
20 | },
21 | ],
22 | packageRules: [
23 | {
24 | // Microsoft.CodeAnalysis.CSharp.CodeStyle references Roslyn, and if its version is higher than that of the
25 | // locally installed SDK, it'll emit a "CSC : error CS9057: The analyzer assembly
26 | // '/home/runner/.nuget/packages/microsoft.codeanalysis.csharp.codestyle/4.11.0/analyzers/dotnet/cs/Microsoft.CodeAnalysis.CSharp.CodeStyle.dll'
27 | // references version '4.31.0.0' of the compiler, which is newer than the currently running version
28 | // '4.10.0.0'." error. So, we need to update it manually together with the SDK (and targeted .NET version).
29 | matchPackageNames: [
30 | 'Microsoft.CodeAnalysis.CSharp.CodeStyle',
31 | ],
32 | enabled: false,
33 | },
34 | {
35 | // Meziantou.Analyzer needs to be kept on the version in that file.
36 | matchPackageNames: [
37 | 'Meziantou.Analyzer',
38 | ],
39 | matchFileNames: [
40 | 'Lombiq.Analyzers.NetFx/Build.props',
41 | ],
42 | enabled: false,
43 | },
44 | ],
45 | }
46 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.NetFx/Lombiq.Analyzers.NetFx.nuspec.template:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Lombiq.Analyzers.NetFx
5 | $version$
6 | Lombiq .NET Analyzers for .NET Framework
7 | Lombiq Technologies
8 | BSD-3-Clause
9 | NuGetIcon.png
10 | https://github.com/Lombiq/.NET-Analyzers/blob/dev/Lombiq.Analyzers.NetFx
11 | Lombiq .NET Analyzers for .NET Framework: .NET code analyzers and code convention settings for .NET Framework projects. See the project website for detailed documentation.
12 | Copyright © 2020, Lombiq Technologies Ltd.
13 | NetFx Lombiq AspNetCore CodeAnalysis DotNetAnalyzers Analyzer Analyzers Diagnostic Roslyn Refactoring AsyncFixer Meziantou.Analyzer StyleCop
14 |
15 |
16 |
18 |
19 | true
20 |
21 |
22 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.VisualStudioExtension/Lombiq.Analyzers.VisualStudioExtension.nuspec.template:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Lombiq.Analyzers.VisualStudioExtension
5 | $version$
6 | Lombiq .NET Analyzers for Visual Studio Extensions
7 | Lombiq Technologies
8 | BSD-3-Clause
9 | NuGetIcon.png
10 | https://github.com/Lombiq/.NET-Analyzers/blob/dev/Lombiq.Analyzers.VisualStudioExtension
11 | Lombiq .NET Analyzers for Visual Studio Extensions: .NET code analyzers and code convention settings for Visual Studio Extensions. See the project website for detailed documentation.
12 | Copyright © 2020, Lombiq Technologies Ltd.
13 | VisualStudioExtension VisualStudio Lombiq AspNet CodeAnalysis DotNetAnalyzers Analyzer Analyzers Diagnostic Roslyn Refactoring AsyncFixer Meziantou.Analyzer StyleCop
14 |
15 |
16 |
17 |
18 |
19 | true
20 |
21 |
22 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.34202.233
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.Analyzers.ProjectReference", "Lombiq.Analyzers.ProjectReference.csproj", "{E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.Analyzers", "..\..\Lombiq.Analyzers\Lombiq.Analyzers.csproj", "{E4090872-11F2-49D1-A746-65E15DC4977E}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE857933-4E64-44B8-A1CA-3489F88475AB}"
11 | ProjectSection(SolutionItems) = preProject
12 | ..\Directory.Build.props = ..\Directory.Build.props
13 | EndProjectSection
14 | EndProject
15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.Analyzers.OrchardCore", "..\..\Lombiq.Analyzers.OrchardCore\Lombiq.Analyzers.OrchardCore.csproj", "{E1189194-7972-4A65-BFD5-82B55F17763D}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Release|Any CPU = Release|Any CPU
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {E4090872-11F2-49D1-A746-65E15DC4977E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {E4090872-11F2-49D1-A746-65E15DC4977E}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {E4090872-11F2-49D1-A746-65E15DC4977E}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {E4090872-11F2-49D1-A746-65E15DC4977E}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {E1189194-7972-4A65-BFD5-82B55F17763D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {E1189194-7972-4A65-BFD5-82B55F17763D}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {E1189194-7972-4A65-BFD5-82B55F17763D}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {E1189194-7972-4A65-BFD5-82B55F17763D}.Release|Any CPU.Build.0 = Release|Any CPU
35 | EndGlobalSection
36 | GlobalSection(SolutionProperties) = preSolution
37 | HideSolutionNode = FALSE
38 | EndGlobalSection
39 | EndGlobal
40 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.32112.339
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.Analyzers", "Lombiq.Analyzers\Lombiq.Analyzers.csproj", "{1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.Analyzers.OrchardCore", "Lombiq.Analyzers.OrchardCore\Lombiq.Analyzers.OrchardCore.csproj", "{56EB2C63-4689-40E8-B967-8E78D401E25B}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.Analyzers.NetFx", "Lombiq.Analyzers.NetFx\Lombiq.Analyzers.NetFx.csproj", "{5706CF69-091E-4F97-A6CE-3440F9CEACC7}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.Analyzers.Orchard1", "Lombiq.Analyzers.Orchard1\Lombiq.Analyzers.Orchard1.csproj", "{0FD2BD1A-0411-4AB0-B478-C8ECAE8759E8}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.Analyzers.VisualStudioExtension", "Lombiq.Analyzers.VisualStudioExtension\Lombiq.Analyzers.VisualStudioExtension.csproj", "{85C33788-497A-4223-B266-48B2592A04EA}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {56EB2C63-4689-40E8-B967-8E78D401E25B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {56EB2C63-4689-40E8-B967-8E78D401E25B}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {56EB2C63-4689-40E8-B967-8E78D401E25B}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {56EB2C63-4689-40E8-B967-8E78D401E25B}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {5706CF69-091E-4F97-A6CE-3440F9CEACC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {5706CF69-091E-4F97-A6CE-3440F9CEACC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {5706CF69-091E-4F97-A6CE-3440F9CEACC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {5706CF69-091E-4F97-A6CE-3440F9CEACC7}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {0FD2BD1A-0411-4AB0-B478-C8ECAE8759E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {0FD2BD1A-0411-4AB0-B478-C8ECAE8759E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {0FD2BD1A-0411-4AB0-B478-C8ECAE8759E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {0FD2BD1A-0411-4AB0-B478-C8ECAE8759E8}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {85C33788-497A-4223-B266-48B2592A04EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {85C33788-497A-4223-B266-48B2592A04EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {85C33788-497A-4223-B266-48B2592A04EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {85C33788-497A-4223-B266-48B2592A04EA}.Release|Any CPU.Build.0 = Release|Any CPU
42 | EndGlobalSection
43 | GlobalSection(SolutionProperties) = preSolution
44 | HideSolutionNode = FALSE
45 | EndGlobalSection
46 | GlobalSection(ExtensibilityGlobals) = postSolution
47 | SolutionGuid = {CF592D6A-8CAC-4389-89C7-593C104DB561}
48 | EndGlobalSection
49 | EndGlobal
50 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md:
--------------------------------------------------------------------------------
1 | # Using the analyzers during command line builds
2 |
3 | The following notes are useful if you're building not from within and IDE but from the command line, like in a CI environment. For CI builds we recommend using [Lombiq GitHub Actions](https://github.com/Lombiq/GitHub-Actions).
4 |
5 | **Note** the instructions for non-SDK-style .NET Framework projects at the bottom; those projects can't use `dotnet build`!
6 |
7 | ## Showing analyzer warnings during `dotnet build`
8 |
9 | Analyzer warnings will show up in the build output of `dotnet build` regardless of the `RunAnalyzersDuringBuild` config in _Build.props_. Note though, that this will only happen if it's a fresh, clean build; otherwise if you're building an already built solution use the `--no-incremental` switch to make analyzer warnings appear:
10 |
11 | ```ps
12 | dotnet build MySolution.sln --no-incremental
13 | ```
14 |
15 | If you want analyzer violations to fail the build (recommended) then also use `TreatWarningsAsErrors`:
16 |
17 | ```ps
18 | dotnet build MySolution.sln --no-incremental /p:TreatWarningsAsErrors=true
19 | ```
20 |
21 | ## .NET code style analysis
22 |
23 | If you want code style analysis configured in _.globalconfig_ (i.e. IDE\* rules, this is not applicable to the others) to be checked during build too (it's already checked during editing) then you'll need to run the build with `RunAnalyzersDuringBuild=true`. **Don't** enable `EnforceCodeStyleInBuild` as explained in [the docs](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview#code-style-analysis) because that always uses the analyzers from the .NET SDK, not the explicitly referenced packages, and violations won't show up (see [this comment](https://github.com/dotnet/roslyn/issues/50785#issuecomment-768606882)).
24 |
25 | ```ps
26 | dotnet build MySolution.sln --no-incremental /p:RunAnalyzersDuringBuild=true
27 | ```
28 |
29 | Our recommendation is to use it together with `TreatWarningsAsErrors` but do note that for code style analysis warnings you also have to specify `-warnaserror` (this is not needed for the other analyzers):
30 |
31 | ```ps
32 | dotnet build MySolution.sln --no-incremental -warnaserror /p:TreatWarningsAsErrors=true /p:RunAnalyzersDuringBuild=true
33 | ```
34 |
35 | Or if you only want to see the errors and not the full build output (including e.g. NuGet restores, build messages):
36 |
37 | ```ps
38 | dotnet build MySolution.sln --no-incremental -warnaserror /p:TreatWarningsAsErrors=true /p:RunAnalyzersDuringBuild=true -nologo -consoleLoggerParameters:NoSummary -verbosity:quiet
39 | ```
40 |
41 | > ⚠ If you are using the NuGet package, run `dotnet msbuild "-t:Restore;LombiqNetAnalyzers" MySolution.sln` first to ensure the _.editorconfig_ file is deployed. This is especially important for CI usage. For local development, you can simply rebuild the solution.
42 |
43 | ## Non-SDK-style .NET Framework projects
44 |
45 | Non-SDK-style .NET Framework projects can't use `dotnet build` for analyzer warnings to show during build, not just in Visual Studio, because it won't resolve `` elements (see [this issue](https://github.com/dotnet/msbuild/issues/5250)). You'll need to use the following command to achieve what's elaborated above for `dotnet build` (change the MSBuild path to a suitable one):
46 |
47 | ```ps
48 | & "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe" MySolution.sln /p:TreatWarningsAsErrors=true /p:RunAnalyzersDuringBuild=true /t:Rebuild /restore
49 | ```
50 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Docs/UsingAnalyzersDuringDevelopment.md:
--------------------------------------------------------------------------------
1 | # Using the analyzers during development
2 |
3 | ## Working with analyzers in Visual Studio or another IDE
4 |
5 | - Output of the analyzers will show up as entries of various levels (i.e. Errors, Warnings, Messages) in the Error List window of Visual Studio for the currently open files (the error codes will link to more info on the violations). You'll also see squiggly lines in the code editor as it is usual for any code issues.
6 | - For a lot of issues you'll be able to use automatic code fixes, or suppress them if they're wrong in the given context from the Visual Studio Quick Actions menu (Ctrl + . by default). The [Productivity Power Tools](https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.ProductivityPowerPack2022) Visual Studio extension can remove and order namespace imports, as well as format the document when saving (just enable its "Format document on save" option). [CodeMaid](https://marketplace.visualstudio.com/items?itemName=SteveCadwallader.CodeMaid) can similarly format whole projects or even the full solution at once. The command-line [`dotnet-format`](https://github.com/dotnet/format) can fix all issues that can be fixed automatically.
7 | - The _Build.props_ files disable analyzers during Visual Studio build, not to slow down development; you can enable them by setting `RunAnalyzersDuringBuild` to `true`. After this, they'll show for the whole solution after a rebuild (but not when you build an already built solution, just with a rebuild or a fresh build).
8 | - When working on reducing cognitive complexity to pass the [S3776 rule](https://rules.sonarsource.com/csharp/RSPEC-3776/) you can make use of the [CognitiveComplexity plugin for JetBrains Rider](https://plugins.jetbrains.com/plugin/12024-cognitivecomplexity) or the [ReSharper plugin of the same name](https://plugins.jetbrains.com/plugin/12391-cognitivecomplexity) for Visual Studio. It annotates the individual contributors to the cognitive complexity score so you can quickly identify trouble spots with the least effort. The scoring algorithm is not 100% identical to the one used in Sonar but it's similar enough to greatly speed up the task of refactoring complex methods.
9 | - The following VS extensions fit nicely into an analyzer-aided developer workflow:
10 | - [Rewrap](https://marketplace.visualstudio.com/items?itemName=stkb.Rewrap-18980) helps you wrap comment text at a character limit you can change in the settings. We recommend this to be set to 120.
11 | - [Editor Guidelines](https://marketplace.visualstudio.com/items?itemName=PaulHarrington.EditorGuidelinesPreview) displays the column guidelines defined in our editor config.
12 |
13 | ## Practices on suppressing a rule for a given piece of code
14 |
15 | This section is about suppressing analyzers for just certain lines of code or at most a class. On configuring analyzers for a wider scope, see [Configuring analyzers](ConfiguringAnalyzers.md)
16 |
17 | Analyzers are not perfect so they can give false positives, and there can always be justified exceptions to every rule, so suppressing analyzer warnings (as e.g. Visual Studio offers it, with and `SuppressMessage` attribute or with `#pragma warning disable`) is fine if done in moderation (if you have to do it a lot for a given rule then the rule is not suitable for your coding style). When doing so adhere to the following:
18 |
19 | - Always suppress a warning in the smallest scope possible.
20 | - Use the `#pragma` suppress for specific lines of code.
21 | - Only use the `SuppressMessage` attribute on a member (or even a whole project) if the suppress absolutely must cover the whole member or if it's for a method argument.
22 | - Always add a justification.
23 |
24 | Example where the `SuppressMessage` attribute is suitable (note how the suppression affects the whole type, and a justification is provided):
25 |
26 | ```c#
27 | [SuppressMessage(
28 | "Design",
29 | "CA1008:Enums should have zero value",
30 | Justification = "Since members correspond to specific numbers, we can't have a zero value.")]
31 | public enum Numbers
32 | {
33 | One = 1,
34 | Two = 2,
35 | Three = 3,
36 | }
37 | ```
38 |
39 | Example where the `#pragma` suppress is suitable (note how the suppression only affects the class declaration and a justifications is provided):
40 |
41 | ```c#
42 | // The extension method should follow the naming of the original class.
43 | #pragma warning disable S101 // Types should be named in PascalCase
44 | public static class RNGCryptoServiceProviderExtensions
45 | #pragma warning restore S101 // Types should be named in PascalCase
46 | {
47 | public static int Next(this RNGCryptoServiceProvider rng, int minValue, int maxValue)
48 | {
49 | // ...
50 | }
51 | }
52 | ```
53 |
54 | Fence the smallest possible code block with such `#pragma`s, but do fence the whole code block where it applies (i.e. not necessarily just the line where you get an analyzer violation, since certain analyzer rules may work with multiple lines). This is also necessary because otherwise you may get a "IDE0079 Remove unnecessary suppression" violation.
55 |
56 | For further details see the [official docs](https://docs.microsoft.com/en-us/visualstudio/code-quality/in-source-suppression-overview).
57 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers.NetFx/Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | $(OutputPath)
6 |
8 | bin
9 | $(DocumentationDir)/$(MSBuildProjectName).xml
10 |
11 | false
12 |
14 |
16 | 5.0
17 |
20 | AllEnabledByDefault
21 |
25 | false
26 |
29 | <_SkipUpgradeNetAnalyzersNuGetWarning>true
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 | all
45 | runtime; build; native; contentfiles; analyzers;
46 |
47 |
48 |
59 |
60 | all
61 | runtime; build; native; contentfiles; analyzers;
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md:
--------------------------------------------------------------------------------
1 | # Configuring analyzers
2 |
3 | This page is about configuring analyzers for at least a whole folder or project. On suppressing just single analyzer violations see the ["Using the analyzers during development" page](UsingAnalyzersDuringDevelopment.md). For further details see the [official docs](https://docs.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers).
4 |
5 | ## How to disable all analyzers for particular projects
6 |
7 | Place a _Directory.Build.props_ file into the project's folder (or folder with set of projects) with the following contents:
8 |
9 | ```xml
10 |
11 |
12 | ```
13 |
14 | MSBuild only loads in the closest _Directory.Build.props_ file to the project being built. So this empty props file will supersede any parent _Directory.Build.props_. To also disable .NET SDK analysis override them from a _.globalconfig_ file placed into the given project's folder. There you can disable any unwanted rules, like disabling .NET code style analysis completely:
15 |
16 | ```editorconfig
17 | dotnet_analyzer_diagnostic.category-Style.severity = none
18 | ```
19 |
20 | If you rely on `Lombiq.Analyzers` to set up compiler properties such as `` you may still want to import the parent _Directory.Build.props_ file and just disable the code analyzers. Put this into the _Directory.Build.props_ file instead:
21 |
22 | ```xml
23 |
24 |
25 | false
26 |
27 |
28 |
29 |
30 | ```
31 |
32 | Or if you added `Lombiq.Analyzers` to only a single project as a package reference, you can just add the `false` element.
33 |
34 | ## How to disable all analyzers during `dotnet build`
35 |
36 | By default the `dotnet build` command runs analyzers and produces code analysis warnings if there are any but it makes the build slower. Pass the `/p:RunCodeAnalysis=false` parameter to disable analyzers during build, like:
37 |
38 | ```ps
39 | dotnet build MySolution.sln /p:RunCodeAnalysis=false
40 | ```
41 |
42 | ## How to override analyzer configuration globally
43 |
44 | If not all the configuration in this project is suitable for your solution then you can also override them globally. This way, the default configuration will be merged with your custom configuration and you can override any number of rules conveniently at one place for all projects in your solution.
45 |
46 | ### Overriding analyzer configuration from a _.globalconfig_ file
47 |
48 | 1. Create your own _.globalconfig_ file with your own rule configuration, similar to this project's _.globalconfig_ files (see [the official docs on this file format](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig)).
49 | 2. Place the file into the folder under which you want the configuration to apply to all projects.
50 | 3. Now every rule you've configured in your _.globalconfig_ file will take precedence over the default ones. For everything else, the default ones will be applied.
51 |
52 | Note that if you add your _.globalconfig_ file to the solution you'll get GUI support for it in Visual Studio and you'll be able to configure rules without manually editing the configuration text.
53 |
54 | More complex configuration is also available:
55 |
56 | - You can similarly add such _.globalconfig_ files to subfolders, to just override rules for projects in that folder.
57 | - Such files can be placed outside of the folder hierarchy too and referenced from csproj or props files with the `` element, see [the docs](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#naming).
58 | - You can further adjust the precedence of _.globalconfig_ files with their names and the `global_level` entry, see [the docs](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#precedence).
59 |
60 | ### Suppressing analyzers from code for a whole project
61 |
62 | You can suppress specific analyzer rules for a whole project from code as well. Add a _GlobalSuppressions.cs_ file to your project, add `SuppressMessage` attributes to it like below:
63 |
64 | ```csharp
65 | // This file is used by Code Analysis to maintain SuppressMessage attributes that are applied to this project.
66 | // Project-level suppressions either have no target or are given a specific target and scoped to a namespace, type,
67 | // member, etc.
68 |
69 | using System.Diagnostics.CodeAnalysis;
70 |
71 | [assembly: SuppressMessage(
72 | "Minor Code Smell",
73 | "S1199:Nested code blocks should not be used",
74 | Justification = "UI tests commonly have small inner blocks for managing one-off elements like dropdowns.",
75 | Scope = "module")]
76 | ```
77 |
78 | ### Overriding _.editorconfig_ rules
79 |
80 | You can't as easily do the same as with _.globalconfig_ files with _.editorconfig_ rules. [It's not possible to define explicit inheritance between _.editorconfig_ files](https://github.com/editorconfig/editorconfig/issues/236) so [the only option is to use the folder hierarchy](https://stackoverflow.com/questions/58543855/can-visual-studio-use-an-editorconfig-not-in-the-directory-hierarchy/58556556#58556556): The _Build.props_ files of this project copy the default _.editorconfig_ file into the solution root. If you put your projects below that in the folder hierarchy and use your own _.editorconfig_ there then the latter will take precedence and you can override the default rules. E.g. you can override certain analyzer rules for a whole folder (even a folder within a project) like this:
81 |
82 | ```editorconfig
83 | [*.{config,csproj,json,props,targets}]
84 |
85 | indent_size = 4
86 | ```
87 |
88 | ### Overriding _stylecop.json_ and _SonarLint.xml_ configuration
89 |
90 | The project includes further configuration for `StyleCop.Analyzers` and `SonarAnalyzer.CSharp` in their own formats. These files are referenced as `` elements in the _props_ files corresponding to .NET Core or later and .NET Framework. From your own _Directory.Build.props_ file you need to recreate the contents of the original _props_ file but reference your custom configuration file instead.
91 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
7 | false
8 |
11 |
12 |
13 | strict
14 |
15 | 12.0
16 |
18 | 8.0
19 |
24 | AllEnabledByDefault
25 |
28 | <_SkipUpgradeNetAnalyzersNuGetWarning>true
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
40 |
41 | all
42 | runtime; build; native; contentfiles; analyzers;
43 |
44 |
45 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
80 |
81 |
82 |
83 |
89 |
90 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # Lombiq .NET Analyzers
2 |
3 | [](https://www.nuget.org/packages/Lombiq.Analyzers/) [](https://www.nuget.org/packages/Lombiq.Analyzers.NetFx/) [](https://www.nuget.org/packages/Lombiq.Analyzers.OrchardCore/) [](https://www.nuget.org/packages/Lombiq.Analyzers.Orchard1/) [](https://www.nuget.org/packages/Lombiq.Analyzers.VisualStudioExtension/)
4 |
5 | ## About
6 |
7 | .NET code analyzers and code convention settings for [Lombiq](https://lombiq.com) projects, for [Orchard Core](https://orchardcore.net/) and any other .NET and .NET Framework apps. We use these to enforce common standards across all our .NET projects, including e.g. all of our [open-source Orchard Core extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions). If you contribute to our open-source projects while using that solution you'll be guided by these rules, too. You can check out a demo video of the project [here](https://www.youtube.com/watch?v=dtbGRi3Cezs), and the Orchard Harvest 2023 conference talk about automated QA in Orchard Core [here](https://youtu.be/CHdhwD2NHBU).
8 |
9 | There is also support for non-SDK-style .NET Framework projects, as long as they use `PackageReference` for their dependencies (in contrast to _packages.config_).
10 |
11 | Some other projects you may be interested in:
12 |
13 | - Looking for something similar for JavaScript and SCSS? Check out the ESLint and Stylelint integrations of our [Node.js Extensions project](https://github.com/Lombiq/NodeJs-Extensions).
14 | - Looking not just for static code analysis but also dynamic testing? Check out our [UI Testing Toolbox](https://github.com/Lombiq/UI-Testing-Toolbox) and [Testing Toolbox](https://github.com/Lombiq/Testing-Toolbox) projects.
15 | - Looking for a library that'll help you comply with analyzer rules? Check out our [Helpful Libraries project](https://github.com/Lombiq/Helpful-Libraries).
16 |
17 | We at [Lombiq](https://lombiq.com/) also used this module for the following projects:
18 |
19 | - The new [City of Santa Monica website](https://santamonica.gov/) when migrating it from Orchard 1 to Orchard Core ([see case study](https://lombiq.com/blog/helping-the-city-of-santa-monica-with-orchard-core-consulting)).
20 | - The new [Smithsonian Folkways Recordings website](https://folkways.si.edu/) when migrating it from Orchard 1 to Orchard Core ([see case study](https://lombiq.com/blog/smithsonian-folkways-recordings-now-upgraded-to-orchard-core)).
21 | - The new [Lombiq website](https://lombiq.com/) when migrating it from Orchard 1 to Orchard Core ([see case study](https://lombiq.com/blog/how-we-renewed-and-migrated-lombiq-com-from-orchard-1-to-orchard-core)).
22 | - The new client portal for [WTW](https://www.wtwco.com/) ([see case study](https://lombiq.com/blog/lombiq-s-journey-with-wtw-s-client-portal)).
23 | - It also makes [DotNest, the Orchard SaaS](https://dotnest.com/) better.
24 |
25 | Do you want to quickly try out this project and see it in action? Check it out in our [Open-Source Orchard Core Extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions) full Orchard Core solution and also see our other useful Orchard Core-related open-source projects!
26 |
27 | ## Analyzer packages used
28 |
29 | We added and configured analyzers which are widely used and complement each other.
30 |
31 | - [.NET code style analysis](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview#code-style-analysis)
32 | - [.NET code quality analysis](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview#code-quality-analysis)
33 | - [AsyncFixer](https://www.nuget.org/packages/AsyncFixer)
34 | - [DotNetAnalyzers.DocumentationAnalyzers](https://www.nuget.org/packages/DotNetAnalyzers.DocumentationAnalyzers/)
35 | - [Meziantou.Analyzer](https://www.nuget.org/packages/Meziantou.Analyzer/)
36 | - [Microsoft.CodeAnalysis.NetAnalyzers](https://www.nuget.org/packages/Microsoft.CodeAnalysis.NetAnalyzers)
37 | - [Microsoft.VisualStudio.Threading.Analyzers](https://www.nuget.org/packages/microsoft.visualstudio.threading.analyzers)
38 | - [SecurityCodeScan.VS2019](https://www.nuget.org/packages/SecurityCodeScan.VS2019/)
39 | - [StyleCop.Analyzers](https://www.nuget.org/packages/StyleCop.Analyzers/)
40 | - [SonarAnalyzer.CSharp](https://www.nuget.org/packages/SonarAnalyzer.CSharp/)
41 |
42 | Furthermore, the project also includes an _.editorconfig_ file with additional configuration for compatible editors.
43 |
44 | ## Guides
45 |
46 | - [Adding analyzers to your project](Lombiq.Analyzers/Docs/AddingAnalyzers.md)
47 | - [Using the analyzers during development](Lombiq.Analyzers/Docs/UsingAnalyzersDuringDevelopment.md)
48 | - [Using the analyzers during command line builds](Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md)
49 | - [Configuring analyzers](Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md)
50 |
51 | ## Contributing and support
52 |
53 | Bug reports, feature requests, comments, questions, code contributions and love letters are warmly welcome. You can send them to us via GitHub issues and pull requests. Please adhere to our [open-source guidelines](https://lombiq.com/open-source-guidelines) while doing so.
54 |
55 | This project is developed by [Lombiq Technologies](https://lombiq.com/). Commercial-grade support is available through Lombiq.
56 |
57 | ### Publishing a new NuGet package
58 |
59 | When publishing a new version of the NuGet package, even if it's just a pre-release, also update the package references under _TestSolutions\Lombiq.Analyzers.PackageReferences_ to the new version. This is necessary to run the tests there.
60 |
61 | ### Upgrading to a new version of the .NET SDK
62 |
63 | When a new version of the .NET SDK comes out then to the following:
64 |
65 | - Change the `LangVersion` and `AnalysisLevel` elements in the _Build.props_ file to opt in to new language features and analyzers. This does not concern non-SDK-style .NET Framework projects.
66 | - Wait for all analyzers to support the new SDK (primarily the new language features). Then update all packages to latest.
67 | - Check if there are new [code analysis categories](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/categories) that we need to surface warnings for by default in the _Lombiq.Analyzers.globalconfig_ file.
68 |
69 | ### Adding a new analyzer
70 |
71 | When adding a new analyzer package, do the following:
72 |
73 | - Check if the project is actively developed with issues addressed quickly.
74 | - Check if it has any significant impact on build or editing performance.
75 | - Go through all rules in the package and decide one by one whether we need them.
76 | - Check for rules that are already covered by some other analyzer and disable duplicates.
77 | - All rules that we need should be surfaced as Warnings. This allows to only break the build on analyzer violations when we need it, i.e. during CI builds but not during development.
78 | - Add rule configuration to the _.globalconfig_ file of the relevant project, depending on which kind of applications they're applicable to. Editor-only configuration should be in _.editorconfig_ files.
79 | - Test it on multiple significant solutions. Using the [Hastlayer SDK](https://github.com/Lombiq/Hastlayer-SDK) is a good example as it's a large C# solution.
80 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Docs/AddingAnalyzers.md:
--------------------------------------------------------------------------------
1 | # Adding analyzers to your project
2 |
3 | ## Selecting which analyzer project/package to use
4 |
5 | Lombiq .NET Analyzers is split into multiple projects/packages so you can select the one most suitable for your application. Depending on your use case, select one of the following:
6 |
7 | - [`Lombiq.Analyzers`](../Readme.md): General .NET projects.
8 | - [`Lombiq.Analyzers.NetFx`](../../Lombiq.Analyzers.NetFx/Readme.md): General .NET Framework projects.
9 | - [`Lombiq.Analyzers.OrchardCore`](../../Lombiq.Analyzers.OrchardCore/Readme.md): [Orchard Core](https://orchardcore.net/) projects.
10 | - [`Lombiq.Analyzers.Orchard1`](../../Lombiq.Analyzers.Orchard1/Readme.md): [Orchard 1](https://orchardcore.net/orchardcms) projects.
11 | - [`Lombiq.Analyzers.VisualStudioExtension`](../../Lombiq.Analyzers.VisualStudioExtension/Readme.md): Visual Studio extension projects.
12 |
13 | You only need to reference a single project; e.g., even though Orchard Core apps are also .NET apps, you only need to use `Lombiq.Analyzers.OrchardCore` for them.
14 |
15 | ## How to add the analyzers to SDK-style projects from NuGet
16 |
17 | If you don't want to stay on the cutting-edge version, nor do you intend to contribute to Lombiq .NET Analyzers, you can use one of the NuGet packages. Install the package suitable for your project, as described above. Check for the latest version number [on NuGet](https://www.nuget.org/packages/Lombiq.Analyzers/).
18 |
19 | ```csproj
20 |
21 | all
22 |
23 | ```
24 |
25 | The `all` is necessary to prevent the analyzers "leaking" into other projects that may consume yours.
26 |
27 | You can also add the package to all projects inside a folder at once [from a _Directory.Build.props_ file](https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build).
28 |
29 | ## How to add the analyzers to SDK-style projects from a Git submodule
30 |
31 | Use this approach if you always want to use the very latest version, or if you'd like to contribute to Lombiq .NET Analyzers.
32 |
33 | 1. Add to the following to the _.gitmodules_ file (we use the _tools_ subfolder for the submodule's folder here but feel free to use something else):
34 |
35 | ```gitmodules
36 | [submodule "Lombiq.Analyzers"]
37 | path = tools/Lombiq.Analyzers
38 | url = https://github.com/Lombiq/.NET-Analyzers.git
39 | branch = dev
40 | ```
41 |
42 | _`path` can target anything but we suggest either the folder where the solution `.sln` file is located (mostly the repository root) or a "tools" subfolder therein._
43 | 2. Create a _Directory.Build.props_ file in the folder where the solution _.sln_ file is located (mostly the repository root) with the following content, referencing the analyzer project you selected above (if you've put the submodule into a different folder then change the path):
44 |
45 | ```xml
46 |
47 |
48 |
49 | ```
50 |
51 | 3. Since the project's _.editorconfig_ file will be copied into your solution's root you may want to gitignore it:
52 |
53 | ```gitignore
54 | /.editorconfig
55 | ```
56 |
57 | For at least Visual Studio and JetBrains Rider you don't need any further setup for IDE support. For [OmniSharp-integrated editors](http://www.omnisharp.net/#integrations) like Visual Studio Code you'll also need to add an _omnisharp.json_ file to the root of the solution:
58 |
59 | ```json
60 | {
61 | "RoslynExtensionsOptions": {
62 | "enableAnalyzersSupport": true
63 | },
64 | "FormattingOptions": {
65 | "enableEditorConfigSupport": true
66 | }
67 | }
68 | ```
69 |
70 | ## How to add the analyzers to individual non-SDK-style .NET Framework projects (not solutions)
71 |
72 | The key difference compared to .NET projects is that for non-SDK-style .NET Framework projects, you need to add Lombiq .NET Analyzers to each project.
73 |
74 | 1. Same as above - add the .NET-Analyzers repository as a Git submodule to your repository or add the NuGet package in the next step.
75 | 2. Create a _Directory.Build.props_ file in a common root folder of your projects, or in every project folder you want to target, next to the _.csproj_ file with the following content, either referencing `Lombiq.Analyzers.NetFx` or `Lombiq.Analyzers.Orchard1`:
76 |
77 | ```csproj
78 |
79 | all
80 |
81 | ```
82 |
83 | Or if you're using a Git submodule (adjust the relative path as suitable):
84 |
85 | ```xml
86 |
87 |
88 |
89 | ```
90 |
91 | If you do this for multiple projects, it's recommended to add your own central props file (like _Analyzers.Build.props_) where you do the above and import that in each project instead.
92 |
93 | 3. _Build.props_ will copy this project's _.editorconfig_ file into every project folder that you've created a _Directory.Build.props_ in, so you might want to gitignore those:
94 |
95 | ```gitignore
96 | .editorconfig
97 | ```
98 |
99 | ## Introducing analyzers to an existing project
100 |
101 | What to do if you're not starting a green-field project but want to add analyzers to an existing (large) project?
102 |
103 | 1. Fix any existing build warnings. Analyzer violations will be surfaced as warnings so it's best to fix build warnings first.
104 | 2. Enable `TreatWarningsAsErrors` [in CI/CD builds](UsingAnalyzersDuringCommandLineBuilds.md) to make sure you don't introduce more warnings. Or alternatively, at least you can enable `TreatWarningsAsErrors` for all projects so during local build it'll fail on any violation. You can do this from the same _Directory.Build.props_ file by adding the following:
105 |
106 | ```xml
107 |
108 | true
109 |
110 | ```
111 |
112 | 3. .NET compatibility:
113 | - .NET Core and .NET 5 or later projects can use this without anything special.
114 | - .NET Framework projects:
115 | - Projects using the new SDK-style csproj format don't need anything special. You [can convert projects manually](https://docs.microsoft.com/en-us/dotnet/core/porting/#per-project-steps) from the non-SDK-style csproj format or automatically with the [try-convert](https://github.com/dotnet/try-convert) utility. You'll also need to manually remove any leftover _packages.config_ files and adjust _NuGet.config_ files.
116 | - Projects using the legacy, non-SDK-style csproj format should use `Lombiq.Analyzers.NetFx` as described above, but the including project needs to use `PackageReference`s. You can convert your _packages.config_-based project to `PackageReference`s using [this walkthrough](https://docs.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference).
117 | 4. Now you can add this project to yours as explained above.
118 | 5. Introduce analyzers gradually unless it's a small project and you can fix every analyzer violation at once. To do this, only enable a handful of analyzers first (or enable them just for a couple of projects in a given solution), fix the violations, get used to them, then enable more later. See [the docs on configuring analyzers](ConfiguringAnalyzers.md) for how to do disable certain analyzers of the default configuration and thus activating analyzers in your code base gradually. We recommend enabling analyzers and fixing violations in at least three stages:
119 | 1. All the simpler rules, i.e. all rules except the ones in the next steps (that means, if you're working with the default configuration, to disable the rules mentioned in the next steps). These are quite straightforward to fix, to an extent can be done even automatically with individual code fixes and [`dotnet format`](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-format). It's the best if you group warnings by code in the Error List and fix them one by one, committing to the repository after completing each. It's better to batch this work in a way that you fix a particular type of warning for all projects of a solution at once, as opposed to fixing multiple type of warnings for just selected projects. This is because it's more efficient to just repeat the same kind of fix for all projects (can sometimes even be done automatically) in one go instead of revisiting it in multiple iterations. For tips on how to make fixing violations easier see [this page](UsingAnalyzersDuringDevelopment.md).
120 | 2. "[SA1600 Elements should be documented](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1600.md)": This will require adding documentation to all interfaces. This and the next step can also be done individually for specific projects, so just have them enabled for certain projects, since these benefit much less from being done in bulk for the whole solution.
121 | 3. "[S107 Methods should not have too many parameters](https://rules.sonarsource.com/csharp/RSPEC-107/)", "[S134 Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply](https://rules.sonarsource.com/csharp/RSPEC-107/)" and "[S3776 Cognitive Complexity of functions should not be too high](https://rules.sonarsource.com/csharp/RSPEC-3776/)": These analyzer rules will require deeper refactoring of the code base. They're all worth it though.
122 |
--------------------------------------------------------------------------------
/Lombiq.Analyzers/Lombiq.Analyzers.globalconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | global_level = 0
3 |
4 | # General code analysis rules for any .NET and .NET Framework project.
5 |
6 | # To get Visual Studio GUI support for configuring these rules, put it into the solution's startup project's folder and
7 | # rename it to .editorconfig. This should eventually not be necessary, see https://github.com/dotnet/roslyn/issues/70326.
8 |
9 | # Start code style preferences
10 |
11 | # Check out possible configs here:
12 | # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
13 |
14 | # Organize usings
15 | dotnet_separate_import_directive_groups = false
16 | dotnet_sort_system_directives_first = false
17 |
18 | # this. and Me. preferences
19 | dotnet_style_qualification_for_event = false:warning
20 | dotnet_style_qualification_for_field = false:warning
21 | dotnet_style_qualification_for_method = false:warning
22 | dotnet_style_qualification_for_property = false:warning
23 |
24 | # Language keywords vs BCL types preferences
25 | dotnet_style_predefined_type_for_locals_parameters_members = true:warning
26 | dotnet_style_predefined_type_for_member_access = true:warning
27 |
28 | # Parentheses preferences
29 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
30 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
31 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
32 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
33 |
34 | # Modifier preferences
35 | dotnet_style_require_accessibility_modifiers = always:warning
36 |
37 | # Expression-level preferences
38 | dotnet_style_coalesce_expression = true:warning
39 | dotnet_style_collection_initializer = true:warning
40 | dotnet_style_explicit_tuple_names = true:warning
41 | dotnet_style_null_propagation = true:warning
42 | dotnet_style_object_initializer = true:warning
43 | dotnet_style_operator_placement_when_wrapping = beginning_of_line
44 | dotnet_style_prefer_auto_properties = true:warning
45 | dotnet_style_prefer_compound_assignment = true:warning
46 | dotnet_style_prefer_conditional_expression_over_assignment = true:warning
47 | dotnet_style_prefer_conditional_expression_over_return = false
48 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
49 | dotnet_style_prefer_inferred_tuple_names = true:warning
50 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
51 | dotnet_style_prefer_simplified_interpolation = true:warning
52 |
53 | # Field preferences
54 | dotnet_style_readonly_field = true:warning
55 |
56 | # Parameter preferences
57 | dotnet_code_quality_unused_parameters = non_pubic:suggestion
58 |
59 | # Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced
60 | # during build, see: https://github.com/dotnet/roslyn/issues/44201.
61 |
62 | # Default severity for analyzer diagnostics for all categories (escalated to build warnings). See
63 | # https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/categories for the list of categories.
64 | dotnet_analyzer_diagnostic.category-Design.severity = warning
65 | dotnet_analyzer_diagnostic.category-Documentation.severity = warning
66 | dotnet_analyzer_diagnostic.category-Globalization.severity = warning
67 | dotnet_analyzer_diagnostic.category-Interoperability.severity = warning
68 | dotnet_analyzer_diagnostic.category-Maintainability.severity = warning
69 | dotnet_analyzer_diagnostic.category-Naming.severity = warning
70 | dotnet_analyzer_diagnostic.category-Performance.severity = warning
71 | dotnet_analyzer_diagnostic.category-SingleFile.severity = warning
72 | dotnet_analyzer_diagnostic.category-Reliability.severity = warning
73 | dotnet_analyzer_diagnostic.category-Security.severity = warning
74 | dotnet_analyzer_diagnostic.category-Style.severity = warning
75 | dotnet_analyzer_diagnostic.category-Usage.severity = warning
76 | dotnet_analyzer_diagnostic.category-CodeQuality.severity = warning
77 |
78 | # IDE0011: Add braces to 'if' statement.
79 | # The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn
80 | # this off completely, see: https://github.com/dotnet/roslyn/issues/40912.
81 | dotnet_diagnostic.IDE0011.severity = none
82 | # IDE0050: Convert to tuple
83 | # Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and
84 | # those can fail on this silently in runtime while building correctly.
85 | dotnet_diagnostic.IDE0050.severity = none
86 | # IDE0052: Private member can be removed as the value assigned to it is never used.
87 | # We use S4487 for that.
88 | dotnet_diagnostic.IDE0052.severity = none
89 | # IDE0072: Populate switch
90 | # Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876.
91 | dotnet_diagnostic.IDE0072.severity = none
92 | # "Namespace 'Foo' does not match folder structure, expected 'Foo'"
93 | dotnet_diagnostic.IDE0130.severity = none
94 |
95 | # While these are in the Style category, they need to be explicitly set for some reason.
96 | # IDE0079 Remove unnecessary suppression
97 | dotnet_diagnostic.IDE0079.severity = warning
98 | dotnet_diagnostic.IDE0022.severity = warning
99 | # IDE0290 Use Primary Constructors
100 | dotnet_diagnostic.IDE0290.severity = none
101 |
102 | # 'var' preferences
103 | dotnet_diagnostic.IDE0007.severity = warning
104 | dotnet_diagnostic.IDE0008.severity = none
105 | # These won't take effect during build due to this bug: https://github.com/dotnet/roslyn/issues/44250.
106 | csharp_style_var_elsewhere = true:warning
107 | # If this is not turned off then there will be messages for e.g. integers too, like in for loops.
108 | csharp_style_var_for_built_in_types = false:none
109 | csharp_style_var_when_type_is_apparent = true:warning
110 |
111 | # Expression-bodied members
112 | csharp_style_expression_bodied_accessors = true:warning
113 | csharp_style_expression_bodied_constructors = true:warning
114 | csharp_style_expression_bodied_indexers = true:warning
115 | csharp_style_expression_bodied_lambdas = true:warning
116 | csharp_style_expression_bodied_local_functions = true:warning
117 | csharp_style_expression_bodied_methods = true:warning
118 | csharp_style_expression_bodied_operators = true:warning
119 | csharp_style_expression_bodied_properties = true:warning
120 |
121 | # Pattern matching preferences
122 | csharp_style_pattern_matching_over_as_with_null_check = true:warning
123 | csharp_style_pattern_matching_over_is_with_cast_check = true:warning
124 | csharp_style_prefer_switch_expression = true:warning
125 |
126 | # Null-checking preferences
127 | csharp_style_conditional_delegate_call = true:warning
128 |
129 | # Modifier preferences
130 | csharp_prefer_static_local_function = true:warning
131 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
132 |
133 | # Code-block preferences
134 | csharp_prefer_simple_using_statement = true:warning
135 | # IDE0160: Convert to block-scoped namespace
136 | csharp_style_namespace_declarations = file_scoped:warning
137 |
138 | # Expression-level preferences
139 | csharp_prefer_simple_default_expression = true:warning
140 | csharp_style_deconstructed_variable_declaration = false:silent
141 | csharp_style_inlined_variable_declaration = true:warning
142 | csharp_style_pattern_local_over_anonymous_function = true:warning
143 | csharp_style_prefer_index_operator = true:warning
144 | csharp_style_prefer_range_operator = true:warning
145 | csharp_style_throw_expression = true:warning
146 | csharp_style_unused_value_assignment_preference = discard_variable:suggestion
147 | csharp_style_unused_value_expression_statement_preference = discard_variable:none
148 |
149 | # 'using' directive preferences
150 | csharp_using_directive_placement = outside_namespace:silent
151 |
152 | # New line preferences
153 | csharp_new_line_before_catch = true
154 | csharp_new_line_before_else = true
155 | csharp_new_line_before_finally = true
156 | csharp_new_line_before_members_in_anonymous_types = true
157 | csharp_new_line_before_members_in_object_initializers = true
158 | csharp_new_line_before_open_brace = all
159 | csharp_new_line_between_query_expression_clauses = true
160 |
161 | # Indentation preferences
162 | csharp_indent_block_contents = true
163 | csharp_indent_braces = false
164 | csharp_indent_case_contents = true
165 | csharp_indent_case_contents_when_block = true
166 | csharp_indent_labels = no_change
167 | csharp_indent_switch_labels = true
168 |
169 | # Space preferences
170 | csharp_space_after_cast = false
171 | csharp_space_after_colon_in_inheritance_clause = true
172 | csharp_space_after_comma = true
173 | csharp_space_after_dot = false
174 | csharp_space_after_keywords_in_control_flow_statements = true
175 | csharp_space_after_semicolon_in_for_statement = true
176 | csharp_space_around_binary_operators = before_and_after
177 | csharp_space_around_declaration_statements = false
178 | csharp_space_before_colon_in_inheritance_clause = true
179 | csharp_space_before_comma = false
180 | csharp_space_before_dot = false
181 | csharp_space_before_open_square_brackets = false
182 | csharp_space_before_semicolon_in_for_statement = false
183 | csharp_space_between_empty_square_brackets = false
184 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
185 | csharp_space_between_method_call_name_and_opening_parenthesis = false
186 | csharp_space_between_method_call_parameter_list_parentheses = false
187 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
188 | csharp_space_between_method_declaration_name_and_open_parenthesis = false
189 | csharp_space_between_method_declaration_parameter_list_parentheses = false
190 | csharp_space_between_parentheses = false
191 | csharp_space_between_square_brackets = false
192 |
193 | # Wrapping preferences
194 | csharp_preserve_single_line_blocks = true
195 | csharp_preserve_single_line_statements = true
196 |
197 | # Naming rules
198 | dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
199 | dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
200 | dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
201 |
202 | dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
203 | dotnet_naming_rule.types_should_be_pascal_case.symbols = types
204 | dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
205 |
206 | dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
207 | dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
208 | dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
209 |
210 | # Symbol specifications
211 | dotnet_naming_symbols.interface.applicable_kinds = interface
212 | dotnet_naming_symbols.interface.applicable_accessibilities = *
213 | dotnet_naming_symbols.interface.required_modifiers =
214 |
215 | dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
216 | dotnet_naming_symbols.types.applicable_accessibilities = *
217 | dotnet_naming_symbols.types.required_modifiers =
218 |
219 | dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
220 | dotnet_naming_symbols.non_field_members.applicable_accessibilities = *
221 | dotnet_naming_symbols.non_field_members.required_modifiers =
222 |
223 | # Naming styles
224 | dotnet_naming_style.pascal_case.required_prefix =
225 | dotnet_naming_style.pascal_case.required_suffix =
226 | dotnet_naming_style.pascal_case.word_separator =
227 | dotnet_naming_style.pascal_case.capitalization = pascal_case
228 |
229 | dotnet_naming_style.begins_with_i.required_prefix = I
230 | dotnet_naming_style.begins_with_i.required_suffix =
231 | dotnet_naming_style.begins_with_i.word_separator =
232 | dotnet_naming_style.begins_with_i.capitalization = pascal_case
233 |
234 | # Don't apply "CA1822: Mark members as static" to the public API
235 | dotnet_code_quality.CA1822.api_surface = private, internal
236 | csharp_prefer_braces = true:silent
237 |
238 | # End code style preferences
239 |
240 | # DotNetAnalyzers.DocumentationAnalyzers rules
241 | dotnet_diagnostic.DOC100.severity = warning
242 | dotnet_diagnostic.DOC101.severity = warning
243 | dotnet_diagnostic.DOC102.severity = warning
244 | dotnet_diagnostic.DOC103.severity = warning
245 | dotnet_diagnostic.DOC104.severity = warning
246 | dotnet_diagnostic.DOC105.severity = warning
247 | dotnet_diagnostic.DOC106.severity = warning
248 | dotnet_diagnostic.DOC107.severity = warning
249 | dotnet_diagnostic.DOC108.severity = warning
250 | dotnet_diagnostic.DOC200.severity = warning
251 | dotnet_diagnostic.DOC201.severity = warning
252 | dotnet_diagnostic.DOC202.severity = warning
253 | dotnet_diagnostic.DOC203.severity = warning
254 | dotnet_diagnostic.DOC204.severity = warning
255 |
256 | # Microsoft.CodeAnalysis.CSharp rules
257 | dotnet_diagnostic.CS1573.severity = none
258 | # We don't want to decorate every public member with XML comments, only public APIs - so turn CS1591 off.
259 | # CS1591 Missing XML Comment for publicly visible type or member
260 | dotnet_diagnostic.CS1591.severity = none
261 |
262 | # Microsoft.CodeAnalysis.NetAnalyzers rules
263 | dotnet_diagnostic.CA1000.severity = warning
264 | dotnet_diagnostic.CA1001.severity = warning
265 | dotnet_diagnostic.CA1002.severity = silent
266 | dotnet_diagnostic.CA1008.severity = warning
267 | dotnet_diagnostic.CA1010.severity = warning
268 | dotnet_diagnostic.CA1012.severity = warning
269 | dotnet_diagnostic.CA1016.severity = warning
270 | dotnet_diagnostic.CA1018.severity = warning
271 | dotnet_diagnostic.CA1024.severity = warning
272 | dotnet_diagnostic.CA1027.severity = warning
273 | dotnet_diagnostic.CA1028.severity = warning
274 | dotnet_diagnostic.CA1030.severity = warning
275 | # Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive.
276 | dotnet_diagnostic.CA1031.severity = silent
277 | dotnet_diagnostic.CA1032.severity = warning
278 | dotnet_diagnostic.CA1033.severity = warning
279 | # Disabling "do not nest type" suggestion.
280 | dotnet_diagnostic.CA1034.severity = silent
281 | dotnet_diagnostic.CA1036.severity = warning
282 | dotnet_diagnostic.CA1041.severity = warning
283 | dotnet_diagnostic.CA1043.severity = silent
284 | dotnet_diagnostic.CA1044.severity = warning
285 | dotnet_diagnostic.CA1050.severity = warning
286 | dotnet_diagnostic.CA1051.severity = silent
287 | dotnet_diagnostic.CA1052.severity = warning
288 | dotnet_diagnostic.CA1054.severity = silent
289 | dotnet_diagnostic.CA1055.severity = warning
290 | dotnet_diagnostic.CA1056.severity = silent
291 | dotnet_diagnostic.CA1058.severity = warning
292 | dotnet_diagnostic.CA1061.severity = warning
293 | dotnet_diagnostic.CA1063.severity = warning
294 | dotnet_diagnostic.CA1064.severity = warning
295 | dotnet_diagnostic.CA1065.severity = warning
296 | dotnet_diagnostic.CA1066.severity = warning
297 | dotnet_diagnostic.CA1067.severity = warning
298 | dotnet_diagnostic.CA1068.severity = warning
299 | dotnet_diagnostic.CA1069.severity = warning
300 | dotnet_diagnostic.CA1070.severity = warning
301 | dotnet_diagnostic.CA1200.severity = warning
302 | dotnet_diagnostic.CA1304.severity = warning
303 | dotnet_diagnostic.CA1305.severity = warning
304 | dotnet_diagnostic.CA1307.severity = silent
305 | dotnet_diagnostic.CA1308.severity = warning
306 | dotnet_diagnostic.CA1309.severity = warning
307 | dotnet_diagnostic.CA1310.severity = warning
308 | dotnet_diagnostic.CA1401.severity = warning
309 | dotnet_diagnostic.CA1507.severity = warning
310 | dotnet_diagnostic.CA1508.severity = silent
311 | dotnet_diagnostic.CA1712.severity = warning
312 | dotnet_diagnostic.CA1713.severity = warning
313 | dotnet_diagnostic.CA1715.severity = warning
314 | dotnet_diagnostic.CA1720.severity = warning
315 | dotnet_diagnostic.CA1721.severity = warning
316 | dotnet_diagnostic.CA1801.severity = warning
317 | dotnet_diagnostic.CA1802.severity = warning
318 | dotnet_diagnostic.CA1805.severity = warning
319 | dotnet_diagnostic.CA1806.severity = warning
320 | # Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead.
321 | dotnet_diagnostic.CA1810.severity = none
322 | dotnet_diagnostic.CA1813.severity = warning
323 | dotnet_diagnostic.CA1814.severity = warning
324 | dotnet_diagnostic.CA1815.severity = warning
325 | dotnet_diagnostic.CA1816.severity = warning
326 | dotnet_diagnostic.CA1820.severity = warning
327 | dotnet_diagnostic.CA1821.severity = warning
328 | dotnet_diagnostic.CA1822.severity = warning
329 | dotnet_diagnostic.CA1823.severity = warning
330 | dotnet_diagnostic.CA1824.severity = warning
331 | dotnet_diagnostic.CA1825.severity = warning
332 | dotnet_diagnostic.CA1826.severity = none
333 | dotnet_diagnostic.CA1827.severity = none
334 | dotnet_diagnostic.CA1828.severity = warning
335 | dotnet_diagnostic.CA1829.severity = warning
336 | dotnet_diagnostic.CA1830.severity = warning
337 | dotnet_diagnostic.CA1832.severity = warning
338 | dotnet_diagnostic.CA1833.severity = warning
339 | dotnet_diagnostic.CA1834.severity = warning
340 | dotnet_diagnostic.CA1835.severity = warning
341 | dotnet_diagnostic.CA1836.severity = warning
342 | dotnet_diagnostic.CA1837.severity = warning
343 | dotnet_diagnostic.CA1838.severity = warning
344 | dotnet_diagnostic.CA1851.severity = warning
345 | dotnet_diagnostic.CA2000.severity = warning
346 | dotnet_diagnostic.CA2002.severity = warning
347 | dotnet_diagnostic.CA2007.severity = warning
348 | dotnet_diagnostic.CA2008.severity = warning
349 | dotnet_diagnostic.CA2009.severity = warning
350 | dotnet_diagnostic.CA2011.severity = warning
351 | dotnet_diagnostic.CA2012.severity = warning
352 | dotnet_diagnostic.CA2016.severity = none
353 | dotnet_diagnostic.CA2100.severity = warning
354 | dotnet_diagnostic.CA2101.severity = warning
355 | dotnet_diagnostic.CA2119.severity = warning
356 | dotnet_diagnostic.CA2153.severity = warning
357 | dotnet_diagnostic.CA2201.severity = warning
358 | dotnet_diagnostic.CA2207.severity = warning
359 | dotnet_diagnostic.CA2208.severity = warning
360 | dotnet_diagnostic.CA2211.severity = warning
361 | dotnet_diagnostic.CA2213.severity = warning
362 | dotnet_diagnostic.CA2214.severity = warning
363 | dotnet_diagnostic.CA2215.severity = warning
364 | dotnet_diagnostic.CA2216.severity = warning
365 | dotnet_diagnostic.CA2217.severity = warning
366 | dotnet_diagnostic.CA2219.severity = warning
367 | dotnet_diagnostic.CA2225.severity = silent
368 | dotnet_diagnostic.CA2226.severity = warning
369 | dotnet_diagnostic.CA2227.severity = warning
370 | dotnet_diagnostic.CA2229.severity = warning
371 | dotnet_diagnostic.CA2231.severity = warning
372 | dotnet_diagnostic.CA2234.severity = silent
373 | dotnet_diagnostic.CA2235.severity = warning
374 | dotnet_diagnostic.CA2237.severity = warning
375 | dotnet_diagnostic.CA2241.severity = warning
376 | dotnet_diagnostic.CA2242.severity = warning
377 | dotnet_diagnostic.CA2243.severity = warning
378 | dotnet_diagnostic.CA2244.severity = warning
379 | dotnet_diagnostic.CA2245.severity = warning
380 | dotnet_diagnostic.CA2246.severity = warning
381 | dotnet_diagnostic.CA2248.severity = warning
382 | dotnet_diagnostic.CA2249.severity = warning
383 | dotnet_diagnostic.CA2300.severity = warning
384 | dotnet_diagnostic.CA2301.severity = warning
385 | dotnet_diagnostic.CA2302.severity = warning
386 | dotnet_diagnostic.CA2305.severity = warning
387 | dotnet_diagnostic.CA2310.severity = warning
388 | dotnet_diagnostic.CA2311.severity = warning
389 | dotnet_diagnostic.CA2312.severity = warning
390 | dotnet_diagnostic.CA2315.severity = warning
391 | dotnet_diagnostic.CA2321.severity = warning
392 | dotnet_diagnostic.CA2322.severity = warning
393 | dotnet_diagnostic.CA2326.severity = warning
394 | dotnet_diagnostic.CA2327.severity = warning
395 | dotnet_diagnostic.CA2328.severity = warning
396 | dotnet_diagnostic.CA2329.severity = warning
397 | dotnet_diagnostic.CA2330.severity = warning
398 | dotnet_diagnostic.CA2350.severity = warning
399 | dotnet_diagnostic.CA2351.severity = warning
400 | dotnet_diagnostic.CA2352.severity = warning
401 | dotnet_diagnostic.CA2353.severity = warning
402 | dotnet_diagnostic.CA2354.severity = warning
403 | dotnet_diagnostic.CA2355.severity = warning
404 | dotnet_diagnostic.CA2356.severity = warning
405 | dotnet_diagnostic.CA2361.severity = warning
406 | dotnet_diagnostic.CA2362.severity = warning
407 | dotnet_diagnostic.CA3001.severity = warning
408 | dotnet_diagnostic.CA3002.severity = warning
409 | dotnet_diagnostic.CA3003.severity = warning
410 | dotnet_diagnostic.CA3004.severity = warning
411 | dotnet_diagnostic.CA3005.severity = warning
412 | dotnet_diagnostic.CA3006.severity = warning
413 | dotnet_diagnostic.CA3007.severity = warning
414 | dotnet_diagnostic.CA3008.severity = warning
415 | dotnet_diagnostic.CA3009.severity = warning
416 | dotnet_diagnostic.CA3010.severity = warning
417 | dotnet_diagnostic.CA3011.severity = warning
418 | dotnet_diagnostic.CA3012.severity = warning
419 | dotnet_diagnostic.CA3061.severity = warning
420 | dotnet_diagnostic.CA3075.severity = warning
421 | dotnet_diagnostic.CA3076.severity = warning
422 | dotnet_diagnostic.CA3077.severity = warning
423 | dotnet_diagnostic.CA3147.severity = warning
424 | dotnet_diagnostic.CA5350.severity = warning
425 | dotnet_diagnostic.CA5351.severity = warning
426 | dotnet_diagnostic.CA5358.severity = warning
427 | dotnet_diagnostic.CA5359.severity = warning
428 | dotnet_diagnostic.CA5360.severity = warning
429 | dotnet_diagnostic.CA5361.severity = warning
430 | dotnet_diagnostic.CA5362.severity = warning
431 | dotnet_diagnostic.CA5363.severity = warning
432 | dotnet_diagnostic.CA5364.severity = warning
433 | dotnet_diagnostic.CA5365.severity = warning
434 | dotnet_diagnostic.CA5366.severity = warning
435 | dotnet_diagnostic.CA5367.severity = warning
436 | dotnet_diagnostic.CA5368.severity = warning
437 | dotnet_diagnostic.CA5369.severity = warning
438 | dotnet_diagnostic.CA5370.severity = warning
439 | dotnet_diagnostic.CA5371.severity = warning
440 | dotnet_diagnostic.CA5372.severity = warning
441 | dotnet_diagnostic.CA5373.severity = warning
442 | dotnet_diagnostic.CA5374.severity = warning
443 | dotnet_diagnostic.CA5375.severity = warning
444 | dotnet_diagnostic.CA5376.severity = warning
445 | dotnet_diagnostic.CA5377.severity = warning
446 | dotnet_diagnostic.CA5378.severity = warning
447 | dotnet_diagnostic.CA5379.severity = warning
448 | dotnet_diagnostic.CA5380.severity = warning
449 | dotnet_diagnostic.CA5381.severity = warning
450 | dotnet_diagnostic.CA5382.severity = warning
451 | dotnet_diagnostic.CA5383.severity = warning
452 | dotnet_diagnostic.CA5384.severity = warning
453 | dotnet_diagnostic.CA5385.severity = warning
454 | dotnet_diagnostic.CA5386.severity = warning
455 | dotnet_diagnostic.CA5387.severity = warning
456 | dotnet_diagnostic.CA5388.severity = warning
457 | dotnet_diagnostic.CA5389.severity = warning
458 | dotnet_diagnostic.CA5390.severity = warning
459 | dotnet_diagnostic.CA5392.severity = warning
460 | dotnet_diagnostic.CA5393.severity = warning
461 | dotnet_diagnostic.CA5394.severity = warning
462 | dotnet_diagnostic.CA5396.severity = warning
463 | dotnet_diagnostic.CA5397.severity = warning
464 | dotnet_diagnostic.CA5398.severity = warning
465 | dotnet_diagnostic.CA5399.severity = warning
466 | dotnet_diagnostic.CA5400.severity = warning
467 | dotnet_diagnostic.CA5401.severity = warning
468 | dotnet_diagnostic.CA5402.severity = warning
469 | dotnet_diagnostic.CA5403.severity = warning
470 |
471 | # Microsoft.VisualStudio.Threading.Analyzers rules
472 | dotnet_diagnostic.VSTHRD002.severity = none
473 | dotnet_diagnostic.VSTHRD102.severity = warning
474 | dotnet_diagnostic.VSTHRD104.severity = warning
475 | dotnet_diagnostic.VSTHRD109.severity = warning
476 | dotnet_diagnostic.VSTHRD111.severity = none
477 | dotnet_diagnostic.VSTHRD112.severity = warning
478 | dotnet_diagnostic.VSTHRD113.severity = warning
479 | dotnet_diagnostic.VSTHRD200.severity = none
480 |
481 | # Meziantou.Analyzer rules
482 | dotnet_diagnostic.MA0001.severity = none
483 | dotnet_diagnostic.MA0002.severity = none
484 | dotnet_diagnostic.MA0003.severity = warning
485 | dotnet_diagnostic.MA0004.severity = none
486 | dotnet_diagnostic.MA0005.severity = none
487 | dotnet_diagnostic.MA0006.severity = none
488 | dotnet_diagnostic.MA0007.severity = none
489 | dotnet_diagnostic.MA0011.severity = none
490 | dotnet_diagnostic.MA0012.severity = none
491 | dotnet_diagnostic.MA0013.severity = none
492 | dotnet_diagnostic.MA0015.severity = none
493 | dotnet_diagnostic.MA0018.severity = none
494 | dotnet_diagnostic.MA0020.severity = none
495 | dotnet_diagnostic.MA0027.severity = none
496 | dotnet_diagnostic.MA0028.severity = none
497 | dotnet_diagnostic.MA0029.severity = none
498 | dotnet_diagnostic.MA0031.severity = none
499 | dotnet_diagnostic.MA0036.severity = none
500 | dotnet_diagnostic.MA0037.severity = none
501 | dotnet_diagnostic.MA0038.severity = none
502 | dotnet_diagnostic.MA0039.severity = none
503 | dotnet_diagnostic.MA0040.severity = warning
504 | dotnet_diagnostic.MA0041.severity = none
505 | dotnet_diagnostic.MA0042.severity = none
506 | dotnet_diagnostic.MA0043.severity = none
507 | dotnet_diagnostic.MA0044.severity = none
508 | dotnet_diagnostic.MA0047.severity = none
509 | dotnet_diagnostic.MA0048.severity = none
510 | dotnet_diagnostic.MA0049.severity = none
511 | dotnet_diagnostic.MA0050.severity = warning
512 | dotnet_diagnostic.MA0051.severity = none
513 | dotnet_diagnostic.MA0052.severity = none
514 | dotnet_diagnostic.MA0053.severity = none
515 | dotnet_diagnostic.MA0056.severity = none
516 | dotnet_diagnostic.MA0057.severity = none
517 | dotnet_diagnostic.MA0058.severity = none
518 | dotnet_diagnostic.MA0059.severity = none
519 | dotnet_diagnostic.MA0062.severity = none
520 | dotnet_diagnostic.MA0063.severity = warning
521 | dotnet_diagnostic.MA0065.severity = none
522 | dotnet_diagnostic.MA0066.severity = none
523 | dotnet_diagnostic.MA0067.severity = warning
524 | dotnet_diagnostic.MA0069.severity = none
525 | dotnet_diagnostic.MA0071.severity = warning
526 | dotnet_diagnostic.MA0072.severity = none
527 | dotnet_diagnostic.MA0073.severity = none
528 | dotnet_diagnostic.MA0074.severity = none
529 | dotnet_diagnostic.MA0075.severity = warning
530 | dotnet_diagnostic.MA0076.severity = warning
531 | dotnet_diagnostic.MA0078.severity = warning
532 | dotnet_diagnostic.MA0079.severity = warning
533 | dotnet_diagnostic.MA0082.severity = none
534 | dotnet_diagnostic.MA0086.severity = none
535 | dotnet_diagnostic.MA0089.severity = warning
536 | dotnet_diagnostic.MA0090.severity = none
537 | dotnet_diagnostic.MA0095.severity = none
538 | dotnet_diagnostic.MA0097.severity = none
539 | dotnet_diagnostic.MA0098.severity = none
540 | dotnet_diagnostic.MA0101.severity = none
541 | dotnet_diagnostic.MA0102.severity = none
542 | dotnet_diagnostic.MA0105.severity = warning
543 | dotnet_diagnostic.MA0106.severity = none
544 | dotnet_diagnostic.MA0110.severity = warning
545 | dotnet_diagnostic.MA0111.severity = none
546 | dotnet_diagnostic.MA0120.severity = warning
547 | dotnet_diagnostic.MA0121.severity = warning
548 | dotnet_diagnostic.MA0122.severity = warning
549 | dotnet_diagnostic.MA0165.severity = silent
550 |
551 |
552 | # SonarAnalyzer.CSharp rules
553 | dotnet_diagnostic.S100.severity = warning
554 | dotnet_diagnostic.S103.severity = warning
555 | dotnet_diagnostic.S104.severity = warning
556 | dotnet_diagnostic.S105.severity = warning
557 | dotnet_diagnostic.S106.severity = warning
558 | dotnet_diagnostic.S107.severity = warning
559 | dotnet_diagnostic.S1075.severity = none
560 | dotnet_diagnostic.S1109.severity = warning
561 | # Covered by SA1518.
562 | dotnet_diagnostic.S113.severity = none
563 | dotnet_diagnostic.S1133.severity = none
564 | dotnet_diagnostic.S1144.severity = warning
565 | dotnet_diagnostic.S1145.severity = warning
566 | dotnet_diagnostic.S1147.severity = warning
567 | dotnet_diagnostic.S1151.severity = warning
568 | dotnet_diagnostic.S1192.severity = warning
569 | dotnet_diagnostic.S1226.severity = warning
570 | dotnet_diagnostic.S1227.severity = warning
571 | dotnet_diagnostic.S1244.severity = warning
572 | dotnet_diagnostic.S127.severity = warning
573 | dotnet_diagnostic.S1301.severity = warning
574 | dotnet_diagnostic.S131.severity = warning
575 | dotnet_diagnostic.S134.severity = warning
576 | dotnet_diagnostic.S1696.severity = warning
577 | dotnet_diagnostic.S1698.severity = warning
578 | dotnet_diagnostic.S1858.severity = warning
579 | dotnet_diagnostic.S2094.severity = none
580 | dotnet_diagnostic.S2148.severity = warning
581 | dotnet_diagnostic.S2197.severity = warning
582 | dotnet_diagnostic.S2278.severity = warning
583 | dotnet_diagnostic.S2302.severity = warning
584 | # Covered by CA1822.
585 | dotnet_diagnostic.S2325.severity = none
586 | dotnet_diagnostic.S2330.severity = warning
587 | dotnet_diagnostic.S2333.severity = warning
588 | dotnet_diagnostic.S2342.severity = warning
589 | # Covered by CA1711.
590 | dotnet_diagnostic.S2344.severity = none
591 | dotnet_diagnostic.S2357.severity = warning
592 | dotnet_diagnostic.S2387.severity = warning
593 | dotnet_diagnostic.S2437.severity = warning
594 | dotnet_diagnostic.S2699.severity = none
595 | dotnet_diagnostic.S2701.severity = warning
596 | dotnet_diagnostic.S2760.severity = warning
597 | dotnet_diagnostic.S2952.severity = warning
598 | dotnet_diagnostic.S2955.severity = warning
599 | dotnet_diagnostic.S3052.severity = warning
600 | dotnet_diagnostic.S3215.severity = warning
601 | dotnet_diagnostic.S3234.severity = warning
602 | dotnet_diagnostic.S3235.severity = warning
603 | dotnet_diagnostic.S3240.severity = warning
604 | dotnet_diagnostic.S3253.severity = warning
605 | dotnet_diagnostic.S3254.severity = warning
606 | dotnet_diagnostic.S3257.severity = warning
607 | dotnet_diagnostic.S3353.severity = warning
608 | dotnet_diagnostic.S3366.severity = warning
609 | dotnet_diagnostic.S3376.severity = none
610 | dotnet_diagnostic.S3441.severity = warning
611 | dotnet_diagnostic.S3458.severity = none
612 | dotnet_diagnostic.S3532.severity = warning
613 | dotnet_diagnostic.S3604.severity = warning
614 | dotnet_diagnostic.S3626.severity = none
615 | dotnet_diagnostic.S3693.severity = warning
616 | dotnet_diagnostic.S3717.severity = warning
617 | dotnet_diagnostic.S3776.severity = warning
618 | dotnet_diagnostic.S3872.severity = warning
619 | dotnet_diagnostic.S3880.severity = warning
620 | dotnet_diagnostic.S3898.severity = warning
621 | dotnet_diagnostic.S3902.severity = warning
622 | dotnet_diagnostic.S3903.severity = none
623 | dotnet_diagnostic.S3906.severity = warning
624 | dotnet_diagnostic.S3908.severity = warning
625 | dotnet_diagnostic.S3937.severity = warning
626 | dotnet_diagnostic.S3949.severity = warning
627 | dotnet_diagnostic.S3962.severity = warning
628 | dotnet_diagnostic.S3963.severity = none
629 | dotnet_diagnostic.S4002.severity = warning
630 | dotnet_diagnostic.S4025.severity = warning
631 | dotnet_diagnostic.S4041.severity = warning
632 | dotnet_diagnostic.S4047.severity = warning
633 | dotnet_diagnostic.S4052.severity = warning
634 | dotnet_diagnostic.S4212.severity = warning
635 | dotnet_diagnostic.S4225.severity = warning
636 | dotnet_diagnostic.S4226.severity = warning
637 | dotnet_diagnostic.S4261.severity = warning
638 | dotnet_diagnostic.S4432.severity = warning
639 | dotnet_diagnostic.S4487.severity = warning
640 | dotnet_diagnostic.S4564.severity = warning
641 | dotnet_diagnostic.S6934.severity = none
642 | # We don't utilize this rule. Warnings also don't show up in IDE.
643 | dotnet_diagnostic.S6964.severity = none
644 | dotnet_diagnostic.S881.severity = warning
645 |
646 | # StyleCop.Analyzers rules
647 | dotnet_diagnostic.SA0001.severity = none
648 | dotnet_diagnostic.SA1009.severity = none
649 | dotnet_diagnostic.SA1101.severity = none
650 | dotnet_diagnostic.SA1111.severity = none
651 | dotnet_diagnostic.SA1118.severity = none
652 | dotnet_diagnostic.SA1124.severity = none
653 | dotnet_diagnostic.SA1133.severity = none
654 | dotnet_diagnostic.SA1200.severity = none
655 | dotnet_diagnostic.SA1204.severity = none
656 | dotnet_diagnostic.SA1208.severity = none
657 | dotnet_diagnostic.SA1306.severity = none
658 | dotnet_diagnostic.SA1309.severity = none
659 | dotnet_diagnostic.SA1401.severity = none
660 | dotnet_diagnostic.SA1402.severity = none
661 | dotnet_diagnostic.SA1501.severity = none
662 | dotnet_diagnostic.SA1502.severity = none
663 | dotnet_diagnostic.SA1503.severity = none
664 | dotnet_diagnostic.SA1512.severity = none
665 | dotnet_diagnostic.SA1515.severity = none
666 | dotnet_diagnostic.SA1516.severity = none
667 | dotnet_diagnostic.SA1519.severity = none
668 | dotnet_diagnostic.SA1601.severity = none
669 | dotnet_diagnostic.SA1602.severity = none
670 | dotnet_diagnostic.SA1611.severity = none
671 | dotnet_diagnostic.SA1612.severity = none
672 | dotnet_diagnostic.SA1615.severity = none
673 | dotnet_diagnostic.SA1633.severity = none
674 | dotnet_diagnostic.SA1649.severity = none
675 | dotnet_diagnostic.SX1101.severity = warning
676 | dotnet_diagnostic.SX1309S.severity = warning
677 |
--------------------------------------------------------------------------------