From 1081c3ddb02d55ba528267f75c0144a6f4fc9a59 Mon Sep 17 00:00:00 2001 From: James Groom Date: Thu, 28 Dec 2023 10:20:44 +1000 Subject: [PATCH] Updated C# and .NET docs supplement (markdown) --- C#-and-.NET-docs-supplement.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/C#-and-.NET-docs-supplement.md b/C#-and-.NET-docs-supplement.md index 3a45444..efdc07f 100644 --- a/C#-and-.NET-docs-supplement.md +++ b/C#-and-.NET-docs-supplement.md @@ -31,7 +31,7 @@ You can only have 1 `default` branch, but `case _ when ...:` doesn't work. Howev ## MSBuild `Condition` placement -On (older versions of?) VS, `Condition` is ignored if placed on a property. Create a new ``. +On (older versions of?) VS, `Condition` is ignored if placed on a property/item. Create a new ``. ## MSBuild property evaluation execution order @@ -49,6 +49,13 @@ Use `MSBuildProjectDirectory`. Note that the latter doesn't include a trailing s .NET will happily include NUL (`(char) 0`) in a string if you use `String..ctor(char[])`. WinForms' `Label.Text` stops reading at the first NUL for measurement/rendering, at least under Mono. +## Preprocessor TFM constants and .NET Standard + +The table [here](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#conditional-compilation) is good for reference, but mind the note hidden at the bottom: +> The `NETSTANDARD__OR_GREATER` symbols are only defined for .NET Standard targets, and not for targets that implement .NET Standard [...] + +That is, you must use `#if !(NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER)` and not just `#if !NETSTANDARD2_1_OR_GREATER`. + ## `String.GetHashCode` stability The `GetHashCode` implementation for strings does not reflect the string's contents, and as such, the hash not stable between program instances.