Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,32 @@ public void AnalyzeWhenDelegateProvided()
RoslynAssert.Valid(analyzer, testCode);
}

[Test]
public void AnalyzeWhenDelegateLocalProvided()
{
var testCode = TestUtility.WrapInTestMethod(@"
TestDelegate action = MyOperation;
Assert.That(action, Throws.InvalidOperationException);

static void MyOperation() => throw new InvalidOperationException();
");

RoslynAssert.Valid(analyzer, testCode);
}

[Test]
public void AnalyzeWhenDelegateParameterProvided()
{
var testCode = TestUtility.WrapInTestMethod(@"
AssertSupported(MyOperation);

static void AssertSupported(Action test) => Assert.That(test, Throws.InvalidOperationException);
static void MyOperation() => throw new InvalidOperationException();
");

RoslynAssert.Valid(analyzer, testCode);
}

[Test]
public void AnalyzeWhenAsyncDelegateProvided()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override void AnalyzeAssertInvocation(OperationAnalysisContext context
return;
}

if (actualOperation is IDelegateCreationOperation)
if (actualOperation.Type.TypeKind == TypeKind.Delegate)
{
return;
}
Expand Down