34 lines
753 B
Plaintext
34 lines
753 B
Plaintext
include::../why-dotnet.adoc[]
|
|
|
|
include::../impact-dotnet.adoc[]
|
|
|
|
include::../how-dotnet.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
void LogDateTime()
|
|
{
|
|
using var streamWriter = new StreamWriter("logs.txt", true);
|
|
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.
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
|
----
|
|
void LogDateTime()
|
|
{
|
|
using var streamWriter = new StreamWriter("logs.txt", true);
|
|
streamWriter.WriteLine($"DateTime:{DateTime.UtcNow.ToString("o")}");
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
include::../resources-dotnet.adoc[]
|