Skip to content

Commit 134f70d

Browse files
committed
update readme
1 parent e24f466 commit 134f70d

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,32 @@ var types = result.FailingTypes;
8080

8181
## Slices
8282

83+
```csharp
84+
var result = Types.InAssembly(typeof(ExampleDependency).Assembly)
85+
.Slice()
86+
.ByNamespacePrefix("MyApp.Features")
87+
.Should()
88+
.NotHaveDependenciesBetweenSlices()
89+
.GetResult();
90+
91+
```
92+
93+
There is only one way, at least for now, to divide types into slices `ByNamespacePrefix(string prefix)` and it works as follows:
94+
95+
1) Selects types which namespace starts with a given prefix, rest of the types are ignored.
96+
2) Slices are defined by the first part of the namespace that comes right after the prefix:
97+
`namespacePrefix.(sliceName).restOfNamespace`
98+
3) Types with the same `sliceName` part will be placed in the same slice. If `sliceName` is empty for a given type, the type will be also ignored (`BaseFeature` class from folowing image)
99+
100+
![Slices](docs/slices.png)
101+
102+
When we already have our types divided into slices, we can apply only one available right now condition: `NotHaveDependenciesBetweenSlices()`. As the name suggest it detects if any dependencies exist between slices. Any dependency from slice to type that is not part of any other slice is allowed.
103+
104+
allowed | not allowed
105+
--|---
106+
![Slices](docs/slices.ok.png)|![Slices](docs/slices.not.png)
107+
108+
83109
## Custom rules
84110

85111
You can extend the library by writing custom rules that implement the `ICustomRule` interface. These can be applied as both predicates and conditions using a `MeetsCustomRule()` method, e.g.

docs/slices.not.png

7.78 KB
Loading

docs/slices.ok.png

7.12 KB
Loading

docs/slices.png

6.54 KB
Loading

0 commit comments

Comments
 (0)