From 38adebccc7de7a2c4b7f78893544802c1c48ff29 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Tue, 27 Sep 2016 17:55:09 -0700 Subject: [PATCH] Expose AppDomain apis --- clr.coreclr.props | 1 + clrdefinitions.cmake | 1 + src/mscorlib/model.xml | 23 ++++++++++--- src/mscorlib/mscorlib.shared.sources.props | 1 + src/mscorlib/ref/mscorlib.cs | 9 +++++ src/mscorlib/src/System/AppContext/AppContext.cs | 34 +++++++++++++++++++ .../ExceptionServices/ExceptionNotification.cs | 39 ++++++++++++++++++++++ 7 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs diff --git a/clr.coreclr.props b/clr.coreclr.props index 50b3b4f..c136fa5 100644 --- a/clr.coreclr.props +++ b/clr.coreclr.props @@ -21,6 +21,7 @@ true true true + true true true true diff --git a/clrdefinitions.cmake b/clrdefinitions.cmake index b61ab8f..e088f12 100644 --- a/clrdefinitions.cmake +++ b/clrdefinitions.cmake @@ -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) diff --git a/src/mscorlib/model.xml b/src/mscorlib/model.xml index 53f531a..6adb356 100644 --- a/src/mscorlib/model.xml +++ b/src/mscorlib/model.xml @@ -143,15 +143,23 @@ + + + + + + - - - + + + + + - - + + @@ -6429,6 +6437,11 @@ + + + + + diff --git a/src/mscorlib/mscorlib.shared.sources.props b/src/mscorlib/mscorlib.shared.sources.props index 025c93e..d9b5ca8 100644 --- a/src/mscorlib/mscorlib.shared.sources.props +++ b/src/mscorlib/mscorlib.shared.sources.props @@ -935,6 +935,7 @@ + diff --git a/src/mscorlib/ref/mscorlib.cs b/src/mscorlib/ref/mscorlib.cs index 01ab7eb..b51baab 100644 --- a/src/mscorlib/ref/mscorlib.cs +++ b/src/mscorlib/ref/mscorlib.cs @@ -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 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 { diff --git a/src/mscorlib/src/System/AppContext/AppContext.cs b/src/mscorlib/src/System/AppContext/AppContext.cs index b318c34..5e78f8d 100644 --- a/src/mscorlib/src/System/AppContext/AppContext.cs +++ b/src/mscorlib/src/System/AppContext/AppContext.cs @@ -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 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 index 0000000..d0bda1c --- /dev/null +++ b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs @@ -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 +** +** gkhanna +** +=============================================================================*/ +#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 -- 2.7.4