rspec/rules/S6563/vbnet/rule.adoc

36 lines
790 B
Plaintext

include::../why-dotnet.adoc[]
include::../impact-dotnet.adoc[]
include::../how-dotnet.adoc[]
=== Code examples
==== Noncompliant code example
[source,vbnet,diff-id=1,diff-type=noncompliant]
----
Private Sub LogDateTime()
Using streamWriter = New StreamWriter("logs.txt", True)
End Using
streamWriter.WriteLine($"DateTime:{DateTime.Now.ToString("o")}") ' This log won't have any meaning if it's reconstructed in a machine in a different timezone.
End Sub
----
==== Compliant solution
[source,vbnet,diff-id=1,diff-type=compliant]
----
Private Sub LogDateTime()
Using streamWriter = New StreamWriter("logs.txt", True)
End Using
streamWriter.WriteLine($"DateTime:{DateTime.UtcNow.ToString("o")}")
End Sub
----
== Resources
include::../resources-dotnet.adoc[]