mirror of
https://github.com/github/codeql.git
synced 2026-04-22 23:35:14 +02:00
Merge pull request #6773 from tamasvajk/fix/global-stmt-library
C#: Handle invalid code gracefully: global statements in library
This commit is contained in:
@@ -59,8 +59,15 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
return;
|
||||
}
|
||||
|
||||
var entryPoint = Cx.Compilation.GetEntryPoint(System.Threading.CancellationToken.None)!;
|
||||
var entryPoint = Cx.Compilation.GetEntryPoint(System.Threading.CancellationToken.None);
|
||||
var entryMethod = Method.Create(Cx, entryPoint);
|
||||
if (entryMethod is null)
|
||||
{
|
||||
Cx.ExtractionError("No entry method found. Skipping the extraction of global statements.",
|
||||
null, Cx.CreateLocation(globalStatements[0].GetLocation()), null, Severity.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
var block = GlobalStatementsBlock.Create(Cx, entryMethod);
|
||||
|
||||
for (var i = 0; i < globalStatements.Count; i++)
|
||||
|
||||
Reference in New Issue
Block a user