Skip to content

Commit 1b57d9d

Browse files
docs: add documentation for async function limitations in release builds
1 parent 5506ac5 commit 1b57d9d

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

ExampleTest/LimitationsOnReleaseTest.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
using System.Linq;
2+
using System.Threading.Tasks;
23
using ArchUnitNET.Domain;
34
using ArchUnitNET.Domain.Extensions;
45
using ArchUnitNET.Loader;
6+
using ArchUnitNET.xUnit;
57
using Xunit;
8+
using static ArchUnitNET.Fluent.ArchRuleDefinition;
69

710
namespace ExampleTest
811
{
@@ -61,6 +64,15 @@ public void TypeOfDependencyTest()
6164

6265
Assert.Contains(_missingDependencyClass, methodWithTypeOfDependencyDependencies);
6366
}
67+
68+
[Fact]
69+
public void AsyncMethodDependencyTest()
70+
{
71+
Classes().That().Are(typeof(AsyncUser))
72+
.Should()
73+
.CallAny(MethodMembers().That().HaveName("MethodAsync()"))
74+
.Check(Architecture);
75+
}
6476
}
6577

6678
#pragma warning disable 219
@@ -85,5 +97,23 @@ public void MethodWithNullVariable()
8597
internal class MissingDependencyClass { }
8698

8799
internal class SubClass : MissingDependencyClass { }
100+
101+
internal class AsyncService
102+
{
103+
public async Task MethodAsync()
104+
{
105+
await Task.Delay(100);
106+
}
107+
}
108+
109+
internal class AsyncUser
110+
{
111+
private readonly AsyncService _asyncService = new AsyncService();
112+
113+
public async Task UseAsyncService()
114+
{
115+
await _asyncService.MethodAsync();
116+
}
117+
}
88118
}
89119
#pragma warning restore 219

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ namespace ExampleTest
113113
}
114114
```
115115

116+
#### Run the tests
117+
118+
Since ArchUnitNET is reading the architecture form the analyzed binaries, it is recommended to run ArchUnitNET-based tests in Debug configuration.
119+
120+
```
121+
dotnet test -c Debug
122+
```
123+
124+
For more details on known edge cases, see [the documentation](https://archunitnet.readthedocs.io/en/stable/limitations/debug_artifacts/).
125+
116126
#### Further Info and Help
117127

118128
Check out test examples for the current release at

documentation/docs/limitations/debug_artifacts.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
ArchUnitNET gathers information about the architecture from analyzing
33
binaries, therefore running tests with the Release option (`dotnet test -c Release`) instead of the Debug
44
option (`dotnet test -c Debug`) can lead to not finding dependencies you normally would expect to find.
5-
The edge cases we found so far are not initializing a local variable, casting an object and using
6-
the typeof() statement. A minimal example for each edge case can be found [here](https://github.com/TNG/ArchUnitNET/blob/master/ExampleTest/LimitationsOnReleaseTest.cs).
5+
The edge cases we found so far are not initializing a local variable, casting an object, using
6+
the typeof() statement and checking that an async function is called.
7+
A minimal example for each edge case can be found [here](https://github.com/TNG/ArchUnitNET/blob/master/ExampleTest/LimitationsOnReleaseTest.cs).
78

89

910
If you come across another edge case, where executing tests in Debug mode leads to different results than executing

0 commit comments

Comments
 (0)