Skip to content

Commit a9a55df

Browse files
committed
C#: In Assets parser let TryReadAllText return null on read error.
1 parent d3e047f commit a9a55df

File tree

1 file changed

+3
-2
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.IO;
45
using System.Linq;
56
using Newtonsoft.Json.Linq;
@@ -143,7 +144,7 @@ public bool TryParse(string json, DependencyContainer dependencies)
143144
}
144145
}
145146

146-
private static bool TryReadAllText(string path, ProgressMonitor progressMonitor, out string content)
147+
private static bool TryReadAllText(string path, ProgressMonitor progressMonitor, [NotNullWhen(returnValue: true)] out string? content)
147148
{
148149
try
149150
{
@@ -153,7 +154,7 @@ private static bool TryReadAllText(string path, ProgressMonitor progressMonitor,
153154
catch (Exception e)
154155
{
155156
progressMonitor.LogInfo($"Failed to read assets file '{path}': {e.Message}");
156-
content = "";
157+
content = null;
157158
return false;
158159
}
159160
}

0 commit comments

Comments
 (0)