Skip to content

Commit ea38bf5

Browse files
committed
C#: Improve global.json file parsing
1 parent 66d2a84 commit ea38bf5

File tree

1 file changed

+6
-1
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching

1 file changed

+6
-1
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,16 @@ private static BuildScript DownloadDotNet(IBuildActions actions, ILogger logger,
131131
try
132132
{
133133
var o = JObject.Parse(File.ReadAllText(path));
134-
versions.Add((string)o?["sdk"]?["version"]!);
134+
var v = (string?)o?["sdk"]?["version"];
135+
if (v is not null)
136+
{
137+
versions.Add(v);
138+
}
135139
}
136140
catch
137141
{
138142
// not a valid `global.json` file
143+
logger.LogInfo($"Couldn't find .NET SDK version in '{path}'.");
139144
continue;
140145
}
141146
}

0 commit comments

Comments
 (0)