Schema compare cancel operation (#826)

* First cut of schema compare cancel (private nuget)

* Update Dacfx nuget to a published version
This commit is contained in:
udeeshagautam
2019-06-14 18:19:36 -07:00
committed by GitHub
parent 432e054d55
commit 3e1f186891
13 changed files with 168 additions and 13 deletions

View File

@@ -49,7 +49,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
}
protected CancellationToken CancellationToken { get { return this.cancellation.Token; } }
/// <summary>
/// The error occurred during operation
/// </summary>
@@ -58,6 +58,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
// The schema compare public api doesn't currently take a cancellation token so the operation can't be cancelled
public void Cancel()
{
this.cancellation.Cancel();
}
/// <summary>
@@ -91,19 +92,31 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
comparison.Options = SchemaCompareUtils.CreateSchemaCompareOptions(this.Parameters.DeploymentOptions);
}
this.ComparisonResult = comparison.Compare();
// for testing
schemaCompareStarted?.Invoke(this, new EventArgs());
this.ComparisonResult = comparison.Compare(this.CancellationToken);
// try one more time if it didn't work the first time
if (!this.ComparisonResult.IsValid)
{
this.ComparisonResult = comparison.Compare();
this.ComparisonResult = comparison.Compare(this.CancellationToken);
}
// Since DacFx does not throw on schema comparison cancellation, throwing here explicitly to ensure consistency of behavior
if (!this.ComparisonResult.IsValid && this.CancellationToken.IsCancellationRequested)
{
throw new OperationCanceledException(this.CancellationToken);
}
this.Differences = new List<DiffEntry>();
foreach (SchemaDifference difference in this.ComparisonResult.Differences)
if (this.ComparisonResult.Differences != null)
{
DiffEntry diffEntry = SchemaCompareUtils.CreateDiffEntry(difference, null);
this.Differences.Add(diffEntry);
foreach (SchemaDifference difference in this.ComparisonResult.Differences)
{
DiffEntry diffEntry = SchemaCompareUtils.CreateDiffEntry(difference, null);
this.Differences.Add(diffEntry);
}
}
}
catch (Exception e)
@@ -113,5 +126,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
throw;
}
}
internal event EventHandler<EventArgs> schemaCompareStarted;
}
}