Skip to content

Commit f43c01c

Browse files
authored
Remove Html source mappings from the compiler (#12003)
I added Html source mappings to the compiler a little while ago, in order to alter how Html documents are produced, to try to improve the story around diagnostics, specifically with JavaScript and CSS language services having trouble interpreting the `~`s we produce in place of C# code in Html documents. The theory was also to improve some formatting quirks, but the old formatting engine proved such a pain to update to support source mappings, or any type of alternate Html document generation, that we never actually used the feature in tooling. In hindsight, I don't think we'll ever be able to actual use the system, so it seems pretty wasteful to have the compiler produce this extra data, and to process it for no reason in tooling. The reason we won't be able to use it is because we fundamentally don't understand what we'd need to output in place of the C# anyway, and since we've moved to outputting `/*~~*/` comments in place of long runs of C#, the number of issues we see from the system has dropped dramatically. Essentially, given something like: ``` <style> body { font-size: @fontsize } </style> <script> [email protected] = "Font size is " + @fontsize alert(@message); </script> ``` In order to produce "better" Html documents, we'd have to understand, for each piece of C#, the underlying context in either Html, Css or JavaScript, in order to output something that compiles. If we can't do that, outputting comments as we currently do is just as good, so the only thing Html source mappings would buy us is the ability to not have to match 1:1 document coordinates with Razor, but it doesn't seem to me like that cost is very high. Feel free to disagree if you think this system is worth keeping in place for the future, I'm happy to discuss. Oh, commit-at-a-time is probably best, otherwise GitHub might complain.
2 parents 72b6208 + d2428a2 commit f43c01c

File tree

142 files changed

+278
-5069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+278
-5069
lines changed

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ private void DesignTimeTest(string testName)
347347
AssertHtmlDocumentMatchesBaseline(codeDocument.GetHtmlDocument(), testName);
348348
AssertCSharpDocumentMatchesBaseline(codeDocument.GetRequiredCSharpDocument(), testName);
349349
AssertSourceMappingsMatchBaseline(codeDocument, testName);
350-
AssertHtmlSourceMappingsMatchBaseline(codeDocument, testName);
351350
AssertLinePragmas(codeDocument);
352351
AssertCSharpDiagnosticsMatchBaseline(codeDocument, testName);
353352
}
@@ -417,7 +416,6 @@ private void RunDesignTimeTagHelpersTest(IEnumerable<TagHelperDescriptor> descri
417416
AssertDocumentNodeMatchesBaseline(codeDocument.GetRequiredDocumentNode(), testName);
418417
AssertCSharpDocumentMatchesBaseline(codeDocument.GetRequiredCSharpDocument(), testName);
419418
AssertHtmlDocumentMatchesBaseline(codeDocument.GetHtmlDocument(), testName);
420-
AssertHtmlSourceMappingsMatchBaseline(codeDocument, testName);
421419
AssertSourceMappingsMatchBaseline(codeDocument, testName);
422420
AssertCSharpDiagnosticsMatchBaseline(codeDocument, testName);
423421
}

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.html.mappings.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeDirective_DesignTime.html.mappings.txt

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.html.mappings.txt

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.html.mappings.txt

Lines changed: 0 additions & 130 deletions
This file was deleted.

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.html.mappings.txt

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.html.mappings.txt

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_RemoveTagHelper_DesignTime.html.mappings.txt

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)