Add VB snippets
This commit is contained in:
parent
9f0d07611e
commit
d3f9afa35d
18
rules/S6664/vbnet/compliant.adoc
Normal file
18
rules/S6664/vbnet/compliant.adoc
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
[source,vbnet,diff-id=1,diff-type=compliant]
|
||||||
|
----
|
||||||
|
Private Sub MyMethod(ByVal items As List(Of MyObject))
|
||||||
|
For Each item In items
|
||||||
|
logger.Debug("Evaluating: {name} which is {availability}", item.Name, If(item.IsAvailable, "available", "not available"))
|
||||||
|
Try
|
||||||
|
If item.IsAvailable Then
|
||||||
|
' Do stuff
|
||||||
|
Else
|
||||||
|
' Do other stuff
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
logger.Error(ex, "Ops! Something happened: ")
|
||||||
|
End Try
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
----
|
22
rules/S6664/vbnet/noncompliant.adoc
Normal file
22
rules/S6664/vbnet/noncompliant.adoc
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
[source,vbnet,diff-id=1,diff-type=compliant]
|
||||||
|
----
|
||||||
|
Private Sub MyMethod(ByVal items As List(Of MyObject))
|
||||||
|
logger.Debug("The operation started")
|
||||||
|
For Each item In items
|
||||||
|
Try
|
||||||
|
If item.IsAvailable Then
|
||||||
|
' Do stuff
|
||||||
|
logger.Debug($"{item.Name} is available")
|
||||||
|
Else
|
||||||
|
logger.Debug($"{item.Name} is not available")
|
||||||
|
' Do other stuff
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
logger.Error("Ops! Something happened")
|
||||||
|
logger.Error(ex.Message)
|
||||||
|
End Try
|
||||||
|
Next
|
||||||
|
logger.Debug("The operation ended")
|
||||||
|
End Sub
|
||||||
|
----
|
Loading…
x
Reference in New Issue
Block a user