Skip to content

Commit 1cb4e08

Browse files
committed
Async regen
1 parent 739ec44 commit 1cb4e08

15 files changed

+38
-341
lines changed

src/NHibernate.Test/Async/GenericTest/Methods/Fixture.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,6 @@ public async Task QueryListAsync()
102102
}
103103
}
104104

105-
[Test]
106-
public async Task QueryEnumerableAsync()
107-
{
108-
using (var s = OpenSession())
109-
using (var t = s.BeginTransaction())
110-
{
111-
var results = s.CreateQuery("from One").AsyncEnumerable<One>();
112-
var enumerator = results.GetAsyncEnumerator();
113-
114-
Assert.That(await enumerator.MoveNextAsync(), Is.True);
115-
Assert.That(await enumerator.MoveNextAsync(), Is.False);
116-
}
117-
}
118-
119105
[Test]
120106
public async Task FilterAsync()
121107
{
@@ -131,22 +117,5 @@ public async Task FilterAsync()
131117
await (t.CommitAsync());
132118
}
133119
}
134-
135-
[Test]
136-
public async Task FilterEnumerableAsync()
137-
{
138-
using (var s = OpenSession())
139-
using (var t = s.BeginTransaction())
140-
{
141-
One one2 = (One) await s.CreateQuery("from One").UniqueResultAsync();
142-
var results = s.CreateFilter(one2.Manies, "where X = 10").AsyncEnumerable<Many>();
143-
var en = results.GetAsyncEnumerator();
144-
145-
Assert.That(await en.MoveNextAsync(), Is.True);
146-
Assert.That(en.Current.X, Is.EqualTo(10));
147-
Assert.That(await en.MoveNextAsync(), Is.False);
148-
await t.CommitAsync();
149-
}
150-
}
151120
}
152121
}

src/NHibernate.Test/Async/ReadOnly/ReadOnlySessionTest.cs

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -385,46 +385,6 @@ public async Task QueryReadOnlyIterateAsync()
385385
}
386386
}
387387

388-
[Test]
389-
public async Task QueryReadOnlyAsyncIterate()
390-
{
391-
int nExpectedChanges = 0;
392-
QueryIterateCreate(out var lastDataPointId);
393-
394-
using (ISession s = OpenSession())
395-
{
396-
s.CacheMode = CacheMode.Ignore;
397-
398-
using (ITransaction t = s.BeginTransaction())
399-
{
400-
s.DefaultReadOnly = false;
401-
402-
IQuery query = s.CreateQuery("from DataPoint dp order by dp.X asc");
403-
QueryReadOnlyIterateAssertReadOnly(query, s);
404-
405-
var it = query.AsyncEnumerable<DataPoint>().GetAsyncEnumerator();
406-
Assert.That(query.IsReadOnly, Is.True);
407-
DataPoint dpLast = s.Get<DataPoint>(lastDataPointId);
408-
Assert.That(s.IsReadOnly(dpLast), Is.False);
409-
query.SetReadOnly(false);
410-
Assert.That(query.IsReadOnly, Is.False);
411-
Assert.That(s.DefaultReadOnly, Is.False);
412-
413-
int i = 0;
414-
while (await it.MoveNextAsync())
415-
{
416-
QueryReadOnlyIterateAssertRow(s, it.Current, dpLast, ref i, ref nExpectedChanges);
417-
}
418-
419-
Assert.That(s.DefaultReadOnly, Is.False);
420-
421-
t.Commit();
422-
}
423-
424-
QueryIterateClear(s, nExpectedChanges);
425-
}
426-
}
427-
428388
private void QueryReadOnlyIterateAssertReadOnly(IQuery query, ISession s)
429389
{
430390
Assert.That(query.IsReadOnly, Is.False);
@@ -510,45 +470,6 @@ public async Task QueryModifiableIterateAsync()
510470
}
511471
}
512472

513-
[Test]
514-
public async Task QueryModifiableAsyncIterate()
515-
{
516-
int nExpectedChanges = 0;
517-
QueryIterateCreate(out var lastDataPointId);
518-
519-
using (ISession s = OpenSession())
520-
{
521-
s.CacheMode = CacheMode.Ignore;
522-
523-
using (ITransaction t = s.BeginTransaction())
524-
{
525-
s.DefaultReadOnly = true;
526-
527-
IQuery query = s.CreateQuery("from DataPoint dp order by dp.X asc");
528-
QueryModifiableIterateAssertReadOnly(query, s);
529-
530-
var it = query.AsyncEnumerable<DataPoint>().GetAsyncEnumerator();
531-
Assert.That(query.IsReadOnly, Is.False);
532-
DataPoint dpLast = s.Get<DataPoint>(lastDataPointId);
533-
Assert.That(s.IsReadOnly(dpLast), Is.True);
534-
query.SetReadOnly(true);
535-
Assert.That(query.IsReadOnly, Is.True);
536-
Assert.That(s.DefaultReadOnly, Is.True);
537-
538-
int i = 0;
539-
while (await it.MoveNextAsync())
540-
{
541-
QueryModifiableIterateAssertRow(s, it.Current, dpLast, ref i, ref nExpectedChanges);
542-
}
543-
544-
Assert.That(s.DefaultReadOnly, Is.True);
545-
t.Commit();
546-
}
547-
548-
QueryIterateClear(s, nExpectedChanges);
549-
}
550-
}
551-
552473
private void QueryModifiableIterateAssertReadOnly(IQuery query, ISession s)
553474
{
554475
Assert.That(query.IsReadOnly, Is.True);
@@ -641,26 +562,6 @@ private void QueryIterateCreate(out long lastDataPointId)
641562
}
642563
}
643564

644-
private void QueryIterateClear(ISession s, int nExpectedChanges)
645-
{
646-
s.Clear();
647-
using (ITransaction t = s.BeginTransaction())
648-
{
649-
try
650-
{
651-
IList single = s.CreateQuery("from DataPoint where Description = 'done!'").List();
652-
Assert.That(single.Count, Is.EqualTo(nExpectedChanges));
653-
}
654-
finally
655-
{
656-
// cleanup
657-
s.CreateQuery("delete from DataPoint").ExecuteUpdate();
658-
}
659-
660-
t.Commit();
661-
}
662-
}
663-
664565
[Test]
665566
public async Task ReadOnlyRefreshAsync()
666567
{

src/NHibernate/Async/Collection/Generic/PersistentGenericBag.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,7 @@ public override Task<IEnumerable> GetDeletesAsync(ICollectionPersister persister
7777
}
7878

7979
//Since 5.3
80-
/// <summary>
81-
/// Get all "orphaned" elements
82-
/// </summary>
83-
/// <param name="snapshot">The snapshot of the collection.</param>
84-
/// <param name="entityName">The persistent class whose objects
85-
/// the collection is expected to contain.</param>
86-
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
87-
/// <returns>
88-
/// An <see cref="ICollection"/> that contains all of the elements
89-
/// that have been orphaned.
90-
/// </returns>
80+
/// <inheritdoc />
9181
[Obsolete("This method has no more usages and will be removed in a future version")]
9282
public override Task<ICollection> GetOrphansAsync(object snapshot, string entityName, CancellationToken cancellationToken)
9383
{
@@ -97,8 +87,7 @@ public override Task<ICollection> GetOrphansAsync(object snapshot, string entity
9787
}
9888
try
9989
{
100-
var sn = (ICollection) snapshot;
101-
return Task.FromResult<ICollection>(GetOrphans(sn, (ICollection) _gbag, entityName, Session));
90+
return Task.FromResult<ICollection>(GetOrphans(snapshot, entityName));
10291
}
10392
catch (Exception ex)
10493
{

src/NHibernate/Async/Collection/Generic/PersistentGenericIdentifierBag.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,7 @@ public override async Task<object> ReadFromAsync(DbDataReader reader, ICollectio
157157
}
158158

159159
//Since 5.3
160-
/// <summary>
161-
/// Get all "orphaned" elements
162-
/// </summary>
163-
/// <param name="snapshot">The snapshot of the collection.</param>
164-
/// <param name="entityName">The persistent class whose objects
165-
/// the collection is expected to contain.</param>
166-
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
167-
/// <returns>
168-
/// An <see cref="ICollection"/> that contains all of the elements
169-
/// that have been orphaned.
170-
/// </returns>
160+
/// <inheritdoc />
171161
[Obsolete("This method has no more usages and will be removed in a future version")]
172162
public override Task<ICollection> GetOrphansAsync(object snapshot, string entityName, CancellationToken cancellationToken)
173163
{
@@ -177,8 +167,7 @@ public override Task<ICollection> GetOrphansAsync(object snapshot, string entity
177167
}
178168
try
179169
{
180-
var sn = (ISet<SnapshotElement>)GetSnapshot();
181-
return Task.FromResult<ICollection>(GetOrphans(sn.ToArray(x => x.Value), (ICollection) _values, entityName, Session));
170+
return Task.FromResult<ICollection>(GetOrphans(snapshot, entityName));
182171
}
183172
catch (Exception ex)
184173
{

src/NHibernate/Async/Collection/Generic/PersistentGenericList.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,7 @@ public partial class PersistentGenericList<T> : AbstractPersistentCollection, IL
3131
{
3232

3333
//Since 5.3
34-
/// <summary>
35-
/// Get all "orphaned" elements
36-
/// </summary>
37-
/// <param name="snapshot">The snapshot of the collection.</param>
38-
/// <param name="entityName">The persistent class whose objects
39-
/// the collection is expected to contain.</param>
40-
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
41-
/// <returns>
42-
/// An <see cref="ICollection"/> that contains all of the elements
43-
/// that have been orphaned.
44-
/// </returns>
34+
/// <inheritdoc />
4535
[Obsolete("This method has no more usages and will be removed in a future version")]
4636
public override Task<ICollection> GetOrphansAsync(object snapshot, string entityName, CancellationToken cancellationToken)
4737
{
@@ -51,8 +41,7 @@ public override Task<ICollection> GetOrphansAsync(object snapshot, string entity
5141
}
5242
try
5343
{
54-
var sn = (IList<T>)snapshot;
55-
return Task.FromResult<ICollection>(GetOrphans((ICollection)sn, (ICollection) WrappedList, entityName, Session));
44+
return Task.FromResult<ICollection>(GetOrphans(snapshot, entityName));
5645
}
5746
catch (Exception ex)
5847
{

src/NHibernate/Async/Collection/Generic/PersistentGenericMap.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,7 @@ public partial class PersistentGenericMap<TKey, TValue> : AbstractPersistentColl
3131
{
3232

3333
//Since 5.3
34-
/// <summary>
35-
/// Get all "orphaned" elements
36-
/// </summary>
37-
/// <param name="snapshot">The snapshot of the collection.</param>
38-
/// <param name="entityName">The persistent class whose objects
39-
/// the collection is expected to contain.</param>
40-
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
41-
/// <returns>
42-
/// An <see cref="ICollection"/> that contains all of the elements
43-
/// that have been orphaned.
44-
/// </returns>
34+
/// <inheritdoc />
4535
[Obsolete("This method has no more usages and will be removed in a future version")]
4636
public override Task<ICollection> GetOrphansAsync(object snapshot, string entityName, CancellationToken cancellationToken)
4737
{
@@ -51,8 +41,7 @@ public override Task<ICollection> GetOrphansAsync(object snapshot, string entity
5141
}
5242
try
5343
{
54-
var sn = (IDictionary<TKey, TValue>) snapshot;
55-
return Task.FromResult<ICollection>(GetOrphans((ICollection)sn.Values, (ICollection)WrappedMap.Values, entityName, Session));
44+
return Task.FromResult<ICollection>(GetOrphans(snapshot, entityName));
5645
}
5746
catch (Exception ex)
5847
{

src/NHibernate/Async/Collection/Generic/PersistentGenericSet.cs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,7 @@ public partial class PersistentGenericSet<T> : AbstractPersistentCollection, ISe
3232
{
3333

3434
//Since 5.3
35-
/// <summary>
36-
/// Get all "orphaned" elements
37-
/// </summary>
38-
/// <param name="snapshot">The snapshot of the collection.</param>
39-
/// <param name="entityName">The persistent class whose objects
40-
/// the collection is expected to contain.</param>
41-
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
42-
/// <returns>
43-
/// An <see cref="ICollection"/> that contains all of the elements
44-
/// that have been orphaned.
45-
/// </returns>
35+
/// <inheritdoc />
4636
[Obsolete("This method has no more usages and will be removed in a future version")]
4737
public override Task<ICollection> GetOrphansAsync(object snapshot, string entityName, CancellationToken cancellationToken)
4838
{
@@ -52,12 +42,7 @@ public override Task<ICollection> GetOrphansAsync(object snapshot, string entity
5242
}
5343
try
5444
{
55-
var sn = new SetSnapShot<T>((IEnumerable<T>)snapshot);
56-
57-
// TODO: Avoid duplicating shortcuts and array copy, by making base class GetOrphans() more flexible
58-
if (WrappedSet.Count == 0) return Task.FromResult<ICollection>(sn);
59-
if (((ICollection)sn).Count == 0) return Task.FromResult<ICollection>(sn);
60-
return Task.FromResult<ICollection>(GetOrphans(sn, WrappedSet.ToArray(), entityName, Session));
45+
return Task.FromResult<ICollection>(GetOrphans(snapshot, entityName));
6146
}
6247
catch (Exception ex)
6348
{

src/NHibernate/Async/Collection/PersistentArrayHolder.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,7 @@ public partial class PersistentArrayHolder : AbstractPersistentCollection, IColl
2828
{
2929

3030
//Since 5.3
31-
/// <summary>
32-
/// Get all "orphaned" elements
33-
/// </summary>
34-
/// <param name="snapshot">The snapshot of the collection.</param>
35-
/// <param name="entityName">The persistent class whose objects
36-
/// the collection is expected to contain.</param>
37-
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
38-
/// <returns>
39-
/// An <see cref="ICollection"/> that contains all of the elements
40-
/// that have been orphaned.
41-
/// </returns>
31+
/// <inheritdoc />
4232
[Obsolete("This method has no more usages and will be removed in a future version")]
4333
public override Task<ICollection> GetOrphansAsync(object snapshot, string entityName, CancellationToken cancellationToken)
4434
{
@@ -48,7 +38,7 @@ public override Task<ICollection> GetOrphansAsync(object snapshot, string entity
4838
}
4939
try
5040
{
51-
return Task.FromResult<ICollection>(GetOrphans((object[]) snapshot, (object[]) array, entityName, Session));
41+
return Task.FromResult<ICollection>(GetOrphans(snapshot, entityName));
5242
}
5343
catch (Exception ex)
5444
{

src/NHibernate/Async/Engine/Query/HQLQueryPlan.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public async Task PerformListAsync(QueryParameters queryParameters, ISessionImpl
9797
}
9898
}
9999
// Since v5.3
100+
/// <inheritdoc />
100101
[Obsolete("This method has no more usages and will be removed in a future version")]
101102
public Task<IEnumerable> PerformIterateAsync(QueryParameters queryParameters, IEventSource session, CancellationToken cancellationToken)
102103
{
@@ -114,6 +115,7 @@ public Task<IEnumerable> PerformIterateAsync(QueryParameters queryParameters, IE
114115
}
115116
}
116117
// Since v5.3
118+
/// <inheritdoc />
117119
[Obsolete("This method has no more usages and will be removed in a future version")]
118120
public async Task<IEnumerable<T>> PerformIterateAsync<T>(QueryParameters queryParameters, IEventSource session, CancellationToken cancellationToken)
119121
{

0 commit comments

Comments
 (0)