Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove WcfOperationSessionContext from .Net Core and .Net Standard #1842

Merged
merged 3 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) { }
}
hazzik marked this conversation as resolved.
Show resolved Hide resolved
}
#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", true)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it generic "Not supported in this platform"

public class WcfOperationSessionContext : MapBasedSessionContext
{
public WcfOperationSessionContext(ISessionFactoryImplementor factory) : base(factory)
{
throw new NotSupportedException(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be PlatformNotSupportedException

"WcfOperationSessionContext is currently supported only by the .Net Framework distribution of NHibernate");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to change wording to emphasise that this is not supported in the current framework. The fact that it is only supported in full .NET Framework is not relevant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is, current framework can be .Net Framework, while using the .Net Standard binaries. In such case stating it is not supported by the current framework while the lack of support actually comes from the binaries would be confusing.
Granted, that is a corner case. Normally by using NuGet no-one should ends up using the .Net Standard binaries under .Net Framework, and currently NHibernate .Net Standard binaries are not provided anywhere else than on NuGet.

}

protected override IDictionary GetMap()
{
return null;
}

protected override void SetMap(IDictionary value)
{
}
}
}
hazzik marked this conversation as resolved.
Show resolved Hide resolved
#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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be PlatformNotSupportedException

"WcfOperationSessionContext is currently supported only by the .Net Framework distribution of NHibernate");
hazzik marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in the constructor.

#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