
Update rule content and descriptions to LaYC format. https://sonarsource.github.io/rspec/#/rspec/S4586 ## Review A dedicated reviewer checked the rule description successfully for: - [ ] logical errors and incorrect information - [ ] information gaps and missing content - [ ] text style and tone - [ ] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
48 lines
1.2 KiB
Plaintext
48 lines
1.2 KiB
Plaintext
:keyword_null: Nothing
|
|
:keyword_async: Async
|
|
:concept_method: procedure
|
|
:typeparameter_TResult: (Of TResult)
|
|
|
|
== Why is this an issue?
|
|
|
|
include::../why-dotnet.adoc[]
|
|
|
|
[source,vbnet,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
Public Function DoFooAsync() As Task
|
|
Return Nothing ' Noncompliant: Causes a NullReferenceException if awaited.
|
|
End Function
|
|
|
|
Public Async Function Main() As Task
|
|
Await DoFooAsync() ' NullReferenceException
|
|
End Function
|
|
----
|
|
|
|
[source,vbnet,diff-id=1,diff-type=compliant]
|
|
----
|
|
Public Function DoFooAsync() As Task
|
|
Return Task.CompletedTask ' Compliant: Method can be awaited.
|
|
End Function
|
|
|
|
Public Async Function Main() As Task
|
|
Await DoFooAsync()
|
|
End Function
|
|
----
|
|
|
|
[source,vbnet,diff-id=2,diff-type=noncompliant]
|
|
----
|
|
Public Function GetFooAsync() As Task(Of Object)
|
|
Return Nothing ' Noncompliant: Causes a NullReferenceException if awaited.
|
|
End Function
|
|
----
|
|
|
|
[source,vbnet,diff-id=2,diff-type=compliant]
|
|
----
|
|
Public Function GetFooAsync() As Task(Of Object)
|
|
Return Task.FromResult(Of Object)(Nothing) ' Compliant: Method can be awaited.
|
|
End Function
|
|
----
|
|
|
|
include::../resources.adoc[]
|
|
|
|
include::../rspecator.adoc[] |