Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit 0ddcd54

Browse files
author
YishaiGalatzer
committed
Update razor precompilation diagnostics:
consistently add razor errors to diagnostics. This will start producing proper errors with line numbers when Roslyn updates the default diagnostics formatter.
1 parent f33eec4 commit 0ddcd54

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Microsoft.AspNet.Mvc.Razor/Razor/PreCompileViews/RazorPreCompiler.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ protected virtual RazorFileInfo ParseView([NotNull] RelativeFileInfo fileInfo,
120120
{
121121
var results = _host.GenerateCode(fileInfo.RelativePath, stream);
122122

123+
foreach (var parserError in results.ParserErrors)
124+
{
125+
var diagnostic = parserError.ToDiagnostics(fileInfo.FileInfo.PhysicalPath);
126+
context.Diagnostics.Add(diagnostic);
127+
}
128+
123129
var generatedCode = results.GeneratedCode;
124130

125131
if (generatedCode != null)
@@ -143,14 +149,8 @@ protected virtual RazorFileInfo ParseView([NotNull] RelativeFileInfo fileInfo,
143149
};
144150
}
145151
}
146-
147-
foreach (var parserError in results.ParserErrors)
148-
{
149-
context.Diagnostics.Add(parserError.ToDiagnostics(fileInfo.FileInfo.PhysicalPath));
150-
}
151152
}
152153

153-
// TODO: Add diagnostics when view parsing/code generation failed.
154154
return null;
155155
}
156156
}

0 commit comments

Comments
 (0)