Table of Contents

Class MigrationResult

Namespace
KeenEyes.Serialization
Assembly
KeenEyes.Core.dll

Represents the result of a component migration operation, including timing diagnostics.

public sealed class MigrationResult
Inheritance
MigrationResult
Inherited Members

Examples

var result = migrator.MigrateWithDiagnostics("MyComponent", data, 1, 4);

if (result.Success)
{
    Console.WriteLine($"Migration took {result.TotalElapsed.TotalMilliseconds}ms");
    foreach (var timing in result.StepTimings)
    {
        Console.WriteLine($"  {timing.Step}: {timing.Elapsed.TotalMilliseconds}ms");
    }
}

Remarks

This class captures detailed information about a migration execution:

  • Whether the migration succeeded
  • The migrated data (if successful)
  • Total execution time
  • Per-step timing breakdown
  • The migration chain that was executed

Use this class when you need detailed diagnostics about migration performance, especially for profiling or debugging slow migrations.

Properties

ComponentTypeName

Gets the component type name that was migrated.

public string? ComponentTypeName { get; init; }

Property Value

string

Data

Gets the migrated data, or null if migration failed.

public JsonElement? Data { get; init; }

Property Value

JsonElement?

ErrorMessage

Gets the error message if migration failed, or null if successful.

public string? ErrorMessage { get; init; }

Property Value

string

FailedAtVersion

Gets the version at which the migration failed, or null if successful.

public int? FailedAtVersion { get; init; }

Property Value

int?

FromVersion

Gets the source version of the migration.

public int FromVersion { get; init; }

Property Value

int

StepTimings

Gets the timing information for each step in the migration chain.

public IReadOnlyList<MigrationStepTiming> StepTimings { get; init; }

Property Value

IReadOnlyList<MigrationStepTiming>

Success

Gets whether the migration completed successfully.

public bool Success { get; init; }

Property Value

bool

ToVersion

Gets the target version of the migration.

public int ToVersion { get; init; }

Property Value

int

TotalElapsed

Gets the total elapsed time for the entire migration chain.

public TimeSpan TotalElapsed { get; init; }

Property Value

TimeSpan

Methods

Failed(string, int, int, TimeSpan, string, int?, IReadOnlyList<MigrationStepTiming>?)

Creates a failed migration result.

public static MigrationResult Failed(string componentTypeName, int fromVersion, int toVersion, TimeSpan totalElapsed, string errorMessage, int? failedAtVersion = null, IReadOnlyList<MigrationStepTiming>? stepTimings = null)

Parameters

componentTypeName string

The component type name.

fromVersion int

The source version.

toVersion int

The target version.

totalElapsed TimeSpan

The total elapsed time before failure.

errorMessage string

The error message describing the failure.

failedAtVersion int?

The version at which migration failed.

stepTimings IReadOnlyList<MigrationStepTiming>

The per-step timing information (for steps that completed).

Returns

MigrationResult

A failed migration result.

NoMigrationNeeded(JsonElement, string, int)

Creates a result indicating no migration was needed (versions equal).

public static MigrationResult NoMigrationNeeded(JsonElement data, string componentTypeName, int version)

Parameters

data JsonElement

The original data (unchanged).

componentTypeName string

The component type name.

version int

The version (both from and to).

Returns

MigrationResult

A successful result with no migration steps.

Succeeded(JsonElement, string, int, int, TimeSpan, IReadOnlyList<MigrationStepTiming>)

Creates a successful migration result.

public static MigrationResult Succeeded(JsonElement data, string componentTypeName, int fromVersion, int toVersion, TimeSpan totalElapsed, IReadOnlyList<MigrationStepTiming> stepTimings)

Parameters

data JsonElement

The migrated data.

componentTypeName string

The component type name.

fromVersion int

The source version.

toVersion int

The target version.

totalElapsed TimeSpan

The total elapsed time.

stepTimings IReadOnlyList<MigrationStepTiming>

The per-step timing information.

Returns

MigrationResult

A successful migration result.

ToString()

Returns a diagnostic string representation of the migration result.

public override string ToString()

Returns

string