There a is bug when comparing documents using Aspose.Words for .NET. When you compare two documents, it produces numerous “Style Definition” revisions when none exist. It is very simple to reproduce given the attached document. Just calling the Compare method on the same document produces the revisions when we would expect none, because there are no changes between the same document. The compared documents don’t have to be the same, but are for the simplicity of reproducing the issue. This issue occurs in 26.7, but is reproducible since 26.1. When I use 25.12, this issue does not appear.
The attached document includes the before and after document, code snippet below:
// Code example: at this point the word document is loaded into a MemoryStream
docMemoryStream.Position = 0;
var compareDocument = new Document(docMemoryStream);
docMemoryStream.Position = 0;
var compareAgainstDocument = new Document(docMemoryStream);
docMemoryStream.Position = 0;
var debugId = Guid.NewGuid();
var preComparePath = Path.Combine(Path.GetTempPath(), $"AsposeCompareDebug_{debugId:N}_pre.docx");
await File.WriteAllBytesAsync(preComparePath, docMemoryStream.ToArray());
compareDocument.Compare(compareAgainstDocument, "AsposeCompareDebug", DateTime.Now);
var postComparePath = Path.Combine(Path.GetTempPath(), $"AsposeCompareDebug_{debugId:N}_post.docx");
compareDocument.Save(postComparePath);
Console.WriteLine(
$"Aspose.Words {Aspose.Words.BuildVersionInfo.Version} self-compare produced {compareDocument.Revisions.Count} revisions; pre saved to {preComparePath}, post saved to {postComparePath}");
compare_document_bug_example.zip (22.2 KB)