Search Issue Tracker
Fixed
Votes
0
Found in
Issue ID
805846
Regression
No
Wrong exception types don't fall through in generic methods, causing invalid cast exception
Given this code, .NET and IL2CPP output differs:
using System;
using static System.Console;
class Program
{
public delegate void ActionDelegate();
static void CatchException<T>(ActionDelegate action) where T : Exception
{
try
{
action();
}
catch (T e)
{
WriteLine("Caught T: {0}", e.Message);
}
}
static void Main()
{
try
{
CatchException<NullReferenceException>(() => { throw new NotImplementedException(); });
}
catch (Exception e)
{
WriteLine("Caught something. Exception type: {0}", e.GetType());
}
}
}
>csc a.cs /nologo
>a.exe
Caught something. Exception type: System.NotImplementedException
>il2cpp.exe --outputpath=a_il2cpp.exe --cachedirectory="obj_cache" --generatedcppdir="generated_cpp" a.exe && a_il2cpp.exe
.....
Caught something. Exception type: System.InvalidCastException
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Construct matrix block disappears, and other bugs and exceptions related to it show when opening/running project
- New browser tab is not created when trying to open Package Manager hyperlinks by holding the Ctrl key and pressing the left mouse button
- [Mobile] NavigationSubmitEvent is not being triggered when the submit button is pressed on a mobile keyboard
- Materials render incorrect color when using the "require native16bit" pragma directive
- GUIUtility.hotControl controlID value does not change when clicking with the Left Mouse Button
Add comment