Skip to content

Flatten plugin image generation into the plugin namespace#22

Open
mkholt wants to merge 5 commits into
mainfrom
flatten-image-generation
Open

Flatten plugin image generation into the plugin namespace#22
mkholt wants to merge 5 commits into
mainfrom
flatten-image-generation

Conversation

@mkholt

@mkholt mkholt commented Jul 3, 2026

Copy link
Copy Markdown
Member

Generate PreImage/PostImage/ActionWrapper into the plugin's own namespace with
registration-derived names ({PluginClass}{Entity}{Operation}{Stage}{Kind}),
mirroring the Custom API request/response scheme, instead of a per-registration
{...}.PluginRegistrations.{...} namespace with bare type names. The runtime
wrapper discovery in Plugin.RegisterStep is updated to match (shared
IdentifierSanitizer).

Because generated type names are now unique within the plugin namespace, the
entire aliased-usings subsystem is removed: the signature/create-method code
fixes emit fully-qualified image parameter types (no using directives) and use
WellKnownFixAllProviders.BatchFixer. Deletes AliasedImageUsingsFixAllProvider
and the alias/requalification helpers in SyntaxFactoryHelper. The
signature-mismatch analyzer now matches the concrete wrapper by fully-qualified
name and reports the expected type names to the code fixes.

Uniqueness within the namespace is guaranteed by XPC2002 (one registration per
entity/operation/stage per plugin) plus distinct plugin class names.

Tests and end-to-end TypeSafe plugins updated to the new names; alias-specific
code-fix tests removed. CHANGELOG marks the breaking change under v1.5.0.

Co-Authored-By: Claude noreply@anthropic.com via Conducktor conducktor@contextand.com

mkholt and others added 3 commits July 3, 2026 10:16
Working reference for the v1.5.0 effort to name generated image types after
their registration (like Custom APIs) and delete the aliased-usings subsystem.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
Generate PreImage/PostImage/ActionWrapper into the plugin's own namespace with
registration-derived names ({PluginClass}{Entity}{Operation}{Stage}{Kind}),
mirroring the Custom API request/response scheme, instead of a per-registration
{...}.PluginRegistrations.{...} namespace with bare type names. The runtime
wrapper discovery in Plugin.RegisterStep is updated to match (shared
IdentifierSanitizer).

Because generated type names are now unique within the plugin namespace, the
entire aliased-usings subsystem is removed: the signature/create-method code
fixes emit fully-qualified image parameter types (no using directives) and use
WellKnownFixAllProviders.BatchFixer. Deletes AliasedImageUsingsFixAllProvider
and the alias/requalification helpers in SyntaxFactoryHelper. The
signature-mismatch analyzer now matches the concrete wrapper by fully-qualified
name and reports the expected type names to the code fixes.

Uniqueness within the namespace is guaranteed by XPC2002 (one registration per
entity/operation/stage per plugin) plus distinct plugin class names.

Tests and end-to-end TypeSafe plugins updated to the new names; alias-specific
code-fix tests removed. CHANGELOG marks the breaking change under v1.5.0.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
Rewrite the Type-Safe Images section of CLAUDE.md for the new scheme: generated wrappers live in the plugin namespace with registration-derived names, no per-registration namespace or using aliases. Reframe the shared image interfaces as an escape hatch (raw Entity / attribute-agnostic logic) rather than the recommended parameter type, since they bypass the generated typed properties. Record progress and the manual-migration decision in the plan.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>

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 changes the type-safe plugin image generation scheme so that generated PreImage/PostImage/ActionWrapper types are emitted into the plugin’s own namespace with registration-derived (sanitized) unique type names, removing the previous per-registration ...PluginRegistrations... namespaces and the aliasing/usings subsystem that supported them. Runtime wrapper discovery (Plugin.RegisterStep) and the analyzers/code-fixes are updated to match the new naming contract, and tests/docs are updated accordingly.

Changes:

  • Flatten generated image and action-wrapper types into the plugin namespace using a sanitized registration-derived type prefix, and update runtime reflection-based wrapper discovery to match.
  • Remove aliased-usings machinery; update code fixes to emit fully-qualified generated wrapper type names and use WellKnownFixAllProviders.BatchFixer.
  • Update/trim tests and docs to reflect the new type naming and migration guidance.

Reviewed changes

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

Show a summary per file
File Description
XrmPluginCore/Plugin.cs Updates runtime wrapper type-name discovery to the new sanitized, flattened naming scheme.
XrmPluginCore/CHANGELOG.md Documents the breaking change and migration guidance for the new generated type names.
XrmPluginCore.Tests/TestPlugins/TypeSafe/TypeSafeContactService.cs Updates test plugin service to use the new generated PreImage wrapper type name.
XrmPluginCore.Tests/TestPlugins/TypeSafe/TypeSafeContactPlugin.cs Updates test plugin to store/use the new generated PreImage wrapper type name.
XrmPluginCore.Tests/TestPlugins/TypeSafe/TypeSafeAccountService.cs Updates test plugin service to use the new generated Pre/Post image wrapper type names.
XrmPluginCore.Tests/TestPlugins/TypeSafe/TypeSafeAccountPlugin.cs Updates test plugin to store/use the new generated Pre/Post image wrapper type names.
XrmPluginCore.SourceGenerator/Models/PluginStepMetadata.cs Replaces per-registration namespace computation with a sanitized registration-derived type prefix and helper name builders.
XrmPluginCore.SourceGenerator/Helpers/SyntaxFactoryHelper.cs Removes alias/usings rewrite helpers; updates image parameter list generation to use fully-qualified type names.
XrmPluginCore.SourceGenerator/Helpers/RegisterStepHelper.cs Updates expected generated type computation to return fully-qualified wrapper type names (not namespaces).
XrmPluginCore.SourceGenerator/Constants.cs Replaces diagnostic property key for image namespace with pre/post image fully-qualified type names.
XrmPluginCore.SourceGenerator/CodeGeneration/WrapperClassGenerator.cs Emits generated types into the plugin namespace and prefixes wrapper/action-wrapper class names.
XrmPluginCore.SourceGenerator/CodeFixes/FixHandlerSignatureCodeFixProvider.cs Updates signature fix to use fully-qualified image wrapper types; switches FixAll to BatchFixer.
XrmPluginCore.SourceGenerator/CodeFixes/CreateHandlerMethodCodeFixProvider.cs Updates method creation fix to use fully-qualified image wrapper types; switches FixAll to BatchFixer.
XrmPluginCore.SourceGenerator/CodeFixes/AliasedImageUsingsFixAllProvider.cs Deletes the custom FixAll provider used for alias-based image handler fixes.
XrmPluginCore.SourceGenerator/Analyzers/HandlerSignatureMismatchAnalyzer.cs Matches concrete wrappers by fully-qualified name and passes expected wrapper type names to code fixes.
XrmPluginCore.SourceGenerator/Analyzers/HandlerMethodNotFoundAnalyzer.cs Populates diagnostics with expected fully-qualified wrapper type names (pre/post separately).
XrmPluginCore.SourceGenerator.Tests/IntegrationTests/CompilationTests.cs Updates reflection-based assertions to the new fully-qualified generated type names.
XrmPluginCore.SourceGenerator.Tests/Helpers/TestFixtures.cs Updates test fixture source to reference the new wrapper type names and removes old PluginRegistrations usings.
XrmPluginCore.SourceGenerator.Tests/GenerationTests/WrapperClassGenerationTests.cs Updates generated-source assertions for new class names/namespace and action-wrapper name.
XrmPluginCore.SourceGenerator.Tests/DiagnosticTests/FixHandlerSignatureCodeFixProviderTests.cs Updates tests to expect fully-qualified wrapper types and removes aliasing-specific test cases.
XrmPluginCore.SourceGenerator.Tests/DiagnosticTests/DiagnosticReportingTests.cs Updates expected generated type names/namespaces in diagnostic-related tests.
XrmPluginCore.SourceGenerator.Tests/DiagnosticTests/CreateHandlerMethodCodeFixProviderTests.cs Updates tests to expect fully-qualified wrapper types and simplifies FixAll scenarios.
docs/plans/flatten-image-generation.md Adds an implementation/migration plan documenting the new scheme and rationale.
CLAUDE.md Updates documentation/examples to the flattened namespace + registration-derived type naming model.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mkholt and others added 2 commits July 3, 2026 12:28
CreateHandlerMethodCodeFixProvider now bails out when a registered image's generated wrapper type name couldn't be resolved (HasPreImage/HasPostImage is set but the type-name property is missing), rather than creating a param-less, permanently mismatched handler method.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
The flatten-image-generation plan was a working reference for the v1.5.0 effort; the work is complete, so it no longer needs to live in the repo.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
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.

2 participants