Skip to content

Commit

Permalink
[mono] Preserve FirstChanceExceptionEventArgs ctor (#68235)
Browse files Browse the repository at this point in the history
The runtime is creating the exception so we need to preserve it.
See dotnet/android#6626

While looking at this I noticed that `FirstChanceExceptionEventArgs` is in ExceptionNotification.cs for some reason, fixed the filename to match the type name.

Use DynamicDependency for preserving `FirstChanceExceptionEventArgs` and `UnhandledExceptionEventArgs`
  • Loading branch information
akoeplinger authored Apr 20, 2022
1 parent 7fd3c92 commit a6202a8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ConstrainedExecution\PrePrepareMethodAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ConstrainedExecution\ReliabilityContractAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ExceptionServices\ExceptionNotification.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ExceptionServices\FirstChanceExceptionEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ExceptionServices\HandleProcessCorruptedStateExceptionsAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\GCSettings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\AllowReversePInvokeCallsAttribute.cs" />
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/AppContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Tracing;
using System.Reflection;
using System.Runtime.ExceptionServices;
Expand Down Expand Up @@ -62,8 +63,10 @@ public static void SetData(string name!!, object? data)
}

#pragma warning disable CS0067 // events raised by the VM
[field: DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors, typeof(UnhandledExceptionEventArgs))]
public static event UnhandledExceptionEventHandler? UnhandledException;

[field: DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors, typeof(FirstChanceExceptionEventArgs))]
public static event EventHandler<FirstChanceExceptionEventArgs>? FirstChanceException;
#pragma warning restore CS0067

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,6 @@
<field name="_value"/>
</type>

<!-- object.c: create_unhandled_exception_eventargs (assert) -->
<type fullname="System.UnhandledExceptionEventArgs">
<method signature="System.Void .ctor(System.Object,System.Boolean)" />
</type>

<!-- class.c: make_generic_param_class -->
<type fullname="System.ValueType" preserve="nothing" />

Expand Down

0 comments on commit a6202a8

Please sign in to comment.