Skip to content

Instantly share code, notes, and snippets.

@cezarypiatek
Last active February 14, 2023 21:48
Show Gist options
  • Save cezarypiatek/f56c671c6f634aab285a88095488c1de to your computer and use it in GitHub Desktop.
Save cezarypiatek/f56c671c6f634aab285a88095488c1de to your computer and use it in GitHub Desktop.
This snippet set severity level to error for different rules related to the reference nullability
[*.cs]
# CS8603: Possible null reference return.
dotnet_diagnostic.CS8603.severity = error
# CS8604: Possible null reference argument.
dotnet_diagnostic.CS8604.severity = error
# CS8606: Possible null reference assignment to iteration variable
dotnet_diagnostic.CS8606.severity = error
# CS8600: Converting null literal or possible null value to non-nullable type.
dotnet_diagnostic.CS8600.severity = error
# CS8602: Dereference of a possibly null reference.
dotnet_diagnostic.CS8602.severity = error
# CS8625: Cannot convert null literal to non-nullable reference type.
dotnet_diagnostic.CS8625.severity = error
# CS8607: A possible null value may not be passed to a target marked with the [DisallowNull] attribute
dotnet_diagnostic.CS8607.severity = error
# CS8608: Nullability of reference types in type doesn't match overridden member.
dotnet_diagnostic.CS8608.severity = error
# CS8609: Nullability of reference types in return type doesn't match overridden member.
dotnet_diagnostic.CS8609.severity = error
# CS8610: Nullability of reference types in type of parameter doesn't match overridden member.
dotnet_diagnostic.CS8610.severity = error
# CS8611: Nullability of reference types in type of parameter doesn't match partial method declaration.
dotnet_diagnostic.CS8611.severity = error
# CS8612: Nullability of reference types in type doesn't match implicitly implemented member.
dotnet_diagnostic.CS8612.severity = error
# CS8613: Nullability of reference types in return type doesn't match implicitly implemented member.
dotnet_diagnostic.CS8613.severity = error
# CS8614: Nullability of reference types in type of parameter doesn't match implicitly implemented member.
dotnet_diagnostic.CS8614.severity = error
# CS8615: Nullability of reference types in type doesn't match implemented member.
dotnet_diagnostic.CS8615.severity = error
# CS8616: Nullability of reference types in return type doesn't match implemented member.
dotnet_diagnostic.CS8616.severity = error
# CS8617: Nullability of reference types in type of parameter doesn't match implemented member.
dotnet_diagnostic.CS8617.severity = error
# CS8619: Nullability of reference types in value doesn't match target type.
dotnet_diagnostic.CS8619.severity = error
#CS8620: Argument cannot be used for parameter due to differences in the nullability of reference types.
dotnet_diagnostic.CS8620.severity = error
#CS8621: Nullability of reference types in return type doesn't match the target delegate.
dotnet_diagnostic.CS8621.severity = error
#CS8622: Nullability of reference types in type of parameter doesn't match the target delegate.
dotnet_diagnostic.CS8622.severity = error
#CS8624: Argument cannot be used as an output for parameter due to differences in the nullability of reference types.
dotnet_diagnostic.CS8624.severity = error
#CS8625: Cannot convert null literal to non-nullable reference type.
dotnet_diagnostic.CS8625.severity = error
#CS8626: The 'as' operator may produce a null value for a type parameter.
dotnet_diagnostic.CS8626.severity = error
#CS8629: Nullable value type may be null.
dotnet_diagnostic.CS8629.severity = error
#CS8631: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match constraint type.
dotnet_diagnostic.CS8631.severity = error
#CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
dotnet_diagnostic.CS8632.severity = error
#CS8633: Nullability in constraints for type parameter doesn't match the constraints for type parameter in implicitly implemented interface method.
dotnet_diagnostic.CS8633.severity = error
#CS8634: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'class' constraint.
dotnet_diagnostic.CS8634.severity = error
#CS8638: Conditional access may produce a null value for a type parameter.
dotnet_diagnostic.CS8638.severity = error
#CS8643: Nullability of reference types in explicit interface specifier doesn't match interface implemented by the type.
dotnet_diagnostic.CS8643.severity = error
#CS8644: Type does not implement interface member. Nullability of reference types in interface implemented by the base type doesn't match.
dotnet_diagnostic.CS8644.severity = error
#CS8645: Interface is already listed in the interface list with different nullability of reference types.
dotnet_diagnostic.CS8645.severity = error
#CS8653: A default expression introduces a null value for a type parameter.
dotnet_diagnostic.CS8653.severity = error
#CS8654: A null literal introduces a null value for a type parameter.
dotnet_diagnostic.CS8654.severity = error
#CS8655: The switch expression does not handle some null inputs.
dotnet_diagnostic.CS8655.severity = error
#CS8667: Partial method declarations have inconsistent nullability in constraints for type parameter
dotnet_diagnostic.CS8667.severity = error
#CS8714: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'notnull' constraint.
dotnet_diagnostic.CS8714.severity = error
#CS8618: Non-nullable property is uninitialized. Consider declaring the property as nullable.
dotnet_diagnostic.CS8618.severity = error
@NN---
Copy link

NN--- commented Jun 6, 2020

First CS8625 is incorrect.

It should be:

CS8605: Unboxing a possibly null value.

dotnet_diagnostic.CS8605.severity = error

@NN---
Copy link

NN--- commented Jun 6, 2020

@matthewblott
Copy link

@juanchavezlive
Copy link

juanchavezlive commented Sep 8, 2021

Love this ! Very useful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment