Skip to content

Commit 86a1979

Browse files
committed
Upgrade to AsyncGenerator 0.8.2.6
- Enable AlwaysAwait for test methods.
1 parent df7fb3a commit 86a1979

Some content is hidden

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

52 files changed

+637
-1527
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ current-test-configuration
1313
NHibernate.dll
1414
TestResult.xml
1515
.vscode
16+
.DS_Store

Tools/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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.8.2.4" targetFramework="net461" />
10+
<package id="CSharpAsyncGenerator.CommandLine" version="0.8.2.6" targetFramework="net461" />
1111
<package id="vswhere" version="2.1.4" targetFramework="net461" />
1212
<package id="gitreleasemanager" version="0.7.0" targetFramework="net461" />
1313
</packages>

src/AsyncGenerator.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@
189189
preserveReturnType:
190190
- hasAttributeName: TestAttribute
191191
- hasAttributeName: TheoryAttribute
192+
alwaysAwait:
193+
- hasAttributeName: TestAttribute
194+
- hasAttributeName: TheoryAttribute
195+
- hasAttributeName: SetUpAttribute
196+
- hasAttributeName: TearDownAttribute
192197
typeConversion:
193198
- conversion: Ignore
194199
name: ObjectAssert

src/NHibernate.Test/Async/CacheTest/CacheFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ namespace NHibernate.Test.CacheTest
2222
public class CacheFixtureAsync
2323
{
2424
[Test]
25-
public Task TestSimpleCacheAsync()
25+
public async Task TestSimpleCacheAsync()
2626
{
27-
return DoTestCacheAsync(new HashtableCacheProvider());
27+
await (DoTestCacheAsync(new HashtableCacheProvider()));
2828
}
2929

3030
private CacheKey CreateCacheKey(string text)

src/NHibernate.Test/Async/CfgTest/ConfigurationFixture.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ public async Task ManualConfigurationAsync()
6565
/// <see cref="Configuration" /> works as intended.
6666
/// </summary>
6767
[Test]
68-
public Task SetDefaultAssemblyAndNamespaceAsync()
68+
public async Task SetDefaultAssemblyAndNamespaceAsync()
6969
{
70-
try
71-
{
72-
string hbmFromDomainModel =
70+
string hbmFromDomainModel =
7371
@"<?xml version='1.0' ?>
7472
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
7573
<class name='A'>
@@ -79,7 +77,7 @@ public Task SetDefaultAssemblyAndNamespaceAsync()
7977
</class>
8078
</hibernate-mapping>";
8179

82-
string hbmFromTest =
80+
string hbmFromTest =
8381
@"<?xml version='1.0' ?>
8482
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
8583
<class name='LocatedInTestAssembly' lazy='false'>
@@ -89,23 +87,18 @@ public Task SetDefaultAssemblyAndNamespaceAsync()
8987
</class>
9088
</hibernate-mapping>";
9189

92-
Configuration cfg = new Configuration();
93-
cfg
90+
Configuration cfg = new Configuration();
91+
cfg
9492
.SetDefaultAssembly("NHibernate.DomainModel")
9593
.SetDefaultNamespace("NHibernate.DomainModel")
9694
.AddXmlString(hbmFromDomainModel);
9795

98-
cfg
96+
cfg
9997
.SetDefaultAssembly("NHibernate.Test")
10098
.SetDefaultNamespace(typeof(LocatedInTestAssembly).Namespace)
10199
.AddXmlString(hbmFromTest);
102100

103-
return cfg.BuildSessionFactory().CloseAsync();
104-
}
105-
catch (Exception ex)
106-
{
107-
return Task.FromException<object>(ex);
108-
}
101+
await (cfg.BuildSessionFactory().CloseAsync());
109102
}
110103

111104
public class SampleQueryProvider : DefaultQueryProvider

src/NHibernate.Test/Async/Criteria/DetachedCriteriaSerializable.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,11 @@ protected override IList Mappings
4646
}
4747

4848
[Test]
49-
public Task DetachedCriteriaItSelfAsync()
49+
public async Task DetachedCriteriaItSelfAsync()
5050
{
51-
try
52-
{
53-
DetachedCriteria dc = DetachedCriteria.For(typeof(Student))
51+
DetachedCriteria dc = DetachedCriteria.For(typeof(Student))
5452
.Add(Expression.Eq("Name", "Gavin King"));
55-
return SerializeAndListAsync(dc);
56-
}
57-
catch (Exception ex)
58-
{
59-
return Task.FromException<object>(ex);
60-
}
53+
await (SerializeAndListAsync(dc));
6154
}
6255

6356
[Test]

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ protected override IList Mappings
3636
public delegate IList AllModelQueryDelegate(ISession session);
3737

3838
[Test]
39-
public Task ShouldWorkWithHQLAsync()
39+
public async Task ShouldWorkWithHQLAsync()
4040
{
41-
return TestLazyDynamicClassAsync(
41+
await (TestLazyDynamicClassAsync(
4242
s => (IDictionary) s.CreateQuery("from ProductLine pl order by pl.Description").UniqueResult(),
43-
s => s.CreateQuery("from Model m").List());
43+
s => s.CreateQuery("from Model m").List()));
4444
}
4545

4646
[Test]
47-
public Task ShouldWorkWithCriteriaAsync()
47+
public async Task ShouldWorkWithCriteriaAsync()
4848
{
49-
return TestLazyDynamicClassAsync(
49+
await (TestLazyDynamicClassAsync(
5050
s => (IDictionary) s.CreateCriteria("ProductLine").AddOrder(Order.Asc("Description")).UniqueResult(),
51-
s => s.CreateCriteria("Model").List());
51+
s => s.CreateCriteria("Model").List()));
5252
}
5353

5454
public async Task TestLazyDynamicClassAsync(SingleCarQueryDelegate singleCarQueryHandler, AllModelQueryDelegate allModelQueryHandler, CancellationToken cancellationToken = default(CancellationToken))

src/NHibernate.Test/Async/Legacy/SQLLoaderTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,16 @@ public async Task EmbeddedCompositePropertiesAsync()
439439
}
440440

441441
[Test]
442-
public Task ComponentStarAsync()
442+
public async Task ComponentStarAsync()
443443
{
444-
return ComponentTestAsync("select {comp.*} from Componentizable comp");
444+
await (ComponentTestAsync("select {comp.*} from Componentizable comp"));
445445
}
446446

447447
[Test]
448-
public Task ComponentNoStarAsync()
448+
public async Task ComponentNoStarAsync()
449449
{
450-
return ComponentTestAsync(
451-
"select comp.Id as {comp.id}, comp.nickName as {comp.NickName}, comp.Name as {comp.Component.Name}, comp.SubName as {comp.Component.SubComponent.SubName}, comp.SubName1 as {comp.Component.SubComponent.SubName1} from Componentizable comp");
450+
await (ComponentTestAsync(
451+
"select comp.Id as {comp.id}, comp.nickName as {comp.NickName}, comp.Name as {comp.Component.Name}, comp.SubName as {comp.Component.SubComponent.SubName}, comp.SubName1 as {comp.Component.SubComponent.SubName1} from Componentizable comp"));
452452
}
453453

454454
private async Task ComponentTestAsync(string sql, CancellationToken cancellationToken = default(CancellationToken))

src/NHibernate.Test/Async/Linq/ByMethod/GroupByTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -904,19 +904,12 @@ public override int GetHashCode()
904904

905905

906906
[Test(Description = "NH-3446"), KnownBug("NH-3446", "NHibernate.HibernateException")]
907-
public Task GroupByOrderByKeySelectToClassAsync()
907+
public async Task GroupByOrderByKeySelectToClassAsync()
908908
{
909-
try
910-
{
911-
return db.Products.GroupBy(x => x.Supplier.CompanyName)
909+
await (db.Products.GroupBy(x => x.Supplier.CompanyName)
912910
.OrderBy(x => x.Key)
913911
.Select(x => new GroupInfo {Key = x.Key, ItemCount = x.Count(), HasSubgroups = false, Items = x})
914-
.ToListAsync();
915-
}
916-
catch (Exception ex)
917-
{
918-
return Task.FromException<object>(ex);
919-
}
912+
.ToListAsync());
920913
}
921914

922915
private class GroupInfo

src/NHibernate.Test/Async/Linq/ByMethod/OrderByTests.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -232,29 +232,15 @@ orderby order.ShippingDate descending
232232
}
233233

234234
[Test(Description = "NH-3217")]
235-
public Task OrderByNullCompareAndSkipAndTakeAsync()
235+
public async Task OrderByNullCompareAndSkipAndTakeAsync()
236236
{
237-
try
238-
{
239-
return db.Orders.OrderBy(o => o.Shipper == null ? 0 : o.Shipper.ShipperId).Skip(3).Take(4).ToListAsync();
240-
}
241-
catch (System.Exception ex)
242-
{
243-
return Task.FromException<object>(ex);
244-
}
237+
await (db.Orders.OrderBy(o => o.Shipper == null ? 0 : o.Shipper.ShipperId).Skip(3).Take(4).ToListAsync());
245238
}
246239

247240
[Test(Description = "NH-3445"), KnownBug("NH-3445")]
248-
public Task OrderByWithSelectDistinctAndTakeAsync()
241+
public async Task OrderByWithSelectDistinctAndTakeAsync()
249242
{
250-
try
251-
{
252-
return db.Orders.Select(o => o.ShippedTo).Distinct().OrderBy(o => o).Take(1000).ToListAsync();
253-
}
254-
catch (System.Exception ex)
255-
{
256-
return Task.FromException<object>(ex);
257-
}
243+
await (db.Orders.Select(o => o.ShippedTo).Distinct().OrderBy(o => o).Take(1000).ToListAsync());
258244
}
259245
}
260246
}

0 commit comments

Comments
 (0)