-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to remove exception filters. #1770
Conversation
0e12127
to
d861611
Compare
This test might be useful in this effort: using System;
class P
{
interface Q
{
static int s_counter;
static void Main()
{
try
{
throw new Exception();
}
catch (ArgumentException) when (True())
{
Console.WriteLine("Unreached");
}
catch (Exception) when (Throw())
{
Console.WriteLine("Unreached");
s_counter = -1;
}
catch (Exception) when (False())
{
Console.WriteLine("Unreached");
s_counter = -1;
}
catch (Exception)
{
Console.WriteLine("Works as expected");
s_counter |= 4;
}
if (s_counter == 7)
{
Console.WriteLine("Success");
}
else
{
Console.WriteLine("Fail");
}
}
static bool Throw()
{
s_counter |= 1;
throw new Exception();
}
static bool False()
{
s_counter |= 2;
return false;
}
static bool True()
{
s_counter = -1;
return true;
}
}
} |
protected override void Process () | ||
{ | ||
foreach (var assembly in Context.Annotations.GetAssemblies ()) { | ||
RewriteBodies (assembly.MainModule.Types); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to check if we are linking assembly otherwise do something else (e.g. issue warning).
8463f26
to
2cef215
Compare
I suspect that we'll need to run this code during the inner dev loop with an interpreter for consistency where hooking up linker would be a pain. I'm wondering if we should take this as an opportunity to introduce a new task inside dotnet/runtime instead of injecting this functionality into linker. We have other similar needs for AOT pipeline which could be developed there instead of inside linker. It'd also allow us to run these steps heavily in parallel if we go with SRM instead of Cecil. We would have run all of the following "steps" at the same time inside that task
/cc @lewing |
Its controlled by the --remove-filters command line option. This works by rewriting: catch (Exception ex) when (<cond>) { .. } into: catch (Exception ex) { if (!<cond>) throw ex; .. }
1172bea
to
6c7a3be
Compare
This currently can't handle the case when there are more than 1 filter clause for the same try range. Closing for now in favor of: mono/mono#20796 |
Its controlled by the --remove-filters command line option.
This works by rewriting:
into: