Skip to content

Update NativeAOT Invoke exception handling #69336

@LakshanF

Description

@LakshanF

Very similar to #67457 but opening a new issue since that one is tracking mono changes. We should throw TargetInvocationException with the inner exception set to OverflowException instead of directly throwing OverflowException

using System;
using System.Reflection;
using System.Linq;

public class Program
{
    static void Main(string[] args)
    {
        ConstructorInfo[] constructors = typeof(object[]).GetTypeInfo().DeclaredConstructors.ToArray();

        try
        {
            constructors[0].Invoke(new object[] { -1 });
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.GetType().FullName);
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions