Prevent diagnostics on .NET SDK 8.0.100#2049
Merged
Merged
Conversation
* disabled several entirely * fixed some easy ones
In most cases, we now just use the new (C# 12.0) collection expression syntax. However, we've disabled IDE0305 because it makes suggestions that aren't an obvious improvement. It wants to rewrite use of ToArray() to be a collection expression. E.g. something.ToArray() would become [.. something]. Perhaps that will seem natural once we've all got used to spreads in collection expressions, but to me (idg10) today that looks odd.
Make UWP test runner use the same warning settings as everything else, except for CS0618, which a large number of tests appear to depend on.
HowardvanRooijen
approved these changes
Nov 22, 2023
idg10
added a commit
that referenced
this pull request
May 21, 2024
Address collection expression diagnostics In most cases, we now just use the new (C# 12.0) collection expression syntax. However, we've disabled IDE0305 because it makes suggestions that aren't an obvious improvement. It wants to rewrite use of ToArray() to be a collection expression. E.g. something.ToArray() would become [.. something]. Perhaps that will seem natural once we've all got used to spreads in collection expressions, but to me (idg10) today that looks odd. Add comment explaining why we've disable IDE0290 Make UWP test runner use the same warning settings as everything else, except for CS0618, which a large number of tests appear to depend on.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The .NET SDK 8.0.100 adds various new diagnostics. Some of these relate to new language features in C# 12.0, and some are just part of the ongoing tendency for the SDK to notice ever more issues.
This updates the code to use C# 12.0 collection expressions except in one case: we aren't currently big fans of IDE0305, which wants to transform all uses of
x.ToArray()to[.. x]. This seems a little obscure. Possibly it will seem more natural in a few years when we're used to seeing collection expressions. Or possibly not—use of spreads in these expressions might be a less mainstream technique.After some deliberation we've also elected to disable IDE0290, which wants us to use primary constructors. Although there are some cases where its suggestions seem like a clear improvement, in some they are not. In particular, when types have multiple constructors but the diagnostic has determined that use of
this(...)means its able to designate one as a primary constructor, it often just looks a bit odd. The decision to usethis(...)is often an implementation choice, and the constructor elevated to be the 'primary' one often looks a bit arbitrary as a result. Unless and until some way of making this rule more selective can be found, we are going to leave it switched off.