Skip to content

Commit

Permalink
Supressed: Incorrect Trim Warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Jul 5, 2022
1 parent 18bd3b9 commit d0e8519
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/Reloaded.Hooks/Tools/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ public static unsafe int GetHookLength(nuint hookAddress, int hookLength, bool i
private static bool TryGetIFuncPtrFromType<
#if NET5_0_OR_GREATER
[DynamicallyAccessedMembers(Trimming.FuncPtrTypes)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072", Justification = "Nested parameterless constructor preserved via nested types.")]
#endif
TType>(out IFuncPtr value)
{
Expand All @@ -391,12 +390,17 @@ public static unsafe int GetHookLength(nuint hookAddress, int hookLength, bool i
{
if (typeof(IFuncPtr).IsAssignableFrom(field.FieldType))
{
value = (IFuncPtr)Activator.CreateInstance(field.FieldType);
value = (IFuncPtr)CreateInstanceSuppressed(field);
return true;
}
}

return false;

#if NET5_0_OR_GREATER
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072", Justification = "Nested parameterless constructor preserved via nested types.")]
#endif
static object CreateInstanceSuppressed(FieldInfo field) => Activator.CreateInstance(field.FieldType);
}

/// <summary>
Expand Down

0 comments on commit d0e8519

Please sign in to comment.