Skip to content

Commit 3f5719f

Browse files
authored
Adding guidance on what is considered a breaking change in the .NET SDK (#45288)
2 parents 1b4e91b + b787ca7 commit 3f5719f

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

documentation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Documents Index
99
- [Roadmap and OS support](https://github.com/dotnet/core/blob/main/roadmap.md)
1010
- [Comprehensive CLI documentation](https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/)
1111
- [ASP.NET Core Command Line Tools](general/aspnetcore-tools.md)
12+
- [Guidelines for how to introduce a new diagnostic or breaking change](project-docs/breaking-change-guidelines.md)
1213

1314
## Working with the CLI repo
1415

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# SDK Breaking Change and Diagnostic Guidelines
2+
3+
This document provides guidelines for introducing new diagnostics or breaking changes to the .NET SDK, which configuration knobs are available, what criteria should guide the decision around severity, timeline for introduction, and deprecation of diagnostics, and what steps are required by the .NET release process.
4+
5+
## General guidance
6+
7+
In general, we want to make updating the .NET SDK as smooth as possible for developers. This means:
8+
9+
* Introducing new changes in a staged/gradual way.
10+
* Tying new analyzers/diagnostics to a mechanism that requires explicit opt-in.
11+
* Providing a way to opt out of a change entirely.
12+
13+
## Kinds of .NET SDK breaking changes
14+
15+
There are many kinds of breaking changes that can ship in the .NET SDK, such as:
16+
17+
* New MSBuild warnings and errors (props/targets).
18+
* New NuGet warnings and errors.
19+
* For example, NuGet Audit.
20+
* Roslyn Analyzers and CodeFixes.
21+
* This includes trimming/ILLink analyzers and codefixes.
22+
* Behavioral/implementation changes.
23+
* MSBuild engine changes like MSBuild Server.
24+
* Implementation changes for MSBuild Tasks.
25+
* NuGet Restore algorithm enhancements.
26+
* Changes to DotNet CLI behavior or output.
27+
* Changes to DotNet CLI grammar.
28+
* Changes to defaults in CLI flags that impact behavior.
29+
* For example, `--configuration` flag defaulting to `Release` instead of `Debug`.
30+
31+
## Configuration Knobs
32+
33+
The following knobs are available to enable/disable these changes (some may not apply to all kinds of changes):
34+
35+
* [TargetFramework](https://learn.microsoft.com/en-us/dotnet/standard/frameworks)
36+
* [SdkAnalysisLevel](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#sdkanalysislevel)
37+
* EditorConfig (for Analyzers)
38+
* AnalysisLevel (for Analyzers/CodeFixes)
39+
* WarningLevel
40+
* [Change waves](https://learn.microsoft.com/en-us/visualstudio/msbuild/change-waves) (for MSBuild engine behavior)
41+
* [LangVer](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version)
42+
43+
## Deciding how to Surface Changes
44+
45+
### Support new and old commands in the first release
46+
47+
For changes in the CLI grammar, fully support both commands in one release, add a message to the old command in the subsequent release, and remove the old command in the release after that. This allows users to migrate to the new command at their own pace.
48+
49+
Specific example: When the `dotnet new --list` command was changed to `dotnet new list` to adhere to CLI design guidelines,
50+
the old command was still the default supported and a warning was written to the console when the old form was used pointing users to the new form. This allowed users and scripts to continue using the old form and gradually migrate to the new.
51+
52+
### Implement changes in an informational/non-blocking way initially
53+
54+
What this means will vary change-to-change. For example, for a change expressed as an Analyzer or MSBuild diagnostic, consider
55+
Informational level severities initially. For a behavioral change on a CLI, consider an informational message written to the
56+
stderr channel on the console instead of making the stdout output unparseable by tools.
57+
58+
### Gradually increase severity over each release
59+
60+
If a change in introduced in an informational/non-blocking way, determine the time frame where it is safe to increase the severity. For Analyzers, this may mean tying it to the next value of AnalysisLevel (which is downstream of TFM). For small MSBuild and NuGet diagnostics, this may mean tying it to the next Warning Level or SdkAnalysisLevel. For CLI changes, this may mean tying it to the next LTS major version of the SDK. Ideally the way you would structure this increase would be automated and documented so that users know what's coming down the pipe.
61+
62+
### Cut-over to new behavior after a long introduction period
63+
64+
After the change has been introduced in a gradual way, cut over to the new behavior. This may mean removing the old behavior entirely, or it may mean making the new behavior the default and providing a way to opt out of it. It is important that you
65+
provide enough time for users to adapt - for example the `dotnet new --list` example above took an entire major release to make the new forms the default.
66+
67+
### Always provide a way to opt out of the change
68+
69+
Have some kind of knob that allows users to opt out of the change entirely. Preferably, this would be a project property, but, for depending on the change, other mechanisms would be more appropriate. For example, an environment variable for MsBuild engine changes or a CLI argument to opt out of a new output format. This allows users to continue using the old behavior if they need to in exceptional situations.
70+
71+
It is important to document the opt out mechanism in the SDK documentation, as well as document the timeline for when this opt out mechanism will be removed entirely, forcing users to adopt the new behavior. For systems like Analyzers, that time may be _never_, because the cost of detection is so low. This is a product-level decision that is hard to give universal guidance for.
72+
73+
### Hook into the unified SdkAnalysisLevel knob to allow users to easily opt out of all changes
74+
75+
This knob exists so that users can safely and consistently say "for whatever reason, I just need you to act like SDK version X". This is the one-stop shop - users no longer need to know about all the individual knobs that are available to them.
76+
77+
### Tie potentially impactful changes to the target TFM
78+
79+
Changes that are expected to cause significant disruption should only be introduced behind the Target Framework knob. This ensures business continuity and allows developers to address changes needed as part of scheduled work to migrate a codebase to a new TFM.
80+
81+
Specific example: NuGet warnings for vulnerable transitive dependencies were introduced in the .NET 10 SDK only for applications targeting .NET 10 and higher.
82+
83+
## Required process for all .NET SDK breaking changes
84+
85+
* Create an issue in the appropriate GitHub repository to track the change, if one does not already exist.
86+
* Add the breaking-change label to the issue. This label should be available in all .NET repositories that ship as part of the .NET SDK. If the label is not available, please file an issue in [dotnet/sdk](https://github.com/dotnet/sdk).
87+
* The issue will trigger a message with instructions to add documentation. In addition, you are invited to work with the SDK team to publish a blog post for the change.
88+
* Consider creating and pinning an issue in the appropriate GitHub repository where the community can provide feedback.

0 commit comments

Comments
 (0)