TIL: C# has a `strict` option. A csproj file specifying <Features>strict</Features>
Next thing you know, it'll have an Explicit and On Error feature option too.
So I had a look at all the neat things this flag does. First, without the flag, this does not emit any error at all.

lock (null)
{
}

with strict, this no longer compiles. (1/n tweets)
Currently C# lets you use is/as against a static class. Strict prevents it. This compiles without the flag. (2/n)

static class Foo {
static void Bar(object baz) {
if (baz is Foo) {
}
}
}
C# without "strict" will let you do a null check against Guid or IntPtr even though they're structs and not emit a warning. With the strict feature, it emits a warning like other struct types. (3/n)

Guid baz = Guid.NewGuid();
if (baz == null) { // Produces warning with strict
}
Strict prevents this from compiling, which compiles with no errors or warnings by default.

enum Cat { Fuchsia, White }
static void Bar() {
var foo = 1 - Cat.Fuchsia;
Console.WriteLine(foo);
}
C# lets you pass arguments to a delegate's constructor by ref. `strict` prevents that from compiling. (5/n)

var v = new Func<string, string>(x => x);
var y = new Func<string, string>(ref v); //Does not compile with Strict
FOR THE RECORD, the Roslyn (C#) team does _not_ "support" this flag. I do not recommend you shove it in all your project files now. I just find it interesting that they _have_ fixed several bugs, and have the fixes gated behind something unsupported.
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Kevin Jones🏒🏳️‍🌈
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member and get exclusive features!

Premium member ($3.00/month or $30.00/year)

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!