mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Improve global.json file parsing
This commit is contained in:
@@ -131,11 +131,16 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var o = JObject.Parse(File.ReadAllText(path));
|
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
|
catch
|
||||||
{
|
{
|
||||||
// not a valid `global.json` file
|
// not a valid `global.json` file
|
||||||
|
logger.LogInfo($"Couldn't find .NET SDK version in '{path}'.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user