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 support for remoting #507

Merged
merged 1 commit into from Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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)
- Removed 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)
Expand Down
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -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:
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/common.props
Expand Up @@ -45,7 +45,7 @@
<DiagnosticsConstants>DEBUG</DiagnosticsConstants>
<NetStandard20Constants>TRACE</NetStandard20Constants>
<NetStandard21Constants>TRACE</NetStandard21Constants>
<CommonDesktopClrConstants>TRACE;FEATURE_APPDOMAIN;FEATURE_ASSEMBLYBUILDER_SAVE;FEATURE_EVENTLOG;FEATURE_REMOTING;FEATURE_SERIALIZATION;FEATURE_SYSTEM_CONFIGURATION;FEATURE_TEST_COM;FEATURE_TEST_WINFORMS</CommonDesktopClrConstants>
<CommonDesktopClrConstants>TRACE;FEATURE_APPDOMAIN;FEATURE_ASSEMBLYBUILDER_SAVE;FEATURE_EVENTLOG;FEATURE_SERIALIZATION;FEATURE_SYSTEM_CONFIGURATION;FEATURE_TEST_COM;FEATURE_TEST_WINFORMS</CommonDesktopClrConstants>
<DesktopClrConstants Condition="'$(OS)'=='Unix'">$(CommonDesktopClrConstants)</DesktopClrConstants>
<DesktopClrConstants Condition="'$(OS)'=='Windows_NT'">$(CommonDesktopClrConstants);FEATURE_TEST_PEVERIFY</DesktopClrConstants>
</PropertyGroup>
Expand Down
11 changes: 5 additions & 6 deletions ref/Castle.Core-net45.cs
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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) { }
Expand Down Expand Up @@ -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) { }
Expand Down Expand Up @@ -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<string> messageFactory) { }
public void Trace(string message) { }
Expand Down Expand Up @@ -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) { }
Expand Down
2 changes: 1 addition & 1 deletion ref/Castle.Services.Logging.SerilogIntegration-net45.cs
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion ref/Castle.Services.Logging.log4netIntegration-net45.cs
Expand Up @@ -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; }
Expand Down
Expand Up @@ -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)
{
Expand Down
Expand Up @@ -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()
{
Expand Down
Expand Up @@ -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
{
/// <summary>
/// Creates a new extended logger, getting the logger name from the specified type.
Expand Down
6 changes: 1 addition & 5 deletions src/Castle.Core/Core/Logging/AbstractLoggerFactory.cs
Expand Up @@ -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)
{
Expand Down
6 changes: 1 addition & 5 deletions src/Castle.Core/Core/Logging/ConsoleFactory.cs
Expand Up @@ -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;

Expand Down
16 changes: 1 addition & 15 deletions src/Castle.Core/Core/Logging/LevelFilteredLogger.cs
Expand Up @@ -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";
Expand All @@ -56,16 +52,6 @@ protected LevelFilteredLogger(String loggerName, LoggerLevel loggerLevel) : this
ChangeName(loggerName);
}

#if FEATURE_REMOTING
/// <summary>
/// Keep the instance alive in a remoting scenario
/// </summary>
public override object InitializeLifetimeService()
{
return null;
}
#endif

public abstract ILogger CreateChildLogger(string loggerName);

/// <value>
Expand Down
2 changes: 0 additions & 2 deletions src/Castle.Core/DynamicProxy/AllMethodsHook.cs
Expand Up @@ -26,10 +26,8 @@ public class AllMethodsHook : IProxyGenerationHook
protected static readonly ICollection<Type> SkippedTypes = new[]
{
typeof(object),
#if FEATURE_REMOTING
typeof(MarshalByRefObject),
typeof(ContextBoundObject)
#endif
};

public virtual bool ShouldInterceptMethod(Type type, MethodInfo methodInfo)
Expand Down
8 changes: 2 additions & 6 deletions src/Castle.Core/DynamicProxy/Contributors/MembersCollector.cs
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down
18 changes: 1 addition & 17 deletions src/Castle.Core/DynamicProxy/ProxyGenerator.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
jonorossi marked this conversation as resolved.
Show resolved Hide resolved
{
var interfaceId = interfaceToProxy.GUID;
if (interfaceId != Guid.Empty)
Expand All @@ -588,22 +581,13 @@ public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, object targe
}
}
}
#endif

CheckNotGenericTypeDefinition(interfaceToProxy, "interfaceToProxy");
CheckNotGenericTypeDefinitions(additionalInterfacesToProxy, "additionalInterfacesToProxy");

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());
}

Expand Down
42 changes: 9 additions & 33 deletions src/Castle.Core/DynamicProxy/ProxyUtil.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -85,41 +81,27 @@ 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;
}

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;
}
}

Expand All @@ -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
jonorossi marked this conversation as resolved.
Show resolved Hide resolved
return instance is IProxyTargetAccessor;
}

Expand Down
6 changes: 1 addition & 5 deletions src/Castle.Core/DynamicProxy/StandardInterceptor.cs
Expand Up @@ -19,11 +19,7 @@ namespace Castle.DynamicProxy
#if FEATURE_SERIALIZATION
[Serializable]
#endif
jonorossi marked this conversation as resolved.
Show resolved Hide resolved
public class StandardInterceptor :
#if FEATURE_REMOTING
MarshalByRefObject,
#endif
IInterceptor
public class StandardInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
Expand Down
Expand Up @@ -22,11 +22,7 @@ namespace Castle.Services.Logging.SerilogIntegration
#if FEATURE_SERIALIZATION
[Serializable]
#endif
public class SerilogLogger :
#if FEATURE_APPDOMAIN
MarshalByRefObject,
#endif
jonorossi marked this conversation as resolved.
Show resolved Hide resolved
Castle.Core.Logging.ILogger
public class SerilogLogger : Castle.Core.Logging.ILogger
{
public SerilogLogger(ILogger logger, SerilogFactory factory)
{
Expand Down
Expand Up @@ -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);

Expand Down