Skip to content

Commit 9952932

Browse files
dennis-grRogerKratz
authored andcommitted
#50 Add async support
1 parent fd99653 commit 9952932

File tree

637 files changed

+18512
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

637 files changed

+18512
-333
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools":{
5+
"csharpasyncgenerator.tool": {
6+
"version": "0.21.1",
7+
"commands": [
8+
"async-generator"
9+
]
10+
}
11+
}
12+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Generate Async code
2+
3+
on:
4+
pull_request_target:
5+
paths:
6+
- '**.cs'
7+
8+
permissions: {}
9+
10+
jobs:
11+
generate-async:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
ref: ${{ github.event.pull_request.head.ref }}
18+
repository: ${{ github.event.pull_request.head.repo.full_name }}
19+
token: ${{ secrets.NHIBERNATE_BOT_TOKEN }}
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v3
23+
with:
24+
dotnet-version: 6.0.x
25+
26+
- name: Generate Async code
27+
run: |
28+
pushd Src
29+
dotnet tool restore
30+
dotnet restore ./Envers.sln
31+
dotnet async-generator
32+
popd
33+
34+
- name: Push changes
35+
run: |
36+
git config user.name github-actions[bot]
37+
git config user.email github-actions[bot]@users.noreply.github.com
38+
if [[ -z "$(git status --porcelain)" ]]; then
39+
echo "No changes to commit"
40+
exit 0
41+
fi
42+
git add -A
43+
git commit -am "Generate async files"
44+
git push

.github/workflows/dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- db: MySQL
2424
connectionstring: "Server=localhost;Uid=root;Password=envers;Database=envers;SslMode=none;"
2525
dialect: "NHibernate.Dialect.MySQL8InnoDBDialect"
26-
driverclass: "NHibernate.Driver.MySqlDataDriver"
26+
driverclass: "NHibernate.Driver.MySqlConnector.MySqlConnectorDriver, NHibernate.Driver.MySqlConnector"
2727
- db: Oracle
2828
connectionstring: "User ID=envers;Password=envers;Metadata Pooling=false;Self Tuning=false;Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XEPDB1)))"
2929
dialect: "NHibernate.Dialect.Oracle10gDialect"
@@ -47,7 +47,7 @@ jobs:
4747
if: matrix.db == 'MySQL'
4848
run: |
4949
sudo service mysql stop
50-
docker run --name mysql --tmpfs /var/lib/mysql:rw,noexec,nosuid,size=256m -e MYSQL_ROOT_PASSWORD=envers -e MYSQL_USER=envers -e MYSQL_PASSWORD=envers -e MYSQL_DATABASE=envers -p 3306:3306 --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -d mysql:8.0 mysqld --lower_case_table_names=1 --skip-ssl --default_authentication_plugin=mysql_native_password
50+
docker run --name mysql --tmpfs /var/lib/mysql:rw,noexec,nosuid,size=1024m -e MYSQL_ROOT_PASSWORD=envers -e MYSQL_USER=envers -e MYSQL_PASSWORD=envers -e MYSQL_DATABASE=envers -p 3306:3306 --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -d mysql:8.0 mysqld --lower_case_table_names=1 --skip-ssl --default_authentication_plugin=mysql_native_password
5151
- name: Set up Oracle
5252
if: matrix.db == 'Oracle'
5353
run: |

Src/AsyncGenerator.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
projects:
2+
- filePath: NHibernate.Envers\NHibernate.Envers.csproj
3+
targetFramework: netcoreapp2.0
4+
concurrentRun: true
5+
applyChanges: true
6+
analyzation:
7+
methodConversion:
8+
- conversion: ToAsync
9+
name: Results
10+
containingTypeName: IEntityAuditQuery
11+
- conversion: ToAsync
12+
name: BuildAndExecuteQuery
13+
containingTypeName: AbstractRevisionsQuery
14+
- conversion: ToAsync
15+
name: Results
16+
containingTypeName: AllEntitiesAtRevisionQuery
17+
- conversion: Ignore
18+
containingTypeName: IPropertyMapper
19+
- conversion: Ignore
20+
containingTypeName: CollectionProxy
21+
typeConversion:
22+
- conversion: Ignore
23+
name: Toolz
24+
callForwarding: true
25+
cancellationTokens:
26+
guards: true
27+
methodParameter:
28+
- parameter: Optional
29+
requiresCancellationToken:
30+
- containingTypeName: IEntityAuditQuery
31+
scanMethodBody: true
32+
searchAsyncCounterpartsInInheritedTypes: true
33+
scanForMissingAsyncMembers:
34+
- all: true
35+
alwaysAwait:
36+
- all: true
37+
transformation:
38+
configureAwaitArgument: false
39+
localFunctions: true
40+
registerPlugin:
41+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
42+
assemblyName: AsyncGenerator.Core
43+
- filePath: NHibernate.Envers.Tests\NHibernate.Envers.Tests.csproj
44+
targetFramework: net6.0
45+
concurrentRun: true
46+
applyChanges: true
47+
analyzation:
48+
callForwarding: true
49+
cancellationTokens:
50+
enabled: true
51+
scanMethodBody: true
52+
searchAsyncCounterpartsInInheritedTypes: true
53+
scanForMissingAsyncMembers:
54+
- all: true
55+
methodConversion:
56+
- conversion: Ignore
57+
name: Initialize
58+
containingTypeName: OneStrategyTestBase
59+
transformation:
60+
configureAwaitArgument: false
61+
localFunctions: true
62+
registerPlugin:
63+
- type: AsyncGenerator.Core.Plugins.NUnitPlugin
64+
parameters:
65+
- name: createNewTypes
66+
value: false
67+
assemblyName: AsyncGenerator.Core
68+
- type: AsyncGenerator.Core.Plugins.TransactionScopeAsyncFlowAdder
69+
assemblyName: AsyncGenerator.Core
70+
methodRules:
71+
- filters:
72+
- containingType: NHibernate.Envers.Synchronization.transactionCompletionProcess
73+
name: TransactionCompletion

Src/Build/default.msbuild

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<MakeDir Directories="$(TempDirectory)"/>
2121
</Target>
2222

23-
<Target Name="BuildRelease" DependsOnTargets="RunBuild;nuget;CopyNuget">
23+
<Target Name="BuildRelease" DependsOnTargets="RunBuild;GenerateAsyncCode;nuget;CopyNuget">
2424
<RemoveDir Directories="$(TempDirectory)"/>
2525
</Target>
2626

@@ -37,6 +37,10 @@
3737
<Target Name="RunBuild" DependsOnTargets="MakeBuildDirectory">
3838
<MSBuild Projects="$(SourceDir)\NHibernate.Envers\NHibernate.Envers.csproj" Targets="Clean;Build" />
3939
</Target>
40+
41+
<Target Name="GenerateAsyncCode" DependsOnTargets="RunBuild">
42+
<Exec Command="dotnet async-generator" WorkingDirectory="$(SourceDir)" />
43+
</Target>
4044

4145
<!-- Documentation build steps/targets-->
4246
<Target Name="BuildDocs" DependsOnTargets="RunPdfBuild;RunHtmlBuild">

Src/Envers.sln

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27428.2015
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34031.279
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{34BA8295-3EBE-47B0-ABBF-0A7E9A8E6B35}"
77
ProjectSection(SolutionItems) = preProject
8+
AsyncGenerator.yml = AsyncGenerator.yml
89
Build\buildDoc.bat = Build\buildDoc.bat
910
Build\buildRelease.bat = Build\buildRelease.bat
1011
Build\default.msbuild = Build\default.msbuild
11-
ReleaseNotes.txt = ReleaseNotes.txt
1212
..\.github\workflows\dotnet.yml = ..\.github\workflows\dotnet.yml
13+
..\.github\workflows\GenerateAsyncCode.yml = ..\.github\workflows\GenerateAsyncCode.yml
14+
ReleaseNotes.txt = ReleaseNotes.txt
1315
EndProjectSection
1416
EndProject
1517
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Doc", "Doc", "{C9C74EFE-506E-41A8-8359-88AB303E60DA}"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using NUnit.Framework;
12+
13+
namespace NHibernate.Envers.Tests.Integration.AccessType
14+
{
15+
using System.Threading.Tasks;
16+
public partial class FieldAccessTest : TestBase
17+
{
18+
19+
[Test]
20+
public async Task VerifyRevisionCountAsync()
21+
{
22+
CollectionAssert.AreEquivalent(new[] { 1, 2 }, await (AuditReader().GetRevisionsAsync(typeof(FieldAccessEntity), id)).ConfigureAwait(false));
23+
}
24+
25+
[Test]
26+
public async Task VerifyHistoryAsync()
27+
{
28+
var ver1 = new FieldAccessEntity { Id = id };
29+
ver1.SetData("first");
30+
var ver2 = new FieldAccessEntity { Id = id };
31+
ver2.SetData("second");
32+
33+
Assert.AreEqual(ver1, await (AuditReader().FindAsync<FieldAccessEntity>(id, 1)).ConfigureAwait(false));
34+
Assert.AreEqual(ver2, await (AuditReader().FindAsync<FieldAccessEntity>(id, 2)).ConfigureAwait(false));
35+
}
36+
}
37+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using NUnit.Framework;
12+
13+
namespace NHibernate.Envers.Tests.Integration.AccessType
14+
{
15+
using System.Threading.Tasks;
16+
public partial class ImmutableClassAccessTest : TestBase
17+
{
18+
19+
[Test]
20+
public async Task VerifyRevisionCountAsync()
21+
{
22+
CollectionAssert.AreEquivalent(new[] { 1 }, await (AuditReader().GetRevisionsAsync(typeof(Country), country.Code)).ConfigureAwait(false));
23+
}
24+
25+
[Test]
26+
public async Task VerifyHistoryAsync()
27+
{
28+
var country1 = await (Session.GetAsync<Country>(country.Code)).ConfigureAwait(false);
29+
Assert.AreEqual(country, country1);
30+
31+
var history = await (AuditReader().FindAsync<Country>(country1.Code, 1)).ConfigureAwait(false);
32+
Assert.AreEqual(country, history);
33+
}
34+
}
35+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using NUnit.Framework;
12+
13+
namespace NHibernate.Envers.Tests.Integration.AccessType
14+
{
15+
using System.Threading.Tasks;
16+
public partial class MixedAccessTest : TestBase
17+
{
18+
19+
[Test]
20+
public async Task VerifyRevisionCountAsync()
21+
{
22+
CollectionAssert.AreEquivalent(new[] { 1, 2 }, await (AuditReader().GetRevisionsAsync(typeof(MixedAccessEntity), id1)).ConfigureAwait(false));
23+
}
24+
25+
[Test]
26+
public async Task VerifyHistoryAsync()
27+
{
28+
var ver1 = new MixedAccessEntity(id1, "data");
29+
var ver2 = new MixedAccessEntity(id1, "data2");
30+
31+
var rev1 = await (AuditReader().FindAsync<MixedAccessEntity>(id1, 1)).ConfigureAwait(false);
32+
var rev2 = await (AuditReader().FindAsync<MixedAccessEntity>(id1, 2)).ConfigureAwait(false);
33+
34+
Assert.IsTrue(rev1.IsDataSet);
35+
Assert.IsTrue(rev2.IsDataSet);
36+
37+
Assert.AreEqual(ver1, rev1);
38+
Assert.AreEqual(ver2, rev2);
39+
}
40+
}
41+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using NUnit.Framework;
12+
13+
namespace NHibernate.Envers.Tests.Integration.AccessType
14+
{
15+
using System.Threading.Tasks;
16+
public partial class NoSetterTest : TestBase
17+
{
18+
19+
[Test]
20+
public async Task VerifyRevisionCountAsync()
21+
{
22+
CollectionAssert.AreEquivalent(new[] { 1, 2 }, await (AuditReader().GetRevisionsAsync(typeof(NoSetterEntity), id1)).ConfigureAwait(false));
23+
}
24+
25+
[Test]
26+
public async Task VerifyHistoryAsync()
27+
{
28+
var rev1 = await (AuditReader().FindAsync<NoSetterEntity>(id1, 1)).ConfigureAwait(false);
29+
var rev2 = await (AuditReader().FindAsync<NoSetterEntity>(id1, 2)).ConfigureAwait(false);
30+
31+
Assert.AreEqual("data", rev1.Data);
32+
Assert.AreEqual("data2", rev2.Data);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)