Skip to content

Add Documentation for Async Function Limitations in Release Builds #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions ExampleTest/LimitationsOnReleaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Linq;
using System.Threading.Tasks;
using ArchUnitNET.Domain;
using ArchUnitNET.Domain.Extensions;
using ArchUnitNET.Loader;
using ArchUnitNET.xUnit;
using Xunit;
using static ArchUnitNET.Fluent.ArchRuleDefinition;

namespace ExampleTest
{
Expand Down Expand Up @@ -61,6 +64,17 @@ public void TypeOfDependencyTest()

Assert.Contains(_missingDependencyClass, methodWithTypeOfDependencyDependencies);
}

[Fact]
public void AsyncMethodDependencyTest()
{
Classes()
.That()
.Are(typeof(AsyncUser))
.Should()
.CallAny(MethodMembers().That().HaveName("MethodAsync()"))
.Check(Architecture);
}
}

#pragma warning disable 219
Expand All @@ -85,5 +99,23 @@ public void MethodWithNullVariable()
internal class MissingDependencyClass { }

internal class SubClass : MissingDependencyClass { }

internal class AsyncService
{
public async Task MethodAsync()
{
await Task.Delay(100);
}
}

internal class AsyncUser
{
private readonly AsyncService _asyncService = new AsyncService();

public async Task UseAsyncService()
{
await _asyncService.MethodAsync();
}
}
}
#pragma warning restore 219
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ namespace ExampleTest
}
```

#### Run the tests

Since ArchUnitNET is reading the architecture form the analyzed binaries, it is recommended to run ArchUnitNET-based tests in Debug configuration.

```
dotnet test -c Debug
```

For more details on known edge cases, see [the documentation](https://archunitnet.readthedocs.io/en/stable/limitations/debug_artifacts/).

#### Further Info and Help

Check out test examples for the current release at
Expand Down
5 changes: 3 additions & 2 deletions documentation/docs/limitations/debug_artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
ArchUnitNET gathers information about the architecture from analyzing
binaries, therefore running tests with the Release option (`dotnet test -c Release`) instead of the Debug
option (`dotnet test -c Debug`) can lead to not finding dependencies you normally would expect to find.
The edge cases we found so far are not initializing a local variable, casting an object and using
the typeof() statement. A minimal example for each edge case can be found [here](https://github.com/TNG/ArchUnitNET/blob/master/ExampleTest/LimitationsOnReleaseTest.cs).
The edge cases we found so far are not initializing a local variable, casting an object, using
the typeof() statement and checking that an async function is called.
A minimal example for each edge case can be found [here](https://github.com/TNG/ArchUnitNET/blob/master/ExampleTest/LimitationsOnReleaseTest.cs).


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