I want to develop C# with all possible warnings from Microsoft turned on, and I found this answer that says to add <Features>strict</Features>
to my .csproj
file.
However, before I start using it, I want to read up on what warnings it enables and other side effects it may have.
Unfortunately, I can't find any documentation on it whatsoever.
I assume it's in Microsoft's documentation somewhere, but I can't find it anywhere.
UPDATE: I found an article about this property with the following quote:
Note that this flag is not documented and not well-known.
Did Microsoft just never document this feature to begin with?
Thanks to everyone who helped by posting links to useful articles and documentations.
For now, I have settled on creating a file named Directory.Build.props
with the following content:
<Project>
<PropertyGroup>
<Features>strict</Features>
<WarningLevel>9999</WarningLevel>
</PropertyGroup>
</Project>
NOTE: For .NET Core,
WarningLevel
maxes out at4
. For .NET 5 and newer, it maxes out at9999
.
I will then copy and paste this file to the root directory of all my Solution files.
My goal was to have an easy way to enable all C# warnings for any project so I can code with confidence that I am not doing anything I'm not supposed to.
While I get most of my confidence from tests, each language has its own conventions and best practices which usually generate warnings when not followed, which was my motivation for enabling these features.
This approach should work with both Visual Studio Code and Visual Studio, and while I'm using the latest .NET SDK in my environment, it should work for all modern C# environments and any IDE as well.