Skip to content

Expose registered project file extensions - #85106

Merged
JoeRobich merged 4 commits into
mainfrom
dev/jorobich/project-extension-registry-apis
Sep 9, 2026
Merged

Expose registered project file extensions#85106
JoeRobich merged 4 commits into
mainfrom
dev/jorobich/project-extension-registry-apis

Conversation

@JoeRobich

@JoeRobich JoeRobich commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

Expose focused query APIs on ProjectFileExtensionRegistry for consumers that need to enumerate registered project extensions or resolve a language directly from an extension.

Existing project-path lookup retains file-based application compatibility; this PR only separates reusable registry queries from that behavior.

Stack

Depends on Centralize Language Server workspace folder tracking.

Validation

  • Analyzer-enabled Microsoft.CodeAnalysis.Workspaces.MSBuild build succeeded with 0 errors.
Microsoft Reviewers: Open in CodeFlow

@JoeRobich
JoeRobich requested a review from a team as a code owner August 31, 2026 16:10
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 4641429 to 288bc3c Compare August 31, 2026 16:38
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 288bc3c to 3bf7054 Compare August 31, 2026 16:53
akhera99
akhera99 previously approved these changes Aug 31, 2026
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 3bf7054 to 639cc89 Compare August 31, 2026 17:06
dibarbet
dibarbet previously approved these changes Aug 31, 2026
jasonmalinowski
jasonmalinowski previously approved these changes Sep 1, 2026
Comment thread src/Workspaces/MSBuild/Core/MSBuild/ProjectFileExtensionRegistry.cs
Comment thread src/Workspaces/MSBuild/Core/MSBuild/ProjectFileExtensionRegistry.cs
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 639cc89 to cccc725 Compare September 1, 2026 22:36
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from cccc725 to 5e4077d Compare September 2, 2026 05:24
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 5e4077d to c5022f7 Compare September 2, 2026 20:25
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from c5022f7 to 9afef8b Compare September 2, 2026 22:27
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 9afef8b to 0c7bc7f Compare September 2, 2026 23:11
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 0c7bc7f to 602d180 Compare September 3, 2026 04:29
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 602d180 to 1bcb8dc Compare September 3, 2026 05:08
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 1bcb8dc to 4e2613c Compare September 3, 2026 05:15

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.

Copilot review overview

🟢 Approval recommended

Changes are small and low-risk, and the only feedback is minor clarity/documentation improvements rather than correctness issues.

Review tier: Lite
Findings: 3 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity src/​Workspaces/​MSBuild/​Test/​NetCoreTests.cs — This test change is specifically validating that leading-dot extensions are accepted/normalized.…
Pre-existing issues (2)
Severity Finding
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — TryGetLanguageNameFromExtension() is a new query API but doesn’t document whether callers should… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — This change adds new query APIs (GetRegisteredProjectFileExtensions/TryGetLanguageNameFromExtension)… View comment
Issues resolved since last review (1)
Severity Finding
Medium severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — GetRegisteredProjectFileExtensions() returns dictionary key enumeration order, which is not… View resolved comment
Suppressed comments (1)

src/Workspaces/MSBuild/Core/MSBuild/ProjectFileExtensionRegistry.cs:60

  • TryGetLanguageNameFromExtension is a newly exposed query API but doesn’t document the accepted extension format (leading '.' allowed/ignored) or the intent that it matches Path.GetExtension inputs. Adding an XML doc comment here would help internal consumers avoid re-learning the normalization rules.
    public bool TryGetLanguageNameFromExtension(string extension, [NotNullWhen(true)] out string? languageName)
    {

Comment thread src/Workspaces/MSBuild/Test/NetCoreTests.cs
Copilot AI review requested due to automatic review settings September 4, 2026 06:48
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 72170b9 to 3462c3a Compare September 4, 2026 06:49

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.

Copilot review overview

🔵 Needs a closer look

The updated test drops coverage for the historically-supported non-dotted extension form and should validate both "cs" and ".cs" for backward compatibility.

Review tier: Lite
Findings: 3 Low severity

Pre-existing issues (3)
Severity Finding
Low severity src/​Workspaces/​MSBuild/​Test/​NetCoreTests.cs — This test change is specifically validating that leading-dot extensions are accepted/normalized.… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — TryGetLanguageNameFromExtension() is a new query API but doesn’t document whether callers should… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — This change adds new query APIs (GetRegisteredProjectFileExtensions/TryGetLanguageNameFromExtension)… View comment
Suppressed comments (1)

src/Workspaces/MSBuild/Test/NetCoreTests.cs:753

  • This test now only exercises the ".cs" form of AssociateFileExtensionWithLanguage(). Since the API historically accepted extensions without a leading dot, it would be good to cover both "cs" and ".cs" here to protect backward compatibility while also validating the new normalization behavior.
        using var workspace = CreateMSBuildWorkspace();
        workspace.AssociateFileExtensionWithLanguage(".cs", LanguageNames.CSharp);
        await workspace.OpenProjectAsync(sourceFilePath);

        // [Failure] Msbuild failed when processing the file 'Program.cs' with message:

Comment thread src/Workspaces/MSBuild/Core/MSBuild/ProjectFileExtensionRegistry.cs Outdated
Copilot AI review requested due to automatic review settings September 8, 2026 17:20

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.

Copilot review overview

🟡 Changes recommended

WorkspaceFolderTracker now reads shared state without a synchronization/visibility mechanism, which can lead to stale workspace-folder sets being observed across threads.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 Medium severity · 3 Low severity

New issues introduced by this change (1)
Severity Finding
Medium severity src/​LanguageServer/​Protocol/​Handler/​WorkspaceFolderTracker.cs — GetRequiredWorkspaceFolderPaths() now reads _workspaceFolderPaths without any synchronization, but…
Pre-existing issues (3)
Severity Finding
Low severity src/​Workspaces/​MSBuild/​Test/​NetCoreTests.cs — This test change is specifically validating that leading-dot extensions are accepted/normalized.… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — TryGetLanguageNameFromExtension() is a new query API but doesn’t document whether callers should… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — This change adds new query APIs (GetRegisteredProjectFileExtensions/TryGetLanguageNameFromExtension)… View comment

Comment thread src/LanguageServer/Protocol/Handler/WorkspaceFolderTracker.cs Outdated
Copilot AI review requested due to automatic review settings September 8, 2026 18:11
Base automatically changed from dev/jorobich/lsp-workspace-folder-tracker to main September 8, 2026 18:12
JoeRobich and others added 3 commits September 8, 2026 11:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@JoeRobich
JoeRobich force-pushed the dev/jorobich/project-extension-registry-apis branch from 75eda8e to ebe1514 Compare September 8, 2026 18:13

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.

Copilot review overview

🟡 Changes recommended

Extension normalization currently treats the single-dot string "." as an empty extension, which is a subtle behavioral change worth fixing or explicitly deciding on before merge.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 Medium severity · 4 Low severity

New issues introduced by this change (2)
Severity Finding
Medium severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.csRemoveLeadingDot currently treats the single-dot string "." as an empty extension (it returns…
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — This adds new query APIs (GetRegisteredProjectFileExtensions / TryGetLanguageNameFromExtension)…
Pre-existing issues (3)
Severity Finding
Low severity src/​Workspaces/​MSBuild/​Test/​NetCoreTests.cs — This test change is specifically validating that leading-dot extensions are accepted/normalized.… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — TryGetLanguageNameFromExtension() is a new query API but doesn’t document whether callers should… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — This change adds new query APIs (GetRegisteredProjectFileExtensions/TryGetLanguageNameFromExtension)… View comment
Issues resolved since last review (1)
Severity Finding
Medium severity src/​LanguageServer/​Protocol/​Handler/​WorkspaceFolderTracker.cs — GetRequiredWorkspaceFolderPaths() now reads _workspaceFolderPaths without any synchronization, but… View resolved comment

Comment thread src/Workspaces/MSBuild/Core/MSBuild/ProjectFileExtensionRegistry.cs Outdated
Comment thread src/Workspaces/MSBuild/Core/MSBuild/ProjectFileExtensionRegistry.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1d6a35c4-0f49-4671-b352-8cac98e9eaa4

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.

Copilot review overview

🟡 Changes recommended

It introduces a couple of correctness/maintainability issues (notably an over-strong XML doc contract and a brittle test assertion) that should be addressed before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 6 Low severity

New issues introduced by this change (2)
Severity Finding
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — The XML doc for GetRegisteredProjectFileExtensions() promises every returned extension has a…
Low severity src/​Workspaces/​MSBuild/​Test/​NetCoreTests.cs — This test hard-codes the current number of default registered extensions (3), which makes it…
Pre-existing issues (4)
Severity Finding
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — This adds new query APIs (GetRegisteredProjectFileExtensions / TryGetLanguageNameFromExtension)… View comment
Low severity src/​Workspaces/​MSBuild/​Test/​NetCoreTests.cs — This test change is specifically validating that leading-dot extensions are accepted/normalized.… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — TryGetLanguageNameFromExtension() is a new query API but doesn’t document whether callers should… View comment
Low severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.cs — This change adds new query APIs (GetRegisteredProjectFileExtensions/TryGetLanguageNameFromExtension)… View comment
Issues resolved since last review (1)
Severity Finding
Medium severity src/​Workspaces/​MSBuild/​Core/​MSBuild/​ProjectFileExtensionRegistry.csRemoveLeadingDot currently treats the single-dot string "." as an empty extension (it returns… View resolved comment

Comment thread src/Workspaces/MSBuild/Core/MSBuild/ProjectFileExtensionRegistry.cs
Comment thread src/Workspaces/MSBuild/Test/NetCoreTests.cs
@JoeRobich

Copy link
Copy Markdown
Member Author

/azp run roslyn-CI

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Comment thread .github/instructions/IDE.instructions.md
Comment thread src/LanguageServer/Protocol/Handler/IWorkspaceFolderTracker.cs

@jasonmalinowski jasonmalinowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved -- comments can be done in a mop-up.

Comment thread src/LanguageServer/Protocol/Handler/WorkspaceFolderTracker.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants