-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that warnaserror works identically for warnings configured in … #47710
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we only consider
generalDiagnosticOption
in this particularif
block? Why not the others essentially?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is due to the fact that global configs are lazily parsed, while rulesets are parsed upfront by the command line parser.
/warnaserror
command line arguments: http://sourceroslyn.io/#Microsoft.CodeAnalysis.CSharp/CommandLine/CSharpCommandLineParser.cs,158/warnaserror
on command line, options from rulesets are directly bumped to errors in place: http://sourceroslyn.io/#Microsoft.CodeAnalysis.CSharp/CommandLine/CSharpCommandLineParser.cs,828There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, we can consider implementing a similar fix for settings in editorconfig files, i.e. if you specify
dotnet_diagnostic.RuleId.severity = warning
in an editorconfig and execute with/warnaserror
, then the diagnostic gets promoted to error - that does seem more sensible behavior as/warnaserror
should ideally imply one does not see any warnings, but only errors (unless of course users have a/warnaserror-:RuleId
for specific rules). Customers are also requesting the fix to editorconfig behavior in #43051, but there is potential of that being a more visible breaking change for existing users as editorconfig support in compiler has been shipped for a while. We have 2 options:/warnaserror
to bump user configured warnings to errors. The approach taken currently in this PR./warnaserror
. This would be a simple change to make in this PR if we are comfortable with it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we document what the precedence level is between all of the various options here? I was a bit surprised at first glance to see that the test verifies that the command line essentially overrides the config files. Likely my intuition is just off here. But wanted to find a full list of "A wins over B" so I could consider what other tests we may need here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have #47154 tracking adding this documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaredpar @chsienki I plan to add the precedence level documentation tracked in #47154 to docs.microsoft.com later today.
However, the open question in my above comment #47710 (comment) still needs to be answered to define this order wrt to command line options: do we believe that command line options (/nowarn and /warnaserror) should always override diagnostic settings from all of the other sources (editorconfig, global config and rulesets)? I think that should be the case, as shown by the scenarios in #43051.
This PR ensures these semantics for global configs. I can create a follow-up PR for ensuring the same semantics for editorconfigs, if we feel it is a reasonable behavior change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaredpar Do you feel scheduling a meeting for discussing this would be preferrable? Also, should this PR be retargeted to 16.8 release branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I just lost track of this.