Skip to content

Commit

Permalink
Add support to ignore line endings in function definitions (#43)
Browse files Browse the repository at this point in the history
- Updated DiffPlex
- Added setting checkbox to ignore line endings
  • Loading branch information
diametric authored Jan 11, 2025
1 parent 7f09c7a commit d8001b1
Show file tree
Hide file tree
Showing 9 changed files with 420 additions and 378 deletions.
94 changes: 53 additions & 41 deletions SyncKusto/App.config
Original file line number Diff line number Diff line change
@@ -1,42 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SyncKusto.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<userSettings>
<SyncKusto.Properties.Settings>
<setting name="PreviousFilePath" serializeAs="String">
<value />
</setting>
<setting name="KustoClusterForTempDatabases" serializeAs="String">
<value />
</setting>
<setting name="AADAuthority" serializeAs="String">
<value />
</setting>
<setting name="TemporaryKustoDatabase" serializeAs="String">
<value />
</setting>
<setting name="KustoObjectDropWarning" serializeAs="String">
<value>True</value>
</setting>
<setting name="TableFieldsOnNewLine" serializeAs="String">
<value>False</value>
</setting>
<setting name="CreateMergeEnabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="UseLegacyCslExtension" serializeAs="String">
<value>True</value>
</setting>
<setting name="CertificateLocation" serializeAs="String">
<value>CurrentUser</value>
</setting>
</SyncKusto.Properties.Settings>
</userSettings>
</configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SyncKusto.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<userSettings>
<SyncKusto.Properties.Settings>
<setting name="PreviousFilePath" serializeAs="String">
<value />
</setting>
<setting name="KustoClusterForTempDatabases" serializeAs="String">
<value />
</setting>
<setting name="AADAuthority" serializeAs="String">
<value />
</setting>
<setting name="TemporaryKustoDatabase" serializeAs="String">
<value />
</setting>
<setting name="KustoObjectDropWarning" serializeAs="String">
<value>True</value>
</setting>
<setting name="TableFieldsOnNewLine" serializeAs="String">
<value>False</value>
</setting>
<setting name="CreateMergeEnabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="UseLegacyCslExtension" serializeAs="String">
<value>True</value>
</setting>
<setting name="CertificateLocation" serializeAs="String">
<value>CurrentUser</value>
</setting>
<setting name="RecentClusters" serializeAs="String">
<value />
</setting>
<setting name="RecentDatabases" serializeAs="String">
<value />
</setting>
<setting name="RecentAppIds" serializeAs="String">
<value />
</setting>
<setting name="IgnoreLineEndings" serializeAs="String">
<value>False</value>
</setting>
</SyncKusto.Properties.Settings>
</userSettings>
</configuration>
11 changes: 9 additions & 2 deletions SyncKusto/Kusto/QueryEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

using System;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Kusto.Data;
using Kusto.Data.Common;
using Kusto.Data.Net.Client;
using Newtonsoft.Json;
using SyncKusto.Properties;
using SyncKusto.Utilities;

namespace SyncKusto.Kusto
Expand Down Expand Up @@ -105,7 +107,12 @@ public DatabaseSchema GetDatabaseSchema()
}
foreach (var function in result.Functions.Values)
{
if (function.Folder == null)
if (SettingsWrapper.IgnoreLineEndings ?? false)
{
function.Body = function.Body.Replace("\r\n", "\n").Replace("\r", "\n");
}

if (function.Folder == null)
{
function.Folder = "";
}
Expand Down Expand Up @@ -318,4 +325,4 @@ public static string NormalizeClusterName(string cluster)
}
}
}
}
}
4 changes: 2 additions & 2 deletions SyncKusto/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private void tvComparison_NodeMouseClick(object sender, TreeNodeMouseClickEventA
}

var diffBuilder = new InlineDiffBuilder(new Differ());
DiffPlex.DiffBuilder.Model.DiffPaneModel diff = diffBuilder.BuildDiffModel(targetText, sourceText);
DiffPlex.DiffBuilder.Model.DiffPaneModel diff = diffBuilder.BuildDiffModel(targetText, sourceText, SettingsWrapper.IgnoreLineEndings ?? false);
rtbSourceText.Clear();

int longestLine = 98;
Expand Down Expand Up @@ -515,4 +515,4 @@ private bool IsTempClusterDefined()
return !string.IsNullOrWhiteSpace(SettingsWrapper.KustoClusterForTempDatabases);
}
}
}
}
15 changes: 13 additions & 2 deletions SyncKusto/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions SyncKusto/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="UTF-8"?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SyncKusto.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
Expand Down Expand Up @@ -38,5 +38,9 @@
<Setting Name="RecentAppIds" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="IgnoreLineEndings" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
</SettingsFile>

Loading

0 comments on commit d8001b1

Please sign in to comment.