Home

Awesome

ReflectionAnalyzers

License Build status Build Status NuGet Join the chat at https://gitter.im/DotNetAnalyzers/ReflectionAnalyzers

Analyzers checking System.Reflection

IdTitle
REFL001Cast return value to the correct type
REFL002Discard the return value
REFL003The member does not exist
REFL004More than one member is matching the criteria
REFL005There is no member matching the filter
REFL006The binding flags can be more precise
REFL007The binding flags are not in the expected order
REFL008Specify binding flags for better performance and less fragile code
REFL009The referenced member is not known to exist
REFL010Prefer the generic extension method GetCustomAttribute<T>
REFL011Duplicate BindingFlag
REFL012Prefer Attribute.IsDefined()
REFL013The member is of the wrong type
REFL014Prefer GetMember().AccessorMethod
REFL015Use the containing type
REFL016Use nameof
REFL017Don't use name of wrong member
REFL018The member is explicitly implemented
REFL019No member matches the types
REFL020More than one interface is matching the name
REFL022Use fully qualified name
REFL023The type does not implement the interface
REFL024Prefer null over empty array
REFL025Use correct arguments
REFL026No parameterless constructor defined for this object
REFL027Prefer Type.EmptyTypes
REFL028Cast return value to correct type
REFL029Specify types in case an overload is added in the future
REFL030Use correct obj parameter
REFL031Use generic arguments that satisfies the type parameters
REFL032The dependency does not exist
REFL033Use the same type as the parameter
REFL034Don't call MakeGeneric when not a generic definition
REFL035Don't call Invoke on a generic definition
REFL036Pass 'throwOnError: true' or check if null
REFL037The type does not exist
REFL038Prefer RuntimeHelpers.RunClassConstructor
REFL039Prefer typeof(...) over instance.GetType when the type is sealed
REFL040Prefer type.IsInstanceOfType(...)
REFL041Delegate type is not matching
REFL042First argument must be reference type
REFL043First argument must match type
REFL044Expected attribute type
REFL045These flags are insufficient to match any members
REFL046The specified default member does not exist

Using ReflectionAnalyzers

The preferable way to use the analyzers is to add the nuget package ReflectionAnalyzers to the project(s).

The severity of individual rules may be configured using rule set files in Visual Studio 2015.

Installation

ReflectionAnalyzers can be installed using:

Install using the command line:

paket add ReflectionAnalyzers --project <project>

or if you prefer NuGet

Install-Package ReflectionAnalyzers