Open YoshiRulz opened 1 month ago
I agree that the file structure is difficult to follow. ASP.NET is heavily convention based and I haven't kept up on the conventions.
I propose that every source file which 'renders' output should also include its own path as a simple HTML comment
Does that mean the final emitted markup served to the end user would have these comments in it? Would that inflate our document size too much?
Just as a ballpark figure I'd say the worst-affected pages would grow by at most 1 KiB before compression. This could be locked to only development environments if that's a problem, given that contributors are expected to test locally anyway.
One idea is to add one line to _ViewStart.cshtml
that does something similar.
<!-- @(Html.ViewContext.View.Path) -->
Result:
But this only works for views, not for partials.
Okay actually, we can override (or I think it's called to shadow) the Activate
method of the RazorPageActivator
and use that in the services.
This way we see the beginning of every new view or partial or other things. (Not the end though, since there is no "Deactivate".)
My experience with contributing to the site, being a novice to ASP.NET, has involved a lot of grepping the codebase for tag/attribute names in order to find the source file where the thing I'm looking at originates. I've since learned that the directory structure under
/TASVideos/Pages
roughly corresponds to page paths, but that doesn't account for 'partials'. I propose that every source file which 'renders' output should also include its own path as a simple HTML comment, such that more people might be able to submit fixes or at least precisely identify where problems are. I've found thatHtml.ViewContext.ExecutingFilePath
produces the right path (relative to$(ProjectDir)
), but it would be a pain to manually include that in every page and partial. Does anyone know of a better way?