Open CoolCoderSuper opened 15 hours ago
The reason for this is that SyntaxtGenerator being language agnostic
// Update definition to add static modifier.
document = solution.GetDocument(document.Id)!;
root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
node = root.GetAnnotatedNodes(s_annotationForFixedDeclaration).Single();
var syntaxGenerator = SyntaxGenerator.GetGenerator(document);
var oldModifiersAndStatic = syntaxGenerator.GetModifiers(node).WithIsStatic(true).WithIsReadOnly(false);
var newNode = syntaxGenerator.WithModifiers(node, oldModifiersAndStatic);
The iterator modifer does not exist in C# and is not recognized here. I am thinking the best way to do this is to add the Iterator field to DeclarationModifiers. Unless we would add VB specific logic to analyzer but that would require them having split sources since the analyzer package doesn't directly reference language specific packages and I assume it should stay that way.
Analyzer
Diagnostic ID: CA1822:
Mark members as static
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 8.0.100
Describe the bug
Applying make static analyzer in VB removes the Iterator modifier.
Expected behavior
The Shared modifier is added to the method and keeps existing modifiers.
Actual behavior
Shared modifier replaces Iterator modifier.
Additional context
https://github.com/user-attachments/assets/b5083632-d992-41ab-bc70-cdcf111cf9ae