Skip to content

Commit

Permalink
Remove WcfOperationSessionContext from .Net Core and .Net Standard
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericDelaporte committed Sep 7, 2018
1 parent eb2adba commit 209c87d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
41 changes: 40 additions & 1 deletion src/NHibernate/Context/WcfOperationSessionContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
using System;
// There is no support of WCF Server under .Net Core, so it makes little sense to provide
// a WCF OperationContext for it. Since it adds additional heavy dependencies, it has been
// considered not desirable to provide it for .Net Standard. (It could be useful in case some
// WCF server becames available in another frameworks or if a .Net Framework application
// consumes the .Net standard distribution of NHibernate instead of the .Net Framework one)
// See https://github.com/dotnet/wcf/issues/1200 and #1842
#if NETFX
using System.Collections;
using System.ServiceModel;

Expand Down Expand Up @@ -50,3 +56,36 @@ public void Attach(OperationContext owner) { }
public void Detach(OperationContext owner) { }
}
}
#else
// 6.0 TODO: remove the whole #else
using System;
using System.Collections;
using NHibernate.Engine;

namespace NHibernate.Context
{
/// <summary>
/// Obsolete class not usable in the .Net Core and .Net Standard distributions of NHibernate. Use the
/// .Net Framework distribution of NHibernate if you need it. See
/// https://github.com/nhibernate/nhibernate-core/issues/1842
/// </summary>
[Obsolete("Not supported in the .Net Core and .Net Standard distributions of NHibernate")]
public class WcfOperationSessionContext : MapBasedSessionContext
{
public WcfOperationSessionContext(ISessionFactoryImplementor factory) : base(factory)
{
throw new NotSupportedException(
"WcfOperationSessionContext is currently supported only by the .Net Framework distribution of NHibernate");
}

protected override IDictionary GetMap()
{
return null;
}

protected override void SetMap(IDictionary value)
{
}
}
}
#endif
11 changes: 11 additions & 0 deletions src/NHibernate/Impl/SessionFactoryImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,18 @@ private ICurrentSessionContext BuildCurrentSessionContext()
case "web":
return new WebSessionContext(this);
case "wcf_operation":
#if NETFX
return new WcfOperationSessionContext(this);
#else
// There is no support of WCF Server under .Net Core, so it makes little sense to provide
// a WCF OperationContext for it. Since it adds additional heavy dependencies, it has been
// considered not desirable to provide it for .Net Standard. (It could be useful in case some
// WCF server becames available in another frameworks or if a .Net Framework application
// consumes the .Net standard distribution of NHibernate instead of the .Net Framework one)
// See https://github.com/dotnet/wcf/issues/1200 and #1842
throw new NotSupportedException(
"WcfOperationSessionContext is currently supported only by the .Net Framework distribution of NHibernate");
#endif
}

try
Expand Down
2 changes: 0 additions & 2 deletions src/NHibernate/NHibernate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
<PackageReference Include="System.Security.Permissions" Version="4.4.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
<PackageReference Include="System.Security.Permissions" Version="4.4.1" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
Expand Down

0 comments on commit 209c87d

Please sign in to comment.