Skip to content

[WIP] Async generator #588

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

Closed
wants to merge 91 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
d3a6e46
Changes needed to be done in order to have more async methods generated
maca88 Mar 31, 2017
86ac3e5
Refactored custom data readers to be created and initialized within a…
maca88 Apr 2, 2017
8af83eb
Added missing async overrides for custom readers
maca88 Apr 3, 2017
bbd4077
Fixed summaries for ICriteria and IQueryOver async methods
maca88 Apr 4, 2017
c835828
Removed ASYNC directive as .NET 4 is not supported anymore and added …
maca88 Apr 4, 2017
da52c06
Refactor ForeignKeys.IsTransient & ForeignKeys.IsNotTransient to redu…
hazzik May 4, 2017
539ad02
NH-2088 - Generate async code
hazzik May 4, 2017
2c49ae4
Replace CollectionCacheEntry constructor with factory method
hazzik May 4, 2017
59817b7
Inline HQLQueryPlan.DoIterate
hazzik May 7, 2017
bddac98
Revert "Replace CollectionCacheEntry constructor with factory method"
hazzik May 7, 2017
fa82f2e
Re-generate with latest version
hazzik May 13, 2017
d1256c4
Generate Async tests.
hazzik May 30, 2017
b8b3fcb
Re-generate with latest
hazzik May 30, 2017
5ea079c
Do not generate ignored tests
hazzik Jun 1, 2017
ee267e4
Fixed some oddities in apparently non-generated xml comments. A regen…
fredericDelaporte Jun 2, 2017
a1df597
Replacing includes by inherits in xml comments
fredericDelaporte Jun 2, 2017
23f376b
Refactored method reflexion.
fredericDelaporte Jun 2, 2017
5cd4038
Fix compilation error
hazzik Jun 3, 2017
214accc
Re-generate with latest version
hazzik Jun 3, 2017
bba9e19
Fix encoding
hazzik Jun 3, 2017
37b7fd9
Re-generate with master
hazzik Jun 3, 2017
0c7a8a6
ConfigureAwait, and some fixes in new async code that should be done …
fredericDelaporte Jun 3, 2017
d49dc2b
Wrapping potential exceptions in a task.
fredericDelaporte Jun 3, 2017
f867123
Re-generate with latest version
hazzik Jun 10, 2017
5b812ba
Missing null check.
fredericDelaporte Jun 11, 2017
8f8fe28
Whitespace misses during a previous refactoring.
fredericDelaporte Jun 11, 2017
dc5c502
Updating AsyncLock according to blog source supplied by Cremor.
fredericDelaporte Jun 11, 2017
eaae4ac
Missing cancellation checks, preconditions, exception wrappings, xml …
fredericDelaporte Jun 12, 2017
3c33332
Fix bad reference in xml comment.
fredericDelaporte Jun 12, 2017
56f3b99
Replacing ThreadLocal by AsyncLocal, and adjusting tests.
fredericDelaporte Jun 12, 2017
92e1d91
Reverting change on DelayedPostInsert and Table: AsyncLocal cannot be…
fredericDelaporte Jun 13, 2017
9cb106e
Fix projects
hazzik Jun 14, 2017
8748f86
Add AsyncGenerator CLI
hazzik Jun 14, 2017
bdf0060
Generate async code
hazzik Jun 14, 2017
5286d22
Update NUnit to 3.6.1+
hazzik Jun 15, 2017
454aa99
Downgrade NUnit to 3.6.1
hazzik Jun 15, 2017
c265ba1
Build menu option for async generator + contributing guide lines for …
fredericDelaporte Jun 15, 2017
552b434
Fix a lost character in buuild menu
fredericDelaporte Jun 15, 2017
6be82b7
Upgrading async generator
fredericDelaporte Jun 15, 2017
46e7c10
Upgrading async generator.
fredericDelaporte Jun 15, 2017
1cfb105
Make generate-async task dependant on common.generate-assemblyinfo
hazzik Jun 15, 2017
1ad582b
Move code generation back to "H"
hazzik Jun 15, 2017
0e6c53f
Merge branch 'master' into AsyncGenerator
hazzik Jun 15, 2017
b4a4298
Generate async files letter adjustment.
fredericDelaporte Jun 15, 2017
4b9793d
Merge branch 'master' into AsyncGenerator
hazzik Jun 15, 2017
969fde4
Update AsyncGenerator
hazzik Jun 19, 2017
e1d8eb8
Mark methods of ICache as async
hazzik Jun 19, 2017
9aa7e0d
Generate async methods for ICache
hazzik Jun 19, 2017
d6c8dc7
Merge branch 'master' into AsyncGenerator
hazzik Jun 20, 2017
f33bff7
Fix test failures for Firebird
hazzik Jun 20, 2017
083e88c
Re-generate with latest version
hazzik Jun 20, 2017
adfebbf
Update AsyncGenerator
hazzik Jun 20, 2017
14afe44
Generate CancellationTokens for ICache
hazzik Jun 20, 2017
84613a7
Re-generate with latest config.
hazzik Jun 20, 2017
a0055d9
Merging master.
fredericDelaporte Jun 20, 2017
7a106cc
Regen Async
fredericDelaporte Jun 20, 2017
4366020
Generator does not seem to handle theory well.
fredericDelaporte Jun 21, 2017
b798bdf
Revert "Generator does not seem to handle theory well."
hazzik Jun 21, 2017
f6fb0b9
Do not add CancellationTokens to theories
hazzik Jun 21, 2017
e8e6383
Regenerate code
hazzik Jun 21, 2017
22e6384
Fix common.find-nunit
hazzik Jun 21, 2017
1f41c9c
Fixed cancellation tokens for FutureAsync and FutureValueAsync
maca88 Jun 13, 2017
2ed892c
Removed IFutureValueAsync and added GetValueAsync to IFutureValue
maca88 Jun 13, 2017
e07c057
Removed GetAsyncEnumerator<TResult> in favor of GetEnumerator<TResult>
maca88 Jun 13, 2017
64a2be2
Removed FutureAsync in favor of IFutureEnumerable<T>
maca88 Jun 17, 2017
5e78969
Xml comment, forgotten covariance.
fredericDelaporte Jun 21, 2017
67ec24a
Xml comments on future value.
fredericDelaporte Jun 22, 2017
3191b05
Removing AsyncEnumerable from future implementation.
fredericDelaporte Jun 22, 2017
83ecfdc
Ignore EnumerableImpl
hazzik Jun 28, 2017
1ce5462
Do not generate EnumerableImpl
hazzik Jun 28, 2017
d6a5810
Syntax workaround for AsyncGenerator
hazzik Jun 28, 2017
6a7961a
Update AsyncGenerator
hazzik Jul 6, 2017
b2b9893
Merge remote-tracking branch 'origin/master' into AsyncGenerator
hazzik Jul 6, 2017
f689310
Regenerate code
hazzik Jul 6, 2017
a6bd9c5
Merge remote-tracking branch 'origin/master' into AsyncGenerator
hazzik Jul 18, 2017
4da5ad6
Merge branch 'master' of https://github.com/nhibernate/nhibernate-cor…
hazzik Jul 25, 2017
121c554
Update AsyncGenerator to version 0.2.6
hazzik Jul 25, 2017
3f0b711
Regenerate Async code
hazzik Jul 25, 2017
b34c70f
Merge master into AsyncGenerator.
fredericDelaporte Aug 22, 2017
533cffb
Merge branch 'master' into AsyncGenerator
hazzik Aug 25, 2017
3054386
Update AsyncGenerator to 0.3.2
hazzik Aug 25, 2017
6edd364
Restore packages for AsyncGenerator
hazzik Aug 25, 2017
56f02dd
Upgrading async generator to 0.3.5 and adapting configuration.
fredericDelaporte Aug 26, 2017
295de75
Regenerating async.
fredericDelaporte Aug 26, 2017
8458e8c
Workaround for Firebird not immediately dropping objects added to mor…
fredericDelaporte Aug 27, 2017
fa504c4
Merge branch 'master' into AsyncGenerator
fredericDelaporte Aug 27, 2017
938a2f9
Regen async files.
fredericDelaporte Aug 27, 2017
c460370
Upgrading AsyncGenerator and regenerating.
fredericDelaporte Aug 27, 2017
04197a0
More explicit Future interface for enumerables.
fredericDelaporte Aug 28, 2017
367dccd
Regenerate Async.
fredericDelaporte Aug 28, 2017
7ba7c0d
Simplifying slightly ToFutureValue.
fredericDelaporte Aug 29, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ In most cases, you will be adding your test to the NHibernate.Test project. If t
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.
2. Next, just run the tests as usual.

## Regenerate async code

NHibernate uses a code generator for its async implementation and tests. If your changes, including tests, involve any synchronous method having an async
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.

## Commit your Test Case

Ensure that your e-mail address and name are configured appropriately in Git.
Expand Down
16 changes: 12 additions & 4 deletions ShowBuildMenu.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set NANT="%~dp0Tools\nant\bin\NAnt.exe" -t:net-4.0
set BUILDTOOL="%~dp0Tools\BuildTool\bin\Release\BuildTool.exe"
set AVAILABLE_CONFIGURATIONS=%~dp0available-test-configurations
set CURRENT_CONFIGURATION=%~dp0current-test-configuration
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.6.0\tools\nunit3-console.exe"
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.6.1\tools\nunit3-console.exe"

:main-menu
echo ========================= NHIBERNATE BUILD MENU ==========================
Expand All @@ -19,16 +19,20 @@ echo E. Build NHibernate (Debug)
echo F. Build NHibernate (Release)
echo G. Build Release Package (Also runs tests and creates documentation)
echo.
echo --- Code generation ---
echo H. Generate async code (Generates files in Async sub-folders)
echo.
echo --- TeamCity (CI) build options
echo I. TeamCity build menu
echo.
echo --- Exit ---
echo X. Make the beautiful build menu go away.
echo.

%BUILDTOOL% prompt BCDEFGIX
if errorlevel 7 goto end
if errorlevel 6 goto teamcity-menu
%BUILDTOOL% prompt BCDEFGHIX
if errorlevel 8 goto end
if errorlevel 7 goto teamcity-menu
if errorlevel 6 goto build-async
if errorlevel 5 goto build-release-package
if errorlevel 4 goto build-release
if errorlevel 3 goto build-debug
Expand Down Expand Up @@ -168,6 +172,10 @@ rem :build-test
rem %NANT% test
rem goto main-menu

:build-async
%NANT% generate-async
goto main-menu

:build-debug
%NANT% clean build
echo.
Expand Down
1 change: 1 addition & 0 deletions Tools/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nuget.exe
NUnit.*
vswhere.*
CSharpAsyncGenerator.CommandLine.*
5 changes: 3 additions & 2 deletions Tools/packages.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit.Console" version="3.6.0" targetFramework="net461" />
<package id="NUnit.ConsoleRunner" version="3.6.0" targetFramework="net461" />
<package id="NUnit.Console" version="3.6.1" targetFramework="net461" />
<package id="NUnit.ConsoleRunner" version="3.6.1" targetFramework="net461" />
<package id="NUnit.Extension.NUnitProjectLoader" version="3.5.0" targetFramework="net461" />
<package id="NUnit.Extension.NUnitV2Driver" version="3.6.0" targetFramework="net461" />
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.5.0" targetFramework="net461" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.5.0" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.3.6" targetFramework="net461" />
</packages>
7 changes: 7 additions & 0 deletions build-common/common-project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
<arg value="install" />
</exec>
</target>

<target name="common.solution-restore" depends="common.nuget-restore">
<exec program="${path::combine(tools.dir, 'msbuild.cmd')}" verbose="true">
<arg value="/t:Restore" />
<arg value="${root.dir}/src/NHibernate.sln" />
</exec>
</target>

<target name="common.compile-all" depends="common.nuget-restore">
<!--property name="msbuild.cmd" value="${cmd.sln} ${cmd.out} ${cmd.platform} ${cmd.debug} ${cmd.optimize} ${cmd.doc} /t:Rebuild /v:q /m" /-->
Expand Down
21 changes: 19 additions & 2 deletions build-common/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,27 @@
</fileset>
<resourcefileset id="project.resources" />
</target>


<target name="common.get-nuget-package-path">
<xmlpeek
file="${tools.dir}/packages.config"
xpath="/packages/package[@id = '${nuget-package-id}']/@version"
property="nuget-package-version" />
<property name="nuget-package-path" value="${tools.dir}/${nuget-package-id}.${nuget-package-version}/" />
</target>

<target name="common.find-async-generator-console">
<property name="nuget-package-id" value="CSharpAsyncGenerator.CommandLine" />
<call target="common.get-nuget-package-path" />
<property name="async-generator-console" value="${nuget-package-path}/tools/AsyncGenerator.CommandLine.exe" />
</target>

<target name="common.find-nunit">
<property name="nunit-console" value="${tools.dir}/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe" />
<property name="nuget-package-id" value="NUnit.ConsoleRunner" />
<call target="common.get-nuget-package-path" />
<property name="nunit-console" value="${nuget-package-path}/tools/nunit3-console.exe" />
</target>

<target name="common.find-ndoc">
<property name="ndoc-console" value="${tools.dir}/ndoc/NDocConsole.exe" />
</target>
Expand Down
6 changes: 6 additions & 0 deletions default.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
<target name="build"
depends="check-framework-version init prepare-build-directory common.compile-all"
description="Builds NHibernate in the current configuration" />

<target name="generate-async" depends="common.nuget-restore common.solution-restore common.find-async-generator-console">
<exec
workingdir="${root.dir}/src"
program="${async-generator-console}" />
</target>

<target name="check-framework-version">
<echo>Running with ${framework::get-target-framework()}</echo>
Expand Down
248 changes: 248 additions & 0 deletions src/AsyncGenerator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
projects:
- filePath: NHibernate\NHibernate.csproj
concurrentRun: true
applyChanges: true
analyzation:
methodConversion:
- conversion: Ignore
hasAttributeName: ObsoleteAttribute
- conversion: Ignore
name: PostProcessInsert
containingTypeName: HqlSqlWalker
- conversion: Ignore
name: Intercept
containingTypeName: IInterceptor
- conversion: Ignore
name: Intercept
containingTypeName: IFieldInterceptor
- conversion: Ignore
name: InitializeOrGetAssociation
containingTypeName: AbstractFieldInterceptor
- conversion: Ignore
name: InitializeLazyProperty
containingTypeName: ILazyPropertyInitializer
- conversion: Ignore
name: InitializeLazyPropertiesFromDatastore
containingTypeName: AbstractEntityPersister
- conversion: Ignore
name: InitializeLazyPropertiesFromCache
containingTypeName: AbstractEntityPersister
- conversion: Ignore
name: Invoke
containingTypeName: BasicLazyInitializer
- conversion: Ignore
name: SetReadOnly
containingTypeName: StatefulPersistenceContext
- conversion: Ignore
name: Unproxy
containingTypeName: StatefulPersistenceContext
- conversion: Ignore
name: Contains
containingTypeName: CollectionType
- conversion: Ignore
name: GuessClass
containingTypeName: NHibernateProxyHelper
- conversion: Ignore
name: IsPropertyInitialized
containingTypeName: NHibernateUtil
- conversion: Ignore
name: BestGuessEntityName
containingTypeName: ISession
- conversion: Ignore
name: Contains
containingTypeName: ISession
- conversion: Ignore
name: BestGuessEntityName
containingTypeName: ISessionImplementor
- conversion: Ignore
name: Contains
containingTypeName: ISessionImplementor
- conversion: Ignore
name: GetUnsavedVersionValue
containingTypeName: UnsavedValueFactory
- conversion: Ignore
name: ReadSize
containingTypeName: AbstractPersistentCollection
- conversion: Ignore
name: ReadIndexExistence
containingTypeName: AbstractPersistentCollection
- conversion: Ignore
name: ReadElementExistence
containingTypeName: AbstractPersistentCollection
- conversion: Ignore
name: ReadElementByIndex
containingTypeName: AbstractPersistentCollection
- conversion: Ignore
name: Read
containingTypeName: AbstractPersistentCollection
- conversion: Ignore
name: Write
containingTypeName: AbstractPersistentCollection
- conversion: Ignore
name: GetSize
containingTypeName: ICollectionPersister
- conversion: Ignore
name: IndexExists
containingTypeName: ICollectionPersister
- conversion: Ignore
name: ElementExists
containingTypeName: ICollectionPersister
- conversion: Ignore
name: GetElementByIndex
containingTypeName: ICollectionPersister
- conversion: Ignore
name: Exists
containingTypeName: ICollectionPersister
- conversion: Ignore
name: Exists
containingTypeName: AbstractCollectionPersister
- conversion: ToAsync
name: ExecuteReader
containingTypeName: IBatcher
- conversion: ToAsync
name: ExecuteNonQuery
containingTypeName: IBatcher
- conversion: ToAsync
rule: EventListener
- conversion: ToAsync
rule: ICache
typeConversion:
- conversion: Ignore
name: EnumerableImpl
ignoreSearchForAsyncCounterparts:
- name: GetFieldValue
- name: IsDBNull
- name: WriteLine
callForwarding: true
cancellationTokens:
guards: true
methodParameter:
- anyInterfaceRule: PubliclyExposedType
parameter: Optional
- parameter: Optional
rule: PubliclyExposedType
- parameter: Required
requiresCancellationToken:
- rule: EventListener
- rule: ICache
scanMethodBody: true
transformation:
configureAwaitArgument: false
localFunctions: true
asyncLock:
type: NHibernate.Util.AsyncLock
methodName: LockAsync
documentationComments:
addOrReplaceMethodSummary:
- name: Commit
containingTypeName: AdoTransaction
content: |
/// Commits the <see cref="ITransaction"/> by flushing asynchronously the <see cref="ISession"/>
/// then committing synchronously the <see cref="DbTransaction"/>.
registerPlugin:
- type: AsyncGenerator.Core.Plugins.TransactionScopeAsyncFlowAdder
assemblyName: AsyncGenerator.Core
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
assemblyName: AsyncGenerator.Core
- filePath: NHibernate.DomainModel\NHibernate.DomainModel.csproj
concurrentRun: true
applyChanges: true
analyzation:
scanMethodBody: true
scanForMissingAsyncMembers:
- all: true
- filePath: NHibernate.Test\NHibernate.Test.csproj
concurrentRun: true
applyChanges: true
analyzation:
methodConversion:
- conversion: Ignore
hasAttributeName: IgnoreAttribute
- conversion: Smart
hasAttributeName: TestAttribute
- conversion: Smart
hasAttributeName: TheoryAttribute
asyncExtensionMethods:
projectFiles:
- fileName: LinqExtensionMethods.cs
projectName: NHibernate
preserveReturnType:
- hasAttributeName: TestAttribute
- hasAttributeName: TheoryAttribute
typeConversion:
- conversion: Ignore
name: NorthwindDbCreator
- conversion: Ignore
name: ObjectAssert
- conversion: Ignore
name: LinqReadonlyTestsContext
- conversion: Ignore
hasAttributeName: IgnoreAttribute
- conversion: NewType
hasAttributeName: TestFixtureAttribute
- conversion: Ignore
rule: IsTestCase
- conversion: Ignore
anyBaseTypeRule: IsTestCase
ignoreDocuments:
- filePathEndsWith: Linq\MathTests.cs
- filePathEndsWith: Linq\ExpressionSessionLeakTest.cs
cancellationTokens:
withoutCancellationToken:
- hasAttributeName: TestAttribute
- hasAttributeName: TheoryAttribute
scanMethodBody: true
scanForMissingAsyncMembers:
- anyInterfaceRule: NHibernateAssembly
registerPlugin:
- type: AsyncGenerator.Core.Plugins.NUnitAsyncCounterpartsFinder
assemblyName: AsyncGenerator.Core
- type: AsyncGenerator.Core.Plugins.TransactionScopeAsyncFlowAdder
assemblyName: AsyncGenerator.Core
methodRules:
- filters:
- containingTypeName: IAutoFlushEventListener
- containingTypeName: IFlushEventListener
- containingTypeName: IDeleteEventListener
- containingTypeName: ISaveOrUpdateEventListener
- containingTypeName: IPostCollectionRecreateEventListener
- containingTypeName: IPostCollectionRemoveEventListener
- containingTypeName: IPostCollectionUpdateEventListener
- containingTypeName: IPostDeleteEventListener
- containingTypeName: IPostInsertEventListener
- containingTypeName: IPostUpdateEventListener
- containingTypeName: IPreCollectionRecreateEventListener
- containingTypeName: IPreCollectionRemoveEventListener
- containingTypeName: IPreCollectionUpdateEventListener
- containingTypeName: IPreDeleteEventListener
- containingTypeName: IPreInsertEventListener
- containingTypeName: IPreLoadEventListener
- containingTypeName: IPreUpdateEventListener
name: EventListener
- filters:
- containingType: NHibernate.Cache.ICache
name: Get
- containingType: NHibernate.Cache.ICache
name: Put
- containingType: NHibernate.Cache.ICache
name: Remove
- containingType: NHibernate.Cache.ICache
name: Clear
- containingType: NHibernate.Cache.ICache
name: Lock
- containingType: NHibernate.Cache.ICache
name: Unlock
name: ICache
- filters:
- containingNamespace: NHibernate
- containingType: NHibernate.Tool.hbm2ddl.SchemaUpdate
- containingType: NHibernate.Tool.hbm2ddl.SchemaValidator
- containingType: NHibernate.Tool.hbm2ddl.SchemaExport
name: PubliclyExposedType
typeRules:
- filters:
- containingAssemblyName: NHibernate
name: NHibernateAssembly
- filters:
- name: TestCase
name: IsTestCase
Loading