Skip to content

Commit d3ae9e1

Browse files
committed
Move trimming suppression
1 parent bfe9c0b commit d3ae9e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/DataProtection/DataProtection/src/XmlEncryption/XmlEncryptionExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.DataProtection.XmlEncryption;
1717
internal static unsafe class XmlEncryptionExtensions
1818
{
1919
// Used for testing edge case assembly loading errors
20-
internal static Func<string, Type?> _getType = name => Type.GetType(name, throwOnError: false);
20+
internal static Func<string, Type?> _getType = GetType;
2121

2222
public static XElement DecryptElement(this XElement element, IActivator activator)
2323
{
@@ -70,7 +70,6 @@ public static XElement DecryptElement(this XElement element, IActivator activato
7070
return doc.Root!;
7171
}
7272

73-
[UnconditionalSuppressMessage("Trimmer", "IL2057", Justification = "Type.GetType result is only useful with types that are referenced by DataProtection assembly.")]
7473
private static IXmlDecryptor CreateDecryptor(IActivator activator, string decryptorTypeName)
7574
{
7675
if (!TryGetDecryptorType(decryptorTypeName, out var type))
@@ -115,6 +114,9 @@ private static bool TryGetDecryptorType(string decryptorTypeName, [NotNullWhen(t
115114
}
116115
}
117116

117+
[UnconditionalSuppressMessage("Trimmer", "IL2057", Justification = "Type.GetType result is only useful with types that are referenced by DataProtection assembly.")]
118+
private static Type? GetType(string typeName) => Type.GetType(typeName, throwOnError: false);
119+
118120
public static XElement? EncryptIfNecessary(this IXmlEncryptor encryptor, XElement element)
119121
{
120122
// If no encryption is necessary, return null.

0 commit comments

Comments
 (0)