Code inspection: Simplify 'IsInstanceOfType()' invocation

Last modified: 08 August 2024

This inspection reports invocations like IsAssignableFrom(value.GetType()). Such invocations can be simplified either as IsInstanceOfType(value) or as value is string. All those expressions are identical in terms of semantics and performance, but the suggested alternatives improve readability.

There is an additional safety benefit in the suggested transformations, because both IsInstanceOfType() and is will return false if value is null, thus avoiding a potential NullReferenceException, which otherwise will be thrown by the GetType() invocation.