22 lines
672 B
Plaintext
22 lines
672 B
Plaintext
== Why is this an issue?
|
|
|
|
Calling https://learn.microsoft.com/en-us/dotnet/api/system.object.tostring[ToString()] on an object should always return a `string`. Thus, overriding the ToString method should never return `Nothing` because it breaks the method's implicit contract, and as a result the consumer's expectations.
|
|
|
|
[source,vbnet,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
Public Overrides Function ToString() As String
|
|
Return Nothing ' Noncompliant
|
|
End Function
|
|
----
|
|
|
|
[source,vbnet,diff-id=1,diff-type=compliant]
|
|
----
|
|
Public Overrides Function ToString() As String
|
|
Return ""
|
|
End Function
|
|
----
|
|
|
|
include::../resources-dotnet.adoc[]
|
|
|
|
include::../rspecator.adoc[]
|