-
-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Description
Hello,
In the following code ChangeType.Modified is not working. When there is a change within a line, it's detected as deleted and added and is counted as two changes instead of one. Could you please provide more info about why the ChangeType.Modified is not working and how to fix it? Thank you in advance
public static int CompareTwoNCFiles(string expectedResultFile, string newGeneratedFile, string comparisonFile)
{
StringBuilder sb = new StringBuilder();
var d = new Differ();
var builder = new InlineDiffBuilder(d);
var result = builder.BuildDiffModel(expectedResultFile, newGeneratedFile, ignoreWhitespace: true);
int countOfChanges = 0;
List<string> exceptions = new List<string>
{
"PPF VERSION",
"POST VERSION",
"PROJECT NAME",
"PROGRAM DATE",
"UNIQUEJOBID"
};
foreach (var line in result.Lines)
{
if (exceptions.Any(e => line.Text.Contains(e)))
continue;
switch (line.Type)
{
case ChangeType.Inserted:
sb.Append("+ ");
countOfChanges++;
break;
case ChangeType.Deleted:
sb.Append("- ");
countOfChanges++;
break;
case ChangeType.Modified: // Modified is not working with the current implementation
sb.Append("* ");
countOfChanges++;
break;
case ChangeType.Imaginary:
sb.Append("? ");
break;
case ChangeType.Unchanged:
sb.Append(" ");
break;
}
sb.Append(line.Text + "\n");
}
File.WriteAllText(comparisonFile, sb.ToString());
return countOfChanges;
}
Metadata
Metadata
Assignees
Labels
No labels