File tree Expand file tree Collapse file tree
src/PolySharp.SourceGenerators/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,18 +50,51 @@ public static bool HasAccessibleTypeWithMetadataName(this Compilation compilatio
5050 // If there is only a single matching symbol, check its accessibility
5151 if ( compilation . GetTypeByMetadataName ( fullyQualifiedMetadataName ) is INamedTypeSymbol typeSymbol )
5252 {
53- return compilation . IsSymbolAccessibleWithin ( typeSymbol , compilation . Assembly ) ;
53+ return isSymbolAccessible ( typeSymbol ) ;
5454 }
5555
5656 // Otherwise, check all available types
5757 foreach ( INamedTypeSymbol currentTypeSymbol in compilation . GetTypesByMetadataName ( fullyQualifiedMetadataName ) )
5858 {
59- if ( compilation . IsSymbolAccessibleWithin ( currentTypeSymbol , compilation . Assembly ) )
59+ if ( isSymbolAccessible ( currentTypeSymbol ) )
6060 {
6161 return true ;
6262 }
6363 }
6464
6565 return false ;
66+
67+ bool isSymbolAccessible ( INamedTypeSymbol symbol )
68+ {
69+ if ( ! compilation . IsSymbolAccessibleWithin ( symbol , compilation . Assembly ) )
70+ {
71+ return false ;
72+ }
73+ else if ( ! SymbolEqualityComparer . Default . Equals ( compilation . Assembly , symbol . ContainingAssembly ) )
74+ {
75+ foreach ( AttributeData attribute in symbol . GetAttributes ( ) )
76+ {
77+ if ( attribute . AttributeClass is
78+ {
79+ ContainingNamespace :
80+ {
81+ ContainingNamespace :
82+ {
83+ ContainingNamespace . IsGlobalNamespace : true ,
84+ Name : "Microsoft" ,
85+ } ,
86+ Name : "CodeAnalysis" ,
87+
88+ } ,
89+ Name : "EmbeddedAttribute" ,
90+ } )
91+ {
92+ return false ;
93+ }
94+ }
95+ }
96+
97+ return true ;
98+ }
6699 }
67100}
You can’t perform that action at this time.
0 commit comments