diff options
author | Isabel Serrato <56236284+iserrato@users.noreply.github.com> | 2022-08-19 23:35:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-19 23:35:50 +0300 |
commit | 22d2a37d1e8d2fac67b6745af34a8f6b6499343d (patch) | |
tree | a807c7e7754e6ab7718a630a9e48589f9e7ecfa6 /src | |
parent | 9332578bfd67d8b1e53a3cbf9e0f92d5af7186ac (diff) |
Generate attribute in Code Fix (#2985)
Diffstat (limited to 'src')
-rw-r--r-- | src/ILLink.CodeFix/DAMCodeFixProvider.cs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ILLink.CodeFix/DAMCodeFixProvider.cs b/src/ILLink.CodeFix/DAMCodeFixProvider.cs index a8c13d89f..e36222918 100644 --- a/src/ILLink.CodeFix/DAMCodeFixProvider.cs +++ b/src/ILLink.CodeFix/DAMCodeFixProvider.cs @@ -105,7 +105,6 @@ namespace ILLink.CodeFix return; var syntaxGenerator = SyntaxGenerator.GetGenerator (document); - var attributeArguments = new[] { syntaxGenerator.AttributeArgument (syntaxGenerator.MemberAccessExpression (syntaxGenerator.DottedName ("System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes"), stringArgs)) }; if (await document.GetSemanticModelAsync (context.CancellationToken).ConfigureAwait (false) is not { } model) return; if (model.Compilation.GetTypeByMetadataName (FullyQualifiedAttributeName) is not { } attributeSymbol) @@ -117,7 +116,7 @@ namespace ILLink.CodeFix createChangedDocument: ct => AddAttributeAsync ( document, attributableNode, - attributeArguments, + stringArgs, attributeSymbol, addAsReturnAttribute: AttributeOnReturn.Contains (diagnostic.Id), addGenericParameterAttribute: AttributeOnGeneric.Contains (diagnostic.Id), @@ -128,7 +127,7 @@ namespace ILLink.CodeFix private static async Task<Document> AddAttributeAsync ( Document document, SyntaxNode targetNode, - SyntaxNode[] attributeArguments, + string stringArguments, ITypeSymbol attributeSymbol, bool addAsReturnAttribute, bool addGenericParameterAttribute, @@ -136,6 +135,7 @@ namespace ILLink.CodeFix { var editor = await DocumentEditor.CreateAsync (document, cancellationToken).ConfigureAwait (false); var generator = editor.Generator; + var attributeArguments = new[] { generator.AttributeArgument (generator.MemberAccessExpression (generator.DottedName ("System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes"), stringArguments)) }; var attribute = generator.Attribute ( generator.TypeExpression (attributeSymbol), attributeArguments) .WithAdditionalAnnotations (Simplifier.Annotation, Simplifier.AddImportsAnnotation); |