FakeItEasy provides a Roslyn analyzer to detect incorrect usages of the library that cannot be prevented by the API or the compiler but will typically result in bugs at runtime.
The analyzer works in Visual Studio 2015 Update 1 or later. Install one of these NuGet packages in each project that needs it:
The analyzer currently provides the following diagnostics:
|FakeItEasy0001||Unused call specification||no||Triggered when you specify a call but don't configure or assert it, making it a no-op.|
|FakeItEasy0002||Non-virtual member configuration||no||Triggered when you try to configure a non-virtual member, which cannot be faked.|
|FakeItEasy0003||Argument constraint outside call spec||no||Triggered when you try to use an argument constraint outside of a call specification.|
|FakeItEasy0004||Argument constraint nullability mismatch||yes||Triggered when you use a non-nullable argument constraint for a nullable parameter. Calls where the argument is null won't be matched. If this is intentional, consider using
|FakeItEasy0005||Argument constraint type mismatch||yes||Triggered when you use an argument constraint whose type doesn't match the parameter. No such calls can be matched.|