Skip to content

Commit ccdff05

Browse files
committed
update docs
1 parent 39b75c5 commit ccdff05

File tree

3 files changed

+74
-8
lines changed

3 files changed

+74
-8
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ What **eNhancedEdition** has to offer, that is not available in the NetArchTest
3030
- BenMorris/NetArchTest#126 - added rules for structs, enums and delegates
3131
- BenMorris/NetArchTest#131 - added rules for all access modifiers: public, internal, private, protected, private protected, protected internal
3232
- BenMorris/NetArchTest#133 - added rules: AreInheritedByAnyType, AreNotInheritedByAnyType
33+
- added rules : AreUsedByAny, AreNotUsedByAny
3334

3435

3536
## Index
@@ -140,7 +141,13 @@ Once the set of types have been filtered, you can apply a set of conditions usi
140141
```csharp
141142
types.That().ResideInNamespace("MyProject.Data").Should().BeSealed();
142143
```
143-
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 the result will also return a list of types that failed to meet the conditions.
144+
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.
145+
146+
Note that `GetResult()` returns [`TestResult`](documentation/api.md#testresult) which contains a few lists of types:
147+
- `LoadedTypes` - all types loded by `Types`
148+
- `SelectedTypesForTesting` - types that passed predicates
149+
- `FailingTypes`- types that failed to meet the conditions
150+
144151
```csharp
145152
var result = types.That().ResideInNamespace("MyProject.Data").Should().BeSealed().GetResult();
146153
var isValid = result.IsSuccessful;
@@ -164,9 +171,9 @@ Dependency matrix:
164171
| h | x | x | x |
165172

166173

167-
Available predicates/conditions:
174+
Available rules:
168175

169-
| | Predicate | number<br> of required<br> dependencies <br>from the list | type can have<br>a dependency<br>that is not<br>on the list | passing types | failing types |
176+
| | Rule | number<br> of required<br> dependencies <br>from the list | type can have<br>a dependency<br>that is not<br>on the list | passing types | failing types |
170177
|---|---|---|---|---|---|
171178
| 1 | [HaveDependencyOnAny(D1, D2)](documentation/api.md#conditionhavedependencyonany) | at least 1 | yes | c, d, e, f, g, h, | a, b |
172179
| 2 | [HaveDependencyOnAll(D1, D2)](documentation/api.md#conditionhavedependencyonall) | all | yes | g, h | a, b, c, d, e, f |
@@ -177,6 +184,14 @@ Available predicates/conditions:
177184

178185
Explnation why a type fails dependecy search test is available on the failing type: [IType.Explanation](documentation/api.md#itypeexplanation)
179186

187+
188+
### Reverse dependency search
189+
190+
| | Predicate | number<br> of required<br> dependencies <br>from the list | type can use<br>a type<br>that is not<br>on the list | passing types | failing types |
191+
|---|---|---|---|---|---|
192+
| R1 | [AreUsedByAny(c, d)](documentation/api.md#predicateareusedbyany) | at least 1 | yes | D2, D3 | D1 |
193+
| R1N | [AreNotUsedByAny(c, d)](documentation/api.md#predicatearenotusedbyany) | none | yes | D1 | D2, D3 |
194+
180195
## Slices
181196

182197
```csharp

documentation/api.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
* [AreNotSealed](#PredicateAreNotSealed)
4545
* [AreNotStatic](#PredicateAreNotStatic)
4646
* [AreNotStructures](#PredicateAreNotStructures)
47+
* [AreNotUsedByAny](#PredicateAreNotUsedByAny)
4748
* [AreOfType](#PredicateAreOfType)
4849
* [ArePrivate](#PredicateArePrivate)
4950
* [ArePrivateProtected](#PredicateArePrivateProtected)
@@ -54,6 +55,7 @@
5455
* [AreStateless](#PredicateAreStateless)
5556
* [AreStatic](#PredicateAreStatic)
5657
* [AreStructures](#PredicateAreStructures)
58+
* [AreUsedByAny](#PredicateAreUsedByAny)
5759
* [DoNotHaveCustomAttribute](#PredicateDoNotHaveCustomAttribute)
5860
* [DoNotHaveCustomAttribute<T>](#PredicateDoNotHaveCustomAttribute)
5961
* [DoNotHaveCustomAttributeOrInherit](#PredicateDoNotHaveCustomAttributeOrInherit)
@@ -130,6 +132,7 @@
130132
* [BeStateless](#ConditionBeStateless)
131133
* [BeStatic](#ConditionBeStatic)
132134
* [BeStructures](#ConditionBeStructures)
135+
* [BeUsedByAny](#ConditionBeUsedByAny)
133136
* [HaveCustomAttribute](#ConditionHaveCustomAttribute)
134137
* [HaveCustomAttribute<T>](#ConditionHaveCustomAttribute)
135138
* [HaveCustomAttributeOrInherit](#ConditionHaveCustomAttributeOrInherit)
@@ -168,6 +171,7 @@
168171
* [NotBeSealed](#ConditionNotBeSealed)
169172
* [NotBeStatic](#ConditionNotBeStatic)
170173
* [NotBeStructures](#ConditionNotBeStructures)
174+
* [NotBeUsedByAny](#ConditionNotBeUsedByAny)
171175
* [NotHaveCustomAttribute](#ConditionNotHaveCustomAttribute)
172176
* [NotHaveCustomAttribute<T>](#ConditionNotHaveCustomAttribute)
173177
* [NotHaveCustomAttributeOrInherit](#ConditionNotHaveCustomAttributeOrInherit)
@@ -205,6 +209,8 @@
205209

206210
* [FailingTypes](#TestResultFailingTypes)
207211
* [IsSuccessful](#TestResultIsSuccessful)
212+
* [LoadedTypes](#TestResultLoadedTypes)
213+
* [SelectedTypesForTesting](#TestResultSelectedTypesForTesting)
208214

209215
## IType
210216

@@ -421,6 +427,11 @@ Selects types that are not static.
421427
PredicateList Predicate.AreNotStructures()
422428
```
423429
Selects types that are not structures.
430+
### Predicate.AreNotUsedByAny
431+
```csharp
432+
PredicateList Predicate.AreNotUsedByAny(params string[] users)
433+
```
434+
Selects types that are not used by any of the supplied types.
424435
### Predicate.AreOfType
425436
```csharp
426437
PredicateList Predicate.AreOfType(params Type[] type)
@@ -471,6 +482,11 @@ Selects types that are static.
471482
PredicateList Predicate.AreStructures()
472483
```
473484
Selects types that are structures.
485+
### Predicate.AreUsedByAny
486+
```csharp
487+
PredicateList Predicate.AreUsedByAny(params string[] users)
488+
```
489+
Selects types that are used by any of the supplied types.
474490
### Predicate.DoNotHaveCustomAttribute
475491
```csharp
476492
PredicateList Predicate.DoNotHaveCustomAttribute(Type attribute)
@@ -825,6 +841,11 @@ Selects types that are static.
825841
ConditionList Condition.BeStructures()
826842
```
827843
Selects types that are structures.
844+
### Condition.BeUsedByAny
845+
```csharp
846+
ConditionList Condition.BeUsedByAny(params string[] users)
847+
```
848+
Selects types that are used by any of the supplied types.
828849
### Condition.HaveCustomAttribute
829850
```csharp
830851
ConditionList Condition.HaveCustomAttribute(Type attribute)
@@ -922,12 +943,12 @@ ConditionList Condition.Inherit<T>()
922943
Selects types that inherit a particular type.
923944
### Condition.MeetCustomRule
924945
```csharp
925-
ConditionList Condition.MeetCustomRule(Func<TypeDefinition, bool> rule)
946+
ConditionList Condition.MeetCustomRule(ICustomRule rule)
926947
```
927948
Selects types that meet a custom rule.
928949
### Condition.MeetCustomRule
929950
```csharp
930-
ConditionList Condition.MeetCustomRule(ICustomRule rule)
951+
ConditionList Condition.MeetCustomRule(Func<TypeDefinition, bool> rule)
931952
```
932953
Selects types that meet a custom rule.
933954
### Condition.NotBeAbstract
@@ -1015,6 +1036,11 @@ Selects types that are not static.
10151036
ConditionList Condition.NotBeStructures()
10161037
```
10171038
Selects types that are not structures.
1039+
### Condition.NotBeUsedByAny
1040+
```csharp
1041+
ConditionList Condition.NotBeUsedByAny(params string[] users)
1042+
```
1043+
Selects types that are not used by any of the particular types.
10181044
### Condition.NotHaveCustomAttribute
10191045
```csharp
10201046
ConditionList Condition.NotHaveCustomAttribute(Type attribute)
@@ -1174,6 +1200,16 @@ Gets a list of the types that failed the test.
11741200
IsSuccessful
11751201
```
11761202
Gets a flag indicating the success or failure of the test.
1203+
### TestResult.LoadedTypes
1204+
```csharp
1205+
LoadedTypes
1206+
```
1207+
Gets a list of all the types that were loded by <see cref="T:NetArchTest.Rules.Types"/>.
1208+
### TestResult.SelectedTypesForTesting
1209+
```csharp
1210+
SelectedTypesForTesting
1211+
```
1212+
Gets a list of the types that passed filtering by predicates and were used as input to conditions.
11771213

11781214
## IType
11791215
### IType.Explanation

documentation/readme.nt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ What **eNhancedEdition** has to offer, that is not available in the NetArchTest
3333
- BenMorris/NetArchTest#126 - added rules for structs, enums and delegates
3434
- BenMorris/NetArchTest#131 - added rules for all access modifiers: public, internal, private, protected, private protected, protected internal
3535
- BenMorris/NetArchTest#133 - added rules: AreInheritedByAnyType, AreNotInheritedByAnyType
36+
- added rules : AreUsedByAny, AreNotUsedByAny
3637

3738

3839
## Index
@@ -91,7 +92,13 @@ Once the set of types have been filtered, you can apply a set of conditions usi
9192
```csharp
9293
types.That().ResideInNamespace("MyProject.Data").Should().BeSealed();
9394
```
94-
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 the result will also return a list of types that failed to meet the conditions.
95+
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.
96+
97+
Note that `GetResult()` returns [`TestResult`](documentation/api.md#testresult) which contains a few lists of types:
98+
- `LoadedTypes` - all types loded by `Types`
99+
- `SelectedTypesForTesting` - types that passed predicates
100+
- `FailingTypes`- types that failed to meet the conditions
101+
95102
```csharp
96103
var result = types.That().ResideInNamespace("MyProject.Data").Should().BeSealed().GetResult();
97104
var isValid = result.IsSuccessful;
@@ -115,9 +122,9 @@ Dependency matrix:
115122
| h | x | x | x |
116123

117124

118-
Available predicates/conditions:
125+
Available rules:
119126

120-
| | Predicate | number<br> of required<br> dependencies <br>from the list | type can have<br>a dependency<br>that is not<br>on the list | passing types | failing types |
127+
| | Rule | number<br> of required<br> dependencies <br>from the list | type can have<br>a dependency<br>that is not<br>on the list | passing types | failing types |
121128
|---|---|---|---|---|---|
122129
| 1 | [HaveDependencyOnAny(D1, D2)](documentation/api.md#conditionhavedependencyonany) | at least 1 | yes | c, d, e, f, g, h, | a, b |
123130
| 2 | [HaveDependencyOnAll(D1, D2)](documentation/api.md#conditionhavedependencyonall) | all | yes | g, h | a, b, c, d, e, f |
@@ -128,6 +135,14 @@ Available predicates/conditions:
128135

129136
Explnation why a type fails dependecy search test is available on the failing type: [IType.Explanation](documentation/api.md#itypeexplanation)
130137

138+
139+
### Reverse dependency search
140+
141+
| | Predicate | number<br> of required<br> dependencies <br>from the list | type can use<br>a type<br>that is not<br>on the list | passing types | failing types |
142+
|---|---|---|---|---|---|
143+
| R1 | [AreUsedByAny(c, d)](documentation/api.md#predicateareusedbyany) | at least 1 | yes | D2, D3 | D1 |
144+
| R1N | [AreNotUsedByAny(c, d)](documentation/api.md#predicatearenotusedbyany) | none | yes | D1 | D2, D3 |
145+
131146
## Slices
132147

133148
```csharp

0 commit comments

Comments
 (0)