-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Added SourceLocation to inherited chunks \ tag helpers #2390
Conversation
Updated CompilationResult to support compilation failures from multiple files. Fixes #2321
Ties into Diagnostics changes - aspnet/Diagnostics#123 and Razor changes - aspnet/Razor#357. The error page from Helios already supports multiple error files. |
{ | ||
var sourceFilePath = group.Key; | ||
string sourceFileContent; | ||
if (string.Equals(assemblyName, sourceFilePath, StringComparison.Ordinal)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows us to show errors if they happen to be produced in the generated code (for instance a custom base type that does not have a RenderAsync
method). Mapping it to the cshtml file is not very helpful in diagnosing the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a very general statement and doesn't seem correct. if it were correct, Razor would not generate #line
pragmas at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or, are you commenting only on the case where the #line
mapping is currently hidden
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is for generated code that we produce but don't map back to the cshtml - this includes things like default inherited directives (IHtmlHelper<TModel>
) and any code that relies on a property \ method being present on the base type DefineSection
, RenderAsync
etc).
- I have a tracking bug for the first case - When code-gening inherited chunks that replace TModel token, wrap it in line pragmas #2373.
- I wasn't able to find the bug the last time I looked - Razor CompilationFailedExceptions contain design-time-missing content and incorrect line/column information #1968. Mapping to the generated code should give you more more useful information for errors of this sort.
|
|
||
public RazorCompilationService(ICompilationService compilationService, | ||
IMvcRazorHost razorHost) | ||
IMvcRazorHost razorHost, | ||
IOptions<RazorViewEngineOptions> viewEngineOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious: Why not just do IFileProvider
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file system that we use for views specifically hangs off of RazorViewEngineOptions
. It allows doing things like using resources as view sources - https://github.com/aspnet/Mvc/blob/dev/test/WebSites/RazorEmbeddedViewsWebSite/Startup.cs#L20-L23
|
Updated CompilationResult to support compilation failures from multiple
files.
Fixes #2321