File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ public override void Populate(TextWriter trapFile)
8181 }
8282
8383 // Class location
84- if ( ( ! Symbol . IsGenericType || Symbol . IsReallyUnbound ( ) ) && Context . ExtractLocation ( Symbol ) )
84+ if ( ! Symbol . IsGenericType || Symbol . IsReallyUnbound ( ) )
8585 {
8686 WriteLocationsToTrap ( trapFile . type_location , this , Locations ) ;
8787 }
@@ -111,15 +111,18 @@ public override IEnumerable<Location> Locations
111111 }
112112 }
113113
114- private static IEnumerable < Microsoft . CodeAnalysis . Location > GetLocations ( INamedTypeSymbol type )
114+ private IEnumerable < Microsoft . CodeAnalysis . Location > GetLocations ( INamedTypeSymbol type )
115115 {
116- return type . Locations
117- . Where ( l => l . IsInMetadata )
118- . Concat ( type . DeclaringSyntaxReferences
116+ var metadataLocations = type . Locations
117+ . Where ( l => l . IsInMetadata ) ;
118+ var sourceLocations = type . DeclaringSyntaxReferences
119119 . Select ( loc => loc . GetSyntax ( ) )
120120 . OfType < CSharpSyntaxNode > ( )
121121 . Select ( l => l . FixedLocation ( ) )
122- ) ;
122+ . Where ( Context . IsLocationInContext ) ;
123+
124+ return metadataLocations
125+ . Concat ( sourceLocations ) ;
123126 }
124127
125128 public override Microsoft . CodeAnalysis . Location ? ReportingLocation => GetLocations ( Symbol ) . BestOrDefault ( ) ;
Original file line number Diff line number Diff line change @@ -554,6 +554,9 @@ public bool ExtractLocation(ISymbol symbol) =>
554554 SymbolEqualityComparer . Default . Equals ( symbol , symbol . OriginalDefinition ) &&
555555 scope . InScope ( symbol ) ;
556556
557+ public bool IsLocationInContext ( Location location ) =>
558+ location . SourceTree == SourceTree ;
559+
557560 /// <summary>
558561 /// Runs the given action <paramref name="a"/>, guarding for trap duplication
559562 /// based on key <paramref name="key"/>.
You can’t perform that action at this time.
0 commit comments