Warning on lower case type names in C# 11

C# 11 is the next version of C# coming in .NET 7, and it is introducing a warning wave that issues a warning when a type is declared with all lower-case letters. This is being done so that in the future the language can begin moving away from conditional keywords and instead use full on keywords instead. The warning is alerting customers to types that may become keywords in future versions.

Exploring borrowed annotations in C#

One request I see fairly often for C# is to add the concept of borrowed values. That is values which can be used but not stored beyond the invocation of a particular method. This generally comes up in the context of features which require a form of ownership semantics like stack allocation of classes, using statements, resource management, etc … Borrowing provides a way to safely use owned values without complicated ownership transfer.

string vs. String is not a style debate

Often I see developers debating using String vs. string as if it’s a simple style decision. No different than discussing the position of braces, tabs vs. spaces, etc … A meaningless distinction where there is no right answer, just finding a decision everyone can agree on. The debate between String and string though is not a simple style debate, instead it has the potential to radically change the semantics of a program.

Is making a struct readonly a breaking change?

C# 7.2 added the ability to mark a struct declaration as readonly. This has the effect of guaranteeing that no member of the struct can mutate its contents as it ensures every field is marked as readonly. This guarantee is imporant because it allows the compiler to avoid defensive copies of struct values in cases where the underlying location is considered readonly. For example when invoking members of a struct which is stored in a readonly field.

Profilers and impossible exceptions

At first glance some customer crash reports look simply impossible. The code in question is so throughly tested or on such a common code path that it simply can’t be broken. If it were broken customers would be breaking your inbox with crash reports.