mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Improve global.json file parsing
This commit is contained in:
@@ -131,11 +131,16 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
try
|
||||
{
|
||||
var o = JObject.Parse(File.ReadAllText(path));
|
||||
versions.Add((string)o?["sdk"]?["version"]!);
|
||||
var v = (string?)o?["sdk"]?["version"];
|
||||
if (v is not null)
|
||||
{
|
||||
versions.Add(v);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// not a valid `global.json` file
|
||||
logger.LogInfo($"Couldn't find .NET SDK version in '{path}'.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user