19 lines
624 B
Plaintext
19 lines
624 B
Plaintext
[source,vbnet]
|
|
----
|
|
Public NotInheritable Class NotNullAttribute ' The alternative name 'ValidatedNotNullAttribute' is also supported
|
|
Inherits Attribute
|
|
End Class
|
|
|
|
Public Module Guard
|
|
Public Sub CheckNotNull(Of T)(<NotNull> Value As T, Name As String)
|
|
If Value Is Nothing Then Throw New ArgumentNullException(Name)
|
|
End Sub
|
|
End Module
|
|
|
|
Public Module Utils
|
|
Public Function Normalize(Value As String) As String
|
|
CheckNotNull(Value, nameof(Value)) ' Will throw if 'Value' is Nothing
|
|
Return Value.ToUpper() ' Compliant: value is known to be not Nothing here
|
|
End Function
|
|
End Module
|
|
---- |