From: Jan Kotas Date: Wed, 21 Nov 2018 18:24:11 +0000 (-0800) Subject: Change System.Object to ClassInterface.None (#21137) X-Git-Tag: accepted/tizen/unified/20190422.045933~571 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2079632dfbde7fd398375c201f37533209c4bc21;p=platform%2Fupstream%2Fcoreclr.git Change System.Object to ClassInterface.None (#21137) * Change System.Object to ClassInterface.None Prevents .NET Framework legacy interfaces from leaking out. Fixes https://github.com/dotnet/corefx/issues/33638 * Use AutoDispatch for System.Object --- diff --git a/src/System.Private.CoreLib/src/System/Delegate.cs b/src/System.Private.CoreLib/src/System/Delegate.cs index 0d6c1e1..677f7a1 100644 --- a/src/System.Private.CoreLib/src/System/Delegate.cs +++ b/src/System.Private.CoreLib/src/System/Delegate.cs @@ -2,20 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; + namespace System { - using System; - using System.Reflection; - using System.Runtime; - using System.Threading; - using System.Runtime.Serialization; - using System.Runtime.InteropServices; - using System.Runtime.CompilerServices; - using System.Runtime.Versioning; - using System.Diagnostics; - - [ClassInterface(ClassInterfaceType.AutoDual)] - [System.Runtime.InteropServices.ComVisible(true)] + [ClassInterface(ClassInterfaceType.None)] + [ComVisible(true)] public abstract class Delegate : ICloneable, ISerializable { // _target is the object we will invoke on diff --git a/src/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/System.Private.CoreLib/src/System/MulticastDelegate.cs index 2634819..e0ffd0f 100644 --- a/src/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -2,16 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; +using System.Diagnostics; using System.Reflection; +using System.Runtime.InteropServices; using System.Runtime.Serialization; -using System.Diagnostics; -using System.Reflection.Emit; + using Internal.Runtime.CompilerServices; namespace System { - [System.Runtime.InteropServices.ComVisible(true)] + [ClassInterface(ClassInterfaceType.None)] + [ComVisible(true)] public abstract class MulticastDelegate : Delegate { // This is set under 3 circumstances @@ -42,7 +43,7 @@ namespace System internal bool InvocationListLogicallyNull() { - return (_invocationList == null) || (_invocationList is LoaderAllocator) || (_invocationList is DynamicResolver); + return (_invocationList == null) || (_invocationList is LoaderAllocator) || (_invocationList is System.Reflection.Emit.DynamicResolver); } public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/src/System.Private.CoreLib/src/System/Object.cs b/src/System.Private.CoreLib/src/System/Object.cs index 5cf1d0c..0c8442b 100644 --- a/src/System.Private.CoreLib/src/System/Object.cs +++ b/src/System.Private.CoreLib/src/System/Object.cs @@ -22,12 +22,11 @@ namespace System // is the super class for all other CLR objects and provide a set of methods and low level // services to subclasses. These services include object synchronization and support for clone // operations. - // - //This class contains no data and does not need to be serializable + // [Serializable] - [ClassInterface(ClassInterfaceType.AutoDual)] - [System.Runtime.InteropServices.ComVisible(true)] - [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [ClassInterface(ClassInterfaceType.AutoDispatch)] + [ComVisible(true)] + [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Object { // Creates a new instance of an Object. @@ -114,8 +113,8 @@ namespace System // The name "__Canon" will never been seen by users but it will appear a lot in debugger stack traces // involving generics so it is kept deliberately short as to avoid being a nuisance. - [ClassInterface(ClassInterfaceType.AutoDual)] - [System.Runtime.InteropServices.ComVisible(true)] + [ClassInterface(ClassInterfaceType.None)] + [ComVisible(true)] internal class __Canon { }