diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14e1c516a7..a093e371e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ Enhancements:
Deprecations:
- Removed support for the .NET Framework < 4.5 and .NET Standard 1.x. (@stakx, #495, #496)
- Removed support for Code Access Security (CAS). (@stakx, #502)
+ - Minimized support for Remoting. This library no longer defines any types deriving from `MarshalByRefObject`, and `ProxyUtil.IsProxy` (which used to recognize remoting/"transparent" proxies) now tests only for DynamicProxy proxies. (@stakx, #507)
- The following public members have been removed:
- `Castle.Core.Internal.Lock` (class) along with all related types and methods
- `Castle.Core.Internal.PermissionUtil.IsGranted` (method)
diff --git a/README.md b/README.md
index 767eb07f26..f2daaa77e2 100644
--- a/README.md
+++ b/README.md
@@ -65,7 +65,6 @@ Symbol | .NET 4.5 | .NET Standard 2.x
`FEATURE_APPDOMAIN` | :white_check_mark: | :no_entry_sign:
`FEATURE_ASSEMBLYBUILDER_SAVE` | :white_check_mark: | :no_entry_sign:
`FEATURE_EVENTLOG` | :white_check_mark: | :no_entry_sign:
-`FEATURE_REMOTING` | :white_check_mark: | :no_entry_sign:
`FEATURE_SERIALIZATION` | :white_check_mark: | :no_entry_sign:
`FEATURE_SYSTEM_CONFIGURATION` | :white_check_mark: | :no_entry_sign:
`FEATURE_TEST_COM` | :white_check_mark: | :no_entry_sign:
@@ -77,7 +76,6 @@ Symbol | .NET 4.5 | .NET Standard 2.x
* `FEATURE_APPDOMAIN` - enables support for features that make use of an AppDomain in the host.
* `FEATURE_ASSEMBLYBUILDER_SAVE` - enabled support for saving the dynamically generated proxy assembly.
* `FEATURE_EVENTLOG` - provides a diagnostics logger using the Windows Event Log.
-* `FEATURE_REMOTING` - supports remoting on various types including inheriting from MarshalByRefObject.
* `FEATURE_SERIALIZATION` - enables support for serialization of dynamic proxies and other types.
* `FEATURE_SYSTEM_CONFIGURATION` - enables features that use System.Configuration and the ConfigurationManager.
* `FEATURE_TEST_COM` - enables COM Interop tests.
diff --git a/buildscripts/common.props b/buildscripts/common.props
index 1fb3e174bb..f84d720495 100644
--- a/buildscripts/common.props
+++ b/buildscripts/common.props
@@ -45,7 +45,7 @@
DEBUG
TRACE
TRACE
- TRACE;FEATURE_APPDOMAIN;FEATURE_ASSEMBLYBUILDER_SAVE;FEATURE_EVENTLOG;FEATURE_REMOTING;FEATURE_SERIALIZATION;FEATURE_SYSTEM_CONFIGURATION;FEATURE_TEST_COM;FEATURE_TEST_WINFORMS
+ TRACE;FEATURE_APPDOMAIN;FEATURE_ASSEMBLYBUILDER_SAVE;FEATURE_EVENTLOG;FEATURE_SERIALIZATION;FEATURE_SYSTEM_CONFIGURATION;FEATURE_TEST_COM;FEATURE_TEST_WINFORMS
$(CommonDesktopClrConstants)
$(CommonDesktopClrConstants);FEATURE_TEST_PEVERIFY
diff --git a/ref/Castle.Core-net45.cs b/ref/Castle.Core-net45.cs
index 2663a8b73e..8d714e94e1 100644
--- a/ref/Castle.Core-net45.cs
+++ b/ref/Castle.Core-net45.cs
@@ -1966,7 +1966,7 @@ public class InternalsVisible
}
namespace Castle.Core.Logging
{
- public abstract class AbstractExtendedLoggerFactory : System.MarshalByRefObject, Castle.Core.Logging.IExtendedLoggerFactory, Castle.Core.Logging.ILoggerFactory
+ public abstract class AbstractExtendedLoggerFactory : Castle.Core.Logging.IExtendedLoggerFactory, Castle.Core.Logging.ILoggerFactory
{
protected AbstractExtendedLoggerFactory() { }
public abstract Castle.Core.Logging.IExtendedLogger Create(string name);
@@ -1975,7 +1975,7 @@ public abstract class AbstractExtendedLoggerFactory : System.MarshalByRefObject,
public virtual Castle.Core.Logging.IExtendedLogger Create(System.Type type, Castle.Core.Logging.LoggerLevel level) { }
protected static System.IO.FileInfo GetConfigFile(string fileName) { }
}
- public abstract class AbstractLoggerFactory : System.MarshalByRefObject, Castle.Core.Logging.ILoggerFactory
+ public abstract class AbstractLoggerFactory : Castle.Core.Logging.ILoggerFactory
{
protected AbstractLoggerFactory() { }
public abstract Castle.Core.Logging.ILogger Create(string name);
@@ -1984,7 +1984,7 @@ public abstract class AbstractLoggerFactory : System.MarshalByRefObject, Castle.
public virtual Castle.Core.Logging.ILogger Create(System.Type type, Castle.Core.Logging.LoggerLevel level) { }
protected static System.IO.FileInfo GetConfigFile(string fileName) { }
}
- public class ConsoleFactory : System.MarshalByRefObject, Castle.Core.Logging.ILoggerFactory
+ public class ConsoleFactory : Castle.Core.Logging.ILoggerFactory
{
public ConsoleFactory() { }
public ConsoleFactory(Castle.Core.Logging.LoggerLevel level) { }
@@ -2106,7 +2106,7 @@ public interface ILoggerFactory
Castle.Core.Logging.ILogger Create(string name, Castle.Core.Logging.LoggerLevel level);
Castle.Core.Logging.ILogger Create(System.Type type, Castle.Core.Logging.LoggerLevel level);
}
- public abstract class LevelFilteredLogger : System.MarshalByRefObject, Castle.Core.Logging.ILogger
+ public abstract class LevelFilteredLogger : Castle.Core.Logging.ILogger
{
protected LevelFilteredLogger() { }
protected LevelFilteredLogger(Castle.Core.Logging.LoggerLevel loggerLevel) { }
@@ -2150,7 +2150,6 @@ public abstract class LevelFilteredLogger : System.MarshalByRefObject, Castle.Co
public void InfoFormat(System.Exception exception, string format, params object[] args) { }
public void InfoFormat(System.IFormatProvider formatProvider, string format, params object[] args) { }
public void InfoFormat(System.Exception exception, System.IFormatProvider formatProvider, string format, params object[] args) { }
- public override object InitializeLifetimeService() { }
protected abstract void Log(Castle.Core.Logging.LoggerLevel loggerLevel, string loggerName, string message, System.Exception exception);
public void Trace(System.Func messageFactory) { }
public void Trace(string message) { }
@@ -2752,7 +2751,7 @@ public static class ProxyUtil
public static bool IsProxy(object instance) { }
public static bool IsProxyType(System.Type type) { }
}
- public class StandardInterceptor : System.MarshalByRefObject, Castle.DynamicProxy.IInterceptor
+ public class StandardInterceptor : Castle.DynamicProxy.IInterceptor
{
public StandardInterceptor() { }
public void Intercept(Castle.DynamicProxy.IInvocation invocation) { }
diff --git a/ref/Castle.Services.Logging.SerilogIntegration-net45.cs b/ref/Castle.Services.Logging.SerilogIntegration-net45.cs
index 2adb4ae9d7..414d840f81 100644
--- a/ref/Castle.Services.Logging.SerilogIntegration-net45.cs
+++ b/ref/Castle.Services.Logging.SerilogIntegration-net45.cs
@@ -8,7 +8,7 @@ public class SerilogFactory : Castle.Core.Logging.AbstractLoggerFactory
public override Castle.Core.Logging.ILogger Create(string name) { }
public override Castle.Core.Logging.ILogger Create(string name, Castle.Core.Logging.LoggerLevel level) { }
}
- public class SerilogLogger : System.MarshalByRefObject, Castle.Core.Logging.ILogger
+ public class SerilogLogger : Castle.Core.Logging.ILogger
{
public SerilogLogger(Serilog.ILogger logger, Castle.Services.Logging.SerilogIntegration.SerilogFactory factory) { }
protected Castle.Services.Logging.SerilogIntegration.SerilogFactory Factory { get; set; }
diff --git a/ref/Castle.Services.Logging.log4netIntegration-net45.cs b/ref/Castle.Services.Logging.log4netIntegration-net45.cs
index 29814f6ee5..aae6fdf6d8 100644
--- a/ref/Castle.Services.Logging.log4netIntegration-net45.cs
+++ b/ref/Castle.Services.Logging.log4netIntegration-net45.cs
@@ -37,7 +37,7 @@ public class Log4netFactory : Castle.Core.Logging.AbstractLoggerFactory
public override Castle.Core.Logging.ILogger Create(string name) { }
public override Castle.Core.Logging.ILogger Create(string name, Castle.Core.Logging.LoggerLevel level) { }
}
- public class Log4netLogger : System.MarshalByRefObject, Castle.Core.Logging.ILogger
+ public class Log4netLogger : Castle.Core.Logging.ILogger
{
public Log4netLogger(log4net.Core.ILogger logger, Castle.Services.Logging.Log4netIntegration.Log4netFactory factory) { }
protected Castle.Services.Logging.Log4netIntegration.Log4netFactory Factory { get; set; }
diff --git a/src/Castle.Core.Tests/DynamicProxy.Tests/BugsReported/Camera.cs b/src/Castle.Core.Tests/DynamicProxy.Tests/BugsReported/Camera.cs
index 02a3df1ae0..309b259e9a 100644
--- a/src/Castle.Core.Tests/DynamicProxy.Tests/BugsReported/Camera.cs
+++ b/src/Castle.Core.Tests/DynamicProxy.Tests/BugsReported/Camera.cs
@@ -33,11 +33,7 @@ public interface ICameraService : ICameraServiceBase
void Record(ICamera cam);
}
- public class CameraService :
-#if FEATURE_REMOTING
- MarshalByRefObject,
-#endif
- ICameraService
+ public class CameraService : ICameraService
{
public ICamera Add(String name, String ipNumber)
{
diff --git a/src/Castle.Core.Tests/DynamicProxy.Tests/InterClasses/IService2.cs b/src/Castle.Core.Tests/DynamicProxy.Tests/InterClasses/IService2.cs
index 5e0b5e4407..ad18c10dec 100644
--- a/src/Castle.Core.Tests/DynamicProxy.Tests/InterClasses/IService2.cs
+++ b/src/Castle.Core.Tests/DynamicProxy.Tests/InterClasses/IService2.cs
@@ -21,11 +21,7 @@ public interface IService2
void DoOperation2();
}
- public class Service2 :
-#if FEATURE_REMOTING
- MarshalByRefObject,
-#endif
- IService2
+ public class Service2 : IService2
{
public void DoOperation2()
{
diff --git a/src/Castle.Core/Core/Logging/AbstractExtendedLoggerFactory.cs b/src/Castle.Core/Core/Logging/AbstractExtendedLoggerFactory.cs
index 3f8a51d4cf..96a256fdb6 100644
--- a/src/Castle.Core/Core/Logging/AbstractExtendedLoggerFactory.cs
+++ b/src/Castle.Core/Core/Logging/AbstractExtendedLoggerFactory.cs
@@ -17,11 +17,7 @@ namespace Castle.Core.Logging
using System;
using System.IO;
- public abstract class AbstractExtendedLoggerFactory :
-#if FEATURE_REMOTING
- MarshalByRefObject,
-#endif
- IExtendedLoggerFactory
+ public abstract class AbstractExtendedLoggerFactory : IExtendedLoggerFactory
{
///
/// Creates a new extended logger, getting the logger name from the specified type.
diff --git a/src/Castle.Core/Core/Logging/AbstractLoggerFactory.cs b/src/Castle.Core/Core/Logging/AbstractLoggerFactory.cs
index 0a8670afbe..1e7494616c 100644
--- a/src/Castle.Core/Core/Logging/AbstractLoggerFactory.cs
+++ b/src/Castle.Core/Core/Logging/AbstractLoggerFactory.cs
@@ -20,11 +20,7 @@ namespace Castle.Core.Logging
#if FEATURE_SERIALIZATION
[Serializable]
#endif
- public abstract class AbstractLoggerFactory :
-#if FEATURE_REMOTING
- MarshalByRefObject,
-#endif
- ILoggerFactory
+ public abstract class AbstractLoggerFactory : ILoggerFactory
{
public virtual ILogger Create(Type type)
{
diff --git a/src/Castle.Core/Core/Logging/ConsoleFactory.cs b/src/Castle.Core/Core/Logging/ConsoleFactory.cs
index d481e527e9..a80273a4de 100644
--- a/src/Castle.Core/Core/Logging/ConsoleFactory.cs
+++ b/src/Castle.Core/Core/Logging/ConsoleFactory.cs
@@ -19,11 +19,7 @@ namespace Castle.Core.Logging
#if FEATURE_SERIALIZATION
[Serializable]
#endif
- public class ConsoleFactory :
-#if FEATURE_REMOTING
- MarshalByRefObject,
-#endif
- ILoggerFactory
+ public class ConsoleFactory : ILoggerFactory
{
private LoggerLevel? level;
diff --git a/src/Castle.Core/Core/Logging/LevelFilteredLogger.cs b/src/Castle.Core/Core/Logging/LevelFilteredLogger.cs
index 47f0a13d8a..520d8d674e 100644
--- a/src/Castle.Core/Core/Logging/LevelFilteredLogger.cs
+++ b/src/Castle.Core/Core/Logging/LevelFilteredLogger.cs
@@ -25,11 +25,7 @@ namespace Castle.Core.Logging
#if FEATURE_SERIALIZATION
[Serializable]
#endif
- public abstract class LevelFilteredLogger :
-#if FEATURE_REMOTING
- MarshalByRefObject,
-#endif
- ILogger
+ public abstract class LevelFilteredLogger : ILogger
{
private LoggerLevel level = LoggerLevel.Off;
private String name = "unnamed";
@@ -56,16 +52,6 @@ protected LevelFilteredLogger(String loggerName, LoggerLevel loggerLevel) : this
ChangeName(loggerName);
}
-#if FEATURE_REMOTING
- ///
- /// Keep the instance alive in a remoting scenario
- ///
- public override object InitializeLifetimeService()
- {
- return null;
- }
-#endif
-
public abstract ILogger CreateChildLogger(string loggerName);
///
diff --git a/src/Castle.Core/DynamicProxy/AllMethodsHook.cs b/src/Castle.Core/DynamicProxy/AllMethodsHook.cs
index fd6ccc2a3a..f367493274 100644
--- a/src/Castle.Core/DynamicProxy/AllMethodsHook.cs
+++ b/src/Castle.Core/DynamicProxy/AllMethodsHook.cs
@@ -26,10 +26,8 @@ public class AllMethodsHook : IProxyGenerationHook
protected static readonly ICollection SkippedTypes = new[]
{
typeof(object),
-#if FEATURE_REMOTING
typeof(MarshalByRefObject),
typeof(ContextBoundObject)
-#endif
};
public virtual bool ShouldInterceptMethod(Type type, MethodInfo methodInfo)
diff --git a/src/Castle.Core/DynamicProxy/Contributors/MembersCollector.cs b/src/Castle.Core/DynamicProxy/Contributors/MembersCollector.cs
index 0deafce754..e65b4bade9 100644
--- a/src/Castle.Core/DynamicProxy/Contributors/MembersCollector.cs
+++ b/src/Castle.Core/DynamicProxy/Contributors/MembersCollector.cs
@@ -203,10 +203,7 @@ protected bool AcceptMethod(MethodInfo method, bool onlyVirtuals, IProxyGenerati
var isOverridable = method.IsVirtual && !method.IsFinal;
if (onlyVirtuals && !isOverridable)
{
- if (
-#if FEATURE_REMOTING
- method.DeclaringType != typeof(MarshalByRefObject) &&
-#endif
+ if (method.DeclaringType != typeof(MarshalByRefObject) &&
method.IsGetType() == false &&
method.IsMemberwiseClone() == false)
{
@@ -231,12 +228,11 @@ protected bool AcceptMethod(MethodInfo method, bool onlyVirtuals, IProxyGenerati
return false;
}
-#if FEATURE_REMOTING
if (method.DeclaringType == typeof(MarshalByRefObject))
{
return false;
}
-#endif
+
if (method.IsFinalizer())
{
return false;
diff --git a/src/Castle.Core/DynamicProxy/ProxyGenerator.cs b/src/Castle.Core/DynamicProxy/ProxyGenerator.cs
index 27464377ea..87211c6651 100644
--- a/src/Castle.Core/DynamicProxy/ProxyGenerator.cs
+++ b/src/Castle.Core/DynamicProxy/ProxyGenerator.cs
@@ -19,9 +19,6 @@ namespace Castle.DynamicProxy
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
-#if FEATURE_REMOTING
- using System.Runtime.Remoting;
-#endif
using System.Text;
using Castle.Core.Internal;
@@ -559,13 +556,9 @@ public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, object targe
throw new ArgumentException("Specified type is not an interface", "interfaceToProxy");
}
- var isRemotingProxy = false;
-#if FEATURE_REMOTING
if (target != null)
{
- isRemotingProxy = RemotingServices.IsTransparentProxy(target);
-
- if (!isRemotingProxy && Marshal.IsComObject(target))
+ if (Marshal.IsComObject(target))
{
var interfaceId = interfaceToProxy.GUID;
if (interfaceId != Guid.Empty)
@@ -588,7 +581,6 @@ public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, object targe
}
}
}
-#endif
CheckNotGenericTypeDefinition(interfaceToProxy, "interfaceToProxy");
CheckNotGenericTypeDefinitions(additionalInterfacesToProxy, "additionalInterfacesToProxy");
@@ -596,14 +588,6 @@ public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, object targe
var generatedType = CreateInterfaceProxyTypeWithTargetInterface(interfaceToProxy, additionalInterfacesToProxy,
options);
var arguments = GetConstructorArguments(target, interceptors, options);
- if (isRemotingProxy)
- {
- var constructors = generatedType.GetConstructors();
-
- // one .ctor to rule them all
- Debug.Assert(constructors.Length == 1, "constructors.Length == 1");
- return constructors[0].Invoke(arguments.ToArray());
- }
return Activator.CreateInstance(generatedType, arguments.ToArray());
}
diff --git a/src/Castle.Core/DynamicProxy/ProxyUtil.cs b/src/Castle.Core/DynamicProxy/ProxyUtil.cs
index bb3b3793bd..d137e58601 100644
--- a/src/Castle.Core/DynamicProxy/ProxyUtil.cs
+++ b/src/Castle.Core/DynamicProxy/ProxyUtil.cs
@@ -21,10 +21,6 @@ namespace Castle.DynamicProxy
using System.Runtime.CompilerServices;
using System.Threading;
-#if FEATURE_REMOTING
- using System.Runtime.Remoting;
-#endif
-
using Castle.Core.Internal;
using Castle.DynamicProxy.Generators;
using Castle.DynamicProxy.Internal;
@@ -85,15 +81,9 @@ public static Delegate CreateDelegateToMixin(object proxy, Type delegateType)
public static object GetUnproxiedInstance(object instance)
{
-#if FEATURE_REMOTING
- if (!RemotingServices.IsTransparentProxy(instance))
-#endif
+ if (instance is IProxyTargetAccessor accessor)
{
- var accessor = instance as IProxyTargetAccessor;
- if (accessor != null)
- {
- instance = accessor.DynProxyGetTarget();
- }
+ instance = accessor.DynProxyGetTarget();
}
return instance;
@@ -101,25 +91,17 @@ public static object GetUnproxiedInstance(object instance)
public static Type GetUnproxiedType(object instance)
{
-#if FEATURE_REMOTING
- if (!RemotingServices.IsTransparentProxy(instance))
-#endif
+ if (instance is IProxyTargetAccessor accessor)
{
- var accessor = instance as IProxyTargetAccessor;
-
- if (accessor != null)
+ var target = accessor.DynProxyGetTarget();
+ if (target != null)
{
- var target = accessor.DynProxyGetTarget();
-
- if (target != null)
+ if (ReferenceEquals(target, instance))
{
- if (ReferenceEquals(target, instance))
- {
- return instance.GetType().BaseType;
- }
-
- instance = target;
+ return instance.GetType().BaseType;
}
+
+ instance = target;
}
}
@@ -128,12 +110,6 @@ public static Type GetUnproxiedType(object instance)
public static bool IsProxy(object instance)
{
-#if FEATURE_REMOTING
- if (RemotingServices.IsTransparentProxy(instance))
- {
- return true;
- }
-#endif
return instance is IProxyTargetAccessor;
}
diff --git a/src/Castle.Core/DynamicProxy/StandardInterceptor.cs b/src/Castle.Core/DynamicProxy/StandardInterceptor.cs
index ef0c9dcf3e..0ccb24d86e 100644
--- a/src/Castle.Core/DynamicProxy/StandardInterceptor.cs
+++ b/src/Castle.Core/DynamicProxy/StandardInterceptor.cs
@@ -19,11 +19,7 @@ namespace Castle.DynamicProxy
#if FEATURE_SERIALIZATION
[Serializable]
#endif
- public class StandardInterceptor :
-#if FEATURE_REMOTING
- MarshalByRefObject,
-#endif
- IInterceptor
+ public class StandardInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
diff --git a/src/Castle.Services.Logging.SerilogIntegration/SerilogLogger.cs b/src/Castle.Services.Logging.SerilogIntegration/SerilogLogger.cs
index 5e968d2c31..ae66f789e3 100644
--- a/src/Castle.Services.Logging.SerilogIntegration/SerilogLogger.cs
+++ b/src/Castle.Services.Logging.SerilogIntegration/SerilogLogger.cs
@@ -22,11 +22,7 @@ namespace Castle.Services.Logging.SerilogIntegration
#if FEATURE_SERIALIZATION
[Serializable]
#endif
- public class SerilogLogger :
-#if FEATURE_APPDOMAIN
- MarshalByRefObject,
-#endif
- Castle.Core.Logging.ILogger
+ public class SerilogLogger : Castle.Core.Logging.ILogger
{
public SerilogLogger(ILogger logger, SerilogFactory factory)
{
diff --git a/src/Castle.Services.Logging.log4netIntegration/Log4netLogger.cs b/src/Castle.Services.Logging.log4netIntegration/Log4netLogger.cs
index 8deffb3180..b1386faee4 100644
--- a/src/Castle.Services.Logging.log4netIntegration/Log4netLogger.cs
+++ b/src/Castle.Services.Logging.log4netIntegration/Log4netLogger.cs
@@ -24,11 +24,7 @@ namespace Castle.Services.Logging.Log4netIntegration
#if FEATURE_SERIALIZATION
[Serializable]
#endif
- public class Log4netLogger :
-#if FEATURE_APPDOMAIN
- MarshalByRefObject,
-#endif
- Castle.Core.Logging.ILogger
+ public class Log4netLogger : Castle.Core.Logging.ILogger
{
private static readonly Type declaringType = typeof(Log4netLogger);