Add IPluginExecutionContext2-7 support to PluginContext#323
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
PluginContextto implementIPluginExecutionContext7and add missing properties/collections (incl.PreEntityImagesCollection/PostEntityImagesCollection). - Update service provider resolution to return
PluginContextforIPluginExecutionContext2..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.
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>
…egateas/XrmMockup into plugin-execution-context-952
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>
…egateas/XrmMockup into plugin-execution-context-952
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.
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.