C#: Update the extractor to use the BestOrDefault extension method to choose between multiple locations.

This commit is contained in:
Michael Nebel
2024-06-25 15:50:44 +02:00
parent dd65d960be
commit e15a47d58c
12 changed files with 12 additions and 13 deletions

View File

@@ -379,7 +379,7 @@ namespace Semmle.Extraction
{
if (!(optionalSymbol is null))
{
ExtractionError(message, optionalSymbol.ToDisplayString(), CreateLocation(optionalSymbol.Locations.FirstOrDefault()));
ExtractionError(message, optionalSymbol.ToDisplayString(), CreateLocation(optionalSymbol.Locations.BestOrDefault()));
}
else if (!(optionalEntity is null))
{

View File

@@ -13,7 +13,7 @@ namespace Semmle.Extraction
{
Text = msg;
EntityText = symbol.ToString() ?? "";
Location = symbol.Locations.FirstOrDefault();
Location = symbol.Locations.BestOrDefault();
}
public InternalError(SyntaxNode node, string msg)

View File

@@ -27,7 +27,7 @@ namespace Semmle.Extraction
public static Message Create(Context cx, string text, ISymbol symbol, string? stackTrace = null, Severity severity = Severity.Error)
{
return new Message(text, symbol.ToString(), cx.CreateLocation(symbol.Locations.FirstOrDefault()), stackTrace, severity);
return new Message(text, symbol.ToString(), cx.CreateLocation(symbol.Locations.BestOrDefault()), stackTrace, severity);
}
public static Message Create(Context cx, string text, SyntaxNode node, string? stackTrace = null, Severity severity = Severity.Error)