Skip to content

Fix string overloads of EditorExtensionServiceProvider.GetService() on .NET#2332

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/bugfix-editor-extension-service
Open

Fix string overloads of EditorExtensionServiceProvider.GetService() on .NET#2332
Copilot wants to merge 2 commits into
mainfrom
copilot/bugfix-editor-extension-service

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

On .NET (Core), all three string-based overloads of EditorExtensionServiceProvider.GetService() always returned/failed because GetServiceByAssemblyQualifiedName resolved types via Assembly.GetType(asmQualifiedTypeName) — and Assembly.GetType does not accept assembly-qualified names (it returns null). The .NET Framework path already used Type.GetType, which does, hence the platform discrepancy.

// All three funnel through GetServiceByAssemblyQualifiedName:
provider.GetService("Microsoft.PowerShell.EditorServices.Services.WorkspaceService");
provider.GetService("...WorkspaceService", "Microsoft.PowerShell.EditorServices");
provider.GetServiceByAssemblyQualifiedName("...WorkspaceService, Microsoft.PowerShell.EditorServices");
// → all null on .NET Core prior to this change

Changes

  • EditorExtensionServiceProvider.GetServiceByAssemblyQualifiedName: on the .NET Core path, resolve via Type.GetType(asmQualifiedTypeName) instead of s_psesAsm.GetType(...), still wrapped in EnterPsesAlcReflectionContext() so resolution honors the PSES assembly load context. Both platform paths now use Type.GetType.
  • Tests: added EditorExtensionServiceProviderTests exercising all three overloads against a registered service; they fail on the prior code and pass with the fix.

Notes

  • These are public extension APIs, but only internal type-resolution behavior changes — no public signatures are affected, so this is not binary breaking.

Copilot AI changed the title [WIP] Fix string overloads of EditorExtensionServiceProvider.GetService() on .NET Fix string overloads of EditorExtensionServiceProvider.GetService() on .NET Jun 26, 2026
Copilot AI requested a review from andyleejordan June 26, 2026 16:37
@andyleejordan andyleejordan marked this pull request as ready for review June 26, 2026 22:11

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 fixes a platform-specific bug in the public extension API EditorExtensionServiceProvider.GetServiceByAssemblyQualifiedName(). On .NET (Core), the method resolved types via s_psesAsm.GetType(asmQualifiedTypeName), but Assembly.GetType() does not accept assembly-qualified names and returns null. As a result, all three string-based GetService() overloads (which funnel through this method) always failed on .NET Core, while the .NET Framework path worked because it already used Type.GetType().

The fix switches the .NET Core path to Type.GetType() (which accepts assembly-qualified names), still wrapped in EnterPsesAlcReflectionContext() so resolution honors the PSES assembly load context. This aligns both platform paths, and the contextual reflection scope ensures the type resolves from the correct ALC. The change only affects internal type-resolution behavior, so no public signatures change.

Changes:

  • Replace s_psesAsm.GetType(...) with Type.GetType(...) on the .NET Core path in GetServiceByAssemblyQualifiedName.
  • Add EditorExtensionServiceProviderTests covering all three string-based GetService overloads against a registered service.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/PowerShellEditorServices/Extensions/Api/EditorExtensionServiceProvider.cs Fixes .NET Core type resolution to use Type.GetType, which accepts assembly-qualified names, within the PSES ALC reflection context.
test/PowerShellEditorServices.Test/Extensions/EditorExtensionServiceProviderTests.cs New test class exercising the three GetService string overloads, following the existing ExtensionCommandTests setup pattern.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants