Skip to content

Don't copy generated file banners to new documents - #85682

Open
davidwengier wants to merge 1 commit into
dotnet:mainfrom
davidwengier:skip-generated-file-banners
Open

davidwengier wants to merge 1 commit into
dotnet:mainfrom
davidwengier:skip-generated-file-banners

Conversation

@davidwengier

@davidwengier davidwengier commented Sep 17, 2026

Copy link
Copy Markdown
Member

In #84670 we had to introduce a bit of a hack to Razor, to parse out and remove the generated file header from a new document we were creating, because various things in Roslyn act differently for generated files, and because the new file wasn't actually generated.

This PR is the real fix for that workaround, and removal of same. Since the new file formatting services are designed to run on new files being created, it makes no sense for them to get hints from a generated document.

Microsoft Reviewers: Open in CodeFlow

New document formatting used the hint document's banner even when that document was generated. Ignore generated hints and remove Razor's post-processing workaround.
Copilot AI lite review requested due to automatic review settings September 17, 2026 05:17
@davidwengier
davidwengier requested review from a team as code owners September 17, 2026 05:17
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved blocking issues were identified.

Pull request overview

Updates new-document formatting to ignore generated hint documents, removing the Razor-specific banner workaround.

Changes:

  • Ignore generated hint documents when copying banners.
  • Remove obsolete Razor banner cleanup.
  • Add regression test support and coverage.
File summaries
File Description
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/CSharp/CSharpCodeActionResolver.cs Removes the Razor banner workaround.
src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerNewDocumentFormattingProvider.cs Ignores generated hint documents.
src/EditorFeatures/TestUtilities/Formatting/AbstractNewDocumentFormattingServiceTests.cs Supports hint-document tests.
src/EditorFeatures/CSharpTest/Formatting/CSharpNewDocumentFormattingServiceTests.cs Adds banner regression coverage.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants