Browse Source

Do not virtualize compiler-generated stuff

pull/94/head
Meivyn 1 year ago
parent
commit
8c45728c11
No known key found for this signature in database GPG Key ID: 8BDD3E48158B2F71
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      IPA.Injector/Virtualizer.cs

+ 12
- 1
IPA.Injector/Virtualizer.cs View File

@ -3,6 +3,7 @@ using Mono.Cecil.Rocks;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace IPA.Injector
@ -69,11 +70,20 @@ namespace IPA.Injector
}
}
private TypeReference compilerGeneratedAttributeRef;
private TypeReference inModreqRef;
// private TypeReference outModreqRef;
private bool IsCompilerGenerated(Mono.Cecil.ICustomAttributeProvider customAttributeProvider)
{
compilerGeneratedAttributeRef ??= module.ImportReference(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute));
return customAttributeProvider.CustomAttributes.Any(ca => ca.AttributeType.FullName == compilerGeneratedAttributeRef.FullName);
}
private void VirtualizeType(TypeDefinition type)
{
if (IsCompilerGenerated(type)) return;
if(type.IsSealed)
{
// Unseal
@ -108,7 +118,8 @@ namespace IPA.Injector
&& !method.IsConstructor
&& !method.IsSpecialName
&& !method.IsGenericInstance
&& !method.HasOverrides)
&& !method.HasOverrides
&& !IsCompilerGenerated(method))
{
if (!method.IsStatic)
{


Loading…
Cancel
Save