From 27b9dd6bf92ddab04763ebaec931f83dad62cfa1 Mon Sep 17 00:00:00 2001 From: Vitek Karas <10670590+vitek-karas@users.noreply.github.com> Date: Mon, 13 Jun 2022 14:19:48 -0700 Subject: Mark all type forwarders used during string->Type resolution (#2836) Previously we only marked the type forwarder for the outer-most type (if any), but the same problem can happen with type names in generic arguments. If they are forwarder we need to mark those type forwarders as well. This change records all type resolutions during the string->Type resolution and then makes sure that all type forwarders used get marked. Renamed a method on HandleCallAction to make it more descriptive of what it actually does. Also unifies all string->Type resolution into the ReflectionMarker. Enabled test which has been already added for the bug and added another variation (CreateInstance). Improved ResultsChecker to include assembly names in validation messages. --- test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'test/Mono.Linker.Tests.Cases/DataFlow') diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs b/test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs index 18c77aa81..2e071edd7 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs @@ -139,7 +139,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow RequirePublicMethods (Type.GetType ("Mono.Linker.Tests.Cases.DataFlow.ComplexTypeHandling+ArrayTypeGetTypeElement[]")); } - // Nothing should be marked as CreateInstance doesn't work on arrays + // Technically there's no reason to mark this type since it's only used as an array element type and CreateInstance + // doesn't work on arrays, but the currently implementation will preserve it anyway due to how it processes + // string -> Type resolution. This will only impact code which would have failed at runtime, so very unlikely to + // actually occur in real apps (and even if it does happen, it just increases size, doesn't break behavior). + [Kept] class ArrayCreateInstanceByNameElement { public ArrayCreateInstanceByNameElement () -- cgit v1.2.3