Skip to content

Commit db9ba92

Browse files
committed
Guard null path at GetDiagnosticString.
1 parent 40cca3b commit db9ba92

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/IncrementalCompiler/Compiler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ private string GetDiagnosticString(Diagnostic diagnostic, string type)
268268
{
269269
var line = diagnostic.Location.GetLineSpan();
270270

271+
// Path could be null
272+
if (string.IsNullOrEmpty(line.Path))
273+
return $"None: " + $"{type} {diagnostic.Id}: {diagnostic.GetMessage()}";
274+
271275
// Unity3d must have a relative path starting with "Assets/".
272276
var path = (line.Path.StartsWith(_options.WorkDirectory + "/") || line.Path.StartsWith(_options.WorkDirectory + "\\"))
273277
? line.Path.Substring(_options.WorkDirectory.Length + 1)

0 commit comments

Comments
 (0)