Qowaiv.Diagnostics.Contracts 2.0.3

dotnet add package Qowaiv.Diagnostics.Contracts --version 2.0.3                
NuGet\Install-Package Qowaiv.Diagnostics.Contracts -Version 2.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Qowaiv.Diagnostics.Contracts" Version="2.0.3">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Qowaiv.Diagnostics.Contracts --version 2.0.3                
#r "nuget: Qowaiv.Diagnostics.Contracts, 2.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Qowaiv.Diagnostics.Contracts as a Cake Addin
#addin nuget:?package=Qowaiv.Diagnostics.Contracts&version=2.0.3

// Install Qowaiv.Diagnostics.Contracts as a Cake Tool
#tool nuget:?package=Qowaiv.Diagnostics.Contracts&version=2.0.3                

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.

There are no supported framework assets in this package.

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.

Version Downloads Last updated
2.0.3 241 11/15/2024
2.0.2 1,138 10/24/2024
2.0.1 1,515 10/10/2024
2.0.0 118 10/10/2024
1.0.0 9,206 6/28/2024
1.0.0-rc.1 59 6/27/2024

v2.0.3
- Generate with #pragma warning disable headers.
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.