Skip to content

Add new rule for unnecessary use of lambda expressions #927

@manfred-brands

Description

@manfred-brands

I have seen code that does: Assert.That(() => instance.Method(parameters), Is.True);

There is no need for the lambda.

The lambda is only needed if:

  • Expecting an exception, like in: Assert.That(() => instance.Method(parameters), Throws.InvalidOperationException);
  • Using DelayConstraint, like in: `Assert.That(() => instance.Method(parameters), Is.True.After(1).Seconds;

I would like a new Analyzer with code fix that is raises issues and allows removing the lambda.

This rule is the opposite of NUnit2044 (Delegate Required)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions