Skip to content

Commit 61df506

Browse files
fredericDelaportehazzik
authored andcommitted
Add missing OperationCanceledException in async code where required
- Update AsyncGenerator to 0.8.2.4 Fixes #1672
1 parent 291d26a commit 61df506

Some content is hidden

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

49 files changed

+66
-434
lines changed

Tools/packages.config

Lines changed: 1 addition & 1 deletion
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.6.0" targetFramework="net461" />
10+
<package id="CSharpAsyncGenerator.CommandLine" version="0.8.2.4" targetFramework="net461" />
1111
<package id="vswhere" version="2.1.4" targetFramework="net461" />
1212
</packages>

src/NHibernate.Test/Async/Cascade/Circle/MultiPathCircleCascadeTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public async Task MergeEntityWithNonNullableEntityNullAsync()
155155
await (session.MergeAsync(route, cancellationToken));
156156
Assert.Fail("should have thrown an exception");
157157
}
158+
catch (OperationCanceledException) { throw; }
158159
catch (Exception ex)
159160
{
160161
Assert.That(ex, Is.TypeOf(typeof(PropertyValueException)));

src/NHibernate.Test/Async/DebugConnectionProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public override async Task<DbConnection> GetConnectionAsync(CancellationToken ca
3030
connections.TryAdd(connection, 0);
3131
return connection;
3232
}
33+
catch (OperationCanceledException) { throw; }
3334
catch (Exception e)
3435
{
3536
throw new HibernateException("Could not open connection to: " + ConnectionString, e);

src/NHibernate.Test/Async/Events/Collections/Association/Bidirectional/ManyToMany/BidirectionalManyToManyBagToSetCollectionEventFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public override Task UpdateParentOneToTwoSameChildrenAsync()
3939
{
4040
Assert.Ignore("Not supported");
4141
return Task.CompletedTask;
42+
// This test need some more deep study if it really work in H3.2
43+
// because <bag> allow duplication.
4244
}
4345
catch (System.Exception ex)
4446
{
4547
return Task.FromException<object>(ex);
4648
}
47-
// This test need some more deep study if it really work in H3.2
48-
// because <bag> allow duplication.
4949
}
5050
}
5151
}

src/NHibernate.Test/Async/ExpressionTest/QueryByExampleTest.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
namespace NHibernate.Test.ExpressionTest
1818
{
1919
using System.Threading.Tasks;
20-
using System.Threading;
2120
[TestFixture]
2221
public class QueryByExampleTestAsync : TestCase
2322
{
@@ -150,30 +149,6 @@ public async Task TestExcludingQBEAsync()
150149
}
151150
}
152151

153-
private async Task InitDataAsync(CancellationToken cancellationToken = default(CancellationToken))
154-
{
155-
using (ISession s = OpenSession())
156-
{
157-
Componentizable master = GetMaster("hibernate", "ORM tool", "ORM tool1");
158-
await (s.SaveAsync(master, cancellationToken));
159-
await (s.FlushAsync(cancellationToken));
160-
}
161-
162-
using (ISession s = OpenSession())
163-
{
164-
Componentizable master = GetMaster("hibernate", "open source", "open source1");
165-
await (s.SaveAsync(master, cancellationToken));
166-
await (s.FlushAsync(cancellationToken));
167-
}
168-
169-
using (ISession s = OpenSession())
170-
{
171-
Componentizable master = GetMaster("hibernate", null, null);
172-
await (s.SaveAsync(master, cancellationToken));
173-
await (s.FlushAsync(cancellationToken));
174-
}
175-
}
176-
177152
private void InitData()
178153
{
179154
using (ISession s = OpenSession())
@@ -198,16 +173,6 @@ private void InitData()
198173
}
199174
}
200175

201-
private async Task DeleteDataAsync(CancellationToken cancellationToken = default(CancellationToken))
202-
{
203-
using (ISession s = OpenSession())
204-
using (ITransaction t = s.BeginTransaction())
205-
{
206-
await (s.DeleteAsync("from Componentizable", cancellationToken));
207-
await (t.CommitAsync(cancellationToken));
208-
}
209-
}
210-
211176
private void DeleteData()
212177
{
213178
using (ISession s = OpenSession())

src/NHibernate.Test/Async/NHSpecificTest/Logs/LogsFixture.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ public async Task WillGetSessionIdFromSessionLogsConcurrentAsync()
156156
var sessionIds = new ConcurrentDictionary<int, Guid>();
157157
using (var spy = new TextLogSpy("NHibernate.SQL", "%message | SessionId: %property{sessionId}"))
158158
{
159-
await (Task.WhenAll(Enumerable.Range( 1, 12).Select( async i =>
159+
await (Task.WhenAll(
160+
Enumerable.Range(1, 12 - 1).Select(async i =>
160161
{
161162
if (i > 10)
162163
{

src/NHibernate.Test/Async/NHSpecificTest/NH1507/Fixture.cs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
namespace NHibernate.Test.NHSpecificTest.NH1507
1717
{
1818
using System.Threading.Tasks;
19-
using System.Threading;
2019
[TestFixture]
2120
public class FixtureAsync : BugTestCase
2221
{
@@ -35,54 +34,6 @@ protected override void OnTearDown()
3534
CleanupData();
3635
}
3736

38-
private async Task CreateDataAsync(CancellationToken cancellationToken = default(CancellationToken))
39-
{
40-
//Employee
41-
var emp = new Employee
42-
{
43-
Address = "Zombie street",
44-
City = "Bitonto",
45-
PostalCode = "66666",
46-
FirstName = "tomb",
47-
LastName = "mutilated"
48-
};
49-
50-
//and his related orders
51-
var order = new Order
52-
{OrderDate = DateTime.Now, Employee = emp, ShipAddress = "dead zone 1", ShipCountry = "Deadville"};
53-
54-
var order2 = new Order
55-
{OrderDate = DateTime.Now, Employee = emp, ShipAddress = "dead zone 2", ShipCountry = "Deadville"};
56-
57-
//Employee with no related orders but with same PostalCode
58-
var emp2 = new Employee
59-
{
60-
Address = "Gut street",
61-
City = "Mariotto",
62-
Country = "Arised",
63-
PostalCode = "66666",
64-
FirstName = "carcass",
65-
LastName = "purulent"
66-
};
67-
68-
//Order with no related employee but with same ShipCountry
69-
var order3 = new Order {OrderDate = DateTime.Now, ShipAddress = "dead zone 2", ShipCountry = "Deadville"};
70-
71-
using (ISession session = OpenSession())
72-
{
73-
using (ITransaction tx = session.BeginTransaction())
74-
{
75-
await (session.SaveAsync(emp, cancellationToken));
76-
await (session.SaveAsync(emp2, cancellationToken));
77-
await (session.SaveAsync(order, cancellationToken));
78-
await (session.SaveAsync(order2, cancellationToken));
79-
await (session.SaveAsync(order3, cancellationToken));
80-
81-
await (tx.CommitAsync(cancellationToken));
82-
}
83-
}
84-
}
85-
8637
private void CreateData()
8738
{
8839
//Employee
@@ -131,23 +82,6 @@ private void CreateData()
13182
}
13283
}
13384

134-
private async Task CleanupDataAsync(CancellationToken cancellationToken = default(CancellationToken))
135-
{
136-
using (ISession session = OpenSession())
137-
{
138-
using (ITransaction tx = session.BeginTransaction())
139-
{
140-
//delete empolyee and related orders
141-
await (session.DeleteAsync("from Employee ee where ee.PostalCode = '66666'", cancellationToken));
142-
143-
//delete order not related to employee
144-
await (session.DeleteAsync("from Order oo where oo.ShipCountry = 'Deadville'", cancellationToken));
145-
146-
await (tx.CommitAsync(cancellationToken));
147-
}
148-
}
149-
}
150-
15185
private void CleanupData()
15286
{
15387
using (ISession session = OpenSession())

src/NHibernate.Test/Async/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,6 @@ protected override bool AppliesTo(ISessionFactoryImplementor factory)
159159
return factory.ConnectionProvider.Driver is SqlClientDriver;
160160
}
161161

162-
private async Task SetAllowSnapshotIsolationAsync(bool on, CancellationToken cancellationToken = default(CancellationToken))
163-
{
164-
using (ISession session = OpenSession())
165-
{
166-
var command = session.Connection.CreateCommand();
167-
command.CommandText = "ALTER DATABASE " + session.Connection.Database + " set allow_snapshot_isolation "
168-
+ (on ? "on" : "off");
169-
await (command.ExecuteNonQueryAsync(cancellationToken));
170-
}
171-
}
172-
173162
private void SetAllowSnapshotIsolation(bool on)
174163
{
175164
using (ISession session = OpenSession())

src/NHibernate.Test/Async/NHSpecificTest/NH1792/Fixture.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
namespace NHibernate.Test.NHSpecificTest.NH1792
1717
{
1818
using System.Threading.Tasks;
19-
using System.Threading;
2019
[TestFixture]
2120
public class FixtureAsync : BugTestCase
2221
{
@@ -25,22 +24,6 @@ protected override void OnTearDown()
2524
DeleteAll();
2625
}
2726

28-
/// <summary>
29-
/// Deletes all the product entities from the persistence medium
30-
/// </summary>
31-
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
32-
private async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken))
33-
{
34-
using (ISession session = OpenSession())
35-
{
36-
using (ITransaction trans = session.BeginTransaction())
37-
{
38-
await (session.DeleteAsync("from Product", cancellationToken));
39-
await (trans.CommitAsync(cancellationToken));
40-
}
41-
}
42-
}
43-
4427
/// <summary>
4528
/// Deletes all the product entities from the persistence medium
4629
/// </summary>

src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
namespace NHibernate.Test.NHSpecificTest.NH2302
1818
{
1919
using System.Threading.Tasks;
20-
using System.Threading;
2120
[TestFixture]
2221
public class FixtureAsync : BugTestCase
2322
{
@@ -197,16 +196,6 @@ public async Task BlobWithoutLengthAsync()
197196
}
198197
}
199198

200-
private async Task CleanUpAsync(CancellationToken cancellationToken = default(CancellationToken))
201-
{
202-
using (ISession session = OpenSession())
203-
using (ITransaction tx = session.BeginTransaction())
204-
{
205-
await (session.DeleteAsync("from StringLengthEntity", cancellationToken));
206-
await (tx.CommitAsync(cancellationToken));
207-
}
208-
}
209-
210199
private void CleanUp()
211200
{
212201
using (ISession session = OpenSession())

src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,6 @@ protected override void OnTearDown()
305305
}
306306
}
307307

308-
private static Task DeleteAllAsync<T>(ISession session, CancellationToken cancellationToken = default(CancellationToken))
309-
{
310-
try
311-
{
312-
return session.CreateQuery("delete from " + typeof(T).Name).ExecuteUpdateAsync(cancellationToken);
313-
}
314-
catch (Exception ex)
315-
{
316-
return Task.FromException<object>(ex);
317-
}
318-
}
319-
320308
private static void DeleteAll<T>(ISession session)
321309
{
322310
session.CreateQuery("delete from " + typeof(T).Name).ExecuteUpdate();

src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -273,34 +273,6 @@ private static TransactionScope CreateDistributedTransactionScope()
273273
return scope;
274274
}
275275

276-
private async Task RunScriptAsync(string script, CancellationToken cancellationToken = default(CancellationToken))
277-
{
278-
var cxnString = cfg.Properties["connection.connection_string"] + "; Pooling=No";
279-
// Disable connection pooling so this won't be hindered by
280-
// problems encountered during the actual test
281-
282-
string sql;
283-
using (var reader = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + "." + script)))
284-
{
285-
sql = await (reader.ReadToEndAsync());
286-
}
287-
288-
using (var cxn = new SqlConnection(cxnString))
289-
{
290-
await (cxn.OpenAsync(cancellationToken));
291-
292-
foreach (var batch in Regex.Split(sql, @"^go\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline)
293-
.Where(b => !string.IsNullOrEmpty(b)))
294-
{
295-
296-
using (var cmd = new System.Data.SqlClient.SqlCommand(batch, cxn))
297-
{
298-
await (cmd.ExecuteNonQueryAsync(cancellationToken));
299-
}
300-
}
301-
}
302-
}
303-
304276
private void RunScript(string script)
305277
{
306278
var cxnString = cfg.Properties["connection.connection_string"] + "; Pooling=No";

0 commit comments

Comments
 (0)