Skip to content

Better align Razor with Roslyn's misc file Uri handling - #85019

Merged
davidwengier merged 2 commits into
dotnet:mainfrom
davidwengier:fix-razor-virtual-uri-classification
Aug 26, 2026
Merged

Better align Razor with Roslyn's misc file Uri handling#85019
davidwengier merged 2 commits into
dotnet:mainfrom
davidwengier:fix-razor-virtual-uri-classification

Conversation

@davidwengier

@davidwengier davidwengier commented Aug 25, 2026

Copy link
Copy Markdown
Member

Fixes dotnet/vscode-csharp#9353
Fixes dotnet/vscode-csharp#9464
Fixes dotnet/vscode-csharp#9678

This check assumed that a document file path is just a file path, but for some odd Uris Roslyn will set the document file path to the raw Uri from the incoming request, which failed.

Microsoft Reviewers: Open in CodeFlow

@davidwengier
davidwengier requested a review from a team as a code owner August 25, 2026 02:07
Copilot AI lite review requested due to automatic review settings August 25, 2026 02:07
@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.

Pull request overview

This PR updates Remote Razor’s additional-document classification so that “file paths” that are actually absolute URIs (including query/fragment) can still be recognized as Razor documents by inspecting the URI’s local path for .razor/.cshtml extensions.

Changes:

  • Update IsRazorDocument classification to handle additional-document FilePath values that include URI query/fragment by parsing absolute URIs and checking LocalPath extensions.
  • Add unit test coverage validating Razor vs non-Razor classification across plain paths and virtual-URI-like FilePath values.
  • Document the intended handling of virtual URIs in the Razor agent instructions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Remote.Razor.UnitTests/RemoteWorkspaceProviderTest.cs Adds a theory validating IsRazorDocument/ContainsRazorDocuments for plain paths and URI-like file paths with queries.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/Extensions.cs Enhances Razor-document detection to handle absolute URIs where query/fragment obscures the extension in the raw FilePath string.
.github/instructions/Razor.instructions.md Documents the recommended approach for Razor document identity vs extension checks when FilePath is an absolute URI.

Copilot AI review requested due to automatic review settings August 25, 2026 03:52

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

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.

Project does not contain any Razor documents ww 3rd party extension is creating URIs that are mistaken for file URIs

3 participants