@@ -17,12 +17,14 @@ 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." ;
20
+ private const string Title = "Cross-assembly internal access requires referenced item to have " + AttributeName + " attribute .";
21
21
private const 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
23
"with the attribute " + AttributeName + "." ;
24
24
private const string Description =
25
- "The ML.NET ." ;
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
28
27
29
private static DiagnosticDescriptor Rule =
28
30
new DiagnosticDescriptor ( DiagnosticId , Title , Format , Category ,
@@ -44,13 +46,13 @@ private void Analyze(SemanticModelAnalysisContext context)
44
46
var model = context . SemanticModel ;
45
47
var comp = model . Compilation ;
46
48
47
- // Get the symbols of the key types we are analyzing. If we can't find any of them there is
48
- // no point in going further.
49
- var attrType = comp . GetTypeByMetadataName ( AttributeName ) ;
50
- if ( attrType == null )
49
+ // Get the symbols of the key types we are analyzing. If we can't find either
50
+ // of them there is no point in going further.
51
+ var bestFriendAttributeType = comp . GetTypeByMetadataName ( AttributeName ) ;
52
+ if ( bestFriendAttributeType == null )
51
53
return ;
52
- var assemblyAttrType = comp . GetTypeByMetadataName ( AssemblyAttributeName ) ;
53
- if ( assemblyAttrType == null )
54
+ var wantsToBeBestFriendsAttributeType = comp . GetTypeByMetadataName ( AssemblyAttributeName ) ;
55
+ if ( wantsToBeBestFriendsAttributeType == null )
54
56
return ;
55
57
56
58
var myAssembly = comp . Assembly ;
@@ -87,12 +89,12 @@ private void Analyze(SemanticModelAnalysisContext context)
87
89
// further.
88
90
if ( ! assemblyHasAttrMap . TryGetValue ( symbolAssembly , out bool assemblyWantsBestFriends ) )
89
91
{
90
- assemblyWantsBestFriends = symbolAssembly . GetAttributes ( ) . Any ( a => a . AttributeClass == assemblyAttrType ) ;
92
+ assemblyWantsBestFriends = symbolAssembly . GetAttributes ( ) . Any ( a => a . AttributeClass == wantsToBeBestFriendsAttributeType ) ;
91
93
assemblyHasAttrMap [ symbolAssembly ] = assemblyWantsBestFriends ;
92
94
}
93
95
if ( ! assemblyWantsBestFriends )
94
96
continue ;
95
- if ( symbol . GetAttributes ( ) . Any ( a => a . AttributeClass == attrType ) )
97
+ if ( symbol . GetAttributes ( ) . Any ( a => a . AttributeClass == bestFriendAttributeType ) )
96
98
{
97
99
// You're not just a friend, you're my best friend!
98
100
continue ;
0 commit comments