Skip to content

Commit

Permalink
Merge pull request #1 from sharwell/update-935
Browse files Browse the repository at this point in the history
Tweak changed document detection
  • Loading branch information
vweijsters committed Jul 8, 2015
2 parents e0304de + a350818 commit bb9cee1
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Text;
using Xunit;

/// <summary>
Expand Down Expand Up @@ -80,7 +79,11 @@ private async Task VerifyFixAsync(string language, ImmutableArray<DiagnosticAnal
break;
}

Assert.True(AreDiagnosticsDifferent(analyzerDiagnostics, previousDiagnostics), "Unmodified diagnostics detected!");
if (!AreDiagnosticsDifferent(analyzerDiagnostics, previousDiagnostics))
{
break;
}

previousDiagnostics = analyzerDiagnostics;

done = true;
Expand All @@ -93,14 +96,15 @@ private async Task VerifyFixAsync(string language, ImmutableArray<DiagnosticAnal
if (actions.Count > 0)
{
var fixedDocument = await ApplyFixAsync(document, actions.ElementAt(codeFixIndex.GetValueOrDefault(0)), cancellationToken).ConfigureAwait(false);

var oldText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
var newText = await fixedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
done = oldText.ContentEquals(newText);

// workaround for issue #936 - force reparsing to get the same sort of syntax tree as the original document.
document = CreateDocument(newText.ToString(), language);
break;
if (fixedDocument != document)
{
done = false;
var newText = await fixedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);

// workaround for issue #936 - force re-parsing to get the same sort of syntax tree as the original document.
document = document.WithText(newText);
break;
}
}
}
}
Expand Down

0 comments on commit bb9cee1

Please sign in to comment.