rspec/rules/S4586/vbnet/rule.adoc

18 lines
476 B
Plaintext
Raw Normal View History

2020-12-23 14:59:06 +01:00
Returning ``Nothing`` from a non-``async`` ``Task``/``Task(Of T)`` method will cause a ``NullReferenceException`` at runtime. This problem can be avoided by returning ``Task.FromResult(Of T)(Nothing)`` instead.
2020-06-30 12:49:37 +02:00
== Noncompliant Code Example
----
Public Function GetFooAsync() As Task(Of Object)
Return Nothing
End Function
----
== Compliant Solution
----
Public Function GetFooAsync() As Task(Of Object)
Return Task.FromResult(Of Object)(Nothing)
End Function
----