Skip to content

Add IPluginExecutionContext2-7 support to PluginContext#323

Merged
mkholt merged 7 commits intomasterfrom
plugin-execution-context-952
Mar 23, 2026
Merged

Add IPluginExecutionContext2-7 support to PluginContext#323
mkholt merged 7 commits intomasterfrom
plugin-execution-context-952

Conversation

@mkholt
Copy link
Member

@mkholt mkholt commented Mar 20, 2026

Plugins targeting newer SDK versions that cast to IPluginExecutionContext2 through IPluginExecutionContext7 will no longer fail at runtime in XrmMockup. Also refactors all PluginContext property bag keys to use nameof() instead of hardcoded strings, and populates PreEntityImagesCollection/ PostEntityImagesCollection for Multiple operations.

Plugins targeting newer SDK versions that cast to IPluginExecutionContext2
through IPluginExecutionContext7 will no longer fail at runtime in XrmMockup.
Also refactors all PluginContext property bag keys to use nameof() instead
of hardcoded strings, and populates PreEntityImagesCollection/
PostEntityImagesCollection for Multiple operations.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extends XrmMockup365’s plugin execution context to support SDK interfaces IPluginExecutionContext2 through IPluginExecutionContext7, so plugins targeting newer Dataverse SDKs can resolve the expected context types without runtime casting failures. It also refactors PluginContext’s property bag usage to nameof(...) keys and adds support for populating the per-entity pre/post image collections used by multiple-record operations.

Changes:

  • Update PluginContext to implement IPluginExecutionContext7 and add missing properties/collections (incl. PreEntityImagesCollection / PostEntityImagesCollection).
  • Update service provider resolution to return PluginContext for IPluginExecutionContext2..7.
  • Populate image collections for multiple operations and add a new test/plugin exercising IPluginExecutionContext7.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/XrmMockup365Test/XrmmockupFixture.cs Registers a new test plugin step for account Create (pre-op).
tests/XrmMockup365Test/TestPluginExecutionContext7.cs Adds a test intended to validate IPluginExecutionContext7 resolution.
tests/TestPluginAssembly365/Plugins/DirectPlugins/AccountPluginExecutionContext7PreOp.cs Adds a plugin that resolves and validates IPluginExecutionContext7 defaults.
src/XrmMockup365/Plugin/PluginManager.cs Sets up image collections for Single→Multiple conversions and extracts per-entity images for Multiple→Single triggering.
src/XrmMockup365/Plugin/PluginContext.cs Implements IPluginExecutionContext7, switches property bag keys to nameof, adds context v2–v7 properties and image collection arrays, and updates cloning.
src/XrmMockup365/MockupServiceProviderAndFactory.cs Extends GetService to return the context for IPluginExecutionContext2..7.
src/XrmMockup365/Core.cs Initializes some v2–v7 defaults and populates pre/post image collections for multiple operations.

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

mkholt and others added 6 commits March 20, 2026 15:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
For CreateMultiple, the original entities in the EntityCollection don't
have their Ids set after execution (the handler clones them). Use the
response Ids from CreateMultipleResponse to retrieve post-images instead
of relying on e.Id which remains Guid.Empty.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
The test now verifies the plugin actually fired by checking that the
Description field was stamped with "Context7Resolved", rather than only
asserting the Create returned a non-empty ID.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
The test now verifies the plugin actually fired by checking that the
Description field was stamped with "Context7Resolved", rather than only
asserting the Create returned a non-empty ID.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
@mkholt mkholt merged commit 4793843 into master Mar 23, 2026
2 checks passed
@mkholt mkholt deleted the plugin-execution-context-952 branch March 23, 2026 07:10
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