Last active
November 15, 2025 05:58
-
-
Save kurnakovv/0a5f49c7700af910c0c7490fef44cfc8 to your computer and use it in GitHub Desktop.
WarningsAsErrors for all nullable codes in .editorconfig | NullReferenceException (NRE)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [*.cs] | |
| ## | |
| ## NullReferenceException (NRE) or nullable | |
| ## | |
| # All rules here https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/nullable-warnings | |
| # Thrown value may be null. | |
| dotnet_diagnostic.CS8597.severity = error | |
| # The suppression operator is not allowed in this context | |
| dotnet_diagnostic.CS8598.severity = error | |
| # Converting null literal or possible null value to non-nullable type. | |
| dotnet_diagnostic.CS8600.severity = error | |
| # Possible null reference assignment. | |
| dotnet_diagnostic.CS8601.severity = error | |
| # Dereference of a possibly null reference. | |
| dotnet_diagnostic.CS8602.severity = error | |
| # Possible null reference return. | |
| dotnet_diagnostic.CS8603.severity = error | |
| # Possible null reference argument for parameter. | |
| dotnet_diagnostic.CS8604.severity = error | |
| # Unboxing a possibly null value. | |
| dotnet_diagnostic.CS8605.severity = error | |
| # A possible null value may not be used for a type marked with [NotNull] or [DisallowNull] | |
| dotnet_diagnostic.CS8607.severity = error | |
| # Nullability of reference types in type doesn't match overridden member. | |
| dotnet_diagnostic.CS8608.severity = error | |
| # Nullability of reference types in return type doesn't match overridden member. | |
| dotnet_diagnostic.CS8609.severity = error | |
| # Nullability of reference types in type parameter doesn't match overridden member. | |
| dotnet_diagnostic.CS8610.severity = error | |
| # Nullability of reference types in type parameter doesn't match partial method declaration. | |
| dotnet_diagnostic.CS8611.severity = error | |
| # Nullability of reference types in type doesn't match implicitly implemented member. | |
| dotnet_diagnostic.CS8612.severity = error | |
| # Nullability of reference types in return type doesn't match implicitly implemented member. | |
| dotnet_diagnostic.CS8613.severity = error | |
| # Nullability of reference types in type of parameter doesn't match implicitly implemented member. | |
| dotnet_diagnostic.CS8614.severity = error | |
| # Nullability of reference types in type doesn't match implemented member. | |
| dotnet_diagnostic.CS8615.severity = error | |
| # Nullability of reference types in return type doesn't match implemented member. | |
| dotnet_diagnostic.CS8616.severity = error | |
| # Nullability of reference types in type of parameter doesn't match implemented member. | |
| dotnet_diagnostic.CS8617.severity = error | |
| # Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. | |
| dotnet_diagnostic.CS8618.severity = error | |
| # Nullability of reference types in value doesn't match target type. | |
| dotnet_diagnostic.CS8619.severity = error | |
| # Argument cannot be used for parameter due to differences in the nullability of reference types. | |
| dotnet_diagnostic.CS8620.severity = error | |
| # Nullability of reference types in return type doesn't match the target delegate (possibly because of nullability attributes). | |
| dotnet_diagnostic.CS8621.severity = error | |
| # Nullability of reference types in type of parameter doesn't match the target delegate (possibly because of nullability attributes). | |
| dotnet_diagnostic.CS8622.severity = error | |
| # Explicit application of System.Runtime.CompilerServices.NullableAttribute is not allowed. | |
| dotnet_diagnostic.CS8623.severity = error | |
| # Argument cannot be used as an output due to differences in the nullability of reference types. | |
| dotnet_diagnostic.CS8624.severity = error | |
| # Cannot convert null literal to non-nullable reference type. | |
| dotnet_diagnostic.CS8625.severity = error | |
| # Cannot use a nullable reference type in object creation. | |
| dotnet_diagnostic.CS8628.severity = error | |
| # Nullable value type may be null. | |
| dotnet_diagnostic.CS8629.severity = error | |
| # 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 | |
| # The annotation for nullable reference types should only be used in code within a #nullable annotations context. | |
| dotnet_diagnostic.CS8632.severity = error | |
| # Nullability in constraints for type parameter of method doesn't match the constraints for type parameter of interface method. Consider using an explicit interface implementation instead. | |
| dotnet_diagnostic.CS8633.severity = error | |
| # 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 | |
| # Invalid option for /nullable; must be disable, enable, warnings or annotations | |
| dotnet_diagnostic.CS8636.severity = error | |
| # Expected enable, disable, or restore | |
| dotnet_diagnostic.CS8637.severity = error | |
| # The typeof operator cannot be used on a nullable reference type | |
| dotnet_diagnostic.CS8639.severity = error | |
| # Nullability of reference types in explicit interface specifier doesn't match interface implemented by the type. | |
| dotnet_diagnostic.CS8643.severity = error | |
| # 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 | |
| # Member is already listed in the interface list on type with different nullability of reference types. | |
| dotnet_diagnostic.CS8645.severity = error | |
| # The switch expression does not handle some null inputs (it is not exhaustive). | |
| dotnet_diagnostic.CS8655.severity = error | |
| # Partial method declarations have inconsistent nullability in constraints for type parameter. | |
| dotnet_diagnostic.CS8667.severity = error | |
| # Object or collection initializer implicitly dereferences possibly null member. | |
| dotnet_diagnostic.CS8670.severity = error | |
| # 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 | |
| # Parameter must have a non-null value when exiting. | |
| dotnet_diagnostic.CS8762.severity = error | |
| # A method marked [DoesNotReturn] should not return. | |
| dotnet_diagnostic.CS8763.severity = error | |
| # Nullability of return type doesn't match overridden member (possibly because of nullability attributes). | |
| dotnet_diagnostic.CS8764.severity = error | |
| # Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes). | |
| dotnet_diagnostic.CS8765.severity = error | |
| # Nullability of reference types in return type of doesn't match implicitly implemented member (possibly because of nullability attributes). | |
| dotnet_diagnostic.CS8766.severity = error | |
| # Nullability of reference types in type of parameter of doesn't match implicitly implemented member (possibly because of nullability attributes). | |
| dotnet_diagnostic.CS8767.severity = error | |
| # Nullability of reference types in return type doesn't match implemented member (possibly because of nullability attributes). | |
| dotnet_diagnostic.CS8768.severity = error | |
| # Nullability of reference types in type of parameter doesn't match implemented member (possibly because of nullability attributes). | |
| dotnet_diagnostic.CS8769.severity = error | |
| # Method lacks [DoesNotReturn] annotation to match implemented or overridden member. | |
| dotnet_diagnostic.CS8770.severity = error | |
| # Member must have a non-null value when exiting. | |
| dotnet_diagnostic.CS8774.severity = error | |
| # Member cannot be used in this attribute. | |
| dotnet_diagnostic.CS8776.severity = error | |
| # Member must have a non-null value when exiting. | |
| dotnet_diagnostic.CS8775.severity = error | |
| # Parameter must have a non-null value when exiting. | |
| dotnet_diagnostic.CS8777.severity = error | |
| # Nullability of reference types in return type doesn't match partial method declaration. | |
| dotnet_diagnostic.CS8819.severity = error | |
| # Parameter must have a non-null value when exiting because parameter is non-null. | |
| dotnet_diagnostic.CS8824.severity = error | |
| # Return value must be non-null because parameter is non-null. | |
| dotnet_diagnostic.CS8825.severity = error | |
| # The switch expression does not handle some null inputs (it is not exhaustive). However, a pattern with a 'when' clause might successfully match this value. | |
| dotnet_diagnostic.CS8847.severity = error | |
| ## **END** NullReferenceException (NRE) or nullable **END** |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For what?
<WarningsAsErrors>nullable</WarningsAsErrors>in all of themdefault/warning/none/silent/suggestion) for specific codeSimplified version
This code is no different, just less indentation and spaces.
Program