Skip to content

Commit 38d9606

Browse files
committed
NH-2088 - Generate async code
1 parent 06c998b commit 38d9606

File tree

562 files changed

+29581
-313
lines changed

Some content is hidden

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

562 files changed

+29581
-313
lines changed

src/NHibernate/Action/BulkOperationCleanupAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace NHibernate.Action
1010
/// Implementation of BulkOperationCleanupAction.
1111
/// </summary>
1212
[Serializable]
13-
public class BulkOperationCleanupAction: IExecutable
13+
public partial class BulkOperationCleanupAction: IExecutable
1414
{
1515
private readonly ISessionImplementor session;
1616
private readonly HashSet<string> affectedEntityNames = new HashSet<string>();

src/NHibernate/Action/CollectionAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace NHibernate.Action
1414
/// Any action relating to insert/update/delete of a collection
1515
/// </summary>
1616
[Serializable]
17-
public abstract class CollectionAction : IExecutable, IComparable<CollectionAction>, IDeserializationCallback
17+
public abstract partial class CollectionAction : IExecutable, IComparable<CollectionAction>, IDeserializationCallback
1818
{
1919
private readonly object key;
2020
private object finalKey;

src/NHibernate/Action/CollectionRecreateAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace NHibernate.Action
99
{
1010
[Serializable]
11-
public sealed class CollectionRecreateAction : CollectionAction
11+
public sealed partial class CollectionRecreateAction : CollectionAction
1212
{
1313
public CollectionRecreateAction(IPersistentCollection collection, ICollectionPersister persister, object key, ISessionImplementor session)
1414
: base(persister, collection, key, session) { }

src/NHibernate/Action/CollectionRemoveAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace NHibernate.Action
99
{
1010
[Serializable]
11-
public sealed class CollectionRemoveAction : CollectionAction
11+
public sealed partial class CollectionRemoveAction : CollectionAction
1212
{
1313
private readonly bool emptySnapshot;
1414
private readonly object affectedOwner;

src/NHibernate/Action/CollectionUpdateAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace NHibernate.Action
1212
{
1313
[Serializable]
14-
public sealed class CollectionUpdateAction : CollectionAction
14+
public sealed partial class CollectionUpdateAction : CollectionAction
1515
{
1616
private readonly bool emptySnapshot;
1717

src/NHibernate/Action/EntityAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace NHibernate.Action
1313
/// instance.
1414
/// </summary>
1515
[Serializable]
16-
public abstract class EntityAction : IExecutable, IComparable<EntityAction>, IDeserializationCallback
16+
public abstract partial class EntityAction : IExecutable, IComparable<EntityAction>, IDeserializationCallback
1717
{
1818
private readonly string entityName;
1919
private readonly object id;

src/NHibernate/Action/EntityDeleteAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace NHibernate.Action
1010
{
1111
[Serializable]
12-
public sealed class EntityDeleteAction : EntityAction
12+
public sealed partial class EntityDeleteAction : EntityAction
1313
{
1414
private readonly object[] state;
1515
private readonly object version;

src/NHibernate/Action/EntityIdentityInsertAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace NHibernate.Action
88
{
99
[Serializable]
10-
public sealed class EntityIdentityInsertAction : EntityAction
10+
public sealed partial class EntityIdentityInsertAction : EntityAction
1111
{
1212
private readonly object lockObject = new object();
1313
private readonly object[] state;

src/NHibernate/Action/EntityInsertAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace NHibernate.Action
1010
{
1111
[Serializable]
12-
public sealed class EntityInsertAction : EntityAction
12+
public sealed partial class EntityInsertAction : EntityAction
1313
{
1414
private readonly object[] state;
1515
private object version;

src/NHibernate/Action/EntityUpdateAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace NHibernate.Action
1212
{
1313
[Serializable]
14-
public sealed class EntityUpdateAction : EntityAction
14+
public sealed partial class EntityUpdateAction : EntityAction
1515
{
1616
private readonly object[] state;
1717
private readonly object[] previousState;

src/NHibernate/Action/IExecutable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace NHibernate.Action
2828
/// Usually, the operation is a database insert/update/delete,
2929
/// together with required second-level cache management.
3030
/// </summary>
31-
public interface IExecutable
31+
public partial interface IExecutable
3232
{
3333
/// <summary>
3434
/// What spaces (tables) are affected by this action?

src/NHibernate/AdoNet/AbstractBatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace NHibernate.AdoNet
1818
/// <summary>
1919
/// Manages prepared statements and batching. Class exists to enforce separation of concerns
2020
/// </summary>
21-
public abstract class AbstractBatcher : IBatcher
21+
public abstract partial class AbstractBatcher : IBatcher
2222
{
2323
protected static readonly IInternalLogger Log = LoggerProvider.LoggerFor(typeof(AbstractBatcher));
2424

src/NHibernate/AdoNet/ConnectionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace NHibernate.AdoNet
1717
/// combined.
1818
/// </remarks>
1919
[Serializable]
20-
public class ConnectionManager : ISerializable, IDeserializationCallback
20+
public partial class ConnectionManager : ISerializable, IDeserializationCallback
2121
{
2222
private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof(ConnectionManager));
2323

src/NHibernate/AdoNet/MySqlClientBatchingBatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace NHibernate.AdoNet
88
{
9-
public class MySqlClientBatchingBatcher : AbstractBatcher
9+
public partial class MySqlClientBatchingBatcher : AbstractBatcher
1010
{
1111
private int batchSize;
1212
private int totalExpectedRowsAffected;

src/NHibernate/AdoNet/NonBatchingBatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace NHibernate.AdoNet
99
/// An implementation of the <see cref="IBatcher" />
1010
/// interface that does no batching.
1111
/// </summary>
12-
public class NonBatchingBatcher : AbstractBatcher
12+
public partial class NonBatchingBatcher : AbstractBatcher
1313
{
1414
/// <summary>
1515
/// Initializes a new instance of the <see cref="NonBatchingBatcher"/> class.

src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace NHibernate.AdoNet
1111
/// Summary description for OracleDataClientBatchingBatcher.
1212
/// By Tomer Avissar
1313
/// </summary>
14-
public class OracleDataClientBatchingBatcher : AbstractBatcher
14+
public partial class OracleDataClientBatchingBatcher : AbstractBatcher
1515
{
1616
private int _batchSize;
1717
private int _countOfCommands;

src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace NHibernate.AdoNet
99
{
10-
public class SqlClientBatchingBatcher : AbstractBatcher
10+
public partial class SqlClientBatchingBatcher : AbstractBatcher
1111
{
1212
private int _batchSize;
1313
private int _totalExpectedRowsAffected;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 System;
12+
using System.Collections.Generic;
13+
using NHibernate.Engine;
14+
using NHibernate.Metadata;
15+
using NHibernate.Persister.Entity;
16+
17+
namespace NHibernate.Action
18+
{
19+
using System.Threading.Tasks;
20+
public partial class BulkOperationCleanupAction: IExecutable
21+
{
22+
23+
#region IExecutable Members
24+
25+
public Task ExecuteAsync()
26+
{
27+
return Task.CompletedTask;
28+
// nothing to do
29+
}
30+
31+
#endregion
32+
}
33+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 System;
12+
using System.Runtime.Serialization;
13+
using NHibernate.Cache;
14+
using NHibernate.Cache.Access;
15+
using NHibernate.Collection;
16+
using NHibernate.Engine;
17+
using NHibernate.Impl;
18+
using NHibernate.Persister.Collection;
19+
using NHibernate.Util;
20+
21+
namespace NHibernate.Action
22+
{
23+
using System.Threading.Tasks;
24+
public abstract partial class CollectionAction : IExecutable, IComparable<CollectionAction>, IDeserializationCallback
25+
{
26+
27+
#region IExecutable Members
28+
29+
/// <summary>Execute this action</summary>
30+
public abstract Task ExecuteAsync();
31+
32+
#endregion
33+
34+
#region IComparable<CollectionAction> Members
35+
36+
#endregion
37+
38+
#region IDeserializationCallback Members
39+
40+
#endregion
41+
}
42+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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 System;
12+
using System.Diagnostics;
13+
using NHibernate.Collection;
14+
using NHibernate.Engine;
15+
using NHibernate.Event;
16+
using NHibernate.Persister.Collection;
17+
18+
namespace NHibernate.Action
19+
{
20+
using System.Threading.Tasks;
21+
public sealed partial class CollectionRecreateAction : CollectionAction
22+
{
23+
24+
/// <summary> Execute this action</summary>
25+
/// <remarks>
26+
/// This method is called when a new non-null collection is persisted
27+
/// or when an existing (non-null) collection is moved to a new owner
28+
/// </remarks>
29+
public override async Task ExecuteAsync()
30+
{
31+
bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled;
32+
Stopwatch stopwatch = null;
33+
if (statsEnabled)
34+
{
35+
stopwatch = Stopwatch.StartNew();
36+
}
37+
IPersistentCollection collection = Collection;
38+
39+
await (PreRecreateAsync()).ConfigureAwait(false);
40+
41+
await (Persister.RecreateAsync(collection, Key, Session)).ConfigureAwait(false);
42+
43+
Session.PersistenceContext.GetCollectionEntry(collection).AfterAction(collection);
44+
45+
Evict();
46+
47+
await (PostRecreateAsync()).ConfigureAwait(false);
48+
if (statsEnabled)
49+
{
50+
stopwatch.Stop();
51+
Session.Factory.StatisticsImplementor.RecreateCollection(Persister.Role, stopwatch.Elapsed);
52+
}
53+
}
54+
55+
private async Task PreRecreateAsync()
56+
{
57+
IPreCollectionRecreateEventListener[] preListeners = Session.Listeners.PreCollectionRecreateEventListeners;
58+
if (preListeners.Length > 0)
59+
{
60+
PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(Persister, Collection, (IEventSource)Session);
61+
for (int i = 0; i < preListeners.Length; i++)
62+
{
63+
await (preListeners[i].OnPreRecreateCollectionAsync(preEvent)).ConfigureAwait(false);
64+
}
65+
}
66+
}
67+
68+
private async Task PostRecreateAsync()
69+
{
70+
IPostCollectionRecreateEventListener[] postListeners = Session.Listeners.PostCollectionRecreateEventListeners;
71+
if (postListeners.Length > 0)
72+
{
73+
PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(Persister, Collection, (IEventSource)Session);
74+
for (int i = 0; i < postListeners.Length; i++)
75+
{
76+
await (postListeners[i].OnPostRecreateCollectionAsync(postEvent)).ConfigureAwait(false);
77+
}
78+
}
79+
}
80+
}
81+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 System;
12+
using System.Diagnostics;
13+
using NHibernate.Collection;
14+
using NHibernate.Engine;
15+
using NHibernate.Event;
16+
using NHibernate.Persister.Collection;
17+
18+
namespace NHibernate.Action
19+
{
20+
using System.Threading.Tasks;
21+
public sealed partial class CollectionRemoveAction : CollectionAction
22+
{
23+
24+
public override async Task ExecuteAsync()
25+
{
26+
bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled;
27+
Stopwatch stopwatch = null;
28+
if (statsEnabled)
29+
{
30+
stopwatch = Stopwatch.StartNew();
31+
}
32+
33+
await (PreRemoveAsync()).ConfigureAwait(false);
34+
35+
if (!emptySnapshot)
36+
{
37+
await (Persister.RemoveAsync(Key, Session)).ConfigureAwait(false);
38+
}
39+
40+
IPersistentCollection collection = Collection;
41+
if (collection != null)
42+
{
43+
Session.PersistenceContext.GetCollectionEntry(collection).AfterAction(collection);
44+
}
45+
46+
Evict();
47+
48+
await (PostRemoveAsync()).ConfigureAwait(false);
49+
50+
if (statsEnabled)
51+
{
52+
stopwatch.Stop();
53+
Session.Factory.StatisticsImplementor.RemoveCollection(Persister.Role, stopwatch.Elapsed);
54+
}
55+
}
56+
57+
private async Task PreRemoveAsync()
58+
{
59+
IPreCollectionRemoveEventListener[] preListeners = Session.Listeners.PreCollectionRemoveEventListeners;
60+
if (preListeners.Length > 0)
61+
{
62+
PreCollectionRemoveEvent preEvent = new PreCollectionRemoveEvent(Persister, Collection, (IEventSource) Session,
63+
affectedOwner);
64+
for (int i = 0; i < preListeners.Length; i++)
65+
{
66+
await (preListeners[i].OnPreRemoveCollectionAsync(preEvent)).ConfigureAwait(false);
67+
}
68+
}
69+
}
70+
71+
private async Task PostRemoveAsync()
72+
{
73+
IPostCollectionRemoveEventListener[] postListeners = Session.Listeners.PostCollectionRemoveEventListeners;
74+
if (postListeners.Length > 0)
75+
{
76+
PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(Persister, Collection, (IEventSource) Session,
77+
affectedOwner);
78+
for (int i = 0; i < postListeners.Length; i++)
79+
{
80+
await (postListeners[i].OnPostRemoveCollectionAsync(postEvent)).ConfigureAwait(false);
81+
}
82+
}
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)