diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Base/CachedSymbol.cs b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Base/CachedSymbol.cs
index 92861e97fdd8..c10d7865a5bc 100644
--- a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Base/CachedSymbol.cs
+++ b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Base/CachedSymbol.cs
@@ -81,12 +81,12 @@ protected void ExtractCompilerGenerated(TextWriter trapFile)
/// The location which is stored in the database and is used when highlighting source code.
/// It's generally short, e.g. a method name.
///
- public override Microsoft.CodeAnalysis.Location? ReportingLocation => Symbol.Locations.BestOrDefault();
+ public override Microsoft.CodeAnalysis.Location? ReportingLocation => Context.GetMsLocations(Symbol).BestOrDefault();
///
/// The full text span of the entity, e.g. for binding comments.
///
- public virtual Microsoft.CodeAnalysis.Location? FullLocation => Symbol.Locations.BestOrDefault();
+ public virtual Microsoft.CodeAnalysis.Location? FullLocation => Context.GetMsLocations(Symbol).BestOrDefault();
public virtual IEnumerable Locations
{
diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Parameter.cs b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Parameter.cs
index a5d208fc86fe..36c8292b3f8b 100644
--- a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Parameter.cs
+++ b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Parameter.cs
@@ -115,10 +115,9 @@ public override void Populate(TextWriter trapFile)
var type = Type.Create(Context, Symbol.Type);
trapFile.@params(this, Name, type.TypeRef, Ordinal, ParamKind, Parent!, Original);
- foreach (var l in Symbol.Locations)
- {
- WriteLocationToTrap(trapFile.param_location, this, Context.CreateLocation(l));
- }
+ var locations = Context.GetLocations(Symbol);
+
+ WriteLocationsToTrap(trapFile.param_location, this, locations);
if (!Symbol.Locations.Any() &&
Symbol.ContainingSymbol is IMethodSymbol ms &&
diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Extractor/Context.cs b/csharp/extractor/Semmle.Extraction.CSharp/Extractor/Context.cs
index 74b3b186b517..7a5524fd8778 100644
--- a/csharp/extractor/Semmle.Extraction.CSharp/Extractor/Context.cs
+++ b/csharp/extractor/Semmle.Extraction.CSharp/Extractor/Context.cs
@@ -562,10 +562,20 @@ public bool ExtractLocation(ISymbol symbol) =>
/// The symbol
/// List of locations
public IEnumerable GetLocations(ISymbol symbol) =>
- symbol.Locations
- .Where(l => !l.IsInSource || IsLocationInContext(l))
+ GetMsLocations(symbol)
.Select(CreateLocation);
+ ///
+ /// Gets the locations of the symbol that are either
+ /// (1) In assemblies.
+ /// (2) In the current context.
+ ///
+ /// The symbol
+ /// List of locations
+ public IEnumerable GetMsLocations(ISymbol symbol) =>
+ symbol.Locations
+ .Where(l => !l.IsInSource || IsLocationInContext(l));
+
public bool IsLocationInContext(Location location) =>
location.SourceTree == SourceTree;