Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduction of Qowaiv.Diagnostics.Contracts package.
- Loading branch information
Showing
29 changed files
with
161 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/Qowaiv.Data.SqlClient/Internals/Diagnostics/Contracts/FluentSyntaxAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Qowaiv.Data.SqlClient.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>To mark a method explicitly as impure. Methods decorated with | ||
/// this attribute return the same instance that was provided as argument. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class FluentSyntaxAttribute : ImpureAttribute { } |
6 changes: 6 additions & 0 deletions
6
src/Qowaiv.Data.SqlClient/Internals/Diagnostics/Contracts/ImpureAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Qowaiv.Data.SqlClient.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>To mark a method explicitly as impure.</summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class ImpureAttribute : Attribute { } |
10 changes: 10 additions & 0 deletions
10
src/Qowaiv.Data.SqlClient/Internals/Diagnostics/Contracts/InheritableAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Qowaiv.Data.SqlClient.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>Indicates the a class is designed to be inheritable.</summary> | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class InheritableAttribute : Attribute | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="InheritableAttribute"/> class.</summary> | ||
public InheritableAttribute(string? message = null) => _ = message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Qowaiv.Diagnostics.Contracts; | ||
|
||
/// <summary>Indicates the class is designed to be mutable.</summary> | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class MutableAttribute : Attribute { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
global using System; | ||
global using System.Diagnostics; | ||
global using System.Resources; |
16 changes: 16 additions & 0 deletions
16
src/Qowaiv.Diagnostics.Contracts/Qowaiv.Diagnostics.Contracts.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Import Project="..\..\props\package.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<Version>1.0.0</Version> | ||
<PackageId>Qowaiv.Diagnostics.Contracts</PackageId> | ||
<PackageReleaseNotes> | ||
v1.0.0 | ||
- Initial version. | ||
</PackageReleaseNotes> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Qowaiv Diagnostics Contracts | ||
This packages contains attributes to define (expected) behaviour on code. | ||
|
||
## 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](https://github.com/Qowaiv/qowaiv-analyzers/blob/main/rules/QW0003.md). | ||
|
||
### 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. | ||
|
||
## 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](https://github.com/Qowaiv/qowaiv-analyzers/blob/main/rules/QW0006.md). | ||
|
||
### 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](https://github.com/Qowaiv/qowaiv-analyzers/blob/main/rules/QW0011.md) | ||
and [QW0012](https://github.com/Qowaiv/qowaiv-analyzers/blob/main/rules/QW0012.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Qowaiv.Diagnostics.Contracts; | ||
|
||
/// <summary>Indicates the class will be sealed with the next major change.</summary> | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class WillBeSealedAttributee(string? message = null) : InheritableAttribute(message) { } |
8 changes: 8 additions & 0 deletions
8
src/Qowaiv.TestTools/Internals/Diagnostics/Contracts/FluentSyntaxAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Qowaiv.Testools.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>To mark a method explicitly as impure. Methods decorated with | ||
/// this attribute return the same instance that was provided as argument. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class FluentSyntaxAttribute : ImpureAttribute { } |
6 changes: 6 additions & 0 deletions
6
src/Qowaiv.TestTools/Internals/Diagnostics/Contracts/ImpureAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Qowaiv.Testools.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>To mark a method explicitly as impure.</summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class ImpureAttribute : Attribute { } |
10 changes: 10 additions & 0 deletions
10
src/Qowaiv.TestTools/Internals/Diagnostics/Contracts/InheritableAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Qowaiv.Testools.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>Indicates the a class is designed to be inheritable.</summary> | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class InheritableAttribute : Attribute | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="InheritableAttribute"/> class.</summary> | ||
public InheritableAttribute(string? message = null) => _ = message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/Qowaiv/Internals/Diagnostics/Contracts/CollectionMutationAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Qowaiv.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>To mark a method explicitly as impure. Methods decorated with | ||
/// this attribute return info about (like, removal or addition was successful). | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
internal sealed class CollectionMutationAttribute : ImpureAttribute { } |
8 changes: 8 additions & 0 deletions
8
src/Qowaiv/Internals/Diagnostics/Contracts/FluentSyntaxAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Qowaiv.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>To mark a method explicitly as impure. Methods decorated with | ||
/// this attribute return the same instance that was provided as argument. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class FluentSyntaxAttribute : ImpureAttribute { } |
6 changes: 6 additions & 0 deletions
6
src/Qowaiv/Internals/Diagnostics/Contracts/ImpureAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Qowaiv.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>To mark a method explicitly as impure.</summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class ImpureAttribute : Attribute { } |
10 changes: 10 additions & 0 deletions
10
src/Qowaiv/Internals/Diagnostics/Contracts/InheritableAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Qowaiv.Internals.Diagnostics.Contracts; | ||
|
||
/// <summary>Indicates the a class is designed to be inheritable.</summary> | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class InheritableAttribute : Attribute | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="InheritableAttribute"/> class.</summary> | ||
public InheritableAttribute(string? message = null) => _ = message; | ||
} |
2 changes: 1 addition & 1 deletion
2
...ostics/Contracts/WillBeSealedAttribute.cs → ...ostics/Contracts/WillBeSealedAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Qowaiv/Diagnostics/DebugDisplay.cs → ...aiv/Internals/Diagnostics/DebugDisplay.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters