Qowaiv.Diagnostics.Contracts
2.0.2
See the version list below for details.
dotnet add package Qowaiv.Diagnostics.Contracts --version 2.0.2
NuGet\Install-Package Qowaiv.Diagnostics.Contracts -Version 2.0.2
<PackageReference Include="Qowaiv.Diagnostics.Contracts" Version="2.0.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Qowaiv.Diagnostics.Contracts --version 2.0.2
#r "nuget: Qowaiv.Diagnostics.Contracts, 2.0.2"
// Install Qowaiv.Diagnostics.Contracts as a Cake Addin #addin nuget:?package=Qowaiv.Diagnostics.Contracts&version=2.0.2 // Install Qowaiv.Diagnostics.Contracts as a Cake Tool #tool nuget:?package=Qowaiv.Diagnostics.Contracts&version=2.0.2
Qowaiv Diagnostics Contracts
This packages contains attributes to define (expected) behavior on code.
Most likely, you only need this dependency compile time. In that case you should add the dependency as follows:
<ItemGroup>
<PackageReference
Include="Qowaiv.Diagnostics.Contracts"
Version="*"
PrivateAssets=""all" />
<ItemGroup>
To embed the result of these decorations in the compiled assembly, the DEFINE
constant CONTRACTS_FULL
has to be set.
<PropertyGroup>
<DefineConstants>CONTRACTS_FULL</DefineConstants>
</PropertyGroup>
If you only use these decorations to enable static code analysis, this constant is not needed.
Impure attribute
Opposed to the [Pure]
attribute, the [Impure]
attribute indicates that a
method has side effects. This attribute can help working with static code
analyzer rule: QW0003.
Collection mutation attribute
An attribute that inherits from [Impure]
to indicate that the collection
changes due to this method call.
Fluent syntax mutation attribute
An attribute that inherits from [Impure]
to indicate that the returned
instance is equal to self or of the parameters, just to allow a fluent syntax.
Empty type attributes
Empty types (classes, enums, interfaces, structs) are generally seen as a bad practice, or assumed to be unfinished code. Decorating them with an attribute that explains the reason why the type is empty (for test cases for example) can help:
[EmptyClass(Justification = "")]
[EmptyEnum(Justification = "")]
[EmptyInterface(Justification = "")]
[EmptyStruct(Justification = "")]
[EmptyTestClass]
[EmptyTestEnum]
[EmptyTestInterface]
[EmptyTestStruct]
Inheritable attribute
The [Inheritable]
attribute indicates that a class is designed to be
inheritable although no virtual or protected members have been defined.
This attribute can help working with static code analyzer rule: QW0006.
Will be sealed attribute
An attribute that inherits from [Inheritable]
that indicates that the
decorated member will be sealed in the future, and that overrides are considered
obsolete code.
Mutable attribute
Indicates that a class, record, interface or struct is mutable by design. This attribute can help working with static code analyzer rules: QW0011 and QW0012.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v2.0.2
- Fix ambiguous reference issue if consuming project defines types with overlapping names.
- Fix support for C# language version 9 and lower.
v2.0.1
- Fix NuGet version not actually generating source code.
v2.0.0
- Convert to source generator. #418
v1.0.0
- Initial version.