Migrate MEF metadata view interfaces to concrete metadata classes#84315
Draft
olegtk wants to merge 1 commit into
Draft
Migrate MEF metadata view interfaces to concrete metadata classes#84315olegtk wants to merge 1 commit into
olegtk wants to merge 1 commit into
Conversation
Roslyn used three interface-typed MEF metadata views consumed via [ImportMany] Lazy<T, TMetadata>. Interface metadata views require VS-MEF to emit and JIT a runtime proxy class per interface. Converting them to concrete metadata classes with an IDictionary<string, object> constructor - the pattern used by every other Roslyn metadata view (e.g. WorkspaceServiceMetadata, EventListenerMetadata, LspServiceMetadataView) - avoids that proxy generation and JIT cost and makes these views consistent with the rest of the codebase. Converted: - IIntentProviderMetadata -> IntentProviderMetadata - ILspBuildOnlyDiagnosticsMetadata -> LspBuildOnlyDiagnosticsMetadata - ILspWillRenameListenerMetadata -> LspWillRenameListenerMetadata The paired [MetadataAttribute] export attributes no longer implement the metadata interface; they continue to supply the same named metadata, which the new classes read by key. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates three MEF metadata views from interface-based projections to concrete metadata classes constructed from IDictionary<string, object>, reducing VS-MEF runtime proxy/JIT overhead and aligning these views with the common Roslyn metadata pattern.
Changes:
- Replaced
ILspWillRenameListenerMetadata,ILspBuildOnlyDiagnosticsMetadata, andIIntentProviderMetadatawith concrete*Metadataclasses that read required values from the metadata dictionary by key. - Updated
[ImportMany] Lazy<T, TMetadata>consumers to use the new concrete metadata types. - Updated corresponding
[MetadataAttribute]export attributes to stop implementing the removed metadata interfaces.
Show a summary per file
| File | Description |
|---|---|
| src/LanguageServer/Protocol/Handler/Rename/WillRenameHandler.cs | Switches rename listener metadata import to LspWillRenameListenerMetadata. |
| src/LanguageServer/Protocol/Handler/Rename/LspWillRenameListenerMetadata.cs | Adds concrete metadata view for will-rename listeners (Glob). |
| src/LanguageServer/Protocol/Handler/Rename/ILspWillRenameListenerMetadata.cs | Removes interface-based metadata view. |
| src/LanguageServer/Protocol/Handler/Rename/ExportLspWillRenameListenerAttribute.cs | Stops implementing the removed metadata interface while preserving metadata properties. |
| src/LanguageServer/Protocol/Handler/Diagnostics/BuildOnlyDiagnosticIdsHandler.cs | Updates build-only diagnostics imports to LspBuildOnlyDiagnosticsMetadata. |
| src/LanguageServer/Protocol/DefaultCapabilitiesProvider.cs | Updates rename listener metadata type used to build file-operation filters. |
| src/Features/Core/Portable/Intents/IntentProviderMetadata.cs | Adds concrete metadata view for intent providers (IntentName, LanguageName). |
| src/Features/Core/Portable/Intents/IntentProviderAttribute.cs | Stops implementing the removed metadata interface while preserving metadata properties. |
| src/Features/Core/Portable/Intents/IIntentProviderMetadata.cs | Removes interface-based metadata view. |
| src/Features/Core/Portable/Diagnostics/LanguageServer/LspBuildOnlyDiagnosticsMetadata.cs | Adds concrete metadata view for build-only diagnostics (LanguageName, BuildOnlyDiagnostics). |
| src/Features/Core/Portable/Diagnostics/LanguageServer/LspBuildOnlyDiagnosticsAttribute.cs | Stops implementing the removed metadata interface while preserving metadata properties. |
| src/Features/Core/Portable/Diagnostics/LanguageServer/ILspBuildOnlyDiagnosticsMetadata.cs | Removes interface-based metadata view. |
| src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs | Updates build-only diagnostics import/field metadata type. |
| src/EditorFeatures/Core/ExternalAccess/IntelliCode/IntentProcessor.cs | Updates intent provider import/map metadata type. |
Copilot's findings
- Files reviewed: 14/14 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Roslyn had three interface-typed MEF metadata views consumed via
[ImportMany] Lazy<T, TMetadata>. Interface metadata views force VS-MEF to emit and JIT a runtime proxy class for each interface. This converts them to concrete metadata classes with anIDictionary<string, object>constructor — the pattern used by every other metadata view in Roslyn (e.g.WorkspaceServiceMetadata,EventListenerMetadata,LspServiceMetadataView) — which avoids the proxy emission/JIT cost and makes these views consistent with the rest of the codebase.Converted
IIntentProviderMetadataIntentProviderMetadataILspBuildOnlyDiagnosticsMetadataLspBuildOnlyDiagnosticsMetadataILspWillRenameListenerMetadataLspWillRenameListenerMetadataEach new class reads its values from the metadata dictionary by key (using
nameof(ExportXxxAttribute.Prop)), matching the existing convention.Details
[MetadataAttribute]export attributes (IntentProviderAttribute,LspBuildOnlyDiagnosticsAttribute,ExportLspWillRenameListenerAttribute) no longer implement the metadata interface. They continue to supply the same named metadata properties, so the projected metadata shape is unchanged.Validation
Microsoft.CodeAnalysis.LanguageServer.ProtocolandMicrosoft.CodeAnalysis.EditorFeatures: 0 warnings, 0 errors.Microsoft Reviewers: Open in CodeFlow