mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
C#: Update the extractor to use the BestOrDefault extension method to choose between multiple locations.
This commit is contained in:
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user