Replace string-based root dispatch with typed ExecuteFromProfile#13
Conversation
The root command previously re-dispatched sync items by reconstructing string[] args and re-invoking System.CommandLine parsing, requiring every option to be mirrored on the root command via ProfileOverrideProvider.
Replace this with a typed dispatch contract: each sync command implements ExecuteFromProfile(SyncItem, ProfileExecutionContext, CancellationToken), which receives already-resolved values and calls the command's existing
DI + sync logic directly. The root command now merges CLI overrides inline
(one switch expression per sync item type) and calls ExecuteFromProfile
on each sub-command until one claims the item.
Remove ProfileOverrideProvider, XrmSyncSyncCommandBase, ArgumentOverrides, and all Execute*/ExecuteSubCommand/AddCommonArgs helpers from the root command. Root-level override options (--folder, --prefix, --operation,
--client-id, --tenant-id, --file-extensions) are now first-class options
on XrmSyncRootCommand rather than being advertised dynamically by
sub-commands. Absorb sync-specific shared options and SyncCommandAction
into XrmSyncCommandBase, flattening the command class hierarchy.
There was a problem hiding this comment.
Pull request overview
This PR refactors profile execution so the root command no longer rebuilds string[] args and re-invokes System.CommandLine parsing to dispatch sync items. Instead, the root command merges CLI overrides into typed SyncItem records and dispatches via a new typed contract (ExecuteFromProfile) implemented by each sync sub-command.
Changes:
- Introduces typed profile dispatch:
IXrmSyncCommand.ExecuteFromProfile(SyncItem, ProfileExecutionContext, CancellationToken)andProfileExecutionContext. - Moves sync shared options/behavior into
XrmSyncCommandBaseand removes the old override-provider based design (ProfileOverrideProvider,XrmSyncSyncCommandBase, plus root “re-dispatch” helpers). - Updates sync sub-commands to execute directly from resolved profile values (via shared
RunCorepaths) while retaining standalone CLI execution.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| XrmSync/Commands/XrmSyncSyncCommandBase.cs | Removes the old sync-command base class now replaced by consolidated logic in XrmSyncCommandBase. |
| XrmSync/Commands/XrmSyncRootCommand.cs | Implements inline typed override merging and dispatches sync items via ExecuteFromProfile. |
| XrmSync/Commands/XrmSyncCommandBase.cs | Adds sync shared option support + common SyncCommandAction; introduces default ExecuteFromProfile. |
| XrmSync/Commands/WebresourceSyncCommand.cs | Migrates to ExecuteFromProfile dispatch and extracts shared execution into RunCore. |
| XrmSync/Commands/ProfileOverrideProvider.cs | Deletes the override provider mechanism. |
| XrmSync/Commands/ProfileExecutionContext.cs | Adds a typed execution context passed from root to sub-commands. |
| XrmSync/Commands/PluginSyncCommand.cs | Migrates to ExecuteFromProfile dispatch and extracts shared execution into RunCore. |
| XrmSync/Commands/PluginAnalyzeCommand.cs | Migrates analysis profile execution to ExecuteFromProfile and extracts RunCore. |
| XrmSync/Commands/IdentityCommand.cs | Migrates to ExecuteFromProfile dispatch and extracts shared execution into RunCore. |
| XrmSync/Commands/IXrmSyncCommand.cs | Replaces GetProfileOverrides with ExecuteFromProfile. |
| XrmSync/Commands/ConfigCommand.cs | Updates to the new IXrmSyncCommand contract (no profile dispatch handling). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix: Use string extention to do the fallback logic
…code. Refactor: Combine a couple of records into the execution context record and pass that for dry run, profile and related
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 48 out of 48 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
XrmSync/Options/ConfigValidationOutput.cs:15
- The constructor now takes
IOptions<ExecutionContext>but the thrownInvalidOperationExceptionmessage still says it requiresSharedOptions. Update the message to referenceExecutionContextto avoid confusing users and future maintainers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The root command previously re-dispatched sync items by reconstructing string[] args and re-invoking System.CommandLine parsing, requiring every option to be mirrored on the root command via ProfileOverrideProvider.
Replace this with a typed dispatch contract: each sync command implements ExecuteFromProfile(SyncItem, ProfileExecutionContext, CancellationToken), which receives already-resolved values and calls the command's existing
DI + sync logic directly. The root command now merges CLI overrides inline
(one switch expression per sync item type) and calls ExecuteFromProfile
on each sub-command until one claims the item.
Remove ProfileOverrideProvider, XrmSyncSyncCommandBase, ArgumentOverrides, and all Execute*/ExecuteSubCommand/AddCommonArgs helpers from the root command. Root-level override options (--folder, --prefix, --operation,
--client-id, --tenant-id, --file-extensions) are now first-class options
on XrmSyncRootCommand rather than being advertised dynamically by
sub-commands. Absorb sync-specific shared options and SyncCommandAction
into XrmSyncCommandBase, flattening the command class hierarchy.