rspec/rules/S2259/csharp/rule.adoc

28 lines
898 B
Plaintext
Raw Normal View History

2023-07-03 17:26:15 +02:00
:null-keyword: null
:null-keyword-link: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null
:language: csharp
2023-07-03 17:26:15 +02:00
include::../why-dotnet.adoc[]
2020-06-30 12:48:07 +02:00
2023-07-03 17:26:15 +02:00
==== Null forgiving operator
2020-06-30 12:48:07 +02:00
2023-07-03 17:26:15 +02:00
Expression marked with the https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-forgiving[null forgiving operator]
[source,csharp]
----
public void Method()
2020-06-30 12:48:07 +02:00
{
2023-07-03 17:26:15 +02:00
object o = null;
o!.ToString(); // Compliant: the null forgiving operator suppresses the nullable warning
2020-06-30 12:48:07 +02:00
}
----
2023-07-03 17:26:15 +02:00
include::../how-dotnet.adoc[]
2023-07-03 17:26:15 +02:00
include::../resources-dotnet.adoc[]
2023-07-03 17:26:15 +02:00
* Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null[null (C# Reference)]
* Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-forgiving[! (null-forgiving) operator (C# reference)]
2023-07-03 17:26:15 +02:00
include::../rspecator-dotnet.adoc[]