Skip to content

Commit b29ec23

Browse files
authored
Upgrade AsyncGenerator to 0.6.0 (#1426)
1 parent ecd0d36 commit b29ec23

Some content is hidden

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

41 files changed

+1876
-332
lines changed

Tools/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
88
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
99
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
10-
<package id="CSharpAsyncGenerator.CommandLine" version="0.5.1" targetFramework="net461" />
10+
<package id="CSharpAsyncGenerator.CommandLine" version="0.6.0" targetFramework="net461" />
1111
<package id="vswhere" version="2.1.4" targetFramework="net461" />
1212
</packages>

src/AsyncGenerator.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
projects:
2-
- filePath: NHibernate\NHibernate.csproj
2+
- filePath: NHibernate/NHibernate.csproj
33
concurrentRun: true
44
applyChanges: true
55
analyzation:
@@ -152,14 +152,14 @@
152152
assemblyName: AsyncGenerator.Core
153153
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
154154
assemblyName: AsyncGenerator.Core
155-
- filePath: NHibernate.DomainModel\NHibernate.DomainModel.csproj
155+
- filePath: NHibernate.DomainModel/NHibernate.DomainModel.csproj
156156
concurrentRun: true
157157
applyChanges: true
158158
analyzation:
159159
scanMethodBody: true
160160
scanForMissingAsyncMembers:
161161
- all: true
162-
- filePath: NHibernate.Test\NHibernate.Test.csproj
162+
- filePath: NHibernate.Test/NHibernate.Test.csproj
163163
concurrentRun: true
164164
applyChanges: true
165165
analyzation:
@@ -188,6 +188,8 @@
188188
name: ObjectAssert
189189
- conversion: Ignore
190190
name: LinqReadonlyTestsContext
191+
- conversion: Ignore
192+
name: MultiThreadRunner
191193
- conversion: Ignore
192194
hasAttributeName: IgnoreAttribute
193195
- conversion: NewType
@@ -202,9 +204,9 @@
202204
- hasAttributeName: TheoryAttribute
203205
- hasAttributeName: TestAttribute
204206
ignoreDocuments:
205-
- filePathEndsWith: Linq\MathTests.cs
206-
- filePathEndsWith: Linq\ExpressionSessionLeakTest.cs
207-
- filePathEndsWith: Linq\NorthwindDbCreator.cs
207+
- filePathEndsWith: Linq/MathTests.cs
208+
- filePathEndsWith: Linq/ExpressionSessionLeakTest.cs
209+
- filePathEndsWith: Linq/NorthwindDbCreator.cs
208210
cancellationTokens:
209211
withoutCancellationToken:
210212
- hasAttributeName: TestAttribute
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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 System.Threading;
14+
using NHibernate.Cache;
15+
using NHibernate.Cache.Access;
16+
using NUnit.Framework;
17+
18+
namespace NHibernate.Test.CacheTest
19+
{
20+
using System.Threading.Tasks;
21+
[TestFixture]
22+
public class CacheFixtureAsync
23+
{
24+
[Test]
25+
public Task TestSimpleCacheAsync()
26+
{
27+
return DoTestCacheAsync(new HashtableCacheProvider());
28+
}
29+
30+
private CacheKey CreateCacheKey(string text)
31+
{
32+
return new CacheKey(text, NHibernateUtil.String, "Foo", null);
33+
}
34+
35+
public async Task DoTestCacheAsync(ICacheProvider cacheProvider, CancellationToken cancellationToken = default(CancellationToken))
36+
{
37+
ICache cache = cacheProvider.BuildCache(typeof(String).FullName, new Dictionary<string, string>());
38+
39+
long longBefore = Timestamper.Next();
40+
41+
await (Task.Delay(15, cancellationToken));
42+
43+
long before = Timestamper.Next();
44+
45+
await (Task.Delay(15, cancellationToken));
46+
47+
ICacheConcurrencyStrategy ccs = new ReadWriteCache();
48+
ccs.Cache = cache;
49+
50+
// cache something
51+
CacheKey fooKey = CreateCacheKey("foo");
52+
53+
Assert.IsTrue(await (ccs.PutAsync(fooKey, "foo", before, null, null, false, cancellationToken)));
54+
55+
await (Task.Delay(15, cancellationToken));
56+
57+
long after = Timestamper.Next();
58+
59+
Assert.IsNull(await (ccs.GetAsync(fooKey, longBefore, cancellationToken)));
60+
Assert.AreEqual("foo", await (ccs.GetAsync(fooKey, after, cancellationToken)));
61+
Assert.IsFalse(await (ccs.PutAsync(fooKey, "foo", before, null, null, false, cancellationToken)));
62+
63+
// update it;
64+
65+
ISoftLock fooLock = await (ccs.LockAsync(fooKey, null, cancellationToken));
66+
67+
Assert.IsNull(await (ccs.GetAsync(fooKey, after, cancellationToken)));
68+
Assert.IsNull(await (ccs.GetAsync(fooKey, longBefore, cancellationToken)));
69+
Assert.IsFalse(await (ccs.PutAsync(fooKey, "foo", before, null, null, false, cancellationToken)));
70+
71+
await (Task.Delay(15, cancellationToken));
72+
73+
long whileLocked = Timestamper.Next();
74+
75+
Assert.IsFalse(await (ccs.PutAsync(fooKey, "foo", whileLocked, null, null, false, cancellationToken)));
76+
77+
await (Task.Delay(15, cancellationToken));
78+
79+
await (ccs.ReleaseAsync(fooKey, fooLock, cancellationToken));
80+
81+
Assert.IsNull(await (ccs.GetAsync(fooKey, after, cancellationToken)));
82+
Assert.IsNull(await (ccs.GetAsync(fooKey, longBefore, cancellationToken)));
83+
Assert.IsFalse(await (ccs.PutAsync(fooKey, "bar", whileLocked, null, null, false, cancellationToken)));
84+
Assert.IsFalse(await (ccs.PutAsync(fooKey, "bar", after, null, null, false, cancellationToken)));
85+
86+
await (Task.Delay(15, cancellationToken));
87+
88+
long longAfter = Timestamper.Next();
89+
90+
Assert.IsTrue(await (ccs.PutAsync(fooKey, "baz", longAfter, null, null, false, cancellationToken)));
91+
Assert.IsNull(await (ccs.GetAsync(fooKey, after, cancellationToken)));
92+
Assert.IsNull(await (ccs.GetAsync(fooKey, whileLocked, cancellationToken)));
93+
94+
await (Task.Delay(15, cancellationToken));
95+
96+
long longLongAfter = Timestamper.Next();
97+
98+
Assert.AreEqual("baz", await (ccs.GetAsync(fooKey, longLongAfter, cancellationToken)));
99+
100+
// update it again, with multiple locks
101+
102+
ISoftLock fooLock1 = await (ccs.LockAsync(fooKey, null, cancellationToken));
103+
ISoftLock fooLock2 = await (ccs.LockAsync(fooKey, null, cancellationToken));
104+
105+
Assert.IsNull(await (ccs.GetAsync(fooKey, longLongAfter, cancellationToken)));
106+
107+
await (Task.Delay(15, cancellationToken));
108+
109+
whileLocked = Timestamper.Next();
110+
111+
Assert.IsFalse(await (ccs.PutAsync(fooKey, "foo", whileLocked, null, null, false, cancellationToken)));
112+
113+
await (Task.Delay(15, cancellationToken));
114+
115+
await (ccs.ReleaseAsync(fooKey, fooLock2, cancellationToken));
116+
117+
await (Task.Delay(15, cancellationToken));
118+
119+
long betweenReleases = Timestamper.Next();
120+
121+
Assert.IsFalse(await (ccs.PutAsync(fooKey, "bar", betweenReleases, null, null, false, cancellationToken)));
122+
Assert.IsNull(await (ccs.GetAsync(fooKey, betweenReleases, cancellationToken)));
123+
124+
await (Task.Delay(15, cancellationToken));
125+
126+
await (ccs.ReleaseAsync(fooKey, fooLock1, cancellationToken));
127+
128+
Assert.IsFalse(await (ccs.PutAsync(fooKey, "bar", whileLocked, null, null, false, cancellationToken)));
129+
130+
await (Task.Delay(15, cancellationToken));
131+
132+
longAfter = Timestamper.Next();
133+
134+
Assert.IsTrue(await (ccs.PutAsync(fooKey, "baz", longAfter, null, null, false, cancellationToken)));
135+
Assert.IsNull(await (ccs.GetAsync(fooKey, whileLocked, cancellationToken)));
136+
137+
await (Task.Delay(15, cancellationToken));
138+
139+
longLongAfter = Timestamper.Next();
140+
141+
Assert.AreEqual("baz", await (ccs.GetAsync(fooKey, longLongAfter, cancellationToken)));
142+
}
143+
144+
private async Task DoTestMinValueTimestampOnStrategyAsync(ICache cache, ICacheConcurrencyStrategy strategy, CancellationToken cancellationToken = default(CancellationToken))
145+
{
146+
CacheKey key = CreateCacheKey("key");
147+
strategy.Cache = cache;
148+
await (strategy.PutAsync(key, "value", long.MinValue, 0, null, false, cancellationToken));
149+
150+
Assert.IsNull(await (strategy.GetAsync(key, long.MinValue, cancellationToken)), "{0} strategy fails the test", strategy.GetType());
151+
Assert.IsNull(await (strategy.GetAsync(key, long.MaxValue, cancellationToken)), "{0} strategy fails the test", strategy.GetType());
152+
}
153+
154+
[Test]
155+
public async Task MinValueTimestampAsync()
156+
{
157+
ICache cache = new HashtableCacheProvider().BuildCache("region", new Dictionary<string, string>());
158+
ICacheConcurrencyStrategy strategy = new ReadWriteCache();
159+
strategy.Cache = cache;
160+
161+
await (DoTestMinValueTimestampOnStrategyAsync(cache, new ReadWriteCache()));
162+
await (DoTestMinValueTimestampOnStrategyAsync(cache, new NonstrictReadWriteCache()));
163+
await (DoTestMinValueTimestampOnStrategyAsync(cache, new ReadOnlyCache()));
164+
}
165+
}
166+
}

src/NHibernate.Test/Async/EntityModeTest/Map/Basic/DynamicClassFixture.cs

+16
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ protected override IList Mappings
3535
public delegate IDictionary SingleCarQueryDelegate(ISession session);
3636
public delegate IList AllModelQueryDelegate(ISession session);
3737

38+
[Test]
39+
public Task ShouldWorkWithHQLAsync()
40+
{
41+
return TestLazyDynamicClassAsync(
42+
s => (IDictionary) s.CreateQuery("from ProductLine pl order by pl.Description").UniqueResult(),
43+
s => s.CreateQuery("from Model m").List());
44+
}
45+
46+
[Test]
47+
public Task ShouldWorkWithCriteriaAsync()
48+
{
49+
return TestLazyDynamicClassAsync(
50+
s => (IDictionary) s.CreateCriteria("ProductLine").AddOrder(Order.Asc("Description")).UniqueResult(),
51+
s => s.CreateCriteria("Model").List());
52+
}
53+
3854
public async Task TestLazyDynamicClassAsync(SingleCarQueryDelegate singleCarQueryHandler, AllModelQueryDelegate allModelQueryHandler, CancellationToken cancellationToken = default(CancellationToken))
3955
{
4056
ITransaction t;

src/NHibernate.Test/Async/Hql/Ast/BulkManipulation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public async Task IncrementTimestampVersionAsync()
503503

504504
DateTime initialVersion = entity.Version;
505505

506-
Thread.Sleep(1300);
506+
await (Task.Delay(1300));
507507

508508
using (ISession s = OpenSession())
509509
{

0 commit comments

Comments
 (0)