using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("CRSilenceAll")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CRSilenceAll")]
[assembly: AssemblyTitle("CRSilenceAll")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[BepInPlugin("local.fix.silence.cr_pce", "CR PCE Silencer", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
private const BindingFlags MethodFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private static readonly HarmonyMethod FinalizerMethod = new HarmonyMethod(typeof(Plugin).GetMethod("Finalizer", BindingFlags.Static | BindingFlags.NonPublic));
private void Start()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Harmony val = new Harmony("local.fix.silence.cr_pce");
int num = 0;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type[] array;
Type[] types;
try
{
array = assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
List<Type> list = new List<Type>();
types = ex.Types;
foreach (Type type in types)
{
if (type != null)
{
list.Add(type);
}
}
array = list.ToArray();
}
catch (Exception ex2)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("skip assembly " + assembly.FullName + ": " + ex2.GetType().Name));
continue;
}
types = array;
foreach (Type type2 in types)
{
if (type2 == null || type2.FullName == null || (!type2.FullName.StartsWith("CR.", StringComparison.Ordinal) && !type2.FullName.StartsWith("PCE.", StringComparison.Ordinal)))
{
continue;
}
MethodInfo[] methods;
try
{
methods = type2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
catch (Exception ex3)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("skip type " + type2.FullName + ": " + ex3.GetType().Name));
continue;
}
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
if (!(methodInfo == null) && !methodInfo.IsAbstract && !methodInfo.IsGenericMethod && !methodInfo.IsGenericMethodDefinition && !methodInfo.ContainsGenericParameters && !typeof(IEnumerator).IsAssignableFrom(methodInfo.ReturnType))
{
try
{
val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, FinalizerMethod, (HarmonyMethod)null);
num++;
}
catch (Exception ex4)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("patch failed: " + type2.FullName + "." + methodInfo.Name + " (" + ex4.GetType().Name + ")"));
}
}
}
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)("finalizers installed: " + num));
}
private static Exception Finalizer(Exception __exception)
{
if (__exception is NullReferenceException)
{
return null;
}
return __exception;
}
}