4 Commits
Author SHA1 Message Date
dualfroz 14f32689d4 Replace the Issue3659 IL test with a VBPretty test 2026-09-13 18:32:51 +02:00
upstream 5088708223 Upstream icsharpcode/ILSpy state of the touched files before 39c6f5eada 2026-09-13 18:32:51 +02:00
dualfroz b5ad0ac820 Recognize a VB exception filter's type test
vbc builds an exception filter as a single non-short-circuiting
expression: `isinst`, then the user's `when` conditions, combined with
`and`. DetectCatchWhenConditionBlocks only knew the branch chain csc
emits, so the type test stayed inside the filter and the handler kept the
`object` variable it has in IL:

    catch (object obj) when ((obj is Exception) & (num2 != 0) & (num == 0))
    {
        ProjectData.SetProjectError((Exception)obj);

A catch type has to derive from Exception, so that does not compile.

The conjunction form is matched too now, lifting the test to the catch
type as the block form already does. The other conjuncts stop running for
a non-matching exception once the test moves, so the filter has to be
pure for this to be invisible; PropagateExceptionVariable then drops the
castclass in the handler:

    catch (Exception ex) when ((num2 != 0) & (num == 0))
    {
        ProjectData.SetProjectError(ex);

Closes #3659
2026-09-15 19:16:29 +02:00
upstream aa0b6871d2 Upstream icsharpcode/ILSpy state of the touched files before d5ff770959 2026-09-11 23:55:33 +02:00