Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoussef Victor <youssefvictor00@gmail.com>2022-08-01 20:45:25 +0300
committerGitHub <noreply@github.com>2022-08-01 20:45:25 +0300
commit8b176742b2160d78fd5712b65343dddade4d40ab (patch)
treeedfb4c449250f1dba23bfddbf701a12c3787e2a7
parentd0ca2a6646ad5b35208ee2428a3feeb78df16602 (diff)
Update DAMCodeFixProvider.cs (#2932)
Add ExportCodeFixProvider attribute Co-authored-by: Isabel Serrato <iserrato@olin.edu>
-rw-r--r--src/ILLink.CodeFix/DAMCodeFixProvider.cs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/ILLink.CodeFix/DAMCodeFixProvider.cs b/src/ILLink.CodeFix/DAMCodeFixProvider.cs
index 60de66cea..5aac3eb0c 100644
--- a/src/ILLink.CodeFix/DAMCodeFixProvider.cs
+++ b/src/ILLink.CodeFix/DAMCodeFixProvider.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Immutable;
+using System.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -19,25 +20,25 @@ using Microsoft.CodeAnalysis.Simplification;
namespace ILLink.CodeFix
{
- public class DAMCodeFixProvider : Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider
+ [ExportCodeFixProvider (LanguageNames.CSharp, Name = nameof (DAMCodeFixProvider)), Shared]
+ public sealed class DAMCodeFixProvider : Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider
{
- public static ImmutableArray<DiagnosticDescriptor> GetSupportedDiagnostics ()
+ private static ImmutableArray<DiagnosticDescriptor> GetSupportedDiagnostics ()
{
- var diagDescriptorsArrayBuilder = ImmutableArray.CreateBuilder<DiagnosticDescriptor> ();
- diagDescriptorsArrayBuilder.Add (DiagnosticDescriptors.GetDiagnosticDescriptor (DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsThisParameter));
- diagDescriptorsArrayBuilder.Add (DiagnosticDescriptors.GetDiagnosticDescriptor (DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsThisParameter));
- return diagDescriptorsArrayBuilder.ToImmutable ();
+ return ImmutableArray.Create (
+ DiagnosticDescriptors.GetDiagnosticDescriptor (DiagnosticId.DynamicallyAccessedMembersMismatchParameterTargetsThisParameter),
+ DiagnosticDescriptors.GetDiagnosticDescriptor (DiagnosticId.DynamicallyAccessedMembersMismatchFieldTargetsThisParameter));
}
public static ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => GetSupportedDiagnostics ();
public sealed override ImmutableArray<string> FixableDiagnosticIds => SupportedDiagnostics.Select (dd => dd.Id).ToImmutableArray ();
- private protected static LocalizableString CodeFixTitle => new LocalizableResourceString (nameof (Resources.DynamicallyAccessedMembersCodeFixTitle), Resources.ResourceManager, typeof (Resources));
+ private static LocalizableString CodeFixTitle => new LocalizableResourceString (nameof (Resources.DynamicallyAccessedMembersCodeFixTitle), Resources.ResourceManager, typeof (Resources));
- private protected static string FullyQualifiedAttributeName => DynamicallyAccessedMembersAnalyzer.FullyQualifiedDynamicallyAccessedMembersAttribute;
+ private static string FullyQualifiedAttributeName => DynamicallyAccessedMembersAnalyzer.FullyQualifiedDynamicallyAccessedMembersAttribute;
- protected static SyntaxNode[] GetAttributeArguments (ISymbol targetSymbol, SyntaxGenerator syntaxGenerator, Diagnostic diagnostic)
+ private static SyntaxNode[] GetAttributeArguments (ISymbol targetSymbol, SyntaxGenerator syntaxGenerator, Diagnostic diagnostic)
{
object id = Enum.Parse (typeof (DiagnosticId), diagnostic.Id.Substring (2));
switch (id) {
@@ -61,7 +62,7 @@ namespace ILLink.CodeFix
var document = context.Document;
if (await document.GetSyntaxRootAsync (context.CancellationToken).ConfigureAwait (false) is not { } root)
return;
- var diagnostic = context.Diagnostics.First ();
+ var diagnostic = context.Diagnostics[0];
SyntaxNode diagnosticNode = root.FindNode (diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
if (await document.GetSemanticModelAsync (context.CancellationToken).ConfigureAwait (false) is not { } model)
return;