Skip to content

Commit

Permalink
Updated to AvalonDock 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirkster99 committed Sep 2, 2020
1 parent d779206 commit 38a5481
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 11 deletions.
8 changes: 4 additions & 4 deletions source/Aehnlich/Aehnlich/Aehnlich.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@
<ApplicationIcon>tilde_LightDark.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="AvalonDock, Version=4.30.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\..\packages\Dirkster.AvalonDock.4.30.0\lib\net40\AvalonDock.dll</HintPath>
<Reference Include="AvalonDock, Version=4.40.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\..\packages\Dirkster.AvalonDock.4.40.0\lib\net40\AvalonDock.dll</HintPath>
</Reference>
<Reference Include="AvalonDock.Themes.VS2013, Version=4.20.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\..\packages\Dirkster.AvalonDock.Themes.VS2013.4.20.0\lib\net40\AvalonDock.Themes.VS2013.dll</HintPath>
<Reference Include="AvalonDock.Themes.VS2013, Version=4.40.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\..\packages\Dirkster.AvalonDock.Themes.VS2013.4.40.0\lib\net40\AvalonDock.Themes.VS2013.dll</HintPath>
</Reference>
<Reference Include="HL, Version=1.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Dirkster.HL.1.0.4\lib\net40\HL.dll</HintPath>
Expand Down
4 changes: 2 additions & 2 deletions source/Aehnlich/Aehnlich/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AvalonEdit" version="6.0.1" targetFramework="net452" />
<package id="Dirkster.AvalonDock" version="4.30.0" targetFramework="net452" />
<package id="Dirkster.AvalonDock.Themes.VS2013" version="4.20.0" targetFramework="net452" />
<package id="Dirkster.AvalonDock" version="4.40.0" targetFramework="net452" />
<package id="Dirkster.AvalonDock.Themes.VS2013" version="4.40.0" targetFramework="net452" />
<package id="Dirkster.HL" version="1.0.4" targetFramework="net452" />
<package id="Dirkster.MLib" version="1.3.1.2" targetFramework="net452" />
<package id="Dirkster.MWindowLib" version="1.3.0.2" targetFramework="net452" />
Expand Down
2 changes: 1 addition & 1 deletion source/AehnlichLib_UnitTests/AehnlichLib_UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ private static IDiffFileModeItemViewModel CreateCompareFileModes(
"Compare each file by their length and byte-by-byte sequence",
DiffDirFileMode.AllBytes));

diffFileModes.Add(new DiffFileModeItemViewModel("All Bytes without LineFeeds",
diffFileModes.Add(new DiffFileModeItemViewModel("All Bytes without LineFeeds (experimental)",
"Compare each file by their byte-by-byte sequence but ignoring different LineFeeds in text files.",
DiffDirFileMode.ByteLength_AllBytes_IgnoreLf));

diffFileModes.Add(new DiffFileModeItemViewModel("All Bytes without LineFeeds and White-Spaces (experimental)",
"Compare each file by their byte-by-byte sequence but ignoring different LineFeeds and usage of space and tabs in text files.",
DiffDirFileMode.ByteLength_AllBytes_IgnoreLf_WSP));

return defaultItem;
}
#endregion methods
Expand Down
71 changes: 68 additions & 3 deletions source/FsDataLib/Dir/DirDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,21 @@ public bool AreBinaryFilesDifferent(string fileName1, string fileName2, DiffDirF
public bool AreBinaryFilesDifferent(IFileInfo ifo1, IFileInfo ifo2, DiffDirFileMode diffMode)
{
// Should we ignore different linefeeds on text files and is this type of matching applicable here?
if ((diffMode & DiffDirFileMode.IgnoreLf) != 0)
if (diffMode == DiffDirFileMode.ByteLength_AllBytes_IgnoreLf)
{
bool IsIfo1Text = ifo1.Is == FileType.Text | ifo1.Is == FileType.Xml;
bool IsIfo2Text = ifo2.Is == FileType.Text | ifo2.Is == FileType.Xml;

if (IsIfo1Text && IsIfo2Text)
return AreTextFilesIgnoringLF_Different(ifo1, ifo2);
return AreTextFiles_IgnoringLF_Different(ifo1, ifo2);
}
else if (diffMode == DiffDirFileMode.ByteLength_AllBytes_IgnoreLf_WSP)
{
bool IsIfo1Text = ifo1.Is == FileType.Text | ifo1.Is == FileType.Xml;
bool IsIfo2Text = ifo2.Is == FileType.Text | ifo2.Is == FileType.Xml;

if (IsIfo1Text && IsIfo2Text)
return AreTextFiles_IgnoringLF_WSP_Different(ifo1, ifo2);
}

// Before we open the files, compare the sizes. If they are different,
Expand Down Expand Up @@ -191,7 +199,7 @@ public bool AreBinaryFilesDifferent(IFileInfo ifo1, IFileInfo ifo2, DiffDirFileM
/// <param name="ifo1"></param>
/// <param name="ifo2"></param>
/// <returns></returns>
internal bool AreTextFilesIgnoringLF_Different(IFileInfo ifo1, IFileInfo ifo2)
internal bool AreTextFiles_IgnoringLF_Different(IFileInfo ifo1, IFileInfo ifo2)
{
var info1 = new FileInfo(ifo1.FullName);
var info2 = new FileInfo(ifo2.FullName);
Expand Down Expand Up @@ -235,6 +243,63 @@ internal bool AreTextFilesIgnoringLF_Different(IFileInfo ifo1, IFileInfo ifo2)
return false; // The files are considered equal.
}
}

/// <summary>Compares two text files with a byte-by-byte sequence strategy.
/// Based on a: byte-by-byte comparison ignoring different line feed styles on text files.</summary>
/// <param name="ifo1"></param>
/// <param name="ifo2"></param>
/// <returns></returns>
internal bool AreTextFiles_IgnoringLF_WSP_Different(IFileInfo ifo1, IFileInfo ifo2)
{
var info1 = new FileInfo(ifo1.FullName);
var info2 = new FileInfo(ifo2.FullName);

using (FileStream stream1 = info1.OpenRead())
using (FileStream stream2 = info2.OpenRead())
{
// We have to check byte-by-byte. As soon as we find a significant difference, we can quit.
int byte1, byte2;
byte1 = stream1.ReadByte();
byte2 = stream2.ReadByte();

while (byte1 >= 0 && byte2 >= 0)
{
Debug.Assert(byte1 <= 255, "Byte1 size is larger than 8 bit.");
Debug.Assert(byte2 <= 255, "Byte2 size is larger than 8 bit.");

// Skip any white spaces since these are not meant to be relevant for this comparison strategy
while (byte1 == 0x20 || byte1 == 0x09)
byte1 = stream1.ReadByte();

while (byte2 == 0x20 || byte2 == 0x09)
byte2 = stream2.ReadByte();

if (byte1 != byte2)
{
// Advance both sequences beyond known LineFeed bytes (any LineFeed byte (eg 0x0A) is considered equal any other (eg 0x0D))
if ((byte1 == 0x0a || byte1 == 0x0d) && (byte2 == 0x0a || byte2 == 0x0d))
{
while (byte1 == 0x0a || byte1 == 0x0d)
byte1 = stream1.ReadByte();

while (byte2 == 0x0a || byte1 == 0x0d)
byte2 = stream2.ReadByte();
}
else
{
return true; // Files are not equal
}
}
else
{
byte1 = stream1.ReadByte();
byte2 = stream2.ReadByte();
}
}

return false; // The files are considered equal.
}
}
#endregion methods
}
}
4 changes: 4 additions & 0 deletions source/FsDataLib/Enums/DiffDirFileMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public enum DiffDirFileMode : uint
/// <summary>Text file matching treads Cr, Lf and LfCr bytes as equal sequences.</summary>
IgnoreLf = 0x08,

IgnoreWSP = 0x10,

/// <summary>
/// Two files in the same relative location A (left dir tree) and B (right dir tree)
/// are considered equal if:
Expand All @@ -76,6 +78,8 @@ public enum DiffDirFileMode : uint
/// </summary>
ByteLength_AllBytes_IgnoreLf = (AllBytes | IgnoreLf),

ByteLength_AllBytes_IgnoreLf_WSP = (AllBytes | IgnoreLf | IgnoreWSP),

/// <summary>
/// Two files in the same relative location A (left dir tree) and B (right dir tree)
/// are considered equal:
Expand Down

0 comments on commit 38a5481

Please sign in to comment.