From 209c87d09b25197b025e1830bb8f812e445b0abd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?=
<12201973+fredericDelaporte@users.noreply.github.com>
Date: Fri, 7 Sep 2018 11:40:04 +0200
Subject: [PATCH 1/3] Remove WcfOperationSessionContext from .Net Core and .Net
Standard
---
.../Context/WcfOperationSessionContext.cs | 41 ++++++++++++++++++-
src/NHibernate/Impl/SessionFactoryImpl.cs | 11 +++++
src/NHibernate/NHibernate.csproj | 2 -
3 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/src/NHibernate/Context/WcfOperationSessionContext.cs b/src/NHibernate/Context/WcfOperationSessionContext.cs
index ba0e6ad7301..f3e934896f0 100644
--- a/src/NHibernate/Context/WcfOperationSessionContext.cs
+++ b/src/NHibernate/Context/WcfOperationSessionContext.cs
@@ -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;
@@ -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
+{
+ ///
+ /// 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
+ ///
+ [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
diff --git a/src/NHibernate/Impl/SessionFactoryImpl.cs b/src/NHibernate/Impl/SessionFactoryImpl.cs
index 3f90f9d0181..b06231b807e 100644
--- a/src/NHibernate/Impl/SessionFactoryImpl.cs
+++ b/src/NHibernate/Impl/SessionFactoryImpl.cs
@@ -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
diff --git a/src/NHibernate/NHibernate.csproj b/src/NHibernate/NHibernate.csproj
index 04cfc0cf258..059a9b91746 100644
--- a/src/NHibernate/NHibernate.csproj
+++ b/src/NHibernate/NHibernate.csproj
@@ -52,13 +52,11 @@
-
-
From 68e18a1622ec94a1ae77498f93a0f77146a99cb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?=
<12201973+fredericDelaporte@users.noreply.github.com>
Date: Fri, 7 Sep 2018 12:10:21 +0200
Subject: [PATCH 2/3] Flag obsolete usage as error
---
src/NHibernate/Context/WcfOperationSessionContext.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/NHibernate/Context/WcfOperationSessionContext.cs b/src/NHibernate/Context/WcfOperationSessionContext.cs
index f3e934896f0..51fc85b98fc 100644
--- a/src/NHibernate/Context/WcfOperationSessionContext.cs
+++ b/src/NHibernate/Context/WcfOperationSessionContext.cs
@@ -69,7 +69,7 @@ namespace NHibernate.Context
/// .Net Framework distribution of NHibernate if you need it. See
/// https://github.com/nhibernate/nhibernate-core/issues/1842
///
- [Obsolete("Not supported in the .Net Core and .Net Standard distributions of NHibernate")]
+ [Obsolete("Not supported in the .Net Core and .Net Standard distributions of NHibernate", true)]
public class WcfOperationSessionContext : MapBasedSessionContext
{
public WcfOperationSessionContext(ISessionFactoryImplementor factory) : base(factory)
From d536d9f47a0887b8d3c0380ecfae6d6492d3ef3d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?=
<12201973+fredericDelaporte@users.noreply.github.com>
Date: Tue, 11 Sep 2018 10:09:56 +0200
Subject: [PATCH 3/3] Reword and adjust exception type
---
src/NHibernate/Context/WcfOperationSessionContext.cs | 10 +++++-----
src/NHibernate/Impl/SessionFactoryImpl.cs | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/NHibernate/Context/WcfOperationSessionContext.cs b/src/NHibernate/Context/WcfOperationSessionContext.cs
index 51fc85b98fc..fe0dda21a45 100644
--- a/src/NHibernate/Context/WcfOperationSessionContext.cs
+++ b/src/NHibernate/Context/WcfOperationSessionContext.cs
@@ -2,7 +2,7 @@
// 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)
+// 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;
@@ -65,17 +65,17 @@ public void Detach(OperationContext owner) { }
namespace NHibernate.Context
{
///
- /// Obsolete class not usable in the .Net Core and .Net Standard distributions of NHibernate. Use the
+ /// Obsolete class not usable with the current framework. Use the
/// .Net Framework distribution of NHibernate if you need it. See
/// https://github.com/nhibernate/nhibernate-core/issues/1842
///
- [Obsolete("Not supported in the .Net Core and .Net Standard distributions of NHibernate", true)]
+ [Obsolete("Not supported in this platform", true)]
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");
+ throw new PlatformNotSupportedException(
+ "WcfOperationSessionContext is not supported for the current framework");
}
protected override IDictionary GetMap()
diff --git a/src/NHibernate/Impl/SessionFactoryImpl.cs b/src/NHibernate/Impl/SessionFactoryImpl.cs
index b06231b807e..66168743adf 100644
--- a/src/NHibernate/Impl/SessionFactoryImpl.cs
+++ b/src/NHibernate/Impl/SessionFactoryImpl.cs
@@ -1283,10 +1283,10 @@ private ICurrentSessionContext BuildCurrentSessionContext()
// 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)
+ // 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");
+ throw new PlatformNotSupportedException(
+ "WcfOperationSessionContext is not supported for the current framework");
#endif
}