Skip to content

Commit 6991d27

Browse files
ngbrownhazzik
authored andcommitted
NH-3807 - Guard Remoting methods and types and Wcf service model operations
1 parent 9a282b8 commit 6991d27

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

src/NHibernate/Context/CallSessionContext.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if FEATURE_REMOTING
2+
13
using System;
24
using System.Collections;
35
using System.Runtime.Remoting.Messaging;
@@ -36,4 +38,6 @@ protected override IDictionary GetMap()
3638
return CallContext.GetData(SessionFactoryMapKey) as IDictionary;
3739
}
3840
}
39-
}
41+
}
42+
43+
#endif

src/NHibernate/Context/WcfOperationSessionContext.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if FEATURE_SYSTEM_SERVICEMODEL
2+
13
using System;
24
using System.Collections;
35
using System.ServiceModel;
@@ -49,4 +51,6 @@ public class WcfStateExtension : IExtension<OperationContext>
4951
public void Attach(OperationContext owner) { }
5052
public void Detach(OperationContext owner) { }
5153
}
52-
}
54+
}
55+
56+
#endif

src/NHibernate/Impl/SessionFactoryImpl.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,14 +1239,18 @@ private ICurrentSessionContext BuildCurrentSessionContext()
12391239
{
12401240
case null:
12411241
return null;
1242+
#if FEATURE_REMOTING
12421243
case "call":
12431244
return new CallSessionContext(this);
1245+
#endif
12441246
case "thread_static":
12451247
return new ThreadStaticSessionContext(this);
12461248
case "web":
12471249
return new WebSessionContext(this);
1250+
#if FEATURE_REMOTING
12481251
case "wcf_operation":
12491252
return new WcfOperationSessionContext(this);
1253+
#endif
12501254
}
12511255

12521256
try

src/NHibernate/Proxy/DefaultDynamicProxyMethodCheckerExtensions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ public static class DefaultDynamicProxyMethodCheckerExtensions
1010
public static bool IsProxiable(this MethodInfo method)
1111
{
1212
return !method.IsFinal
13+
#if FEATURE_REMOTING
1314
&& (method.DeclaringType != typeof(MarshalByRefObject))
15+
#endif
1416
&& (method.DeclaringType != typeof(object) || !"finalize".Equals(method.Name.ToLowerInvariant()))
1517
&&
1618
(
@@ -23,7 +25,10 @@ public static bool IsProxiable(this MethodInfo method)
2325
public static bool ShouldBeProxiable(this MethodInfo method)
2426
{
2527
// to use only for real methods (no getter/setter)
26-
return (method.DeclaringType != typeof (MarshalByRefObject)) &&
28+
return
29+
#if FEATURE_REMOTING
30+
(method.DeclaringType != typeof (MarshalByRefObject)) &&
31+
#endif
2732
(method.DeclaringType != typeof (object) || !"finalize".Equals(method.Name.ToLowerInvariant())) &&
2833
(!(method.DeclaringType == typeof (object) && "GetType".Equals(method.Name))) &&
2934
(!(method.DeclaringType == typeof (object) && "obj_address".Equals(method.Name))) && // Mono-specific method
@@ -48,4 +53,4 @@ private static bool IsDisposeMethod(MethodInfo method)
4853
// return method.Name.Equals("Dispose") && method.IsMethodOf(typeof(IDisposable));
4954
}
5055
}
51-
}
56+
}

0 commit comments

Comments
 (0)