Nullable feature is now automatically enabled by default.
- For legacy frameworks (before NetCoreApp3.0/NetStandard2.1) warnings won't be raised:
<Nullable>Annotation</Nullable>
- While full activation is done only for recent frameworks (NetCoreApp3.0/NetStandard2.1 or more recent):
<Nullable>Enable</Nullable>
- And in all cases C# version is defined to use last version:
<LangVersion>Latest</LangVersion>
This are default values that are used if you do not override them in your csproj file. They have been chosen to match the most common use case which is multi-targeted projects that target recent frameworks that will produce the warnings and legacy frameworks that will just be annotated ignoring warnings related to the fact that the frameworks are not annotated.
This release adds support for .NET 5's MemberNotNullAttribute
and MemberNotNullWhenAttribute
.
This release fixes the XML documentation from the nullable attributes leaking into the automatically generated XML documentation file of consumers of the package (see issue #8).
Details:
For now, the attribute's XML documentation is wrapped in #if DEBUG
conditionals. This ensures that
the attribute's XML documentation doesn't appear in the documentation file of a release build while
still being available during development (e.g. for IntelliSense in Visual Studio).
This release provides solutions for issue #1 and
issue #6. In addition, potential compiler
warnings in the NullableAttributes.cs
file are now hidden.
Upgrading:
Remove any previously defined NULLABLE_ATTRIBUTES_EXCLUDE_FROM_CODE_COVERAGE
compiler constant,
as it does not have any effect anymore.
ℹ️ Note:
Builds will NOT break if the constant is still defined. It is simply ignored now.
Details:
- The package now supports
packages.config
via acontent/
folder in the NuGet package. - The attributes are now excluded from code coverage by default.
When referenced from projects targeting .NET Standard >= 2.0 or .NET Framework >= 4.0, the
ExcludeFromCodeCoverageAttribute
is used. For other project types, theDebuggerNonUserCodeAttribute
is used. - Added support for the
NULLABLE_ATTRIBUTES_INCLUDE_IN_CODE_COVERAGE
compiler constant which removes the code coverage attributes. - The
NULLABLE_ATTRIBUTES_EXCLUDE_FROM_CODE_COVERAGE
compiler constant no longer has any effects. Code coverage is now disabled by default. - The
NullableAttributes.cs
file now wraps the attributes with a#pragma warning disable
and#pragma warning restore
block to disable both compiler- and code-analysis warnings.
This release adds the // <auto-generated>
header to the NullableAttributes.cs
file so that
code analyzers like StyleCop ignore the file during the static code analysis.
Thanks to @skarllot for suggesting and making this change!
This release updates the package, so that the attributes file is no longer included in projects targeting a framework >= .NET Standard 2.1. For any target version below, the file is still automatically included. This ensures that the package can easily be installed in libraries which are multi-targeting different frameworks, without them having to define conditional compilation constants.
In addition, a small typo in the XML documentation was fixed.
The initial release.
This release covers the following attributes:
AllowNullAttribute
DisallowNullAttribute
DoesNotReturnAttribute
DoesNotReturnIfAttribute
MaybeNullAttribute
MaybeNullWhenAttribute
NotNullAttribute
NotNullIfNotNullAttribute
NotNullWhenAttribute
Furthermore, the following compiler directives are supported in the source file:
NULLABLE_ATTRIBUTES_DISABLE
NULLABLE_ATTRIBUTES_EXCLUDE_FROM_CODE_COVERAGE