rspec/rules/S2225/vbnet/rule.adoc

22 lines
668 B
Plaintext
Raw Normal View History

== Why is this an issue?
2023-06-13 16:11:53 +02:00
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`, as it breaks the method's implicit contract, and as a result the consumer's expectations.
2022-10-18 12:11:58 +02:00
2023-06-13 16:11:53 +02:00
[source,vbnet,diff-id=1,diff-type=noncompliant]
2022-10-18 12:11:58 +02:00
----
Public Overrides Function ToString() As String
2023-06-13 16:11:53 +02:00
Return Nothing ' Noncompliant
2022-10-18 12:11:58 +02:00
End Function
----
2023-06-13 16:11:53 +02:00
[source,vbnet,diff-id=1,diff-type=compliant]
2022-10-18 12:11:58 +02:00
----
Public Overrides Function ToString() As String
Return ""
End Function
----
2023-06-13 16:11:53 +02:00
include::../resources-dotnet.adoc[]
2022-10-18 12:11:58 +02:00
2023-06-13 16:11:53 +02:00
include::../rspecator.adoc[]