Skip to content

Commit 4ac6387

Browse files
authored
code analysis updates for .net 9 release (#43395)
1 parent efc0d4e commit 4ac6387

File tree

313 files changed

+379
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+379
-379
lines changed

docs/core/project-sdk/msbuild-props.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -932,15 +932,15 @@ The following MSBuild properties are documented in this section:
932932

933933
### AnalysisLevel
934934

935-
The `AnalysisLevel` property lets you specify a set of code analyzers to run according to a .NET release. Each .NET release, starting in .NET 5, has a set of code analysis rules. Of that set, the rules that are enabled by default for that release will analyze your code. For example, if you upgrade to .NET 8 but don't want the default set of code analysis rules to change, set `AnalysisLevel` to `7`.
935+
The `AnalysisLevel` property lets you specify a set of code analyzers to run according to a .NET release. Each .NET release has a set of code analysis rules. Of that set, the rules that are enabled by default for that release analyze your code. For example, if you upgrade from .NET 8 to .NET 9 but don't want the default set of code analysis rules to change, set `AnalysisLevel` to `8`.
936936

937937
```xml
938938
<PropertyGroup>
939-
<AnalysisLevel>preview</AnalysisLevel>
939+
<AnalysisLevel>8</AnalysisLevel>
940940
</PropertyGroup>
941941
```
942942

943-
Optionally, starting in .NET 6, you can specify a compound value for this property that also specifies how aggressively to enable rules. Compound values take the form `<version>-<mode>`, where the `<mode>` value is one of the [AnalysisMode](#analysismode) values. The following example uses the preview version of code analyzers, and enables the recommended set of rules.
943+
Optionally, you can specify a compound value for this property that also specifies how aggressively to enable rules. Compound values take the form `<version>-<mode>`, where the `<mode>` value is one of the [AnalysisMode](#analysismode) values. The following example uses the `preview` version of code analyzers, and enables the `recommended` set of rules.
944944

945945
```xml
946946
<PropertyGroup>
@@ -955,12 +955,16 @@ Default value:
955955

956956
The following table shows the values you can specify.
957957

958-
| Value | Meaning |
959-
|-|-|
958+
| Value | Meaning |
959+
|----------|----------------------------------------------------------------------------------|
960960
| `latest` | The latest code analyzers that have been released are used. This is the default. |
961961
| `latest-<mode>` | The latest code analyzers that have been released are used. The `<mode>` value determines which rules are enabled. |
962962
| `preview` | The latest code analyzers are used, even if they are in preview. |
963963
| `preview-<mode>` | The latest code analyzers are used, even if they are in preview. The `<mode>` value determines which rules are enabled. |
964+
| `9.0` | The set of rules that was available for the .NET 9 release is used, even if newer rules are available. |
965+
| `9.0-<mode>` | The set of rules that was available for the .NET 9 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
966+
| `9` | The set of rules that was available for the .NET 9 release is used, even if newer rules are available. |
967+
| `9-<mode>` | The set of rules that was available for the .NET 9 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
964968
| `8.0` | The set of rules that was available for the .NET 8 release is used, even if newer rules are available. |
965969
| `8.0-<mode>` | The set of rules that was available for the .NET 8 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
966970
| `8` | The set of rules that was available for the .NET 8 release is used, even if newer rules are available. |
@@ -969,18 +973,10 @@ The following table shows the values you can specify.
969973
| `7.0-<mode>` | The set of rules that was available for the .NET 7 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
970974
| `7` | The set of rules that was available for the .NET 7 release is used, even if newer rules are available. |
971975
| `7-<mode>` | The set of rules that was available for the .NET 7 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
972-
| `6.0` | The set of rules that was available for the .NET 6 release is used, even if newer rules are available. |
973-
| `6.0-<mode>` | The set of rules that was available for the .NET 6 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
974-
| `6` | The set of rules that was available for the .NET 6 release is used, even if newer rules are available. |
975-
| `6-<mode>` | The set of rules that was available for the .NET 6 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
976-
| `5.0` | The set of rules that was available for the .NET 5 release is used, even if newer rules are available. |
977-
| `5.0-<mode>` | The set of rules that was available for the .NET 5 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
978-
| `5` | The set of rules that was available for the .NET 5 release is used, even if newer rules are available. |
979-
| `5-<mode>` | The set of rules that was available for the .NET 5 release is used, even if newer rules are available. The `<mode>` value determines which rules are enabled. |
980976

981977
> [!NOTE]
982978
>
983-
> - Starting in .NET 6, if you set [EnforceCodeStyleInBuild](#enforcecodestyleinbuild) to `true`, this property affects [code-style (IDEXXXX) rules](../../fundamentals/code-analysis/style-rules/index.md) (in addition to code-quality rules).
979+
> - If you set [EnforceCodeStyleInBuild](#enforcecodestyleinbuild) to `true`, this property affects [code-style (IDEXXXX) rules](../../fundamentals/code-analysis/style-rules/index.md) (in addition to code-quality rules).
984980
> - If you set a compound value for `AnalysisLevel`, you don't need to specify an [AnalysisMode](#analysismode). However, if you do, `AnalysisLevel` takes precedence over `AnalysisMode`.
985981
> - This property has no effect on code analysis in projects that don't reference a [project SDK](overview.md), for example, legacy .NET Framework projects that reference the Microsoft.CodeAnalysis.NetAnalyzers NuGet package.
986982
@@ -1002,8 +998,8 @@ This property is the same as [AnalysisLevel](#analysislevel), except that it onl
1002998

1003999
The following table lists the property name for each rule category.
10041000

1005-
| Property name | Rule category |
1006-
| - |
1001+
| Property name | Rule category |
1002+
|-------------------------|-----------------------------------------------------------------------------------|
10071003
| `<AnalysisLevelDesign>` | [Design rules](../../fundamentals/code-analysis/quality-rules/design-warnings.md) |
10081004
| `<AnalysisLevelDocumentation>` | [Documentation rules](../../fundamentals/code-analysis/quality-rules/documentation-warnings.md) |
10091005
| `<AnalysisLevelGlobalization>` | [Globalization rules](../../fundamentals/code-analysis/quality-rules/globalization-warnings.md) |
@@ -1033,8 +1029,8 @@ The following table shows the available option values. They're listed in increas
10331029

10341030
> [!NOTE]
10351031
>
1036-
> - Starting in .NET 6, if you set [EnforceCodeStyleInBuild](#enforcecodestyleinbuild) to `true`, this property affects [code-style (IDEXXXX) rules](../../fundamentals/code-analysis/style-rules/index.md) (in addition to code-quality rules).
1037-
> - If you use a compound value for [AnalysisLevel](#analysislevel), for example, `<AnalysisLevel>8-recommended</AnalysisLevel>`, you can omit this property entirely. However, if you specify both properties, `AnalysisLevel` takes precedence over `AnalysisMode`.
1032+
> - If you set [EnforceCodeStyleInBuild](#enforcecodestyleinbuild) to `true`, this property affects [code-style (IDEXXXX) rules](../../fundamentals/code-analysis/style-rules/index.md) (in addition to code-quality rules).
1033+
> - If you use a compound value for [AnalysisLevel](#analysislevel), for example, `<AnalysisLevel>9-recommended</AnalysisLevel>`, you can omit this property entirely. However, if you specify both properties, `AnalysisLevel` takes precedence over `AnalysisMode`.
10381034
> - This property has no effect on code analysis in projects that don't reference a [project SDK](overview.md), for example, legacy .NET Framework projects that reference the Microsoft.CodeAnalysis.NetAnalyzers NuGet package.
10391035
10401036
### AnalysisMode\<Category>
@@ -1049,8 +1045,8 @@ This property is the same as [AnalysisMode](#analysismode), except that it only
10491045

10501046
The following table lists the property name for each rule category.
10511047

1052-
| Property name | Rule category |
1053-
| - |
1048+
| Property name | Rule category |
1049+
|------------------------|-----------------------------------------------------------------------------------|
10541050
| `<AnalysisModeDesign>` | [Design rules](../../fundamentals/code-analysis/quality-rules/design-warnings.md) |
10551051
| `<AnalysisModeDocumentation>` | [Documentation rules](../../fundamentals/code-analysis/quality-rules/documentation-warnings.md) |
10561052
| `<AnalysisModeGlobalization>` | [Globalization rules](../../fundamentals/code-analysis/quality-rules/globalization-warnings.md) |

docs/fundamentals/code-analysis/includes/analysis-model-levels.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
| Value | Description |
2-
|-|-|
2+
|-------|-------------|
33
| `None` | All rules are disabled. You can selectively [opt in to](../configuration-options.md) individual rules to enable them. |
44
| `Default` | Default mode, where certain rules are enabled as build warnings, certain rules are enabled as Visual Studio IDE suggestions, and the remainder are disabled. |
55
| `Minimum` | More aggressive mode than `Default` mode. Certain suggestions that are highly recommended for build enforcement are enabled as build warnings. To see which rules this includes, inspect the *%ProgramFiles%/dotnet/sdk/\[version]/Sdks/Microsoft.NET.Sdk/analyzers/build/config/analysislevel_\[level]_minimum.editorconfig* file. |

0 commit comments

Comments
 (0)