From 2f0ba6d3da5fcd74085437dc66c5a297e4d8f926 Mon Sep 17 00:00:00 2001 From: Mateo Torres Ruiz Date: Thu, 14 Oct 2021 09:16:54 -0700 Subject: [PATCH] Add test --- .../Basic/ExceptionRegions.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/coreclr/tools/ILTrim/ILTrim.Tests.Cases/Basic/ExceptionRegions.cs diff --git a/src/coreclr/tools/ILTrim/ILTrim.Tests.Cases/Basic/ExceptionRegions.cs b/src/coreclr/tools/ILTrim/ILTrim.Tests.Cases/Basic/ExceptionRegions.cs new file mode 100644 index 00000000000..b33be77e558 --- /dev/null +++ b/src/coreclr/tools/ILTrim/ILTrim.Tests.Cases/Basic/ExceptionRegions.cs @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Basic +{ + [Kept] + public class ExceptionRegions + { + [Kept] + static void Main() + { + try + { + A(); + } + catch (CustomException ce) + { + Console.WriteLine(ce.Message); + try + { + B(); + } + catch (Exception e) when (e.InnerException != null) + { + Console.WriteLine(e.Message); + } + } + finally + { + C(); + } + } + + [Kept] + static void A() { } + + [Kept] + static void B() { } + + [Kept] + static void C() { } + } + + [Kept] + [KeptBaseType(typeof(Exception))] + class CustomException : Exception + { + } +}