Inspectopedia 2025.2 Help

Common Practices and Code Improvements

Access to a static member of a type via a derived type   New in this release

Access to a static member of a type via a derived type.

Actual number of bytes read by 'Stream.Read()' is ignored   New in this release

Actual number of bytes read by 'Stream.Read()' is ignored.

Add explicit 'return' or 'continue' before local functions   New in this release

Add explicit 'return' or 'continue' before local functions.

Annotation duplicate in hierarchy   New in this release

Annotation duplicate in hierarchy.

Auto-property can be made get-only (non-private accessibility)   New in this release

Auto-property can be made get-only (non-private accessibility).

Auto-property can be made get-only (private accessibility)   New in this release

Auto-property can be made get-only (private accessibility).

Base member has 'params' parameter, but the overrider does not have it   New in this release

Base member has 'params' parameter, but the overrider does not have it.

Can simplify 'Contains' before 'Add'   New in this release

Can simplify 'Contains' before 'Add'.

Cast expression can be replaced with explicit type arguments   New in this release

Cast expression can be replaced with explicit type arguments.

Cast expression can be replaced with explicit variable type   New in this release

Cast expression can be replaced with explicit variable type.

Cast expression can be replaced with lambda return type   New in this release

Cast expression can be replaced with lambda return type.

Cast expression can be replaced with simplified type arguments   New in this release

Cast expression can be replaced with simplified type arguments.

Change lock field type to 'System.Threading.Lock'   New in this release

Change lock field type to 'System.Threading.Lock'.

Check for reference equality instead   New in this release

Check for reference equality instead.

Class can be made sealed (non-inheritable) (non-private accessibility)   New in this release

Class can be made sealed (non-inheritable) (non-private accessibility).

Class can be made sealed (non-inheritable) (private accessibility)   New in this release

Class can be made sealed (non-inheritable) (private accessibility).

Confusing body-like statement   New in this release

Confusing body-like statement.

Container nullability attribute usage with declaration of non-container type   New in this release

Container nullability attribute usage with declaration of non-container type.

Convert 'if do while' into 'while'   New in this release

Convert 'if do while' into 'while'.

Convert 'if' into '||'   New in this release

Convert 'if' into '||'.

Convert local variable or field into constant (non-private accessibility)   New in this release

Convert local variable or field into constant (non-private accessibility).

Convert local variable or field into constant (private accessibility)   New in this release

Convert local variable or field into constant (private accessibility).

Declaration nullability inferred (parameter is inferred to be not null)   New in this release

Declaration nullability inferred (parameter is inferred to be not null).

Declaration nullability inferred (parameter is inferred to be nullable)   New in this release

Declaration nullability inferred (parameter is inferred to be nullable).

Declaration nullability inferred (type member is inferred to be not null)   New in this release

Declaration nullability inferred (type member is inferred to be not null).

Declaration nullability inferred (type member is inferred to be nullable)   New in this release

Declaration nullability inferred (type member is inferred to be nullable).

Dictionary item removal can be simplified with single 'Remove'   New in this release

Dictionary item removal can be simplified with single 'Remove'.

Dictionary lookup can be simplified with 'GetValueOrDefault'   New in this release

Dictionary lookup can be simplified with 'GetValueOrDefault'.

Dictionary lookup can be simplified with 'TryAdd'   New in this release

Dictionary lookup can be simplified with 'TryAdd'.

Dictionary lookup can be simplified with 'TryGetValue'   New in this release

Dictionary lookup can be simplified with 'TryGetValue'.

Empty statement is redundant   New in this release

Empty statement is redundant.

Extract common property pattern   New in this release

Extract common property pattern.

Field can be made readonly (non-private accessibility)   New in this release

Field can be made readonly (non-private accessibility).

Field can be made readonly (private accessibility)   New in this release

Field can be made readonly (private accessibility).

Get-only auto-property is never assigned   New in this release

Get-only auto-property is never assigned.

Invert condition   New in this release

Invert condition.

Iteration variable can be declared with a more specific type   New in this release

Iteration variable can be declared with a more specific type.

Join local variable declaration and assignment   New in this release

Join local variable declaration and assignment.

Local function can be made static   New in this release

Local function can be made static.

Local variable has too wide declaration scope   New in this release

Local variable has too wide declaration scope.

Make constructor in abstract class protected   New in this release

Make constructor in abstract class protected.

Member can be made private (non-private accessibility)   New in this release

Member can be made private (non-private accessibility).

Member can be made private (private accessibility)   New in this release

Member can be made private (private accessibility).

Member can be made protected (non-private accessibility)   New in this release

Member can be made protected (non-private accessibility).

Member can be made protected (private accessibility)   New in this release

Member can be made protected (private accessibility).

Member can be made static (shared) (non-private accessibility)   New in this release

Member can be made static (shared) (non-private accessibility).

Member can be made static (shared) (private accessibility)   New in this release

Member can be made static (shared) (private accessibility).

Member or type can be made internal (friend)   New in this release

Member or type can be made internal (friend).

Method has async overload   New in this release

Method has async overload.

Method has async overload with cancellation support   New in this release

Method has async overload with cancellation support.

Method supports cancellation   New in this release

Method supports cancellation.

Missing XML comment for private or internal type or member   New in this release

Missing XML comment for private or internal type or member.

Multiple nullable attributes usage   New in this release

Multiple nullable attributes usage.

Nested string interpolation can be inlined   New in this release

Nested string interpolation can be inlined.

Nullability attribute usage with declaration of void or value type   New in this release

Nullability attribute usage with declaration of void or value type.

Nullability attribute used with declaration that cannot be directly referenced from other code   New in this release

Nullability attribute used with declaration that cannot be directly referenced from other code.

Parameter can be declared with the base type   New in this release

Parameter can be declared with the base type.

Parameter of the constructor can be declared with the base type   New in this release

Parameter of the constructor can be declared with the base type.

Parameter type can be IEnumerable<T> (non-private accessibility)   New in this release

Parameter type can be IEnumerable<T> (non-private accessibility).

Parameter type can be IEnumerable<T> (private accessibility)   New in this release

Parameter type can be IEnumerable<T> (private accessibility).

Prefer using concrete value over 'default' or 'new()'   New in this release

Prefer using concrete value over 'default' or 'new()'.

Property can be made init-only (non-private accessibility)   New in this release

Property can be made init-only (non-private accessibility).

Property can be made init-only (private accessibility)   New in this release

Property can be made init-only (private accessibility).

Put local function after 'return' or 'continue'   New in this release

Put local function after 'return' or 'continue'.

Redundant 'is'   New in this release

Redundant 'is'.

Remove constructor invocation   New in this release

Remove constructor invocation.

Remove redundant statement   New in this release

Remove redundant statement.

Remove ToList()  

Remove ToList().

Replace 'async' code with 'Task'-return   New in this release

Replace 'async' code with 'Task'-return.

Replace with FirstOrDefault($args$)  

Replace with FirstOrDefault($args$).

Replace with LastOrDefault($args$)   New in this release

Replace with LastOrDefault($args$).

Replace with OfType<T>()   New in this release

Replace with OfType<T>().

Replace with OfType<T>().Any()   New in this release

Replace with OfType<T>().Any().

Replace with OfType<T>().Any() (replace with OfType<T>().Any(..))   New in this release

Replace with OfType<T>().Any() (replace with OfType<T>().Any(..)).

Replace with OfType<T>().Count()   New in this release

Replace with OfType<T>().Count().

Replace with OfType<T>().Count() (replace with OfType<T>().Count(..))   New in this release

Replace with OfType<T>().Count() (replace with OfType<T>().Count(..)).

Replace with OfType<T>().First()   New in this release

Replace with OfType<T>().First().

Replace with OfType<T>().First() (replace with OfType<T>().First(..))   New in this release

Replace with OfType<T>().First() (replace with OfType<T>().First(..)).

Replace with OfType<T>().FirstOrDefault()   New in this release

Replace with OfType<T>().FirstOrDefault().

Replace with OfType<T>().FirstOrDefault() (replace with OfType<T>().FirstOrDefault(..))   New in this release

Replace with OfType<T>().FirstOrDefault() (replace with OfType<T>().FirstOrDefault(..)).

Replace with OfType<T>().Last()   New in this release

Replace with OfType<T>().Last().

Replace with OfType<T>().Last() (replace with OfType<T>().Last(..))   New in this release

Replace with OfType<T>().Last() (replace with OfType<T>().Last(..)).

Replace with OfType<T>().LastOrDefault()   New in this release

Replace with OfType<T>().LastOrDefault().

Replace with OfType<T>().LastOrDefault() (replace with OfType<T>().LastOrDefault(..))   New in this release

Replace with OfType<T>().LastOrDefault() (replace with OfType<T>().LastOrDefault(..)).

Replace with OfType<T>().LongCount()   New in this release

Replace with OfType<T>().LongCount().

Replace with OfType<T>().Single()   New in this release

Replace with OfType<T>().Single().

Replace with OfType<T>().Single() (replace with OfType<T>().Single(..))   New in this release

Replace with OfType<T>().Single() (replace with OfType<T>().Single(..)).

Replace with OfType<T>().SingleOrDefault()   New in this release

Replace with OfType<T>().SingleOrDefault().

Replace with OfType<T>().SingleOrDefault() (replace with OfType<T>().SingleOrDefault(..))   New in this release

Replace with OfType<T>().SingleOrDefault() (replace with OfType<T>().SingleOrDefault(..)).

Replace with OfType<T>().Where() (replace with OfType<T>().Where(..))   New in this release

Replace with OfType<T>().Where() (replace with OfType<T>().Where(..)).

Replace with simple assignment   New in this release

Replace with simple assignment.

Replace with single assignment  

Replace with single assignment.

Replace with single call to Any(..)  

Replace with single call to Any(..).

Replace with single call to Count(..)  

Replace with single call to Count(..).

Replace with single call to First(..)  

Replace with single call to First(..).

Replace with single call to FirstOrDefault(..)  

Replace with single call to FirstOrDefault(..).

Replace with single call to Last(..)  

Replace with single call to Last(..).

Replace with single call to LastOrDefault(..)  

Replace with single call to LastOrDefault(..).

Replace with single call to Single(..)   New in this release

Replace with single call to Single(..).

Replace with single call to SingleOrDefault(..)  

Replace with single call to SingleOrDefault(..).

Replace with SingleOrDefault($args$)   New in this release

Replace with SingleOrDefault($args$).

Return type can be IEnumerable<T> (non-private accessibility)   New in this release

Return type can be IEnumerable<T> (non-private accessibility).

Return type can be IEnumerable<T> (private accessibility)   New in this release

Return type can be IEnumerable<T> (private accessibility).

Simplify 'IsInstanceOfType()' invocation   New in this release

Simplify 'IsInstanceOfType()' invocation.

Simplify conditional ternary expression   New in this release

Simplify conditional ternary expression.

Simplify LINQ expression (use 'All')   New in this release

Simplify LINQ expression (use 'All').

Simplify LINQ expression (use 'Any')   New in this release

Simplify LINQ expression (use 'Any').

Simplify negated pattern   New in this release

Simplify negated pattern.

Simplify negated relational pattern   New in this release

Simplify negated relational pattern.

Simplify negative equality expression   New in this release

Simplify negative equality expression.

Specify string comparison explicitly   New in this release

Specify string comparison explicitly.

Specify string culture explicitly   New in this release

Specify string culture explicitly.

String literal can be inlined   New in this release

String literal can be inlined.

String.Compare is culture-specific (string.Compare(string, int, string, int) is culture-specific)   New in this release

String.Compare is culture-specific (string.Compare(string, int, string, int) is culture-specific).

String.Compare is culture-specific (string.Compare(string, int, string, int, bool) is culture-specific)   New in this release

String.Compare is culture-specific (string.Compare(string, int, string, int, bool) is culture-specific).

String.Compare is culture-specific (string.Compare(string, string) is culture-specific)   New in this release

String.Compare is culture-specific (string.Compare(string, string) is culture-specific).

String.Compare is culture-specific (string.Compare(string, string, bool) is culture-specific)   New in this release

String.Compare is culture-specific (string.Compare(string, string, bool) is culture-specific).

String.CompareTo is culture-specific   New in this release

String.CompareTo is culture-specific.

String.EndsWith is culture-specific (string.EndsWith(string) is culture-specific)  

String.EndsWith is culture-specific (string.EndsWith(string) is culture-specific).

String.IndexOf is culture-specific (string.IndexOf(string) is culture-specific)   New in this release

String.IndexOf is culture-specific (string.IndexOf(string) is culture-specific).

String.IndexOf is culture-specific (string.IndexOf(string, int) is culture-specific)   New in this release

String.IndexOf is culture-specific (string.IndexOf(string, int) is culture-specific).

String.LastIndexOf is culture-specific (string.LastIndexOf(string) is culture-specific)  

String.LastIndexOf is culture-specific (string.LastIndexOf(string) is culture-specific).

String.LastIndexOf is culture-specific (string.LastIndexOf(string, int) is culture-specific)  

String.LastIndexOf is culture-specific (string.LastIndexOf(string, int) is culture-specific).

String.StartsWith is culture-specific (string.StartsWith(string) is culture-specific)   New in this release

String.StartsWith is culture-specific (string.StartsWith(string) is culture-specific).

Struct can be made readonly   New in this release

Struct can be made readonly.

Struct lacks 'IEquatable' implementation (non-private accessibility)   New in this release

Struct lacks 'IEquatable' implementation (non-private accessibility).

Struct lacks 'IEquatable' implementation (private accessibility)   New in this release

Struct lacks 'IEquatable' implementation (private accessibility).

Struct member can be made readonly   New in this release

Struct member can be made readonly.

Struct with default equality members is used for comparison (non-private accessibility)   New in this release

Struct with default equality members is used for comparison (non-private accessibility).

Struct with default equality members is used for comparison (private accessibility)   New in this release

Struct with default equality members is used for comparison (private accessibility).

try-catch and try-finally statements can be merged   New in this release

try-catch and try-finally statements can be merged.

Type can be made file-local   New in this release

Type can be made file-local.

Type parameter could be declared as covariant or contravariant   New in this release

Type parameter could be declared as covariant or contravariant.

Type with suspicious equality is used in a record (non-private accessibility)   New in this release

Type with suspicious equality is used in a record (non-private accessibility).

Type with suspicious equality is used in a record (private accessibility)   New in this release

Type with suspicious equality is used in a record (private accessibility).

Usage of default struct equality   New in this release

Usage of default struct equality.

Use 'ArgumentNullException.ThrowIfNull'   New in this release

Use 'ArgumentNullException.ThrowIfNull'.

Use 'Array.Empty<T>()'   New in this release

Use 'Array.Empty<T>()'.

Use 'EventArgs.Empty'   New in this release

Use 'EventArgs.Empty'.

Use 'is' operator   New in this release

Use 'is' operator.

Use 'String.IsNullOrEmpty'   New in this release

Use 'String.IsNullOrEmpty'.

Use 'Type.EmptyTypes'   New in this release

Use 'Type.EmptyTypes'.

Use array creation expression   New in this release

Use array creation expression.

Use cancellation token   New in this release

Use cancellation token.

Use compiler-supported nullable attributes   New in this release

Use compiler-supported nullable attributes.

Use indexed property   New in this release

Use indexed property.

Use method Any()  

Use method Any().

Last modified: 29 July 2025