C#: Improve global.json file parsing

This commit is contained in:
Tamas Vajk
2024-03-07 15:35:06 +01:00
parent 66d2a8499d
commit ea38bf5ebc

View File

@@ -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;
}
}