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
Data
Gets the migrated data, or null if migration failed.
public JsonElement? Data { get; init; }
Property Value
ErrorMessage
Gets the error message if migration failed, or null if successful.
public string? ErrorMessage { get; init; }
Property Value
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
StepTimings
Gets the timing information for each step in the migration chain.
public IReadOnlyList<MigrationStepTiming> StepTimings { get; init; }
Property Value
Success
Gets whether the migration completed successfully.
public bool Success { get; init; }
Property Value
ToVersion
Gets the target version of the migration.
public int ToVersion { get; init; }
Property Value
TotalElapsed
Gets the total elapsed time for the entire migration chain.
public TimeSpan TotalElapsed { get; init; }
Property Value
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
componentTypeNamestringThe component type name.
fromVersionintThe source version.
toVersionintThe target version.
totalElapsedTimeSpanThe total elapsed time before failure.
errorMessagestringThe error message describing the failure.
failedAtVersionint?The version at which migration failed.
stepTimingsIReadOnlyList<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
dataJsonElementThe original data (unchanged).
componentTypeNamestringThe component type name.
versionintThe 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
dataJsonElementThe migrated data.
componentTypeNamestringThe component type name.
fromVersionintThe source version.
toVersionintThe target version.
totalElapsedTimeSpanThe total elapsed time.
stepTimingsIReadOnlyList<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()