-
Notifications
You must be signed in to change notification settings - Fork 507
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
SA1010 false positive when list syntax is used in a field initializer #3687
Comments
I hit this when telling VS to make fixes for Use collection initializers (IDE0028). It will automatically create statements that trigger SA1010. For example: List<string> foo = []; |
Hit this in a few places. ctors = [.. ctors.OrderByDescending(info => info.GetParameters().Length)]; object result = TypesManager.InvokeGenericStaticMethod(typeof(ServiceLocator), nameof(ResolveMock), [type]); if (request.OtherEmails != null)
{
emails = [.. request.OtherEmails.Split([';', ','])];
} public static readonly string[] AllBlastRadiusStrings = [SingleNode, SingleCustomer, SingleScaleUnitSlicePartition, SingleScaleUnit, SingleRack, SingleCluster, SingleAZ, SingleRegion, MultipleRacks, MultipleClusters, MultipleAZs, MultipleRegions, Global, Other]; |
I assume that .NET 8 and C# 12 will be released very soon now. This fix is probably trivial, but what do you think about adding a new test project, @sharwell? Should it wait until you are done with your updates to the test projects (#3675 (comment)), or can it be done now? If you would like to wait, do you have any estimate of when you will be done? |
.NET 8 and C# 12 were released yesterday and so this is now an issue with production code. For now, I've had to disable the SA1010 rule for our code until this can be fixed. Please can this be fixed as quickly as possible. |
…e expected style in all known cases and ignore all unknown cases. DotNetAnalyzers#3687
I'm unsure if all the various cases are being tracked or accounted for, but I thought I would report that SA1010 also fires during coalesce, coalesce assign, and ternary operations. List<string>? list = default;
// fires on coalesce
List<string> otherList = list ?? [];
// fires on ternary
List<string> anotherList = list is null ? [] : list;
// fires on coalesce assigement
list ??= []; |
see also #3503 |
There's still a lot of IDE0028 warnings as the auto fix really wants to use the C#12 collection expressions, which btw will trigger SA1010 warnings (DotNetAnalyzers/StyleCopAnalyzers#3687)
* Fix null analyzer complaints: CS8602, CS8618, CS8603, CS8622, IDE0031 * Hide warnings related to IDE0008 related to using `var` keyword * Removed Coersion logic from IconSourceElementConverter, and placed in IconElement and IcounSourceElement classes instead * Cleaning single-line warnings: SA1005 - Removed commented-out Toolbox attributes - Replaced single-line commented-out code with multi-line * Fix missing braces or single-lined braces - Add stylecop supression of 1502 "element should not be on a single line" - Wrap with braces where needed * Fix warnings on registered dependency properties WPF0100, WPF0005, WPF0012 * Fix documentation warnings WPF0108, WPF0060, SA1642, SA1623 * Fix warnings about using language keywords - Use string, double, int rather than String, Double, Int32, etc - remove 'this' keyword when context is obvious * Fix warnings where attributes are on a single line SA1133 * When setting DPs, favor SetCurrentValue over the CLR setter. WPF0041 * Remove unnecessary things (parenthesis, assignments, etc). SA1119, IDE0059 * Fix order of operation warnings * Do not use regions SA1124. Clean VirtualizingPanelBase of warnings * Turn protected control fields into protected properties. fix some documentation warnings * Cleanup warnings in Interop classes and suppress warnings related to uper-casing and private fields * Continue cleaning up warnings in Wpf.Ui * Edit .editorconfig to suppress warnings related to valueconverters * Cleanup warning related to 'var' * Fix warnings * Split ContextMenu style from its loader dictionary There were some issue when having a class called ContextMenu that wasn't actually a contextmenu but a ResourceDictionary * Resolve "expression value is never used" IDE0058 warnings * Fix warnings related to collection initialization. There's still a lot of IDE0028 warnings as the auto fix really wants to use the C#12 collection expressions, which btw will trigger SA1010 warnings (DotNetAnalyzers/StyleCopAnalyzers#3687) * Remove unused suppressions * Supress IDE0290 (Use primary constructor). Just didn't seem necessary. * IDE0009 should be configured through dotnet_styles * Separate out the loader component from the Menu.xaml style. Justification: Menu was not a control.Menu, it's more like a hack to change private api settings. * Fix warnings on NavigationView.NavigationParent attached property * Fix warnings related to setting refernce types as default values. for dependency properties. Also fixed some enum warnings * Fix warnings * Fix regression error where the ContentDialog wouldn't appear and change name of ContentPresenter to DialogHost * Remove obsolete forceBacground parameters. Breaking changes * Remove redundant #if DEBUG directives around Debug.WriteLine calls * Fix some analyzer warnings
The following line produces a SA1010 warning claiming that the open square bracket should not be preceded by a space:
This is using 1.2.0.507.
The text was updated successfully, but these errors were encountered: