Moving MissingFieldException (fully) and MissingMethodException (partially) to shared...
authorMaryam Ariyan <maryam.ariyan@microsoft.com>
Thu, 31 May 2018 02:55:47 +0000 (19:55 -0700)
committerJan Kotas <jkotas@microsoft.com>
Thu, 31 May 2018 02:55:47 +0000 (19:55 -0700)
src/System.Private.CoreLib/System.Private.CoreLib.csproj
src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
src/System.Private.CoreLib/shared/System/MissingFieldException.cs [moved from src/System.Private.CoreLib/src/System/MissingFieldException.cs with 71% similarity]
src/System.Private.CoreLib/shared/System/MissingMemberException.cs [moved from src/System.Private.CoreLib/src/System/MissingMemberException.cs with 74% similarity]
src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs [new file with mode: 0644]
src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs
src/System.Private.CoreLib/src/System/MissingMemberException.CoreCLR.cs [new file with mode: 0644]
src/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs
src/System.Private.CoreLib/src/System/ThrowHelper.cs
src/System.Private.CoreLib/src/System/TypeLoadException.cs

index 6ef1f04..82cbf53 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Math.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\MathF.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\mda.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\MissingFieldException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\MissingMemberException.cs" />
+    <Compile Include="$(BclSourcesRoot)\System\MissingMemberException.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Number.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\PinnableBufferCache.cs" />
     <Compile Include="$(BclSourcesRoot)\System\RtType.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Debugger.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\ICustomDebuggerNotification.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Stacktrace.cs" />
+    <Compile Include="$(BclSourcesRoot)\System\Diagnostics\StackFrameHelper.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\StackFrame.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\EditAndContinueHelper.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\EventSource_CoreCLR.cs" />
index 06ef620..2574b91 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\MemoryExtensions.Fast.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\MethodAccessException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\MidpointRounding.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\MissingFieldException.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\MissingMemberException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\MissingMethodException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\MulticastNotSupportedException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\NotFiniteNumberException.cs" />
@@ -2,18 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*=============================================================================
-**
-**
-** Purpose: The exception class for class loading failures.
-**
-=============================================================================*/
-
-
-using System;
 using System.Runtime.Serialization;
-using System.Runtime.CompilerServices;
-using System.Globalization;
 
 namespace System
 {
@@ -39,11 +28,18 @@ namespace System
             HResult = HResults.COR_E_MISSINGFIELD;
         }
 
-        protected MissingFieldException(SerializationInfo info, StreamingContext context) : base(info, context)
+        public MissingFieldException(string className, string fieldName)
+        {
+            ClassName = className;
+            MemberName = fieldName;
+        }
+
+        protected MissingFieldException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
         {
         }
 
-        public override String Message
+        public override string Message
         {
             get
             {
@@ -58,15 +54,5 @@ namespace System
                 }
             }
         }
-
-        public MissingFieldException(String className, String fieldName)
-        {
-            ClassName = className;
-            MemberName = fieldName;
-        }
-
-        // If ClassName != null, Message will construct on the fly using it
-        // and the other variables. This allows customization of the
-        // format depending on the language environment.
     }
 }
@@ -2,24 +2,13 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*=============================================================================
-**
-**
-**
-** Purpose: The exception class for versioning problems with DLLS.
-**
-**
-=============================================================================*/
-
-
 using System.Runtime.Serialization;
-using System.Runtime.CompilerServices;
 
 namespace System
 {
     [Serializable]
     [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
-    public class MissingMemberException : MemberAccessException, ISerializable
+    public partial class MissingMemberException : MemberAccessException
     {
         public MissingMemberException()
             : base(SR.Arg_MissingMemberException)
@@ -39,14 +28,29 @@ namespace System
             HResult = HResults.COR_E_MISSINGMEMBER;
         }
 
-        protected MissingMemberException(SerializationInfo info, StreamingContext context) : base(info, context)
+        public MissingMemberException(string className, string memberName)
+        {
+            ClassName = className;
+            MemberName = memberName;
+        }
+
+        protected MissingMemberException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
         {
             ClassName = info.GetString("MMClassName");
             MemberName = info.GetString("MMMemberName");
             Signature = (byte[])info.GetValue("MMSignature", typeof(byte[]));
         }
 
-        public override String Message
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+            info.AddValue("MMClassName", ClassName, typeof(string));
+            info.AddValue("MMMemberName", MemberName, typeof(string));
+            info.AddValue("MMSignature", Signature, typeof(byte[]));
+        }
+
+        public override string Message
         {
             get
             {
@@ -57,35 +61,16 @@ namespace System
                 else
                 {
                     // do any desired fixups to classname here.
-                    return SR.Format(SR.MissingMember_Name, ClassName + "." + MemberName + (Signature != null ? " " + FormatSignature(Signature) : ""));
+                    return SR.Format(SR.MissingMember_Name, ClassName + "." + MemberName + (Signature != null ? " " + FormatSignature(Signature) : string.Empty));
                 }
             }
         }
 
-        // Called to format signature
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        internal static extern String FormatSignature(byte[] signature);
-
-        public MissingMemberException(String className, String memberName)
-        {
-            ClassName = className;
-            MemberName = memberName;
-        }
-
-        public override void GetObjectData(SerializationInfo info, StreamingContext context)
-        {
-            base.GetObjectData(info, context);
-            info.AddValue("MMClassName", ClassName, typeof(string));
-            info.AddValue("MMMemberName", MemberName, typeof(string));
-            info.AddValue("MMSignature", Signature, typeof(byte[]));
-        }
-
-
         // If ClassName != null, GetMessage will construct on the fly using it
         // and the other variables. This allows customization of the
         // format depending on the language environment.
-        protected String ClassName;
-        protected String MemberName;
+        protected string ClassName;
+        protected string MemberName;
         protected byte[] Signature;
     }
 }
diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs b/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs
new file mode 100644 (file)
index 0000000..c5a07a2
--- /dev/null
@@ -0,0 +1,186 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// 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.Collections;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.Security;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
+using System.Globalization;
+using System.Runtime.Versioning;
+
+namespace System.Diagnostics
+{
+    // READ ME:
+    // Modifying the order or fields of this object may require other changes 
+    // to the unmanaged definition of the StackFrameHelper class, in 
+    // VM\DebugDebugger.h. The binder will catch some of these layout problems.
+    internal class StackFrameHelper
+    {
+        private Thread targetThread;
+        private int[] rgiOffset;
+        private int[] rgiILOffset;
+
+#pragma warning disable 414
+        // dynamicMethods is an array of System.Resolver objects, used to keep
+        // DynamicMethodDescs alive for the lifetime of StackFrameHelper.
+        private Object dynamicMethods; // Field is not used from managed.        
+
+        private IntPtr[] rgMethodHandle;
+        private string[] rgAssemblyPath;
+        private IntPtr[] rgLoadedPeAddress;
+        private int[] rgiLoadedPeSize;
+        private IntPtr[] rgInMemoryPdbAddress;
+        private int[] rgiInMemoryPdbSize;
+        // if rgiMethodToken[i] == 0, then don't attempt to get the portable PDB source/info
+        private int[] rgiMethodToken;
+        private string[] rgFilename;
+        private int[] rgiLineNumber;
+        private int[] rgiColumnNumber;
+        private bool[] rgiLastFrameFromForeignExceptionStackTrace;
+        private int iFrameCount;
+#pragma warning restore 414
+
+        private delegate void GetSourceLineInfoDelegate(string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize,
+            IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset,
+            out string sourceFile, out int sourceLine, out int sourceColumn);
+
+        private static GetSourceLineInfoDelegate s_getSourceLineInfo = null;
+
+        [ThreadStatic]
+        private static int t_reentrancy = 0;
+
+        public StackFrameHelper(Thread target)
+        {
+            targetThread = target;
+            rgMethodHandle = null;
+            rgiMethodToken = null;
+            rgiOffset = null;
+            rgiILOffset = null;
+            rgAssemblyPath = null;
+            rgLoadedPeAddress = null;
+            rgiLoadedPeSize = null;
+            rgInMemoryPdbAddress = null;
+            rgiInMemoryPdbSize = null;
+            dynamicMethods = null;
+            rgFilename = null;
+            rgiLineNumber = null;
+            rgiColumnNumber = null;
+
+            rgiLastFrameFromForeignExceptionStackTrace = null;
+
+            // 0 means capture all frames.  For StackTraces from an Exception, the EE always
+            // captures all frames.  For other uses of StackTraces, we can abort stack walking after
+            // some limit if we want to by setting this to a non-zero value.  In Whidbey this was 
+            // hard-coded to 512, but some customers complained.  There shouldn't be any need to limit
+            // this as memory/CPU is no longer allocated up front.  If there is some reason to provide a
+            // limit in the future, then we should expose it in the managed API so applications can 
+            // override it.
+            iFrameCount = 0;
+        }
+
+        //
+        // Initializes the stack trace helper. If fNeedFileInfo is true, initializes rgFilename, 
+        // rgiLineNumber and rgiColumnNumber fields using the portable PDB reader if not already
+        // done by GetStackFramesInternal (on Windows for old PDB format).
+        //
+        internal void InitializeSourceInfo(int iSkip, bool fNeedFileInfo, Exception exception)
+        {
+            StackTrace.GetStackFramesInternal(this, iSkip, fNeedFileInfo, exception);
+
+            if (!fNeedFileInfo)
+                return;
+
+            // Check if this function is being reentered because of an exception in the code below
+            if (t_reentrancy > 0)
+                return;
+
+            t_reentrancy++;
+            try
+            {
+                if (s_getSourceLineInfo == null)
+                {
+                    Type symbolsType = Type.GetType(
+                        "System.Diagnostics.StackTraceSymbols, System.Diagnostics.StackTrace, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
+                        throwOnError: false);
+
+                    if (symbolsType == null)
+                    {
+                        return;
+                    }
+
+                    MethodInfo symbolsMethodInfo = symbolsType.GetMethod("GetSourceLineInfo", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+                    if (symbolsMethodInfo == null)
+                    {
+                        return;
+                    }
+
+                    // Create an instance of System.Diagnostics.Stacktrace.Symbols
+                    object target = Activator.CreateInstance(symbolsType);
+
+                    // Create an instance delegate for the GetSourceLineInfo method
+                    GetSourceLineInfoDelegate getSourceLineInfo = (GetSourceLineInfoDelegate)symbolsMethodInfo.CreateDelegate(typeof(GetSourceLineInfoDelegate), target);
+
+                    // We could race with another thread. It doesn't matter if we win or lose, the losing instance will be GC'ed and all threads including this one will
+                    // use the winning instance
+                    Interlocked.CompareExchange(ref s_getSourceLineInfo, getSourceLineInfo, null);
+                }
+
+                for (int index = 0; index < iFrameCount; index++)
+                {
+                    // If there was some reason not to try get the symbols from the portable PDB reader like the module was
+                    // ENC or the source/line info was already retrieved, the method token is 0.
+                    if (rgiMethodToken[index] != 0)
+                    {
+                        s_getSourceLineInfo(rgAssemblyPath[index], rgLoadedPeAddress[index], rgiLoadedPeSize[index],
+                            rgInMemoryPdbAddress[index], rgiInMemoryPdbSize[index], rgiMethodToken[index],
+                            rgiILOffset[index], out rgFilename[index], out rgiLineNumber[index], out rgiColumnNumber[index]);
+                    }
+                }
+            }
+            catch
+            {
+            }
+            finally
+            {
+                t_reentrancy--;
+            }
+        }
+
+        public virtual MethodBase GetMethodBase(int i)
+        {
+            // There may be a better way to do this.
+            // we got RuntimeMethodHandles here and we need to go to MethodBase
+            // but we don't know whether the reflection info has been initialized
+            // or not. So we call GetMethods and GetConstructors on the type
+            // and then we fetch the proper MethodBase!!
+            IntPtr mh = rgMethodHandle[i];
+
+            if (mh == IntPtr.Zero)
+                return null;
+
+            IRuntimeMethodInfo mhReal = RuntimeMethodHandle.GetTypicalMethodDefinition(new RuntimeMethodInfoStub(mh, this));
+
+            return RuntimeType.GetMethodBase(mhReal);
+        }
+
+        public virtual int GetOffset(int i) { return rgiOffset[i]; }
+        public virtual int GetILOffset(int i) { return rgiILOffset[i]; }
+        public virtual string GetFilename(int i) { return rgFilename == null ? null : rgFilename[i]; }
+        public virtual int GetLineNumber(int i) { return rgiLineNumber == null ? 0 : rgiLineNumber[i]; }
+        public virtual int GetColumnNumber(int i) { return rgiColumnNumber == null ? 0 : rgiColumnNumber[i]; }
+
+        public virtual bool IsLastFrameFromForeignExceptionStackTrace(int i)
+        {
+            return (rgiLastFrameFromForeignExceptionStackTrace == null) ? false : rgiLastFrameFromForeignExceptionStackTrace[i];
+        }
+
+        public virtual int GetNumberOfFrames() { return iFrameCount; }
+    }
+}
\ No newline at end of file
index 08363d2..3e4da5c 100644 (file)
 // 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.Collections;
 using System.Collections.Generic;
-using System.Text;
-using System.Threading;
-using System.Security;
-using System.IO;
+using System.Globalization;
 using System.Reflection;
-using System.Runtime.InteropServices;
 using System.Runtime.CompilerServices;
-using System.Globalization;
-using System.Runtime.Versioning;
+using System.Security;
+using System.Text;
+using System.Threading;
 
 namespace System.Diagnostics
 {
-    // READ ME:
-    // Modifying the order or fields of this object may require other changes 
-    // to the unmanaged definition of the StackFrameHelper class, in 
-    // VM\DebugDebugger.h. The binder will catch some of these layout problems.
-    internal class StackFrameHelper
-    {
-        private Thread targetThread;
-        private int[] rgiOffset;
-        private int[] rgiILOffset;
-
-#pragma warning disable 414
-        // dynamicMethods is an array of System.Resolver objects, used to keep
-        // DynamicMethodDescs alive for the lifetime of StackFrameHelper.
-        private Object dynamicMethods; // Field is not used from managed.        
-
-        private IntPtr[] rgMethodHandle;
-        private string[] rgAssemblyPath;
-        private IntPtr[] rgLoadedPeAddress;
-        private int[] rgiLoadedPeSize;
-        private IntPtr[] rgInMemoryPdbAddress;
-        private int[] rgiInMemoryPdbSize;
-        // if rgiMethodToken[i] == 0, then don't attempt to get the portable PDB source/info
-        private int[] rgiMethodToken;
-        private string[] rgFilename;
-        private int[] rgiLineNumber;
-        private int[] rgiColumnNumber;
-        private bool[] rgiLastFrameFromForeignExceptionStackTrace;
-        private int iFrameCount;
-#pragma warning restore 414
-
-        private delegate void GetSourceLineInfoDelegate(string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize,
-            IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset,
-            out string sourceFile, out int sourceLine, out int sourceColumn);
-
-        private static GetSourceLineInfoDelegate s_getSourceLineInfo = null;
-
-        [ThreadStatic]
-        private static int t_reentrancy = 0;
-
-        public StackFrameHelper(Thread target)
-        {
-            targetThread = target;
-            rgMethodHandle = null;
-            rgiMethodToken = null;
-            rgiOffset = null;
-            rgiILOffset = null;
-            rgAssemblyPath = null;
-            rgLoadedPeAddress = null;
-            rgiLoadedPeSize = null;
-            rgInMemoryPdbAddress = null;
-            rgiInMemoryPdbSize = null;
-            dynamicMethods = null;
-            rgFilename = null;
-            rgiLineNumber = null;
-            rgiColumnNumber = null;
-
-            rgiLastFrameFromForeignExceptionStackTrace = null;
-
-            // 0 means capture all frames.  For StackTraces from an Exception, the EE always
-            // captures all frames.  For other uses of StackTraces, we can abort stack walking after
-            // some limit if we want to by setting this to a non-zero value.  In Whidbey this was 
-            // hard-coded to 512, but some customers complained.  There shouldn't be any need to limit
-            // this as memory/CPU is no longer allocated up front.  If there is some reason to provide a
-            // limit in the future, then we should expose it in the managed API so applications can 
-            // override it.
-            iFrameCount = 0;
-        }
-
-        //
-        // Initializes the stack trace helper. If fNeedFileInfo is true, initializes rgFilename, 
-        // rgiLineNumber and rgiColumnNumber fields using the portable PDB reader if not already
-        // done by GetStackFramesInternal (on Windows for old PDB format).
-        //
-        internal void InitializeSourceInfo(int iSkip, bool fNeedFileInfo, Exception exception)
-        {
-            StackTrace.GetStackFramesInternal(this, iSkip, fNeedFileInfo, exception);
-
-            if (!fNeedFileInfo)
-                return;
-
-            // Check if this function is being reentered because of an exception in the code below
-            if (t_reentrancy > 0)
-                return;
-
-            t_reentrancy++;
-            try
-            {
-                if (s_getSourceLineInfo == null)
-                {
-                    Type symbolsType = Type.GetType(
-                        "System.Diagnostics.StackTraceSymbols, System.Diagnostics.StackTrace, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
-                        throwOnError: false);
-
-                    if (symbolsType == null)
-                    {
-                        return;
-                    }
-
-                    MethodInfo symbolsMethodInfo = symbolsType.GetMethod("GetSourceLineInfo", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
-                    if (symbolsMethodInfo == null)
-                    {
-                        return;
-                    }
-
-                    // Create an instance of System.Diagnostics.Stacktrace.Symbols
-                    object target = Activator.CreateInstance(symbolsType);
-
-                    // Create an instance delegate for the GetSourceLineInfo method
-                    GetSourceLineInfoDelegate getSourceLineInfo = (GetSourceLineInfoDelegate)symbolsMethodInfo.CreateDelegate(typeof(GetSourceLineInfoDelegate), target);
-
-                    // We could race with another thread. It doesn't matter if we win or lose, the losing instance will be GC'ed and all threads including this one will
-                    // use the winning instance
-                    Interlocked.CompareExchange(ref s_getSourceLineInfo, getSourceLineInfo, null);
-                }
-
-                for (int index = 0; index < iFrameCount; index++)
-                {
-                    // If there was some reason not to try get the symbols from the portable PDB reader like the module was
-                    // ENC or the source/line info was already retrieved, the method token is 0.
-                    if (rgiMethodToken[index] != 0)
-                    {
-                        s_getSourceLineInfo(rgAssemblyPath[index], rgLoadedPeAddress[index], rgiLoadedPeSize[index],
-                            rgInMemoryPdbAddress[index], rgiInMemoryPdbSize[index], rgiMethodToken[index],
-                            rgiILOffset[index], out rgFilename[index], out rgiLineNumber[index], out rgiColumnNumber[index]);
-                    }
-                }
-            }
-            catch
-            {
-            }
-            finally
-            {
-                t_reentrancy--;
-            }
-        }
-
-        public virtual MethodBase GetMethodBase(int i)
-        {
-            // There may be a better way to do this.
-            // we got RuntimeMethodHandles here and we need to go to MethodBase
-            // but we don't know whether the reflection info has been initialized
-            // or not. So we call GetMethods and GetConstructors on the type
-            // and then we fetch the proper MethodBase!!
-            IntPtr mh = rgMethodHandle[i];
-
-            if (mh == IntPtr.Zero)
-                return null;
-
-            IRuntimeMethodInfo mhReal = RuntimeMethodHandle.GetTypicalMethodDefinition(new RuntimeMethodInfoStub(mh, this));
-
-            return RuntimeType.GetMethodBase(mhReal);
-        }
-
-        public virtual int GetOffset(int i) { return rgiOffset[i]; }
-        public virtual int GetILOffset(int i) { return rgiILOffset[i]; }
-        public virtual string GetFilename(int i) { return rgFilename == null ? null : rgFilename[i]; }
-        public virtual int GetLineNumber(int i) { return rgiLineNumber == null ? 0 : rgiLineNumber[i]; }
-        public virtual int GetColumnNumber(int i) { return rgiColumnNumber == null ? 0 : rgiColumnNumber[i]; }
-
-        public virtual bool IsLastFrameFromForeignExceptionStackTrace(int i)
-        {
-            return (rgiLastFrameFromForeignExceptionStackTrace == null) ? false : rgiLastFrameFromForeignExceptionStackTrace[i];
-        }
-
-        public virtual int GetNumberOfFrames() { return iFrameCount; }
-    }
-
-
-    // Class which represents a description of a stack trace
-    // There is no good reason for the methods of this class to be virtual.  
+    /// <summary>
+    /// Class which represents a description of a stack trace
+    /// There is no good reason for the methods of this class to be virtual.
+    /// In order to ensure trusted code can trust the data it gets from a
+    /// StackTrace, we use an InheritanceDemand to prevent partially-trusted
+    /// subclasses.
+    /// </summary>
     public class StackTrace
     {
-        private StackFrame[] frames;
         private int m_iNumOfFrames;
         public const int METHODS_TO_SKIP = 0;
         private int m_iMethodsToSkip;
-
-        // Constructs a stack trace from the current location.
+        
+        /// <summary>
+        /// Stack frames comprising this stack trace.
+        /// </summary>
+        private StackFrame[] _stackFrames;
+
+        /// <summary>
+        /// Constructs a stack trace from the current location.
+        /// </summary>
         public StackTrace()
         {
             m_iNumOfFrames = 0;
@@ -202,8 +41,9 @@ namespace System.Diagnostics
             CaptureStackTrace(METHODS_TO_SKIP, false, null, null);
         }
 
-        // Constructs a stack trace from the current location.
-        //
+        /// <summary>
+        /// Constructs a stack trace from the current location.
+        /// </summary>
         public StackTrace(bool fNeedFileInfo)
         {
             m_iNumOfFrames = 0;
@@ -211,9 +51,10 @@ namespace System.Diagnostics
             CaptureStackTrace(METHODS_TO_SKIP, fNeedFileInfo, null, null);
         }
 
-        // Constructs a stack trace from the current location, in a caller's
-        // frame
-        //
+        /// <summary>
+        /// Constructs a stack trace from the current location, in a caller's
+        /// frame
+        /// </summary>
         public StackTrace(int skipFrames)
         {
             if (skipFrames < 0)
@@ -226,9 +67,10 @@ namespace System.Diagnostics
             CaptureStackTrace(skipFrames + METHODS_TO_SKIP, false, null, null);
         }
 
-        // Constructs a stack trace from the current location, in a caller's
-        // frame
-        //
+        /// <summary>
+        /// Constructs a stack trace from the current location, in a caller's
+        /// frame
+        /// </summary>
         public StackTrace(int skipFrames, bool fNeedFileInfo)
         {
             if (skipFrames < 0)
@@ -241,8 +83,9 @@ namespace System.Diagnostics
             CaptureStackTrace(skipFrames + METHODS_TO_SKIP, fNeedFileInfo, null, null);
         }
 
-
-        // Constructs a stack trace from the current location.
+        /// <summary>
+        /// Constructs a stack trace from the current location.
+        /// </summary>
         public StackTrace(Exception e)
         {
             if (e == null)
@@ -253,8 +96,9 @@ namespace System.Diagnostics
             CaptureStackTrace(METHODS_TO_SKIP, false, null, e);
         }
 
-        // Constructs a stack trace from the current location.
-        //
+        /// <summary>
+        /// Constructs a stack trace from the current location.
+        /// </summary>
         public StackTrace(Exception e, bool fNeedFileInfo)
         {
             if (e == null)
@@ -265,9 +109,10 @@ namespace System.Diagnostics
             CaptureStackTrace(METHODS_TO_SKIP, fNeedFileInfo, null, e);
         }
 
-        // Constructs a stack trace from the current location, in a caller's
-        // frame
-        //
+        /// <summary>
+        /// Constructs a stack trace from the current location, in a caller's
+        /// frame
+        /// </summary>
         public StackTrace(Exception e, int skipFrames)
         {
             if (e == null)
@@ -283,9 +128,10 @@ namespace System.Diagnostics
             CaptureStackTrace(skipFrames + METHODS_TO_SKIP, false, null, e);
         }
 
-        // Constructs a stack trace from the current location, in a caller's
-        // frame
-        //
+        /// <summary>
+        /// Constructs a stack trace from the current location, in a caller's
+        /// frame
+        /// </summary>
         public StackTrace(Exception e, int skipFrames, bool fNeedFileInfo)
         {
             if (e == null)
@@ -301,14 +147,13 @@ namespace System.Diagnostics
             CaptureStackTrace(skipFrames + METHODS_TO_SKIP, fNeedFileInfo, null, e);
         }
 
-
-        // Constructs a "fake" stack trace, just containing a single frame.  
-        // Does not have the overhead of a full stack trace.
-        //
+        /// <summary>
+        /// Constructs a "fake" stack trace, just containing a single frame.
+        /// Does not have the overhead of a full stack trace.
+        /// </summary>
         public StackTrace(StackFrame frame)
         {
-            frames = new StackFrame[1];
-            frames[0] = frame;
+            _stackFrames = new StackFrame[] { frame };
             m_iMethodsToSkip = 0;
             m_iNumOfFrames = 1;
         }
@@ -345,9 +190,10 @@ namespace System.Diagnostics
             return iRetVal;
         }
 
-        // Retrieves an object with stack trace information encoded.
-        // It leaves out the first "iSkip" lines of the stacktrace.
-        //
+        /// <summary>
+        /// Retrieves an object with stack trace information encoded.
+        /// It leaves out the first "iSkip" lines of the stacktrace.
+        /// </summary>
         private void CaptureStackTrace(int iSkip, bool fNeedFileInfo, Thread targetThread, Exception e)
         {
             m_iMethodsToSkip += iSkip;
@@ -363,7 +209,7 @@ namespace System.Diagnostics
 
             if (m_iNumOfFrames != 0)
             {
-                frames = new StackFrame[m_iNumOfFrames];
+                _stackFrames = new StackFrame[m_iNumOfFrames];
 
                 for (int i = 0; i < m_iNumOfFrames; i++)
                 {
@@ -384,7 +230,7 @@ namespace System.Diagnostics
                         sfTemp.SetColumnNumber(StackF.GetColumnNumber(i));
                     }
 
-                    frames[i] = sfTemp;
+                    _stackFrames[i] = sfTemp;
                 }
 
                 // CalculateFramesToSkip skips all frames in the System.Diagnostics namespace,
@@ -402,56 +248,61 @@ namespace System.Diagnostics
             // In case this is the same object being re-used, set frames to null
             else
             {
-                frames = null;
+                _stackFrames = null;
             }
         }
 
-        // Property to get the number of frames in the stack trace
-        //
+        /// <summary>
+        /// Property to get the number of frames in the stack trace
+        /// </summary>
         public virtual int FrameCount
         {
             get { return m_iNumOfFrames; }
         }
 
-
-        // Returns a given stack frame.  Stack frames are numbered starting at
-        // zero, which is the last stack frame pushed.
-        //
+        /// <summary>
+        /// Returns a given stack frame.  Stack frames are numbered starting at
+        /// zero, which is the last stack frame pushed.
+        /// </summary>
         public virtual StackFrame GetFrame(int index)
         {
-            if ((frames != null) && (index < m_iNumOfFrames) && (index >= 0))
-                return frames[index + m_iMethodsToSkip];
+            if ((_stackFrames != null) && (index < m_iNumOfFrames) && (index >= 0))
+                return _stackFrames[index + m_iMethodsToSkip];
 
             return null;
         }
 
-        // Returns an array of all stack frames for this stacktrace.
-        // The array is ordered and sized such that GetFrames()[i] == GetFrame(i)
-        // The nth element of this array is the same as GetFrame(n). 
-        // The length of the array is the same as FrameCount.
-        // 
+        /// <summary>
+        /// Returns an array of all stack frames for this stacktrace.
+        /// The array is ordered and sized such that GetFrames()[i] == GetFrame(i)
+        /// The nth element of this array is the same as GetFrame(n).
+        /// The length of the array is the same as FrameCount.
+        /// </summary>
         public virtual StackFrame[] GetFrames()
         {
-            if (frames == null || m_iNumOfFrames <= 0)
+            if (_stackFrames == null || m_iNumOfFrames <= 0)
                 return null;
 
             // We have to return a subset of the array. Unfortunately this
             // means we have to allocate a new array and copy over.
             StackFrame[] array = new StackFrame[m_iNumOfFrames];
-            Array.Copy(frames, m_iMethodsToSkip, array, 0, m_iNumOfFrames);
+            Array.Copy(_stackFrames, m_iMethodsToSkip, array, 0, m_iNumOfFrames);
             return array;
         }
 
-        // Builds a readable representation of the stack trace
-        //
+        /// <summary>
+        /// Builds a readable representation of the stack trace
+        /// </summary>
         public override string ToString()
         {
             // Include a trailing newline for backwards compatibility
             return ToString(TraceFormat.TrailingNewLine);
         }
 
-        // TraceFormat is Used to specify options for how the 
-        // string-representation of a StackTrace should be generated.
+        /// <summary>
+        /// TraceFormat is Used to specify options for how the 
+        /// string-representation of a StackTrace should be generated.
+        /// </summary>
         internal enum TraceFormat
         {
             Normal,
@@ -459,8 +310,10 @@ namespace System.Diagnostics
             NoResourceLookup    // to prevent infinite resource recusion
         }
 
-        // Builds a readable representation of the stack trace, specifying 
-        // the format for backwards compatibility.
+        /// <summary>
+        /// Builds a readable representation of the stack trace, specifying 
+        /// the format for backwards compatibility.
+        /// </summary>
         internal string ToString(TraceFormat traceFormat)
         {
             bool displayFilenames = true;   // we'll try, but demand may fail
diff --git a/src/System.Private.CoreLib/src/System/MissingMemberException.CoreCLR.cs b/src/System.Private.CoreLib/src/System/MissingMemberException.CoreCLR.cs
new file mode 100644 (file)
index 0000000..9c532cf
--- /dev/null
@@ -0,0 +1,15 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// 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.Runtime.Serialization;
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+    public partial class MissingMemberException : MemberAccessException, ISerializable
+    {
+        [MethodImplAttribute(MethodImplOptions.InternalCall)]
+        internal static extern string FormatSignature(byte[] signature);
+    }
+}
index c000cda..750e873 100644 (file)
@@ -82,7 +82,7 @@ namespace System.Runtime
         // chunks, we don't have to special case this.  Also, we need to
         // deal with 32 bit machines in 3 GB mode.
         // Using Win32's GetSystemInfo should handle all this for us.
-        private static readonly ulong TopOfMemory;
+        private static readonly ulong s_topOfMemory;
 
         // Walking the address space is somewhat expensive, taking around half
         // a millisecond.  Doing that per transaction limits us to a max of 
@@ -90,25 +90,25 @@ namespace System.Runtime
         // walk once every 10 seconds, or when we will likely fail.  This
         // amortization scheme can reduce the cost of a memory gate by about
         // a factor of 100.
-        private static long hiddenLastKnownFreeAddressSpace = 0;
-        private static long hiddenLastTimeCheckingAddressSpace = 0;
+        private static long s_hiddenLastKnownFreeAddressSpace = 0;
+        private static long s_hiddenLastTimeCheckingAddressSpace = 0;
         private const int CheckThreshold = 10 * 1000;  // 10 seconds
 
         private static long LastKnownFreeAddressSpace
         {
-            get { return Volatile.Read(ref hiddenLastKnownFreeAddressSpace); }
-            set { Volatile.Write(ref hiddenLastKnownFreeAddressSpace, value); }
+            get { return Volatile.Read(ref s_hiddenLastKnownFreeAddressSpace); }
+            set { Volatile.Write(ref s_hiddenLastKnownFreeAddressSpace, value); }
         }
 
         private static long AddToLastKnownFreeAddressSpace(long addend)
         {
-            return Interlocked.Add(ref hiddenLastKnownFreeAddressSpace, addend);
+            return Interlocked.Add(ref s_hiddenLastKnownFreeAddressSpace, addend);
         }
 
         private static long LastTimeCheckingAddressSpace
         {
-            get { return Volatile.Read(ref hiddenLastTimeCheckingAddressSpace); }
-            set { Volatile.Write(ref hiddenLastTimeCheckingAddressSpace, value); }
+            get { return Volatile.Read(ref s_hiddenLastTimeCheckingAddressSpace); }
+            set { Volatile.Write(ref s_hiddenLastTimeCheckingAddressSpace, value); }
         }
 
         // When allocating memory segment by segment, we've hit some cases
@@ -130,7 +130,7 @@ namespace System.Runtime
         // Note: This may become dynamically tunable in the future.
         // Also note that we can have different segment sizes for the normal vs. 
         // large object heap.  We currently use the max of the two.
-        private static readonly ulong GCSegmentSize;
+        private static readonly ulong s_GCSegmentSize;
 
         // For multi-threaded workers, we want to ensure that if two workers
         // use a MemoryFailPoint at the same time, and they both succeed, that
@@ -144,7 +144,7 @@ namespace System.Runtime
 
         static MemoryFailPoint()
         {
-            GetMemorySettings(out GCSegmentSize, out TopOfMemory);
+            GetMemorySettings(out s_GCSegmentSize, out s_topOfMemory);
         }
 
         // We can remove this link demand in a future version - we will
@@ -166,8 +166,8 @@ namespace System.Runtime
             // size, not the amount of memory the user wants to allocate.
             // Consider correcting this to reflect free memory within the GC
             // heap, and to check both the normal & large object heaps.
-            ulong segmentSize = (ulong)(Math.Ceiling((double)size / GCSegmentSize) * GCSegmentSize);
-            if (segmentSize >= TopOfMemory)
+            ulong segmentSize = (ulong)(Math.Ceiling((double)size / s_GCSegmentSize) * s_GCSegmentSize);
+            if (segmentSize >= s_topOfMemory)
                 throw new InsufficientMemoryException(SR.InsufficientMemory_MemFailPoint_TooBig);
 
             ulong requestedSizeRounded = (ulong)(Math.Ceiling((double)sizeInMegabytes / MemoryCheckGranularity) * MemoryCheckGranularity);
@@ -356,14 +356,14 @@ namespace System.Runtime
         // this check if we use a MemoryFailPoint with a smaller size next.
         private static unsafe ulong MemFreeAfterAddress(void* address, ulong size)
         {
-            if (size >= TopOfMemory)
+            if (size >= s_topOfMemory)
                 return 0;
 
             ulong largestFreeRegion = 0;
             Win32Native.MEMORY_BASIC_INFORMATION memInfo = new Win32Native.MEMORY_BASIC_INFORMATION();
             UIntPtr sizeOfMemInfo = (UIntPtr)Marshal.SizeOf(memInfo);
 
-            while (((ulong)address) + size < TopOfMemory)
+            while (((ulong)address) + size < s_topOfMemory)
             {
                 UIntPtr r = Win32Native.VirtualQuery(address, ref memInfo, sizeOfMemInfo);
                 if (r == UIntPtr.Zero)
index b1a2fec..7ec7a57 100644 (file)
@@ -4,8 +4,8 @@
 
 
 // This file defines an internal class used to throw exceptions in BCL code.
-// The main purpose is to reduce code size.
-//
+// The main purpose is to reduce code size. 
+// 
 // The old way to throw an exception generates quite a lot IL code and assembly code.
 // Following is an example:
 //     C# source
 //          IL_0012:  newobj     instance void System.ArgumentNullException::.ctor(string,string)
 //          IL_0017:  throw
 //    which is 21bytes in IL.
-//
+// 
 // So we want to get rid of the ldstr and call to Environment.GetResource in IL.
 // In order to do that, I created two enums: ExceptionResource, ExceptionArgument to represent the
-// argument name and resource name in a small integer. The source code will be changed to
+// argument name and resource name in a small integer. The source code will be changed to 
 //    ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key, ExceptionResource.ArgumentNull_Key);
 //
 // The IL code will be 7 bytes.
 //    IL_000a:  call       void System.ThrowHelper::ThrowArgumentNullException(valuetype System.ExceptionArgument)
 //    IL_000f:  ldarg.0
 //
-// This will also reduce the Jitted code size a lot.
-//
-// It is very important we do this for generic classes because we can easily generate the same code
-// multiple times for different instantiation.
+// This will also reduce the Jitted code size a lot. 
 //
+// It is very important we do this for generic classes because we can easily generate the same code 
+// multiple times for different instantiation. 
+// 
 
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Runtime.CompilerServices;
 using System.Runtime.Serialization;
-using System.Diagnostics;
 
 namespace System
 {
index 1b52cc4..6438670 100644 (file)
@@ -32,19 +32,19 @@ namespace System
             HResult = HResults.COR_E_TYPELOAD;
         }
 
-        public TypeLoadException(String message)
+        public TypeLoadException(string message)
             : base(message)
         {
             HResult = HResults.COR_E_TYPELOAD;
         }
 
-        public TypeLoadException(String message, Exception inner)
+        public TypeLoadException(string message, Exception inner)
             : base(message, inner)
         {
             HResult = HResults.COR_E_TYPELOAD;
         }
 
-        public override String Message
+        public override string Message
         {
             get
             {
@@ -68,14 +68,14 @@ namespace System
                     if (ClassName == null)
                         ClassName = SR.IO_UnknownFileName;
 
-                    String format = null;
+                    string format = null;
                     GetTypeLoadExceptionMessage(ResourceId, JitHelpers.GetStringHandleOnStack(ref format));
                     _message = string.Format(CultureInfo.CurrentCulture, format, ClassName, AssemblyName, MessageArg);
                 }
             }
         }
 
-        public String TypeName
+        public string TypeName
         {
             get
             {
@@ -87,9 +87,9 @@ namespace System
         }
 
         // This is called from inside the EE. 
-        private TypeLoadException(String className,
-                                  String assemblyName,
-                                  String messageArg,
+        private TypeLoadException(string className,
+                                  string assemblyName,
+                                  string messageArg,
                                   int resourceId)
         : base(null)
         {
@@ -127,9 +127,9 @@ namespace System
         // If ClassName != null, GetMessage will construct on the fly using it
         // and ResourceId (mscorrc.dll). This allows customization of the
         // class name format depending on the language environment.
-        private String ClassName;
-        private String AssemblyName;
-        private String MessageArg;
+        private string ClassName;
+        private string AssemblyName;
+        private string MessageArg;
         internal int ResourceId;
     }
 }