Skip to content

Commit d0e8519

Browse files
committed
Supressed: Incorrect Trim Warning
1 parent 18bd3b9 commit d0e8519

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

source/Reloaded.Hooks/Tools/Utilities.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ public static int GetNumberofParametersWithoutFloats<
373373
private static bool TryGetIFuncPtrFromType<
374374
#if NET5_0_OR_GREATER
375375
[DynamicallyAccessedMembers(Trimming.FuncPtrTypes)]
376-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072", Justification = "Nested parameterless constructor preserved via nested types.")]
377376
#endif
378377
TType>(out IFuncPtr value)
379378
{
@@ -391,12 +390,17 @@ private static bool TryGetIFuncPtrFromType<
391390
{
392391
if (typeof(IFuncPtr).IsAssignableFrom(field.FieldType))
393392
{
394-
value = (IFuncPtr)Activator.CreateInstance(field.FieldType);
393+
value = (IFuncPtr)CreateInstanceSuppressed(field);
395394
return true;
396395
}
397396
}
398397

399398
return false;
399+
400+
#if NET5_0_OR_GREATER
401+
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072", Justification = "Nested parameterless constructor preserved via nested types.")]
402+
#endif
403+
static object CreateInstanceSuppressed(FieldInfo field) => Activator.CreateInstance(field.FieldType);
400404
}
401405

402406
/// <summary>

0 commit comments

Comments
 (0)