Skip to content

fix(migration): make SchemaMismatchException.TotalMissingCount lazy #460

@joshsmithxrm

Description

@joshsmithxrm

Summary

TotalMissingCount in SchemaMismatchException is calculated in the constructor and could become stale.

Problem

In SchemaMismatchException.cs:30:

public SchemaMismatchException(...)
{
    MissingColumns = missingColumns;
    TotalMissingCount = missingColumns.Values.Sum(list => list.Count);  // Calculated once
}

If the dictionary is mutated after construction, TotalMissingCount becomes stale.

Solution

Calculate in property getter instead of constructor:

public int TotalMissingCount => MissingColumns.Values.Sum(list => list.Count);

Files to Modify

  • src/PPDS.Migration/Exceptions/SchemaMismatchException.cs

Work Stream

Stream B - Code Patterns

Acceptance Criteria

  • Property calculates on access
  • Behavior unchanged for normal usage
  • All existing tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:dataData import/export/migrationbugSomething isn't workingpriority:lowLow priority

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions