Skip to content

Commit 12dc65d

Browse files
committed
C#: For implicit constructors, pick a unique source location as reporting location (if any).
1 parent b5592ad commit 12dc65d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Constructor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ public override Microsoft.CodeAnalysis.Location? ReportingLocation
222222

223223
if (Symbol.IsImplicitlyDeclared)
224224
{
225-
return ContainingType!.ReportingLocation;
225+
var best = Symbol.Locations.Where(l => l.IsInSource).BestOrDefault();
226+
return best ?? ContainingType!.ReportingLocation;
226227
}
227228

228229
return Symbol.ContainingType.Locations.FirstOrDefault();

0 commit comments

Comments
 (0)