Skip to content

Commit 0c4507d

Browse files
maca88hazzik
authored andcommitted
Removed ASYNC directive as .NET 4 is not supported anymore and added nuget package System.Interactive.Async that will be used by the async Future methods
1 parent 8a36461 commit 0c4507d

20 files changed

+9
-62
lines changed

src/NHibernate/AdoNet/ResultSetWrapper.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
using System.Collections;
33
using System.Data;
44
using System.Data.Common;
5-
#if ASYNC
65
using System.Threading;
76
using System.Threading.Tasks;
8-
#endif
97

108
namespace NHibernate.AdoNet
119
{
@@ -51,7 +49,6 @@ public override bool Read()
5149
return rs.Read();
5250
}
5351

54-
#if ASYNC
5552
public override Task<bool> ReadAsync(CancellationToken cancellationToken)
5653
{
5754
return rs.ReadAsync(cancellationToken);
@@ -66,7 +63,6 @@ public override Task<bool> IsDBNullAsync(int ordinal, CancellationToken cancella
6663
{
6764
return rs.IsDBNullAsync(ordinal, cancellationToken);
6865
}
69-
#endif
7066

7167
public override int Depth
7268
{

src/NHibernate/Criterion/QueryOver.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ private IFutureValue<U> FutureValue<U>()
102102
return criteria.FutureValue<U>();
103103
}
104104

105-
#if ASYNC
106105
private IAsyncEnumerable<TRoot> FutureAsync()
107106
{
108107
return criteria.FutureAsync<TRoot>();
@@ -122,7 +121,6 @@ private IFutureValueAsync<U> FutureValueAsync<U>()
122121
{
123122
return criteria.FutureValueAsync<U>();
124123
}
125-
#endif
126124

127125
/// <summary>
128126
/// Get an executable instance of <c>IQueryOver&lt;TRoot&gt;</c>,
@@ -268,7 +266,6 @@ IFutureValue<TRoot> IQueryOver<TRoot>.FutureValue()
268266
IFutureValue<U> IQueryOver<TRoot>.FutureValue<U>()
269267
{ return FutureValue<U>(); }
270268

271-
#if ASYNC
272269
IAsyncEnumerable<TRoot> IQueryOver<TRoot>.FutureAsync()
273270
{ return FutureAsync(); }
274271

@@ -280,7 +277,6 @@ IFutureValueAsync<TRoot> IQueryOver<TRoot>.FutureValueAsync()
280277

281278
IFutureValueAsync<U> IQueryOver<TRoot>.FutureValueAsync<U>()
282279
{ return FutureValueAsync<U>(); }
283-
#endif
284280

285281
IQueryOver<TRoot,TRoot> IQueryOver<TRoot>.Clone()
286282
{ return Clone(); }

src/NHibernate/Driver/BasicResultSetsCommand.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
using NHibernate.Engine;
88
using NHibernate.SqlCommand;
99
using NHibernate.SqlTypes;
10-
#if ASYNC
1110
using System.Threading;
1211
using System.Threading.Tasks;
13-
#endif
1412

1513
namespace NHibernate.Driver
1614
{
@@ -277,7 +275,6 @@ public override bool Read()
277275
return reader.Read();
278276
}
279277

280-
#if ASYNC
281278
public override Task<bool> ReadAsync(CancellationToken cancellationToken)
282279
{
283280
return reader.ReadAsync(cancellationToken);
@@ -292,7 +289,6 @@ public override Task<bool> NextResultAsync(CancellationToken cancellationToken)
292289
{
293290
return reader.NextResultAsync(cancellationToken);
294291
}
295-
#endif
296292

297293
public override int Depth
298294
{

src/NHibernate/Driver/NDataReader.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
using System.Data;
55
using System.Data.Common;
66
using NHibernate.Util;
7-
#if ASYNC
87
using System.Threading;
98
using System.Threading.Tasks;
10-
#endif
119

1210
namespace NHibernate.Driver
1311
{
@@ -165,7 +163,6 @@ public override bool Read()
165163
return true;
166164
}
167165

168-
#if ASYNC
169166
public override Task<bool> ReadAsync(CancellationToken cancellationToken)
170167
{
171168
return Task.FromResult(Read());
@@ -180,7 +177,6 @@ public override Task<bool> IsDBNullAsync(int ordinal, CancellationToken cancella
180177
{
181178
return Task.FromResult(IsDBNull(ordinal));
182179
}
183-
#endif
184180

185181
/// <summary></summary>
186182
public override int Depth

src/NHibernate/Driver/NHybridDataReader.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
using System.Collections;
33
using System.Data;
44
using System.Data.Common;
5-
#if ASYNC
65
using System.Threading;
76
using System.Threading.Tasks;
8-
#endif
97

108
namespace NHibernate.Driver
119
{
@@ -130,7 +128,6 @@ public override bool Read()
130128
return _isMidstream;
131129
}
132130

133-
#if ASYNC
134131
public override async Task<bool> ReadAsync(CancellationToken cancellationToken)
135132
{
136133
_isMidstream = await _reader.ReadAsync(cancellationToken);
@@ -147,7 +144,6 @@ public override Task<bool> IsDBNullAsync(int ordinal, CancellationToken cancella
147144
{
148145
return _reader.IsDBNullAsync(ordinal, cancellationToken);
149146
}
150-
#endif
151147

152148
/// <summary></summary>
153149
public override int Depth

src/NHibernate/ICriteria.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ public interface ICriteria : ICloneable
315315
/// <returns></returns>
316316
IFutureValue<T> FutureValue<T>();
317317

318-
#if ASYNC
319318
/// <summary>
320319
/// Get a enumerable that when enumerated will execute
321320
/// a batch of queries in a single database roundtrip
@@ -333,7 +332,6 @@ public interface ICriteria : ICloneable
333332
/// <typeparam name="T"></typeparam>
334333
/// <returns></returns>
335334
IFutureValueAsync<T> FutureValueAsync<T>();
336-
#endif
337335

338336
/// <summary>
339337
/// Set the read-only mode for entities (and proxies) loaded by this Criteria. This

src/NHibernate/IFutureValueAsync.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if ASYNC
21
using System.Threading.Tasks;
32

43
namespace NHibernate
@@ -8,4 +7,3 @@ public interface IFutureValueAsync<T>
87
Task<T> GetValue();
98
}
109
}
11-
#endif

src/NHibernate/IQuery.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,6 @@ public interface IQuery
635635
/// <returns></returns>
636636
IFutureValue<T> FutureValue<T>();
637637

638-
#if ASYNC
639638
/// <summary>
640639
/// Get a enumerable that when enumerated will execute
641640
/// a batch of queries in a single database roundtrip
@@ -653,6 +652,5 @@ public interface IQuery
653652
/// <typeparam name="T"></typeparam>
654653
/// <returns></returns>
655654
IFutureValueAsync<T> FutureValueAsync<T>();
656-
#endif
657655
}
658656
}

src/NHibernate/IQueryOver.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ public interface IQueryOver<TRoot> : IQueryOver
115115
/// </summary>
116116
IFutureValue<U> FutureValue<U>();
117117

118-
#if ASYNC
119118
/// <summary>
120119
/// Get a enumerable that when enumerated will execute
121120
/// a batch of queries in a single database roundtrip
@@ -143,7 +142,6 @@ public interface IQueryOver<TRoot> : IQueryOver
143142
/// single roundtrip
144143
/// </summary>
145144
IFutureValueAsync<U> FutureValueAsync<U>();
146-
#endif
147145

148146
/// <summary>
149147
/// Creates an exact clone of the IQueryOver

src/NHibernate/Impl/AbstractQueryImpl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,6 @@ public IFutureValue<T> FutureValue<T>()
904904
return session.FutureQueryBatch.GetFutureValue<T>();
905905
}
906906

907-
#if ASYNC
908907
public IAsyncEnumerable<T> FutureAsync<T>()
909908
{
910909
if (!session.Factory.ConnectionProvider.Driver.SupportsMultipleQueries)
@@ -926,7 +925,6 @@ public IFutureValueAsync<T> FutureValueAsync<T>()
926925
session.FutureQueryBatch.Add<T>(this);
927926
return session.FutureQueryBatch.GetFutureValueAsync<T>();
928927
}
929-
#endif
930928

931929
/// <summary> Override the current session cache mode, just for this query.
932930
/// </summary>

src/NHibernate/Impl/CriteriaImpl.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ public IEnumerable<T> Future<T>()
423423
return session.FutureCriteriaBatch.GetEnumerator<T>();
424424
}
425425

426-
#if ASYNC
427426
public IFutureValueAsync<T> FutureValueAsync<T>()
428427
{
429428
if (!session.Factory.ConnectionProvider.Driver.SupportsMultipleQueries)
@@ -445,7 +444,6 @@ public IAsyncEnumerable<T> FutureAsync<T>()
445444
session.FutureCriteriaBatch.Add<T>(this);
446445
return session.FutureCriteriaBatch.GetAsyncEnumerator<T>();
447446
}
448-
#endif
449447

450448
public object UniqueResult()
451449
{
@@ -819,7 +817,6 @@ public IEnumerable<T> Future<T>()
819817
return root.Future<T>();
820818
}
821819

822-
#if ASYNC
823820
public IFutureValueAsync<T> FutureValueAsync<T>()
824821
{
825822
return root.FutureValueAsync<T>();
@@ -829,7 +826,6 @@ public IAsyncEnumerable<T> FutureAsync<T>()
829826
{
830827
return root.FutureAsync<T>();
831828
}
832-
#endif
833829

834830
public void List(IList results)
835831
{

src/NHibernate/Impl/DelayedAsyncEnumerator.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if ASYNC
21
using System;
32
using System.Collections;
43
using System.Collections.Generic;
@@ -67,5 +66,4 @@ public void Dispose()
6766
}
6867
}
6968
}
70-
}
71-
#endif
69+
}

src/NHibernate/Impl/FutureBatch.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System.Collections;
22
using System.Collections.Generic;
33
using System.Linq;
4-
#if ASYNC
54
using System.Threading.Tasks;
6-
#endif
75

86
namespace NHibernate.Impl
97
{
@@ -54,7 +52,6 @@ public IEnumerable<TResult> GetEnumerator<TResult>()
5452
return new DelayedEnumerator<TResult>(() => GetCurrentResult<TResult>(currentIndex));
5553
}
5654

57-
#if ASYNC
5855
public IFutureValueAsync<TResult> GetFutureValueAsync<TResult>()
5956
{
6057
int currentIndex = index;
@@ -71,7 +68,6 @@ private async Task<IEnumerable<TResult>> GetCurrentResultAsync<TResult>(int curr
7168
{
7269
return ((IList)(await GetResultsAsync())[currentIndex]).Cast<TResult>();
7370
}
74-
#endif
7571

7672
private IList GetResults()
7773
{

src/NHibernate/Impl/FutureValueAsync.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if ASYNC
21
using System;
32
using System.Collections.Generic;
43
using System.Linq;
@@ -35,5 +34,4 @@ public async Task<T> GetValue()
3534

3635
public Delegate ExecuteOnEval { get; set; }
3736
}
38-
}
39-
#endif
37+
}

src/NHibernate/Linq/DefaultQueryProvider.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,16 @@
88
using NHibernate.Impl;
99
using NHibernate.Type;
1010
using NHibernate.Util;
11-
#if ASYNC
1211
using System.Threading.Tasks;
13-
#endif
1412

1513
namespace NHibernate.Linq
1614
{
1715
public interface INhQueryProvider : IQueryProvider
1816
{
1917
object ExecuteFuture(Expression expression);
2018
void SetResultTransformerAndAdditionalCriteria(IQuery query, NhLinqExpression nhExpression, IDictionary<string, Tuple<object, IType>> parameters);
21-
#if ASYNC
2219
Task<TResult> ExecuteAsync<TResult>(Expression expression);
2320
object ExecuteFutureAsync(Expression expression);
24-
#endif
2521
}
2622

2723
public class DefaultQueryProvider : INhQueryProvider
@@ -74,8 +70,6 @@ public virtual object ExecuteFuture(Expression expression)
7470
return ExecuteFutureQuery(nhLinqExpression, query, nhQuery);
7571
}
7672

77-
#if ASYNC
78-
7973
public virtual object ExecuteFutureAsync(Expression expression)
8074
{
8175
IQuery query;
@@ -98,8 +92,6 @@ public virtual async Task<object> ExecuteAsync(Expression expression)
9892
return await ExecuteQueryAsync(nhLinqExpression, query, nhQuery);
9993
}
10094

101-
#endif
102-
10395
protected virtual NhLinqExpression PrepareQuery(Expression expression, out IQuery query, out NhLinqExpression nhQuery)
10496
{
10597
var nhLinqExpression = new NhLinqExpression(expression, Session.Factory);

src/NHibernate/Linq/LinqExtensionMethods.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88
using NHibernate.Util;
99
using Remotion.Linq;
1010
using Remotion.Linq.Parsing.ExpressionTreeVisitors;
11-
#if ASYNC
1211
using System.Reflection;
1312
using System.Threading.Tasks;
14-
#endif
1513

1614
namespace NHibernate.Linq
1715
{
1816
public static class LinqExtensionMethods
1917
{
20-
#if ASYNC
2118
private static readonly Dictionary<string, MethodInfo> cachableQueryableMethods;
2219

2320
static LinqExtensionMethods()
@@ -1584,7 +1581,6 @@ public static IFutureValueAsync<TResult> ToFutureValueAsync<TSource, TResult>(th
15841581
return (IFutureValueAsync<TResult>)provider.ExecuteFutureAsync(expression);
15851582
}
15861583

1587-
#endif
15881584
public static IQueryable<T> Query<T>(this ISession session)
15891585
{
15901586
return new NhQueryable<T>(session.GetSessionImplementation());

src/NHibernate/NHibernate.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
<Reference Include="System" />
8686
<Reference Include="System.Core" />
8787
<Reference Include="System.Data" />
88+
<Reference Include="System.Interactive.Async, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
89+
<HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net46\System.Interactive.Async.dll</HintPath>
90+
<Private>True</Private>
91+
</Reference>
8892
<Reference Include="System.ServiceModel" />
8993
<Reference Include="System.Transactions" />
9094
<Reference Include="System.Xml" />

src/NHibernate/Util/AsyncLock.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if ASYNC
21
using System;
32
using System.Threading;
43
using System.Threading.Tasks;
@@ -45,5 +44,4 @@ public void Dispose()
4544
}
4645
}
4746
}
48-
}
49-
#endif
47+
}

0 commit comments

Comments
 (0)