dotnet-library-checklist
dotnet-library-checklist copied to clipboard
Some ideas
That checklist is a great idea! Here are a few points I usually set in my own libraries/apps, some with retro-compatibility requirements, I mostly wonder if it could be useful outside of my context, so it's more an open discussion than an issue :)
- Enabling default code analyzers:
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
Rationale: you want to fix or document any warning.
- Explicit Lang Version:
<LangVersion>10</LangVersion>
Rationale: To avoid any conflict, and with latest version, you get extra help to modernize code.
- Restore Package with lock files:
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
Rationale: best explained here: https://devblogs.microsoft.com/nuget/enable-repeatable-package-restores-using-a-lock-file/
- Explicit Root Namespace:
<RootNamespace>FooBar</RootNamespace>
Rationale: to avoid an output rename that would conflict with existing code (more appropriate for exe than lib ?)
- Explicit value for EmbeddedResourceUseDependentUponConvention:
<EmbeddedResourceUseDependentUponConvention>true</EmbeddedResourceUseDependentUponConvention>
Rationale: needed for multitarget to .net framework when using resx.
- Explicit CheckForOverflowUnderflow in Debug
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
Rationale: default is false: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/language#checkforoverflowunderflow but still better safe than sorry, and add explicit bypass in code if needed
- Documentation File
<DocumentationFile>..\bin\$(Configuration)\FooBar.xml</DocumentationFile>
Rationale: boring but useful for libraries.
-Treat Warning as Error in Release
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Rationale: effective way to keep the count low.
- Add a .editorconfig, and set what is needed to keep a consistent style.
Thanks for the ideas! There is definitely a few I'll add!