Skip to content

Commit

Permalink
Add regression test for SA1013 reporting on anonymous types in indexers
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelvo committed Aug 12, 2015
1 parent 2088f26 commit dfd0ed4
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,31 @@ public void TestMethod2()
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
}

/// <summary>
/// Verifies that the analyzer will properly handle anonymous classes in indexers.
/// This is a regression test for <see href="https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1191">DotNetAnalyzers/StyleCopAnalyzers#1191</see>
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task TestIndexersAsync()
{
var testCode = @"namespace TestNamespace
{
public class TestClass
{
public void TestMethod()
{
var dictionary = new System.Collections.Generic.Dictionary<object, object>();
dictionary[new { Foo = ""Foo"", Bar = 5 }] = 42;
}
}
}
";

// no space between closing curly bracket and closing bracket should not be reported by SA1013
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <inheritdoc/>
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
{
Expand Down

0 comments on commit dfd0ed4

Please sign in to comment.