Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0c1d11c
Blazor ebook frontmatter (#27086)
ardalis Nov 15, 2021
1f1e5bb
VS 2022 'preview' removed (#27070)
jakubkozera Nov 15, 2021
7d05463
Fixed Typo (#27072)
mohamed-azhar Nov 15, 2021
7475617
Update package index with latest published versions (#27083)
azure-sdk Nov 15, 2021
522db4f
Update ExampleAsyncDisposable.cs (#27074)
wuyuansushen Nov 15, 2021
45f3b2f
Details overloading `==` and `!=` operators on the `ValueObject` type…
IEvangelist Nov 15, 2021
d3dd722
Fix text element count not starting at 1 (#27010)
enchant97 Nov 15, 2021
a227987
Update code analysis props for .NET 6 (#26880)
gewarren Nov 16, 2021
56457d9
Update package index with latest published versions (#27095)
azure-sdk Nov 16, 2021
0d2c8d7
Add link to Fedora .NET 6 tracking bug (#27091)
adegeo Nov 16, 2021
08af11c
Retitle Fact 1 (#27102)
radrow Nov 16, 2021
5e3f838
Add the HTTP keyword to the expected list of available slug completio…
IEvangelist Nov 16, 2021
86db076
Address concerns about inconsistent code style and formatting (#27089)
IEvangelist Nov 16, 2021
e2d8bbb
Code block fix (#27103)
kendaleiv Nov 16, 2021
39961fa
Update package index with latest published versions (#27105)
azure-sdk Nov 16, 2021
34ee5a0
Fix NETSDK error number (#27106)
tdykstra Nov 16, 2021
0291f98
Add more info to recommended actions (#27093)
gewarren Nov 16, 2021
7da65f5
Add note about .NET Framework (#27107)
gewarren Nov 16, 2021
e25944b
Update package index with latest published versions (#27108)
azure-sdk Nov 16, 2021
33de384
fix build suggestions (#27109)
gewarren Nov 16, 2021
35b4b0a
Add note about FTP (#27094)
gewarren Nov 16, 2021
13db9bb
Add with-expressions to anonymous types (#27111)
BillWagner Nov 16, 2021
7d15439
Bump Humanizer (#27124)
dependabot[bot] Nov 17, 2021
27f8137
Fix Dispose(bool) method overload in ConjunctiveDisposable pattern (#…
wuyuansushen Nov 17, 2021
657431b
Add documentation for CA2255 (new in .NET 6) (#27096)
jeffhandley Nov 17, 2021
ff039e3
Remove backticks from page metadata (#27114)
jeffhandley Nov 17, 2021
9193947
Update package index with latest published versions (#27115)
azure-sdk Nov 17, 2021
1bf94fa
acrolinx (#27117)
gewarren Nov 17, 2021
b3ebcba
Restore the Azure for .NET devs tile (#27128)
scottaddie Nov 17, 2021
719a11a
Update rabbitmq-event-bus-development-test-environment.md (#27134)
IEvangelist Nov 17, 2021
c6b969b
Fix typo (#27141)
gewarren Nov 18, 2021
69956d1
Acrolinx 11/17 (#27131)
gewarren Nov 18, 2021
8ddcaee
Blazor Hot Reload (#27166)
ardalis Nov 19, 2021
0713043
update vs images (#27375)
ardalis Dec 2, 2021
3e67580
Update to .NET 6 / VS 2022
ardalis Dec 2, 2021
6cdabf0
Update to .NET 6 / VS 2022 (#27379)
ardalis Dec 2, 2021
0e3c8cd
Merge branch 'blazor-ebook-net6' into ardalis/blazor-ebook-net6
ardalis Dec 7, 2021
20343de
update ms.date and another startup reference
ardalis Dec 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update code analysis props for .NET 6 (#26880)
  • Loading branch information
gewarren authored and IEvangelist committed Nov 18, 2021
commit a2279873903a92e39664042145a6be8a5416699e
15 changes: 6 additions & 9 deletions docs/core/project-sdk/msbuild-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ The following table lists the property name for each rule category.

### AnalysisMode

Starting with .NET 5, the .NET SDK ships with all of the ["CA" code quality rules](../../fundamentals/code-analysis/quality-rules/index.md). By default, only [some rules are enabled](../../fundamentals/code-analysis/overview.md#enabled-rules) as build warnings. The `AnalysisMode` property lets you customize the set of rules that are enabled by default. You can either switch to a more aggressive (opt-out) analysis mode or a more conservative (opt-in) analysis mode. For example, if you want to enable all rules by default as build warnings, set the value to `All` or `AllEnabledByDefault`.
Starting with .NET 5, the .NET SDK ships with all of the ["CA" code quality rules](../../fundamentals/code-analysis/quality-rules/index.md). By default, only [some rules are enabled](../../fundamentals/code-analysis/overview.md#enabled-rules) as build warnings. The `AnalysisMode` property lets you customize the set of rules that are enabled by default. You can either switch to a more aggressive (opt-out) analysis mode or a more conservative (opt-in) analysis mode. For example, if you want to enable all rules by default as build warnings, set the value to `All`.

```xml
<PropertyGroup>
Expand All @@ -597,13 +597,13 @@ Starting with .NET 5, the .NET SDK ships with all of the ["CA" code quality rule

The following table shows the available option values in .NET 5 and .NET 6. They're listed in increasing order of the number of rules they enable.

| .NET 5 value | .NET 6 value | Meaning |
| .NET 6+ value | .NET 5 value | Meaning |
|-|-|-|
| `AllDisabledByDefault` | `None` | All rules are disabled by default. You can selectively [opt in to](../../fundamentals/code-analysis/configuration-options.md) individual rules to enable them. |
| `None` | `AllDisabledByDefault` | All rules are disabled by default. You can selectively [opt in to](../../fundamentals/code-analysis/configuration-options.md) individual rules to enable them. |
| `Default` | `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. |
| | `Minimum` | More aggressive mode than the `Default` mode. Certain suggestions that are highly recommended for build enforcement are enabled as build warnings. |
| | `Recommended` | More aggressive mode than the `Minimum` mode, where more rules are enabled as build warnings. |
| `AllEnabledByDefault` | `All` | All rules are enabled by default as build warnings. You can selectively [opt out](../../fundamentals/code-analysis/configuration-options.md) of individual rules to disable them. |
| `Minimum` | N/A | More aggressive mode than the `Default` mode. Certain suggestions that are highly recommended for build enforcement are enabled as build warnings. |
| `Recommended` | N/A | More aggressive mode than the `Minimum` mode, where more rules are enabled as build warnings. |
| `All` | `AllEnabledByDefault` | All rules are enabled by default as build warnings. You can selectively [opt out](../../fundamentals/code-analysis/configuration-options.md) of individual rules to disable them. |

> [!NOTE]
>
Expand Down Expand Up @@ -664,9 +664,6 @@ The `CodeAnalysisTreatWarningsAsErrors` property lets you configure whether code

### EnforceCodeStyleInBuild

> [!NOTE]
> This feature is currently experimental and may change between the .NET 5 and .NET 6 releases.

[.NET code style analysis](../../fundamentals/code-analysis/overview.md#code-style-analysis) is disabled, by default, on build for all .NET projects. You can enable code style analysis for .NET projects by setting the `EnforceCodeStyleInBuild` property to `true`.

```xml
Expand Down
2 changes: 1 addition & 1 deletion docs/fundamentals/code-analysis/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The following table shows the different rule severities that you can configure f
>
> - Add an explicit `dotnet_diagnostic.<rule ID>.severity = <severity>` configuration entry for each rule.
> - In .NET 6+, enable a category of rules by setting [\<AnalysisMode\<Category>>](../../core/project-sdk/msbuild-props.md#analysismodecategory) to `All`.
> - Enable *all* rules by setting [\<AnalysisMode>](../../core/project-sdk/msbuild-props.md#analysismode) to `AllEnabledByDefault`.
> - Enable *all* rules by setting [\<AnalysisMode>](../../core/project-sdk/msbuild-props.md#analysismode) to `All` or by setting [\<AnalysisLevel>](../../core/project-sdk/msbuild-props.md#analysislevel) to `latest-All`.

#### Precedence

Expand Down
52 changes: 37 additions & 15 deletions docs/fundamentals/code-analysis/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Code analysis in .NET
titleSuffix: ""
description: Learn about source code analysis in the .NET SDK.
ms.date: 12/04/2020
ms.date: 11/08/2021
ms.topic: overview
ms.custom: updateeachrelease
helpviewer_keywords:
Expand All @@ -29,18 +29,26 @@ If rule violations are found by an analyzer, they're reported as a suggestion, w

### Enabled rules

The following rules are enabled, by default, in .NET 5.
The following rules are enabled, by default, in .NET 6.

| Diagnostic ID | Category | Severity | Description |
| - | - | - | - |
| [CA1416](/visualstudio/code-quality/ca1416) | Interoperability | Warning | Platform compatibility analyzer |
| [CA1417](/visualstudio/code-quality/ca1417) | Interoperability | Warning | Do not use `OutAttribute` on string parameters for P/Invokes |
| [CA1831](/visualstudio/code-quality/ca1831) | Performance | Warning | Use `AsSpan` instead of range-based indexers for string when appropriate |
| [CA2013](/visualstudio/code-quality/ca2013) | Reliability | Warning | Do not use `ReferenceEquals` with value types |
| [CA2014](/visualstudio/code-quality/ca2014) | Reliability | Warning | Do not use `stackalloc` in loops |
| [CA2015](/visualstudio/code-quality/ca2015) | Reliability | Warning | Do not define finalizers for types derived from <xref:System.Buffers.MemoryManager%601> |
| [CA2200](/visualstudio/code-quality/ca2200) | Usage | Warning | Rethrow to preserve stack details
| [CA2247](/visualstudio/code-quality/ca2247) | Usage | Warning | Argument passed to TaskCompletionSource constructor should be <xref:System.Threading.Tasks.TaskCreationOptions> enum instead of <xref:System.Threading.Tasks.TaskContinuationOptions> |
| [CA1416](quality-rules/ca1416.md) | Interoperability | Warning | Platform compatibility analyzer |
| [CA1417](quality-rules/ca1417.md) | Interoperability | Warning | Do not use `OutAttribute` on string parameters for P/Invokes |
| [CA1418](quality-rules/ca1418.md) | Interoperability | Warning | Use valid platform string |
| [CA1831](quality-rules/ca1831.md) | Performance | Warning | Use `AsSpan` instead of range-based indexers for string when appropriate |
| [CA2013](quality-rules/ca2013.md) | Reliability | Warning | Do not use `ReferenceEquals` with value types |
| [CA2014](quality-rules/ca2014.md) | Reliability | Warning | Do not use `stackalloc` in loops |
| [CA2015](quality-rules/ca2015.md) | Reliability | Warning | Do not define finalizers for types derived from <xref:System.Buffers.MemoryManager%601> |
| CA2017 | Reliability | Warning | Parameter count mismatch |
| [CA2018](quality-rules/ca2018.md) | Reliability | Warning | The `count` argument to `Buffer.BlockCopy` should specify the number of bytes to copy |
| [CA2200](quality-rules/ca2200.md) | Usage | Warning | Rethrow to preserve stack details |
| [CA2252](quality-rules/ca2252.md) | Usage | Error | Opt in to preview features |
| [CA2247](quality-rules/ca2247.md) | Usage | Warning | Argument passed to `TaskCompletionSource` constructor should be <xref:System.Threading.Tasks.TaskCreationOptions> enum instead of <xref:System.Threading.Tasks.TaskContinuationOptions> |
| CA2255 | Usage | Warning | The `ModuleInitializer` attribute should not be used in libraries |
| CA2256 | Usage | Warning | All members declared in parent interfaces must have an implementation in a `DynamicInterfaceCastableImplementation`-attributed interface |
| CA2257 | Usage | Warning | Members defined on an interface with the `DynamicInterfaceCastableImplementationAttribute` should be `static` |
| CA2258 | Usage | Warning | Providing a `DynamicInterfaceCastableImplementation` interface in Visual Basic is unsupported |

You can change the severity of these rules to disable them or elevate them to errors. You can also [enable more rules](#enable-additional-rules).

Expand All @@ -51,11 +59,25 @@ You can change the severity of these rules to disable them or elevate them to er

*Analysis mode* refers to a predefined code analysis configuration where none, some, or all rules are enabled. In the default analysis mode, only a small number of rules are [enabled as build warnings](#enabled-rules). You can change the analysis mode for your project by setting the [\<AnalysisMode>](../../core/project-sdk/msbuild-props.md#analysismode) property in the project file. The allowable values are:

| Value | Description |
| - | - |
| `AllDisabledByDefault` | This is the most conservative mode. All rules are disabled by default. You can selectively [opt into](configuration-options.md) individual rules to enable them.<br /><br />`<AnalysisMode>AllDisabledByDefault</AnalysisMode>` |
| `AllEnabledByDefault` | This is the most aggressive mode. All rules are enabled as build warnings. You can selectively [opt out of](configuration-options.md) individual rules to disable them.<br /><br />`<AnalysisMode>AllEnabledByDefault</AnalysisMode>` |
| `Default` | The default mode, where a handful of rules are enabled as warnings, others are enabled only as Visual Studio IDE suggestions with corresponding code fixes, and the rest are disabled completely. You can selectively [opt into or out of](configuration-options.md) individual rules to disable them.<br /><br />`<AnalysisMode>Default</AnalysisMode>` |
:::row:::
:::column:::
`None`
:::column-end:::
:::column:::
`Default`
:::column-end:::
:::column:::
`Minimum`
:::column-end:::
:::column:::
`Recommended`
:::column-end:::
:::column:::
`All`
:::column-end:::
:::row-end:::

Starting in .NET 6, you can omit [\<AnalysisMode>](../../core/project-sdk/msbuild-props.md#analysismode) in favor of a compound value for the \<AnalysisLevel> property. For example, the following value enables the recommended set of rules for the latest release: `<AnalysisLevel>latest-Recommended</AnalysisLevel>`. For more information, see [AnalysisLevel](../../core/project-sdk/msbuild-props.md#analysislevel).

To find the default severity for each available rule and whether or not the rule is enabled in the default analysis mode, see the [full list of rules](https://github.com/dotnet/roslyn-analyzers/blob/main/src/NetAnalyzers/Core/AnalyzerReleases.Shipped.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/standard/base-types/string-comparison-net-5-plus.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ These specific rules aren't enabled by default. To enable them and show any viol

```xml
<PropertyGroup>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisMode>All</AnalysisMode>
<WarningsAsErrors>$(WarningsAsErrors);CA1307;CA1309;CA1310</WarningsAsErrors>
</PropertyGroup>
```
Expand Down