Repository navigation
Update edited document before continuing code fixing - #2250
Conversation
| var attributeArguments = GetAttributeArguments (SyntaxGenerator.GetGenerator (document), targetSymbol, diagnostic); | ||
| var codeFixTitle = CodeFixTitle.ToString (); | ||
|
|
||
| context.RegisterCodeFix (CodeAction.Create (codeFixTitle, |
There was a problem hiding this comment.
Could you preserve the earlier formatting? It's longer but clearer about what argument belongs to each method call
| // /0/Test0.cs(24,31): warning IL2026: Using member 'C.M1()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. message. | ||
| VerifyCS.Diagnostic (DiagnosticId.RequiresUnreferencedCode).WithSpan (24, 31, 24, 37).WithArguments ("C.M1()", " message.", "") | ||
| }, new[] { | ||
| // /0/Test0.cs(27,10): error CS7036: There is no argument given that corresponds to the required formal parameter 'message' of 'RequiresUnreferencedCodeAttribute.RequiresUnreferencedCodeAttribute(string)' |
There was a problem hiding this comment.
I think these results were correct -- we don't want to fill in the message for public members, since that message will be visible to external users. The code owner should be responsible for writing a message for their public APIs.
|
OK I finally figured this out -- the problem is not the lack of a FixAll Provider, it's that the SyntaxEditor is shared via lambda capturing among multiple different invocations of the analyzer. Since the SyntaxEditor is mutable, this causes a race in addition attributes to the tree. Your change fixes the problem by avoiding sharing the editor instance across multiple invocations. It's probably hard to write a test to reveal this problem (and probably not worth it to write one). If you can narrow down the fix to just that area I think we should take this for 6.0 |
agocke
left a comment
There was a problem hiding this comment.
LGTM aside from minor suggestions
|
@mateoatr Can you backport to 6.0? |
* PR feedback * Remove unnecessary method
Backport of #2250 Applying code fixes suggested by our fixer was causing multiple applications of the same fix (see here). This was caused by a race condition due to sharing the same instance of a SyntaxEditor across multiple invocations (see comment).
) * PR feedback * Remove unnecessary method Commit migrated from dotnet/linker@23f5f59
Fixes #2149.