View on GitHub

Arnolyzer

Clean-code Roslyn-based analyzer for C# 6

Arnolyzer on nuget

AA2000 - Do Not Use Not Implemented Exception

Report code: AA2000-DoNotUseNotImplementedException

Summary

Status Implemented
Description The NotImplementedException is a direct violation of the Liskov Substitution Principle (LSP) and so must not be used
Category Liskov Substitution Principle Analyzers
Enabled by default: Yes
Severity: Error

Cause

From the Liskov Substitution Principle (LSP) article on Wikipedia: > Substitutability is a principle in object-oriented programming. It states that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may substitute objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.)

A subtype (or interface implementation) that throws a NotImplementedException cannot be used as a substitute to its parent “without altering any of the desirable properties of that program”. Therefore the use of this exception is a violation of the LSP.

How to fix violations

There currently aren’t any implemented code-fixes for this rule.

How to suppress violations

This rule cannot be suppressed.