Decompiled source of ShowHiddenCategory v1.0.0

plugins/ShowHiddenCategory/ShowHiddenCategory.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
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=v10.0", FrameworkDisplayName = ".NET 10.0")]
[assembly: AssemblyCompany("NepuShiro")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9923573e70674b8bac4526717c5f3a9b92594753")]
[assembly: AssemblyProduct("ShowHiddenCategory")]
[assembly: AssemblyTitle("ShowHiddenCategory")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/NepuShiro/ShowHiddenCategory")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace ShowHiddenCategory;

[ResonitePlugin("NepuShiro.ShowHiddenCategory", "ShowHiddenCategory", "1.0.0", "NepuShiro", "https://github.com/NepuShiro/ShowHiddenCategory")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
	[HarmonyPatch(typeof(WorkerInitializer), "Initialize", new global::System.Type[]
	{
		typeof(List<global::System.Type>),
		typeof(bool)
	})]
	public static class WorkerInitializerPatch
	{
		[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> instructions;

			public global::System.Collections.Generic.IEnumerable<CodeInstruction> <>3__instructions;

			private bool <patched>5__2;

			private Enumerator<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()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap2 = default(Enumerator<CodeInstruction>);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						List<CodeInstruction> val = Enumerable.ToList<CodeInstruction>(instructions);
						<patched>5__2 = false;
						<>7__wrap2 = val.GetEnumerator();
						<>1__state = -3;
						break;
					}
					case 1:
						<>1__state = -3;
						break;
					}
					if (<>7__wrap2.MoveNext())
					{
						CodeInstruction current = <>7__wrap2.Current;
						if (current.opcode == OpCodes.Ldstr && current.operand is string text && text == "Hidden")
						{
							current.operand = "Some random string nothing is going to use";
							<patched>5__2 = true;
						}
						<>2__current = current;
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>7__wrap2 = default(Enumerator<CodeInstruction>);
					if (!<patched>5__2)
					{
						ManualLogSource log = Log;
						bool flag = default(bool);
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(16, 0, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to patch!");
						}
						log.LogInfo(val2);
					}
					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;
				((global::System.IDisposable)<>7__wrap2/*cast due to .constrained prefix*/).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__.instructions = <>3__instructions;
				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))]
		public static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> val = Enumerable.ToList<CodeInstruction>(instructions);
			bool patched = false;
			Enumerator<CodeInstruction> enumerator = val.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					CodeInstruction current = enumerator.Current;
					if (current.opcode == OpCodes.Ldstr && current.operand is string text && text == "Hidden")
					{
						current.operand = "Some random string nothing is going to use";
						patched = true;
					}
					yield return current;
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			if (!patched)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(16, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to patch!");
				}
				log.LogInfo(val2);
			}
		}
	}

	internal static ManualLogSource Log;

	public override void Load()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		Log = ((BasePlugin)this).Log;
		((BasePlugin)this).HarmonyInstance.PatchAll();
		ManualLogSource log = Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("NepuShiro.ShowHiddenCategory");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
		}
		log.LogInfo(val);
	}

	public override bool Unload()
	{
		((BasePlugin)this).HarmonyInstance.UnpatchSelf();
		return true;
	}
}
public static class PluginMetadata
{
	public const string GUID = "NepuShiro.ShowHiddenCategory";

	public const string NAME = "ShowHiddenCategory";

	public const string VERSION = "1.0.0";

	public const string AUTHORS = "NepuShiro";

	public const string REPOSITORY_URL = "https://github.com/NepuShiro/ShowHiddenCategory";
}