Skip to content

Commit 59b923b

Browse files
committed
Fix file path in diagnostic messages. #7
Unity only can understand a relative path in diagnostic messages.
1 parent 0a0b1c8 commit 59b923b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/IncrementalCompiler/Compiler.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,16 @@ private void Emit(CompileResult result)
264264
}
265265
}
266266

267-
private static string GetDiagnosticString(Diagnostic diagnostic, string type)
267+
private string GetDiagnosticString(Diagnostic diagnostic, string type)
268268
{
269269
var line = diagnostic.Location.GetLineSpan();
270-
return $"{line.Path}({line.StartLinePosition.Line + 1},{line.StartLinePosition.Character + 1}): " + $"{type} {diagnostic.Id}: {diagnostic.GetMessage()}";
270+
271+
// Unity3d must have a relative path starting with "Assets/".
272+
var path = (line.Path.StartsWith(_options.WorkDirectory + "/") || line.Path.StartsWith(_options.WorkDirectory + "\\"))
273+
? line.Path.Substring(_options.WorkDirectory.Length + 1)
274+
: line.Path;
275+
276+
return $"{path}({line.StartLinePosition.Line + 1},{line.StartLinePosition.Character + 1}): " + $"{type} {diagnostic.Id}: {diagnostic.GetMessage()}";
271277
}
272278

273279
public static int ConvertPdb2Mdb(string dllFile)

0 commit comments

Comments
 (0)