GithubHelp home page GithubHelp logo

dirkster99 / aehnlich Goto Github PK

View Code? Open in Web Editor NEW
92.0 92.0 9.0 3.81 MB

Show/Merge differences in directories and their content (text files) in Light/Dark designs

License: MIT License

Batchfile 0.31% C# 99.69%
csharp diff diff-tool directory-comparator directory-management directory-traversal gui merge myers-algorithm text-compare text-diff winmerge wpf wpf-application

aehnlich's People

Contributors

dirkster99 avatar softworkz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aehnlich's Issues

Comparing similar strings

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

image

Live Editing

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?

Left selection border

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... :-)

image

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?

Shortened View around changes only + Export

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:

  • html file with diff view (side by side)
  • patch file (diff )
  • ...

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.