Skip to content

Commit 2a6021f

Browse files
Remove WcfOperationSessionContext from .Net Core and .Net Standard (#1842)
1 parent eb2adba commit 2a6021f

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

src/NHibernate/Context/WcfOperationSessionContext.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using System;
1+
// There is no support of WCF Server under .Net Core, so it makes little sense to provide
2+
// a WCF OperationContext for it. Since it adds additional heavy dependencies, it has been
3+
// considered not desirable to provide it for .Net Standard. (It could be useful in case some
4+
// WCF server becames available in another frameworks or if a .Net Framework application
5+
// consumes the .Net Standard distribution of NHibernate instead of the .Net Framework one.)
6+
// See https://github.com/dotnet/wcf/issues/1200 and #1842
7+
#if NETFX
28
using System.Collections;
39
using System.ServiceModel;
410

@@ -50,3 +56,36 @@ public void Attach(OperationContext owner) { }
5056
public void Detach(OperationContext owner) { }
5157
}
5258
}
59+
#else
60+
// 6.0 TODO: remove the whole #else
61+
using System;
62+
using System.Collections;
63+
using NHibernate.Engine;
64+
65+
namespace NHibernate.Context
66+
{
67+
/// <summary>
68+
/// Obsolete class not usable with the current framework. Use the
69+
/// .Net Framework distribution of NHibernate if you need it. See
70+
/// https://github.com/nhibernate/nhibernate-core/issues/1842
71+
/// </summary>
72+
[Obsolete("Not supported in this platform", true)]
73+
public class WcfOperationSessionContext : MapBasedSessionContext
74+
{
75+
public WcfOperationSessionContext(ISessionFactoryImplementor factory) : base(factory)
76+
{
77+
throw new PlatformNotSupportedException(
78+
"WcfOperationSessionContext is not supported for the current framework");
79+
}
80+
81+
protected override IDictionary GetMap()
82+
{
83+
return null;
84+
}
85+
86+
protected override void SetMap(IDictionary value)
87+
{
88+
}
89+
}
90+
}
91+
#endif

src/NHibernate/Impl/SessionFactoryImpl.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,18 @@ private ICurrentSessionContext BuildCurrentSessionContext()
12761276
case "web":
12771277
return new WebSessionContext(this);
12781278
case "wcf_operation":
1279+
#if NETFX
12791280
return new WcfOperationSessionContext(this);
1281+
#else
1282+
// There is no support of WCF Server under .Net Core, so it makes little sense to provide
1283+
// a WCF OperationContext for it. Since it adds additional heavy dependencies, it has been
1284+
// considered not desirable to provide it for .Net Standard. (It could be useful in case some
1285+
// WCF server becames available in another frameworks or if a .Net Framework application
1286+
// consumes the .Net Standard distribution of NHibernate instead of the .Net Framework one.)
1287+
// See https://github.com/dotnet/wcf/issues/1200 and #1842
1288+
throw new PlatformNotSupportedException(
1289+
"WcfOperationSessionContext is not supported for the current framework");
1290+
#endif
12801291
}
12811292

12821293
try

src/NHibernate/NHibernate.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@
5252
</ItemGroup>
5353

5454
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
55-
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.0" />
5655
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
5756
<PackageReference Include="System.Security.Permissions" Version="4.4.1" />
5857
</ItemGroup>
5958

6059
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
61-
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.0" />
6260
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
6361
<PackageReference Include="System.Security.Permissions" Version="4.4.1" />
6462
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />

0 commit comments

Comments
 (0)