diff --git a/C#-and-.NET-docs-supplement.md b/C#-and-.NET-docs-supplement.md index 0beff3c..ef3ab99 100644 --- a/C#-and-.NET-docs-supplement.md +++ b/C#-and-.NET-docs-supplement.md @@ -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).