using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using FrooxEngine;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("eia485")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+5cd2ea75ebacbb6b76faadcedb4ca99bbbc1e7c2")]
[assembly: AssemblyProduct("AcceptEquivalentDelegates")]
[assembly: AssemblyTitle("AcceptEquivalentDelegates")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EIA485/NeosAcceptEquivalentDelegates")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace AcceptEquivalentDelegates;
[ResonitePlugin("net.eia485.AcceptEquivalentDelegates", "AcceptEquivalentDelegates", "1.0.1", "eia485", "https://github.com/EIA485/NeosAcceptEquivalentDelegates")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AcceptEquivalentDelegates : BasePlugin
{
[HarmonyPatch(typeof(DelegateEditor), "TryReceive")]
private class AcceptEquivalentDelegates_Patch
{
[CompilerGenerated]
private sealed class <Transpiler>d__0 : global::System.Collections.Generic.IEnumerable<CodeInstruction>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<CodeInstruction>, global::System.Collections.IEnumerator, global::System.IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private global::System.Collections.Generic.IEnumerable<CodeInstruction> codes;
public global::System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;
private bool <find>5__2;
private global::System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap2;
CodeInstruction global::System.Collections.Generic.IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object global::System.Collections.IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void global::System.IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>7__wrap2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<find>5__2 = true;
<>7__wrap2 = codes.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
break;
case 2:
<>1__state = -3;
break;
}
if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext())
{
CodeInstruction current = <>7__wrap2.Current;
if (<find>5__2)
{
object operand = current.operand;
object obj = ((operand is MethodInfo) ? operand : null);
if (((obj != null) ? ((MemberInfo)obj).Name : null) == "TrySet")
{
<find>5__2 = false;
<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AcceptEquivalentDelegates), "MyTrySet", (global::System.Type[])null, (global::System.Type[])null));
<>1__state = 1;
return true;
}
}
<>2__current = current;
<>1__state = 2;
return true;
}
<>m__Finally1();
<>7__wrap2 = null;
if (<find>5__2)
{
log.LogError((object)"TryReceive Transpiler Failed to find target il");
}
return false;
}
catch
{
//try-fault
((global::System.IDisposable)this).Dispose();
throw;
}
}
bool global::System.Collections.IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>7__wrap2 != null)
{
((global::System.IDisposable)<>7__wrap2).Dispose();
}
}
[DebuggerHidden]
void global::System.Collections.IEnumerator.Reset()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
[DebuggerHidden]
global::System.Collections.Generic.IEnumerator<CodeInstruction> global::System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.codes = <>3__codes;
return <Transpiler>d__;
}
[DebuggerHidden]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
private static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__0(-2)
{
<>3__codes = codes
};
}
}
private static ManualLogSource log;
public override void Load()
{
((BasePlugin)this).HarmonyInstance.PatchAll();
log = ((BasePlugin)this).Log;
}
private static bool MyTrySet(ISyncDelegate instance, global::System.Delegate target)
{
try
{
return instance.TrySet(target.Method.CreateDelegate(FirstGeneric(((object)instance).GetType()), target.Target));
}
catch
{
return false;
}
}
private static global::System.Type FirstGeneric(global::System.Type last)
{
global::System.Type[] genericArguments = last.GetGenericArguments();
if (genericArguments != null && genericArguments.Length != 0)
{
global::System.Type[] array = genericArguments;
foreach (global::System.Type type in array)
{
if (typeof(global::System.Delegate).IsAssignableFrom(type))
{
return type;
}
}
}
global::System.Type baseType = last.BaseType;
if (baseType != (global::System.Type)null)
{
return FirstGeneric(baseType);
}
return null;
}
}
public static class PluginMetadata
{
public const string GUID = "net.eia485.AcceptEquivalentDelegates";
public const string NAME = "AcceptEquivalentDelegates";
public const string VERSION = "1.0.1";
public const string AUTHORS = "eia485";
public const string REPOSITORY_URL = "https://github.com/EIA485/NeosAcceptEquivalentDelegates";
}