From 55ceaf484856317c0d13653aaaea1e32f5bfac12 Mon Sep 17 00:00:00 2001 From: NeVeSpl Date: Tue, 28 Nov 2023 14:47:40 +0100 Subject: [PATCH] update docs --- README.md | 40 ++++++++++++++++++++++++++++++++-------- documentation/readme.nt | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 73f798b..f1607ff 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,8 @@ What **eNhancedEdition** has to offer, that is not available in the NetArchTest * [Getting started](#getting-started) * [Examples](#examples) * [Writing rules](#writing-rules) -* [Dependency search](#dependency-search) +* [Rules for dependency analysis](#rules-for-dependency-analysis) +* [Rules for assessing design and architectural principles](#rules-for-assessing-design-and-architectural-principles) * [Slices](#slices) * [Custom rules](#custom-rules) * [Options](#options) @@ -128,7 +129,7 @@ public class SampleApp_ModuleOmega_Tests The fluent API should direct you in building up a rule, based on a combination of [predicates](documentation/api.md#predicate), [conditions](documentation/api.md#condition) and conjunctions. -The starting point for any rule is the static [`Types`](documentation/api.md#types) class, where you load a set of types from a assembly, domain or patth. +The starting point for any rule is the static [`Types`](documentation/api.md#types) class, where you load a set of types from an assembly, domain or path. ```csharp var types = Types.InAssembly(typeof(MyClass).Assembly); @@ -144,9 +145,9 @@ types.That().ResideInNamespace("MyProject.Data").Should().BeSealed(); Finally, you obtain a result from the rule by using an executor, i.e. use `GetTypes()` to return the types that match the rule or `GetResult()` to determine whether the rule has been met. Note that `GetResult()` returns [`TestResult`](documentation/api.md#testresult) which contains a few lists of types: -- `LoadedTypes` - all types loded by `Types` -- `SelectedTypesForTesting` - types that passed predicates -- `FailingTypes`- types that failed to meet the conditions +- `LoadedTypes` - all types loded by [`Types`](documentation/api.md#types) +- `SelectedTypesForTesting` - types that passed [predicates](documentation/api.md#predicate) +- `FailingTypes`- types that failed to meet the [conditions](documentation/api.md#condition) ```csharp var result = types.That().ResideInNamespace("MyProject.Data").Should().BeSealed().GetResult(); @@ -155,7 +156,7 @@ var types = result.FailingTypes; ``` -## Dependency search +## Rules for dependency analysis Dependency matrix: @@ -171,7 +172,7 @@ Dependency matrix: | h | x | x | x | -Available rules: +#### Dependency search: | | Rule | number
of required
dependencies
from the list | type can have
a dependency
that is not
on the list | passing types | failing types | |---|---|---|---|---|---| @@ -185,13 +186,36 @@ Available rules: Explnation why a type fails dependecy search test is available on the failing type: [IType.Explanation](documentation/api.md#itypeexplanation) -### Reverse dependency search +#### Reverse dependency search | | Predicate | number
of required
dependencies
from the list | type can use
a type
that is not
on the list | passing types | failing types | |---|---|---|---|---|---| | R1 | [AreUsedByAny(c, d)](documentation/api.md#predicateareusedbyany) | at least 1 | yes | D2, D3 | D1 | | R1N | [AreNotUsedByAny(c, d)](documentation/api.md#predicatearenotusedbyany) | none | yes | D1 | D2, D3 | + +## Rules for assessing design and architectural principles + +#### BeImmutable + +A Type is considered as immutable when all its state (instance and static, fields, properties and events) cannot be changed after creation. Shallow immutability. + +#### BeImmutableExternally + +A Type is considered as externally immutable when its state (instance and static, fields, properties and events) with a public access modifier cannot be changed from the outside of the type. Shallow immutability. + +#### BeStateless + +A Type is considered as stateless when it does not have an instance state (fields, properties and events). + +#### HaveSourceFileNameMatchingName + +#### HaveSourceFilePathMatchingNamespace + +#### HaveMatchingTypeWithName + + + ## Slices ```csharp diff --git a/documentation/readme.nt b/documentation/readme.nt index 5e12326..ed951d8 100644 --- a/documentation/readme.nt +++ b/documentation/readme.nt @@ -41,7 +41,8 @@ What **eNhancedEdition** has to offer, that is not available in the NetArchTest * [Getting started](#getting-started) * [Examples](#examples) * [Writing rules](#writing-rules) -* [Dependency search](#dependency-search) +* [Rules for dependency analysis](#rules-for-dependency-analysis) +* [Rules for assessing design and architectural principles](#rules-for-assessing-design-and-architectural-principles) * [Slices](#slices) * [Custom rules](#custom-rules) * [Options](#options) @@ -79,7 +80,7 @@ The library is available as a package on NuGet: [NetArchTest.eNhancedEdition](ht The fluent API should direct you in building up a rule, based on a combination of [predicates](documentation/api.md#predicate), [conditions](documentation/api.md#condition) and conjunctions. -The starting point for any rule is the static [`Types`](documentation/api.md#types) class, where you load a set of types from a assembly, domain or patth. +The starting point for any rule is the static [`Types`](documentation/api.md#types) class, where you load a set of types from an assembly, domain or path. ```csharp var types = Types.InAssembly(typeof(MyClass).Assembly); @@ -95,9 +96,9 @@ types.That().ResideInNamespace("MyProject.Data").Should().BeSealed(); Finally, you obtain a result from the rule by using an executor, i.e. use `GetTypes()` to return the types that match the rule or `GetResult()` to determine whether the rule has been met. Note that `GetResult()` returns [`TestResult`](documentation/api.md#testresult) which contains a few lists of types: -- `LoadedTypes` - all types loded by `Types` -- `SelectedTypesForTesting` - types that passed predicates -- `FailingTypes`- types that failed to meet the conditions +- `LoadedTypes` - all types loded by [`Types`](documentation/api.md#types) +- `SelectedTypesForTesting` - types that passed [predicates](documentation/api.md#predicate) +- `FailingTypes`- types that failed to meet the [conditions](documentation/api.md#condition) ```csharp var result = types.That().ResideInNamespace("MyProject.Data").Should().BeSealed().GetResult(); @@ -106,7 +107,7 @@ var types = result.FailingTypes; ``` -## Dependency search +## Rules for dependency analysis Dependency matrix: @@ -122,7 +123,7 @@ Dependency matrix: | h | x | x | x | -Available rules: +#### Dependency search: | | Rule | number
of required
dependencies
from the list | type can have
a dependency
that is not
on the list | passing types | failing types | |---|---|---|---|---|---| @@ -136,13 +137,36 @@ Available rules: Explnation why a type fails dependecy search test is available on the failing type: [IType.Explanation](documentation/api.md#itypeexplanation) -### Reverse dependency search +#### Reverse dependency search | | Predicate | number
of required
dependencies
from the list | type can use
a type
that is not
on the list | passing types | failing types | |---|---|---|---|---|---| | R1 | [AreUsedByAny(c, d)](documentation/api.md#predicateareusedbyany) | at least 1 | yes | D2, D3 | D1 | | R1N | [AreNotUsedByAny(c, d)](documentation/api.md#predicatearenotusedbyany) | none | yes | D1 | D2, D3 | + +## Rules for assessing design and architectural principles + +#### BeImmutable + +A Type is considered as immutable when all its state (instance and static, fields, properties and events) cannot be changed after creation. Shallow immutability. + +#### BeImmutableExternally + +A Type is considered as externally immutable when its state (instance and static, fields, properties and events) with a public access modifier cannot be changed from the outside of the type. Shallow immutability. + +#### BeStateless + +A Type is considered as stateless when it does not have an instance state (fields, properties and events). + +#### HaveSourceFileNameMatchingName + +#### HaveSourceFilePathMatchingNamespace + +#### HaveMatchingTypeWithName + + + ## Slices ```csharp