Skip to content

Commit

Permalink
Update severity part for .NET 9 (#39570)
Browse files Browse the repository at this point in the history
  • Loading branch information
gewarren authored Feb 16, 2024
1 parent b7ad47f commit 3e26467
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/fundamentals/code-analysis/style-rules/language-rules.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Code-style language and unnecessary code rules
description: Learn about the different code-style rules for using C# and Visual Basic language constructs and for finding unnecessary code.
ms.date: 11/10/2023
ms.date: 02/15/2024
helpviewer_keywords:
- language code style rules [EditorConfig]
- language rules
Expand Down Expand Up @@ -42,9 +42,12 @@ or

- **Severity** (optional in Visual Studio 2019 and later versions)

The second part of the rule specifies the [severity level](../configuration-options.md#severity-level) for the rule. When specified in this way, *the severity setting is only respected inside development IDEs, such as Visual Studio*. It is *not* respected during build.
The second part of the rule specifies the [severity level](../configuration-options.md#severity-level) for the rule. In .NET 9 and later versions, the severity is always respected—that is, inside development IDEs *and* during command-line builds. In .NET 8 and earlier versions, this severity setting is only respected inside development IDEs, such as Visual Studio, and *not* during build.

To enforce code style rules at build time, set the severity by using the rule ID-based severity configuration syntax for analyzers instead. The syntax takes the form `dotnet_diagnostic.<rule ID>.severity = <severity>`, for example, `dotnet_diagnostic.IDE0040.severity = none`. For more information, see [severity level](../configuration-options.md#severity-level).
If you're using the .NET 8 SDK or an earlier version and you want to enforce code style rules at build time, you can do so in one of two ways:

- Set the [\<AnalysisLevel>](../../../core/project-sdk/msbuild-props.md#analysislevel) or `<AnalysisLevelStyle>` property to `9.0` or higher, or to `preview`.
- Set the severity by using the rule ID-based severity configuration syntax for analyzers instead. The syntax takes the form `dotnet_diagnostic.<rule ID>.severity = <severity>`, for example, `dotnet_diagnostic.IDE0040.severity = none`. For more information, see [severity level](../configuration-options.md#severity-level).

> [!TIP]
>
Expand Down

0 comments on commit 3e26467

Please sign in to comment.