-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Closed
Copy link
Labels
Description
Version Used: .NET 10.0.103
I have LangVersion set to latest, but this analyzer is showing a warning and recommending a fix that breaks the build. Not sure why the initial warning doesn't fail the build, as I also have TreatWarningsAsErrors set to true on CI.
Dictionary<string, object> dict1 = [];
Dictionary<string, object> dict2 = new(dict1); // ⚠️ IDE0028: Collection initialization can be simplifiedDiagnostic Id: IDE0028
Use collection initializers or expressions (IDE0028)
Expected Behavior:
I did not expect an analyzer to recommend unsupported preview features! 😁
Collection expression arguments
Actual Behavior:
Accept the codefix:
Dictionary<string, object> dict1 = [];
Dictionary<string, object> dict2 = [with(dict1)]; // ❌ CS8652: The feature 'collection expression arguments' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.Reactions are currently unavailable