Expose AppDomain apis
authorRahul Kumar <rahku@microsoft.com>
Wed, 28 Sep 2016 00:55:09 +0000 (17:55 -0700)
committerRahul Kumar <rahku@microsoft.com>
Fri, 30 Sep 2016 20:36:09 +0000 (13:36 -0700)
clr.coreclr.props
clrdefinitions.cmake
src/mscorlib/model.xml
src/mscorlib/mscorlib.shared.sources.props
src/mscorlib/ref/mscorlib.cs
src/mscorlib/src/System/AppContext/AppContext.cs
src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs [new file with mode: 0644]

index 50b3b4f..c136fa5 100644 (file)
@@ -21,6 +21,7 @@
     <FeatureDbiOopDebugging_HostOneCoreamd64 Condition="'$(TargetArch)' == 'amd64'">true</FeatureDbiOopDebugging_HostOneCoreamd64>
     <FeatureEventTrace>true</FeatureEventTrace>
     <FeatureExceptionDispatchInfo>true</FeatureExceptionDispatchInfo>
+    <FeatureExceptionNotifications>true</FeatureExceptionNotifications>
     <FeatureFrameworkInternal>true</FeatureFrameworkInternal>
     <FeatureHijack>true</FeatureHijack>
     <FeatureInteropDebugging Condition="('$(TargetArch)' == 'i386') or ('$(TargetArch)' == 'amd64')">true</FeatureInteropDebugging>
index b61ab8f..e088f12 100644 (file)
@@ -118,6 +118,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
     add_definitions(-DFEATURE_EVENTSOURCE_XPLAT=1)
 endif(CLR_CMAKE_PLATFORM_UNIX)
 add_definitions(-DFEATURE_EXCEPTIONDISPATCHINFO)
+add_definitions(-DFEATURE_EXCEPTION_NOTIFICATIONS)
 # NetBSD doesn't implement this feature
 if(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
     add_definitions(-DFEATURE_HIJACK)
index 53f531a..6adb356 100644 (file)
       <Member Name="#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)" />
     </Type>
     <Type Name="System.AppContext">
+      <Member MemberType="Event" Name="FirstChanceException" />
+      <Member MemberType="Event" Name="ProcessExit" />
+      <Member MemberType="Event" Name="UnhandledException" />
+      <Member Name="add_FirstChanceException(System.EventHandler&lt;System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs&gt;)" />
+      <Member Name="add_ProcessExit(System.EventHandler)" />
+      <Member Name="add_UnhandledException(System.UnhandledExceptionEventHandler)" />
       <Member Name="get_BaseDirectory" />
-      <Member MemberType="Property" Name="BaseDirectory" />
       <Member Name="get_TargetFrameworkName" />
-      <Member MemberType="Property" Name="TargetFrameworkName" />
-      <Member Name="DefineSwitchDefault(System.String,System.Boolean)" />
+      <Member Name="GetData(System.String)" />
+      <Member Name="remove_FirstChanceException(System.EventHandler&lt;System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs&gt;)" />
+      <Member Name="remove_ProcessExit(System.EventHandler)" />
+      <Member Name="remove_UnhandledException(System.UnhandledExceptionEventHandler)" />
+      <Member Name="SetData(System.String,System.Object)" />
       <Member Name="SetSwitch(System.String,System.Boolean)" />
       <Member Name="TryGetSwitch(System.String,System.Boolean@)" />
-      <Member Name="GetData(System.String)" />
-      <Member MemberType="Event" Name="UnhandledException" />
+      <Member MemberType="Property" Name="BaseDirectory" />
+      <Member MemberType="Property" Name="TargetFrameworkName" />
     </Type>
     <Type Name="System.ApplicationException">
       <Member Name="#ctor" />
       <Member MemberType="Property" Name="SourceException" />
     </Type>
     <!-- #endif FEATURE_EXCEPTIONDISPATCHINFO -->
+    <Type Name="System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs">
+      <Member Name="#ctor(System.Exception)" />
+      <Member Name="get_Exception" />
+      <Member MemberType="Property" Name="Exception" />
+    </Type>
     <Type Name="System.Runtime.GCLatencyMode">
       <Member MemberType="Field" Name="Batch" />
       <Member MemberType="Field" Name="Interactive" />
index 025c93e..d9b5ca8 100644 (file)
   <ItemGroup>
     <ExceptionservicesSources Condition="'$(FeatureCorruptingExceptions)' == 'true'" Include="$(BclSourcesRoot)\System\Runtime\ExceptionServices\CorruptingExceptionCommon.cs" />
     <ExceptionservicesSources Condition="'$(FeatureExceptionDispatchInfo)' == 'true'" Include="$(BclSourcesRoot)\System\Runtime\ExceptionServices\ExceptionServicesCommon.cs" />
+    <ExceptionservicesSources Condition="'$(FeatureExceptionNotifications)' == 'true'" Include="$(BclSourcesRoot)\System\Runtime\ExceptionServices\ExceptionNotification.cs" />
   </ItemGroup>
   <ItemGroup>
     <HostingSources Condition="'$(FeatureHostAssemblyResolver)' == 'true'" Include="$(BclSourcesRoot)\System\Runtime\Loader\AssemblyLoadContext.cs" />
index 01ab7eb..b51baab 100644 (file)
@@ -138,9 +138,13 @@ namespace System
         public static string TargetFrameworkName { get { throw null; } }
         [System.Security.SecuritySafeCriticalAttribute]
         public static object GetData(string name) { throw null; }
+        [System.Security.SecuritySafeCriticalAttribute]
+        public static void SetData(string name, object data) { }
         public static void SetSwitch(string switchName, bool isEnabled) { }
         public static bool TryGetSwitch(string switchName, out bool isEnabled) { isEnabled = default(bool); throw null; }
         public static event UnhandledExceptionEventHandler UnhandledException { add { } remove { } }
+        public static event System.EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs> FirstChanceException { add { } remove { } }
+        public static event System.EventHandler ProcessExit { add { } remove { } }
     }
     [System.Runtime.InteropServices.ClassInterfaceAttribute((System.Runtime.InteropServices.ClassInterfaceType)(0))]
     [System.Runtime.InteropServices.ComVisibleAttribute(true)]
@@ -10260,6 +10264,11 @@ namespace System.Runtime.ExceptionServices
     {
         public HandleProcessCorruptedStateExceptionsAttribute() { }
     }
+    public sealed partial class FirstChanceExceptionEventArgs : EventArgs
+    {
+        public FirstChanceExceptionEventArgs(Exception exception) { }
+        public Exception Exception { get { throw null; } }
+    }
 }
 namespace System.Runtime.InteropServices
 {
index b318c34..5e78f8d 100644 (file)
@@ -49,6 +49,12 @@ namespace System
             return AppDomain.CurrentDomain.GetData(name);
         }
 
+        [System.Security.SecuritySafeCritical]
+        public static void SetData(string name, object data)
+        {
+            AppDomain.CurrentDomain.SetData(name, data);
+        }
+
         public static event UnhandledExceptionEventHandler UnhandledException
         {
             [System.Security.SecurityCritical]
@@ -64,6 +70,34 @@ namespace System
             }
         }
 
+        public static event System.EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs> FirstChanceException
+        {  
+            [System.Security.SecurityCritical]
+            add  
+            {  
+                AppDomain.CurrentDomain.FirstChanceException += value;  
+            }  
+            [System.Security.SecurityCritical]
+            remove  
+            {  
+                AppDomain.CurrentDomain.FirstChanceException -= value;  
+            }  
+        }  
+
+        public static event System.EventHandler ProcessExit
+        {  
+            [System.Security.SecurityCritical]
+            add  
+            {  
+                AppDomain.CurrentDomain.ProcessExit += value;  
+            }  
+            [System.Security.SecurityCritical]  
+            remove  
+            {  
+                AppDomain.CurrentDomain.ProcessExit -= value;  
+            }  
+        }
+
         #region Switch APIs
         static AppContext()
         {
diff --git a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs
new file mode 100644 (file)
index 0000000..d0bda1c
--- /dev/null
@@ -0,0 +1,39 @@
+// 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.
+/*=============================================================================
+**
+** File: ExceptionNotification.cs
+**
+**
+** Purpose: Contains definitions for supporting Exception Notifications.
+**
+** Created: 10/07/2008
+** 
+** <owner>gkhanna</owner>
+** 
+=============================================================================*/
+#if FEATURE_EXCEPTION_NOTIFICATIONS
+namespace System.Runtime.ExceptionServices {
+    using System;
+    
+    // Definition of the argument-type passed to the FirstChanceException event handler
+    public class FirstChanceExceptionEventArgs : EventArgs
+    {
+        // Constructor
+        public FirstChanceExceptionEventArgs(Exception exception)
+        {
+            m_Exception = exception;
+        }
+
+        // Returns the exception object pertaining to the first chance exception
+        public Exception Exception
+        {
+            get { return m_Exception; }
+        }
+
+        // Represents the FirstChance exception instance
+        private Exception m_Exception;
+    }
+}
+#endif // FEATURE_EXCEPTION_NOTIFICATIONS
\ No newline at end of file