Skip to content

Commit 4d99b2b

Browse files
authored
Merge pull request #677 from fredericDelaporte/AsyncGenerator
NH-3905 - Implement Async operations
2 parents 1b6f844 + 5df9626 commit 4d99b2b

File tree

1,378 files changed

+150115
-1157
lines changed

Some content is hidden

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

1,378 files changed

+150115
-1157
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ In most cases, you will be adding your test to the NHibernate.Test project. If t
6565
1. Sometimes tests fail when run under x64. If required (ex. SQLite and Firebird), go to the project properties Build tab and set the target to x86.
6666
2. Next, just run the tests as usual.
6767

68+
## Regenerate async code
69+
70+
NHibernate uses a code generator for its async implementation and tests. If your changes, including tests, involve any synchronous method having an async
71+
counter-part, you should regenerate the async code. Use build-menu option H for this. Then test any async counter-part it may have generated from your tests.
72+
6873
## Commit your Test Case
6974

7075
Ensure that your e-mail address and name are configured appropriately in Git.

ShowBuildMenu.bat

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set NANT="%~dp0Tools\nant\bin\NAnt.exe" -t:net-4.0
55
set BUILDTOOL="%~dp0Tools\BuildTool\bin\Release\BuildTool.exe"
66
set AVAILABLE_CONFIGURATIONS=%~dp0available-test-configurations
77
set CURRENT_CONFIGURATION=%~dp0current-test-configuration
8-
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.6.0\tools\nunit3-console.exe"
8+
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe"
99

1010
:main-menu
1111
echo ========================= NHIBERNATE BUILD MENU ==========================
@@ -19,16 +19,20 @@ echo E. Build NHibernate (Debug)
1919
echo F. Build NHibernate (Release)
2020
echo G. Build Release Package (Also runs tests and creates documentation)
2121
echo.
22+
echo --- Code generation ---
23+
echo H. Generate async code (Generates files in Async sub-folders)
24+
echo.
2225
echo --- TeamCity (CI) build options
2326
echo I. TeamCity build menu
2427
echo.
2528
echo --- Exit ---
2629
echo X. Make the beautiful build menu go away.
2730
echo.
2831

29-
%BUILDTOOL% prompt BCDEFGIX
30-
if errorlevel 7 goto end
31-
if errorlevel 6 goto teamcity-menu
32+
%BUILDTOOL% prompt BCDEFGHIX
33+
if errorlevel 8 goto end
34+
if errorlevel 7 goto teamcity-menu
35+
if errorlevel 6 goto build-async
3236
if errorlevel 5 goto build-release-package
3337
if errorlevel 4 goto build-release
3438
if errorlevel 3 goto build-debug
@@ -168,6 +172,10 @@ rem :build-test
168172
rem %NANT% test
169173
rem goto main-menu
170174

175+
:build-async
176+
%NANT% generate-async
177+
goto main-menu
178+
171179
:build-debug
172180
%NANT% clean build
173181
echo.

Tools/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
nuget.exe
22
NUnit.*
33
vswhere.*
4+
CSharpAsyncGenerator.CommandLine.*

Tools/packages.config

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="NUnit.Console" version="3.6.0" targetFramework="net461" />
4-
<package id="NUnit.ConsoleRunner" version="3.6.0" targetFramework="net461" />
5-
<package id="NUnit.Extension.NUnitProjectLoader" version="3.5.0" targetFramework="net461" />
6-
<package id="NUnit.Extension.NUnitV2Driver" version="3.6.0" targetFramework="net461" />
7-
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.5.0" targetFramework="net461" />
3+
<package id="NUnit.Console" version="3.7.0" targetFramework="net461" />
4+
<package id="NUnit.ConsoleRunner" version="3.7.0" targetFramework="net461" />
5+
<package id="NUnit.Extension.NUnitProjectLoader" version="3.6.0" targetFramework="net461" />
6+
<package id="NUnit.Extension.NUnitV2Driver" version="3.7.0" targetFramework="net461" />
7+
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
88
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
9-
<package id="NUnit.Extension.VSProjectLoader" version="3.5.0" targetFramework="net461" />
9+
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
10+
<package id="CSharpAsyncGenerator.CommandLine" version="0.3.6" targetFramework="net461" />
1011
</packages>

build-common/common-project.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@
5555
</exec>
5656
</target>
5757

58+
<target name="common.solution-restore" depends="common.nuget-restore">
59+
<exec program="${path::combine(tools.dir, 'msbuild.cmd')}" verbose="true">
60+
<arg value="/t:Restore" />
61+
<arg value="${root.dir}/src/NHibernate.sln" />
62+
</exec>
63+
</target>
64+
5865
<target name="common.compile-all" depends="common.nuget-restore">
5966
<!--property name="msbuild.cmd" value="${cmd.sln} ${cmd.out} ${cmd.platform} ${cmd.debug} ${cmd.optimize} ${cmd.doc} /t:Rebuild /v:q /m" /-->
6067
<exec program="${path::combine(tools.dir, 'msbuild.cmd')}" verbose="true">

build-common/common.xml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,27 @@
153153
</fileset>
154154
<resourcefileset id="project.resources" />
155155
</target>
156-
156+
157+
<target name="common.get-nuget-package-path">
158+
<xmlpeek
159+
file="${tools.dir}/packages.config"
160+
xpath="/packages/package[@id = '${nuget-package-id}']/@version"
161+
property="nuget-package-version" />
162+
<property name="nuget-package-path" value="${tools.dir}/${nuget-package-id}.${nuget-package-version}/" />
163+
</target>
164+
165+
<target name="common.find-async-generator-console">
166+
<property name="nuget-package-id" value="CSharpAsyncGenerator.CommandLine" />
167+
<call target="common.get-nuget-package-path" />
168+
<property name="async-generator-console" value="${nuget-package-path}/tools/AsyncGenerator.CommandLine.exe" />
169+
</target>
170+
157171
<target name="common.find-nunit">
158-
<property name="nunit-console" value="${tools.dir}/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe" />
172+
<property name="nuget-package-id" value="NUnit.ConsoleRunner" />
173+
<call target="common.get-nuget-package-path" />
174+
<property name="nunit-console" value="${nuget-package-path}/tools/nunit3-console.exe" />
159175
</target>
176+
160177
<target name="common.find-ndoc">
161178
<property name="ndoc-console" value="${tools.dir}/ndoc/NDocConsole.exe" />
162179
</target>

default.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
<target name="build"
2929
depends="check-framework-version init prepare-build-directory common.compile-all"
3030
description="Builds NHibernate in the current configuration" />
31+
32+
<target name="generate-async" depends="common.nuget-restore common.solution-restore common.find-async-generator-console">
33+
<exec
34+
workingdir="${root.dir}/src"
35+
program="${async-generator-console}" />
36+
</target>
3137

3238
<target name="check-framework-version">
3339
<echo>Running with ${framework::get-target-framework()}</echo>

src/AsyncGenerator.yml

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
projects:
2+
- filePath: NHibernate\NHibernate.csproj
3+
concurrentRun: true
4+
applyChanges: true
5+
analyzation:
6+
methodConversion:
7+
- conversion: Ignore
8+
hasAttributeName: ObsoleteAttribute
9+
- conversion: Ignore
10+
name: PostProcessInsert
11+
containingTypeName: HqlSqlWalker
12+
- conversion: Ignore
13+
name: Intercept
14+
containingTypeName: IInterceptor
15+
- conversion: Ignore
16+
name: Intercept
17+
containingTypeName: IFieldInterceptor
18+
- conversion: Ignore
19+
name: InitializeOrGetAssociation
20+
containingTypeName: AbstractFieldInterceptor
21+
- conversion: Ignore
22+
name: InitializeLazyProperty
23+
containingTypeName: ILazyPropertyInitializer
24+
- conversion: Ignore
25+
name: InitializeLazyPropertiesFromDatastore
26+
containingTypeName: AbstractEntityPersister
27+
- conversion: Ignore
28+
name: InitializeLazyPropertiesFromCache
29+
containingTypeName: AbstractEntityPersister
30+
- conversion: Ignore
31+
name: Invoke
32+
containingTypeName: BasicLazyInitializer
33+
- conversion: Ignore
34+
name: SetReadOnly
35+
containingTypeName: StatefulPersistenceContext
36+
- conversion: Ignore
37+
name: Unproxy
38+
containingTypeName: StatefulPersistenceContext
39+
- conversion: Ignore
40+
name: Contains
41+
containingTypeName: CollectionType
42+
- conversion: Ignore
43+
name: GuessClass
44+
containingTypeName: NHibernateProxyHelper
45+
- conversion: Ignore
46+
name: IsPropertyInitialized
47+
containingTypeName: NHibernateUtil
48+
- conversion: Ignore
49+
name: BestGuessEntityName
50+
containingTypeName: ISession
51+
- conversion: Ignore
52+
name: Contains
53+
containingTypeName: ISession
54+
- conversion: Ignore
55+
name: BestGuessEntityName
56+
containingTypeName: ISessionImplementor
57+
- conversion: Ignore
58+
name: Contains
59+
containingTypeName: ISessionImplementor
60+
- conversion: Ignore
61+
name: GetUnsavedVersionValue
62+
containingTypeName: UnsavedValueFactory
63+
- conversion: Ignore
64+
name: ReadSize
65+
containingTypeName: AbstractPersistentCollection
66+
- conversion: Ignore
67+
name: ReadIndexExistence
68+
containingTypeName: AbstractPersistentCollection
69+
- conversion: Ignore
70+
name: ReadElementExistence
71+
containingTypeName: AbstractPersistentCollection
72+
- conversion: Ignore
73+
name: ReadElementByIndex
74+
containingTypeName: AbstractPersistentCollection
75+
- conversion: Ignore
76+
name: Read
77+
containingTypeName: AbstractPersistentCollection
78+
- conversion: Ignore
79+
name: Write
80+
containingTypeName: AbstractPersistentCollection
81+
- conversion: Ignore
82+
name: GetSize
83+
containingTypeName: ICollectionPersister
84+
- conversion: Ignore
85+
name: IndexExists
86+
containingTypeName: ICollectionPersister
87+
- conversion: Ignore
88+
name: ElementExists
89+
containingTypeName: ICollectionPersister
90+
- conversion: Ignore
91+
name: GetElementByIndex
92+
containingTypeName: ICollectionPersister
93+
- conversion: Ignore
94+
name: Exists
95+
containingTypeName: ICollectionPersister
96+
- conversion: Ignore
97+
name: Exists
98+
containingTypeName: AbstractCollectionPersister
99+
- conversion: ToAsync
100+
name: ExecuteReader
101+
containingTypeName: IBatcher
102+
- conversion: ToAsync
103+
name: ExecuteNonQuery
104+
containingTypeName: IBatcher
105+
- conversion: ToAsync
106+
rule: EventListener
107+
- conversion: ToAsync
108+
rule: ICache
109+
typeConversion:
110+
- conversion: Ignore
111+
name: EnumerableImpl
112+
ignoreSearchForAsyncCounterparts:
113+
- name: GetFieldValue
114+
- name: IsDBNull
115+
- name: WriteLine
116+
callForwarding: true
117+
cancellationTokens:
118+
guards: true
119+
methodParameter:
120+
- anyInterfaceRule: PubliclyExposedType
121+
parameter: Optional
122+
- parameter: Optional
123+
rule: PubliclyExposedType
124+
- parameter: Required
125+
requiresCancellationToken:
126+
- rule: EventListener
127+
- rule: ICache
128+
scanMethodBody: true
129+
transformation:
130+
configureAwaitArgument: false
131+
localFunctions: true
132+
asyncLock:
133+
type: NHibernate.Util.AsyncLock
134+
methodName: LockAsync
135+
documentationComments:
136+
addOrReplaceMethodSummary:
137+
- name: Commit
138+
containingTypeName: AdoTransaction
139+
content: |
140+
/// Commits the <see cref="ITransaction"/> by flushing asynchronously the <see cref="ISession"/>
141+
/// then committing synchronously the <see cref="DbTransaction"/>.
142+
registerPlugin:
143+
- type: AsyncGenerator.Core.Plugins.TransactionScopeAsyncFlowAdder
144+
assemblyName: AsyncGenerator.Core
145+
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
146+
assemblyName: AsyncGenerator.Core
147+
- filePath: NHibernate.DomainModel\NHibernate.DomainModel.csproj
148+
concurrentRun: true
149+
applyChanges: true
150+
analyzation:
151+
scanMethodBody: true
152+
scanForMissingAsyncMembers:
153+
- all: true
154+
- filePath: NHibernate.Test\NHibernate.Test.csproj
155+
concurrentRun: true
156+
applyChanges: true
157+
analyzation:
158+
methodConversion:
159+
- conversion: Ignore
160+
hasAttributeName: IgnoreAttribute
161+
- conversion: Smart
162+
hasAttributeName: TestAttribute
163+
- conversion: Smart
164+
hasAttributeName: TheoryAttribute
165+
asyncExtensionMethods:
166+
projectFiles:
167+
- fileName: LinqExtensionMethods.cs
168+
projectName: NHibernate
169+
preserveReturnType:
170+
- hasAttributeName: TestAttribute
171+
- hasAttributeName: TheoryAttribute
172+
typeConversion:
173+
- conversion: Ignore
174+
name: NorthwindDbCreator
175+
- conversion: Ignore
176+
name: ObjectAssert
177+
- conversion: Ignore
178+
name: LinqReadonlyTestsContext
179+
- conversion: Ignore
180+
hasAttributeName: IgnoreAttribute
181+
- conversion: NewType
182+
hasAttributeName: TestFixtureAttribute
183+
- conversion: Ignore
184+
rule: IsTestCase
185+
- conversion: Ignore
186+
anyBaseTypeRule: IsTestCase
187+
ignoreDocuments:
188+
- filePathEndsWith: Linq\MathTests.cs
189+
- filePathEndsWith: Linq\ExpressionSessionLeakTest.cs
190+
cancellationTokens:
191+
withoutCancellationToken:
192+
- hasAttributeName: TestAttribute
193+
- hasAttributeName: TheoryAttribute
194+
scanMethodBody: true
195+
scanForMissingAsyncMembers:
196+
- anyInterfaceRule: NHibernateAssembly
197+
registerPlugin:
198+
- type: AsyncGenerator.Core.Plugins.NUnitAsyncCounterpartsFinder
199+
assemblyName: AsyncGenerator.Core
200+
- type: AsyncGenerator.Core.Plugins.TransactionScopeAsyncFlowAdder
201+
assemblyName: AsyncGenerator.Core
202+
methodRules:
203+
- filters:
204+
- containingTypeName: IAutoFlushEventListener
205+
- containingTypeName: IFlushEventListener
206+
- containingTypeName: IDeleteEventListener
207+
- containingTypeName: ISaveOrUpdateEventListener
208+
- containingTypeName: IPostCollectionRecreateEventListener
209+
- containingTypeName: IPostCollectionRemoveEventListener
210+
- containingTypeName: IPostCollectionUpdateEventListener
211+
- containingTypeName: IPostDeleteEventListener
212+
- containingTypeName: IPostInsertEventListener
213+
- containingTypeName: IPostUpdateEventListener
214+
- containingTypeName: IPreCollectionRecreateEventListener
215+
- containingTypeName: IPreCollectionRemoveEventListener
216+
- containingTypeName: IPreCollectionUpdateEventListener
217+
- containingTypeName: IPreDeleteEventListener
218+
- containingTypeName: IPreInsertEventListener
219+
- containingTypeName: IPreLoadEventListener
220+
- containingTypeName: IPreUpdateEventListener
221+
name: EventListener
222+
- filters:
223+
- containingType: NHibernate.Cache.ICache
224+
name: Get
225+
- containingType: NHibernate.Cache.ICache
226+
name: Put
227+
- containingType: NHibernate.Cache.ICache
228+
name: Remove
229+
- containingType: NHibernate.Cache.ICache
230+
name: Clear
231+
- containingType: NHibernate.Cache.ICache
232+
name: Lock
233+
- containingType: NHibernate.Cache.ICache
234+
name: Unlock
235+
name: ICache
236+
- filters:
237+
- containingNamespace: NHibernate
238+
- containingType: NHibernate.Tool.hbm2ddl.SchemaUpdate
239+
- containingType: NHibernate.Tool.hbm2ddl.SchemaValidator
240+
- containingType: NHibernate.Tool.hbm2ddl.SchemaExport
241+
name: PubliclyExposedType
242+
typeRules:
243+
- filters:
244+
- containingAssemblyName: NHibernate
245+
name: NHibernateAssembly
246+
- filters:
247+
- name: TestCase
248+
name: IsTestCase

0 commit comments

Comments
 (0)