Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions src/DacFXTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,35 +202,6 @@ public static async System.Threading.Tasks.Task<int> Main(string[] args)
return 0;
}

// compare true "<DACPAC_PATH>" "connectionString"
if (args.Length == 4
&& (args[0] == "compare")
&& bool.TryParse(args[1], out bool databaseIsSource))
{
if (!new FileInfo(args[2]).Exists)
{
await Console.Out.WriteLineAsync("Error:");
await Console.Out.WriteLineAsync($"DACPAC file '{args[2]}' not found");
return 1;
}

var script = DacPackageComparer.Compare(args[2], args[3], databaseIsSource);

var path = Path.Join(Path.GetTempPath(), "SqlProjDiff.sql");

if (string.IsNullOrEmpty(script))
{
script = "-- No differences found";
}

await File.WriteAllTextAsync(path, script, Encoding.UTF8);

await Console.Out.WriteLineAsync("Result:");
await Console.Out.WriteLineAsync(path);

return 0;
}

// visualcompare "<DACPAC_PATH>" "connectionString" <database_is_source>
if (args.Length == 4
&& args[0] == "visualcompare"
Expand Down
61 changes: 0 additions & 61 deletions src/DacFXToolLib/DacPackageComparer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Globalization;
using System.Text;
using DacFXToolLib.Common;
using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Dac.Compare;
Expand Down Expand Up @@ -84,64 +82,5 @@
};
}

public static string Compare(string dacpacPath, string connectionString, bool databaseIsSource)
{
var databaseName = new SqlConnectionStringBuilder(connectionString).InitialCatalog;

var dacpac = new SchemaCompareDacpacEndpoint(dacpacPath);
var database = new SchemaCompareDatabaseEndpoint(connectionString);

var comparison = databaseIsSource
? new SchemaComparison(database, dacpac)
: new SchemaComparison(dacpac, database);
var compareResult = comparison.Compare();

var errors = string.Empty;

if (compareResult.GetErrors().Any())
{
errors = string.Join(Environment.NewLine, compareResult.GetErrors().Select(e => "--" + e.Message));
}

if (!compareResult.IsValid)
{
throw new InvalidOperationException("Schema comparison failed to complete.");
}

if (compareResult.IsEqual)
{
return string.Empty;
}

if (!databaseIsSource)
{
var result = compareResult.GenerateScript(databaseName);

if (!result.Success)
{
if (result.Exception != null)
{
throw result.Exception;
}

throw new InvalidOperationException($"Script generation encountered errors: {result.Message}");
}

return errors + Environment.NewLine + result.Script;
}

var diffScript = new StringBuilder();

diffScript.Append(string.Empty);

foreach (var difference in compareResult.Differences)
{
diffScript.AppendLine();
diffScript.AppendLine(CultureInfo.InvariantCulture, $"-- Difference: {difference.SourceObject.Name} ({difference.SourceObject.ObjectType.Name})");
diffScript.AppendLine(compareResult.GetDiffEntrySourceScript(difference));
}

return diffScript.ToString();
}
}

Check warning on line 85 in src/DacFXToolLib/DacPackageComparer.cs

View workflow job for this annotation

GitHub Actions / build

}
23 changes: 0 additions & 23 deletions src/Vsix/Commands/CompareCommand.cs

This file was deleted.

177 changes: 0 additions & 177 deletions src/Vsix/Handlers/CompareHandler.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Vsix/Handlers/ProcessLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,6 @@ public async Task<string> GetVisualCompareAsync(bool databaseIsSource, string da
return filePath;
}

public async Task<string> GetCompareAsync(bool databaseIsSource, string dacpacPath, string connectionString)
{
var option = "compare ";

var arguments = option + databaseIsSource.ToString() + " \"" + dacpacPath.Replace("\"", "\\\"") + "\" " + " \"" + connectionString.Replace("\"", "\\\"") + "\"";

var filePath = await GetDiagramInternalAsync(arguments);

return filePath;
}

public async Task<string> GetDatabaseSettingsAsync(string connectionString)
{
var option = "getdboptions ";
Expand Down
1 change: 0 additions & 1 deletion src/Vsix/VSCommandTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ internal sealed partial class PackageIds
public const int cmdidSqlProjectMenuGroup = 0x0004;
public const int cmdidAnalyze = 0x0001;
public const int cmdidImport = 0x0002;
public const int cmdidCompare = 0x0005;
public const int cmdidErDiagram = 0x0007;
public const int cmdidReverseEngineerDab = 0x0012;
public const int cmdidAbout = 0x0006;
Expand Down
12 changes: 0 additions & 12 deletions src/Vsix/VSCommandTable.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@
</Strings>
</Button>

<Button guid="Vsix" id="cmdidCompare" priority="0x0105" type="Button">
<Parent guid="Vsix" id="cmdidSqlProjectMenuItemsGroup" />
<Icon guid="ImageCatalogGuid" id="CompareSchemas" />
<CommandFlag>IconIsMoniker</CommandFlag>
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>TextChanges</CommandFlag>
<Strings>
<ButtonText>Schema compare script...</ButtonText>
</Strings>
</Button>

<Button guid="Vsix" id="cmdidVisualCompare" priority="0x0106" type="Button">
<Parent guid="Vsix" id="cmdidSqlProjectMenuItemsGroup" />
<Icon guid="ImageCatalogGuid" id="CompareSchemas" />
Expand Down Expand Up @@ -192,7 +181,6 @@
<!-- Project Menu Entries -->
<IDSymbol name="cmdidAnalyze" value="0x0001" />
<IDSymbol name="cmdidImport" value="0x0002" />
<IDSymbol name="cmdidCompare" value="0x0005" />
<IDSymbol name="cmdidErDiagram" value="0x0007" />
<IDSymbol name="cmdidReverseEngineerDab" value="0x0012" />
<IDSymbol name="cmdidAbout" value="0x0006" />
Expand Down
2 changes: 0 additions & 2 deletions src/Vsix/Vsix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<ItemGroup>
<Compile Include="Commands\AnalyzeCommand.cs" />
<Compile Include="Commands\DabCommand.cs" />
<Compile Include="Commands\CompareCommand.cs" />
<Compile Include="Commands\VisualCompareCommand.cs" />
<Compile Include="Commands\SeedCommand.cs" />
<Compile Include="Commands\ImportCommand.cs" />
Expand Down Expand Up @@ -103,7 +102,6 @@
<Compile Include="Handlers\SeedHandler.cs" />
<Compile Include="Handlers\DabBuilderHandler.cs" />
<Compile Include="Handlers\DacpacAnalyzerHandler.cs" />
<Compile Include="Handlers\CompareHandler.cs" />
<Compile Include="Handlers\VisualCompareHandler.cs" />
<Compile Include="Handlers\HandlerHelper.cs" />
<Compile Include="Handlers\ImportHandler.cs" />
Expand Down
Loading