Skip to content

feat: add post-export normalizer to reduce solution roundtrip noise#72

Open
zekelinAlex wants to merge 1 commit into
TALXIS:masterfrom
zekelinAlex:users/alexander.zekelin/export-normalizer
Open

feat: add post-export normalizer to reduce solution roundtrip noise#72
zekelinAlex wants to merge 1 commit into
TALXIS:masterfrom
zekelinAlex:users/alexander.zekelin/export-normalizer

Conversation

@zekelinAlex

Copy link
Copy Markdown
Contributor

The core idea: local Solution.xml is the source of truth for what a solution contains. The export is only trusted for component content. ExportNormalizer takes the unpacked export, compares it with the source project and reduces it to the declared state, so pull produces a clean diff. The manifest itself is never rewritten, it can only grow: subcomponents that arrive with a behavior=0 entity get declared as explicit RootComponents.

What happens to an export, point by point (each rule can be switched off via options):

components not declared in RootComponents and not present in the source project are removed, together with their rows in the exported manifest. This applies only to classic platform types with reliable manifest identity: entities, option sets, workflows, web resources, roles, app modules, plugin assemblies and SDK steps. Site maps, SCF components (canvas apps, PCF, environment variables, connection references...) and anything unknown pass through untouched — their type codes are environment-specific and their names don't reliably match RootComponents rows, so filtering them would be guessing

forms, views and ribbons of entities declared with behavior 1 or 2 are removed, unless they're explicitly declared as root components or already sit in the repo. Changing an entity's behavior never deletes what you already pulled, it only stops new server-side additions

server-added system relationships (owner, business unit, team, user, createdby/modifiedby lookups) are removed when they're not in the source. Matched by participants, with a name-pattern fallback for skeletal entries

forms and views owned by a different solution are removed in multi-solution workspaces (the behavior=0 cross-solution leak)
OrganizationVersion, OrganizationSchemaType and CRMServerServiceabilityVersion are stripped from the roots of Solution.xml and Customizations.xml

Managed and Version are kept at the source values

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

Adds a post-export normalization step for Dataverse solution workspaces to reduce “roundtrip noise” by stripping server-added artifacts and aligning exported content with the source project’s declared solution state.

Changes:

  • Introduces ExportNormalizer with configurable rules and a change-reporting model (ExportNormalizationOptions / ExportNormalizationResult).
  • Extends Workspace/Solution APIs to support removing components and root-components during normalization.
  • Updates XmlWorkspaceWriter relationship writing to preserve formatting, avoid duplicate definitions, and delete stale relationship files/directories; adds comprehensive tests.

Reviewed changes

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

Show a summary per file
File Description
tests/TALXIS.Platform.Metadata.Tests/ExportNormalizerTests.cs Adds unit tests covering normalization rules and relationship file roundtripping/deletion behavior.
src/TALXIS.Platform.Metadata/Solutions/Solution.cs Adds root-component removal overload supporting schema-name and/or GUID matching.
src/TALXIS.Platform.Metadata.Serialization.Xml/XmlWorkspaceWriter.cs Refines relationships writing/patching logic, preserves whitespace, deletes stale files, and adds a manifest-only write entrypoint.
src/TALXIS.Platform.Metadata.Serialization.Xml/Workspace.cs Adds removal helpers for entities and several component types (forms/views/etc.).
src/TALXIS.Platform.Metadata.Serialization.Xml/ExportNormalizer.cs Implements normalization rules (strip non-source components, system relationships, cross-solution subcomponents, server attrs; normalize Managed/Version).
src/TALXIS.Platform.Metadata.Serialization.Xml/ExportNormalizationResult.cs Adds rule enum + change/result reporting types for normalization runs.
src/TALXIS.Platform.Metadata.Serialization.Xml/ExportNormalizationOptions.cs Adds rule toggles (enabled by default) for the normalizer.

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

Comment on lines +1 to +2
namespace TALXIS.Platform.Metadata.Serialization.Xml;

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