From 801a243ef1015b1a1aca2843b34b6dace06399eb Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Tue, 7 Oct 2025 17:13:11 -0700 Subject: [PATCH 1/6] Allow ExternalTypeMap to have duplicates entries with identical mapping but different trimTarget --- .../InteropServices/TypeMapLazyDictionary.cs | 20 ++++++++++++++++++- .../tests/TrimmingTests/TypeMap.cs | 18 ++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs index a1fc75f100bdba..cea05b275e31a9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs @@ -265,6 +265,20 @@ private unsafe struct TypeNameUtf8 { public required void* Utf8TypeName { get; init; } public required int Utf8TypeNameLen { get; init; } + + public bool Equals(TypeNameUtf8 other) + { + if (Utf8TypeNameLen != other.Utf8TypeNameLen) + return false; + byte* thisChars = (byte*)Utf8TypeName; + byte* otherChars = (byte*)Utf8TypeName; + for (int i = 0; i < Utf8TypeNameLen; i++) + { + if (thisChars[i] != otherChars[i]) + return false; + } + return true; + } } [RequiresUnreferencedCode("Lazy TypeMap isn't supported for Trimmer scenarios")] @@ -282,6 +296,8 @@ public DelayedType(TypeNameUtf8 typeNameUtf8, RuntimeAssembly fallbackAssembly) _type = null; } + public TypeNameUtf8 TypeName => _typeNameUtf8; + public unsafe Type GetOrLoadType() { if (_type is null) @@ -328,7 +344,9 @@ protected override bool TryGetOrLoadType(string key, [NotNullWhen(true)] out Typ public void Add(string key, TypeNameUtf8 targetType, RuntimeAssembly fallbackAssembly) { int hash = ComputeHashCode(key); - if (_lazyData.ContainsKey(hash)) + // Allow duplicates that have the same string -> mapping. They may have different trimTargets. + // Warn if the mapping conflicts with an existing mapping. + if (_lazyData.TryGetValue(hash, out DelayedType? existing) && existing.TypeName.Equals(targetType)) { ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(key); } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs index 5dcf5e35009ecd..ae631021aaffed 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs @@ -8,6 +8,8 @@ [assembly: TypeMap("TrimTargetIsTarget", typeof(TargetAndTrimTarget), typeof(TargetAndTrimTarget))] [assembly: TypeMap("TrimTargetIsUnrelated", typeof(TargetType), typeof(TrimTarget))] +[assembly: TypeMap("DuplicateMappingWithDifferentTrimTargets", typeof(TargetType2), typeof(TrimTarget2))] +[assembly: TypeMap("DuplicateMappingWithDifferentTrimTargets", typeof(TargetType2), typeof(TrimTarget3))] [assembly: TypeMap("TrimTargetIsUnreferenced", typeof(UnreferencedTargetType), typeof(UnreferencedTrimTarget))] [assembly: TypeMapAssociation(typeof(SourceClass), typeof(ProxyType))] @@ -34,7 +36,7 @@ IReadOnlyDictionary usedTypeMap = TypeMapping.GetOrCreateExternalTypeMapping(); -if (!usedTypeMap.TryGetValue("TrimTargetIsTarget", out Type targetAndTrimTargetType)) +if (!usedTypeMap.TryGetValue("TrimTargetIsTarget", out Type? targetAndTrimTargetType)) { Console.WriteLine("TrimTargetIsTarget not found in used type map."); return 1; @@ -46,12 +48,13 @@ return 2; } -if (!usedTypeMap.TryGetValue("TrimTargetIsUnrelated", out Type targetType)) +if (!usedTypeMap.TryGetValue("TrimTargetIsUnrelated", out Type? targetType)) { Console.WriteLine("TrimTargetIsUnrelated not found in used type map."); return 3; } + if (targetType != GetTypeWithoutTrimAnalysis(nameof(TargetType))) { Console.WriteLine("TrimTargetIsUnrelated type does not match expected type."); @@ -71,7 +74,7 @@ } IReadOnlyDictionary usedProxyTypeMap = TypeMapping.GetOrCreateProxyTypeMapping(); -if (!usedProxyTypeMap.TryGetValue(typeof(SourceClass), out Type proxyType)) +if (!usedProxyTypeMap.TryGetValue(typeof(SourceClass), out Type? proxyType)) { Console.WriteLine("SourceClass not found in used proxy type map."); return 7; @@ -95,6 +98,12 @@ return 10; } +if (!usedTypeMap.TryGetValue("DuplicateMappingWithDifferentTrimTargets", out Type? duplicatedTarget)) +{ + Console.WriteLine("Could not find duplicated target type"); + return 11; +} + return 100; [MethodImpl(MethodImplOptions.NoInlining)] @@ -106,7 +115,10 @@ static Type GetTypeWithoutTrimAnalysis(string typeName) class UsedTypeMap; class TargetAndTrimTarget; class TargetType; +class TargetType1; class TrimTarget; +class TrimTarget1; +class TrimTarget2; class UnreferencedTargetType; class UnreferencedTrimTarget; class SourceClass; From 1f3366c6dbc835d512944c88341eb84a275fc222 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Tue, 7 Oct 2025 17:17:04 -0700 Subject: [PATCH 2/6] Update src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs index cea05b275e31a9..02e583cc7f73b8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs @@ -271,7 +271,7 @@ public bool Equals(TypeNameUtf8 other) if (Utf8TypeNameLen != other.Utf8TypeNameLen) return false; byte* thisChars = (byte*)Utf8TypeName; - byte* otherChars = (byte*)Utf8TypeName; + byte* otherChars = (byte*)other.Utf8TypeName; for (int i = 0; i < Utf8TypeNameLen; i++) { if (thisChars[i] != otherChars[i]) From 81b70a5cef66753d066e11620a7138aab0487840 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:05:59 -0700 Subject: [PATCH 3/6] PR Feedback: - Use Span for UTF8 string comparison - Negate name check for duplicate check - Add branch to avoid re-adding for duplicate entries --- .../InteropServices/TypeMapLazyDictionary.cs | 19 ++++++++----------- .../tests/TrimmingTests/TypeMap.cs | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs index cea05b275e31a9..86e0fc0803336b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs @@ -270,14 +270,9 @@ public bool Equals(TypeNameUtf8 other) { if (Utf8TypeNameLen != other.Utf8TypeNameLen) return false; - byte* thisChars = (byte*)Utf8TypeName; - byte* otherChars = (byte*)Utf8TypeName; - for (int i = 0; i < Utf8TypeNameLen; i++) - { - if (thisChars[i] != otherChars[i]) - return false; - } - return true; + ReadOnlySpan thisSpan = new ReadOnlySpan(Utf8TypeName, Utf8TypeNameLen); + ReadOnlySpan otherSpan = new ReadOnlySpan(other.Utf8TypeName, other.Utf8TypeNameLen); + return thisSpan.SequenceEqual(otherSpan); } } @@ -346,12 +341,14 @@ public void Add(string key, TypeNameUtf8 targetType, RuntimeAssembly fallbackAss int hash = ComputeHashCode(key); // Allow duplicates that have the same string -> mapping. They may have different trimTargets. // Warn if the mapping conflicts with an existing mapping. - if (_lazyData.TryGetValue(hash, out DelayedType? existing) && existing.TypeName.Equals(targetType)) + if (!_lazyData.TryGetValue(hash, out DelayedType? existing)) + { + _lazyData.Add(hash, new DelayedType(targetType, fallbackAssembly)); + } + else if (!existing.TypeName.Equals(targetType)) { ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(key); } - - _lazyData.Add(hash, new DelayedType(targetType, fallbackAssembly)); } } diff --git a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs index ae631021aaffed..28084eb1c3e672 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs @@ -115,10 +115,10 @@ static Type GetTypeWithoutTrimAnalysis(string typeName) class UsedTypeMap; class TargetAndTrimTarget; class TargetType; -class TargetType1; +class TargetType2; class TrimTarget; -class TrimTarget1; class TrimTarget2; +class TrimTarget3; class UnreferencedTargetType; class UnreferencedTrimTarget; class SourceClass; From d4d8258b7908bb1480690db818827b52914af596 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Thu, 9 Oct 2025 11:40:04 -0700 Subject: [PATCH 4/6] PR Feedback, fix/add test for duplicate entries --- .../InteropServices/TypeMapLazyDictionary.cs | 2 -- .../tests/TrimmingTests/TypeMap.cs | 1 - src/tests/Interop/TypeMap/GroupTypes.cs | 4 ++- src/tests/Interop/TypeMap/TypeMapApp.cs | 29 ++++++++++++++----- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs index 86e0fc0803336b..557d7328b386b0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs @@ -268,8 +268,6 @@ private unsafe struct TypeNameUtf8 public bool Equals(TypeNameUtf8 other) { - if (Utf8TypeNameLen != other.Utf8TypeNameLen) - return false; ReadOnlySpan thisSpan = new ReadOnlySpan(Utf8TypeName, Utf8TypeNameLen); ReadOnlySpan otherSpan = new ReadOnlySpan(other.Utf8TypeName, other.Utf8TypeNameLen); return thisSpan.SequenceEqual(otherSpan); diff --git a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs index 28084eb1c3e672..ddf4266a39a160 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs @@ -54,7 +54,6 @@ return 3; } - if (targetType != GetTypeWithoutTrimAnalysis(nameof(TargetType))) { Console.WriteLine("TrimTargetIsUnrelated type does not match expected type."); diff --git a/src/tests/Interop/TypeMap/GroupTypes.cs b/src/tests/Interop/TypeMap/GroupTypes.cs index 67fa870a233120..e5c0dcf359e090 100644 --- a/src/tests/Interop/TypeMap/GroupTypes.cs +++ b/src/tests/Interop/TypeMap/GroupTypes.cs @@ -17,7 +17,9 @@ public class I2 {} public class TypicalUseCase { } -public class DuplicateTypeNameKey { } +public class ValidDuplicateTypeNameKey { } + +public class InvalidDuplicateTypeNameKey { } public class InvalidTypeNameKey { } diff --git a/src/tests/Interop/TypeMap/TypeMapApp.cs b/src/tests/Interop/TypeMap/TypeMapApp.cs index 5a355855d89df5..99f6a57ef0cd12 100644 --- a/src/tests/Interop/TypeMap/TypeMapApp.cs +++ b/src/tests/Interop/TypeMap/TypeMapApp.cs @@ -61,11 +61,15 @@ [assembly: TypeMap(null!, typeof(object))] [assembly: TypeMapAssociation(null!, typeof(object))] -[assembly: TypeMap("1", typeof(object))] -[assembly: TypeMap("1", typeof(object))] +[assembly: TypeMap("1", typeof(object))] +[assembly: TypeMap("1", typeof(object), typeof(object))] +[assembly: TypeMap("1", typeof(object), typeof(string))] -[assembly: TypeMapAssociation(typeof(DupType_MapObject), typeof(object))] -[assembly: TypeMapAssociation(typeof(DupType_MapString), typeof(string))] +[assembly: TypeMap("1", typeof(object))] +[assembly: TypeMap("1", typeof(string))] + +[assembly: TypeMapAssociation(typeof(DupType_MapObject), typeof(object))] +[assembly: TypeMapAssociation(typeof(DupType_MapString), typeof(string))] // Redefine the same type as in the TypeMapLib2 assembly // This is testing the duplicate type name key for the @@ -178,19 +182,28 @@ public static void Validate_ProxyTypeMapping() } [Fact] - public static void Validate_ExternalTypeMapping_DuplicateTypeKey() + public static void Validate_ExternalTypeMapping_InvalidDuplicateTypeKey() { - Console.WriteLine(nameof(Validate_ExternalTypeMapping_DuplicateTypeKey)); + Console.WriteLine(nameof(Validate_ExternalTypeMapping_InvalidDuplicateTypeKey)); - AssertExtensions.ThrowsAny(() => TypeMapping.GetOrCreateExternalTypeMapping()); + AssertExtensions.ThrowsAny(() => TypeMapping.GetOrCreateExternalTypeMapping()); } + [Fact] + public static void Validate_ExternalTypeMapping_ValidDuplicateTypeKey() + { + Console.WriteLine(nameof(Validate_ExternalTypeMapping_ValidDuplicateTypeKey)); + + var mapping = TypeMapping.GetOrCreateExternalTypeMapping(); + Assert.Equal(typeof(object), mapping["1"]); + } [Fact] public static void Validate_ProxyTypeMapping_DuplicateTypeKey() { Console.WriteLine(nameof(Validate_ProxyTypeMapping_DuplicateTypeKey)); - IReadOnlyDictionary map = TypeMapping.GetOrCreateProxyTypeMapping(); + // Invalid external mapping shouldn't impact proxy mapping + IReadOnlyDictionary map = TypeMapping.GetOrCreateProxyTypeMapping(); Assert.Equal(typeof(object), map[typeof(DupType_MapObject)]); Assert.Equal(typeof(string), map[typeof(DupType_MapString)]); From 82cdfa12d6c080af642b24367f37cfe76d1e8fcd Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Thu, 9 Oct 2025 11:40:04 -0700 Subject: [PATCH 5/6] PR Feedback, fix/add test for duplicate entries --- .../InteropServices/TypeMapLazyDictionary.cs | 2 -- .../tests/TrimmingTests/TypeMap.cs | 1 - src/tests/Interop/TypeMap/GroupTypes.cs | 4 ++- src/tests/Interop/TypeMap/TypeMapApp.cs | 29 ++++++++++++++----- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs index 86e0fc0803336b..557d7328b386b0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs @@ -268,8 +268,6 @@ private unsafe struct TypeNameUtf8 public bool Equals(TypeNameUtf8 other) { - if (Utf8TypeNameLen != other.Utf8TypeNameLen) - return false; ReadOnlySpan thisSpan = new ReadOnlySpan(Utf8TypeName, Utf8TypeNameLen); ReadOnlySpan otherSpan = new ReadOnlySpan(other.Utf8TypeName, other.Utf8TypeNameLen); return thisSpan.SequenceEqual(otherSpan); diff --git a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs index 28084eb1c3e672..ddf4266a39a160 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs @@ -54,7 +54,6 @@ return 3; } - if (targetType != GetTypeWithoutTrimAnalysis(nameof(TargetType))) { Console.WriteLine("TrimTargetIsUnrelated type does not match expected type."); diff --git a/src/tests/Interop/TypeMap/GroupTypes.cs b/src/tests/Interop/TypeMap/GroupTypes.cs index 67fa870a233120..e5c0dcf359e090 100644 --- a/src/tests/Interop/TypeMap/GroupTypes.cs +++ b/src/tests/Interop/TypeMap/GroupTypes.cs @@ -17,7 +17,9 @@ public class I2 {} public class TypicalUseCase { } -public class DuplicateTypeNameKey { } +public class ValidDuplicateTypeNameKey { } + +public class InvalidDuplicateTypeNameKey { } public class InvalidTypeNameKey { } diff --git a/src/tests/Interop/TypeMap/TypeMapApp.cs b/src/tests/Interop/TypeMap/TypeMapApp.cs index 5a355855d89df5..99f6a57ef0cd12 100644 --- a/src/tests/Interop/TypeMap/TypeMapApp.cs +++ b/src/tests/Interop/TypeMap/TypeMapApp.cs @@ -61,11 +61,15 @@ [assembly: TypeMap(null!, typeof(object))] [assembly: TypeMapAssociation(null!, typeof(object))] -[assembly: TypeMap("1", typeof(object))] -[assembly: TypeMap("1", typeof(object))] +[assembly: TypeMap("1", typeof(object))] +[assembly: TypeMap("1", typeof(object), typeof(object))] +[assembly: TypeMap("1", typeof(object), typeof(string))] -[assembly: TypeMapAssociation(typeof(DupType_MapObject), typeof(object))] -[assembly: TypeMapAssociation(typeof(DupType_MapString), typeof(string))] +[assembly: TypeMap("1", typeof(object))] +[assembly: TypeMap("1", typeof(string))] + +[assembly: TypeMapAssociation(typeof(DupType_MapObject), typeof(object))] +[assembly: TypeMapAssociation(typeof(DupType_MapString), typeof(string))] // Redefine the same type as in the TypeMapLib2 assembly // This is testing the duplicate type name key for the @@ -178,19 +182,28 @@ public static void Validate_ProxyTypeMapping() } [Fact] - public static void Validate_ExternalTypeMapping_DuplicateTypeKey() + public static void Validate_ExternalTypeMapping_InvalidDuplicateTypeKey() { - Console.WriteLine(nameof(Validate_ExternalTypeMapping_DuplicateTypeKey)); + Console.WriteLine(nameof(Validate_ExternalTypeMapping_InvalidDuplicateTypeKey)); - AssertExtensions.ThrowsAny(() => TypeMapping.GetOrCreateExternalTypeMapping()); + AssertExtensions.ThrowsAny(() => TypeMapping.GetOrCreateExternalTypeMapping()); } + [Fact] + public static void Validate_ExternalTypeMapping_ValidDuplicateTypeKey() + { + Console.WriteLine(nameof(Validate_ExternalTypeMapping_ValidDuplicateTypeKey)); + + var mapping = TypeMapping.GetOrCreateExternalTypeMapping(); + Assert.Equal(typeof(object), mapping["1"]); + } [Fact] public static void Validate_ProxyTypeMapping_DuplicateTypeKey() { Console.WriteLine(nameof(Validate_ProxyTypeMapping_DuplicateTypeKey)); - IReadOnlyDictionary map = TypeMapping.GetOrCreateProxyTypeMapping(); + // Invalid external mapping shouldn't impact proxy mapping + IReadOnlyDictionary map = TypeMapping.GetOrCreateProxyTypeMapping(); Assert.Equal(typeof(object), map[typeof(DupType_MapObject)]); Assert.Equal(typeof(string), map[typeof(DupType_MapString)]); From ed32787a3ed94f99d81b32dd3052f608604708ba Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Mon, 13 Oct 2025 11:36:20 -0700 Subject: [PATCH 6/6] Remove nullable annotations --- .../tests/TrimmingTests/TypeMap.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs index ddf4266a39a160..5ed92108fdd827 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs @@ -36,7 +36,7 @@ IReadOnlyDictionary usedTypeMap = TypeMapping.GetOrCreateExternalTypeMapping(); -if (!usedTypeMap.TryGetValue("TrimTargetIsTarget", out Type? targetAndTrimTargetType)) +if (!usedTypeMap.TryGetValue("TrimTargetIsTarget", out Type targetAndTrimTargetType)) { Console.WriteLine("TrimTargetIsTarget not found in used type map."); return 1; @@ -48,7 +48,7 @@ return 2; } -if (!usedTypeMap.TryGetValue("TrimTargetIsUnrelated", out Type? targetType)) +if (!usedTypeMap.TryGetValue("TrimTargetIsUnrelated", out Type targetType)) { Console.WriteLine("TrimTargetIsUnrelated not found in used type map."); return 3; @@ -73,7 +73,7 @@ } IReadOnlyDictionary usedProxyTypeMap = TypeMapping.GetOrCreateProxyTypeMapping(); -if (!usedProxyTypeMap.TryGetValue(typeof(SourceClass), out Type? proxyType)) +if (!usedProxyTypeMap.TryGetValue(typeof(SourceClass), out Type proxyType)) { Console.WriteLine("SourceClass not found in used proxy type map."); return 7; @@ -97,7 +97,7 @@ return 10; } -if (!usedTypeMap.TryGetValue("DuplicateMappingWithDifferentTrimTargets", out Type? duplicatedTarget)) +if (!usedTypeMap.TryGetValue("DuplicateMappingWithDifferentTrimTargets", out Type duplicatedTarget)) { Console.WriteLine("Could not find duplicated target type"); return 11;