Updated C# and .NET docs supplement (markdown)

James Groom 2024-06-19 18:43:52 +10:00
parent 00fa29a2c7
commit 2f802a7d64
1 changed files with 6 additions and 0 deletions

@ -87,6 +87,12 @@ It seems that `Guid`'s implementation *is* stable across instances, and even acr
Notice also the default window icon (`Form.Icon`): on Windows, it's a distinct icon; on Mono (not shown in the screenshot), it resembles `SystemIcon.Application`. From 2.9, EmuHawk overrides the default to the logo.
## `[ThreadStatic]` field initialisation
Per [docs](https://learn.microsoft.com/en-us/dotnet/api/system.threadstaticattribute?view=netstandard-2.0#remarks) ([simpler](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2019#rule-description)), static fields initialisation is moved to the static constructor in IL, which runs on at most 1 thread, so a `[ThreadStatic]` field will be `default` on all other threads if initialised in the usual way.
Incorrect usage in BizHawk *should* be flagged with CA2019, but apparently it's not working in CI.
## Type casting
There are two types of casts in C#: the C-style `(T) o` throws if the object is not of the desired type, whereas `o as T` evaluates to `null` if it's not of the desired type. There's no '?' in this `null`-producing operator (this is probably only confusing if you use Kotlin).