Skip to content

Commit 8e22b70

Browse files
authored
Add .NET Standard 2.1 target (#3050)
1 parent e6b8dbc commit 8e22b70

18 files changed

+31
-25
lines changed

build-common/NHibernate.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<FileVersion Condition="'$(FileVersion)' == ''">$(VersionPrefix).0</FileVersion>
1616

1717
<NhAppTargetFrameworks Condition ="$(NhAppTargetFrameworks) == ''">net48;net6.0</NhAppTargetFrameworks>
18-
<NhLibTargetFrameworks Condition ="$(NhLibTargetFrameworks) == ''">net461;netcoreapp2.0;netstandard2.0</NhLibTargetFrameworks>
18+
<NhLibTargetFrameworks Condition ="$(NhLibTargetFrameworks) == ''">net461;netcoreapp2.0;netstandard2.0;netstandard2.1</NhLibTargetFrameworks>
1919
<NhNetFx>false</NhNetFx>
2020
<NhNetFx Condition="$(TargetFramework.StartsWith('net4'))">true</NhNetFx>
2121
<!-- Visual Basic requires to use coma (,) as a separator, other project types - semicolon (;) -->

default.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<arg value="/t:Restore" />
4646
<arg value="/t:Rebuild" />
4747
<arg value="/v:q" />
48-
<arg value="/m" />
48+
<arg value="/m:1" />
4949
</exec>
5050
</target>
5151

psake.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Task Build {
103103
Exec {
104104
dotnet `
105105
build ./src/NHibernate.sln `
106+
-m:1 `
106107
-c Release
107108
}
108109
}

src/NHibernate/Collection/Generic/SetHelpers/SetSnapShot.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4-
#if NETCOREAPP2_0_OR_GREATER
4+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
55
using System.Runtime.Serialization;
66
using System.Threading;
77
#endif
@@ -132,7 +132,7 @@ void ICollection.CopyTo(Array array, int index)
132132
}
133133
#endif
134134

135-
#if NETCOREAPP2_0_OR_GREATER
135+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
136136
[Serializable]
137137
internal class SetSnapShot<T> : HashSet<T>, ICollection
138138
{

src/NHibernate/Driver/DriverBase.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,14 @@ public DbParameter GenerateOutputParameter(DbCommand command)
338338

339339
public virtual bool RequiresTimeSpanForTime => false;
340340

341-
#if NETCOREAPP2_0_OR_GREATER
342-
public virtual bool SupportsSystemTransactions => false;
343-
344-
public virtual bool SupportsNullEnlistment => false;
345-
#else
341+
#if NETFX
346342
public virtual bool SupportsSystemTransactions => true;
347343

348344
public virtual bool SupportsNullEnlistment => true;
345+
#else
346+
public virtual bool SupportsSystemTransactions => false;
347+
348+
public virtual bool SupportsNullEnlistment => false;
349349
#endif
350350

351351
/// <inheritdoc />

src/NHibernate/Driver/ReflectionBasedDriver.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ protected ReflectionBasedDriver(string providerInvariantName, string driverAssem
4646

4747
if (connectionType == null || commandType == null)
4848
{
49-
#if NETFX
49+
#if NETFX || NETSTANDARD2_1_OR_GREATER
5050
if (string.IsNullOrEmpty(providerInvariantName))
5151
{
5252
#endif
5353
throw new HibernateException(string.Format(ReflectionTypedProviderExceptionMessageTemplate, driverAssemblyName));
54-
#if NETFX
54+
#if NETFX || NETSTANDARD2_1_OR_GREATER
5555
}
5656
var factory = DbProviderFactories.GetFactory(providerInvariantName);
5757
connectionCommandProvider = new DbProviderFactoryDriveConnectionCommandProvider(factory);

src/NHibernate/Linq/Functions/MathGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public MathGenerator()
5555

5656
ReflectHelper.FastGetMethod(Math.Pow, default(double), default(double)),
5757

58-
#if NETCOREAPP2_0_OR_GREATER
58+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
5959
ReflectHelper.FastGetMethod(MathF.Sin, default(float)),
6060
ReflectHelper.FastGetMethod(MathF.Cos, default(float)),
6161
ReflectHelper.FastGetMethod(MathF.Tan, default(float)),

src/NHibernate/Linq/Functions/RoundGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public RoundGenerator()
2121
ReflectHelper.FastGetMethod(decimal.Round, default(decimal)),
2222
ReflectHelper.FastGetMethod(decimal.Round, default(decimal), default(int)),
2323

24-
#if NETCOREAPP2_0_OR_GREATER
24+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
2525
ReflectHelper.FastGetMethod(MathF.Round, default(float)),
2626
ReflectHelper.FastGetMethod(MathF.Round, default(float), default(int)),
2727
#endif

src/NHibernate/Linq/Functions/StringGenerator.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
269269

270270
public class ReplaceGenerator : BaseHqlGeneratorForMethod
271271
{
272-
#if NETCOREAPP2_0_OR_GREATER
272+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
273273
private static readonly MethodInfo MethodWithComparer = ReflectHelper.GetMethodDefinition<string>(x => x.Replace(string.Empty, string.Empty, default(StringComparison)));
274274
#endif
275275

@@ -279,15 +279,15 @@ public ReplaceGenerator()
279279
{
280280
ReflectHelper.GetMethodDefinition<string>(s => s.Replace(' ', ' ')),
281281
ReflectHelper.GetMethodDefinition<string>(s => s.Replace("", "")),
282-
#if NETCOREAPP2_0_OR_GREATER
282+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
283283
MethodWithComparer,
284284
#endif
285285
};
286286
}
287287

288288
public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
289289
{
290-
#if NETCOREAPP2_0_OR_GREATER
290+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
291291
LogIgnoredStringComparisonParameter(method, MethodWithComparer);
292292
#endif
293293
return treeBuilder.MethodCall(

src/NHibernate/Linq/Functions/TruncateGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public TruncateGenerator()
1818
ReflectHelper.FastGetMethod(Math.Truncate, default(double)),
1919
ReflectHelper.FastGetMethod(decimal.Truncate, default(decimal)),
2020

21-
#if NETCOREAPP2_0_OR_GREATER
21+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
2222
ReflectHelper.FastGetMethod(MathF.Truncate, default(float)),
2323
#endif
2424
};

src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected override Expression VisitMember(MemberExpression expression)
207207
return expression;
208208
}
209209

210-
#if NETCOREAPP2_0_OR_GREATER
210+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
211211
protected override Expression VisitInvocation(InvocationExpression expression)
212212
{
213213
if (ExpressionsHelper.TryGetDynamicMemberBinder(expression, out var memberBinder))

src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected override Expression VisitMethodCall(MethodCallExpression expression)
118118
return base.VisitMethodCall(expression);
119119
}
120120

121-
#if NETCOREAPP2_0_OR_GREATER
121+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
122122
protected override Expression VisitInvocation(InvocationExpression expression)
123123
{
124124
if (ExpressionsHelper.TryGetDynamicMemberBinder(expression, out _))

src/NHibernate/Linq/Visitors/HqlGeneratorExpressionVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private HqlTreeNode VisitNhNominated(NhNominatedExpression nhNominatedExpression
228228

229229
private HqlTreeNode VisitInvocationExpression(InvocationExpression expression)
230230
{
231-
#if NETCOREAPP2_0_OR_GREATER
231+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
232232
if (ExpressionsHelper.TryGetDynamicMemberBinder(expression, out var binder))
233233
{
234234
return _hqlTreeBuilder.Dot(

src/NHibernate/Linq/Visitors/ParameterTypeLocator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private bool IsDynamicMember(Expression expression)
390390
{
391391
switch (expression)
392392
{
393-
#if NETCOREAPP2_0_OR_GREATER
393+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
394394
case InvocationExpression invocationExpression:
395395
// session.Query<Product>().Where("Properties.Name == @0", "First Product")
396396
return ExpressionsHelper.TryGetDynamicMemberBinder(invocationExpression, out _);

src/NHibernate/NHibernate.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
6161
</ItemGroup>
6262

63+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
64+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
65+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
66+
</ItemGroup>
67+
6368
<ItemGroup>
6469
<Content Include="*.xsd">
6570
<PackagePath>./</PackagePath>

src/NHibernate/Proxy/FieldInterceptorProxyBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static TypeInfo CreateProxyType(System.Type baseType)
5757

5858
var assemblyBuilder = ProxyBuilderHelper.DefineDynamicAssembly(AppDomain.CurrentDomain, name);
5959

60-
#if NETFX || NETCOREAPP2_0_OR_GREATER
60+
#if NETFX || NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
6161
if (!baseType.IsVisible)
6262
ProxyBuilderHelper.GenerateInstanceOfIgnoresAccessChecksToAttribute(assemblyBuilder, baseType.Assembly.GetName().Name);
6363
#endif

src/NHibernate/Proxy/NHibernateProxyBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public TypeInfo CreateProxyType(System.Type baseType, IReadOnlyCollection<System
7676
interfaces.Add(baseType);
7777
}
7878

79-
#if NETFX || NETCOREAPP2_0_OR_GREATER
79+
#if NETFX || NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
8080
var assemblyNamesToIgnoreAccessCheck =
8181
new[] {baseType}
8282
.Concat(interfaces).Where(i => !i.IsVisible)

src/NHibernate/Util/ExpressionsHelper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static MemberInfo DecodeMemberAccessExpression<TEntity, TResult>(Expressi
3333
return ((MemberExpression)expression.Body).Member;
3434
}
3535

36-
#if NETCOREAPP2_0_OR_GREATER
36+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
3737
/// <summary>
3838
/// Try to retrieve <see cref="GetMemberBinder"/> from a reduced <see cref="ExpressionType.Dynamic"/> expression.
3939
/// </summary>
@@ -721,7 +721,7 @@ protected override Expression VisitMember(MemberExpression node)
721721
return base.Visit(node.Expression);
722722
}
723723

724-
#if NETCOREAPP2_0_OR_GREATER
724+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
725725
protected override Expression VisitInvocation(InvocationExpression node)
726726
{
727727
if (TryGetDynamicMemberBinder(node, out var binder))

0 commit comments

Comments
 (0)