@@ -17,21 +17,21 @@ public sealed class BestFriendAnalyzer : DiagnosticAnalyzer
17
17
private const string Category = "Access" ;
18
18
internal const string DiagnosticId = "MSML_NoBestFriendInternal" ;
19
19
20
- private const string Title = "Cross-assembly internal access requires referenced item to have " + AttributeName + " attribute." ;
21
- private const string Format = "Access of '{0}' is a cross assembly internal " +
20
+ private string Title => "Cross-assembly internal access requires referenced item to have " + _attributeName + " attribute." ;
21
+ private string Format => "Access of '{0}' is a cross assembly internal " +
22
22
"reference, and the declaring assembly wants these accesses to be on something " +
23
- "with the attribute " + AttributeName + "." ;
24
- private const string Description =
23
+ "with the attribute " + _attributeName + "." ;
24
+ private string Description =>
25
25
"The identifier indicated is defined as an internal member of an assembly that has the " +
26
- AssemblyAttributeName + " assembly-level attribute set. Even with friend access to that " +
27
- "assembly, such a usage requires that the item have the " + AttributeName + " on it." ;
26
+ _assemblyAttributeName + " assembly-level attribute set. Even with friend access to that " +
27
+ "assembly, such a usage requires that the item have the " + _attributeName + " on it." ;
28
28
29
- private static DiagnosticDescriptor Rule =
29
+ private DiagnosticDescriptor Rule =>
30
30
new DiagnosticDescriptor ( DiagnosticId , Title , Format , Category ,
31
31
DiagnosticSeverity . Warning , isEnabledByDefault : true , description : Description ) ;
32
32
33
- private const string AttributeName = "Microsoft.ML.BestFriendAttribute (or Microsoft.ML.Runtime.Internal.CpuMath.BestFriendAttribute)" ;
34
- private const string AssemblyAttributeName = "Microsoft.ML.WantsToBeBestFriendsAttribute (or Microsoft.ML.Runtime.Internal.CpuMath.WantsToBeBestFriendsAttribute)" ;
33
+ private string _attributeName ;
34
+ private string _assemblyAttributeName ;
35
35
36
36
public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics =>
37
37
ImmutableArray . Create ( Rule ) ;
@@ -110,8 +110,15 @@ private void AnalyzeCore(SemanticModelAnalysisContext context, string attributeN
110
110
111
111
private void Analyze ( SemanticModelAnalysisContext context )
112
112
{
113
- AnalyzeCore ( context , "Microsoft.ML.BestFriendAttribute" , "Microsoft.ML.WantsToBeBestFriendsAttribute" ) ;
114
- AnalyzeCore ( context , "Microsoft.ML.Hidden.BestFriendAttribute" , "Microsoft.ML.Hidden.WantsToBeBestFriendsAttribute" ) ;
113
+ // Analyzer function for BestFriend defined in Microsoft.ML
114
+ _attributeName = "Microsoft.ML.BestFriendAttribute" ;
115
+ _assemblyAttributeName = "Microsoft.ML.WantsToBeBestFriendsAttribute" ;
116
+ AnalyzeCore ( context , _attributeName , _assemblyAttributeName ) ;
117
+
118
+ // Analyzer function for BestFriend defined in Microsoft.ML.Hidden
119
+ _attributeName = "Microsoft.ML.Hidden.BestFriendAttribute" ;
120
+ _assemblyAttributeName = "Microsoft.ML.Hidden.WantsToBeBestFriendsAttribute" ;
121
+ AnalyzeCore ( context , _attributeName , _assemblyAttributeName ) ;
115
122
}
116
123
}
117
124
}
0 commit comments