From af0207c67dda2fe60e176c837d23405f33f781d3 Mon Sep 17 00:00:00 2001 From: Rama krishnan Raghupathy Date: Wed, 12 Oct 2016 10:34:09 -0700 Subject: [PATCH] Exposing MarshalByRefObject (dotnet/coreclr#7558) Commit migrated from https://github.com/dotnet/coreclr/commit/3cdb42e9b5a8ca871b53a27194106707a2db8962 --- src/coreclr/src/mscorlib/model.xml | 3 +++ src/coreclr/src/mscorlib/ref/mscorlib.cs | 4 ++++ .../mscorlib/src/Microsoft/Win32/RegistryKey.cs | 5 ----- .../src/mscorlib/src/System/AppDomainManager.cs | 4 ---- .../src/mscorlib/src/System/ContextBoundObject.cs | 4 ---- .../src/mscorlib/src/System/IO/FileSystemInfo.cs | 4 ---- src/coreclr/src/mscorlib/src/System/IO/Stream.cs | 4 ---- .../src/mscorlib/src/System/IO/TextReader.cs | 4 ---- .../src/mscorlib/src/System/IO/TextWriter.cs | 4 ---- .../src/mscorlib/src/System/MarshalByRefObject.cs | 24 +++++++++++++++++----- .../mscorlib/src/System/Threading/ThreadPool.cs | 4 ---- .../src/mscorlib/src/System/Threading/Timer.cs | 4 ---- .../mscorlib/src/System/Threading/WaitHandle.cs | 4 ---- 13 files changed, 26 insertions(+), 46 deletions(-) diff --git a/src/coreclr/src/mscorlib/model.xml b/src/coreclr/src/mscorlib/model.xml index 445f3b6..e7733ae 100644 --- a/src/coreclr/src/mscorlib/model.xml +++ b/src/coreclr/src/mscorlib/model.xml @@ -3561,6 +3561,9 @@ + + + diff --git a/src/coreclr/src/mscorlib/ref/mscorlib.cs b/src/coreclr/src/mscorlib/ref/mscorlib.cs index 2f0e873..1231d89 100644 --- a/src/coreclr/src/mscorlib/ref/mscorlib.cs +++ b/src/coreclr/src/mscorlib/ref/mscorlib.cs @@ -2490,6 +2490,10 @@ namespace System public abstract partial class MarshalByRefObject { protected MarshalByRefObject() { } + public object GetLifetimeService() { throw null; } + public virtual object InitializeLifetimeService() { throw null; } + protected System.MarshalByRefObject MemberwiseClone(bool cloneIdentity) { throw null; } + } public static partial class Math { diff --git a/src/coreclr/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs b/src/coreclr/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs index dcf31dc..0d6a447 100644 --- a/src/coreclr/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs +++ b/src/coreclr/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs @@ -96,13 +96,8 @@ namespace Microsoft.Win32 { * @security(checkDllCalls=off) * @security(checkClassLinking=on) */ -#if FEATURE_REMOTING [ComVisible(true)] public sealed class RegistryKey : MarshalByRefObject, IDisposable -#else - [ComVisible(true)] - public sealed class RegistryKey : IDisposable -#endif { // We could use const here, if C# supported ELEMENT_TYPE_I fully. diff --git a/src/coreclr/src/mscorlib/src/System/AppDomainManager.cs b/src/coreclr/src/mscorlib/src/System/AppDomainManager.cs index 291099e..dc9fae4 100644 --- a/src/coreclr/src/mscorlib/src/System/AppDomainManager.cs +++ b/src/coreclr/src/mscorlib/src/System/AppDomainManager.cs @@ -39,11 +39,7 @@ namespace System { #if !FEATURE_CORECLR [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)] #endif -#if FEATURE_REMOTING public class AppDomainManager : MarshalByRefObject { -#else // FEATURE_REMOTING - public class AppDomainManager { -#endif // FEATURE_REMOTING public AppDomainManager () {} #if FEATURE_REMOTING [System.Security.SecurityCritical] // auto-generated diff --git a/src/coreclr/src/mscorlib/src/System/ContextBoundObject.cs b/src/coreclr/src/mscorlib/src/System/ContextBoundObject.cs index 01929da..d074ad1 100644 --- a/src/coreclr/src/mscorlib/src/System/ContextBoundObject.cs +++ b/src/coreclr/src/mscorlib/src/System/ContextBoundObject.cs @@ -15,10 +15,6 @@ namespace System { using System.Security.Permissions; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] -#if FEATURE_REMOTING public abstract class ContextBoundObject : MarshalByRefObject { -#else // FEATURE_REMOTING - public abstract class ContextBoundObject { -#endif // FEATURE_REMOTING } } diff --git a/src/coreclr/src/mscorlib/src/System/IO/FileSystemInfo.cs b/src/coreclr/src/mscorlib/src/System/IO/FileSystemInfo.cs index 7a17a41..a35b87f 100644 --- a/src/coreclr/src/mscorlib/src/System/IO/FileSystemInfo.cs +++ b/src/coreclr/src/mscorlib/src/System/IO/FileSystemInfo.cs @@ -32,11 +32,7 @@ namespace System.IO { [FileIOPermissionAttribute(SecurityAction.InheritanceDemand,Unrestricted=true)] #endif [ComVisible(true)] -#if FEATURE_REMOTING public abstract class FileSystemInfo : MarshalByRefObject, ISerializable { -#else // FEATURE_REMOTING - public abstract class FileSystemInfo : ISerializable { -#endif //FEATURE_REMOTING [System.Security.SecurityCritical] // auto-generated internal Win32Native.WIN32_FILE_ATTRIBUTE_DATA _data; // Cache the file information diff --git a/src/coreclr/src/mscorlib/src/System/IO/Stream.cs b/src/coreclr/src/mscorlib/src/System/IO/Stream.cs index 4ec0a31..3b94cec 100644 --- a/src/coreclr/src/mscorlib/src/System/IO/Stream.cs +++ b/src/coreclr/src/mscorlib/src/System/IO/Stream.cs @@ -30,11 +30,7 @@ using System.Reflection; namespace System.IO { [Serializable] [ComVisible(true)] -#if FEATURE_REMOTING public abstract class Stream : MarshalByRefObject, IDisposable { -#else // FEATURE_REMOTING - public abstract class Stream : IDisposable { -#endif // FEATURE_REMOTING public static readonly Stream Null = new NullStream(); diff --git a/src/coreclr/src/mscorlib/src/System/IO/TextReader.cs b/src/coreclr/src/mscorlib/src/System/IO/TextReader.cs index ede4827..b8cacde 100644 --- a/src/coreclr/src/mscorlib/src/System/IO/TextReader.cs +++ b/src/coreclr/src/mscorlib/src/System/IO/TextReader.cs @@ -35,11 +35,7 @@ namespace System.IO { // There are methods on the Stream class for reading bytes. [Serializable] [ComVisible(true)] -#if FEATURE_REMOTING public abstract class TextReader : MarshalByRefObject, IDisposable { -#else // FEATURE_REMOTING - public abstract class TextReader : IDisposable { -#endif // FEATURE_REMOTING public static readonly TextReader Null = new NullTextReader(); diff --git a/src/coreclr/src/mscorlib/src/System/IO/TextWriter.cs b/src/coreclr/src/mscorlib/src/System/IO/TextWriter.cs index 165001e..b923106 100644 --- a/src/coreclr/src/mscorlib/src/System/IO/TextWriter.cs +++ b/src/coreclr/src/mscorlib/src/System/IO/TextWriter.cs @@ -35,11 +35,7 @@ namespace System.IO { // There are methods on the Stream class for writing bytes. [Serializable] [ComVisible(true)] -#if FEATURE_REMOTING public abstract class TextWriter : MarshalByRefObject, IDisposable { -#else // FEATURE_REMOTING - public abstract class TextWriter : IDisposable { -#endif // FEATURE_REMOTING public static readonly TextWriter Null = new NullTextWriter(); // This should be initialized to Environment.NewLine, but diff --git a/src/coreclr/src/mscorlib/src/System/MarshalByRefObject.cs b/src/coreclr/src/mscorlib/src/System/MarshalByRefObject.cs index 4948a43..201aa75 100644 --- a/src/coreclr/src/mscorlib/src/System/MarshalByRefObject.cs +++ b/src/coreclr/src/mscorlib/src/System/MarshalByRefObject.cs @@ -35,7 +35,7 @@ namespace System { [System.Runtime.InteropServices.ComVisible(true)] public abstract class MarshalByRefObject { -#if FEATURE_REMOTING +#if FEATURE_REMOTING private Object __identity; private Object Identity { get { return __identity; } set { __identity = value; } } @@ -87,7 +87,8 @@ namespace System { return t.InvokeMember(name, invokeAttr, binder, this, args, modifiers, culture, namedParameters); } - // Returns a new cloned MBR instance that is a memberwise copy of this + + // Returns a new cloned MBR instance that is a memberwise copy of this // with the identity nulled out, so there are no identity conflicts // when the cloned object is marshalled protected MarshalByRefObject MemberwiseClone(bool cloneIdentity) @@ -98,8 +99,6 @@ namespace System { mbr.Identity = null; return mbr; } - - // A helper routine to extract the identity either from the marshalbyrefobject base // class if it is not a proxy, otherwise from the real proxy. @@ -256,7 +255,22 @@ namespace System { return o.CanCastToXmlType(xmlTypeName, xmlTypeNamespace); } // CanCastToXmlType - +#else + protected MarshalByRefObject() { } + public object GetLifetimeService() + { + throw new PlatformNotSupportedException(); + } + public virtual object InitializeLifetimeService() + { + throw new PlatformNotSupportedException(); + } + protected MarshalByRefObject MemberwiseClone(bool cloneIdentity) + { + MarshalByRefObject mbr = (MarshalByRefObject)base.MemberwiseClone(); + return mbr; + } #endif // FEATURE_REMOTING + } } // namespace diff --git a/src/coreclr/src/mscorlib/src/System/Threading/ThreadPool.cs b/src/coreclr/src/mscorlib/src/System/Threading/ThreadPool.cs index 09fe93c..046dabe 100644 --- a/src/coreclr/src/mscorlib/src/System/Threading/ThreadPool.cs +++ b/src/coreclr/src/mscorlib/src/System/Threading/ThreadPool.cs @@ -1094,11 +1094,7 @@ namespace System.Threading } [System.Runtime.InteropServices.ComVisible(true)] -#if FEATURE_REMOTING public sealed class RegisteredWaitHandle : MarshalByRefObject { -#else // FEATURE_REMOTING - public sealed class RegisteredWaitHandle { -#endif // FEATURE_REMOTING private RegisteredWaitHandleSafe internalRegisteredWait; internal RegisteredWaitHandle() diff --git a/src/coreclr/src/mscorlib/src/System/Threading/Timer.cs b/src/coreclr/src/mscorlib/src/System/Threading/Timer.cs index cb08c6e..99eae69 100644 --- a/src/coreclr/src/mscorlib/src/System/Threading/Timer.cs +++ b/src/coreclr/src/mscorlib/src/System/Threading/Timer.cs @@ -774,11 +774,7 @@ namespace System.Threading [HostProtection(Synchronization=true, ExternalThreading=true)] [System.Runtime.InteropServices.ComVisible(true)] -#if FEATURE_REMOTING public sealed class Timer : MarshalByRefObject, IDisposable -#else // FEATURE_REMOTING - public sealed class Timer : IDisposable -#endif // FEATURE_REMOTING { private const UInt32 MAX_SUPPORTED_TIMEOUT = (uint)0xfffffffe; diff --git a/src/coreclr/src/mscorlib/src/System/Threading/WaitHandle.cs b/src/coreclr/src/mscorlib/src/System/Threading/WaitHandle.cs index 9980c82..b8fbe48 100644 --- a/src/coreclr/src/mscorlib/src/System/Threading/WaitHandle.cs +++ b/src/coreclr/src/mscorlib/src/System/Threading/WaitHandle.cs @@ -28,11 +28,7 @@ namespace System.Threading using Win32Native = Microsoft.Win32.Win32Native; [System.Runtime.InteropServices.ComVisible(true)] -#if FEATURE_REMOTING public abstract class WaitHandle : MarshalByRefObject, IDisposable { -#else // FEATURE_REMOTING - public abstract class WaitHandle : IDisposable { -#endif // FEATURE_REMOTING public const int WaitTimeout = 0x102; private const int MAX_WAITHANDLES = 64; -- 2.7.4