Razor Formatting Log Investigation
Use this skill when:
- investigating a Razor formatting issue from Visual Studio or VS Code feedback
- given an Azure DevOps work item, Developer Community ticket, or GitHub issue that includes a formatting log zip
- asked to import a
Full_*_razor.ziporRange_*_razor.ziparchive into the test suite
Goal
- Get a local path to the formatting log archive.
- Import every file from that zip into
src\Razor\src\Razor\test\Microsoft.VisualStudio.LanguageServices.Razor.UnitTests\TestFiles\FormattingLog\<TestName>\. - Add a matching
[Fact]tosrc\Razor\src\Razor\test\Microsoft.VisualStudio.LanguageServices.Razor.UnitTests\Cohost\Formatting\FormattingLogTest.cs. - Run the imported formatting log test.
- If it passes, report that the issue captured in the logs no longer reproduces.
- If it fails, keep the imported repro, reduce it to a minimal
DocumentFormattingTest, and then fix the product code.
Finding the archive
Azure DevOps / VS feedback ticket
- Read the work item and comments with the Azure DevOps tools so you know which attachment to ask for.
- Do not try to download Developer Community or Azure DevOps feedback attachments yourself. The available tooling cannot reliably fetch those private files.
- Ask the user to download the
Full_*_razor.ziporRange_*_razor.zipattachment locally and give you the absolute zip path. - Continue only after the user has provided that local path.
GitHub issue
- Read the issue body and comments.
- Look for uploaded zip attachments or linked archives with the same naming pattern.
- If the archive is directly downloadable, download it to a temporary folder. Otherwise ask the user to download it and provide a local path.
Import the logs
Use the helper script in this skill:
.\.github\skills\formatting-log\scripts\Import-FormattingLog.ps1 `
-ZipPath C:\Users\dawengie\Downloads\Range_Index_razor.zip `
-WorkItemUrl https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2878103 `
-TestName RanOutOfOriginalLines
-ZipPathmust be a local file path. For Developer Community and Azure DevOps feedback tickets, ask the user to download the archive first instead of trying to fetch it yourself.-TestNamedefaults to a sanitized name derived from the zip filename. Override it when you want a shorter or more descriptive repro name.- Keep the folder name and the test name identical.
- Use
-Expectation Nullonly when the correct outcome is that all edits should be filtered out. Otherwise keep the defaultNotNull. - The script copies every extracted file into the new test asset folder and appends the matching test method to
src\Razor\src\Razor\test\Microsoft.VisualStudio.LanguageServices.Razor.UnitTests\Cohost\Formatting\FormattingLogTest.cs.
Run the imported test
dotnet test src\Razor\src\Razor\test\Microsoft.VisualStudio.LanguageServices.Razor.UnitTests\Microsoft.VisualStudio.LanguageServices.Razor.UnitTests.csproj --filter "FullyQualifiedName~FormattingLogTest.<TestName>"
Do not run dotnet test at the repo root.
Interpreting the result
- Test passes: report that the problem captured in the logs no longer reproduces.
- Test fails: continue with a minimal repro and product fix.
When the imported log test fails
- Commit the imported formatting log assets and
FormattingLogTest.cschange by themselves. - Reduce the failure to a focused repro in
src\Razor\src\Razor\test\Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests\Formatting\DocumentFormattingTest.cs. - Commit the minimal repro by itself.
- Fix the product code.
- Commit the fix by itself.
- Re-run the imported
FormattingLogTestplus the focusedDocumentFormattingTestcoverage.
The formatting-log test, the minimal repro, and the fix should stay as separate commits during the investigation.
Notes
- If the user only gives you a Developer Community or Azure DevOps ticket URL, stop and ask them to download the zip before proceeding.
FormattingLogTestaccepts both real range payloads and literalnullRange.jsonfiles from full-document logs.- Imported log zips often contain more files than the test currently consumes. Keep them all in the test asset folder.
- Prefer adding
[WorkItem("...")]with the originating Azure DevOps or GitHub URL on the imported test.