Skip to content

AA2001DoNotUseNotSupportedException

David Arno edited this page Jul 18, 2016 · 1 revision

Warning: this wiki page is auto-generated by the Arnolyzer solution-build process. Do not directly edit this page, as your changes will be lost on the next commit. To edit this page, please refer to Contributing to this project.

These wiki pages reflect the state of the project in development, per the last commit. For details of the latest release of the Arnolyzer Analysers, please see the Arnolyzer website.


AA2001 - Do Not Use Not Supported Exception

Report code: AA2001-DoNotUseNotSupportedException

Summary

Status Implemented
Description The NotSupportedException 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 NotSupportedException 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.