dirkster99 / aehnlich Goto Github PK
View Code? Open in Web Editor NEWShow/Merge differences in directories and their content (text files) in Light/Dark designs
License: MIT License
Show/Merge differences in directories and their content (text files) in Light/Dark designs
License: MIT License
Hi,
It's not exactly a bug, but enhancement. Is it possible to group similar lines and compare them? As you can see on screenshot, lines #21 are compared, however, lines #21 and #22 have a more suitable format for comparison. The line number 21 on the right should be marked as added, and the subsequent lines should be compared, because they start with the same values
One more question: Have you ever tried to get the diff feature working with editing allowed?
Like - did it turn out to be tough to get it working or is it just that you have never tried because you never needed it?
Once again: great library. It's a shame that I'm the only fork at this time.
Maybe you'd need some more appealing screenshots... :-)
I'm wondering whether you could help me with one issue:
I like the rounded selection borders, but the borders always get clipped on the left edge, as there's one or two pixels missing for painting it properly.
Do you have any idea how this could be achieved?
Hi, I really like how Aehnlich works!
When using it I missed a "short view" where it gets rid of nearly all similar code and shrinks it to only the changed parts and maybe a bit around (configure lines around).
And an "export function" to export it maybe as:
Would be a great addition at least for me.
And I successfully extended it as an experiment to diff dotnet assemblies with adding ilspy functions to it.
(just as an alternative to JustAssembly)
Doubleclicking an assembly triggers the comparison.
CompareType.cs
/// <summary>
/// Diff files as binary files.
/// </summary>
Binary,
/// <summary>
/// Diff files as assembly files.
/// </summary>
Assembly
}
...
FileCompInfo.cs
public enum FileType
{
Unknown,
NotExisting,
Binary,
Assembly,
Text,
Xml
}
ProcessTextDiff
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.Metadata;
using System.Threading;
private DiffBinaryTextResults GetFileLines(FileCompInfo fileA
,FileCompInfo fileB
,TextBinaryDiffArgs args
,IDiffProgress progress)
{
// Nothing to compare if both files do not exist
if (fileA.FileExists == false && fileB.FileExists == false)
return new DiffBinaryTextResults(CompareType.Text, new FileContentInfo(), new FileContentInfo());
if (args.CompareType == CompareType.Assembly ||
(args.IsAuto && fileA.Is == FileType.Assembly || fileB.Is == FileType.Assembly))
return GetAssemblyFileLines(fileA, fileB, args, progress);
if (args.CompareType == CompareType.Binary ||
(args.IsAuto && fileA.Is == FileType.Binary || fileB.Is == FileType.Binary))
return GetBinaryFileLines(fileA, fileB, args, progress);
...
private string DecompileAssembly(string assemblyFilePath)
{
if (String.IsNullOrEmpty(assemblyFilePath) || !File.Exists(assemblyFilePath)) return String.Empty;
try
{
var settings = new DecompilerSettings();
//settings = new DecompilerSettings { UsingDeclarations = false, ShowXmlDocumentation = false };
var decompiler = new CSharpDecompiler(assemblyFilePath, settings);
return decompiler.DecompileWholeModuleAsString();
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
//Try to decompile as IL
try
{
using (var peFileStream = new FileStream(assemblyFilePath, FileMode.Open, FileAccess.Read))
using (var peFile = new PEFile(assemblyFilePath, peFileStream))
using (var writer = new StringWriter())
{
var output = new PlainTextOutput(writer);
ReflectionDisassembler rd = new ReflectionDisassembler(output, CancellationToken.None);
rd.DetectControlStructure = false;
//rd.ShowMetadataTokens = false;
//rd.ShowSequencePoints = false;
rd.WriteAssemblyReferences(peFile.Metadata);
var metadata = peFile.Metadata;
if (metadata.IsAssembly)
rd.WriteAssemblyHeader(peFile);
output.WriteLine();
rd.WriteModuleHeader(peFile);
output.WriteLine();
bool filterRvaAndCodeSize = true;
if (filterRvaAndCodeSize)
{
/*
StringBuilder result = new StringBuilder();
var sb = writer.GetStringBuilder(); //get the underlying StringBuilder
foreach (string line in sb.ToString().ReadLines())
{
if (!line.TrimStart().StartsWith("// Method begins at RVA") && !line.TrimStart().StartsWith("// Code size")) result.Append(line + Environment.NewLine);
}
return result.ToString();
*/
rd.WriteModuleContents(peFile, false);
}
else
{
rd.WriteModuleContents(peFile);
}
return writer.ToString();
}
}
catch (Exception ex2)
{
Console.WriteLine(ex2.ToString());
}
}
return string.Empty;
}
/// <summary>
/// Get Assembly file contents disassembled and rendered as text lines with line number marker at beginning of each line.
/// </summary>
/// <param name="fileA"></param>
/// <param name="fileB"></param>
/// <param name="args"></param>
/// <param name="progress"></param>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="leadingCharactersToIgnore">Leading number of characters to ignore for diff in each line.
/// This space is used in binary diff to display 8 digit line number and 4 digit space.</param>
private DiffBinaryTextResults GetAssemblyFileLines(FileCompInfo fileA, FileCompInfo fileB
, TextBinaryDiffArgs args
, IDiffProgress progress)
{
// Neither left nor right file exist or cannot be accessed
if (fileA.FileExists == false && fileB.FileExists == false)
return new DiffBinaryTextResults(CompareType.Assembly, new FileContentInfo(), new FileContentInfo());
string textA = DecompileAssembly(fileA.FileNamePath);
string textB = DecompileAssembly(fileB.FileNamePath);
FileContentInfo af = null, bf = null;
if (af == null || bf == null)
{
af = new FileContentInfo();
bf = new FileContentInfo();
af.Lines = DiffUtility.GetStringTextLines(textA, progress);
bf.Lines = DiffUtility.GetStringTextLines(textB, progress);
}
af.TextContent = textA;
bf.TextContent = textB;
DiffBinaryTextResults result = new DiffBinaryTextResults(CompareType.Text, af, bf);
return result;
}
Thanks for it!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.