Skip to content

Migrate MEF metadata view interfaces to concrete metadata classes#84315

Draft
olegtk wants to merge 1 commit into
dotnet:mainfrom
olegtk:olegtk/mef-metadata-source-generator
Draft

Migrate MEF metadata view interfaces to concrete metadata classes#84315
olegtk wants to merge 1 commit into
dotnet:mainfrom
olegtk:olegtk/mef-metadata-source-generator

Conversation

@olegtk

@olegtk olegtk commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

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 an IDictionary<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

Interface Concrete class
IIntentProviderMetadata IntentProviderMetadata
ILspBuildOnlyDiagnosticsMetadata LspBuildOnlyDiagnosticsMetadata
ILspWillRenameListenerMetadata LspWillRenameListenerMetadata

Each new class reads its values from the metadata dictionary by key (using nameof(ExportXxxAttribute.Prop)), matching the existing convention.

Details

  • The paired [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.
  • All consumers were updated to reference the concrete class instead of the interface.

Validation

  • Built Microsoft.CodeAnalysis.LanguageServer.Protocol and Microsoft.CodeAnalysis.EditorFeatures: 0 warnings, 0 errors.
  • Repo-wide check confirms no remaining references to the old interface names.
  • Whitespace formatting applied to all changed files.
Microsoft Reviewers: Open in CodeFlow
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>
Copilot AI review requested due to automatic review settings June 28, 2026 00:25
@olegtk olegtk requested a review from a team as a code owner June 28, 2026 00:25
@dotnet-policy-service dotnet-policy-service Bot added Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode labels Jun 28, 2026
@olegtk olegtk marked this pull request as draft June 28, 2026 00:26

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 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, and IIntentProviderMetadata with concrete *Metadata classes 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode

2 participants