Decompiled source of Sideloader v0.9.7404

LBoL-Entity-Sideloader.dll

Decompiled 2 days ago
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.CompilerServices;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using Extensions.Unity.ImageLoader;
using HarmonyLib;
using LBoL.Base;
using LBoL.Base.Extensions;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Adventures;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Cards;
using LBoL.Core.GapOptions;
using LBoL.Core.SaveData;
using LBoL.Core.Stations;
using LBoL.Core.StatusEffects;
using LBoL.Core.Units;
using LBoL.EntityLib.Adventures;
using LBoL.EntityLib.Cards.Character.Reimu;
using LBoL.EntityLib.EnemyUnits.Character;
using LBoL.Presentation;
using LBoL.Presentation.Effect;
using LBoL.Presentation.I10N;
using LBoL.Presentation.UI;
using LBoL.Presentation.UI.ExtraWidgets;
using LBoL.Presentation.UI.Panels;
using LBoL.Presentation.UI.Widgets;
using LBoL.Presentation.Units;
using LBoLEntitySideloader;
using LBoLEntitySideloader.Attributes;
using LBoLEntitySideloader.BattleModifiers.Actions;
using LBoLEntitySideloader.BattleModifiers.Args;
using LBoLEntitySideloader.CustomHandlers;
using LBoLEntitySideloader.Entities;
using LBoLEntitySideloader.Entities.DynamicTemplates;
using LBoLEntitySideloader.Entities.MockConfigs;
using LBoLEntitySideloader.Entities.Patches;
using LBoLEntitySideloader.PersistentValues;
using LBoLEntitySideloader.ReflectionHelpers;
using LBoLEntitySideloader.Resource;
using LBoLEntitySideloader.TemplateGen;
using LBoLEntitySideloader.UIhelpers;
using LBoLEntitySideloader.Utils;
using LBoLEntitySideloader.Utils.ArrayExtensions;
using Mono.CSharp;
using MonoMod.Utils;
using ScriptEngine;
using Spine.Unity;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Networking;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Helpers;
using YamlDotNet.RepresentationModel;
using YamlDotNet.Serialization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("LBoL-Entity-Sideloader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LBoL-Entity-Sideloader")]
[assembly: AssemblyTitle("LBoL-Entity-Sideloader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Extensions.Unity.ImageLoader
{
	public static class ImageLoader
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass10_0
		{
			public string url;

			public UnityWebRequest request;

			public bool ignoreImageNotFoundError;

			public bool finished;

			internal bool <LoadSprite>b__0()
			{
				return IsLoading(url);
			}

			internal async void <LoadSprite>b__1()
			{
				try
				{
					request = UnityWebRequestTexture.GetTexture(url);
					UnityWebRequestAsyncOperationAwaiter val = UnityAsyncExtensions.GetAwaiter(request.SendWebRequest());
					if (!((UnityWebRequestAsyncOperationAwaiter)(ref val)).IsCompleted)
					{
						await val;
						UnityWebRequestAsyncOperationAwaiter val2 = default(UnityWebRequestAsyncOperationAwaiter);
						val = val2;
					}
					((UnityWebRequestAsyncOperationAwaiter)(ref val)).GetResult();
				}
				catch (Exception ex)
				{
					Exception e = ex;
					if (!ignoreImageNotFoundError && settings.debugLevel <= DebugLevel.Exception)
					{
						Debug.LogException(e);
					}
				}
				finally
				{
					finished = true;
				}
			}

			internal bool <LoadSprite>b__2()
			{
				return finished;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass11_0
		{
			public string url;

			public Rect? rect;

			public Vector2? pivot;

			public int ppu;

			public SpriteMeshType spriteMeshType;

			public UnityWebRequest request;

			public bool ignoreImageNotFoundError;

			public bool finished;

			internal bool <LoadSpriteMemoryOptimized>b__0()
			{
				return IsLoading(url);
			}

			internal Sprite <LoadSpriteMemoryOptimized>b__1(Texture2D texture)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				if (!rect.HasValue)
				{
					rect = new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height);
				}
				if (!pivot.HasValue)
				{
					pivot = new Vector2(0.5f, 0.5f);
				}
				return Sprite.Create(texture, rect.Value, pivot.Value, (float)ppu, 0u, spriteMeshType);
			}

			internal async void <LoadSpriteMemoryOptimized>b__2()
			{
				try
				{
					request = new UnityWebRequest(url);
					request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
					UnityWebRequestAsyncOperationAwaiter val = UnityAsyncExtensions.GetAwaiter(request.SendWebRequest());
					if (!((UnityWebRequestAsyncOperationAwaiter)(ref val)).IsCompleted)
					{
						await val;
						UnityWebRequestAsyncOperationAwaiter val2 = default(UnityWebRequestAsyncOperationAwaiter);
						val = val2;
					}
					((UnityWebRequestAsyncOperationAwaiter)(ref val)).GetResult();
				}
				catch (Exception ex)
				{
					Exception e = ex;
					if (!ignoreImageNotFoundError && settings.debugLevel <= DebugLevel.Exception)
					{
						Debug.LogException(e);
					}
				}
				finally
				{
					finished = true;
				}
			}

			internal bool <LoadSpriteMemoryOptimized>b__3()
			{
				return finished;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass30_0
		{
			public Image image;
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass30_1
		{
			public Sprite sprite;

			public <>c__DisplayClass30_0 CS$<>8__locals1;

			internal void <SetSprite>b__0()
			{
				if ((Object)(object)CS$<>8__locals1.image == (Object)null || ((UIBehaviour)CS$<>8__locals1.image).IsDestroyed() || object.Equals(((Component)CS$<>8__locals1.image).gameObject, null))
				{
					return;
				}
				try
				{
					CS$<>8__locals1.image.sprite = sprite;
				}
				catch (Exception ex)
				{
					if (settings.debugLevel <= DebugLevel.Exception)
					{
						Debug.LogException(ex);
					}
				}
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass35_0
		{
			public Image[] images;

			public Sprite sprite;

			internal void <SetSprite>b__0()
			{
				for (int i = 0; i < images.Length; i++)
				{
					try
					{
						if (!((Object)(object)images[i] == (Object)null) && !((UIBehaviour)images[i]).IsDestroyed() && !object.Equals(((Component)images[i]).gameObject, null))
						{
							images[i].sprite = sprite;
						}
					}
					catch (Exception ex)
					{
						if (settings.debugLevel <= DebugLevel.Exception)
						{
							Debug.LogException(ex);
						}
					}
				}
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass37_0
		{
			public SpriteRenderer spriteRenderer;
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass37_1
		{
			public Sprite sprite;

			public <>c__DisplayClass37_0 CS$<>8__locals1;

			internal void <SetSprite>b__0()
			{
				if ((Object)(object)CS$<>8__locals1.spriteRenderer == (Object)null || object.Equals(((Component)CS$<>8__locals1.spriteRenderer).gameObject, null))
				{
					return;
				}
				try
				{
					CS$<>8__locals1.spriteRenderer.sprite = sprite;
				}
				catch (Exception ex)
				{
					if (settings.debugLevel <= DebugLevel.Exception)
					{
						Debug.LogException(ex);
					}
				}
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass42_0
		{
			public SpriteRenderer[] spriteRenderers;

			public Sprite sprite;

			internal void <SetSprite>b__0()
			{
				for (int i = 0; i < spriteRenderers.Length; i++)
				{
					try
					{
						if (!((Object)(object)spriteRenderers[i] == (Object)null) && !object.Equals(((Component)spriteRenderers[i]).gameObject, null))
						{
							spriteRenderers[i].sprite = sprite;
						}
					}
					catch (Exception ex)
					{
						if (settings.debugLevel <= DebugLevel.Exception)
						{
							Debug.LogException(ex);
						}
					}
				}
			}
		}

		[CompilerGenerated]
		private sealed class <LoadSprite>d__10 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder<Sprite> <>t__builder;

			public string url;

			public Vector2 pivot;

			public TextureFormat textureFormat;

			public bool ignoreImageNotFoundError;

			private <>c__DisplayClass10_0 <>8__1;

			private Sprite <sprite>5__2;

			private Sprite <>s__3;

			private byte[] <cachedImage>5__4;

			private byte[] <>s__5;

			private Texture2D <texture>5__6;

			private Sprite <sprite>5__7;

			private Exception <e>5__8;

			private string <name>5__9;

			private Texture2D <tex>5__10;

			private Sprite <sprite>5__11;

			private Awaiter <>u__1;

			private Awaiter<Sprite> <>u__2;

			private TaskAwaiter<byte[]> <>u__3;

			private Awaiter <>u__4;

			private TaskAwaiter <>u__5;

			private void MoveNext()
			{
				//IL_050f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0514: Unknown result type (might be due to invalid IL or missing references)
				//IL_0518: Unknown result type (might be due to invalid IL or missing references)
				//IL_051d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_022a: Unknown result type (might be due to invalid IL or missing references)
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0237: Unknown result type (might be due to invalid IL or missing references)
				//IL_0552: Unknown result type (might be due to invalid IL or missing references)
				//IL_0557: Unknown result type (might be due to invalid IL or missing references)
				//IL_055f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0532: Unknown result type (might be due to invalid IL or missing references)
				//IL_0534: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_061b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0670: Unknown result type (might be due to invalid IL or missing references)
				//IL_0683: Unknown result type (might be due to invalid IL or missing references)
				//IL_020a: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e0: Expected O, but got Unknown
				//IL_0365: Unknown result type (might be due to invalid IL or missing references)
				//IL_036a: Unknown result type (might be due to invalid IL or missing references)
				//IL_036e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0373: Unknown result type (might be due to invalid IL or missing references)
				//IL_0424: Unknown result type (might be due to invalid IL or missing references)
				//IL_042a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0388: Unknown result type (might be due to invalid IL or missing references)
				//IL_038a: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Sprite result;
				try
				{
					Awaiter awaiter4;
					Awaiter<Sprite> awaiter3;
					Awaiter awaiter2;
					TaskAwaiter awaiter;
					UniTask val;
					switch (num)
					{
					default:
						<>8__1 = new <>c__DisplayClass10_0();
						<>8__1.url = url;
						<>8__1.ignoreImageNotFoundError = ignoreImageNotFoundError;
						if (string.IsNullOrEmpty(<>8__1.url))
						{
							if (settings.debugLevel <= DebugLevel.Error)
							{
								Debug.LogError((object)"[ImageLoader] Empty url. Image could not be loaded!");
							}
							result = null;
						}
						else
						{
							if (!MemoryCacheContains(<>8__1.url))
							{
								goto IL_00fc;
							}
							<sprite>5__2 = LoadFromMemoryCache(<>8__1.url);
							if (!((Object)(object)<sprite>5__2 != (Object)null))
							{
								<sprite>5__2 = null;
								goto IL_00fc;
							}
							result = <sprite>5__2;
						}
						goto end_IL_0007;
					case 0:
						awaiter4 = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_01c3;
					case 1:
						awaiter3 = <>u__2;
						<>u__2 = default(Awaiter<Sprite>);
						num = (<>1__state = -1);
						goto IL_0246;
					case 2:
					case 3:
						try
						{
							Awaiter awaiter5;
							TaskAwaiter<byte[]> awaiter6;
							if (num != 2)
							{
								if (num == 3)
								{
									awaiter5 = <>u__4;
									<>u__4 = default(Awaiter);
									num = (<>1__state = -1);
									goto IL_03c4;
								}
								awaiter6 = LoadDiskAsync(<>8__1.url).GetAwaiter();
								if (!awaiter6.IsCompleted)
								{
									num = (<>1__state = 2);
									<>u__3 = awaiter6;
									<LoadSprite>d__10 <LoadSprite>d__ = this;
									<>t__builder.AwaitUnsafeOnCompleted<TaskAwaiter<byte[]>, <LoadSprite>d__10>(ref awaiter6, ref <LoadSprite>d__);
									return;
								}
							}
							else
							{
								awaiter6 = <>u__3;
								<>u__3 = default(TaskAwaiter<byte[]>);
								num = (<>1__state = -1);
							}
							<>s__5 = awaiter6.GetResult();
							<cachedImage>5__4 = <>s__5;
							<>s__5 = null;
							if (<cachedImage>5__4 != null && <cachedImage>5__4.Length != 0)
							{
								SwitchToMainThreadAwaitable val2 = UniTask.SwitchToMainThread(default(CancellationToken));
								awaiter5 = ((SwitchToMainThreadAwaitable)(ref val2)).GetAwaiter();
								if (!((Awaiter)(ref awaiter5)).IsCompleted)
								{
									num = (<>1__state = 3);
									<>u__4 = awaiter5;
									<LoadSprite>d__10 <LoadSprite>d__ = this;
									<>t__builder.AwaitUnsafeOnCompleted<Awaiter, <LoadSprite>d__10>(ref awaiter5, ref <LoadSprite>d__);
									return;
								}
								goto IL_03c4;
							}
							goto IL_0488;
							IL_0488:
							<cachedImage>5__4 = null;
							goto IL_04c2;
							IL_03c4:
							((Awaiter)(ref awaiter5)).GetResult();
							<texture>5__6 = new Texture2D(2, 2, textureFormat, true);
							if (!ImageConversion.LoadImage(<texture>5__6, <cachedImage>5__4))
							{
								<texture>5__6 = null;
								goto IL_0488;
							}
							<sprite>5__7 = Sprite.Create(<texture>5__6, new Rect(0f, 0f, (float)((Texture)<texture>5__6).width, (float)((Texture)<texture>5__6).height), pivot);
							if ((Object)(object)<sprite>5__7 != (Object)null)
							{
								SaveToMemoryCache(<>8__1.url, <sprite>5__7, replace: true);
							}
							RemoveLoading(<>8__1.url);
							result = <sprite>5__7;
						}
						catch (Exception ex)
						{
							<e>5__8 = ex;
							if (settings.debugLevel <= DebugLevel.Exception)
							{
								Debug.LogException(<e>5__8);
							}
							goto IL_04c2;
						}
						goto end_IL_0007;
					case 4:
						awaiter2 = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_056e;
					case 5:
						{
							awaiter = <>u__5;
							<>u__5 = default(TaskAwaiter);
							num = (<>1__state = -1);
							break;
						}
						IL_01c3:
						((Awaiter)(ref awaiter4)).GetResult();
						awaiter3 = LoadSprite(<>8__1.url, textureFormat, <>8__1.ignoreImageNotFoundError).GetAwaiter();
						if (!awaiter3.IsCompleted)
						{
							num = (<>1__state = 1);
							<>u__2 = awaiter3;
							<LoadSprite>d__10 <LoadSprite>d__ = this;
							<>t__builder.AwaitUnsafeOnCompleted<Awaiter<Sprite>, <LoadSprite>d__10>(ref awaiter3, ref <LoadSprite>d__);
							return;
						}
						goto IL_0246;
						IL_04c2:
						<>8__1.request = null;
						<>8__1.finished = false;
						UniTask.Post((Action)async delegate
						{
							try
							{
								<>8__1.request = UnityWebRequestTexture.GetTexture(<>8__1.url);
								UnityWebRequestAsyncOperationAwaiter val3 = UnityAsyncExtensions.GetAwaiter(<>8__1.request.SendWebRequest());
								if (!((UnityWebRequestAsyncOperationAwaiter)(ref val3)).IsCompleted)
								{
									await val3;
									UnityWebRequestAsyncOperationAwaiter val4 = default(UnityWebRequestAsyncOperationAwaiter);
									val3 = val4;
								}
								((UnityWebRequestAsyncOperationAwaiter)(ref val3)).GetResult();
							}
							catch (Exception ex2)
							{
								Exception e = ex2;
								if (!<>8__1.ignoreImageNotFoundError && settings.debugLevel <= DebugLevel.Exception)
								{
									Debug.LogException(e);
								}
							}
							finally
							{
								<>8__1.finished = true;
							}
						}, (PlayerLoopTiming)8);
						val = UniTask.WaitUntil((Func<bool>)(() => <>8__1.finished), (PlayerLoopTiming)8, default(CancellationToken), false);
						awaiter2 = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter2)).IsCompleted)
						{
							num = (<>1__state = 4);
							<>u__1 = awaiter2;
							<LoadSprite>d__10 <LoadSprite>d__ = this;
							<>t__builder.AwaitUnsafeOnCompleted<Awaiter, <LoadSprite>d__10>(ref awaiter2, ref <LoadSprite>d__);
							return;
						}
						goto IL_056e;
						IL_056e:
						((Awaiter)(ref awaiter2)).GetResult();
						RemoveLoading(<>8__1.url);
						if (string.IsNullOrEmpty(<>8__1.request.error))
						{
							<name>5__9 = Path.GetFileNameWithoutExtension(<>8__1.url);
							<tex>5__10 = ((DownloadHandlerTexture)<>8__1.request.downloadHandler).texture;
							Debug.Log((object)$"LoadSprite: name={<name>5__9}, size={Utils.ToSize(<tex>5__10.GetRawTextureData().Length)}, mipmap={((Texture)<tex>5__10).mipmapCount}, format={<tex>5__10.format}, graphicsFormat={((Texture)<tex>5__10).graphicsFormat}, size={((Texture)<tex>5__10).width}x{((Texture)<tex>5__10).height}");
							<sprite>5__11 = ToSprite(<tex>5__10);
							awaiter = SaveDiskAsync(<>8__1.url, <>8__1.request.downloadHandler.data).GetAwaiter();
							if (!awaiter.IsCompleted)
							{
								num = (<>1__state = 5);
								<>u__5 = awaiter;
								<LoadSprite>d__10 <LoadSprite>d__ = this;
								<>t__builder.AwaitUnsafeOnCompleted<TaskAwaiter, <LoadSprite>d__10>(ref awaiter, ref <LoadSprite>d__);
								return;
							}
							break;
						}
						if (settings.debugLevel <= DebugLevel.Error)
						{
							Debug.LogError((object)("[ImageLoader] " + <>8__1.request.error + ": url=" + <>8__1.url));
						}
						result = null;
						goto end_IL_0007;
						IL_00fc:
						if (IsLoading(<>8__1.url))
						{
							if (settings.debugLevel <= DebugLevel.Log)
							{
								Debug.Log((object)("[ImageLoader] Waiting while another task is loading the sprite url=" + <>8__1.url));
							}
							val = UniTask.WaitWhile((Func<bool>)(() => IsLoading(<>8__1.url)), (PlayerLoopTiming)8, default(CancellationToken), false);
							awaiter4 = ((UniTask)(ref val)).GetAwaiter();
							if (!((Awaiter)(ref awaiter4)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter4;
								<LoadSprite>d__10 <LoadSprite>d__ = this;
								<>t__builder.AwaitUnsafeOnCompleted<Awaiter, <LoadSprite>d__10>(ref awaiter4, ref <LoadSprite>d__);
								return;
							}
							goto IL_01c3;
						}
						AddLoading(<>8__1.url);
						if (settings.debugLevel <= DebugLevel.Log)
						{
							Debug.Log((object)("[ImageLoader] Loading new Sprite into memory url=" + <>8__1.url));
						}
						goto case 2;
						IL_0246:
						<>s__3 = awaiter3.GetResult();
						result = <>s__3;
						goto end_IL_0007;
					}
					awaiter.GetResult();
					SaveToMemoryCache(<>8__1.url, <sprite>5__11, replace: true);
					result = <sprite>5__11;
					end_IL_0007:;
				}
				catch (Exception ex)
				{
					<>1__state = -2;
					<>8__1 = null;
					<>t__builder.SetException(ex);
					return;
				}
				<>1__state = -2;
				<>8__1 = null;
				<>t__builder.SetResult(result);
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[CompilerGenerated]
		private sealed class <LoadSpriteMemoryOptimized>d__11 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder<Sprite> <>t__builder;

			public string url;

			public int ppu;

			public GraphicsFormat finalGraphicsFormat;

			public int anisoLevel;

			public FilterMode filterMode;

			public SpriteMeshType spriteMeshType;

			public Vector2? pivot;

			public Rect? rect;

			public TextureFormat textureFormat;

			public bool ignoreImageNotFoundError;

			private <>c__DisplayClass11_0 <>8__1;

			private Func<Texture2D, Sprite> <createSprite>5__2;

			private Sprite <sprite>5__3;

			private Sprite <>s__4;

			private byte[] <cachedImage>5__5;

			private byte[] <>s__6;

			private Texture2D <texture>5__7;

			private Sprite <sprite>5__8;

			private Exception <e>5__9;

			private string <name>5__10;

			private Texture2D <compressedTexture>5__11;

			private Sprite <sprite>5__12;

			private Awaiter <>u__1;

			private Awaiter<Sprite> <>u__2;

			private TaskAwaiter<byte[]> <>u__3;

			private Awaiter <>u__4;

			private TaskAwaiter <>u__5;

			private void MoveNext()
			{
				//IL_0540: Unknown result type (might be due to invalid IL or missing references)
				//IL_0545: Unknown result type (might be due to invalid IL or missing references)
				//IL_0549: Unknown result type (might be due to invalid IL or missing references)
				//IL_054e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0273: Unknown result type (might be due to invalid IL or missing references)
				//IL_027b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0583: Unknown result type (might be due to invalid IL or missing references)
				//IL_0588: Unknown result type (might be due to invalid IL or missing references)
				//IL_0590: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0563: Unknown result type (might be due to invalid IL or missing references)
				//IL_0565: Unknown result type (might be due to invalid IL or missing references)
				//IL_021b: Unknown result type (might be due to invalid IL or missing references)
				//IL_022b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0230: Unknown result type (might be due to invalid IL or missing references)
				//IL_0234: Unknown result type (might be due to invalid IL or missing references)
				//IL_0239: Unknown result type (might be due to invalid IL or missing references)
				//IL_0653: Unknown result type (might be due to invalid IL or missing references)
				//IL_065f: Unknown result type (might be due to invalid IL or missing references)
				//IL_024e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0250: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_06db: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0403: Unknown result type (might be due to invalid IL or missing references)
				//IL_0408: Unknown result type (might be due to invalid IL or missing references)
				//IL_0410: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_042b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0431: Unknown result type (might be due to invalid IL or missing references)
				//IL_043b: Expected O, but got Unknown
				//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Sprite result;
				try
				{
					Awaiter awaiter4;
					Awaiter<Sprite> awaiter3;
					Awaiter awaiter2;
					TaskAwaiter awaiter;
					UniTask val;
					switch (num)
					{
					default:
						<>8__1 = new <>c__DisplayClass11_0();
						<>8__1.url = url;
						<>8__1.rect = rect;
						<>8__1.pivot = pivot;
						<>8__1.ppu = ppu;
						<>8__1.spriteMeshType = spriteMeshType;
						<>8__1.ignoreImageNotFoundError = ignoreImageNotFoundError;
						if (string.IsNullOrEmpty(<>8__1.url))
						{
							if (settings.debugLevel <= DebugLevel.Error)
							{
								Debug.LogError((object)"[ImageLoader] Empty url. Image could not be loaded!");
							}
							result = null;
						}
						else
						{
							if (!MemoryCacheContains(<>8__1.url))
							{
								goto IL_0140;
							}
							<sprite>5__3 = LoadFromMemoryCache(<>8__1.url);
							if (!((Object)(object)<sprite>5__3 != (Object)null))
							{
								<sprite>5__3 = null;
								goto IL_0140;
							}
							result = <sprite>5__3;
						}
						goto end_IL_0007;
					case 0:
						awaiter4 = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_0207;
					case 1:
						awaiter3 = <>u__2;
						<>u__2 = default(Awaiter<Sprite>);
						num = (<>1__state = -1);
						goto IL_028a;
					case 2:
					case 3:
						try
						{
							Awaiter awaiter5;
							TaskAwaiter<byte[]> awaiter6;
							if (num != 2)
							{
								if (num == 3)
								{
									awaiter5 = <>u__4;
									<>u__4 = default(Awaiter);
									num = (<>1__state = -1);
									goto IL_041f;
								}
								awaiter6 = LoadDiskAsync(<>8__1.url).GetAwaiter();
								if (!awaiter6.IsCompleted)
								{
									num = (<>1__state = 2);
									<>u__3 = awaiter6;
									<LoadSpriteMemoryOptimized>d__11 <LoadSpriteMemoryOptimized>d__ = this;
									<>t__builder.AwaitUnsafeOnCompleted<TaskAwaiter<byte[]>, <LoadSpriteMemoryOptimized>d__11>(ref awaiter6, ref <LoadSpriteMemoryOptimized>d__);
									return;
								}
							}
							else
							{
								awaiter6 = <>u__3;
								<>u__3 = default(TaskAwaiter<byte[]>);
								num = (<>1__state = -1);
							}
							<>s__6 = awaiter6.GetResult();
							<cachedImage>5__5 = <>s__6;
							<>s__6 = null;
							if (<cachedImage>5__5 != null && <cachedImage>5__5.Length != 0)
							{
								SwitchToMainThreadAwaitable val2 = UniTask.SwitchToMainThread(default(CancellationToken));
								awaiter5 = ((SwitchToMainThreadAwaitable)(ref val2)).GetAwaiter();
								if (!((Awaiter)(ref awaiter5)).IsCompleted)
								{
									num = (<>1__state = 3);
									<>u__4 = awaiter5;
									<LoadSpriteMemoryOptimized>d__11 <LoadSpriteMemoryOptimized>d__ = this;
									<>t__builder.AwaitUnsafeOnCompleted<Awaiter, <LoadSpriteMemoryOptimized>d__11>(ref awaiter5, ref <LoadSpriteMemoryOptimized>d__);
									return;
								}
								goto IL_041f;
							}
							goto IL_04b9;
							IL_04b9:
							<cachedImage>5__5 = null;
							goto IL_04f3;
							IL_041f:
							((Awaiter)(ref awaiter5)).GetResult();
							<texture>5__7 = new Texture2D(2, 2, textureFormat, true);
							if (!ImageConversion.LoadImage(<texture>5__7, <cachedImage>5__5))
							{
								<texture>5__7 = null;
								goto IL_04b9;
							}
							<sprite>5__8 = <createSprite>5__2(<texture>5__7);
							if ((Object)(object)<sprite>5__8 != (Object)null)
							{
								SaveToMemoryCache(<>8__1.url, <sprite>5__8, replace: true);
							}
							RemoveLoading(<>8__1.url);
							result = <sprite>5__8;
						}
						catch (Exception ex)
						{
							<e>5__9 = ex;
							if (settings.debugLevel <= DebugLevel.Exception)
							{
								Debug.LogException(<e>5__9);
							}
							goto IL_04f3;
						}
						goto end_IL_0007;
					case 4:
						awaiter2 = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_059f;
					case 5:
						{
							awaiter = <>u__5;
							<>u__5 = default(TaskAwaiter);
							num = (<>1__state = -1);
							break;
						}
						IL_0207:
						((Awaiter)(ref awaiter4)).GetResult();
						awaiter3 = LoadSprite(<>8__1.url, textureFormat, <>8__1.ignoreImageNotFoundError).GetAwaiter();
						if (!awaiter3.IsCompleted)
						{
							num = (<>1__state = 1);
							<>u__2 = awaiter3;
							<LoadSpriteMemoryOptimized>d__11 <LoadSpriteMemoryOptimized>d__ = this;
							<>t__builder.AwaitUnsafeOnCompleted<Awaiter<Sprite>, <LoadSpriteMemoryOptimized>d__11>(ref awaiter3, ref <LoadSpriteMemoryOptimized>d__);
							return;
						}
						goto IL_028a;
						IL_04f3:
						<>8__1.request = null;
						<>8__1.finished = false;
						UniTask.Post((Action)async delegate
						{
							try
							{
								<>8__1.request = new UnityWebRequest(<>8__1.url);
								<>8__1.request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
								UnityWebRequestAsyncOperationAwaiter val3 = UnityAsyncExtensions.GetAwaiter(<>8__1.request.SendWebRequest());
								if (!((UnityWebRequestAsyncOperationAwaiter)(ref val3)).IsCompleted)
								{
									await val3;
									UnityWebRequestAsyncOperationAwaiter val4 = default(UnityWebRequestAsyncOperationAwaiter);
									val3 = val4;
								}
								((UnityWebRequestAsyncOperationAwaiter)(ref val3)).GetResult();
							}
							catch (Exception ex2)
							{
								Exception e = ex2;
								if (!<>8__1.ignoreImageNotFoundError && settings.debugLevel <= DebugLevel.Exception)
								{
									Debug.LogException(e);
								}
							}
							finally
							{
								<>8__1.finished = true;
							}
						}, (PlayerLoopTiming)8);
						val = UniTask.WaitUntil((Func<bool>)(() => <>8__1.finished), (PlayerLoopTiming)8, default(CancellationToken), false);
						awaiter2 = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter2)).IsCompleted)
						{
							num = (<>1__state = 4);
							<>u__1 = awaiter2;
							<LoadSpriteMemoryOptimized>d__11 <LoadSpriteMemoryOptimized>d__ = this;
							<>t__builder.AwaitUnsafeOnCompleted<Awaiter, <LoadSpriteMemoryOptimized>d__11>(ref awaiter2, ref <LoadSpriteMemoryOptimized>d__);
							return;
						}
						goto IL_059f;
						IL_059f:
						((Awaiter)(ref awaiter2)).GetResult();
						RemoveLoading(<>8__1.url);
						if (string.IsNullOrEmpty(<>8__1.request.error))
						{
							<name>5__10 = Path.GetFileNameWithoutExtension(<>8__1.url);
							<compressedTexture>5__11 = Utils.CreateTexWithMipmaps(<>8__1.request.downloadHandler.data, shouldGenerateMipMaps: true, finalGraphicsFormat, anisoLevel, filterMode, <name>5__10);
							ManualLogSource obj = Log.LogDevExtra();
							if (obj != null)
							{
								obj.LogInfo((object)$"LoadSpriteMemoryOptimized: name={<name>5__10}, size={Utils.ToSize(<compressedTexture>5__11.GetRawTextureData().Length)}, mipmap={((Texture)<compressedTexture>5__11).mipmapCount}, format={<compressedTexture>5__11.format}, graphicsFormat={((Texture)<compressedTexture>5__11).graphicsFormat}, size={((Texture)<compressedTexture>5__11).width}x{((Texture)<compressedTexture>5__11).height}");
							}
							<sprite>5__12 = <createSprite>5__2(<compressedTexture>5__11);
							awaiter = SaveDiskAsync(<>8__1.url, <>8__1.request.downloadHandler.data).GetAwaiter();
							if (!awaiter.IsCompleted)
							{
								num = (<>1__state = 5);
								<>u__5 = awaiter;
								<LoadSpriteMemoryOptimized>d__11 <LoadSpriteMemoryOptimized>d__ = this;
								<>t__builder.AwaitUnsafeOnCompleted<TaskAwaiter, <LoadSpriteMemoryOptimized>d__11>(ref awaiter, ref <LoadSpriteMemoryOptimized>d__);
								return;
							}
							break;
						}
						if (settings.debugLevel <= DebugLevel.Error)
						{
							Debug.LogError((object)("[ImageLoader] " + <>8__1.request.error + ": url=" + <>8__1.url));
						}
						result = null;
						goto end_IL_0007;
						IL_0140:
						if (IsLoading(<>8__1.url))
						{
							if (settings.debugLevel <= DebugLevel.Log)
							{
								Debug.Log((object)("[ImageLoader] Waiting while another task is loading the sprite url=" + <>8__1.url));
							}
							val = UniTask.WaitWhile((Func<bool>)(() => IsLoading(<>8__1.url)), (PlayerLoopTiming)8, default(CancellationToken), false);
							awaiter4 = ((UniTask)(ref val)).GetAwaiter();
							if (!((Awaiter)(ref awaiter4)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter4;
								<LoadSpriteMemoryOptimized>d__11 <LoadSpriteMemoryOptimized>d__ = this;
								<>t__builder.AwaitUnsafeOnCompleted<Awaiter, <LoadSpriteMemoryOptimized>d__11>(ref awaiter4, ref <LoadSpriteMemoryOptimized>d__);
								return;
							}
							goto IL_0207;
						}
						AddLoading(<>8__1.url);
						<createSprite>5__2 = delegate(Texture2D texture)
						{
							//IL_002c: Unknown result type (might be due to invalid IL or missing references)
							//IL_006e: Unknown result type (might be due to invalid IL or missing references)
							//IL_0079: Unknown result type (might be due to invalid IL or missing references)
							//IL_0087: Unknown result type (might be due to invalid IL or missing references)
							//IL_0058: Unknown result type (might be due to invalid IL or missing references)
							if (!<>8__1.rect.HasValue)
							{
								<>8__1.rect = new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height);
							}
							if (!<>8__1.pivot.HasValue)
							{
								<>8__1.pivot = new Vector2(0.5f, 0.5f);
							}
							return Sprite.Create(texture, <>8__1.rect.Value, <>8__1.pivot.Value, (float)<>8__1.ppu, 0u, <>8__1.spriteMeshType);
						};
						if (settings.debugLevel <= DebugLevel.Log)
						{
							Debug.Log((object)("[ImageLoader] Loading new Sprite into memory url=" + <>8__1.url));
						}
						goto case 2;
						IL_028a:
						<>s__4 = awaiter3.GetResult();
						result = <>s__4;
						goto end_IL_0007;
					}
					awaiter.GetResult();
					SaveToMemoryCache(<>8__1.url, <sprite>5__12, replace: true);
					result = <sprite>5__12;
					end_IL_0007:;
				}
				catch (Exception ex)
				{
					<>1__state = -2;
					<>8__1 = null;
					<createSprite>5__2 = null;
					<>t__builder.SetException(ex);
					return;
				}
				<>1__state = -2;
				<>8__1 = null;
				<createSprite>5__2 = null;
				<>t__builder.SetResult(result);
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[CompilerGenerated]
		private sealed class <SetSprite>d__30 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public string url;

			public Image image;

			public Vector2 pivot;

			public TextureFormat textureFormat;

			public bool ignoreImageNotFoundError;

			private <>c__DisplayClass30_0 <>8__1;

			private <>c__DisplayClass30_1 <>8__2;

			private Sprite <>s__3;

			private Exception <e>5__4;

			private Awaiter<Sprite> <>u__1;

			private void MoveNext()
			{
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				try
				{
					if (num != 0)
					{
						<>8__1 = new <>c__DisplayClass30_0();
						<>8__1.image = image;
					}
					try
					{
						Awaiter<Sprite> awaiter;
						if (num == 0)
						{
							awaiter = <>u__1;
							<>u__1 = default(Awaiter<Sprite>);
							num = (<>1__state = -1);
							goto IL_011c;
						}
						<>8__2 = new <>c__DisplayClass30_1();
						<>8__2.CS$<>8__locals1 = <>8__1;
						if (!((Object)(object)<>8__2.CS$<>8__locals1.image == (Object)null) && !((UIBehaviour)<>8__2.CS$<>8__locals1.image).IsDestroyed() && !((Object)(object)((Component)<>8__2.CS$<>8__locals1.image).gameObject == (Object)null))
						{
							awaiter = LoadSprite(url, pivot, textureFormat, ignoreImageNotFoundError).GetAwaiter();
							if (!awaiter.IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter;
								<SetSprite>d__30 <SetSprite>d__ = this;
								((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<Sprite>, <SetSprite>d__30>(ref awaiter, ref <SetSprite>d__);
								return;
							}
							goto IL_011c;
						}
						goto end_IL_002c;
						IL_011c:
						<>s__3 = awaiter.GetResult();
						<>8__2.sprite = <>s__3;
						<>s__3 = null;
						UniTask.Post((Action)delegate
						{
							if ((Object)(object)<>8__2.CS$<>8__locals1.image == (Object)null || ((UIBehaviour)<>8__2.CS$<>8__locals1.image).IsDestroyed() || object.Equals(((Component)<>8__2.CS$<>8__locals1.image).gameObject, null))
							{
								return;
							}
							try
							{
								<>8__2.CS$<>8__locals1.image.sprite = <>8__2.sprite;
							}
							catch (Exception ex2)
							{
								if (settings.debugLevel <= DebugLevel.Exception)
								{
									Debug.LogException(ex2);
								}
							}
						}, (PlayerLoopTiming)8);
						<>8__2 = null;
						end_IL_002c:;
					}
					catch (Exception ex)
					{
						<e>5__4 = ex;
						if (settings.debugLevel <= DebugLevel.Exception)
						{
							Debug.LogException(<e>5__4);
						}
					}
				}
				catch (Exception ex)
				{
					<>1__state = -2;
					<>8__1 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(ex);
					return;
				}
				<>1__state = -2;
				<>8__1 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[CompilerGenerated]
		private sealed class <SetSprite>d__35 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public string url;

			public Vector2 pivot;

			public TextureFormat textureFormat;

			public bool ignoreImageNotFoundError;

			public Image[] images;

			private <>c__DisplayClass35_0 <>8__1;

			private Sprite <>s__2;

			private Awaiter<Sprite> <>u__1;

			private void MoveNext()
			{
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				try
				{
					Awaiter<Sprite> awaiter;
					if (num == 0)
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter<Sprite>);
						num = (<>1__state = -1);
						goto IL_00b8;
					}
					<>8__1 = new <>c__DisplayClass35_0();
					<>8__1.images = images;
					if (<>8__1.images != null)
					{
						awaiter = LoadSprite(url, pivot, textureFormat, ignoreImageNotFoundError).GetAwaiter();
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							<SetSprite>d__35 <SetSprite>d__ = this;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<Sprite>, <SetSprite>d__35>(ref awaiter, ref <SetSprite>d__);
							return;
						}
						goto IL_00b8;
					}
					goto end_IL_0007;
					IL_00b8:
					<>s__2 = awaiter.GetResult();
					<>8__1.sprite = <>s__2;
					<>s__2 = null;
					UniTask.Post((Action)delegate
					{
						for (int i = 0; i < <>8__1.images.Length; i++)
						{
							try
							{
								if (!((Object)(object)<>8__1.images[i] == (Object)null) && !((UIBehaviour)<>8__1.images[i]).IsDestroyed() && !object.Equals(((Component)<>8__1.images[i]).gameObject, null))
								{
									<>8__1.images[i].sprite = <>8__1.sprite;
								}
							}
							catch (Exception ex)
							{
								if (settings.debugLevel <= DebugLevel.Exception)
								{
									Debug.LogException(ex);
								}
							}
						}
					}, (PlayerLoopTiming)8);
					end_IL_0007:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<>8__1 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				<>8__1 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[CompilerGenerated]
		private sealed class <SetSprite>d__37 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public string url;

			public SpriteRenderer spriteRenderer;

			public Vector2 pivot;

			public TextureFormat textureFormat;

			public bool ignoreImageNotFoundError;

			private <>c__DisplayClass37_0 <>8__1;

			private <>c__DisplayClass37_1 <>8__2;

			private Sprite <>s__3;

			private Exception <e>5__4;

			private Awaiter<Sprite> <>u__1;

			private void MoveNext()
			{
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				try
				{
					if (num != 0)
					{
						<>8__1 = new <>c__DisplayClass37_0();
						<>8__1.spriteRenderer = spriteRenderer;
					}
					try
					{
						Awaiter<Sprite> awaiter;
						if (num == 0)
						{
							awaiter = <>u__1;
							<>u__1 = default(Awaiter<Sprite>);
							num = (<>1__state = -1);
							goto IL_0105;
						}
						<>8__2 = new <>c__DisplayClass37_1();
						<>8__2.CS$<>8__locals1 = <>8__1;
						if (!((Object)(object)<>8__2.CS$<>8__locals1.spriteRenderer == (Object)null) && !((Object)(object)((Component)<>8__2.CS$<>8__locals1.spriteRenderer).gameObject == (Object)null))
						{
							awaiter = LoadSprite(url, pivot, textureFormat, ignoreImageNotFoundError).GetAwaiter();
							if (!awaiter.IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter;
								<SetSprite>d__37 <SetSprite>d__ = this;
								((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<Sprite>, <SetSprite>d__37>(ref awaiter, ref <SetSprite>d__);
								return;
							}
							goto IL_0105;
						}
						goto end_IL_002c;
						IL_0105:
						<>s__3 = awaiter.GetResult();
						<>8__2.sprite = <>s__3;
						<>s__3 = null;
						UniTask.Post((Action)delegate
						{
							if ((Object)(object)<>8__2.CS$<>8__locals1.spriteRenderer == (Object)null || object.Equals(((Component)<>8__2.CS$<>8__locals1.spriteRenderer).gameObject, null))
							{
								return;
							}
							try
							{
								<>8__2.CS$<>8__locals1.spriteRenderer.sprite = <>8__2.sprite;
							}
							catch (Exception ex2)
							{
								if (settings.debugLevel <= DebugLevel.Exception)
								{
									Debug.LogException(ex2);
								}
							}
						}, (PlayerLoopTiming)8);
						<>8__2 = null;
						end_IL_002c:;
					}
					catch (Exception ex)
					{
						<e>5__4 = ex;
						if (settings.debugLevel <= DebugLevel.Exception)
						{
							Debug.LogException(<e>5__4);
						}
					}
				}
				catch (Exception ex)
				{
					<>1__state = -2;
					<>8__1 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(ex);
					return;
				}
				<>1__state = -2;
				<>8__1 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[CompilerGenerated]
		private sealed class <SetSprite>d__42 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public string url;

			public Vector2 pivot;

			public TextureFormat textureFormat;

			public bool ignoreImageNotFoundError;

			public SpriteRenderer[] spriteRenderers;

			private <>c__DisplayClass42_0 <>8__1;

			private Sprite <>s__2;

			private Awaiter<Sprite> <>u__1;

			private void MoveNext()
			{
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				try
				{
					Awaiter<Sprite> awaiter;
					if (num == 0)
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter<Sprite>);
						num = (<>1__state = -1);
						goto IL_00b8;
					}
					<>8__1 = new <>c__DisplayClass42_0();
					<>8__1.spriteRenderers = spriteRenderers;
					if (<>8__1.spriteRenderers != null)
					{
						awaiter = LoadSprite(url, pivot, textureFormat, ignoreImageNotFoundError).GetAwaiter();
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							<SetSprite>d__42 <SetSprite>d__ = this;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<Sprite>, <SetSprite>d__42>(ref awaiter, ref <SetSprite>d__);
							return;
						}
						goto IL_00b8;
					}
					goto end_IL_0007;
					IL_00b8:
					<>s__2 = awaiter.GetResult();
					<>8__1.sprite = <>s__2;
					<>s__2 = null;
					UniTask.Post((Action)delegate
					{
						for (int i = 0; i < <>8__1.spriteRenderers.Length; i++)
						{
							try
							{
								if (!((Object)(object)<>8__1.spriteRenderers[i] == (Object)null) && !object.Equals(((Component)<>8__1.spriteRenderers[i]).gameObject, null))
								{
									<>8__1.spriteRenderers[i].sprite = <>8__1.sprite;
								}
							}
							catch (Exception ex)
							{
								if (settings.debugLevel <= DebugLevel.Exception)
								{
									Debug.LogException(ex);
								}
							}
						}
					}, (PlayerLoopTiming)8);
					end_IL_0007:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<>8__1 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				<>8__1 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private static HashSet<string> loadingInProcess = new HashSet<string>();

		internal static readonly TaskFactory diskTaskFactory = new TaskFactory(new LimitedConcurrencyLevelTaskScheduler(1));

		internal static Dictionary<string, Sprite> memorySpriteCache = new Dictionary<string, Sprite>();

		public static readonly Settings settings = new Settings();

		private static void AddLoading(string url)
		{
			loadingInProcess.Add(url);
		}

		private static void RemoveLoading(string url)
		{
			loadingInProcess.Remove(url);
		}

		public static void Init()
		{
			string text = settings.diskSaveLocation + settings.diskSaveLocation;
		}

		public static bool IsLoading(string url)
		{
			return loadingInProcess.Contains(url);
		}

		public static Task ClearCache()
		{
			ClearMemoryCache();
			return ClearDiskCache();
		}

		public static bool CacheContains(string url)
		{
			return MemoryCacheContains(url) || DiskCacheContains(url);
		}

		public static Sprite ToSprite(Texture2D texture, float pixelDensity = 100f)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f), pixelDensity);
		}

		public static Sprite ToSprite(Texture2D texture, Vector2 pivot, float pixelDensity = 100f)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), pivot, pixelDensity);
		}

		internal static UniTask<Sprite> LoadSprite(string url, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return LoadSprite(url, Vector2.one * 0.5f, textureFormat, ignoreImageNotFoundError);
		}

		[AsyncStateMachine(typeof(<LoadSprite>d__10))]
		[DebuggerStepThrough]
		internal static UniTask<Sprite> LoadSprite(string url, Vector2 pivot, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			<LoadSprite>d__10 <LoadSprite>d__ = new <LoadSprite>d__10();
			<LoadSprite>d__.<>t__builder = AsyncUniTaskMethodBuilder<Sprite>.Create();
			<LoadSprite>d__.url = url;
			<LoadSprite>d__.pivot = pivot;
			<LoadSprite>d__.textureFormat = textureFormat;
			<LoadSprite>d__.ignoreImageNotFoundError = ignoreImageNotFoundError;
			<LoadSprite>d__.<>1__state = -1;
			<LoadSprite>d__.<>t__builder.Start<<LoadSprite>d__10>(ref <LoadSprite>d__);
			return <LoadSprite>d__.<>t__builder.Task;
		}

		[AsyncStateMachine(typeof(<LoadSpriteMemoryOptimized>d__11))]
		[DebuggerStepThrough]
		internal static UniTask<Sprite> LoadSpriteMemoryOptimized(string url, int ppu = 100, GraphicsFormat finalGraphicsFormat = 4, int anisoLevel = 1, FilterMode filterMode = 1, SpriteMeshType spriteMeshType = 1, Vector2? pivot = null, Rect? rect = null, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			<LoadSpriteMemoryOptimized>d__11 <LoadSpriteMemoryOptimized>d__ = new <LoadSpriteMemoryOptimized>d__11();
			<LoadSpriteMemoryOptimized>d__.<>t__builder = AsyncUniTaskMethodBuilder<Sprite>.Create();
			<LoadSpriteMemoryOptimized>d__.url = url;
			<LoadSpriteMemoryOptimized>d__.ppu = ppu;
			<LoadSpriteMemoryOptimized>d__.finalGraphicsFormat = finalGraphicsFormat;
			<LoadSpriteMemoryOptimized>d__.anisoLevel = anisoLevel;
			<LoadSpriteMemoryOptimized>d__.filterMode = filterMode;
			<LoadSpriteMemoryOptimized>d__.spriteMeshType = spriteMeshType;
			<LoadSpriteMemoryOptimized>d__.pivot = pivot;
			<LoadSpriteMemoryOptimized>d__.rect = rect;
			<LoadSpriteMemoryOptimized>d__.textureFormat = textureFormat;
			<LoadSpriteMemoryOptimized>d__.ignoreImageNotFoundError = ignoreImageNotFoundError;
			<LoadSpriteMemoryOptimized>d__.<>1__state = -1;
			<LoadSpriteMemoryOptimized>d__.<>t__builder.Start<<LoadSpriteMemoryOptimized>d__11>(ref <LoadSpriteMemoryOptimized>d__);
			return <LoadSpriteMemoryOptimized>d__.<>t__builder.Task;
		}

		private static string DiskCachePath(string url)
		{
			return $"{settings.diskSaveLocation}/I_{url.GetHashCode()}";
		}

		private static void SaveDisk(string url, byte[] data)
		{
			if (settings.useDiskCache)
			{
				Directory.CreateDirectory(settings.diskSaveLocation);
				Directory.CreateDirectory(Path.GetDirectoryName(DiskCachePath(url)));
				File.WriteAllBytes(DiskCachePath(url), data);
			}
		}

		private static byte[] LoadDisk(string url)
		{
			if (!settings.useDiskCache)
			{
				return null;
			}
			Directory.CreateDirectory(settings.diskSaveLocation);
			Directory.CreateDirectory(Path.GetDirectoryName(DiskCachePath(url)));
			if (!DiskCacheContains(url))
			{
				return null;
			}
			return File.ReadAllBytes(DiskCachePath(url));
		}

		private static Task SaveDiskAsync(string url, byte[] data)
		{
			if (!settings.useDiskCache)
			{
				return Task.CompletedTask;
			}
			return diskTaskFactory.StartNew(delegate
			{
				SaveDisk(url, data);
			});
		}

		private static Task<byte[]> LoadDiskAsync(string url)
		{
			if (!settings.useDiskCache)
			{
				return Task.FromResult<byte[]>(null);
			}
			return diskTaskFactory.StartNew(() => LoadDisk(url));
		}

		public static bool DiskCacheContains(string url)
		{
			return File.Exists(DiskCachePath(url));
		}

		public static Task<bool> DiskCacheExistsAsync(string url)
		{
			string path = DiskCachePath(url);
			return diskTaskFactory.StartNew(() => File.Exists(path));
		}

		public static Task ClearDiskCache()
		{
			return diskTaskFactory.StartNew(delegate
			{
				if (Directory.Exists(settings.diskSaveLocation))
				{
					Directory.Delete(settings.diskSaveLocation, recursive: true);
				}
			});
		}

		public static Task ClearDiskCache(string url)
		{
			string diskPath = DiskCachePath(url);
			return diskTaskFactory.StartNew(delegate
			{
				if (File.Exists(diskPath))
				{
					File.Delete(diskPath);
				}
			});
		}

		public static bool MemoryCacheContains(string url)
		{
			return memorySpriteCache.ContainsKey(url);
		}

		public static void SaveToMemoryCache(string url, Sprite sprite, bool replace = false)
		{
			if (!settings.useMemoryCache)
			{
				return;
			}
			if (!replace && memorySpriteCache.ContainsKey(url))
			{
				if (settings.debugLevel <= DebugLevel.Warning)
				{
					Debug.LogError((object)("[ImageLoader] Memory cache already contains key: " + url));
				}
			}
			else
			{
				memorySpriteCache[url] = sprite;
			}
		}

		public static Sprite LoadFromMemoryCache(string url)
		{
			if (!settings.useMemoryCache)
			{
				return null;
			}
			return GetValueOrDefault(url);
		}

		public static void ClearMemoryCache(string url)
		{
			Sprite valueOrDefault = GetValueOrDefault(url);
			if ((Object)(object)((valueOrDefault != null) ? valueOrDefault.texture : null) != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)valueOrDefault.texture);
			}
			memorySpriteCache.Remove(url);
		}

		public static void ClearMemoryCache()
		{
			foreach (Sprite value in memorySpriteCache.Values)
			{
				if ((Object)(object)((value != null) ? value.texture : null) != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)value.texture);
				}
			}
			memorySpriteCache.Clear();
		}

		private static Sprite GetValueOrDefault(string url)
		{
			if (memorySpriteCache.TryGetValue(url, out var value))
			{
				return value;
			}
			return null;
		}

		public static UniTask SetSprite(string url, Image image, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, image, Vector2.one * 0.5f, textureFormat, ignoreImageNotFoundError);
		}

		[AsyncStateMachine(typeof(<SetSprite>d__30))]
		[DebuggerStepThrough]
		public static UniTask SetSprite(string url, Image image, Vector2 pivot, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			<SetSprite>d__30 <SetSprite>d__ = new <SetSprite>d__30();
			<SetSprite>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<SetSprite>d__.url = url;
			<SetSprite>d__.image = image;
			<SetSprite>d__.pivot = pivot;
			<SetSprite>d__.textureFormat = textureFormat;
			<SetSprite>d__.ignoreImageNotFoundError = ignoreImageNotFoundError;
			<SetSprite>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <SetSprite>d__.<>t__builder)).Start<<SetSprite>d__30>(ref <SetSprite>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <SetSprite>d__.<>t__builder)).Task;
		}

		public static UniTask SetSprite(string url, params Image[] images)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, Vector2.one * 0.5f, (TextureFormat)5, ignoreImageNotFoundError: false, images);
		}

		public static UniTask SetSprite(string url, TextureFormat textureFormat, params Image[] images)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, Vector2.one * 0.5f, textureFormat, ignoreImageNotFoundError: false, images);
		}

		public static UniTask SetSprite(string url, bool ignoreImageNotFoundError, params Image[] images)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, Vector2.one * 0.5f, (TextureFormat)5, ignoreImageNotFoundError, images);
		}

		public static UniTask SetSprite(string url, TextureFormat textureFormat, bool ignoreImageNotFoundError, params Image[] images)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, Vector2.one * 0.5f, textureFormat, ignoreImageNotFoundError, images);
		}

		[AsyncStateMachine(typeof(<SetSprite>d__35))]
		[DebuggerStepThrough]
		public static UniTask SetSprite(string url, Vector2 pivot, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false, params Image[] images)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			<SetSprite>d__35 <SetSprite>d__ = new <SetSprite>d__35();
			<SetSprite>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<SetSprite>d__.url = url;
			<SetSprite>d__.pivot = pivot;
			<SetSprite>d__.textureFormat = textureFormat;
			<SetSprite>d__.ignoreImageNotFoundError = ignoreImageNotFoundError;
			<SetSprite>d__.images = images;
			<SetSprite>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <SetSprite>d__.<>t__builder)).Start<<SetSprite>d__35>(ref <SetSprite>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <SetSprite>d__.<>t__builder)).Task;
		}

		public static UniTask SetSprite(string url, SpriteRenderer spriteRenderer, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, spriteRenderer, Vector2.one * 0.5f, textureFormat, ignoreImageNotFoundError);
		}

		[AsyncStateMachine(typeof(<SetSprite>d__37))]
		[DebuggerStepThrough]
		public static UniTask SetSprite(string url, SpriteRenderer spriteRenderer, Vector2 pivot, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			<SetSprite>d__37 <SetSprite>d__ = new <SetSprite>d__37();
			<SetSprite>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<SetSprite>d__.url = url;
			<SetSprite>d__.spriteRenderer = spriteRenderer;
			<SetSprite>d__.pivot = pivot;
			<SetSprite>d__.textureFormat = textureFormat;
			<SetSprite>d__.ignoreImageNotFoundError = ignoreImageNotFoundError;
			<SetSprite>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <SetSprite>d__.<>t__builder)).Start<<SetSprite>d__37>(ref <SetSprite>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <SetSprite>d__.<>t__builder)).Task;
		}

		public static UniTask SetSprite(string url, params SpriteRenderer[] spriteRenderers)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, Vector2.one * 0.5f, (TextureFormat)5, ignoreImageNotFoundError: false, spriteRenderers);
		}

		public static UniTask SetSprite(string url, TextureFormat textureFormat, params SpriteRenderer[] spriteRenderers)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, Vector2.one * 0.5f, textureFormat, ignoreImageNotFoundError: false, spriteRenderers);
		}

		public static UniTask SetSprite(string url, bool ignoreImageNotFoundError, params SpriteRenderer[] spriteRenderers)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, Vector2.one * 0.5f, (TextureFormat)5, ignoreImageNotFoundError, spriteRenderers);
		}

		public static UniTask SetSprite(string url, TextureFormat textureFormat, bool ignoreImageNotFoundError, params SpriteRenderer[] spriteRenderers)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return SetSprite(url, Vector2.one * 0.5f, textureFormat, ignoreImageNotFoundError, spriteRenderers);
		}

		[AsyncStateMachine(typeof(<SetSprite>d__42))]
		[DebuggerStepThrough]
		public static UniTask SetSprite(string url, Vector2 pivot, TextureFormat textureFormat = 5, bool ignoreImageNotFoundError = false, params SpriteRenderer[] spriteRenderers)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			<SetSprite>d__42 <SetSprite>d__ = new <SetSprite>d__42();
			<SetSprite>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<SetSprite>d__.url = url;
			<SetSprite>d__.pivot = pivot;
			<SetSprite>d__.textureFormat = textureFormat;
			<SetSprite>d__.ignoreImageNotFoundError = ignoreImageNotFoundError;
			<SetSprite>d__.spriteRenderers = spriteRenderers;
			<SetSprite>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <SetSprite>d__.<>t__builder)).Start<<SetSprite>d__42>(ref <SetSprite>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <SetSprite>d__.<>t__builder)).Task;
		}
	}
	public class Settings
	{
		public DebugLevel debugLevel = DebugLevel.Error;

		public bool useMemoryCache = true;

		public bool useDiskCache = false;

		public bool generateMipMaps = false;

		public string diskSaveLocation { get; set; } = Application.persistentDataPath + "/imageCache";

	}
	public enum DebugLevel
	{
		Log,
		Warning,
		Error,
		Exception,
		None
	}
	public static class Utils
	{
		public enum SizeUnits
		{
			Byte,
			KB,
			MB,
			GB,
			TB,
			PB,
			EB,
			ZB,
			YB
		}

		public class SpriteContainer
		{
			public Sprite sprite;
		}

		public static string ToSize(long value, SizeUnits unit = SizeUnits.MB)
		{
			return ((double)value / Math.Pow(1024.0, (double)unit)).ToString("0.00") + unit;
		}

		public static bool IsPowerOfTwo(int x)
		{
			return x != 0 && (x & (x - 1)) == 0;
		}

		public static Texture2D CreateTexWithMipmaps(byte[] data, GraphicsFormat origGraphicsFormat, int height = 4, int width = 4, TextureFormat textureFormat = 0, string name = "")
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			GraphicsFormat val = (GraphicsFormat)100;
			TextureCreationFlags val2 = (TextureCreationFlags)1;
			Texture2D val3 = new Texture2D(width, height, val, val2);
			((Texture)val3).wrapMode = (TextureWrapMode)1;
			if (!ImageConversion.LoadImage(val3, data))
			{
				Debug.Log((object)$"CreateTexWithMipmaps: LoadImage failed, using format={val}, trying again with {(object)(GraphicsFormat)4}");
				val = (GraphicsFormat)4;
				val3 = new Texture2D(width, height, val, val2);
				if (!ImageConversion.LoadImage(val3, data))
				{
					Debug.LogError((object)$"CreateTexWithMipmaps: LoadImage failed, using format={val}, returning null texture");
					val3 = null;
				}
			}
			return val3;
		}

		public static Texture2D CreateTexWithMipmaps(byte[] data, bool shouldGenerateMipMaps = true, GraphicsFormat finalGraphicsFormat = 4, int anisoLevel = 1, FilterMode filterMode = 1, string name = "DynamicTex")
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			TextureCreationFlags val = (TextureCreationFlags)0;
			if (shouldGenerateMipMaps)
			{
				val = (TextureCreationFlags)1;
			}
			Texture2D val2 = new Texture2D(4, 4, finalGraphicsFormat, val)
			{
				name = name + "-" + shouldGenerateMipMaps,
				wrapMode = (TextureWrapMode)1,
				anisoLevel = 1,
				filterMode = (FilterMode)1
			};
			if (!ImageConversion.LoadImage(val2, data))
			{
				Debug.Log((object)$"CreateTexWithMipmaps: LoadImage failed using format={finalGraphicsFormat}, size={((Texture)val2).width}x{((Texture)val2).height} trying again with {(object)(GraphicsFormat)4}");
			}
			if (((Texture)val2).width % 4 == 0 && ((Texture)val2).height % 4 == 0)
			{
				val2.Compress(false);
			}
			return val2;
		}

		public static IEnumerator GetImageUsingUWRTexture(string url, Image img = null)
		{
			UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(url);
			yield return uwr.SendWebRequest();
			string name = Path.GetFileNameWithoutExtension(url);
			if ((int)uwr.result != 1 || !uwr.isDone)
			{
				Debug.Log((object)("GetImageUsingUWRTexture: Download failed : name=" + name + ", error=" + uwr.error));
				yield break;
			}
			Texture2D uwrTexture = ((DownloadHandlerTexture)uwr.downloadHandler).texture;
			Sprite downloadedSprite = Sprite.Create(uwrTexture, new Rect(0f, 0f, (float)((Texture)uwrTexture).width, (float)((Texture)uwrTexture).height), Vector2.zero, 100f, 0u, (SpriteMeshType)0);
			if ((Object)(object)img != (Object)null)
			{
				img.overrideSprite = downloadedSprite;
			}
			Debug.Log((object)$"GetImageUsingUWRTexture: name={name}, RawSize={ToSize(uwrTexture.GetRawTextureData().Length)}, mipmap={((Texture)uwrTexture).mipmapCount}, format={uwrTexture.format}, graphicsFormat={((Texture)uwrTexture).graphicsFormat}, dimensions={((Texture)uwrTexture).width}x{((Texture)uwrTexture).height}");
			uwr.Dispose();
		}

		public static IEnumerator GetImageUsingUWRBufferAndEnableMipmapsAndCompression(string url, SpriteContainer sprite = null)
		{
			UnityWebRequest uwr = new UnityWebRequest(url);
			uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
			yield return uwr.SendWebRequest();
			string name = Path.GetFileNameWithoutExtension(url);
			if ((int)uwr.result != 1 || !uwr.isDone)
			{
				Debug.Log((object)("GetImageUsingUWRBufferAndEnableMipmapsAndCompression: Download failed : name=" + name + ", error=" + uwr.error));
				yield break;
			}
			GraphicsFormat graphicsFormat = (GraphicsFormat)4;
			TextureCreationFlags flags = (TextureCreationFlags)1;
			Texture2D createdTexture = new Texture2D(4, 4, graphicsFormat, flags)
			{
				name = name,
				wrapMode = (TextureWrapMode)1
			};
			if (!ImageConversion.LoadImage(createdTexture, uwr.downloadHandler.data))
			{
				Debug.LogError((object)$"GetImageUsingUWRBufferAndEnableMipmapsAndCompression: LoadImage failed using format={graphicsFormat}");
			}
			if (((Texture)createdTexture).width % 4 == 0 && ((Texture)createdTexture).height % 4 == 0)
			{
				createdTexture.Compress(false);
			}
			Sprite downloadedSprite = Sprite.Create(createdTexture, new Rect(0f, 0f, (float)((Texture)createdTexture).width, (float)((Texture)createdTexture).height), Vector2.zero, 100f, 0u, (SpriteMeshType)0);
			if (sprite != null)
			{
				sprite.sprite = downloadedSprite;
			}
			Debug.Log((object)$"GetImageUsingUWRBufferAndEnableMipmapsAndCompression: name={name}, RawSize={ToSize(createdTexture.GetRawTextureData().Length)}, mipmap={((Texture)createdTexture).mipmapCount}, format={createdTexture.format}, graphicsFormat={((Texture)createdTexture).graphicsFormat}, dimensions={((Texture)createdTexture).width}x{((Texture)createdTexture).height}");
			uwr.Dispose();
		}
	}
	internal class LimitedConcurrencyLevelTaskScheduler : TaskScheduler
	{
		[ThreadStatic]
		private static bool _currentThreadIsProcessingItems;

		private readonly LinkedList<Task> _tasks = new LinkedList<Task>();

		private readonly int _maxDegreeOfParallelism;

		private int _delegatesQueuedOrRunning = 0;

		public sealed override int MaximumConcurrencyLevel => _maxDegreeOfParallelism;

		public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
		{
			if (maxDegreeOfParallelism < 1)
			{
				throw new ArgumentOutOfRangeException("maxDegreeOfParallelism");
			}
			_maxDegreeOfParallelism = maxDegreeOfParallelism;
		}

		protected sealed override void QueueTask(Task task)
		{
			lock (_tasks)
			{
				_tasks.AddLast(task);
				if (_delegatesQueuedOrRunning < _maxDegreeOfParallelism)
				{
					_delegatesQueuedOrRunning++;
					NotifyThreadPoolOfPendingWork();
				}
			}
		}

		private void NotifyThreadPoolOfPendingWork()
		{
			ThreadPool.UnsafeQueueUserWorkItem(delegate
			{
				_currentThreadIsProcessingItems = true;
				try
				{
					while (true)
					{
						Task value;
						lock (_tasks)
						{
							if (_tasks.Count == 0)
							{
								_delegatesQueuedOrRunning--;
								break;
							}
							value = _tasks.First.Value;
							_tasks.RemoveFirst();
						}
						TryExecuteTask(value);
					}
				}
				catch (Exception ex)
				{
					Debug.LogException(ex);
				}
				finally
				{
					_currentThreadIsProcessingItems = false;
				}
			}, null);
		}

		protected sealed override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
		{
			if (!_currentThreadIsProcessingItems)
			{
				return false;
			}
			if (taskWasPreviouslyQueued)
			{
				TryDequeue(task);
			}
			return TryExecuteTask(task);
		}

		protected sealed override bool TryDequeue(Task task)
		{
			lock (_tasks)
			{
				return _tasks.Remove(task);
			}
		}

		protected sealed override IEnumerable<Task> GetScheduledTasks()
		{
			bool lockTaken = false;
			try
			{
				Monitor.TryEnter(_tasks, ref lockTaken);
				if (lockTaken)
				{
					return _tasks.ToArray();
				}
				throw new NotSupportedException();
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
				return null;
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(_tasks);
				}
			}
		}
	}
}
namespace LBoLEntitySideloader
{
	[BepInPlugin("neo.lbol.frameworks.entitySideloader", "Entity Sideloader", "0.9.7404")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource log;

		private static Harmony harmony = PluginInfo.harmony;

		public static ConfigEntry<bool> devModeConfig;

		public static ConfigEntry<bool> devExtraLoggingConfig;

		public static ConfigEntry<KeyboardShortcut> reloadKeyConfig;

		public static ConfigEntry<KeyboardShortcut> hardReloadKeyConfig;

		public static ConfigEntry<bool> autoRestartLevelConfig;

		public static BepinexPlugin instance;

		private static SemaphoreSlim maBoi = new SemaphoreSlim(1);

		internal static int doingMidRunReload = 0;

		private void Awake()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			log = ((BaseUnityPlugin)this).Logger;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			devModeConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("DevMode", "DevMode", false, "Enables mod developer mode for extra functionality and error feedback.");
			devExtraLoggingConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("DevMode", "ExtraLogging", true, "Enables some additional error feedback when devMode is enabled.");
			reloadKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("DevMode", "ReloadKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Reload all entities (requires scriptengine).");
			hardReloadKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("DevMode", "HardReloadKey", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "Hard reload localization and all entities (requires scriptengine).");
			autoRestartLevelConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("DevMode", "AutoRestart", true, "Restart level after reloading all entities.");
			ImageLoader.Init();
			ImageLoader.settings.useDiskCache = false;
			ImageLoader.settings.debugLevel = DebugLevel.Error;
			harmony.PatchAll();
		}

		private void OnDestroy()
		{
			instance = null;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (!devModeConfig.Value)
			{
				return;
			}
			KeyboardShortcut value = reloadKeyConfig.Value;
			if (!((KeyboardShortcut)(ref value)).IsDown())
			{
				value = hardReloadKeyConfig.Value;
				if (!((KeyboardShortcut)(ref value)).IsDown())
				{
					return;
				}
			}
			if (Chainloader.PluginInfos.TryGetValue("com.bepis.bepinex.scriptengine", out var value2))
			{
				Reload(value2, hardReload: true);
			}
			else
			{
				log.LogInfo((object)"scriptengine is required for runtime reload");
			}
		}

		public void Reload(PluginInfo scriptEngineInfo, bool hardReload = false)
		{
			if (!hardReload)
			{
				log.LogInfo((object)"'Soft' reload is not a thing. Use 'hard' reload instead");
				return;
			}
			foreach (UserInfo value in EntityManager.Instance.sideloaderUsers.userInfos.Values)
			{
				EntityManager.Instance.UnregisterUser(value);
			}
			foreach (UserInfo value2 in EntityManager.Instance.secondaryUsers.userInfos.Values)
			{
				EntityManager.Instance.UnregisterUser(value2);
			}
			EntityManager.Instance.sideloaderUsers.userInfos = new Dictionary<Assembly, UserInfo>();
			EntityManager.Instance.secondaryUsers.userInfos = new Dictionary<Assembly, UserInfo>();
			UniqueTracker.DestroySelf();
			CollectionExtensions.Do<Assembly>((IEnumerable<Assembly>)EntityManager.Instance.loadedFromDiskUsers, (Action<Assembly>)delegate(Assembly a)
			{
				EntityManager.RegisterAssembly(a);
			});
			CollectionExtensions.Do<Action>((IEnumerable<Action>)EntityManager.Instance.loadedFromDiskPostAction, (Action<Action>)delegate(Action a)
			{
				UniqueTracker.Instance.PostMainLoad += a;
			});
			UniqueTracker.Instance.formationAddActions.AddRange(EnemyGroupTemplate.loadedFromDiskCustomFormations);
			UniqueTracker.Instance.populateLoadoutInfosActions.AddRange(EntityManager.Instance.loadedFromDiskCharLoadouts);
			UniqueTracker.Instance.modifyStageListFuncs.AddRange(EntityManager.Instance.loadedFromDiskmodifyStageListFuncs);
			UniqueTracker.Instance.modifyStageActions.AddRange(EntityManager.Instance.loadedFromModifyStageActions);
			UniqueTracker.Instance.formationAddActions.AddRange(StageTemplate.loadedFromDiskEnvironments);
			EntityManager.Instance.addBossIconsActions.Clear();
			Extensions.AddRange<SaveDataID, CustomGameRunSaveData>(UniqueTracker.Instance.customGrSaveData, EntityManager.Instance.loadedFromDsikCustomGrSaveData);
			ScriptEngineWrapper.ReloadPlugins(scriptEngineInfo.Instance);
			((MonoBehaviour)this).StartCoroutine(DoubleDelayAction(async delegate
			{
				if (await maBoi.WaitAsync(0))
				{
					try
					{
						ConfigDataManager.Reload();
						if (hardReload)
						{
							EntityManager.Instance.LoadAll(EntityManager.Instance.sideloaderUsers, "All primary Sideloader users registered!", "Finished loading primary user resources", loadLoc: false);
							await L10nManager.ReloadLocalization();
							UniqueTracker.Instance.RaisePostMainLoad();
							EntityManager.Instance.LoadAll(EntityManager.Instance.secondaryUsers, "All secondary Sideloader users registered!", "Finished loading secondary user resources", loadLoc: false);
						}
						else
						{
							EntityManager.Instance.LoadAll(EntityManager.Instance.sideloaderUsers, "All primary Sideloader users registered!", "Finished loading primary user resources");
							UniqueTracker.Instance.RaisePostMainLoad();
							EntityManager.Instance.LoadAll(EntityManager.Instance.secondaryUsers, "All secondary Sideloader users registered!", "Finished loading secondary user resources");
						}
						EntityManager.Instance.addBossIconsActions.Reload();
						EntityManager.Instance.PostAllLoadProcessing();
						CollectionExtensions.Do<Action>((IEnumerable<Action>)UniqueTracker.Instance.populateLoadoutInfosActions, (Action<Action>)delegate(Action a)
						{
							a();
						});
						if (Singleton<GameMaster>.Instance.CurrentGameRun == null)
						{
							UiManager.GetPanel<StartGamePanel>()._jadeBoxToggles.Clear();
							UiManager.GetPanel<StartGamePanel>().InitialForJadeBox();
							EnemyGroupTemplate.ReloadFormations();
							PlayerSpriteLoader.ReloadForMainMenu();
						}
						else
						{
							SpellTemplate.LoadAllSpecialLoc();
						}
						StageTemplate.ReloadEnvs();
						if (autoRestartLevelConfig.Value && Singleton<GameMaster>.Instance.CurrentGameRun != null)
						{
							SettingPanel panel = UiManager.GetPanel<SettingPanel>();
							if (panel != null)
							{
								panel.UI_RestartBattle();
							}
							doingMidRunReload = 1;
						}
					}
					catch (Exception ex2)
					{
						Exception ex = ex2;
						log.LogError((object)ex);
					}
					finally
					{
						maBoi.Release();
					}
				}
			}));
		}

		private IEnumerator DoubleDelayAction(Action action)
		{
			yield return null;
			yield return null;
			action();
		}
	}
	public static class CharNames
	{
		public const string Reimu = "Reimu";

		public const string Marisa = "Marisa";

		public const string Sakuya = "Sakuya";

		public const string Cirno = "Cirno";

		public const string Koishi = "Koishi";
	}
	internal class DeferredActions
	{
		internal Dictionary<IdContainer, Action> actions = new Dictionary<IdContainer, Action>();

		internal Dictionary<IdContainer, Action> reloadableActions = new Dictionary<IdContainer, Action>();

		internal void AddAction(IdContainer id, Action action, Assembly callingAssembly)
		{
			if (callingAssembly.IsLoadedFromDisk())
			{
				actions.AlwaysAdd(id, action);
			}
			else
			{
				reloadableActions.Add(id, action);
			}
		}

		internal void DoAll()
		{
			CollectionExtensions.Do<Action>((IEnumerable<Action>)actions.Values, (Action<Action>)delegate(Action a)
			{
				a();
			});
			CollectionExtensions.Do<Action>((IEnumerable<Action>)reloadableActions.Values, (Action<Action>)delegate(Action a)
			{
				a();
			});
		}

		internal void Clear()
		{
			reloadableActions.Clear();
		}

		internal void Reload()
		{
			CollectionExtensions.Do<Action>((IEnumerable<Action>)reloadableActions.Values, (Action<Action>)delegate(Action a)
			{
				a();
			});
		}
	}
	public static class DictionaryExtensions
	{
		public static bool AlwaysAdd<K, V>(this Dictionary<K, V> dictionary, K key, V value)
		{
			if (!dictionary.TryAdd(key, value))
			{
				dictionary[key] = value;
				return true;
			}
			return false;
		}

		public static bool AlwaysAdd<K, V>(this AssociationList<K, V> associationList, K key, V value)
		{
			if (!((IDictionary<K, V>)associationList).TryAdd(key, value))
			{
				associationList[key] = value;
				return true;
			}
			return false;
		}

		public static bool Merge<K, V>(this Dictionary<K, V> dictionary, Dictionary<K, V> otherDic, bool overwrite = true)
		{
			bool dupes = false;
			otherDic.ToList().ForEach(delegate(KeyValuePair<K, V> x)
			{
				dupes = dictionary.AlwaysAdd(x.Key, x.Value) || dupes;
			});
			return dupes;
		}
	}
	public class EntityManager
	{
		private static EntityManager _instance;

		private static readonly ManualLogSource log = BepinexPlugin.log;

		public HashSet<Assembly> loadedFromDiskUsers = new HashSet<Assembly>();

		public HashSet<Action> loadedFromDiskPostAction = new HashSet<Action>();

		public SideloaderUsers sideloaderUsers = new SideloaderUsers();

		public SideloaderUsers secondaryUsers = new SideloaderUsers();

		public List<Action> loadedFromDiskCharLoadouts = new List<Action>();

		public List<Func<List<Stage>, List<Stage>>> loadedFromDiskmodifyStageListFuncs = new List<Func<List<Stage>, List<Stage>>>();

		public List<UniqueTracker.StageModAction> loadedFromModifyStageActions = new List<UniqueTracker.StageModAction>();

		internal DeferredActions addBossIconsActions = new DeferredActions();

		internal Dictionary<SaveDataID, CustomGameRunSaveData> loadedFromDsikCustomGrSaveData = new Dictionary<SaveDataID, CustomGameRunSaveData>();

		public static EntityManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new EntityManager();
				}
				return _instance;
			}
		}

		public IEnumerable<(Assembly ass, UserInfo userInfo)> AllUsers => from kv in sideloaderUsers.userInfos.Concat(secondaryUsers.userInfos)
			select (kv.Key, kv.Value);

		public static UserInfo ScanAssembly(Assembly assembly, bool lookForFactypes = true)
		{
			UserInfo userInfo = new UserInfo();
			userInfo.assembly = assembly;
			if (!assembly.IsDynamic && BepinexPlugin.devModeConfig.Value && !string.IsNullOrEmpty(assembly.Location))
			{
				Instance.loadedFromDiskUsers.Add(assembly);
			}
			ManualLogSource obj = Log.LogDev();
			if (obj != null)
			{
				obj.LogInfo((object)("Scanning " + assembly.GetName().Name + "..."));
			}
			Type[] array = ((!assembly.IsDynamic) ? assembly.GetExportedTypes() : assembly.GetTypes());
			userInfo.assembly = assembly;
			HashSet<Type> hashSet = new HashSet<Type>();
			Type[] array2 = array;
			foreach (Type type in array2)
			{
				if (!assembly.IsDynamic && type.IsSubclassOf(typeof(BaseUnityPlugin)))
				{
					object[] customAttributes = type.GetCustomAttributes(inherit: false);
					BepInPlugin val = type.SingularAttribute<BepInPlugin>(customAttributes);
					if (val != null)
					{
						userInfo.GUID = val.GUID;
					}
					else
					{
						log.LogError((object)$"{assembly.GetName().Name}: {type} does not have {typeof(BepInPlugin).Name} attribute despite extending {typeof(BaseUnityPlugin).Name}");
					}
					IEnumerable<BepInDependency> enumerable = type.MultiAttribute<BepInDependency>(customAttributes);
					if (enumerable == null || !enumerable.Any((BepInDependency bd) => bd.DependencyGUID == "neo.lbol.frameworks.entitySideloader" && (int)bd.Flags == 1))
					{
						log.LogWarning((object)string.Format("{0}: {1} does not have a {2} attribute with {3} as hard dependency.", assembly.GetName().Name, type, typeof(BepInDependency).Name, "neo.lbol.frameworks.entitySideloader"));
					}
					continue;
				}
				if (type.IsSubclassOf(typeof(EntityDefinition)))
				{
					if (type.IsSealed)
					{
						EntityDefinition entityDefinition = (EntityDefinition)Activator.CreateInstance(type);
						userInfo.definitionInstances.Add(type, entityDefinition);
						entityDefinition.userAssembly = userInfo.assembly;
						entityDefinition.user = userInfo;
						OverwriteVanilla customAttribute = type.GetCustomAttribute<OverwriteVanilla>(inherit: true);
						if (customAttribute != null)
						{
							userInfo.entitiesToOverwrite.Add(type, new ModificationInfo
							{
								attribute = customAttribute
							});
						}
					}
					else if (BepinexPlugin.devModeConfig.Value && !type.IsSealed)
					{
						ManualLogSource obj2 = Log.LogDevExtra();
						if (obj2 != null)
						{
							obj2.LogWarning((object)$"(Extra logging) {assembly.GetName().Name}: {type} is subtype of {typeof(EntityDefinition).Name} but isn't sealed. Final entity templates need to be sealed.");
						}
					}
					continue;
				}
				Type type2 = TypeFactoryReflection.factoryTypes.FirstOrDefault((Type t) => type.IsSubclassOf(t));
				if (!(type2 != null))
				{
					continue;
				}
				if (type.IsSealed)
				{
					userInfo.entityInfos.TryAdd(type2, new List<EntityInfo>());
					EntityLogic customAttribute2 = type.GetCustomAttribute<EntityLogic>();
					if (customAttribute2 != null)
					{
						if (hashSet.Contains(customAttribute2.DefinitionType))
						{
							log.LogError((object)$"{assembly.GetName().Name}: {customAttribute2.DefinitionType} already has an entity logic type associated. Entity can only have one type defining its logic. Please remove {typeof(EntityLogic).Name} attribute.");
						}
						else if (BepinexPlugin.devModeConfig.Value && !TemplatesReflection.IsTemplateType(customAttribute2.DefinitionType))
						{
							log.LogError((object)(customAttribute2.DefinitionType.Name + " type provided to " + typeof(EntityLogic).Name + " attribute on " + type.Name + " is not an " + typeof(EntityDefinition).Name + ". Entity definition must extend one of the entity templates."));
						}
						else
						{
							hashSet.Add(customAttribute2.DefinitionType);
							EntityInfo entityInfo = new EntityInfo(type2, type, customAttribute2.DefinitionType);
							userInfo.entityInfos[type2].Add(entityInfo);
							userInfo.definition2customEntityLogicType.Add(customAttribute2.DefinitionType, entityInfo.entityType);
						}
						continue;
					}
					ExternalEntityLogicAttribute customAttribute3 = type.GetCustomAttribute<ExternalEntityLogicAttribute>();
					if (customAttribute3 == null)
					{
						ManualLogSource obj3 = Log.LogDevExtra();
						if (obj3 != null)
						{
							obj3.LogWarning((object)("(Extra logging) " + assembly.GetName().Name + ": " + type.Name + " does not have " + typeof(EntityLogic).Name + " attribute despite having qualities of an entity logic type. Please add " + typeof(EntityLogic).Name + " attribute."));
						}
					}
				}
				else if (BepinexPlugin.devModeConfig.Value && !type.IsSealed)
				{
					ManualLogSource obj4 = Log.LogDevExtra();
					if (obj4 != null)
					{
						obj4.LogWarning((object)$"(Extra logging) {assembly.GetName().Name}: {type} is subtype of {type2.Name} but isn't sealed. Final entity logic types need to be sealed");
					}
				}
			}
			if (BepinexPlugin.devModeConfig.Value && BepinexPlugin.devExtraLoggingConfig.Value && !assembly.IsDynamic)
			{
				foreach (Type item in hashSet)
				{
					if (userInfo.definition2customEntityLogicType.TryGetValue(item, out var value) && userInfo.definitionInstances.TryGetValue(item, out var value2) && !value.IsSubclassOf(value2.EntityType()))
					{
						throw new InvalidProgramException($"(Extra Logging) {item.Name} expects its entity logic type, {value.Name}, to extend {value2.EntityType()}. Instead {value.Name} extends {value.BaseType} ");
					}
				}
				foreach (KeyValuePair<Type, EntityDefinition> definitionInstance in userInfo.definitionInstances)
				{
					Type key = definitionInstance.Key;
					EntityDefinition value3 = definitionInstance.Value;
					if (!userInfo.IsForOverwriting(key) && TemplatesReflection.ExpectsEntityLogic(key) && !hashSet.Contains(key))
					{
						log.LogWarning((o

mcs.dll

Decompiled 2 days ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.SymbolStore;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using Mono.CSharp.IL2CPP;
using Mono.CSharp.Linq;
using Mono.CSharp.Nullable;
using Mono.CSharp.yyParser;
using Mono.CSharp.yydebug;
using Mono.CompilerServices.SymbolWriter;
using MonoMod.RuntimeDetour;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("mcs")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("mcs")]
[assembly: AssemblyCopyright("Copyright ©  2018")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e4989e4c-0875-4528-9031-08e2c0e70103")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Mono.CompilerServices.SymbolWriter
{
	public class MonoSymbolFileException : Exception
	{
		public MonoSymbolFileException()
		{
		}

		public MonoSymbolFileException(string message, params object[] args)
			: base(string.Format(message, args))
		{
		}

		public MonoSymbolFileException(string message, Exception innerException)
			: base(message, innerException)
		{
		}
	}
	internal sealed class MyBinaryWriter : BinaryWriter
	{
		public MyBinaryWriter(Stream stream)
			: base(stream)
		{
		}

		public void WriteLeb128(int value)
		{
			Write7BitEncodedInt(value);
		}
	}
	internal class MyBinaryReader : BinaryReader
	{
		public MyBinaryReader(Stream stream)
			: base(stream)
		{
		}

		public int ReadLeb128()
		{
			return Read7BitEncodedInt();
		}

		public string ReadString(int offset)
		{
			long position = BaseStream.Position;
			BaseStream.Position = offset;
			string result = ReadString();
			BaseStream.Position = position;
			return result;
		}
	}
	public interface ISourceFile
	{
		SourceFileEntry Entry { get; }
	}
	public interface ICompileUnit
	{
		CompileUnitEntry Entry { get; }
	}
	public interface IMethodDef
	{
		string Name { get; }

		int Token { get; }
	}
	public class MonoSymbolFile : IDisposable
	{
		private List<MethodEntry> methods = new List<MethodEntry>();

		private List<SourceFileEntry> sources = new List<SourceFileEntry>();

		private List<CompileUnitEntry> comp_units = new List<CompileUnitEntry>();

		private Dictionary<int, AnonymousScopeEntry> anonymous_scopes;

		private OffsetTable ot;

		private int last_type_index;

		private int last_method_index;

		private int last_namespace_index;

		public readonly int MajorVersion = 50;

		public readonly int MinorVersion = 0;

		public int NumLineNumbers;

		private MyBinaryReader reader;

		private Dictionary<int, SourceFileEntry> source_file_hash;

		private Dictionary<int, CompileUnitEntry> compile_unit_hash;

		private List<MethodEntry> method_list;

		private Dictionary<int, MethodEntry> method_token_hash;

		private Dictionary<string, int> source_name_hash;

		private Guid guid;

		internal int LineNumberCount = 0;

		internal int LocalCount = 0;

		internal int StringSize = 0;

		internal int LineNumberSize = 0;

		internal int ExtendedLineNumberSize = 0;

		public int CompileUnitCount => ot.CompileUnitCount;

		public int SourceCount => ot.SourceCount;

		public int MethodCount => ot.MethodCount;

		public int TypeCount => ot.TypeCount;

		public int AnonymousScopeCount => ot.AnonymousScopeCount;

		public int NamespaceCount => last_namespace_index;

		public Guid Guid => guid;

		public OffsetTable OffsetTable => ot;

		public SourceFileEntry[] Sources
		{
			get
			{
				if (reader == null)
				{
					throw new InvalidOperationException();
				}
				SourceFileEntry[] array = new SourceFileEntry[SourceCount];
				for (int i = 0; i < SourceCount; i++)
				{
					array[i] = GetSourceFile(i + 1);
				}
				return array;
			}
		}

		public CompileUnitEntry[] CompileUnits
		{
			get
			{
				if (reader == null)
				{
					throw new InvalidOperationException();
				}
				CompileUnitEntry[] array = new CompileUnitEntry[CompileUnitCount];
				for (int i = 0; i < CompileUnitCount; i++)
				{
					array[i] = GetCompileUnit(i + 1);
				}
				return array;
			}
		}

		public MethodEntry[] Methods
		{
			get
			{
				if (reader == null)
				{
					throw new InvalidOperationException();
				}
				lock (this)
				{
					read_methods();
					MethodEntry[] array = new MethodEntry[MethodCount];
					method_list.CopyTo(array, 0);
					return array;
				}
			}
		}

		internal MyBinaryReader BinaryReader
		{
			get
			{
				if (reader == null)
				{
					throw new InvalidOperationException();
				}
				return reader;
			}
		}

		public MonoSymbolFile()
		{
			ot = new OffsetTable();
		}

		public int AddSource(SourceFileEntry source)
		{
			sources.Add(source);
			return sources.Count;
		}

		public int AddCompileUnit(CompileUnitEntry entry)
		{
			comp_units.Add(entry);
			return comp_units.Count;
		}

		public void AddMethod(MethodEntry entry)
		{
			methods.Add(entry);
		}

		public MethodEntry DefineMethod(CompileUnitEntry comp_unit, int token, ScopeVariable[] scope_vars, LocalVariableEntry[] locals, LineNumberEntry[] lines, CodeBlockEntry[] code_blocks, string real_name, MethodEntry.Flags flags, int namespace_id)
		{
			if (reader != null)
			{
				throw new InvalidOperationException();
			}
			MethodEntry methodEntry = new MethodEntry(this, comp_unit, token, scope_vars, locals, lines, code_blocks, real_name, flags, namespace_id);
			AddMethod(methodEntry);
			return methodEntry;
		}

		internal void DefineAnonymousScope(int id)
		{
			if (reader != null)
			{
				throw new InvalidOperationException();
			}
			if (anonymous_scopes == null)
			{
				anonymous_scopes = new Dictionary<int, AnonymousScopeEntry>();
			}
			anonymous_scopes.Add(id, new AnonymousScopeEntry(id));
		}

		internal void DefineCapturedVariable(int scope_id, string name, string captured_name, CapturedVariable.CapturedKind kind)
		{
			if (reader != null)
			{
				throw new InvalidOperationException();
			}
			AnonymousScopeEntry anonymousScopeEntry = anonymous_scopes[scope_id];
			anonymousScopeEntry.AddCapturedVariable(name, captured_name, kind);
		}

		internal void DefineCapturedScope(int scope_id, int id, string captured_name)
		{
			if (reader != null)
			{
				throw new InvalidOperationException();
			}
			AnonymousScopeEntry anonymousScopeEntry = anonymous_scopes[scope_id];
			anonymousScopeEntry.AddCapturedScope(id, captured_name);
		}

		internal int GetNextTypeIndex()
		{
			return ++last_type_index;
		}

		internal int GetNextMethodIndex()
		{
			return ++last_method_index;
		}

		internal int GetNextNamespaceIndex()
		{
			return ++last_namespace_index;
		}

		private void Write(MyBinaryWriter bw, Guid guid)
		{
			bw.Write(5037318119232611860L);
			bw.Write(MajorVersion);
			bw.Write(MinorVersion);
			bw.Write(guid.ToByteArray());
			long position = bw.BaseStream.Position;
			ot.Write(bw, MajorVersion, MinorVersion);
			methods.Sort();
			for (int i = 0; i < methods.Count; i++)
			{
				methods[i].Index = i + 1;
			}
			ot.DataSectionOffset = (int)bw.BaseStream.Position;
			foreach (SourceFileEntry source in sources)
			{
				source.WriteData(bw);
			}
			foreach (CompileUnitEntry comp_unit in comp_units)
			{
				comp_unit.WriteData(bw);
			}
			foreach (MethodEntry method in methods)
			{
				method.WriteData(this, bw);
			}
			ot.DataSectionSize = (int)bw.BaseStream.Position - ot.DataSectionOffset;
			ot.MethodTableOffset = (int)bw.BaseStream.Position;
			for (int j = 0; j < methods.Count; j++)
			{
				MethodEntry methodEntry = methods[j];
				methodEntry.Write(bw);
			}
			ot.MethodTableSize = (int)bw.BaseStream.Position - ot.MethodTableOffset;
			ot.SourceTableOffset = (int)bw.BaseStream.Position;
			for (int k = 0; k < sources.Count; k++)
			{
				SourceFileEntry sourceFileEntry = sources[k];
				sourceFileEntry.Write(bw);
			}
			ot.SourceTableSize = (int)bw.BaseStream.Position - ot.SourceTableOffset;
			ot.CompileUnitTableOffset = (int)bw.BaseStream.Position;
			for (int l = 0; l < comp_units.Count; l++)
			{
				CompileUnitEntry compileUnitEntry = comp_units[l];
				compileUnitEntry.Write(bw);
			}
			ot.CompileUnitTableSize = (int)bw.BaseStream.Position - ot.CompileUnitTableOffset;
			ot.AnonymousScopeCount = ((anonymous_scopes != null) ? anonymous_scopes.Count : 0);
			ot.AnonymousScopeTableOffset = (int)bw.BaseStream.Position;
			if (anonymous_scopes != null)
			{
				foreach (AnonymousScopeEntry value in anonymous_scopes.Values)
				{
					value.Write(bw);
				}
			}
			ot.AnonymousScopeTableSize = (int)bw.BaseStream.Position - ot.AnonymousScopeTableOffset;
			ot.TypeCount = last_type_index;
			ot.MethodCount = methods.Count;
			ot.SourceCount = sources.Count;
			ot.CompileUnitCount = comp_units.Count;
			ot.TotalFileSize = (int)bw.BaseStream.Position;
			bw.Seek((int)position, SeekOrigin.Begin);
			ot.Write(bw, MajorVersion, MinorVersion);
			bw.Seek(0, SeekOrigin.End);
		}

		public void CreateSymbolFile(Guid guid, FileStream fs)
		{
			if (reader != null)
			{
				throw new InvalidOperationException();
			}
			Write(new MyBinaryWriter(fs), guid);
		}

		private MonoSymbolFile(Stream stream)
		{
			reader = new MyBinaryReader(stream);
			try
			{
				long num = reader.ReadInt64();
				int num2 = reader.ReadInt32();
				int num3 = reader.ReadInt32();
				if (num != 5037318119232611860L)
				{
					throw new MonoSymbolFileException("Symbol file is not a valid");
				}
				if (num2 != 50)
				{
					throw new MonoSymbolFileException("Symbol file has version {0} but expected {1}", num2, 50);
				}
				if (num3 != 0)
				{
					throw new MonoSymbolFileException("Symbol file has version {0}.{1} but expected {2}.{3}", num2, num3, 50, 0);
				}
				MajorVersion = num2;
				MinorVersion = num3;
				guid = new Guid(reader.ReadBytes(16));
				ot = new OffsetTable(reader, num2, num3);
			}
			catch (Exception innerException)
			{
				throw new MonoSymbolFileException("Cannot read symbol file", innerException);
			}
			source_file_hash = new Dictionary<int, SourceFileEntry>();
			compile_unit_hash = new Dictionary<int, CompileUnitEntry>();
		}

		public static MonoSymbolFile ReadSymbolFile(Assembly assembly)
		{
			string location = assembly.Location;
			string mdbFilename = location + ".mdb";
			Module[] modules = assembly.GetModules();
			Guid moduleVersionId = modules[0].ModuleVersionId;
			return ReadSymbolFile(mdbFilename, moduleVersionId);
		}

		public static MonoSymbolFile ReadSymbolFile(string mdbFilename)
		{
			return ReadSymbolFile(new FileStream(mdbFilename, FileMode.Open, FileAccess.Read));
		}

		public static MonoSymbolFile ReadSymbolFile(string mdbFilename, Guid assemblyGuid)
		{
			MonoSymbolFile monoSymbolFile = ReadSymbolFile(mdbFilename);
			if (assemblyGuid != monoSymbolFile.guid)
			{
				throw new MonoSymbolFileException("Symbol file `{0}' does not match assembly", mdbFilename);
			}
			return monoSymbolFile;
		}

		public static MonoSymbolFile ReadSymbolFile(Stream stream)
		{
			return new MonoSymbolFile(stream);
		}

		public SourceFileEntry GetSourceFile(int index)
		{
			if (index < 1 || index > ot.SourceCount)
			{
				throw new ArgumentException();
			}
			if (reader == null)
			{
				throw new InvalidOperationException();
			}
			lock (this)
			{
				if (source_file_hash.TryGetValue(index, out var value))
				{
					return value;
				}
				long position = reader.BaseStream.Position;
				reader.BaseStream.Position = ot.SourceTableOffset + SourceFileEntry.Size * (index - 1);
				value = new SourceFileEntry(this, reader);
				source_file_hash.Add(index, value);
				reader.BaseStream.Position = position;
				return value;
			}
		}

		public CompileUnitEntry GetCompileUnit(int index)
		{
			if (index < 1 || index > ot.CompileUnitCount)
			{
				throw new ArgumentException();
			}
			if (reader == null)
			{
				throw new InvalidOperationException();
			}
			lock (this)
			{
				if (compile_unit_hash.TryGetValue(index, out var value))
				{
					return value;
				}
				long position = reader.BaseStream.Position;
				reader.BaseStream.Position = ot.CompileUnitTableOffset + CompileUnitEntry.Size * (index - 1);
				value = new CompileUnitEntry(this, reader);
				compile_unit_hash.Add(index, value);
				reader.BaseStream.Position = position;
				return value;
			}
		}

		private void read_methods()
		{
			lock (this)
			{
				if (method_token_hash == null)
				{
					method_token_hash = new Dictionary<int, MethodEntry>();
					method_list = new List<MethodEntry>();
					long position = reader.BaseStream.Position;
					reader.BaseStream.Position = ot.MethodTableOffset;
					for (int i = 0; i < MethodCount; i++)
					{
						MethodEntry methodEntry = new MethodEntry(this, reader, i + 1);
						method_token_hash.Add(methodEntry.Token, methodEntry);
						method_list.Add(methodEntry);
					}
					reader.BaseStream.Position = position;
				}
			}
		}

		public MethodEntry GetMethodByToken(int token)
		{
			if (reader == null)
			{
				throw new InvalidOperationException();
			}
			lock (this)
			{
				read_methods();
				method_token_hash.TryGetValue(token, out var value);
				return value;
			}
		}

		public MethodEntry GetMethod(int index)
		{
			if (index < 1 || index > ot.MethodCount)
			{
				throw new ArgumentException();
			}
			if (reader == null)
			{
				throw new InvalidOperationException();
			}
			lock (this)
			{
				read_methods();
				return method_list[index - 1];
			}
		}

		public int FindSource(string file_name)
		{
			if (reader == null)
			{
				throw new InvalidOperationException();
			}
			lock (this)
			{
				if (source_name_hash == null)
				{
					source_name_hash = new Dictionary<string, int>();
					for (int i = 0; i < ot.SourceCount; i++)
					{
						SourceFileEntry sourceFile = GetSourceFile(i + 1);
						source_name_hash.Add(sourceFile.FileName, i);
					}
				}
				if (!source_name_hash.TryGetValue(file_name, out var value))
				{
					return -1;
				}
				return value;
			}
		}

		public AnonymousScopeEntry GetAnonymousScope(int id)
		{
			if (reader == null)
			{
				throw new InvalidOperationException();
			}
			lock (this)
			{
				if (anonymous_scopes != null)
				{
					anonymous_scopes.TryGetValue(id, out var value);
					return value;
				}
				anonymous_scopes = new Dictionary<int, AnonymousScopeEntry>();
				reader.BaseStream.Position = ot.AnonymousScopeTableOffset;
				for (int i = 0; i < ot.AnonymousScopeCount; i++)
				{
					AnonymousScopeEntry value = new AnonymousScopeEntry(reader);
					anonymous_scopes.Add(value.ID, value);
				}
				return anonymous_scopes[id];
			}
		}

		public void Dispose()
		{
			Dispose(disposing: true);
		}

		protected virtual void Dispose(bool disposing)
		{
			if (disposing && reader != null)
			{
				reader.Close();
				reader = null;
			}
		}
	}
	public class OffsetTable
	{
		[Flags]
		public enum Flags
		{
			IsAspxSource = 1,
			WindowsFileNames = 2
		}

		public const int MajorVersion = 50;

		public const int MinorVersion = 0;

		public const long Magic = 5037318119232611860L;

		public int TotalFileSize;

		public int DataSectionOffset;

		public int DataSectionSize;

		public int CompileUnitCount;

		public int CompileUnitTableOffset;

		public int CompileUnitTableSize;

		public int SourceCount;

		public int SourceTableOffset;

		public int SourceTableSize;

		public int MethodCount;

		public int MethodTableOffset;

		public int MethodTableSize;

		public int TypeCount;

		public int AnonymousScopeCount;

		public int AnonymousScopeTableOffset;

		public int AnonymousScopeTableSize;

		public Flags FileFlags;

		public int LineNumberTable_LineBase = -1;

		public int LineNumberTable_LineRange = 8;

		public int LineNumberTable_OpcodeBase = 9;

		internal OffsetTable()
		{
			int platform = (int)Environment.OSVersion.Platform;
			if (platform != 4 && platform != 128)
			{
				FileFlags |= Flags.WindowsFileNames;
			}
		}

		internal OffsetTable(BinaryReader reader, int major_version, int minor_version)
		{
			TotalFileSize = reader.ReadInt32();
			DataSectionOffset = reader.ReadInt32();
			DataSectionSize = reader.ReadInt32();
			CompileUnitCount = reader.ReadInt32();
			CompileUnitTableOffset = reader.ReadInt32();
			CompileUnitTableSize = reader.ReadInt32();
			SourceCount = reader.ReadInt32();
			SourceTableOffset = reader.ReadInt32();
			SourceTableSize = reader.ReadInt32();
			MethodCount = reader.ReadInt32();
			MethodTableOffset = reader.ReadInt32();
			MethodTableSize = reader.ReadInt32();
			TypeCount = reader.ReadInt32();
			AnonymousScopeCount = reader.ReadInt32();
			AnonymousScopeTableOffset = reader.ReadInt32();
			AnonymousScopeTableSize = reader.ReadInt32();
			LineNumberTable_LineBase = reader.ReadInt32();
			LineNumberTable_LineRange = reader.ReadInt32();
			LineNumberTable_OpcodeBase = reader.ReadInt32();
			FileFlags = (Flags)reader.ReadInt32();
		}

		internal void Write(BinaryWriter bw, int major_version, int minor_version)
		{
			bw.Write(TotalFileSize);
			bw.Write(DataSectionOffset);
			bw.Write(DataSectionSize);
			bw.Write(CompileUnitCount);
			bw.Write(CompileUnitTableOffset);
			bw.Write(CompileUnitTableSize);
			bw.Write(SourceCount);
			bw.Write(SourceTableOffset);
			bw.Write(SourceTableSize);
			bw.Write(MethodCount);
			bw.Write(MethodTableOffset);
			bw.Write(MethodTableSize);
			bw.Write(TypeCount);
			bw.Write(AnonymousScopeCount);
			bw.Write(AnonymousScopeTableOffset);
			bw.Write(AnonymousScopeTableSize);
			bw.Write(LineNumberTable_LineBase);
			bw.Write(LineNumberTable_LineRange);
			bw.Write(LineNumberTable_OpcodeBase);
			bw.Write((int)FileFlags);
		}

		public override string ToString()
		{
			return $"OffsetTable [{TotalFileSize} - {DataSectionOffset}:{DataSectionSize} - {SourceCount}:{SourceTableOffset}:{SourceTableSize} - {MethodCount}:{MethodTableOffset}:{MethodTableSize} - {TypeCount}]";
		}
	}
	public class LineNumberEntry
	{
		public sealed class LocationComparer : IComparer<LineNumberEntry>
		{
			public static readonly LocationComparer Default = new LocationComparer();

			public int Compare(LineNumberEntry l1, LineNumberEntry l2)
			{
				int result;
				if (l1.Row != l2.Row)
				{
					int row = l1.Row;
					result = row.CompareTo(l2.Row);
				}
				else
				{
					result = l1.Column.CompareTo(l2.Column);
				}
				return result;
			}
		}

		public readonly int Row;

		public int Column;

		public int EndRow;

		public int EndColumn;

		public readonly int File;

		public readonly int Offset;

		public readonly bool IsHidden;

		public static readonly LineNumberEntry Null = new LineNumberEntry(0, 0, 0, 0);

		public LineNumberEntry(int file, int row, int column, int offset)
			: this(file, row, column, offset, is_hidden: false)
		{
		}

		public LineNumberEntry(int file, int row, int offset)
			: this(file, row, -1, offset, is_hidden: false)
		{
		}

		public LineNumberEntry(int file, int row, int column, int offset, bool is_hidden)
			: this(file, row, column, -1, -1, offset, is_hidden)
		{
		}

		public LineNumberEntry(int file, int row, int column, int end_row, int end_column, int offset, bool is_hidden)
		{
			File = file;
			Row = row;
			Column = column;
			EndRow = end_row;
			EndColumn = end_column;
			Offset = offset;
			IsHidden = is_hidden;
		}

		public override string ToString()
		{
			return string.Format("[Line {0}:{1,2}-{3,4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset);
		}
	}
	public class CodeBlockEntry
	{
		public enum Type
		{
			Lexical = 1,
			CompilerGenerated,
			IteratorBody,
			IteratorDispatcher
		}

		public int Index;

		public int Parent;

		public Type BlockType;

		public int StartOffset;

		public int EndOffset;

		public CodeBlockEntry(int index, int parent, Type type, int start_offset)
		{
			Index = index;
			Parent = parent;
			BlockType = type;
			StartOffset = start_offset;
		}

		internal CodeBlockEntry(int index, MyBinaryReader reader)
		{
			Index = index;
			int num = reader.ReadLeb128();
			BlockType = (Type)(num & 0x3F);
			Parent = reader.ReadLeb128();
			StartOffset = reader.ReadLeb128();
			EndOffset = reader.ReadLeb128();
			if (((uint)num & 0x40u) != 0)
			{
				int num2 = reader.ReadInt16();
				reader.BaseStream.Position += num2;
			}
		}

		public void Close(int end_offset)
		{
			EndOffset = end_offset;
		}

		internal void Write(MyBinaryWriter bw)
		{
			bw.WriteLeb128((int)BlockType);
			bw.WriteLeb128(Parent);
			bw.WriteLeb128(StartOffset);
			bw.WriteLeb128(EndOffset);
		}

		public override string ToString()
		{
			return $"[CodeBlock {Index}:{Parent}:{BlockType}:{StartOffset}:{EndOffset}]";
		}
	}
	public struct LocalVariableEntry
	{
		public readonly int Index;

		public readonly string Name;

		public readonly int BlockIndex;

		public LocalVariableEntry(int index, string name, int block)
		{
			Index = index;
			Name = name;
			BlockIndex = block;
		}

		internal LocalVariableEntry(MonoSymbolFile file, MyBinaryReader reader)
		{
			Index = reader.ReadLeb128();
			Name = reader.ReadString();
			BlockIndex = reader.ReadLeb128();
		}

		internal void Write(MonoSymbolFile file, MyBinaryWriter bw)
		{
			bw.WriteLeb128(Index);
			bw.Write(Name);
			bw.WriteLeb128(BlockIndex);
		}

		public override string ToString()
		{
			return $"[LocalVariable {Name}:{Index}:{BlockIndex - 1}]";
		}
	}
	public struct CapturedVariable
	{
		public enum CapturedKind : byte
		{
			Local,
			Parameter,
			This
		}

		public readonly string Name;

		public readonly string CapturedName;

		public readonly CapturedKind Kind;

		public CapturedVariable(string name, string captured_name, CapturedKind kind)
		{
			Name = name;
			CapturedName = captured_name;
			Kind = kind;
		}

		internal CapturedVariable(MyBinaryReader reader)
		{
			Name = reader.ReadString();
			CapturedName = reader.ReadString();
			Kind = (CapturedKind)reader.ReadByte();
		}

		internal void Write(MyBinaryWriter bw)
		{
			bw.Write(Name);
			bw.Write(CapturedName);
			bw.Write((byte)Kind);
		}

		public override string ToString()
		{
			return $"[CapturedVariable {Name}:{CapturedName}:{Kind}]";
		}
	}
	public struct CapturedScope
	{
		public readonly int Scope;

		public readonly string CapturedName;

		public CapturedScope(int scope, string captured_name)
		{
			Scope = scope;
			CapturedName = captured_name;
		}

		internal CapturedScope(MyBinaryReader reader)
		{
			Scope = reader.ReadLeb128();
			CapturedName = reader.ReadString();
		}

		internal void Write(MyBinaryWriter bw)
		{
			bw.WriteLeb128(Scope);
			bw.Write(CapturedName);
		}

		public override string ToString()
		{
			return $"[CapturedScope {Scope}:{CapturedName}]";
		}
	}
	public struct ScopeVariable
	{
		public readonly int Scope;

		public readonly int Index;

		public ScopeVariable(int scope, int index)
		{
			Scope = scope;
			Index = index;
		}

		internal ScopeVariable(MyBinaryReader reader)
		{
			Scope = reader.ReadLeb128();
			Index = reader.ReadLeb128();
		}

		internal void Write(MyBinaryWriter bw)
		{
			bw.WriteLeb128(Scope);
			bw.WriteLeb128(Index);
		}

		public override string ToString()
		{
			return $"[ScopeVariable {Scope}:{Index}]";
		}
	}
	public class AnonymousScopeEntry
	{
		public readonly int ID;

		private List<CapturedVariable> captured_vars = new List<CapturedVariable>();

		private List<CapturedScope> captured_scopes = new List<CapturedScope>();

		public CapturedVariable[] CapturedVariables
		{
			get
			{
				CapturedVariable[] array = new CapturedVariable[captured_vars.Count];
				captured_vars.CopyTo(array, 0);
				return array;
			}
		}

		public CapturedScope[] CapturedScopes
		{
			get
			{
				CapturedScope[] array = new CapturedScope[captured_scopes.Count];
				captured_scopes.CopyTo(array, 0);
				return array;
			}
		}

		public AnonymousScopeEntry(int id)
		{
			ID = id;
		}

		internal AnonymousScopeEntry(MyBinaryReader reader)
		{
			ID = reader.ReadLeb128();
			int num = reader.ReadLeb128();
			for (int i = 0; i < num; i++)
			{
				captured_vars.Add(new CapturedVariable(reader));
			}
			int num2 = reader.ReadLeb128();
			for (int j = 0; j < num2; j++)
			{
				captured_scopes.Add(new CapturedScope(reader));
			}
		}

		internal void AddCapturedVariable(string name, string captured_name, CapturedVariable.CapturedKind kind)
		{
			captured_vars.Add(new CapturedVariable(name, captured_name, kind));
		}

		internal void AddCapturedScope(int scope, string captured_name)
		{
			captured_scopes.Add(new CapturedScope(scope, captured_name));
		}

		internal void Write(MyBinaryWriter bw)
		{
			bw.WriteLeb128(ID);
			bw.WriteLeb128(captured_vars.Count);
			foreach (CapturedVariable captured_var in captured_vars)
			{
				captured_var.Write(bw);
			}
			bw.WriteLeb128(captured_scopes.Count);
			foreach (CapturedScope captured_scope in captured_scopes)
			{
				captured_scope.Write(bw);
			}
		}

		public override string ToString()
		{
			return $"[AnonymousScope {ID}]";
		}
	}
	public class CompileUnitEntry : ICompileUnit
	{
		public readonly int Index;

		private int DataOffset;

		private MonoSymbolFile file;

		private SourceFileEntry source;

		private List<SourceFileEntry> include_files;

		private List<NamespaceEntry> namespaces;

		private bool creating;

		public static int Size => 8;

		CompileUnitEntry ICompileUnit.Entry => this;

		public SourceFileEntry SourceFile
		{
			get
			{
				if (creating)
				{
					return source;
				}
				ReadData();
				return source;
			}
		}

		public NamespaceEntry[] Namespaces
		{
			get
			{
				ReadData();
				NamespaceEntry[] array = new NamespaceEntry[namespaces.Count];
				namespaces.CopyTo(array, 0);
				return array;
			}
		}

		public SourceFileEntry[] IncludeFiles
		{
			get
			{
				ReadData();
				if (include_files == null)
				{
					return new SourceFileEntry[0];
				}
				SourceFileEntry[] array = new SourceFileEntry[include_files.Count];
				include_files.CopyTo(array, 0);
				return array;
			}
		}

		public CompileUnitEntry(MonoSymbolFile file, SourceFileEntry source)
		{
			this.file = file;
			this.source = source;
			Index = file.AddCompileUnit(this);
			creating = true;
			namespaces = new List<NamespaceEntry>();
		}

		public void AddFile(SourceFileEntry file)
		{
			if (!creating)
			{
				throw new InvalidOperationException();
			}
			if (include_files == null)
			{
				include_files = new List<SourceFileEntry>();
			}
			include_files.Add(file);
		}

		public int DefineNamespace(string name, string[] using_clauses, int parent)
		{
			if (!creating)
			{
				throw new InvalidOperationException();
			}
			int nextNamespaceIndex = file.GetNextNamespaceIndex();
			NamespaceEntry item = new NamespaceEntry(name, nextNamespaceIndex, using_clauses, parent);
			namespaces.Add(item);
			return nextNamespaceIndex;
		}

		internal void WriteData(MyBinaryWriter bw)
		{
			DataOffset = (int)bw.BaseStream.Position;
			bw.WriteLeb128(source.Index);
			int value = ((include_files != null) ? include_files.Count : 0);
			bw.WriteLeb128(value);
			if (include_files != null)
			{
				foreach (SourceFileEntry include_file in include_files)
				{
					bw.WriteLeb128(include_file.Index);
				}
			}
			bw.WriteLeb128(namespaces.Count);
			foreach (NamespaceEntry @namespace in namespaces)
			{
				@namespace.Write(file, bw);
			}
		}

		internal void Write(BinaryWriter bw)
		{
			bw.Write(Index);
			bw.Write(DataOffset);
		}

		internal CompileUnitEntry(MonoSymbolFile file, MyBinaryReader reader)
		{
			this.file = file;
			Index = reader.ReadInt32();
			DataOffset = reader.ReadInt32();
		}

		public void ReadAll()
		{
			ReadData();
		}

		private void ReadData()
		{
			if (creating)
			{
				throw new InvalidOperationException();
			}
			lock (file)
			{
				if (namespaces != null)
				{
					return;
				}
				MyBinaryReader binaryReader = file.BinaryReader;
				int num = (int)binaryReader.BaseStream.Position;
				binaryReader.BaseStream.Position = DataOffset;
				int index = binaryReader.ReadLeb128();
				source = file.GetSourceFile(index);
				int num2 = binaryReader.ReadLeb128();
				if (num2 > 0)
				{
					include_files = new List<SourceFileEntry>();
					for (int i = 0; i < num2; i++)
					{
						include_files.Add(file.GetSourceFile(binaryReader.ReadLeb128()));
					}
				}
				int num3 = binaryReader.ReadLeb128();
				namespaces = new List<NamespaceEntry>();
				for (int j = 0; j < num3; j++)
				{
					namespaces.Add(new NamespaceEntry(file, binaryReader));
				}
				binaryReader.BaseStream.Position = num;
			}
		}
	}
	public class SourceFileEntry
	{
		public readonly int Index;

		private int DataOffset;

		private MonoSymbolFile file;

		private string file_name;

		private byte[] guid;

		private byte[] hash;

		private bool creating;

		private bool auto_generated;

		private readonly string sourceFile;

		public static int Size => 8;

		public byte[] Checksum => hash;

		public string FileName
		{
			get
			{
				return file_name;
			}
			set
			{
				file_name = value;
			}
		}

		public bool AutoGenerated => auto_generated;

		public SourceFileEntry(MonoSymbolFile file, string file_name)
		{
			this.file = file;
			this.file_name = file_name;
			Index = file.AddSource(this);
			creating = true;
		}

		public SourceFileEntry(MonoSymbolFile file, string sourceFile, byte[] guid, byte[] checksum)
			: this(file, sourceFile, sourceFile, guid, checksum)
		{
		}

		public SourceFileEntry(MonoSymbolFile file, string fileName, string sourceFile, byte[] guid, byte[] checksum)
			: this(file, fileName)
		{
			this.guid = guid;
			hash = checksum;
			this.sourceFile = sourceFile;
		}

		internal void WriteData(MyBinaryWriter bw)
		{
			DataOffset = (int)bw.BaseStream.Position;
			bw.Write(file_name);
			if (guid == null)
			{
				guid = new byte[16];
			}
			if (hash == null)
			{
				try
				{
					using FileStream inputStream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read);
					MD5 mD = MD5.Create();
					hash = mD.ComputeHash(inputStream);
				}
				catch
				{
					hash = new byte[16];
				}
			}
			bw.Write(guid);
			bw.Write(hash);
			bw.Write((byte)(auto_generated ? 1u : 0u));
		}

		internal void Write(BinaryWriter bw)
		{
			bw.Write(Index);
			bw.Write(DataOffset);
		}

		internal SourceFileEntry(MonoSymbolFile file, MyBinaryReader reader)
		{
			this.file = file;
			Index = reader.ReadInt32();
			DataOffset = reader.ReadInt32();
			int num = (int)reader.BaseStream.Position;
			reader.BaseStream.Position = DataOffset;
			sourceFile = (file_name = reader.ReadString());
			guid = reader.ReadBytes(16);
			hash = reader.ReadBytes(16);
			auto_generated = reader.ReadByte() == 1;
			reader.BaseStream.Position = num;
		}

		public void SetAutoGenerated()
		{
			if (!creating)
			{
				throw new InvalidOperationException();
			}
			auto_generated = true;
			file.OffsetTable.FileFlags |= OffsetTable.Flags.IsAspxSource;
		}

		public bool CheckChecksum()
		{
			try
			{
				using FileStream inputStream = new FileStream(sourceFile, FileMode.Open);
				MD5 mD = MD5.Create();
				byte[] array = mD.ComputeHash(inputStream);
				for (int i = 0; i < 16; i++)
				{
					if (array[i] != hash[i])
					{
						return false;
					}
				}
				return true;
			}
			catch
			{
				return false;
			}
		}

		public override string ToString()
		{
			return $"SourceFileEntry ({Index}:{DataOffset})";
		}
	}
	public class LineNumberTable
	{
		protected LineNumberEntry[] _line_numbers;

		public readonly int LineBase;

		public readonly int LineRange;

		public readonly byte OpcodeBase;

		public readonly int MaxAddressIncrement;

		public const int Default_LineBase = -1;

		public const int Default_LineRange = 8;

		public const byte Default_OpcodeBase = 9;

		public const byte DW_LNS_copy = 1;

		public const byte DW_LNS_advance_pc = 2;

		public const byte DW_LNS_advance_line = 3;

		public const byte DW_LNS_set_file = 4;

		public const byte DW_LNS_const_add_pc = 8;

		public const byte DW_LNE_end_sequence = 1;

		public const byte DW_LNE_MONO_negate_is_hidden = 64;

		internal const byte DW_LNE_MONO__extensions_start = 64;

		internal const byte DW_LNE_MONO__extensions_end = 127;

		public LineNumberEntry[] LineNumbers => _line_numbers;

		protected LineNumberTable(MonoSymbolFile file)
		{
			LineBase = file.OffsetTable.LineNumberTable_LineBase;
			LineRange = file.OffsetTable.LineNumberTable_LineRange;
			OpcodeBase = (byte)file.OffsetTable.LineNumberTable_OpcodeBase;
			MaxAddressIncrement = (255 - OpcodeBase) / LineRange;
		}

		internal LineNumberTable(MonoSymbolFile file, LineNumberEntry[] lines)
			: this(file)
		{
			_line_numbers = lines;
		}

		internal void Write(MonoSymbolFile file, MyBinaryWriter bw, bool hasColumnsInfo, bool hasEndInfo)
		{
			int num = (int)bw.BaseStream.Position;
			bool flag = false;
			int num2 = 1;
			int num3 = 0;
			int num4 = 1;
			for (int i = 0; i < LineNumbers.Length; i++)
			{
				int num5 = LineNumbers[i].Row - num2;
				int num6 = LineNumbers[i].Offset - num3;
				if (LineNumbers[i].File != num4)
				{
					bw.Write((byte)4);
					bw.WriteLeb128(LineNumbers[i].File);
					num4 = LineNumbers[i].File;
				}
				if (LineNumbers[i].IsHidden != flag)
				{
					bw.Write((byte)0);
					bw.Write((byte)1);
					bw.Write((byte)64);
					flag = LineNumbers[i].IsHidden;
				}
				if (num6 >= MaxAddressIncrement)
				{
					if (num6 < 2 * MaxAddressIncrement)
					{
						bw.Write((byte)8);
						num6 -= MaxAddressIncrement;
					}
					else
					{
						bw.Write((byte)2);
						bw.WriteLeb128(num6);
						num6 = 0;
					}
				}
				if (num5 < LineBase || num5 >= LineBase + LineRange)
				{
					bw.Write((byte)3);
					bw.WriteLeb128(num5);
					if (num6 != 0)
					{
						bw.Write((byte)2);
						bw.WriteLeb128(num6);
					}
					bw.Write((byte)1);
				}
				else
				{
					byte value = (byte)(num5 - LineBase + LineRange * num6 + OpcodeBase);
					bw.Write(value);
				}
				num2 = LineNumbers[i].Row;
				num3 = LineNumbers[i].Offset;
			}
			bw.Write((byte)0);
			bw.Write((byte)1);
			bw.Write((byte)1);
			if (hasColumnsInfo)
			{
				for (int j = 0; j < LineNumbers.Length; j++)
				{
					LineNumberEntry lineNumberEntry = LineNumbers[j];
					if (lineNumberEntry.Row >= 0)
					{
						bw.WriteLeb128(lineNumberEntry.Column);
					}
				}
			}
			if (hasEndInfo)
			{
				for (int k = 0; k < LineNumbers.Length; k++)
				{
					LineNumberEntry lineNumberEntry2 = LineNumbers[k];
					if (lineNumberEntry2.EndRow == -1 || lineNumberEntry2.EndColumn == -1 || lineNumberEntry2.Row > lineNumberEntry2.EndRow)
					{
						bw.WriteLeb128(16777215);
						continue;
					}
					bw.WriteLeb128(lineNumberEntry2.EndRow - lineNumberEntry2.Row);
					bw.WriteLeb128(lineNumberEntry2.EndColumn);
				}
			}
			file.ExtendedLineNumberSize += (int)bw.BaseStream.Position - num;
		}

		internal static LineNumberTable Read(MonoSymbolFile file, MyBinaryReader br, bool readColumnsInfo, bool readEndInfo)
		{
			LineNumberTable lineNumberTable = new LineNumberTable(file);
			lineNumberTable.DoRead(file, br, readColumnsInfo, readEndInfo);
			return lineNumberTable;
		}

		private void DoRead(MonoSymbolFile file, MyBinaryReader br, bool includesColumns, bool includesEnds)
		{
			List<LineNumberEntry> list = new List<LineNumberEntry>();
			bool flag = false;
			bool flag2 = false;
			int num = 1;
			int num2 = 0;
			int file2 = 1;
			while (true)
			{
				byte b = br.ReadByte();
				if (b == 0)
				{
					byte b2 = br.ReadByte();
					long position = br.BaseStream.Position + b2;
					b = br.ReadByte();
					if (b == 1)
					{
						if (flag2)
						{
							list.Add(new LineNumberEntry(file2, num, -1, num2, flag));
						}
						break;
					}
					if (b == 64)
					{
						flag = !flag;
						flag2 = true;
					}
					else if (b < 64 || b > 127)
					{
						throw new MonoSymbolFileException("Unknown extended opcode {0:x}", b);
					}
					br.BaseStream.Position = position;
				}
				else if (b < OpcodeBase)
				{
					switch (b)
					{
					case 1:
						list.Add(new LineNumberEntry(file2, num, -1, num2, flag));
						flag2 = false;
						break;
					case 2:
						num2 += br.ReadLeb128();
						flag2 = true;
						break;
					case 3:
						num += br.ReadLeb128();
						flag2 = true;
						break;
					case 4:
						file2 = br.ReadLeb128();
						flag2 = true;
						break;
					case 8:
						num2 += MaxAddressIncrement;
						flag2 = true;
						break;
					default:
						throw new MonoSymbolFileException("Unknown standard opcode {0:x} in LNT", b);
					}
				}
				else
				{
					b -= OpcodeBase;
					num2 += b / LineRange;
					num += LineBase + b % LineRange;
					list.Add(new LineNumberEntry(file2, num, -1, num2, flag));
					flag2 = false;
				}
			}
			_line_numbers = list.ToArray();
			if (includesColumns)
			{
				for (int i = 0; i < _line_numbers.Length; i++)
				{
					LineNumberEntry lineNumberEntry = _line_numbers[i];
					if (lineNumberEntry.Row >= 0)
					{
						lineNumberEntry.Column = br.ReadLeb128();
					}
				}
			}
			if (!includesEnds)
			{
				return;
			}
			for (int j = 0; j < _line_numbers.Length; j++)
			{
				LineNumberEntry lineNumberEntry2 = _line_numbers[j];
				int num3 = br.ReadLeb128();
				if (num3 == 16777215)
				{
					lineNumberEntry2.EndRow = -1;
					lineNumberEntry2.EndColumn = -1;
				}
				else
				{
					lineNumberEntry2.EndRow = lineNumberEntry2.Row + num3;
					lineNumberEntry2.EndColumn = br.ReadLeb128();
				}
			}
		}

		public bool GetMethodBounds(out LineNumberEntry start, out LineNumberEntry end)
		{
			if (_line_numbers.Length > 1)
			{
				start = _line_numbers[0];
				end = _line_numbers[_line_numbers.Length - 1];
				return true;
			}
			start = LineNumberEntry.Null;
			end = LineNumberEntry.Null;
			return false;
		}
	}
	public class MethodEntry : IComparable
	{
		[Flags]
		public enum Flags
		{
			LocalNamesAmbiguous = 1,
			ColumnsInfoIncluded = 2,
			EndInfoIncluded = 4
		}

		public readonly int CompileUnitIndex;

		public readonly int Token;

		public readonly int NamespaceID;

		private int DataOffset;

		private int LocalVariableTableOffset;

		private int LineNumberTableOffset;

		private int CodeBlockTableOffset;

		private int ScopeVariableTableOffset;

		private int RealNameOffset;

		private Flags flags;

		private int index;

		public readonly CompileUnitEntry CompileUnit;

		private LocalVariableEntry[] locals;

		private CodeBlockEntry[] code_blocks;

		private ScopeVariable[] scope_vars;

		private LineNumberTable lnt;

		private string real_name;

		public readonly MonoSymbolFile SymbolFile;

		public const int Size = 12;

		public Flags MethodFlags => flags;

		public int Index
		{
			get
			{
				return index;
			}
			set
			{
				index = value;
			}
		}

		internal MethodEntry(MonoSymbolFile file, MyBinaryReader reader, int index)
		{
			SymbolFile = file;
			this.index = index;
			Token = reader.ReadInt32();
			DataOffset = reader.ReadInt32();
			LineNumberTableOffset = reader.ReadInt32();
			long position = reader.BaseStream.Position;
			reader.BaseStream.Position = DataOffset;
			CompileUnitIndex = reader.ReadLeb128();
			LocalVariableTableOffset = reader.ReadLeb128();
			NamespaceID = reader.ReadLeb128();
			CodeBlockTableOffset = reader.ReadLeb128();
			ScopeVariableTableOffset = reader.ReadLeb128();
			RealNameOffset = reader.ReadLeb128();
			flags = (Flags)reader.ReadLeb128();
			reader.BaseStream.Position = position;
			CompileUnit = file.GetCompileUnit(CompileUnitIndex);
		}

		internal MethodEntry(MonoSymbolFile file, CompileUnitEntry comp_unit, int token, ScopeVariable[] scope_vars, LocalVariableEntry[] locals, LineNumberEntry[] lines, CodeBlockEntry[] code_blocks, string real_name, Flags flags, int namespace_id)
		{
			SymbolFile = file;
			this.real_name = real_name;
			this.locals = locals;
			this.code_blocks = code_blocks;
			this.scope_vars = scope_vars;
			this.flags = flags;
			index = -1;
			Token = token;
			CompileUnitIndex = comp_unit.Index;
			CompileUnit = comp_unit;
			NamespaceID = namespace_id;
			CheckLineNumberTable(lines);
			lnt = new LineNumberTable(file, lines);
			file.NumLineNumbers += lines.Length;
			int num = ((locals != null) ? locals.Length : 0);
			if (num <= 32)
			{
				for (int i = 0; i < num; i++)
				{
					string name = locals[i].Name;
					for (int j = i + 1; j < num; j++)
					{
						if (locals[j].Name == name)
						{
							flags |= Flags.LocalNamesAmbiguous;
							return;
						}
					}
				}
				return;
			}
			Dictionary<string, LocalVariableEntry> dictionary = new Dictionary<string, LocalVariableEntry>();
			for (int k = 0; k < locals.Length; k++)
			{
				LocalVariableEntry value = locals[k];
				if (dictionary.ContainsKey(value.Name))
				{
					flags |= Flags.LocalNamesAmbiguous;
					break;
				}
				dictionary.Add(value.Name, value);
			}
		}

		private static void CheckLineNumberTable(LineNumberEntry[] line_numbers)
		{
			int num = -1;
			int num2 = -1;
			if (line_numbers == null)
			{
				return;
			}
			foreach (LineNumberEntry lineNumberEntry in line_numbers)
			{
				if (lineNumberEntry.Equals(LineNumberEntry.Null))
				{
					throw new MonoSymbolFileException();
				}
				if (lineNumberEntry.Offset < num)
				{
					throw new MonoSymbolFileException();
				}
				if (lineNumberEntry.Offset > num)
				{
					num2 = lineNumberEntry.Row;
					num = lineNumberEntry.Offset;
				}
				else if (lineNumberEntry.Row > num2)
				{
					num2 = lineNumberEntry.Row;
				}
			}
		}

		internal void Write(MyBinaryWriter bw)
		{
			if (index <= 0 || DataOffset == 0)
			{
				throw new InvalidOperationException();
			}
			bw.Write(Token);
			bw.Write(DataOffset);
			bw.Write(LineNumberTableOffset);
		}

		internal void WriteData(MonoSymbolFile file, MyBinaryWriter bw)
		{
			if (index <= 0)
			{
				throw new InvalidOperationException();
			}
			LocalVariableTableOffset = (int)bw.BaseStream.Position;
			int num = ((locals != null) ? locals.Length : 0);
			bw.WriteLeb128(num);
			for (int i = 0; i < num; i++)
			{
				locals[i].Write(file, bw);
			}
			file.LocalCount += num;
			CodeBlockTableOffset = (int)bw.BaseStream.Position;
			int num2 = ((code_blocks != null) ? code_blocks.Length : 0);
			bw.WriteLeb128(num2);
			for (int j = 0; j < num2; j++)
			{
				code_blocks[j].Write(bw);
			}
			ScopeVariableTableOffset = (int)bw.BaseStream.Position;
			int num3 = ((scope_vars != null) ? scope_vars.Length : 0);
			bw.WriteLeb128(num3);
			for (int k = 0; k < num3; k++)
			{
				scope_vars[k].Write(bw);
			}
			if (real_name != null)
			{
				RealNameOffset = (int)bw.BaseStream.Position;
				bw.Write(real_name);
			}
			LineNumberEntry[] lineNumbers = lnt.LineNumbers;
			foreach (LineNumberEntry lineNumberEntry in lineNumbers)
			{
				if (lineNumberEntry.EndRow != -1 || lineNumberEntry.EndColumn != -1)
				{
					flags |= Flags.EndInfoIncluded;
				}
			}
			LineNumberTableOffset = (int)bw.BaseStream.Position;
			lnt.Write(file, bw, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0);
			DataOffset = (int)bw.BaseStream.Position;
			bw.WriteLeb128(CompileUnitIndex);
			bw.WriteLeb128(LocalVariableTableOffset);
			bw.WriteLeb128(NamespaceID);
			bw.WriteLeb128(CodeBlockTableOffset);
			bw.WriteLeb128(ScopeVariableTableOffset);
			bw.WriteLeb128(RealNameOffset);
			bw.WriteLeb128((int)flags);
		}

		public void ReadAll()
		{
			GetLineNumberTable();
			GetLocals();
			GetCodeBlocks();
			GetScopeVariables();
			GetRealName();
		}

		public LineNumberTable GetLineNumberTable()
		{
			lock (SymbolFile)
			{
				if (lnt != null)
				{
					return lnt;
				}
				if (LineNumberTableOffset == 0)
				{
					return null;
				}
				MyBinaryReader binaryReader = SymbolFile.BinaryReader;
				long position = binaryReader.BaseStream.Position;
				binaryReader.BaseStream.Position = LineNumberTableOffset;
				lnt = LineNumberTable.Read(SymbolFile, binaryReader, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0);
				binaryReader.BaseStream.Position = position;
				return lnt;
			}
		}

		public LocalVariableEntry[] GetLocals()
		{
			lock (SymbolFile)
			{
				if (locals != null)
				{
					return locals;
				}
				if (LocalVariableTableOffset == 0)
				{
					return null;
				}
				MyBinaryReader binaryReader = SymbolFile.BinaryReader;
				long position = binaryReader.BaseStream.Position;
				binaryReader.BaseStream.Position = LocalVariableTableOffset;
				int num = binaryReader.ReadLeb128();
				locals = new LocalVariableEntry[num];
				for (int i = 0; i < num; i++)
				{
					locals[i] = new LocalVariableEntry(SymbolFile, binaryReader);
				}
				binaryReader.BaseStream.Position = position;
				return locals;
			}
		}

		public CodeBlockEntry[] GetCodeBlocks()
		{
			lock (SymbolFile)
			{
				if (code_blocks != null)
				{
					return code_blocks;
				}
				if (CodeBlockTableOffset == 0)
				{
					return null;
				}
				MyBinaryReader binaryReader = SymbolFile.BinaryReader;
				long position = binaryReader.BaseStream.Position;
				binaryReader.BaseStream.Position = CodeBlockTableOffset;
				int num = binaryReader.ReadLeb128();
				code_blocks = new CodeBlockEntry[num];
				for (int i = 0; i < num; i++)
				{
					code_blocks[i] = new CodeBlockEntry(i, binaryReader);
				}
				binaryReader.BaseStream.Position = position;
				return code_blocks;
			}
		}

		public ScopeVariable[] GetScopeVariables()
		{
			lock (SymbolFile)
			{
				if (scope_vars != null)
				{
					return scope_vars;
				}
				if (ScopeVariableTableOffset == 0)
				{
					return null;
				}
				MyBinaryReader binaryReader = SymbolFile.BinaryReader;
				long position = binaryReader.BaseStream.Position;
				binaryReader.BaseStream.Position = ScopeVariableTableOffset;
				int num = binaryReader.ReadLeb128();
				scope_vars = new ScopeVariable[num];
				for (int i = 0; i < num; i++)
				{
					scope_vars[i] = new ScopeVariable(binaryReader);
				}
				binaryReader.BaseStream.Position = position;
				return scope_vars;
			}
		}

		public string GetRealName()
		{
			lock (SymbolFile)
			{
				if (real_name != null)
				{
					return real_name;
				}
				if (RealNameOffset == 0)
				{
					return null;
				}
				real_name = SymbolFile.BinaryReader.ReadString(RealNameOffset);
				return real_name;
			}
		}

		public int CompareTo(object obj)
		{
			MethodEntry methodEntry = (MethodEntry)obj;
			if (methodEntry.Token < Token)
			{
				return 1;
			}
			if (methodEntry.Token > Token)
			{
				return -1;
			}
			return 0;
		}

		public override string ToString()
		{
			return $"[Method {index}:{Token:x}:{CompileUnitIndex}:{CompileUnit}]";
		}
	}
	public struct NamespaceEntry
	{
		public readonly string Name;

		public readonly int Index;

		public readonly int Parent;

		public readonly string[] UsingClauses;

		public NamespaceEntry(string name, int index, string[] using_clauses, int parent)
		{
			Name = name;
			Index = index;
			Parent = parent;
			UsingClauses = ((using_clauses != null) ? using_clauses : new string[0]);
		}

		internal NamespaceEntry(MonoSymbolFile file, MyBinaryReader reader)
		{
			Name = reader.ReadString();
			Index = reader.ReadLeb128();
			Parent = reader.ReadLeb128();
			int num = reader.ReadLeb128();
			UsingClauses = new string[num];
			for (int i = 0; i < num; i++)
			{
				UsingClauses[i] = reader.ReadString();
			}
		}

		internal void Write(MonoSymbolFile file, MyBinaryWriter bw)
		{
			bw.Write(Name);
			bw.WriteLeb128(Index);
			bw.WriteLeb128(Parent);
			bw.WriteLeb128(UsingClauses.Length);
			string[] usingClauses = UsingClauses;
			foreach (string value in usingClauses)
			{
				bw.Write(value);
			}
		}

		public override string ToString()
		{
			return $"[Namespace {Name}:{Index}:{Parent}]";
		}
	}
	public class MonoSymbolWriter
	{
		private List<SourceMethodBuilder> methods;

		private List<SourceFileEntry> sources;

		private List<CompileUnitEntry> comp_units;

		protected readonly MonoSymbolFile file;

		private string filename;

		private SourceMethodBuilder current_method;

		private Stack<SourceMethodBuilder> current_method_stack = new Stack<SourceMethodBuilder>();

		public MonoSymbolFile SymbolFile => file;

		public MonoSymbolWriter(string filename)
		{
			methods = new List<SourceMethodBuilder>();
			sources = new List<SourceFileEntry>();
			comp_units = new List<CompileUnitEntry>();
			file = new MonoSymbolFile();
			this.filename = filename + ".mdb";
		}

		public void CloseNamespace()
		{
		}

		public void DefineLocalVariable(int index, string name)
		{
			if (current_method != null)
			{
				current_method.AddLocal(index, name);
			}
		}

		public void DefineCapturedLocal(int scope_id, string name, string captured_name)
		{
			file.DefineCapturedVariable(scope_id, name, captured_name, CapturedVariable.CapturedKind.Local);
		}

		public void DefineCapturedParameter(int scope_id, string name, string captured_name)
		{
			file.DefineCapturedVariable(scope_id, name, captured_name, CapturedVariable.CapturedKind.Parameter);
		}

		public void DefineCapturedThis(int scope_id, string captured_name)
		{
			file.DefineCapturedVariable(scope_id, "this", captured_name, CapturedVariable.CapturedKind.This);
		}

		public void DefineCapturedScope(int scope_id, int id, string captured_name)
		{
			file.DefineCapturedScope(scope_id, id, captured_name);
		}

		public void DefineScopeVariable(int scope, int index)
		{
			if (current_method != null)
			{
				current_method.AddScopeVariable(scope, index);
			}
		}

		public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, bool is_hidden)
		{
			if (current_method != null)
			{
				current_method.MarkSequencePoint(offset, file, line, column, is_hidden);
			}
		}

		public SourceMethodBuilder OpenMethod(ICompileUnit file, int ns_id, IMethodDef method)
		{
			SourceMethodBuilder result = new SourceMethodBuilder(file, ns_id, method);
			current_method_stack.Push(current_method);
			current_method = result;
			methods.Add(current_method);
			return result;
		}

		public void CloseMethod()
		{
			current_method = current_method_stack.Pop();
		}

		public SourceFileEntry DefineDocument(string url)
		{
			SourceFileEntry sourceFileEntry = new SourceFileEntry(file, url);
			sources.Add(sourceFileEntry);
			return sourceFileEntry;
		}

		public SourceFileEntry DefineDocument(string url, byte[] guid, byte[] checksum)
		{
			SourceFileEntry sourceFileEntry = new SourceFileEntry(file, url, guid, checksum);
			sources.Add(sourceFileEntry);
			return sourceFileEntry;
		}

		public CompileUnitEntry DefineCompilationUnit(SourceFileEntry source)
		{
			CompileUnitEntry compileUnitEntry = new CompileUnitEntry(file, source);
			comp_units.Add(compileUnitEntry);
			return compileUnitEntry;
		}

		public int DefineNamespace(string name, CompileUnitEntry unit, string[] using_clauses, int parent)
		{
			if (unit == null || using_clauses == null)
			{
				throw new NullReferenceException();
			}
			return unit.DefineNamespace(name, using_clauses, parent);
		}

		public int OpenScope(int start_offset)
		{
			if (current_method == null)
			{
				return 0;
			}
			current_method.StartBlock(CodeBlockEntry.Type.Lexical, start_offset);
			return 0;
		}

		public void CloseScope(int end_offset)
		{
			if (current_method != null)
			{
				current_method.EndBlock(end_offset);
			}
		}

		public void OpenCompilerGeneratedBlock(int start_offset)
		{
			if (current_method != null)
			{
				current_method.StartBlock(CodeBlockEntry.Type.CompilerGenerated, start_offset);
			}
		}

		public void CloseCompilerGeneratedBlock(int end_offset)
		{
			if (current_method != null)
			{
				current_method.EndBlock(end_offset);
			}
		}

		public void StartIteratorBody(int start_offset)
		{
			current_method.StartBlock(CodeBlockEntry.Type.IteratorBody, start_offset);
		}

		public void EndIteratorBody(int end_offset)
		{
			current_method.EndBlock(end_offset);
		}

		public void StartIteratorDispatcher(int start_offset)
		{
			current_method.StartBlock(CodeBlockEntry.Type.IteratorDispatcher, start_offset);
		}

		public void EndIteratorDispatcher(int end_offset)
		{
			current_method.EndBlock(end_offset);
		}

		public void DefineAnonymousScope(int id)
		{
			file.DefineAnonymousScope(id);
		}

		public void WriteSymbolFile(Guid guid)
		{
			foreach (SourceMethodBuilder method in methods)
			{
				method.DefineMethod(file);
			}
			try
			{
				File.Delete(filename);
			}
			catch
			{
			}
			using FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
			file.CreateSymbolFile(guid, fs);
		}
	}
	public class SourceMethodBuilder
	{
		private List<LocalVariableEntry> _locals;

		private List<CodeBlockEntry> _blocks;

		private List<ScopeVariable> _scope_vars;

		private Stack<CodeBlockEntry> _block_stack;

		private readonly List<LineNumberEntry> method_lines;

		private readonly ICompileUnit _comp_unit;

		private readonly int ns_id;

		private readonly IMethodDef method;

		public CodeBlockEntry[] Blocks
		{
			get
			{
				if (_blocks == null)
				{
					return new CodeBlockEntry[0];
				}
				CodeBlockEntry[] array = new CodeBlockEntry[_blocks.Count];
				_blocks.CopyTo(array, 0);
				return array;
			}
		}

		public CodeBlockEntry CurrentBlock
		{
			get
			{
				if (_block_stack != null && _block_stack.Count > 0)
				{
					return _block_stack.Peek();
				}
				return null;
			}
		}

		public LocalVariableEntry[] Locals
		{
			get
			{
				if (_locals == null)
				{
					return new LocalVariableEntry[0];
				}
				return _locals.ToArray();
			}
		}

		public ICompileUnit SourceFile => _comp_unit;

		public ScopeVariable[] ScopeVariables
		{
			get
			{
				if (_scope_vars == null)
				{
					return new ScopeVariable[0];
				}
				return _scope_vars.ToArray();
			}
		}

		public SourceMethodBuilder(ICompileUnit comp_unit)
		{
			_comp_unit = comp_unit;
			method_lines = new List<LineNumberEntry>();
		}

		public SourceMethodBuilder(ICompileUnit comp_unit, int ns_id, IMethodDef method)
			: this(comp_unit)
		{
			this.ns_id = ns_id;
			this.method = method;
		}

		public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, bool is_hidden)
		{
			MarkSequencePoint(offset, file, line, column, -1, -1, is_hidden);
		}

		public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, int end_line, int end_column, bool is_hidden)
		{
			int file2 = file?.Index ?? 0;
			LineNumberEntry lineNumberEntry = new LineNumberEntry(file2, line, column, end_line, end_column, offset, is_hidden);
			if (method_lines.Count > 0)
			{
				LineNumberEntry lineNumberEntry2 = method_lines[method_lines.Count - 1];
				if (lineNumberEntry2.Offset == offset)
				{
					if (LineNumberEntry.LocationComparer.Default.Compare(lineNumberEntry, lineNumberEntry2) > 0)
					{
						method_lines[method_lines.Count - 1] = lineNumberEntry;
					}
					return;
				}
			}
			method_lines.Add(lineNumberEntry);
		}

		public void StartBlock(CodeBlockEntry.Type type, int start_offset)
		{
			StartBlock(type, start_offset, (_blocks == null) ? 1 : (_blocks.Count + 1));
		}

		public void StartBlock(CodeBlockEntry.Type type, int start_offset, int scopeIndex)
		{
			if (_block_stack == null)
			{
				_block_stack = new Stack<CodeBlockEntry>();
			}
			if (_blocks == null)
			{
				_blocks = new List<CodeBlockEntry>();
			}
			int parent = ((CurrentBlock != null) ? CurrentBlock.Index : (-1));
			CodeBlockEntry item = new CodeBlockEntry(scopeIndex, parent, type, start_offset);
			_block_stack.Push(item);
			_blocks.Add(item);
		}

		public void EndBlock(int end_offset)
		{
			CodeBlockEntry codeBlockEntry = _block_stack.Pop();
			codeBlockEntry.Close(end_offset);
		}

		public void AddLocal(int index, string name)
		{
			if (_locals == null)
			{
				_locals = new List<LocalVariableEntry>();
			}
			int block = ((CurrentBlock != null) ? CurrentBlock.Index : 0);
			_locals.Add(new LocalVariableEntry(index, name, block));
		}

		public void AddScopeVariable(int scope, int index)
		{
			if (_scope_vars == null)
			{
				_scope_vars = new List<ScopeVariable>();
			}
			_scope_vars.Add(new ScopeVariable(scope, index));
		}

		public void DefineMethod(MonoSymbolFile file)
		{
			DefineMethod(file, method.Token);
		}

		public void DefineMethod(MonoSymbolFile file, int token)
		{
			CodeBlockEntry[] array = Blocks;
			if (array.Length != 0)
			{
				List<CodeBlockEntry> list = new List<CodeBlockEntry>(array.Length);
				int num = 0;
				for (int i = 0; i < array.Length; i++)
				{
					num = Math.Max(num, array[i].Index);
				}
				for (int j = 0; j < num; j++)
				{
					int num2 = j + 1;
					if (j < array.Length && array[j].Index == num2)
					{
						list.Add(array[j]);
						continue;
					}
					bool flag = false;
					for (int k = 0; k < array.Length; k++)
					{
						if (array[k].Index == num2)
						{
							list.Add(array[k]);
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						list.Add(new CodeBlockEntry(num2, -1, CodeBlockEntry.Type.CompilerGenerated, 0));
					}
				}
				array = list.ToArray();
			}
			MethodEntry entry = new MethodEntry(file, _comp_unit.Entry, token, ScopeVariables, Locals, method_lines.ToArray(), array, null, MethodEntry.Flags.ColumnsInfoIncluded, ns_id);
			file.AddMethod(entry);
		}
	}
	public class SymbolWriterImpl : ISymbolWriter
	{
		private delegate Guid GetGuidFunc(ModuleBuilder mb);

		private MonoSymbolWriter msw;

		private int nextLocalIndex;

		private int currentToken;

		private string methodName;

		private Stack namespaceStack = new Stack();

		private bool methodOpened;

		private Hashtable documents = new Hashtable();

		private ModuleBuilder mb;

		private GetGuidFunc get_guid_func;

		public SymbolWriterImpl(ModuleBuilder mb)
		{
			this.mb = mb;
		}

		public void Close()
		{
			MethodInfo method = typeof(ModuleBuilder).GetMethod("Mono_GetGuid", BindingFlags.Static | BindingFlags.NonPublic);
			if ((object)method != null)
			{
				get_guid_func = (GetGuidFunc)Delegate.CreateDelegate(typeof(GetGuidFunc), method);
				msw.WriteSymbolFile(get_guid_func(mb));
			}
		}

		public void CloseMethod()
		{
			if (methodOpened)
			{
				methodOpened = false;
				nextLocalIndex = 0;
				msw.CloseMethod();
			}
		}

		public void CloseNamespace()
		{
			namespaceStack.Pop();
			msw.CloseNamespace();
		}

		public void CloseScope(int endOffset)
		{
			msw.CloseScope(endOffset);
		}

		public ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType)
		{
			SymbolDocumentWriterImpl symbolDocumentWriterImpl = (SymbolDocumentWriterImpl)documents[url];
			if (symbolDocumentWriterImpl == null)
			{
				SourceFileEntry source = msw.DefineDocument(url);
				CompileUnitEntry comp_unit = msw.DefineCompilationUnit(source);
				symbolDocumentWriterImpl = new SymbolDocumentWriterImpl(comp_unit);
				documents[url] = symbolDocumentWriterImpl;
			}
			return symbolDocumentWriterImpl;
		}

		public void DefineField(SymbolToken parent, string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3)
		{
		}

		public void DefineGlobalVariable(string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3)
		{
		}

		public void DefineLocalVariable(string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset)
		{
			msw.DefineLocalVariable(nextLocalIndex++, name);
		}

		public void DefineParameter(string name, ParameterAttributes attributes, int sequence, SymAddressKind addrKind, int addr1, int addr2, int addr3)
		{
		}

		public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns)
		{
			SourceFileEntry file = ((SymbolDocumentWriterImpl)document)?.Entry.SourceFile;
			for (int i = 0; i < offsets.Length; i++)
			{
				if (i <= 0 || offsets[i] != offsets[i - 1] || lines[i] != lines[i - 1] || columns[i] != columns[i - 1])
				{
					msw.MarkSequencePoint(offsets[i], file, lines[i], columns[i], is_hidden: false);
				}
			}
		}

		public void Initialize(IntPtr emitter, string filename, bool fFullBuild)
		{
			msw = new MonoSymbolWriter(filename);
		}

		public void OpenMethod(SymbolToken method)
		{
			currentToken = method.GetToken();
		}

		public void OpenNamespace(string name)
		{
			NamespaceInfo namespaceInfo = new NamespaceInfo();
			namespaceInfo.NamespaceID = -1;
			namespaceInfo.Name = name;
			namespaceStack.Push(namespaceInfo);
		}

		public int OpenScope(int startOffset)
		{
			return msw.OpenScope(startOffset);
		}

		public void SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn)
		{
			int currentNamespace = GetCurrentNamespace(startDoc);
			SourceMethodImpl method = new SourceMethodImpl(methodName, currentToken, currentNamespace);
			msw.OpenMethod(((ICompileUnit)startDoc).Entry, currentNamespace, method);
			methodOpened = true;
		}

		public void SetScopeRange(int scopeID, int startOffset, int endOffset)
		{
		}

		public void SetSymAttribute(SymbolToken parent, string name, byte[] data)
		{
			if (name == "__name")
			{
				methodName = Encoding.UTF8.GetString(data);
			}
		}

		public void SetUnderlyingWriter(IntPtr underlyingWriter)
		{
		}

		public void SetUserEntryPoint(SymbolToken entryMethod)
		{
		}

		public void UsingNamespace(string fullName)
		{
			if (namespaceStack.Count == 0)
			{
				OpenNamespace("");
			}
			NamespaceInfo namespaceInfo = (NamespaceInfo)namespaceStack.Peek();
			if (namespaceInfo.NamespaceID != -1)
			{
				NamespaceInfo namespaceInfo2 = namespaceInfo;
				CloseNamespace();
				OpenNamespace(namespaceInfo2.Name);
				namespaceInfo = (NamespaceInfo)namespaceStack.Peek();
				namespaceInfo.UsingClauses = namespaceInfo2.UsingClauses;
			}
			namespaceInfo.UsingClauses.Add(fullName);
		}

		private int GetCurrentNamespace(ISymbolDocumentWriter doc)
		{
			if (namespaceStack.Count == 0)
			{
				OpenNamespace("");
			}
			NamespaceInfo namespaceInfo = (NamespaceInfo)namespaceStack.Peek();
			if (namespaceInfo.NamespaceID == -1)
			{
				string[] using_clauses = (string[])namespaceInfo.UsingClauses.ToArray(typeof(string));
				int parent = 0;
				if (namespaceStack.Count > 1)
				{
					namespaceStack.Pop();
					parent = ((NamespaceInfo)namespaceStack.Peek()).NamespaceID;
					namespaceStack.Push(namespaceInfo);
				}
				namespaceInfo.NamespaceID = msw.DefineNamespace(namespaceInfo.Name, ((ICompileUnit)doc).Entry, using_clauses, parent);
			}
			return namespaceInfo.NamespaceID;
		}
	}
	internal class SymbolDocumentWriterImpl : ISymbolDocumentWriter, ISourceFile, ICompileUnit
	{
		private CompileUnitEntry comp_unit;

		SourceFileEntry ISourceFile.Entry => comp_unit.SourceFile;

		public CompileUnitEntry Entry => comp_unit;

		public SymbolDocumentWriterImpl(CompileUnitEntry comp_unit)
		{
			this.comp_unit = comp_unit;
		}

		public void SetCheckSum(Guid algorithmId, byte[] checkSum)
		{
		}

		public void SetSource(byte[] source)
		{
		}
	}
	internal class SourceMethodImpl : IMethodDef
	{
		private string name;

		private int token;

		private int namespaceID;

		public string Name => name;

		public int NamespaceID => namespaceID;

		public int Token => token;

		public SourceMethodImpl(string name, int token, int namespaceID)
		{
			this.name = name;
			this.token = token;
			this.namespaceID = namespaceID;
		}
	}
	internal class NamespaceInfo
	{
		public string Name;

		public int NamespaceID;

		public ArrayList UsingClauses = new ArrayList();
	}
}
namespace Mono.CSharp
{
	public abstract class CompilerGeneratedContainer : ClassOrStruct
	{
		protected CompilerGeneratedContainer(TypeContainer parent, MemberName name, Modifiers mod)
			: this(parent, name, mod, MemberKind.Class)
		{
		}

		protected CompilerGeneratedContainer(TypeContainer parent, MemberName name, Modifiers mod, MemberKind kind)
			: base(parent, name, null, kind)
		{
			base.ModFlags = mod | Modifiers.COMPILER_GENERATED | Modifiers.SEALED;
			spec = new TypeSpec(Kind, null, this, null, base.ModFlags);
		}

		protected void CheckMembersDefined()
		{
			if (base.HasMembersDefined)
			{
				throw new InternalErrorException("Helper class already defined!");
			}
		}

		protected override bool DoDefineMembers()
		{
			if (Kind == MemberKind.Class && !base.IsStatic && !base.PartialContainer.HasInstanceConstructor)
			{
				DefineDefaultConstructor(is_static: false);
			}
			return base.DoDefineMembers();
		}

		protected static MemberName MakeMemberName(MemberBase host, string name, int unique_id, TypeParameters tparams, Location loc)
		{
			string host2 = ((host == null) ? null : ((host is InterfaceMemberBase) ? ((InterfaceMemberBase)host).GetFullName(host.MemberName) : host.MemberName.Name));
			string name2 = MakeName(host2, "c", name, unique_id);
			TypeParameters typeParameters = null;
			if (tparams != null)
			{
				typeParameters = new TypeParameters(tparams.Count);
				for (int i = 0; i < tparams.Count; i++)
				{
					typeParameters.Add((TypeParameter)null);
				}
			}
			return new MemberName(name2, typeParameters, loc);
		}

		public static string MakeName(string host, string typePrefix, string name, int id)
		{
			return "<" + host + ">" + typePrefix + "__" + name + id.ToString("X");
		}

		protected override TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class)
		{
			base_type = Compiler.BuiltinTypes.Object;
			base_class = null;
			return null;
		}
	}
	public class HoistedStoreyClass : CompilerGeneratedContainer
	{
		public sealed class HoistedField : Field
		{
			public HoistedField(HoistedStoreyClass parent, FullNamedExpression type, Modifiers mod, string name, Attributes attrs, Location loc)
				: base(parent, type, mod, new MemberName(name, loc), attrs)
			{
			}

			protected override bool ResolveMemberType()
			{
				if (!base.ResolveMemberType())
				{
					return false;
				}
				HoistedStoreyClass genericStorey = ((HoistedStoreyClass)Parent).GetGenericStorey();
				if (genericStorey != null && genericStorey.Mutator != null)
				{
					member_type = genericStorey.Mutator.Mutate(base.MemberType);
				}
				return true;
			}
		}

		protected TypeParameterMutator mutator;

		public TypeParameterMutator Mutator
		{
			get
			{
				return mutator;
			}
			set
			{
				mutator = value;
			}
		}

		public HoistedStoreyClass(TypeDefinition parent, MemberName name, TypeParameters tparams, Modifiers mods, MemberKind kind)
			: base(parent, name, mods | Modifiers.PRIVATE, kind)
		{
			if (tparams != null)
			{
				TypeParameters typeParameters = name.TypeParameters;
				TypeParameterSpec[] array = new TypeParameterSpec[tparams.Count];
				TypeParameterSpec[] array2 = new TypeParameterSpec[tparams.Count];
				for (int i = 0; i < tparams.Count; i++)
				{
					typeParameters[i] = tparams[i].CreateHoistedCopy(spec);
					array[i] = tparams[i].Type;
					array2[i] = typeParameters[i].Type;
				}
				TypeSpec[] targs = array2;
				TypeParameterInflator inflator = new TypeParameterInflator(this, null, array, targs);
				for (int j = 0; j < tparams.Count; j++)
				{
					array[j].InflateConstraints(inflator, array2[j]);
				}
				mutator = new TypeParameterMutator(tparams, typeParameters);
			}
		}

		public HoistedStoreyClass GetGenericStorey()
		{
			TypeContainer typeContainer = this;
			while (typeContainer != null && typeContainer.CurrentTypeParameters == null)
			{
				typeContainer = typeContainer.Parent;
			}
			return typeContainer as HoistedStoreyClass;
		}
	}
	public class AnonymousMethodStorey : HoistedStoreyClass
	{
		private struct StoreyFieldPair
		{
			public readonly AnonymousMethodStorey Storey;

			public readonly Field Field;

			public StoreyFieldPair(AnonymousMethodStorey storey, Field field)
			{
				Storey = storey;
				Field = field;
			}
		}

		private sealed class ThisInitializer : Statement
		{
			private readonly HoistedThis hoisted_this;

			private readonly AnonymousMethodStorey parent;

			public ThisInitializer(HoistedThis hoisted_this, AnonymousMethodStorey parent)
			{
				this.hoisted_this = hoisted_this;
				this.parent = parent;
			}

			protected override void DoEmit(EmitContext ec)
			{
				Expression source = ((parent != null) ? ((Expression)new FieldExpr(parent.HoistedThis.Field, Location.Null)
				{
					InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, Location.Null)
				}) : ((Expression)new CompilerGeneratedThis(ec.CurrentType, loc)));
				hoisted_this.EmitAssign(ec, source, leave_copy: false, isCompound: false);
			}

			protected override bool DoFlowAnalysis(FlowAnalysisContext fc)
			{
				return false;
			}

			protected override void CloneTo(CloneContext clonectx, Statement target)
			{
			}
		}

		public readonly int ID;

		public readonly ExplicitBlock OriginalSourceBlock;

		private List<StoreyFieldPair> used_parent_storeys;

		private List<ExplicitBlock> children_references;

		protected List<HoistedParameter> hoisted_params;

		private List<HoistedParameter> hoisted_local_params;

		protected List<HoistedVariable> hoisted_locals;

		protected HoistedThis hoisted_this;

		public Expression Instance;

		private bool initialize_hoisted_this;

		private AnonymousMethodStorey hoisted_this_parent;

		public HoistedThis HoistedThis
		{
			get
			{
				return hoisted_this;
			}
			set
			{
				hoisted_this = value;
			}
		}

		public IList<ExplicitBlock> ReferencesFromChildrenBlock => children_references;

		public AnonymousMethodStorey(ExplicitBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind)
			: base(parent, CompilerGeneratedContainer.MakeMemberName(host, name, parent.PartialContainer.CounterAnonymousContainers, tparams, block.StartLocation), tparams, (Modifiers)0, kind)
		{
			OriginalSourceBlock = block;
			ID = parent.PartialContainer.CounterAnonymousContainers++;
		}

		public void AddCapturedThisField(EmitContext ec, AnonymousMethodStorey parent)
		{
			TypeExpr type = new TypeExpression(ec.CurrentType, base.Location);
			Field field = AddCompilerGeneratedField("$this", type);
			hoisted_this = new HoistedThis(this, field);
			initialize_hoisted_this = true;
			hoisted_this_parent = parent;
		}

		public Field AddCapturedVariable(string name, TypeSpec type)
		{
			CheckMembersDefined();
			FullNamedExpression type2 = new TypeExpression(type, base.Location);
			if (!spec.IsGenericOrParentIsGeneric)
			{
				return AddCompilerGeneratedField(name, type2);
			}
			Field field = new HoistedField(this, type2, Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED, name, null, base.Location);
			AddField(field);
			return field;
		}

		protected Field AddCompilerGeneratedField(string name, FullNamedExpression type)
		{
			return AddCompilerGeneratedField(name, type, privateAccess: false);
		}

		protected Field AddCompilerGeneratedField(string name, FullNamedExpression type, bool privateAccess)
		{
			Modifiers mod = Modifiers.COMPILER_GENERATED | (privateAccess ? Modifiers.PRIVATE : Modifiers.INTERNAL);
			Field field = new Field(this, type, mod, new MemberName(name, base.Location), null);
			AddField(field);
			return field;
		}

		public void AddReferenceFromChildrenBlock(ExplicitBlock block)
		{
			if (children_references == null)
			{
				children_references = new List<ExplicitBlock>();
			}
			if (!children_references.Contains(block))
			{
				children_references.Add(block);
			}
		}

		public void AddParentStoreyReference(EmitContext ec, AnonymousMethodStorey storey)
		{
			CheckMembersDefined();
			if (used_parent_storeys == null)
			{
				used_parent_storeys = new List<StoreyFieldPair>();
			}
			else if (used_parent_storeys.Exists((StoreyFieldPair i) => i.Storey == storey))
			{
				return;
			}
			TypeExpr type = storey.CreateStoreyTypeExpression(ec);
			int iD = storey.ID;
			Field field = AddCompilerGeneratedField("<>f__ref$" + iD, type);
			used_parent_storeys.Add(new StoreyFieldPair(storey, field));
		}

		public void CaptureLocalVariable(ResolveContext ec, LocalVariable localVariable)
		{
			if (this is StateMachine)
			{
				if (ec.CurrentBlock.ParametersBlock != localVariable.Block.ParametersBlock)
				{
					ec.CurrentBlock.Explicit.HasCapturedVariable = true;
				}
			}
			else
			{
				ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			}
			HoistedVariable hoistedVariable = localVariable.HoistedVariant;
			if (hoistedVariable != null && hoistedVariable.Storey != this && hoistedVariable.Storey is StateMachine)
			{
				hoistedVariable.Storey.hoisted_locals.Remove(hoistedVariable);
				hoistedVariable.Storey.Members.Remove(hoistedVariable.Field);
				hoistedVariable = null;
			}
			if (hoistedVariable == null)
			{
				hoistedVariable = (localVariable.HoistedVariant = new HoistedLocalVariable(this, localVariable, GetVariableMangledName(ec, localVariable)));
				if (hoisted_locals == null)
				{
					hoisted_locals = new List<HoistedVariable>();
				}
				hoisted_locals.Add(hoistedVariable);
			}
			if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoistedVariable.Storey is StateMachine) && hoistedVariable.Storey != null)
			{
				hoistedVariable.Storey.AddReferenceFromChildrenBlock(ec.CurrentBlock.Explicit);
			}
		}

		public void CaptureParameter(ResolveContext ec, ParametersBlock.ParameterInfo parameterInfo, ParameterReference parameterReference)
		{
			if (!(this is StateMachine))
			{
				ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			}
			HoistedParameter hoistedParameter = parameterInfo.Parameter.HoistedVariant;
			if (parameterInfo.Block.StateMachine != null)
			{
				if (hoistedParameter == null && parameterInfo.Block.StateMachine != this)
				{
					StateMachine stateMachine = parameterInfo.Block.StateMachine;
					hoistedParameter = new HoistedParameter(stateMachine, parameterReference);
					parameterInfo.Parameter.HoistedVariant = hoistedParameter;
					if (stateMachine.hoisted_params == null)
					{
						stateMachine.hoisted_params = new List<HoistedParameter>();
					}
					stateMachine.hoisted_params.Add(hoistedParameter);
				}
				if (hoistedParameter != null && hoistedParameter.Storey != this && hoistedParameter.Storey is StateMachine)
				{
					if (hoisted_local_params == null)
					{
						hoisted_local_params = new List<HoistedParameter>();
					}
					hoisted_local_params.Add(hoistedParameter);
					hoistedParameter = null;
				}
			}
			if (hoistedParameter == null)
			{
				hoistedParameter = new HoistedParameter(this, parameterReference);
				parameterInfo.Parameter.HoistedVariant = hoistedParameter;
				if (hoisted_params == null)
				{
					hoisted_params = new List<HoistedParameter>();
				}
				hoisted_params.Add(hoistedParameter);
			}
			if (ec.CurrentBlock.Explicit != parameterInfo.Block)
			{
				hoistedParameter.Storey.AddReferenceFromChildrenBlock(ec.CurrentBlock.Explicit);
			}
		}

		private TypeExpr CreateStoreyTypeExpression(EmitContext ec)
		{
			if (CurrentTypeParameters != null)
			{
				TypeParameters typeParameters = ((ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null) ? ec.CurrentAnonymousMethod.Storey.CurrentTypeParameters : ec.CurrentTypeParameters);
				TypeArguments typeArguments = new TypeArguments();
				for (int i = 0; i < typeParameters.Count; i++)
				{
					typeArguments.Add(new SimpleName(typeParameters[i].Name, base.Location));
				}
				return new GenericTypeExpr(base.Definition, typeArguments, base.Location);
			}
			return new TypeExpression(CurrentType, base.Location);
		}

		public void SetNestedStoryParent(AnonymousMethodStorey parentStorey)
		{
			Parent = parentStorey;
			spec.IsGeneric = false;
			spec.DeclaringType = parentStorey.CurrentType;
			base.MemberName.TypeParameters = null;
		}

		protected override bool DoResolveTypeParameters()
		{
			if (CurrentTypeParameters != null)
			{
				for (int i = 0; i < CurrentTypeParameters.Count; i++)
				{
					TypeParameterSpec type = CurrentTypeParameters[i].Type;
					type.BaseType = mutator.Mutate(type.BaseType);
					if (type.InterfacesDefined != null)
					{
						TypeSpec[] array = new TypeSpec[type.InterfacesDefined.Length];
						for (int j = 0; j < array.Length; j++)
						{
							array[j] = mutator.Mutate(type.InterfacesDefined[j]);
						}
						type.InterfacesDefined = array;
					}
					if (type.TypeArguments != null)
					{
						type.TypeArguments = mutator.Mutate(type.TypeArguments);
					}
				}
			}
			Parent.CurrentType.MemberCache.AddMember(spec);
			return true;
		}

		public void EmitStoreyInstantiation(EmitContext ec, ExplicitBlock block)
		{
			if (Instance != null)
			{
				throw new InternalErrorException();
			}
			ResolveContext resolveContext = new ResolveContext(ec.MemberContext);
			resolveContext.CurrentBlock = block;
			TypeExpr typeExpr = CreateStoreyTypeExpression(ec);
			Expression expression = new New(typeExpr, null, base.Location).Resolve(resolveContext);
			if (ec.CurrentAnonymousMethod is StateMachineInitializer && (block.HasYield || block.HasAwait))
			{
				Field field = ec.CurrentAnonymousMethod.Storey.AddCompilerGeneratedField(LocalVariable.GetCompilerGeneratedName(block), typeExpr, privateAccess: true);
				field.Define();
				field.Emit();
				FieldExpr fieldExpr = new FieldExpr(field, base.Location);
				fieldExpr.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, base.Location);
				fieldExpr.EmitAssign(ec, expression, leave_copy: false, isCompound: false);
				Instance = fieldExpr;
			}
			else
			{
				TemporaryVariableReference temporaryVariableReference = TemporaryVariableReference.Create(expression.Type, block, base.Location, writeToSymbolFile: true);
				if (expression.Type.IsStruct)
				{
					temporaryVariableReference.LocalInfo.CreateBuilder(ec);
				}
				else
				{
					temporaryVariableReference.EmitAssign(ec, expression);
				}
				Instance = temporaryVariableReference;
			}
			EmitHoistedFieldsInitialization(resolveContext, ec);
		}

		private void EmitHoistedFieldsInitialization(ResolveContext rc, EmitContext ec)
		{
			if (used_parent_storeys != null)
			{
				foreach (StoreyFieldPair used_parent_storey in used_parent_storeys)
				{
					Expression storeyInstanceExpression = GetStoreyInstanceExpression(ec);
					FieldSpec member = used_parent_storey.Field.Spec;
					if (TypeManager.IsGenericType(storeyInstanceExpression.Type))
					{
						member = MemberCache.GetMember(storeyInstanceExpression.Type, member);
					}
					FieldExpr fieldExpr = new FieldExpr(member, base.Location);
					fieldExpr.InstanceExpression = storeyInstanceExpression;
					SimpleAssign simpleAssign = new SimpleAssign(fieldExpr, used_parent_storey.Storey.GetStoreyInstanceExpression(ec));
					if (simpleAssign.Resolve(rc) != null)
					{
						simpleAssign.EmitStatement(ec);
					}
				}
			}
			if (initialize_hoisted_this)
			{
				rc.CurrentBlock.AddScopeStatement(new ThisInitializer(hoisted_this, hoisted_this_parent));
			}
			AnonymousExpression currentAnonymousMethod = ec.CurrentAnonymousMethod;
			ec.CurrentAnonymousMethod = null;
			if (hoisted_params != null)
			{
				EmitHoistedParameters(ec, hoisted_params);
			}
			ec.CurrentAnonymousMethod = currentAnonymousMethod;
		}

		protected virtual void EmitHoistedParameters(EmitContext ec, List<HoistedParameter> hoisted)
		{
			foreach (HoistedParameter hp in hoisted)
			{
				if (hp == null)
				{
					continue;
				}
				if (hoisted_local_params != null)
				{
					HoistedParameter hoistedParameter = hoisted_local_params.Find((HoistedParameter l) => l.Parameter.Parameter == hp.Parameter.Parameter);
					FieldExpr fieldExpr = new FieldExpr(hoistedParameter.Field, base.Location);
					fieldExpr.InstanceExpression = new CompilerGeneratedThis(CurrentType, base.Location);
					hp.EmitAssign(ec, fieldExpr, leave_copy: false, isCompound: false);
				}
				else
				{
					hp.EmitHoistingAssignment(ec);
				}
			}
		}

		private Field GetReferencedStoreyField(AnonymousMethodStorey storey)
		{
			if (used_parent_storeys == null)
			{
				return null;
			}
			foreach (StoreyFieldPair used_parent_storey in used_parent_storeys)
			{
				if (used_parent_storey.Storey == storey)
				{
					return used_parent_storey.Field;
				}
			}
			return null;
		}

		public Expression GetStoreyInstanceExpression(EmitContext ec)
		{
			AnonymousExpression currentAnonymousMethod = ec.CurrentAnonymousMethod;
			if (currentAnonymousMethod == null)
			{
				return Instance;
			}
			if (currentAnonymousMethod.Storey == null)
			{
				return Instance;
			}
			Field referencedStoreyField = currentAnonymousMethod.Storey.GetReferencedStoreyField(this);
			if (referencedStoreyField == null)
			{
				if (currentAnonymousMethod.Storey == this)
				{
					return new CompilerGeneratedThis(CurrentType, base.Location);
				}
				return Instance;
			}
			FieldExpr fieldExpr = new FieldExpr(referencedStoreyField, base.Location);
			fieldExpr.InstanceExpression = new CompilerGeneratedThis(CurrentType, base.Location);
			return fieldExpr;
		}

		protected virtual string GetVariableMangledName(ResolveContext rc, LocalVariable local_info)
		{
			return local_info.Name;
		}
	}
	public abstract class HoistedVariable
	{
		private class ExpressionTreeVariableReference : Expression
		{
			private readonly HoistedVariable hv;

			public ExpressionTreeVariableReference(HoistedVariable hv)
			{
				this.hv = hv;
			}

			public override bool ContainsEmitWithAwait()
			{
				return false;
			}

			public override Expression CreateExpressionTree(ResolveContext ec)
			{
				return hv.CreateExpressionTree();
			}

			protected override Expression DoResolve(ResolveContext ec)
			{
				eclass = ExprClass.Value;
				type = ec.Module.PredefinedTypes.Expression.Resolve();
				return this;
			}

			public override void Emit(EmitContext ec)
			{
				ResolveContext resolveContext = new ResolveContext(ec.MemberContext);
				Expression expression = hv.GetFieldExpression(ec).CreateExpressionTree(resolveContext, convertInstance: false);
				expression.Resolve(resolveContext)?.Emit(ec);
			}
		}

		protected readonly AnonymousMethodStorey storey;

		protected Field field;

		private Dictionary<AnonymousExpression, FieldExpr> cached_inner_access;

		private FieldExpr cached_outer_access;

		public Field Field => field;

		public AnonymousMethodStorey Storey => storey;

		protected HoistedVariable(AnonymousMethodStorey storey, string name, TypeSpec type)
			: this(storey, storey.AddCapturedVariable(name, type))
		{
		}

		protected HoistedVariable(AnonymousMethodStorey storey, Field field)
		{
			this.storey = storey;
			this.field = field;
		}

		public void AddressOf(EmitContext ec, AddressOp mode)
		{
			GetFieldExpression(ec).AddressOf(ec, mode);
		}

		public Expression CreateExpressionTree()
		{
			return new ExpressionTreeVariableReference(this);
		}

		public void Emit(EmitContext ec)
		{
			GetFieldExpression(ec).Emit(ec);
		}

		public Expression EmitToField(EmitContext ec)
		{
			return GetFieldExpression(ec);
		}

		protected virtual FieldExpr GetFieldExpression(EmitContext ec)
		{
			if (ec.CurrentAnonymousMethod == null || ec.CurrentAnonymousMethod.Storey == null)
			{
				if (cached_outer_access != null)
				{
					return cached_outer_access;
				}
				if (storey.Instance.Type.IsGenericOrParentIsGeneric)
				{
					FieldSpec member = MemberCache.GetMember(storey.Instance.Type, field.Spec);
					cached_outer_access = new FieldExpr(member, field.Location);
				}
				else
				{
					cached_outer_access = new FieldExpr(field, field.Location);
				}
				cached_outer_access.InstanceExpression = storey.GetStoreyInstanceExpression(ec);
				return cached_outer_access;
			}
			FieldExpr value;
			if (cached_inner_access != null)
			{
				if (!cached_inner_access.TryGetValue(ec.CurrentAnonymousMethod, out value))
				{
					value = null;
				}
			}
			else
			{
				value = null;
				cached_inner_access = new Dictionary<AnonymousExpression, FieldExpr>(4);
			}
			if (value == null)
			{
				if (field.Parent.IsGenericOrParentIsGeneric)
				{
					FieldSpec member2 = MemberCache.GetMember(field.Parent.CurrentType, field.Spec);
					value = new FieldExpr(member2, field.Location);
				}
				else
				{
					value = new FieldExpr(field, field.Location);
				}
				value.InstanceExpression = storey.GetStoreyInstanceExpression(ec);
				cached_inner_access.Add(ec.CurrentAnonymousMethod, value);
			}
			return value;
		}

		public void Emit(EmitContext ec, bool leave_copy)
		{
			GetFieldExpression(ec).Emit(ec, leave_copy);
		}

		public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound)
		{
			GetFieldExpression(ec).EmitAssign(ec, source, leave_copy, isCompound: false);
		}

		public void EmitAssignFromStack(EmitContext ec)
		{
			GetFieldExpression(ec).EmitAssignFromStack(ec);
		}
	}
	public class HoistedParameter : HoistedVariable
	{
		private sealed class HoistedFieldAssign : CompilerAssign
		{
			public HoistedFieldAssign(Expression target, Expression source)
				: base(target, source, target.Location)
			{
			}

			protected override Expression ResolveConversions(ResolveContext ec)
			{
				return this;
			}
		}

		private readonly ParameterReference parameter;

		public bool IsAssigned { get; set; }

		public ParameterReference Parameter => parameter;

		public HoistedParameter(AnonymousMethodStorey scope, ParameterReference par)
			: base(scope, par.Name, par.Type)
		{
			parameter = par;
		}

		public HoistedParameter(HoistedParameter hp, string name)
			: base(hp.storey, name, hp.parameter.Type)
		{
			parameter = hp.parameter;
		}

		public void EmitHoistingAssignment(EmitContext ec)
		{
			HoistedParameter hoistedVariant = parameter.Parameter.HoistedVariant;
			parameter.Parameter.HoistedVariant = null;
			HoistedFieldAssign hoistedFieldAssign = new HoistedFieldAssign(GetFieldExpression(ec), parameter);
			hoistedFieldAssign.EmitStatement(ec);
			parameter.Parameter.HoistedVariant = hoistedVariant;
		}
	}
	internal class HoistedLocalVariable : HoistedVariable
	{
		public HoistedLocalVariable(AnonymousMethodStorey storey, LocalVariable local, string name)
			: base(storey, name, local.Type)
		{
		}
	}
	public class HoistedThis : HoistedVariable
	{
		public HoistedThis(AnonymousMethodStorey storey, Field field)
			: base(storey, field)
		{
		}
	}
	public class AnonymousMethodExpression : Expression
	{
		private class Quote : ShimExpression
		{
			public Quote(Expression expr)
				: base(expr)
			{
			}

			public override Expression CreateExpressionTree(ResolveContext ec)
			{
				Arguments arguments = new Arguments(1);
				arguments.Add(new Argument(expr.CreateExpressionTree(ec)));
				return CreateExpressionFactoryCall(ec, "Quote", arguments);
			}

			protected override Expression DoResolve(ResolveContext rc)
			{
				expr = expr.Resolve(rc);
				if (expr == null)
				{
					return null;
				}
				eclass = expr.eclass;
				type = expr.Type;
				return this;
			}
		}

		private readonly Dictionary<TypeSpec, Expression> compatibles;

		public ParametersBlock Block;

		public override string ExprClassName => "anonymous method";

		public virtual bool HasExplicitParameters => Parameters != ParametersCompiled.Undefined;

		public override bool IsSideEffectFree => true;

		public ParametersCompiled Parameters => Block.Parameters;

		public ReportPrinter TypeInferenceReportPrinter { get; set; }

		public AnonymousMethodExpression(Location loc)
		{
			base.loc = loc;
			compatibles = new Dictionary<TypeSpec, Expression>();
		}

		public bool ImplicitStandardConversionExists(ResolveContext ec, TypeSpec delegate_type)
		{
			using (ec.With(ResolveContext.Options.InferReturnType, enable: false))
			{
				using (ec.Set(ResolveContext.Options.ProbingMode))
				{
					ReportPrinter printer = ec.Report.SetPrinter(TypeInferenceReportPrinter ?? new NullReportPrinter());
					bool result = Compatible(ec, delegate_type) != null;
					ec.Report.SetPrinter(printer);
					return result;
				}
			}
		}

		private TypeSpec CompatibleChecks(ResolveContext ec, TypeSpec delegate_type)
		{
			if (delegate_type.IsDelegate)
			{
				return delegate_type;
			}
			if (delegate_type.IsExpressionTreeType)
			{
				delegate_type = delegate_type.TypeArguments[0];
				if (delegate_type.IsDelegate)
				{
					return delegate_type;
				}
				ec.Report.Error(835, loc, "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'", GetSignatureForError(), delegate_type.GetSignatureForError());
				return null;
			}
			ec.Report.Error(1660, loc, "Cannot convert `{0}' to non-delegate type `{1}'", GetSignatureForError(), delegate_type.GetSignatureForError());
			return null;
		}

		protected bool VerifyExplicitParameters(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type, AParametersCollection parameters)
		{
			if (VerifyParameterCompatibility(ec, tic, delegate_type, parameters, ec.IsInProbingMode))
			{
				return true;
			}
			if (!ec.IsInProbingMode)
			{
				ec.Report.Error(1661, loc, "Cannot convert `{0}' to delegate type `{1}' since there is a parameter mismatch", GetSignatureForError(), delegate_type.GetSignatureForError());
			}
			return false;
		}

		protected bool VerifyParameterCompatibility(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type, AParametersCollection invoke_pd, bool ignore_errors)
		{
			if (Parameters.Count != invoke_pd.Count)
			{
				if (ignore_errors)
				{
					return false;
				}
				ec.Report.Error(1593, loc, "Delegate `{0}' does not take `{1}' arguments", delegate_type.GetSignatureForError(), Parameters.Count.ToString());
				return false;
			}
			bool flag = !HasExplicitParameters;
			bool flag2 = false;
			for (int i = 0; i < Parameters.Count; i++)
			{
				Parameter.Modifier modFlags = invoke_pd.FixedParameters[i].ModFlags;
				if (Parameters.FixedParameters[i].ModFlags != modFlags && modFlags != Parameter.Modifier.PARAMS)
				{
					if (ignore_errors)
					{
						return false;
					}
					if (modFlags == Parameter.Modifier.NONE)
					{
						ec.Report.Error(1677, Parameters[i].Location, "Parameter `{0}' should not be declared with the `{1}' keyword", (i + 1).ToString(), Parameter.GetModifierSignature(Parameters[i].ModFlags));
					}
					else
					{
						ec.Report.Error(1676, Parameters[i].Location, "Parameter `{0}' must be declared with the `{1}' keyword", (i + 1).ToString(), Parameter.GetModifierSignature(modFlags));
					}
					flag2 = true;
				}
				if (flag)
				{
					continue;
				}
				TypeSpec typeSpec = invoke_pd.Types[i];
				if (tic != null)
				{
					typeSpec = tic.InflateGenericArgument(ec, typeSpec);
				}
				if (!TypeSpecComparer.IsEqual(typeSpec, Parameters.Types[i]))
				{
					if (ignore_errors)
					{
						return false;
					}
					ec.Report.Error(1678, Parameters[i].Location, "Parameter `{0}' is declared as type `{1}' but should be `{2}'", (i + 1).ToString(), Parameters.Types[i].GetSignatureForError(), invoke_pd.Types[i].GetSignatureForError());
					flag2 = true;
				}
			}
			return !flag2;
		}

		public bool ExplicitTypeInference(TypeInferenceContext type_inference, TypeSpec delegate_type)
		{
			if (!HasExplicitParameters)
			{
				return false;
			}
			if (!delegate_type.IsDelegate)
			{
				if (!delegate_type.IsExpressionTreeType)
				{
					return false;
				}
				delegate_type = TypeManager.GetTypeArguments(delegate_type)[0];
				if (!delegate_type.IsDelegate)
				{
					return false;
				}
			}
			AParametersCollection parameters = Delegate.GetParameters(delegate_type);
			if (parameters.Count != Parameters.Count)
			{
				return false;
			}
			TypeSpec[] types = Parameters.Types;
			TypeSpec[] types2 = parameters.Types;
			for (int i = 0; i < Parameters.Count; i++)
			{
				if (type_inference.ExactInference(types[i], types2[i]) == 0 && types[i] != types2[i])
				{
					return false;
				}
			}
			return true;
		}

		public TypeSpec InferReturnType(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type)
		{
			if (compatibles.TryGetValue(delegate_type, out var value))
			{
				return (!(value is AnonymousExpression anonymousExpression)) ? null : anonymousExpression.ReturnType;
			}
			AnonymousExpression anonymousExpression2;
			using (ec.Set(ResolveContext.Options.ProbingMode | ResolveContext.Options.InferReturnType))
			{
				ReportPrinter printer = ((TypeInferenceReportPrinter == null) ? null : ec.Report.SetPrinter(TypeInferenceReportPrinter));
				HashSet<LocalVariable> undeclaredVariables = null;
				AnonymousMethodBody anonymousMethodBody = CompatibleMethodBody(ec, tic, null, delegate_type, ref undeclaredVariables);
				anonymousExpression2 = anonymousMethodBody?.Compatible(ec, anonymousMethodBody);
				if (TypeInferenceReportPrinter != null)
				{
					ec.Report.SetPrinter(printer);
				}
				if (undeclaredVariables != null)
				{
					anonymousMethodBody.Block.TopBlock.SetUndeclaredVariables(undeclaredVariables);
				}
			}
			return anonymousExpression2?.ReturnType;
		}

		public override bool ContainsEmitWithAwait()
		{
			return false;
		}

		public Expression Compatible(ResolveContext ec, TypeSpec type)
		{
			if (compatibles.TryGetValue(type, out var value))
			{
				return value;
			}
			if (type == InternalType.ErrorType)
			{
				return null;
			}
			TypeSpec typeSpec = CompatibleChecks(ec, type);
			if (typeSpec == null)
			{
				return null;
			}
			MethodSpec invokeMethod = Delegate.GetInvokeMethod(typeSpec);
			TypeSpec returnType = invokeMethod.ReturnType;
			HashSet<LocalVariable> undeclaredVariables = null;
			AnonymousMethodBody anonymousMethodBody = CompatibleMethodBody(ec, null, returnType, typeSpec, ref undeclaredVariables);
			if (anonymousMethodBody == null)
			{
				return null;
			}
			bool flag = typeSpec != type;
			try
			{
				if (flag)
				{
					if (ec.HasSet(ResolveContext.Options.ExpressionTreeConversion))
					{
						value = anonymousMethodBody.Compatible(ec, ec.CurrentAnonymousMethod);
						if (value != null)
						{
							value = new Quote(value);
						}
					}
					else
					{
						int errors = ec.Report.Errors;
						if (Block.IsAsync)
						{
							ec.Report.Error(1989, loc, "Async lambda expressions cannot be converted to expression trees");
						}
						using (ec.Set(ResolveContext.Options.ExpressionTreeConversion))
						{
							value = anonymousMethodBody.Compatible(ec);
						}
						if (value != null && errors == ec.Report.Errors)
						{
							value = CreateExpressionTree(ec, typeSpec);
						}
					}
				}
				else
				{
					value = anonymousMethodBody.Compatible(ec);
					if (anonymousMethodBody.DirectMethodGroupConversion != null)
					{
						SessionReportPrinter sessionReportPrinter = new SessionReportPrinter();
						ReportPrinter printer = ec.Report.SetPrinter(sessionReportPrinter);
						Expression expression = new ImplicitDelegateCreation(typeSpec, anonymousMethodBody.DirectMethodGroupConversion, loc)
						{
							AllowSpecialMethodsInvocation = true
						}.Resolve(ec);
						ec.Report.SetPrinter(printer);
						if (expression != null && sessionReportPrinter.ErrorsCount == 0)
						{
							value = expression;
						}
					}
				}
			}
			catch (CompletionResult)
			{
				throw;
			}
			catch (FatalException)
			{
				throw;
			}
			catch (Exception e)
			{
				throw new InternalErrorException(e, loc);
			}
			finally
			{
				if (undeclaredVariables != null)
				{
					anonymousMethodBody.Block.TopBlock.SetUndeclaredVariables(undeclaredVariables);
				}
			}
			if (!ec.IsInProbingMode && !flag)
			{
				compatibles.Add(type, value ?? EmptyExpression.Null);
			}
			return value;
		}

		protected virtual Expression CreateExpressionTree(ResolveContext ec, TypeSpec delegate_type)
		{
			return CreateExpressionTree(ec);
		}

		public override Expression CreateExpressionTree(ResolveContext ec)
		{
			ec.Report.Error(1946, loc, "An anonymous method cannot be converted to an expression tree");
			return null;
		}

		protected virtual ParametersCompiled ResolveParameters(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type)
		{
			AParametersCollection parameters = Delegate.GetParameters(delegate_type);
			if (Parameters == ParametersCompiled.Undefined)
			{
				Parameter[] array = new Parameter[parameters.Count];
				for (int i = 0; i < parameters.Count; i++)
				{
					Parameter.Modifier modFlags = parameters.FixedParameters[i].ModFlags;
					if ((modFlags & Parameter.Modifier.OUT) != 0)
					{
						if (!ec.IsInProbingMode)
						{
							ec.Report.Error(1688, loc, "Cannot convert anonymous method block without a parameter list to delegate type `{0}' because it has one or more `out' parameters", delegate_type.GetSignatureForError());
						}
						return null;
					}
					array[i] = new Parameter(new TypeExpression(parameters.Types[i], loc), null, parameters.FixedParameters[i].ModFlags, null, loc);
				}
				return ParametersCompiled.CreateFullyResolved(array, parameters.Types);
			}
			if (!VerifyExplicitParameters(ec, tic, delegate_type, parameters))
			{
				return null;
			}
			return Parameters;
		}

		protected override Expression DoResolve(ResolveContext rc)
		{
			if (rc.HasSet(ResolveContext.Options.ConstantScope))
			{
				rc.Report.Error(1706, loc, "Anonymous methods and lambda expressions cannot be used in the current context");
				return null;
			}
			if (rc.HasAny(ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer) && rc.CurrentMemberDefinition.Parent.PartialContainer.PrimaryConstructorParameters != null)
			{
				ToplevelBlock topBlock = rc.ConstructorBlock.ParametersBlock.TopBlock;
				if (Block.TopBlock != topBlock)
				{
					Block block = Block;
					while (block.Parent != Block.TopBlock && block != Block.TopBlock)
					{
						block = block.Parent;
					}
					block.Parent = topBlock;
					topBlock.IncludeBlock(Block, Block.TopBlock);
					block.ParametersBlock.TopBlock = topBlock;
				}
			}
			eclass = ExprClass.Value;
			type = InternalType.AnonymousMethod;
			if (!DoResolveParameters(rc))
			{
				return null;
			}
			return this;
		}

		protected virtual bool DoResolveParameters(ResolveContext rc)
		{
			return Parameters.Resolve(rc);
		}

		public override void Emit(EmitContext ec)
		{
		}

		public static void Error_AddressOfCapturedVar(ResolveContext rc, IVariableReference var, Location loc)
		{
			if (!(rc.CurrentAnonymousMethod is AsyncInitializer))
			{
				rc.Report.Error(1686, loc, "Local variable or parameter `{0}' cannot have their address taken and be used inside an anonymous method, lambda expression or query expression", var.Name);
			}
		}

		public override string GetSignatureForError()
		{
			return ExprClassName;
		}

		private AnonymousMethodBody CompatibleMethodBody(ResolveContext ec, TypeInferenceContext tic, TypeSpec return_type, TypeSpec delegate_type, ref HashSet<LocalVariable> undeclaredVariables)
		{
			ParametersCompiled parametersCompiled = ResolveParameters(ec, tic, delegate_type);
			if (parametersCompiled == null)
			{
				return null;
			}
			ParametersBlock parametersBlock = (ec.IsInProbingMode ? ((ParametersBlock)Block.PerformClone(ref undeclaredVariables)) : Block);
			if (parametersBlock.IsAsync)
			{
				if (return_type != null && return_type.Kind != MemberKind.Void && return_type != ec.Module.PredefinedTypes.Task.TypeSpec && !return_type.IsGenericTask)
				{
					ec.Report.Error(4010, loc, "Cannot convert async {0} to delegate type `{1}'", GetSignatureForError(), delegate_type.GetSignatureForError());
					return null;
				}
				parametersBlock = parametersBlock.ConvertToAsyncTask(ec, ec.CurrentMemberDefinition.Parent.PartialContainer, parametersCompiled, return_type, delegate_type, loc);
			}
			return CompatibleMethodFactory(return_type ?? InternalType.ErrorType, delegate_type, parametersCompiled, parametersBlock);
		}

		protected virtual AnonymousMethodBody CompatibleMethodFactory(TypeSpec return_type, TypeSpec delegate_type, ParametersCompiled p, ParametersBlock b)
		{
			return new AnonymousMethodBody(p, b, return_type, delegate_type, loc);
		}

		protected override void CloneTo(CloneContext clonectx, Expression t)
		{
			AnonymousMethodExpression anonymousMethodExpression = (AnonymousMethodExpression)t;
			anonymousMethodExpression.Block = (ParametersBlock)clonectx.LookupBlock(Block);
		}

		public override object Accept(StructuralVisitor visitor)
		{
			return visitor.Visit(this);
		}
	}
	public abstract class AnonymousExpression : ExpressionStatement
	{
		protected class AnonymousMethodMethod : Method
		{
			public readonly AnonymousExpression AnonymousMethod;

			public readonly AnonymousMethodStorey Storey;

			public AnonymousMethodMethod(TypeDefinition parent, AnonymousExpression am, AnonymousMethodStorey storey, TypeExpr return_type, Modifiers mod, MemberName name, ParametersCompiled parameters)
				: base(parent, return_type, mod | Modifiers.COMPILER_GENERATED, name, parameters, null)
			{
				AnonymousMethod = am;
				Storey = storey;
				Parent.PartialContainer.Members.Add(this);
				base.Block = new ToplevelBlock(am.block, parameters);
			}

			public override EmitContext CreateEmitContext(ILGenerator ig, SourceMethodBuilder sourceMethod)
			{
				EmitContext emitContext = new EmitContext(this, ig, base.ReturnType, sourceMethod);
				emitContext.CurrentAnonymousMethod = AnonymousMethod;
				return emitContext;
			}

			protected override void DefineTypeParameters()
			{
			}

			protect

System.CodeDom.dll

Decompiled 2 days ago
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using FxResources.System.CodeDom;
using Microsoft.CSharp;
using Microsoft.CodeAnalysis;
using Microsoft.VisualBasic;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyDefaultAlias("System.CodeDom")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: CLSCompliant(true)]
[assembly: UnsupportedOSPlatform("browser")]
[assembly: UnsupportedOSPlatform("ios")]
[assembly: UnsupportedOSPlatform("tvos")]
[assembly: UnsupportedOSPlatform("maccatalyst")]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("Provides types that can be used to model the structure of a source code document and to output source code for that model in a supported language.\r\n\r\nCommonly Used Types:\r\nSystem.CodeDom.CodeObject\r\nSystem.CodeDom.Compiler.CodeDomProvider\r\nMicrosoft.CSharp.CSharpCodeProvider\r\nMicrosoft.VisualBasic.VBCodeProvider")]
[assembly: AssemblyFileVersion("7.0.22.51805")]
[assembly: AssemblyInformationalVersion("7.0.0+d099f075e45d2aa6007a22b71b45a08758559f80")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.CodeDom")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/runtime")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("7.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: System.Runtime.CompilerServices.NullablePublicOnly(false)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class NullablePublicOnlyAttribute : Attribute
	{
		public readonly bool IncludesInternals;

		public NullablePublicOnlyAttribute(bool P_0)
		{
			IncludesInternals = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace FxResources.System.CodeDom
{
	internal static class SR
	{
	}
}
namespace System
{
	internal abstract class CSharpHelpers
	{
		private static readonly HashSet<string> s_fixedStringLookup = new HashSet<string>
		{
			"as", "do", "if", "in", "is", "for", "int", "new", "out", "ref",
			"try", "base", "bool", "byte", "case", "char", "else", "enum", "goto", "lock",
			"long", "null", "this", "true", "uint", "void", "break", "catch", "class", "const",
			"event", "false", "fixed", "float", "sbyte", "short", "throw", "ulong", "using", "where",
			"while", "yield", "double", "extern", "object", "params", "public", "return", "sealed", "sizeof",
			"static", "string", "struct", "switch", "typeof", "unsafe", "ushort", "checked", "decimal", "default",
			"finally", "foreach", "partial", "private", "virtual", "abstract", "continue", "delegate", "explicit", "implicit",
			"internal", "operator", "override", "readonly", "volatile", "__arglist", "__makeref", "__reftype", "interface", "namespace",
			"protected", "unchecked", "__refvalue", "stackalloc"
		};

		public static string CreateEscapedIdentifier(string name)
		{
			if (IsKeyword(name) || IsPrefixTwoUnderscore(name))
			{
				return "@" + name;
			}
			return name;
		}

		public static bool IsValidLanguageIndependentIdentifier(string value)
		{
			return IsValidTypeNameOrIdentifier(value, isTypeName: false);
		}

		internal static bool IsKeyword(string value)
		{
			return s_fixedStringLookup.Contains(value);
		}

		internal static bool IsPrefixTwoUnderscore(string value)
		{
			if (value.Length < 3)
			{
				return false;
			}
			if (value[0] == '_' && value[1] == '_')
			{
				return value[2] != '_';
			}
			return false;
		}

		internal static bool IsValidTypeNameOrIdentifier(string value, bool isTypeName)
		{
			bool nextMustBeStartChar = true;
			if (string.IsNullOrEmpty(value))
			{
				return false;
			}
			foreach (char c in value)
			{
				switch (CharUnicodeInfo.GetUnicodeCategory(c))
				{
				case UnicodeCategory.UppercaseLetter:
				case UnicodeCategory.LowercaseLetter:
				case UnicodeCategory.TitlecaseLetter:
				case UnicodeCategory.ModifierLetter:
				case UnicodeCategory.OtherLetter:
				case UnicodeCategory.LetterNumber:
					nextMustBeStartChar = false;
					break;
				case UnicodeCategory.NonSpacingMark:
				case UnicodeCategory.SpacingCombiningMark:
				case UnicodeCategory.DecimalDigitNumber:
				case UnicodeCategory.ConnectorPunctuation:
					if (nextMustBeStartChar && c != '_')
					{
						return false;
					}
					nextMustBeStartChar = false;
					break;
				default:
					if (!isTypeName || !IsSpecialTypeChar(c, ref nextMustBeStartChar))
					{
						return false;
					}
					break;
				}
			}
			return true;
		}

		internal static bool IsSpecialTypeChar(char ch, ref bool nextMustBeStartChar)
		{
			switch (ch)
			{
			case '$':
			case '&':
			case '*':
			case '+':
			case ',':
			case '-':
			case '.':
			case ':':
			case '<':
			case '>':
			case '[':
			case ']':
				nextMustBeStartChar = true;
				return true;
			case '`':
				return true;
			default:
				return false;
			}
		}
	}
	internal static class SR
	{
		private static readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out var isEnabled) && isEnabled;

		private static ResourceManager s_resourceManager;

		internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR)));

		internal static string CodeDomProvider_NotDefined => GetResourceString("CodeDomProvider_NotDefined");

		internal static string NotSupported_CodeDomAPI => GetResourceString("NotSupported_CodeDomAPI");

		internal static string CodeGenOutputWriter => GetResourceString("CodeGenOutputWriter");

		internal static string CodeGenReentrance => GetResourceString("CodeGenReentrance");

		internal static string InvalidElementType => GetResourceString("InvalidElementType");

		internal static string Argument_NullComment => GetResourceString("Argument_NullComment");

		internal static string InvalidPrimitiveType => GetResourceString("InvalidPrimitiveType");

		internal static string InvalidIdentifier => GetResourceString("InvalidIdentifier");

		internal static string ArityDoesntMatch => GetResourceString("ArityDoesntMatch");

		internal static string InvalidNullEmptyArgument => GetResourceString("InvalidNullEmptyArgument");

		internal static string DuplicateFileName => GetResourceString("DuplicateFileName");

		internal static string InvalidTypeName => GetResourceString("InvalidTypeName");

		internal static string InvalidRegion => GetResourceString("InvalidRegion");

		internal static string InvalidPathCharsInChecksum => GetResourceString("InvalidPathCharsInChecksum");

		internal static string ExecTimeout => GetResourceString("ExecTimeout");

		internal static string Provider_does_not_support_options => GetResourceString("Provider_does_not_support_options");

		internal static string InvalidLanguageIdentifier => GetResourceString("InvalidLanguageIdentifier");

		internal static string toStringUnknown => GetResourceString("toStringUnknown");

		internal static string AutoGen_Comment_Line1 => GetResourceString("AutoGen_Comment_Line1");

		internal static string AutoGen_Comment_Line2 => GetResourceString("AutoGen_Comment_Line2");

		internal static string AutoGen_Comment_Line4 => GetResourceString("AutoGen_Comment_Line4");

		internal static string AutoGen_Comment_Line5 => GetResourceString("AutoGen_Comment_Line5");

		private static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

		internal static string GetResourceString(string resourceKey)
		{
			if (UsingResourceKeys())
			{
				return resourceKey;
			}
			string result = null;
			try
			{
				result = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			return result;
		}

		internal static string GetResourceString(string resourceKey, string defaultString)
		{
			string resourceString = GetResourceString(resourceKey);
			if (!(resourceKey == resourceString) && resourceString != null)
			{
				return resourceString;
			}
			return defaultString;
		}

		internal static string Format(string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(resourceFormat, p1);
		}

		internal static string Format(string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(resourceFormat, p1, p2);
		}

		internal static string Format(string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(resourceFormat, p1, p2, p3);
		}

		internal static string Format(string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + ", " + string.Join(", ", args);
				}
				return string.Format(resourceFormat, args);
			}
			return resourceFormat;
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(provider, resourceFormat, p1);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(provider, resourceFormat, p1, p2);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(provider, resourceFormat, p1, p2, p3);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + ", " + string.Join(", ", args);
				}
				return string.Format(provider, resourceFormat, args);
			}
			return resourceFormat;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace System.Runtime.Versioning
{
	internal abstract class OSPlatformAttribute : Attribute
	{
		public string PlatformName { get; }

		private protected OSPlatformAttribute(string platformName)
		{
			PlatformName = platformName;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
	internal sealed class TargetPlatformAttribute : OSPlatformAttribute
	{
		public TargetPlatformAttribute(string platformName)
			: base(platformName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
	internal sealed class SupportedOSPlatformAttribute : OSPlatformAttribute
	{
		public SupportedOSPlatformAttribute(string platformName)
			: base(platformName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
	internal sealed class UnsupportedOSPlatformAttribute : OSPlatformAttribute
	{
		public string Message { get; }

		public UnsupportedOSPlatformAttribute(string platformName)
			: base(platformName)
		{
		}

		public UnsupportedOSPlatformAttribute(string platformName, string message)
			: base(platformName)
		{
			Message = message;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
	internal sealed class ObsoletedOSPlatformAttribute : OSPlatformAttribute
	{
		public string Message { get; }

		public string Url { get; set; }

		public ObsoletedOSPlatformAttribute(string platformName)
			: base(platformName)
		{
		}

		public ObsoletedOSPlatformAttribute(string platformName, string message)
			: base(platformName)
		{
			Message = message;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
	internal sealed class SupportedOSPlatformGuardAttribute : OSPlatformAttribute
	{
		public SupportedOSPlatformGuardAttribute(string platformName)
			: base(platformName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
	internal sealed class UnsupportedOSPlatformGuardAttribute : OSPlatformAttribute
	{
		public UnsupportedOSPlatformGuardAttribute(string platformName)
			: base(platformName)
		{
		}
	}
}
namespace System.Runtime.InteropServices
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	internal sealed class LibraryImportAttribute : Attribute
	{
		public string LibraryName { get; }

		public string EntryPoint { get; set; }

		public StringMarshalling StringMarshalling { get; set; }

		public Type StringMarshallingCustomType { get; set; }

		public bool SetLastError { get; set; }

		public LibraryImportAttribute(string libraryName)
		{
			LibraryName = libraryName;
		}
	}
	internal enum StringMarshalling
	{
		Custom,
		Utf8,
		Utf16
	}
}
namespace System.Collections.Specialized
{
	internal static class FixedStringLookup
	{
		internal static bool Contains(string[][] lookupTable, string value, bool ignoreCase)
		{
			int length = value.Length;
			if (length <= 0 || length - 1 >= lookupTable.Length)
			{
				return false;
			}
			string[] array = lookupTable[length - 1];
			if (array == null)
			{
				return false;
			}
			return Contains(array, value, ignoreCase);
		}

		private static bool Contains(string[] array, string value, bool ignoreCase)
		{
			int min = 0;
			int max = array.Length;
			int num = 0;
			while (num < value.Length)
			{
				char c = ((!ignoreCase) ? value[num] : char.ToLowerInvariant(value[num]));
				if (max - min <= 1)
				{
					if (c != array[min][num])
					{
						return false;
					}
					num++;
				}
				else
				{
					if (!FindCharacter(array, c, num, ref min, ref max))
					{
						return false;
					}
					num++;
				}
			}
			return true;
		}

		private static bool FindCharacter(string[] array, char value, int pos, ref int min, ref int max)
		{
			while (min < max)
			{
				int num = (min + max) / 2;
				char c = array[num][pos];
				if (value == c)
				{
					int num2 = num;
					while (num2 > min && array[num2 - 1][pos] == value)
					{
						num2--;
					}
					min = num2;
					int i;
					for (i = num + 1; i < max && array[i][pos] == value; i++)
					{
					}
					max = i;
					return true;
				}
				if (value < c)
				{
					max = num;
				}
				else
				{
					min = num + 1;
				}
			}
			return false;
		}
	}
}
namespace System.CodeDom
{
	public class CodeArgumentReferenceExpression : CodeExpression
	{
		private string _parameterName;

		public string ParameterName
		{
			get
			{
				return _parameterName ?? string.Empty;
			}
			set
			{
				_parameterName = value;
			}
		}

		public CodeArgumentReferenceExpression()
		{
		}

		public CodeArgumentReferenceExpression(string parameterName)
		{
			_parameterName = parameterName;
		}
	}
	public class CodeArrayCreateExpression : CodeExpression
	{
		private readonly CodeExpressionCollection _initializers = new CodeExpressionCollection();

		private CodeTypeReference _createType;

		public CodeTypeReference CreateType
		{
			get
			{
				return _createType ?? (_createType = new CodeTypeReference(""));
			}
			set
			{
				_createType = value;
			}
		}

		public CodeExpressionCollection Initializers => _initializers;

		public int Size { get; set; }

		public CodeExpression SizeExpression { get; set; }

		public CodeArrayCreateExpression()
		{
		}

		public CodeArrayCreateExpression(CodeTypeReference createType, params CodeExpression[] initializers)
		{
			_createType = createType;
			_initializers.AddRange(initializers);
		}

		public CodeArrayCreateExpression(string createType, params CodeExpression[] initializers)
		{
			_createType = new CodeTypeReference(createType);
			_initializers.AddRange(initializers);
		}

		public CodeArrayCreateExpression(Type createType, params CodeExpression[] initializers)
		{
			_createType = new CodeTypeReference(createType);
			_initializers.AddRange(initializers);
		}

		public CodeArrayCreateExpression(CodeTypeReference createType, int size)
		{
			_createType = createType;
			Size = size;
		}

		public CodeArrayCreateExpression(string createType, int size)
		{
			_createType = new CodeTypeReference(createType);
			Size = size;
		}

		public CodeArrayCreateExpression(Type createType, int size)
		{
			_createType = new CodeTypeReference(createType);
			Size = size;
		}

		public CodeArrayCreateExpression(CodeTypeReference createType, CodeExpression size)
		{
			_createType = createType;
			SizeExpression = size;
		}

		public CodeArrayCreateExpression(string createType, CodeExpression size)
		{
			_createType = new CodeTypeReference(createType);
			SizeExpression = size;
		}

		public CodeArrayCreateExpression(Type createType, CodeExpression size)
		{
			_createType = new CodeTypeReference(createType);
			SizeExpression = size;
		}
	}
	public class CodeArrayIndexerExpression : CodeExpression
	{
		private CodeExpressionCollection _indices;

		public CodeExpression TargetObject { get; set; }

		public CodeExpressionCollection Indices => _indices ?? (_indices = new CodeExpressionCollection());

		public CodeArrayIndexerExpression()
		{
		}

		public CodeArrayIndexerExpression(CodeExpression targetObject, params CodeExpression[] indices)
		{
			TargetObject = targetObject;
			Indices.AddRange(indices);
		}
	}
	public class CodeAssignStatement : CodeStatement
	{
		public CodeExpression Left { get; set; }

		public CodeExpression Right { get; set; }

		public CodeAssignStatement()
		{
		}

		public CodeAssignStatement(CodeExpression left, CodeExpression right)
		{
			Left = left;
			Right = right;
		}
	}
	public class CodeAttachEventStatement : CodeStatement
	{
		private CodeEventReferenceExpression _eventRef;

		public CodeEventReferenceExpression Event
		{
			get
			{
				return _eventRef ?? (_eventRef = new CodeEventReferenceExpression());
			}
			set
			{
				_eventRef = value;
			}
		}

		public CodeExpression Listener { get; set; }

		public CodeAttachEventStatement()
		{
		}

		public CodeAttachEventStatement(CodeEventReferenceExpression eventRef, CodeExpression listener)
		{
			_eventRef = eventRef;
			Listener = listener;
		}

		public CodeAttachEventStatement(CodeExpression targetObject, string eventName, CodeExpression listener)
			: this(new CodeEventReferenceExpression(targetObject, eventName), listener)
		{
		}
	}
	public class CodeAttributeArgument
	{
		private string _name;

		public string Name
		{
			get
			{
				return _name ?? string.Empty;
			}
			set
			{
				_name = value;
			}
		}

		public CodeExpression Value { get; set; }

		public CodeAttributeArgument()
		{
		}

		public CodeAttributeArgument(CodeExpression value)
		{
			Value = value;
		}

		public CodeAttributeArgument(string name, CodeExpression value)
		{
			Name = name;
			Value = value;
		}
	}
	public class CodeAttributeArgumentCollection : CollectionBase
	{
		public CodeAttributeArgument this[int index]
		{
			get
			{
				return (CodeAttributeArgument)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeAttributeArgumentCollection()
		{
		}

		public CodeAttributeArgumentCollection(CodeAttributeArgumentCollection value)
		{
			AddRange(value);
		}

		public CodeAttributeArgumentCollection(CodeAttributeArgument[] value)
		{
			AddRange(value);
		}

		public int Add(CodeAttributeArgument value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeAttributeArgument[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeAttributeArgumentCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeAttributeArgument value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeAttributeArgument[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeAttributeArgument value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeAttributeArgument value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeAttributeArgument value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeAttributeDeclaration
	{
		private string _name;

		private readonly CodeAttributeArgumentCollection _arguments = new CodeAttributeArgumentCollection();

		private CodeTypeReference _attributeType;

		public string Name
		{
			get
			{
				return _name ?? string.Empty;
			}
			set
			{
				_name = value;
				_attributeType = new CodeTypeReference(_name);
			}
		}

		public CodeAttributeArgumentCollection Arguments => _arguments;

		public CodeTypeReference AttributeType => _attributeType;

		public CodeAttributeDeclaration()
		{
		}

		public CodeAttributeDeclaration(string name)
		{
			Name = name;
		}

		public CodeAttributeDeclaration(string name, params CodeAttributeArgument[] arguments)
		{
			Name = name;
			Arguments.AddRange(arguments);
		}

		public CodeAttributeDeclaration(CodeTypeReference attributeType)
			: this(attributeType, (CodeAttributeArgument[])null)
		{
		}

		public CodeAttributeDeclaration(CodeTypeReference attributeType, params CodeAttributeArgument[] arguments)
		{
			_attributeType = attributeType;
			if (attributeType != null)
			{
				_name = attributeType.BaseType;
			}
			if (arguments != null)
			{
				Arguments.AddRange(arguments);
			}
		}
	}
	public class CodeAttributeDeclarationCollection : CollectionBase
	{
		public CodeAttributeDeclaration this[int index]
		{
			get
			{
				return (CodeAttributeDeclaration)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeAttributeDeclarationCollection()
		{
		}

		public CodeAttributeDeclarationCollection(CodeAttributeDeclarationCollection value)
		{
			AddRange(value);
		}

		public CodeAttributeDeclarationCollection(CodeAttributeDeclaration[] value)
		{
			AddRange(value);
		}

		public int Add(CodeAttributeDeclaration value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeAttributeDeclaration[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeAttributeDeclarationCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeAttributeDeclaration value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeAttributeDeclaration[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeAttributeDeclaration value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeAttributeDeclaration value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeAttributeDeclaration value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeBaseReferenceExpression : CodeExpression
	{
	}
	public class CodeBinaryOperatorExpression : CodeExpression
	{
		public CodeExpression Right { get; set; }

		public CodeExpression Left { get; set; }

		public CodeBinaryOperatorType Operator { get; set; }

		public CodeBinaryOperatorExpression()
		{
		}

		public CodeBinaryOperatorExpression(CodeExpression left, CodeBinaryOperatorType op, CodeExpression right)
		{
			Right = right;
			Operator = op;
			Left = left;
		}
	}
	public enum CodeBinaryOperatorType
	{
		Add,
		Subtract,
		Multiply,
		Divide,
		Modulus,
		Assign,
		IdentityInequality,
		IdentityEquality,
		ValueEquality,
		BitwiseOr,
		BitwiseAnd,
		BooleanOr,
		BooleanAnd,
		LessThan,
		LessThanOrEqual,
		GreaterThan,
		GreaterThanOrEqual
	}
	public class CodeCastExpression : CodeExpression
	{
		private CodeTypeReference _targetType;

		public CodeTypeReference TargetType
		{
			get
			{
				return _targetType ?? (_targetType = new CodeTypeReference(""));
			}
			set
			{
				_targetType = value;
			}
		}

		public CodeExpression Expression { get; set; }

		public CodeCastExpression()
		{
		}

		public CodeCastExpression(CodeTypeReference targetType, CodeExpression expression)
		{
			TargetType = targetType;
			Expression = expression;
		}

		public CodeCastExpression(string targetType, CodeExpression expression)
		{
			TargetType = new CodeTypeReference(targetType);
			Expression = expression;
		}

		public CodeCastExpression(Type targetType, CodeExpression expression)
		{
			TargetType = new CodeTypeReference(targetType);
			Expression = expression;
		}
	}
	public class CodeCatchClause
	{
		private CodeStatementCollection _statements;

		private CodeTypeReference _catchExceptionType;

		private string _localName;

		public string LocalName
		{
			get
			{
				return _localName ?? string.Empty;
			}
			set
			{
				_localName = value;
			}
		}

		public CodeTypeReference CatchExceptionType
		{
			get
			{
				return _catchExceptionType ?? (_catchExceptionType = new CodeTypeReference(typeof(Exception)));
			}
			set
			{
				_catchExceptionType = value;
			}
		}

		public CodeStatementCollection Statements => _statements ?? (_statements = new CodeStatementCollection());

		public CodeCatchClause()
		{
		}

		public CodeCatchClause(string localName)
		{
			_localName = localName;
		}

		public CodeCatchClause(string localName, CodeTypeReference catchExceptionType)
		{
			_localName = localName;
			_catchExceptionType = catchExceptionType;
		}

		public CodeCatchClause(string localName, CodeTypeReference catchExceptionType, params CodeStatement[] statements)
		{
			_localName = localName;
			_catchExceptionType = catchExceptionType;
			Statements.AddRange(statements);
		}
	}
	public class CodeCatchClauseCollection : CollectionBase
	{
		public CodeCatchClause this[int index]
		{
			get
			{
				return (CodeCatchClause)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeCatchClauseCollection()
		{
		}

		public CodeCatchClauseCollection(CodeCatchClauseCollection value)
		{
			AddRange(value);
		}

		public CodeCatchClauseCollection(CodeCatchClause[] value)
		{
			AddRange(value);
		}

		public int Add(CodeCatchClause value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeCatchClause[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeCatchClauseCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeCatchClause value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeCatchClause[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeCatchClause value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeCatchClause value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeCatchClause value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeChecksumPragma : CodeDirective
	{
		private string _fileName;

		public string FileName
		{
			get
			{
				return _fileName ?? string.Empty;
			}
			set
			{
				_fileName = value;
			}
		}

		public Guid ChecksumAlgorithmId { get; set; }

		public byte[] ChecksumData { get; set; }

		public CodeChecksumPragma()
		{
		}

		public CodeChecksumPragma(string fileName, Guid checksumAlgorithmId, byte[] checksumData)
		{
			_fileName = fileName;
			ChecksumAlgorithmId = checksumAlgorithmId;
			ChecksumData = checksumData;
		}
	}
	public class CodeComment : CodeObject
	{
		private string _text;

		public bool DocComment { get; set; }

		public string Text
		{
			get
			{
				return _text ?? string.Empty;
			}
			set
			{
				_text = value;
			}
		}

		public CodeComment()
		{
		}

		public CodeComment(string text)
		{
			Text = text;
		}

		public CodeComment(string text, bool docComment)
		{
			Text = text;
			DocComment = docComment;
		}
	}
	public class CodeCommentStatement : CodeStatement
	{
		public CodeComment Comment { get; set; }

		public CodeCommentStatement()
		{
		}

		public CodeCommentStatement(CodeComment comment)
		{
			Comment = comment;
		}

		public CodeCommentStatement(string text)
		{
			Comment = new CodeComment(text);
		}

		public CodeCommentStatement(string text, bool docComment)
		{
			Comment = new CodeComment(text, docComment);
		}
	}
	public class CodeCommentStatementCollection : CollectionBase
	{
		public CodeCommentStatement this[int index]
		{
			get
			{
				return (CodeCommentStatement)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeCommentStatementCollection()
		{
		}

		public CodeCommentStatementCollection(CodeCommentStatementCollection value)
		{
			AddRange(value);
		}

		public CodeCommentStatementCollection(CodeCommentStatement[] value)
		{
			AddRange(value);
		}

		public int Add(CodeCommentStatement value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeCommentStatement[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeCommentStatementCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeCommentStatement value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeCommentStatement[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeCommentStatement value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeCommentStatement value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeCommentStatement value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeCompileUnit : CodeObject
	{
		private StringCollection _assemblies;

		private CodeAttributeDeclarationCollection _attributes;

		private CodeDirectiveCollection _startDirectives;

		private CodeDirectiveCollection _endDirectives;

		public CodeNamespaceCollection Namespaces { get; } = new CodeNamespaceCollection();


		public StringCollection ReferencedAssemblies => _assemblies ?? (_assemblies = new StringCollection());

		public CodeAttributeDeclarationCollection AssemblyCustomAttributes => _attributes ?? (_attributes = new CodeAttributeDeclarationCollection());

		public CodeDirectiveCollection StartDirectives => _startDirectives ?? (_startDirectives = new CodeDirectiveCollection());

		public CodeDirectiveCollection EndDirectives => _endDirectives ?? (_endDirectives = new CodeDirectiveCollection());
	}
	public class CodeConditionStatement : CodeStatement
	{
		public CodeExpression Condition { get; set; }

		public CodeStatementCollection TrueStatements { get; } = new CodeStatementCollection();


		public CodeStatementCollection FalseStatements { get; } = new CodeStatementCollection();


		public CodeConditionStatement()
		{
		}

		public CodeConditionStatement(CodeExpression condition, params CodeStatement[] trueStatements)
		{
			Condition = condition;
			TrueStatements.AddRange(trueStatements);
		}

		public CodeConditionStatement(CodeExpression condition, CodeStatement[] trueStatements, CodeStatement[] falseStatements)
		{
			Condition = condition;
			TrueStatements.AddRange(trueStatements);
			FalseStatements.AddRange(falseStatements);
		}
	}
	public class CodeConstructor : CodeMemberMethod
	{
		public CodeExpressionCollection BaseConstructorArgs { get; } = new CodeExpressionCollection();


		public CodeExpressionCollection ChainedConstructorArgs { get; } = new CodeExpressionCollection();


		public CodeConstructor()
		{
			base.Name = ".ctor";
		}
	}
	public class CodeDefaultValueExpression : CodeExpression
	{
		private CodeTypeReference _type;

		public CodeTypeReference Type
		{
			get
			{
				return _type ?? (_type = new CodeTypeReference(""));
			}
			set
			{
				_type = value;
			}
		}

		public CodeDefaultValueExpression()
		{
		}

		public CodeDefaultValueExpression(CodeTypeReference type)
		{
			_type = type;
		}
	}
	public class CodeDelegateCreateExpression : CodeExpression
	{
		private CodeTypeReference _delegateType;

		private string _methodName;

		public CodeTypeReference DelegateType
		{
			get
			{
				return _delegateType ?? (_delegateType = new CodeTypeReference(""));
			}
			set
			{
				_delegateType = value;
			}
		}

		public CodeExpression TargetObject { get; set; }

		public string MethodName
		{
			get
			{
				return _methodName ?? string.Empty;
			}
			set
			{
				_methodName = value;
			}
		}

		public CodeDelegateCreateExpression()
		{
		}

		public CodeDelegateCreateExpression(CodeTypeReference delegateType, CodeExpression targetObject, string methodName)
		{
			_delegateType = delegateType;
			TargetObject = targetObject;
			_methodName = methodName;
		}
	}
	public class CodeDelegateInvokeExpression : CodeExpression
	{
		public CodeExpression TargetObject { get; set; }

		public CodeExpressionCollection Parameters { get; } = new CodeExpressionCollection();


		public CodeDelegateInvokeExpression()
		{
		}

		public CodeDelegateInvokeExpression(CodeExpression targetObject)
		{
			TargetObject = targetObject;
		}

		public CodeDelegateInvokeExpression(CodeExpression targetObject, params CodeExpression[] parameters)
		{
			TargetObject = targetObject;
			Parameters.AddRange(parameters);
		}
	}
	public class CodeDirectionExpression : CodeExpression
	{
		public CodeExpression Expression { get; set; }

		public FieldDirection Direction { get; set; }

		public CodeDirectionExpression()
		{
		}

		public CodeDirectionExpression(FieldDirection direction, CodeExpression expression)
		{
			Expression = expression;
			Direction = direction;
		}
	}
	public class CodeDirective : CodeObject
	{
	}
	public class CodeDirectiveCollection : CollectionBase
	{
		public CodeDirective this[int index]
		{
			get
			{
				return (CodeDirective)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeDirectiveCollection()
		{
		}

		public CodeDirectiveCollection(CodeDirectiveCollection value)
		{
			AddRange(value);
		}

		public CodeDirectiveCollection(CodeDirective[] value)
		{
			AddRange(value);
		}

		public int Add(CodeDirective value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeDirective[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeDirectiveCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeDirective value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeDirective[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeDirective value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeDirective value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeDirective value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeEntryPointMethod : CodeMemberMethod
	{
	}
	public class CodeEventReferenceExpression : CodeExpression
	{
		private string _eventName;

		public CodeExpression TargetObject { get; set; }

		public string EventName
		{
			get
			{
				return _eventName ?? string.Empty;
			}
			set
			{
				_eventName = value;
			}
		}

		public CodeEventReferenceExpression()
		{
		}

		public CodeEventReferenceExpression(CodeExpression targetObject, string eventName)
		{
			TargetObject = targetObject;
			_eventName = eventName;
		}
	}
	public class CodeExpression : CodeObject
	{
	}
	public class CodeExpressionCollection : CollectionBase
	{
		public CodeExpression this[int index]
		{
			get
			{
				return (CodeExpression)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeExpressionCollection()
		{
		}

		public CodeExpressionCollection(CodeExpressionCollection value)
		{
			AddRange(value);
		}

		public CodeExpressionCollection(CodeExpression[] value)
		{
			AddRange(value);
		}

		public int Add(CodeExpression value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeExpression[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeExpressionCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeExpression value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeExpression[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeExpression value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeExpression value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeExpression value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeExpressionStatement : CodeStatement
	{
		public CodeExpression Expression { get; set; }

		public CodeExpressionStatement()
		{
		}

		public CodeExpressionStatement(CodeExpression expression)
		{
			Expression = expression;
		}
	}
	public class CodeFieldReferenceExpression : CodeExpression
	{
		private string _fieldName;

		public CodeExpression TargetObject { get; set; }

		public string FieldName
		{
			get
			{
				return _fieldName ?? string.Empty;
			}
			set
			{
				_fieldName = value;
			}
		}

		public CodeFieldReferenceExpression()
		{
		}

		public CodeFieldReferenceExpression(CodeExpression targetObject, string fieldName)
		{
			TargetObject = targetObject;
			FieldName = fieldName;
		}
	}
	public class CodeGotoStatement : CodeStatement
	{
		private string _label;

		public string Label
		{
			get
			{
				return _label;
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					throw new ArgumentNullException("value");
				}
				_label = value;
			}
		}

		public CodeGotoStatement()
		{
		}

		public CodeGotoStatement(string label)
		{
			Label = label;
		}
	}
	public class CodeIndexerExpression : CodeExpression
	{
		private CodeExpressionCollection _indices;

		public CodeExpression TargetObject { get; set; }

		public CodeExpressionCollection Indices => _indices ?? (_indices = new CodeExpressionCollection());

		public CodeIndexerExpression()
		{
		}

		public CodeIndexerExpression(CodeExpression targetObject, params CodeExpression[] indices)
		{
			TargetObject = targetObject;
			Indices.AddRange(indices);
		}
	}
	public class CodeIterationStatement : CodeStatement
	{
		public CodeStatement InitStatement { get; set; }

		public CodeExpression TestExpression { get; set; }

		public CodeStatement IncrementStatement { get; set; }

		public CodeStatementCollection Statements { get; } = new CodeStatementCollection();


		public CodeIterationStatement()
		{
		}

		public CodeIterationStatement(CodeStatement initStatement, CodeExpression testExpression, CodeStatement incrementStatement, params CodeStatement[] statements)
		{
			InitStatement = initStatement;
			TestExpression = testExpression;
			IncrementStatement = incrementStatement;
			Statements.AddRange(statements);
		}
	}
	public class CodeLabeledStatement : CodeStatement
	{
		private string _label;

		public string Label
		{
			get
			{
				return _label ?? string.Empty;
			}
			set
			{
				_label = value;
			}
		}

		public CodeStatement Statement { get; set; }

		public CodeLabeledStatement()
		{
		}

		public CodeLabeledStatement(string label)
		{
			_label = label;
		}

		public CodeLabeledStatement(string label, CodeStatement statement)
		{
			_label = label;
			Statement = statement;
		}
	}
	public class CodeLinePragma
	{
		private string _fileName;

		public string FileName
		{
			get
			{
				return _fileName ?? string.Empty;
			}
			set
			{
				_fileName = value;
			}
		}

		public int LineNumber { get; set; }

		public CodeLinePragma()
		{
		}

		public CodeLinePragma(string fileName, int lineNumber)
		{
			FileName = fileName;
			LineNumber = lineNumber;
		}
	}
	public class CodeMemberEvent : CodeTypeMember
	{
		private CodeTypeReference _type;

		private CodeTypeReferenceCollection _implementationTypes;

		public CodeTypeReference Type
		{
			get
			{
				return _type ?? (_type = new CodeTypeReference(""));
			}
			set
			{
				_type = value;
			}
		}

		public CodeTypeReference PrivateImplementationType { get; set; }

		public CodeTypeReferenceCollection ImplementationTypes => _implementationTypes ?? (_implementationTypes = new CodeTypeReferenceCollection());
	}
	public class CodeMemberField : CodeTypeMember
	{
		private CodeTypeReference _type;

		public CodeTypeReference Type
		{
			get
			{
				return _type ?? (_type = new CodeTypeReference(""));
			}
			set
			{
				_type = value;
			}
		}

		public CodeExpression InitExpression { get; set; }

		public CodeMemberField()
		{
		}

		public CodeMemberField(CodeTypeReference type, string name)
		{
			Type = type;
			base.Name = name;
		}

		public CodeMemberField(string type, string name)
		{
			Type = new CodeTypeReference(type);
			base.Name = name;
		}

		public CodeMemberField(Type type, string name)
		{
			Type = new CodeTypeReference(type);
			base.Name = name;
		}
	}
	public class CodeMemberMethod : CodeTypeMember
	{
		private readonly CodeParameterDeclarationExpressionCollection _parameters = new CodeParameterDeclarationExpressionCollection();

		private readonly CodeStatementCollection _statements = new CodeStatementCollection();

		private CodeTypeReference _returnType;

		private CodeTypeReferenceCollection _implementationTypes;

		private CodeAttributeDeclarationCollection _returnAttributes;

		private CodeTypeParameterCollection _typeParameters;

		private int _populated;

		private const int ParametersCollection = 1;

		private const int StatementsCollection = 2;

		private const int ImplTypesCollection = 4;

		public CodeTypeReference ReturnType
		{
			get
			{
				return _returnType ?? (_returnType = new CodeTypeReference(typeof(void).FullName));
			}
			set
			{
				_returnType = value;
			}
		}

		public CodeStatementCollection Statements
		{
			get
			{
				if ((_populated & 2) == 0)
				{
					_populated |= 2;
					this.PopulateStatements?.Invoke(this, EventArgs.Empty);
				}
				return _statements;
			}
		}

		public CodeParameterDeclarationExpressionCollection Parameters
		{
			get
			{
				if ((_populated & 1) == 0)
				{
					_populated |= 1;
					this.PopulateParameters?.Invoke(this, EventArgs.Empty);
				}
				return _parameters;
			}
		}

		public CodeTypeReference PrivateImplementationType { get; set; }

		public CodeTypeReferenceCollection ImplementationTypes
		{
			get
			{
				if (_implementationTypes == null)
				{
					_implementationTypes = new CodeTypeReferenceCollection();
				}
				if ((_populated & 4) == 0)
				{
					_populated |= 4;
					this.PopulateImplementationTypes?.Invoke(this, EventArgs.Empty);
				}
				return _implementationTypes;
			}
		}

		public CodeAttributeDeclarationCollection ReturnTypeCustomAttributes => _returnAttributes ?? (_returnAttributes = new CodeAttributeDeclarationCollection());

		public CodeTypeParameterCollection TypeParameters => _typeParameters ?? (_typeParameters = new CodeTypeParameterCollection());

		public event EventHandler PopulateParameters;

		public event EventHandler PopulateStatements;

		public event EventHandler PopulateImplementationTypes;
	}
	public class CodeMemberProperty : CodeTypeMember
	{
		private CodeTypeReference _type;

		private bool _hasGet;

		private bool _hasSet;

		private CodeTypeReferenceCollection _implementationTypes;

		public CodeTypeReference PrivateImplementationType { get; set; }

		public CodeTypeReferenceCollection ImplementationTypes => _implementationTypes ?? (_implementationTypes = new CodeTypeReferenceCollection());

		public CodeTypeReference Type
		{
			get
			{
				return _type ?? (_type = new CodeTypeReference(""));
			}
			set
			{
				_type = value;
			}
		}

		public bool HasGet
		{
			get
			{
				if (!_hasGet)
				{
					return GetStatements.Count > 0;
				}
				return true;
			}
			set
			{
				_hasGet = value;
				if (!value)
				{
					GetStatements.Clear();
				}
			}
		}

		public bool HasSet
		{
			get
			{
				if (!_hasSet)
				{
					return SetStatements.Count > 0;
				}
				return true;
			}
			set
			{
				_hasSet = value;
				if (!value)
				{
					SetStatements.Clear();
				}
			}
		}

		public CodeStatementCollection GetStatements { get; } = new CodeStatementCollection();


		public CodeStatementCollection SetStatements { get; } = new CodeStatementCollection();


		public CodeParameterDeclarationExpressionCollection Parameters { get; } = new CodeParameterDeclarationExpressionCollection();

	}
	public class CodeMethodInvokeExpression : CodeExpression
	{
		private CodeMethodReferenceExpression _method;

		public CodeMethodReferenceExpression Method
		{
			get
			{
				return _method ?? (_method = new CodeMethodReferenceExpression());
			}
			set
			{
				_method = value;
			}
		}

		public CodeExpressionCollection Parameters { get; } = new CodeExpressionCollection();


		public CodeMethodInvokeExpression()
		{
		}

		public CodeMethodInvokeExpression(CodeMethodReferenceExpression method, params CodeExpression[] parameters)
		{
			_method = method;
			Parameters.AddRange(parameters);
		}

		public CodeMethodInvokeExpression(CodeExpression targetObject, string methodName, params CodeExpression[] parameters)
		{
			_method = new CodeMethodReferenceExpression(targetObject, methodName);
			Parameters.AddRange(parameters);
		}
	}
	public class CodeMethodReferenceExpression : CodeExpression
	{
		private string _methodName;

		private CodeTypeReferenceCollection _typeArguments;

		public CodeExpression TargetObject { get; set; }

		public string MethodName
		{
			get
			{
				return _methodName ?? string.Empty;
			}
			set
			{
				_methodName = value;
			}
		}

		public CodeTypeReferenceCollection TypeArguments => _typeArguments ?? (_typeArguments = new CodeTypeReferenceCollection());

		public CodeMethodReferenceExpression()
		{
		}

		public CodeMethodReferenceExpression(CodeExpression targetObject, string methodName)
		{
			TargetObject = targetObject;
			MethodName = methodName;
		}

		public CodeMethodReferenceExpression(CodeExpression targetObject, string methodName, params CodeTypeReference[] typeParameters)
		{
			TargetObject = targetObject;
			MethodName = methodName;
			if (typeParameters != null && typeParameters.Length != 0)
			{
				TypeArguments.AddRange(typeParameters);
			}
		}
	}
	public class CodeMethodReturnStatement : CodeStatement
	{
		public CodeExpression Expression { get; set; }

		public CodeMethodReturnStatement()
		{
		}

		public CodeMethodReturnStatement(CodeExpression expression)
		{
			Expression = expression;
		}
	}
	public class CodeNamespace : CodeObject
	{
		private string _name;

		private readonly CodeNamespaceImportCollection _imports = new CodeNamespaceImportCollection();

		private readonly CodeCommentStatementCollection _comments = new CodeCommentStatementCollection();

		private readonly CodeTypeDeclarationCollection _classes = new CodeTypeDeclarationCollection();

		private int _populated;

		private const int ImportsCollection = 1;

		private const int CommentsCollection = 2;

		private const int TypesCollection = 4;

		public CodeTypeDeclarationCollection Types
		{
			get
			{
				if ((_populated & 4) == 0)
				{
					_populated |= 4;
					this.PopulateTypes?.Invoke(this, EventArgs.Empty);
				}
				return _classes;
			}
		}

		public CodeNamespaceImportCollection Imports
		{
			get
			{
				if ((_populated & 1) == 0)
				{
					_populated |= 1;
					this.PopulateImports?.Invoke(this, EventArgs.Empty);
				}
				return _imports;
			}
		}

		public string Name
		{
			get
			{
				return _name ?? string.Empty;
			}
			set
			{
				_name = value;
			}
		}

		public CodeCommentStatementCollection Comments
		{
			get
			{
				if ((_populated & 2) == 0)
				{
					_populated |= 2;
					this.PopulateComments?.Invoke(this, EventArgs.Empty);
				}
				return _comments;
			}
		}

		public event EventHandler PopulateComments;

		public event EventHandler PopulateImports;

		public event EventHandler PopulateTypes;

		public CodeNamespace()
		{
		}

		public CodeNamespace(string name)
		{
			Name = name;
		}
	}
	public class CodeNamespaceCollection : CollectionBase
	{
		public CodeNamespace this[int index]
		{
			get
			{
				return (CodeNamespace)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeNamespaceCollection()
		{
		}

		public CodeNamespaceCollection(CodeNamespaceCollection value)
		{
			AddRange(value);
		}

		public CodeNamespaceCollection(CodeNamespace[] value)
		{
			AddRange(value);
		}

		public int Add(CodeNamespace value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeNamespace[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeNamespaceCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeNamespace value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeNamespace[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeNamespace value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeNamespace value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeNamespace value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeNamespaceImport : CodeObject
	{
		private string _nameSpace;

		public CodeLinePragma LinePragma { get; set; }

		public string Namespace
		{
			get
			{
				return _nameSpace ?? string.Empty;
			}
			set
			{
				_nameSpace = value;
			}
		}

		public CodeNamespaceImport()
		{
		}

		public CodeNamespaceImport(string nameSpace)
		{
			Namespace = nameSpace;
		}
	}
	public class CodeNamespaceImportCollection : IList, ICollection, IEnumerable
	{
		private readonly ArrayList _data = new ArrayList();

		private readonly Dictionary<string, CodeNamespaceImport> _keys = new Dictionary<string, CodeNamespaceImport>(StringComparer.OrdinalIgnoreCase);

		public CodeNamespaceImport this[int index]
		{
			get
			{
				return (CodeNamespaceImport)_data[index];
			}
			set
			{
				_data[index] = value;
				SyncKeys();
			}
		}

		public int Count => _data.Count;

		bool IList.IsReadOnly => false;

		bool IList.IsFixedSize => false;

		object IList.this[int index]
		{
			get
			{
				return this[index];
			}
			set
			{
				this[index] = (CodeNamespaceImport)value;
				SyncKeys();
			}
		}

		int ICollection.Count => Count;

		bool ICollection.IsSynchronized => false;

		object ICollection.SyncRoot => null;

		public void Add(CodeNamespaceImport value)
		{
			if (!_keys.ContainsKey(value.Namespace))
			{
				_keys[value.Namespace] = value;
				_data.Add(value);
			}
		}

		public void AddRange(CodeNamespaceImport[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			foreach (CodeNamespaceImport value2 in value)
			{
				Add(value2);
			}
		}

		public void Clear()
		{
			_data.Clear();
			_keys.Clear();
		}

		private void SyncKeys()
		{
			_keys.Clear();
			foreach (CodeNamespaceImport datum in _data)
			{
				_keys[datum.Namespace] = datum;
			}
		}

		public IEnumerator GetEnumerator()
		{
			return _data.GetEnumerator();
		}

		void ICollection.CopyTo(Array array, int index)
		{
			_data.CopyTo(array, index);
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		int IList.Add(object value)
		{
			return _data.Add((CodeNamespaceImport)value);
		}

		void IList.Clear()
		{
			Clear();
		}

		bool IList.Contains(object value)
		{
			return _data.Contains(value);
		}

		int IList.IndexOf(object value)
		{
			return _data.IndexOf((CodeNamespaceImport)value);
		}

		void IList.Insert(int index, object value)
		{
			_data.Insert(index, (CodeNamespaceImport)value);
			SyncKeys();
		}

		void IList.Remove(object value)
		{
			_data.Remove((CodeNamespaceImport)value);
			SyncKeys();
		}

		void IList.RemoveAt(int index)
		{
			_data.RemoveAt(index);
			SyncKeys();
		}
	}
	public class CodeObject
	{
		private IDictionary _userData;

		public IDictionary UserData => _userData ?? (_userData = new ListDictionary());
	}
	public class CodeObjectCreateExpression : CodeExpression
	{
		private CodeTypeReference _createType;

		public CodeTypeReference CreateType
		{
			get
			{
				return _createType ?? (_createType = new CodeTypeReference(""));
			}
			set
			{
				_createType = value;
			}
		}

		public CodeExpressionCollection Parameters { get; } = new CodeExpressionCollection();


		public CodeObjectCreateExpression()
		{
		}

		public CodeObjectCreateExpression(CodeTypeReference createType, params CodeExpression[] parameters)
		{
			CreateType = createType;
			Parameters.AddRange(parameters);
		}

		public CodeObjectCreateExpression(string createType, params CodeExpression[] parameters)
		{
			CreateType = new CodeTypeReference(createType);
			Parameters.AddRange(parameters);
		}

		public CodeObjectCreateExpression(Type createType, params CodeExpression[] parameters)
		{
			CreateType = new CodeTypeReference(createType);
			Parameters.AddRange(parameters);
		}
	}
	public class CodeParameterDeclarationExpression : CodeExpression
	{
		private CodeTypeReference _type;

		private string _name;

		private CodeAttributeDeclarationCollection _customAttributes;

		public CodeAttributeDeclarationCollection CustomAttributes
		{
			get
			{
				return _customAttributes ?? (_customAttributes = new CodeAttributeDeclarationCollection());
			}
			set
			{
				_customAttributes = value;
			}
		}

		public FieldDirection Direction { get; set; }

		public CodeTypeReference Type
		{
			get
			{
				return _type ?? (_type = new CodeTypeReference(""));
			}
			set
			{
				_type = value;
			}
		}

		public string Name
		{
			get
			{
				return _name ?? string.Empty;
			}
			set
			{
				_name = value;
			}
		}

		public CodeParameterDeclarationExpression()
		{
		}

		public CodeParameterDeclarationExpression(CodeTypeReference type, string name)
		{
			Type = type;
			Name = name;
		}

		public CodeParameterDeclarationExpression(string type, string name)
		{
			Type = new CodeTypeReference(type);
			Name = name;
		}

		public CodeParameterDeclarationExpression(Type type, string name)
		{
			Type = new CodeTypeReference(type);
			Name = name;
		}
	}
	public class CodeParameterDeclarationExpressionCollection : CollectionBase
	{
		public CodeParameterDeclarationExpression this[int index]
		{
			get
			{
				return (CodeParameterDeclarationExpression)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeParameterDeclarationExpressionCollection()
		{
		}

		public CodeParameterDeclarationExpressionCollection(CodeParameterDeclarationExpressionCollection value)
		{
			AddRange(value);
		}

		public CodeParameterDeclarationExpressionCollection(CodeParameterDeclarationExpression[] value)
		{
			AddRange(value);
		}

		public int Add(CodeParameterDeclarationExpression value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeParameterDeclarationExpression[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeParameterDeclarationExpressionCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeParameterDeclarationExpression value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeParameterDeclarationExpression[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeParameterDeclarationExpression value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeParameterDeclarationExpression value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeParameterDeclarationExpression value)
		{
			base.List.Remove(value);
		}
	}
	public class CodePrimitiveExpression : CodeExpression
	{
		public object Value { get; set; }

		public CodePrimitiveExpression()
		{
		}

		public CodePrimitiveExpression(object value)
		{
			Value = value;
		}
	}
	public class CodePropertyReferenceExpression : CodeExpression
	{
		private string _propertyName;

		public CodeExpression TargetObject { get; set; }

		public string PropertyName
		{
			get
			{
				return _propertyName ?? string.Empty;
			}
			set
			{
				_propertyName = value;
			}
		}

		public CodePropertyReferenceExpression()
		{
		}

		public CodePropertyReferenceExpression(CodeExpression targetObject, string propertyName)
		{
			TargetObject = targetObject;
			PropertyName = propertyName;
		}
	}
	public class CodePropertySetValueReferenceExpression : CodeExpression
	{
	}
	public class CodeRegionDirective : CodeDirective
	{
		private string _regionText;

		public string RegionText
		{
			get
			{
				return _regionText ?? string.Empty;
			}
			set
			{
				_regionText = value;
			}
		}

		public CodeRegionMode RegionMode { get; set; }

		public CodeRegionDirective()
		{
		}

		public CodeRegionDirective(CodeRegionMode regionMode, string regionText)
		{
			RegionText = regionText;
			RegionMode = regionMode;
		}
	}
	public enum CodeRegionMode
	{
		None,
		Start,
		End
	}
	public class CodeRemoveEventStatement : CodeStatement
	{
		private CodeEventReferenceExpression _eventRef;

		public CodeEventReferenceExpression Event
		{
			get
			{
				return _eventRef ?? (_eventRef = new CodeEventReferenceExpression());
			}
			set
			{
				_eventRef = value;
			}
		}

		public CodeExpression Listener { get; set; }

		public CodeRemoveEventStatement()
		{
		}

		public CodeRemoveEventStatement(CodeEventReferenceExpression eventRef, CodeExpression listener)
		{
			_eventRef = eventRef;
			Listener = listener;
		}

		public CodeRemoveEventStatement(CodeExpression targetObject, string eventName, CodeExpression listener)
		{
			_eventRef = new CodeEventReferenceExpression(targetObject, eventName);
			Listener = listener;
		}
	}
	public class CodeSnippetCompileUnit : CodeCompileUnit
	{
		private string _value;

		public string Value
		{
			get
			{
				return _value ?? string.Empty;
			}
			set
			{
				_value = value;
			}
		}

		public CodeLinePragma LinePragma { get; set; }

		public CodeSnippetCompileUnit()
		{
		}

		public CodeSnippetCompileUnit(string value)
		{
			Value = value;
		}
	}
	public class CodeSnippetExpression : CodeExpression
	{
		private string _value;

		public string Value
		{
			get
			{
				return _value ?? string.Empty;
			}
			set
			{
				_value = value;
			}
		}

		public CodeSnippetExpression()
		{
		}

		public CodeSnippetExpression(string value)
		{
			Value = value;
		}
	}
	public class CodeSnippetStatement : CodeStatement
	{
		private string _value;

		public string Value
		{
			get
			{
				return _value ?? string.Empty;
			}
			set
			{
				_value = value;
			}
		}

		public CodeSnippetStatement()
		{
		}

		public CodeSnippetStatement(string value)
		{
			Value = value;
		}
	}
	public class CodeSnippetTypeMember : CodeTypeMember
	{
		private string _text;

		public string Text
		{
			get
			{
				return _text ?? string.Empty;
			}
			set
			{
				_text = value;
			}
		}

		public CodeSnippetTypeMember()
		{
		}

		public CodeSnippetTypeMember(string text)
		{
			Text = text;
		}
	}
	public class CodeStatement : CodeObject
	{
		private CodeDirectiveCollection _startDirectives;

		private CodeDirectiveCollection _endDirectives;

		public CodeLinePragma LinePragma { get; set; }

		public CodeDirectiveCollection StartDirectives => _startDirectives ?? (_startDirectives = new CodeDirectiveCollection());

		public CodeDirectiveCollection EndDirectives => _endDirectives ?? (_endDirectives = new CodeDirectiveCollection());
	}
	public class CodeStatementCollection : CollectionBase
	{
		public CodeStatement this[int index]
		{
			get
			{
				return (CodeStatement)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeStatementCollection()
		{
		}

		public CodeStatementCollection(CodeStatementCollection value)
		{
			AddRange(value);
		}

		public CodeStatementCollection(CodeStatement[] value)
		{
			AddRange(value);
		}

		public int Add(CodeStatement value)
		{
			return base.List.Add(value);
		}

		public int Add(CodeExpression value)
		{
			return Add(new CodeExpressionStatement(value));
		}

		public void AddRange(CodeStatement[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeStatementCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeStatement value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeStatement[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeStatement value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeStatement value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeStatement value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeThisReferenceExpression : CodeExpression
	{
	}
	public class CodeThrowExceptionStatement : CodeStatement
	{
		public CodeExpression ToThrow { get; set; }

		public CodeThrowExceptionStatement()
		{
		}

		public CodeThrowExceptionStatement(CodeExpression toThrow)
		{
			ToThrow = toThrow;
		}
	}
	public class CodeTryCatchFinallyStatement : CodeStatement
	{
		public CodeStatementCollection TryStatements { get; } = new CodeStatementCollection();


		public CodeCatchClauseCollection CatchClauses { get; } = new CodeCatchClauseCollection();


		public CodeStatementCollection FinallyStatements { get; } = new CodeStatementCollection();


		public CodeTryCatchFinallyStatement()
		{
		}

		public CodeTryCatchFinallyStatement(CodeStatement[] tryStatements, CodeCatchClause[] catchClauses)
		{
			TryStatements.AddRange(tryStatements);
			CatchClauses.AddRange(catchClauses);
		}

		public CodeTryCatchFinallyStatement(CodeStatement[] tryStatements, CodeCatchClause[] catchClauses, CodeStatement[] finallyStatements)
		{
			TryStatements.AddRange(tryStatements);
			CatchClauses.AddRange(catchClauses);
			FinallyStatements.AddRange(finallyStatements);
		}
	}
	public class CodeTypeConstructor : CodeMemberMethod
	{
		public CodeTypeConstructor()
		{
			base.Name = ".cctor";
		}
	}
	public class CodeTypeDeclaration : CodeTypeMember
	{
		private readonly CodeTypeReferenceCollection _baseTypes = new CodeTypeReferenceCollection();

		private readonly CodeTypeMemberCollection _members = new CodeTypeMemberCollection();

		private bool _isEnum;

		private bool _isStruct;

		private int _populated;

		private const int BaseTypesCollection = 1;

		private const int MembersCollection = 2;

		private CodeTypeParameterCollection _typeParameters;

		public TypeAttributes TypeAttributes { get; set; } = TypeAttributes.Public;


		public CodeTypeReferenceCollection BaseTypes
		{
			get
			{
				if ((_populated & 1) == 0)
				{
					_populated |= 1;
					this.PopulateBaseTypes?.Invoke(this, EventArgs.Empty);
				}
				return _baseTypes;
			}
		}

		public bool IsClass
		{
			get
			{
				if ((TypeAttributes & TypeAttributes.ClassSemanticsMask) == 0 && !_isEnum)
				{
					return !_isStruct;
				}
				return false;
			}
			set
			{
				if (value)
				{
					TypeAttributes &= ~TypeAttributes.ClassSemanticsMask;
					TypeAttributes |= TypeAttributes.NotPublic;
					_isStruct = false;
					_isEnum = false;
				}
			}
		}

		public bool IsStruct
		{
			get
			{
				return _isStruct;
			}
			set
			{
				if (value)
				{
					TypeAttributes &= ~TypeAttributes.ClassSemanticsMask;
					_isEnum = false;
				}
				_isStruct = value;
			}
		}

		public bool IsEnum
		{
			get
			{
				return _isEnum;
			}
			set
			{
				if (value)
				{
					TypeAttributes &= ~TypeAttributes.ClassSemanticsMask;
					_isStruct = false;
				}
				_isEnum = value;
			}
		}

		public bool IsInterface
		{
			get
			{
				return (TypeAttributes & TypeAttributes.ClassSemanticsMask) == TypeAttributes.ClassSemanticsMask;
			}
			set
			{
				if (value)
				{
					TypeAttributes &= ~TypeAttributes.ClassSemanticsMask;
					TypeAttributes |= TypeAttributes.ClassSemanticsMask;
					_isStruct = false;
					_isEnum = false;
				}
				else
				{
					TypeAttributes &= ~TypeAttributes.ClassSemanticsMask;
				}
			}
		}

		public bool IsPartial { get; set; }

		public CodeTypeMemberCollection Members
		{
			get
			{
				if ((_populated & 2) == 0)
				{
					_populated |= 2;
					this.PopulateMembers?.Invoke(this, EventArgs.Empty);
				}
				return _members;
			}
		}

		public CodeTypeParameterCollection TypeParameters => _typeParameters ?? (_typeParameters = new CodeTypeParameterCollection());

		public event EventHandler PopulateBaseTypes;

		public event EventHandler PopulateMembers;

		public CodeTypeDeclaration()
		{
		}

		public CodeTypeDeclaration(string name)
		{
			base.Name = name;
		}
	}
	public class CodeTypeDeclarationCollection : CollectionBase
	{
		public CodeTypeDeclaration this[int index]
		{
			get
			{
				return (CodeTypeDeclaration)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeTypeDeclarationCollection()
		{
		}

		public CodeTypeDeclarationCollection(CodeTypeDeclarationCollection value)
		{
			AddRange(value);
		}

		public CodeTypeDeclarationCollection(CodeTypeDeclaration[] value)
		{
			AddRange(value);
		}

		public int Add(CodeTypeDeclaration value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeTypeDeclaration[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeTypeDeclarationCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeTypeDeclaration value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeTypeDeclaration[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeTypeDeclaration value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeTypeDeclaration value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeTypeDeclaration value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeTypeDelegate : CodeTypeDeclaration
	{
		private CodeTypeReference _returnType;

		public CodeTypeReference ReturnType
		{
			get
			{
				return _returnType ?? (_returnType = new CodeTypeReference(""));
			}
			set
			{
				_returnType = value;
			}
		}

		public CodeParameterDeclarationExpressionCollection Parameters { get; } = new CodeParameterDeclarationExpressionCollection();


		public CodeTypeDelegate()
		{
			base.TypeAttributes &= ~TypeAttributes.ClassSemanticsMask;
			base.TypeAttributes |= TypeAttributes.NotPublic;
			base.BaseTypes.Clear();
			base.BaseTypes.Add(new CodeTypeReference("System.Delegate"));
		}

		public CodeTypeDelegate(string name)
			: this()
		{
			base.Name = name;
		}
	}
	public class CodeTypeMember : CodeObject
	{
		private string _name;

		private CodeAttributeDeclarationCollection _customAttributes;

		private CodeDirectiveCollection _startDirectives;

		private CodeDirectiveCollection _endDirectives;

		public string Name
		{
			get
			{
				return _name ?? string.Empty;
			}
			set
			{
				_name = value;
			}
		}

		public MemberAttributes Attributes { get; set; } = (MemberAttributes)20482;


		public CodeAttributeDeclarationCollection CustomAttributes
		{
			get
			{
				return _customAttributes ?? (_customAttributes = new CodeAttributeDeclarationCollection());
			}
			set
			{
				_customAttributes = value;
			}
		}

		public CodeLinePragma LinePragma { get; set; }

		public CodeCommentStatementCollection Comments { get; } = new CodeCommentStatementCollection();


		public CodeDirectiveCollection StartDirectives => _startDirectives ?? (_startDirectives = new CodeDirectiveCollection());

		public CodeDirectiveCollection EndDirectives => _endDirectives ?? (_endDirectives = new CodeDirectiveCollection());
	}
	public class CodeTypeMemberCollection : CollectionBase
	{
		public CodeTypeMember this[int index]
		{
			get
			{
				return (CodeTypeMember)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeTypeMemberCollection()
		{
		}

		public CodeTypeMemberCollection(CodeTypeMemberCollection value)
		{
			AddRange(value);
		}

		public CodeTypeMemberCollection(CodeTypeMember[] value)
		{
			AddRange(value);
		}

		public int Add(CodeTypeMember value)
		{
			return base.List.Add(value);
		}

		public void AddRange(CodeTypeMember[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeTypeMemberCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeTypeMember value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeTypeMember[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeTypeMember value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeTypeMember value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeTypeMember value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeTypeOfExpression : CodeExpression
	{
		private CodeTypeReference _type;

		public CodeTypeReference Type
		{
			get
			{
				return _type ?? (_type = new CodeTypeReference(""));
			}
			set
			{
				_type = value;
			}
		}

		public CodeTypeOfExpression()
		{
		}

		public CodeTypeOfExpression(CodeTypeReference type)
		{
			Type = type;
		}

		public CodeTypeOfExpression(string type)
		{
			Type = new CodeTypeReference(type);
		}

		public CodeTypeOfExpression(Type type)
		{
			Type = new CodeTypeReference(type);
		}
	}
	public class CodeTypeParameter : CodeObject
	{
		private string _name;

		private CodeAttributeDeclarationCollection _customAttributes;

		private CodeTypeReferenceCollection _constraints;

		public string Name
		{
			get
			{
				return _name ?? string.Empty;
			}
			set
			{
				_name = value;
			}
		}

		public CodeTypeReferenceCollection Constraints => _constraints ?? (_constraints = new CodeTypeReferenceCollection());

		public CodeAttributeDeclarationCollection CustomAttributes => _customAttributes ?? (_customAttributes = new CodeAttributeDeclarationCollection());

		public bool HasConstructorConstraint { get; set; }

		public CodeTypeParameter()
		{
		}

		public CodeTypeParameter(string name)
		{
			_name = name;
		}
	}
	public class CodeTypeParameterCollection : CollectionBase
	{
		public CodeTypeParameter this[int index]
		{
			get
			{
				return (CodeTypeParameter)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeTypeParameterCollection()
		{
		}

		public CodeTypeParameterCollection(CodeTypeParameterCollection value)
		{
			AddRange(value);
		}

		public CodeTypeParameterCollection(CodeTypeParameter[] value)
		{
			AddRange(value);
		}

		public int Add(CodeTypeParameter value)
		{
			return base.List.Add(value);
		}

		public void Add(string value)
		{
			Add(new CodeTypeParameter(value));
		}

		public void AddRange(CodeTypeParameter[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeTypeParameterCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeTypeParameter value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeTypeParameter[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeTypeParameter value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeTypeParameter value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeTypeParameter value)
		{
			base.List.Remove(value);
		}
	}
	[Flags]
	public enum CodeTypeReferenceOptions
	{
		GlobalReference = 1,
		GenericTypeParameter = 2
	}
	public class CodeTypeReference : CodeObject
	{
		private string _baseType;

		private readonly bool _isInterface;

		private CodeTypeReferenceCollection _typeArguments;

		private bool _needsFixup;

		public CodeTypeReference? ArrayElementType { get; set; }

		public int ArrayRank { get; set; }

		internal int NestedArrayDepth
		{
			get
			{
				if (ArrayElementType != null)
				{
					return 1 + ArrayElementType.NestedArrayDepth;
				}
				return 0;
			}
		}

		public string BaseType
		{
			get
			{
				if (ArrayRank > 0 && ArrayElementType != null)
				{
					return ArrayElementType.BaseType;
				}
				if (string.IsNullOrEmpty(_baseType))
				{
					return string.Empty;
				}
				string baseType = _baseType;
				if (!_needsFixup || TypeArguments.Count <= 0)
				{
					return baseType;
				}
				return $"{baseType}`{(uint)TypeArguments.Count}";
			}
			set
			{
				_baseType = value;
				Initialize(_baseType);
			}
		}

		public CodeTypeReferenceOptions Options { get; set; }

		public CodeTypeReferenceCollection TypeArguments
		{
			get
			{
				if (ArrayRank > 0 && ArrayElementType != null)
				{
					return ArrayElementType.TypeArguments;
				}
				return _typeArguments ?? (_typeArguments = new CodeTypeReferenceCollection());
			}
		}

		internal bool IsInterface => _isInterface;

		public CodeTypeReference()
		{
			_baseType = string.Empty;
			ArrayRank = 0;
			ArrayElementType = null;
		}

		public CodeTypeReference(Type type)
		{
			if ((object)type == null)
			{
				throw new ArgumentNullException("type");
			}
			if (type.IsArray)
			{
				ArrayRank = type.GetArrayRank();
				ArrayElementType = new CodeTypeReference(type.GetElementType());
				_baseType = null;
			}
			else
			{
				InitializeFromType(type);
				ArrayRank = 0;
				ArrayElementType = null;
			}
			_isInterface = type.IsInterface;
		}

		public CodeTypeReference(Type type, CodeTypeReferenceOptions codeTypeReferenceOption)
			: this(type)
		{
			Options = codeTypeReferenceOption;
		}

		public CodeTypeReference(string? typeName, CodeTypeReferenceOptions codeTypeReferenceOption)
		{
			Initialize(typeName, codeTypeReferenceOption);
		}

		public CodeTypeReference(string? typeName)
		{
			Initialize(typeName);
		}

		private void InitializeFromType(Type type)
		{
			_baseType = type.Name;
			if (!type.IsGenericParameter)
			{
				Type type2 = type;
				while (type2.IsNested)
				{
					type2 = type2.DeclaringType;
					_baseType = type2.Name + "+" + _baseType;
				}
				if (!string.IsNullOrEmpty(type.Namespace))
				{
					_baseType = type.Namespace + "." + _baseType;
				}
			}
			if (type.IsGenericType && !type.ContainsGenericParameters)
			{
				Type[] genericArguments = type.GetGenericArguments();
				for (int i = 0; i < genericArguments.Length; i++)
				{
					TypeArguments.Add(new CodeTypeReference(genericArguments[i]));
				}
			}
			else if (!type.IsGenericTypeDefinition)
			{
				_needsFixup = true;
			}
		}

		private void Initialize(string typeName)
		{
			Initialize(typeName, Options);
		}

		private void Initialize(string typeName, CodeTypeReferenceOptions options)
		{
			Options = options;
			if (string.IsNullOrEmpty(typeName))
			{
				typeName = typeof(void).FullName;
				_baseType = typeName;
				ArrayRank = 0;
				ArrayElementType = null;
				return;
			}
			typeName = RipOffAssemblyInformationFromTypeName(typeName);
			int num = typeName.Length - 1;
			int num2 = num;
			_needsFixup = true;
			Queue<int> queue = new Queue<int>();
			while (num2 >= 0)
			{
				int num3 = 1;
				if (typeName[num2--] != ']')
				{
					break;
				}
				while (num2 >= 0 && typeName[num2] == ',')
				{
					num3++;
					num2--;
				}
				if (num2 < 0 || typeName[num2] != '[')
				{
					break;
				}
				queue.Enqueue(num3);
				num2--;
				num = num2;
			}
			num2 = num;
			List<CodeTypeReference> list = new List<CodeTypeReference>();
			Stack<string> stack = new Stack<string>();
			if (num2 > 0 && typeName[num2--] == ']')
			{
				_needsFixup = false;
				int num4 = 1;
				int num5 = num;
				while (num2 >= 0)
				{
					if (typeName[num2] == '[')
					{
						if (--num4 == 0)
						{
							break;
						}
					}
					else if (typeName[num2] == ']')
					{
						num4++;
					}
					else if (typeName[num2] == ',' && num4 == 1)
					{
						if (num2 + 1 < num5)
						{
							stack.Push(typeName.Substring(num2 + 1, num5 - num2 - 1));
						}
						num5 = num2;
					}
					num2--;
				}
				if (num2 > 0 && num - num2 - 1 > 0)
				{
					if (num2 + 1 < num5)
					{
						stack.Push(typeName.Substring(num2 + 1, num5 - num2 - 1));
					}
					while (stack.Count > 0)
					{
						string typeName2 = RipOffAssemblyInformationFromTypeName(stack.Pop());
						list.Add(new CodeTypeReference(typeName2));
					}
					num = num2 - 1;
				}
			}
			if (num < 0)
			{
				_baseType = typeName;
				return;
			}
			if (queue.Count > 0)
			{
				CodeTypeReference codeTypeReference = new CodeTypeReference(typeName.Substring(0, num + 1), Options);
				for (int i = 0; i < list.Count; i++)
				{
					codeTypeReference.TypeArguments.Add(list[i]);
				}
				while (queue.Count > 1)
				{
					codeTypeReference = new CodeTypeReference(codeTypeReference, queue.Dequeue());
				}
				_baseType = null;
				ArrayRank = queue.Dequeue();
				ArrayElementType = codeTypeReference;
			}
			else if (list.Count > 0)
			{
				for (int j = 0; j < list.Count; j++)
				{
					TypeArguments.Add(list[j]);
				}
				_baseType = typeName.Substring(0, num + 1);
			}
			else
			{
				_baseType = typeName;
			}
			if (_baseType != null && _baseType.IndexOf('`') != -1)
			{
				_needsFixup = false;
			}
		}

		public CodeTypeReference(string typeName, params CodeTypeReference[] typeArguments)
			: this(typeName)
		{
			if (typeArguments != null && typeArguments.Length != 0)
			{
				TypeArguments.AddRange(typeArguments);
			}
		}

		public CodeTypeReference(CodeTypeParameter typeParameter)
			: this(typeParameter?.Name)
		{
			Options = CodeTypeReferenceOptions.GenericTypeParameter;
		}

		public CodeTypeReference(string baseType, int rank)
		{
			_baseType = null;
			ArrayRank = rank;
			ArrayElementType = new CodeTypeReference(baseType);
		}

		public CodeTypeReference(CodeTypeReference arrayType, int rank)
		{
			_baseType = null;
			ArrayRank = rank;
			ArrayElementType = arrayType;
		}

		private static string RipOffAssemblyInformationFromTypeName(string typeName)
		{
			int i = 0;
			int num = typeName.Length - 1;
			string result = typeName;
			for (; i < typeName.Length && char.IsWhiteSpace(typeName[i]); i++)
			{
			}
			while (num >= 0 && char.IsWhiteSpace(typeName[num]))
			{
				num--;
			}
			if (i < num)
			{
				if (typeName[i] == '[' && typeName[num] == ']')
				{
					i++;
					num--;
				}
				if (typeName[num] != ']')
				{
					int num2 = 0;
					for (int num3 = num; num3 >= i; num3--)
					{
						if (typeName[num3] == ',')
						{
							num2++;
							if (num2 == 4)
							{
								result = typeName.Substring(i, num3 - i);
								break;
							}
						}
					}
				}
			}
			return result;
		}
	}
	public class CodeTypeReferenceCollection : CollectionBase
	{
		public CodeTypeReference this[int index]
		{
			get
			{
				return (CodeTypeReference)base.List[index];
			}
			set
			{
				base.List[index] = value;
			}
		}

		public CodeTypeReferenceCollection()
		{
		}

		public CodeTypeReferenceCollection(CodeTypeReferenceCollection value)
		{
			AddRange(value);
		}

		public CodeTypeReferenceCollection(CodeTypeReference[] value)
		{
			AddRange(value);
		}

		public int Add(CodeTypeReference value)
		{
			return base.List.Add(value);
		}

		public void Add(string value)
		{
			Add(new CodeTypeReference(value));
		}

		public void Add(Type value)
		{
			Add(new CodeTypeReference(value));
		}

		public void AddRange(CodeTypeReference[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}

		public void AddRange(CodeTypeReferenceCollection value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int count = value.Count;
			for (int i = 0; i < count; i++)
			{
				Add(value[i]);
			}
		}

		public bool Contains(CodeTypeReference value)
		{
			return base.List.Contains(value);
		}

		public void CopyTo(CodeTypeReference[] array, int index)
		{
			base.List.CopyTo(array, index);
		}

		public int IndexOf(CodeTypeReference value)
		{
			return base.List.IndexOf(value);
		}

		public void Insert(int index, CodeTypeReference value)
		{
			base.List.Insert(index, value);
		}

		public void Remove(CodeTypeReference value)
		{
			base.List.Remove(value);
		}
	}
	public class CodeTypeReferenceExpression : CodeExpression
	{
		private CodeTypeReference _type;

		public CodeTypeReference Type
		{
			get
			{
				return _type ?? (_type = new CodeTypeReference(""));
			}
			set
			{
				_type = value;
			}
		}

		public CodeTypeReferenceExpression()
		{
		}

		public CodeTypeReferenceExpression(CodeTypeReference type)
		{
			Type = type;
		}

		public CodeTypeReferenceExpression(string type)
		{
			Type = new CodeTypeReference(type);
		}

		public CodeTypeReferenceExpression(Type type)
		{
			Type = new CodeTypeReference(type);
		}
	}
	public class CodeVariableDeclarationStatement : CodeStatement
	{
		private CodeTypeReference _type;

		private string _name;

		public CodeExpression InitExpression { get; set; }

		public string Name
		{
			get
			{
				return _name ?? string.Empty;
			}
			set
			{
				_name = value;
			}
		}

		public CodeTypeReference Type
		{
			get
			{
				return _type ?? (_type = new CodeTypeReference(""));
			}
			set
			{
				_type = value;
			}
		}

		public CodeVariableDeclarationStatement()
		{
		}

		public CodeVariableDeclarationStatement(CodeTypeReference type, string name)
		{
			Type = type;
			Name = name;
		}

		public CodeVariableDeclarationStatement(string type, string name)
		{
			Type = new CodeTypeReference(type);
			Name = name;
		}

		public CodeVariableDeclarationStatement(Type type, string name)
		{
			Type = new CodeTypeReference(type);
			Name = name;
		}

		public CodeVariableDeclarationStatement(CodeTypeReference type, string name, CodeExpression initExpression)
		{
			Type = type;
			Name = name;
			InitExpression = initExpression;
		}

		public CodeVariableDeclarationStatement(string type, string name, CodeExpression initExpression)
		{
			Type = new CodeTypeReference(type);
			Name = name;
			InitExpression = initExpression;
		}

		public CodeVariableDeclarationStatement(Type type, string name, CodeExpression initExpression)
		{
			Type = new CodeTypeReference(type);
			Name = name;
			InitExpression = initExpression;
		}
	}
	public class CodeVariableReferenceExpression : CodeExpression
	{
		private string _variableName;

		public string VariableName
		{
			get
			{
				return _variableName ?? string.Empty;
			}
			set
			{
				_variableName = value;
			}
		}

		public CodeVariableReferenceExpression()
		{
		}

		public CodeVariableReferenceExpression(string variableName)
		{
			_variableName = variableName;
		}
	}
	public enum FieldDirection
	{
		In,
		Out,
		Ref
	}
	[TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
	public enum MemberAttributes
	{
		Abstract = 1,
		Final = 2,
		Static = 3,
		Override = 4,
		Const = 5,
		New = 16,
		Overloaded = 256,
		Assembly = 4096,
		FamilyAndAssembly = 8192,
		Family = 12288,
		FamilyOrAssembly = 16384,
		Private = 20480,
		Public = 24576,
		AccessMask = 61440,
		ScopeMask = 15,
		VTableMask = 240
	}
	internal static class StringExtensions
	{
		internal static bool HasCharAt(this string value, int index, char character)
		{
			if (index < value.Length)
			{
				return value[index] == character;
			}
			return false;
		}
	}
}
namespace System.CodeDom.Compiler
{
	public abstract class CodeCompiler : CodeGenerator, ICodeCompiler
	{
		protected abstract string FileExtension { get; }

		protected abstract string CompilerName { get; }

		CompilerResults ICodeCompiler.CompileAssemblyFromDom(CompilerParameters options, CodeCompileUnit e)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			try
			{
				return FromDom(options, e);
			}
			finally
			{
				options.TempFiles.SafeDelete();
			}
		}

		CompilerResults ICodeCompiler.CompileAssemblyFromFile(CompilerParameters options, string fileName)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			try
			{
				return FromFile(options, fileName);
			}
			finally
			{
				options.TempFiles.SafeDelete();
			}
		}

		CompilerResults ICodeCompiler.CompileAssemblyFromSource(CompilerParameters options, string source)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			try
			{
				return FromSource(options, source);
			}
			finally
			{
				options.TempFiles.SafeDelete();
			}
		}

		CompilerResults ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, string[] sources)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			try
			{
				return FromSourceBatch(options, sources);
			}
			finally
			{
				options.TempFiles.SafeDelete();
			}
		}

		CompilerResults ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			if (fileNames == null)
			{
				throw new ArgumentNullException("fileNames");
			}
			try
			{
				foreach (string path in fileNames)
				{
					File.OpenRead(path).Dispose();
				}
				return FromFileBatch(options, fileNames);
			}
			finally
			{
				options.TempFiles.SafeDelete();
			}
		}

		CompilerResults ICodeCompiler.CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit[] ea)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			try
			{
				return FromDomBatch(options, ea);
			}
			finally
			{
				options.TempFiles.SafeDelete();
			}
		}

		protected virtual CompilerResults FromDom(CompilerParameters options, CodeCompileUnit e)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			return FromDomBatch(options, new CodeCompileUnit[1] { e });
		}

		protected virtual CompilerResults FromFile(CompilerParameters options, string fileName)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			if (fileName == null)
			{
				throw new ArgumentNullException("fileName");
			}
			File.OpenRead(fileName).Dispose();
			return FromFileBatch(options, new string[1] { fileName });
		}

		protected virtual CompilerResults FromSource(CompilerParameters options, string source)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			return FromSourceBatch(options, new string[1] { source });
		}

		protected virtual CompilerResults FromDomBatch(CompilerParameters options, CodeCompileUnit[] ea)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			if (ea == null)
			{
				throw new ArgumentNullException("ea");
			}
			string[] array = new string[ea.Length];
			for (int i = 0; i < ea.Length; i++)
			{
				if (ea[i] == null)
				{
					continue;
				}
				ResolveReferencedAssemblies(options, ea[i]);
				array[i] = options.TempFiles.AddExtension(i + FileExtension);
				using FileStream stream = new FileStream(array[i], FileMode.Create, FileAccess.Write, FileShare.Read);
				using StreamWriter streamWriter = new StreamWriter(stream, Encoding.UTF8);
				((ICodeGenerator)this).GenerateCodeFromCompileUnit(ea[i], (TextWriter)streamWriter, base.Options);
				streamWriter.Flush();
			}
			return FromFileBatch(options, array);
		}

		private static void ResolveReferencedAssemblies(CompilerParameters options, CodeCompileUnit e)
		{
			if (e.ReferencedAssemblies.Count <= 0)
			{
				return;
			}
			StringEnumerator enumerator = e.ReferencedAssemblies.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					string current = enumerator.Current;
					if (!options.ReferencedAssemblies.Contains(current))
					{
						options.ReferencedAssemblies.Add(current);
					}
				}
			}
			finally
			{
				if (enumerator is IDisposable disposable)
				{
					disposable.Dispose();
				}
			}
		}

		protected virtual CompilerResults FromFileBatch(CompilerParameters options, string[] fileNames)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			if (fileNames == null)
			{
				throw new ArgumentNullException("fileNames");
			}
			throw new PlatformNotSupportedException();
		}

		protected abstract void ProcessCompilerOutputLine(CompilerResults results, string line);

		protected abstract string CmdArgsFromParameters(CompilerParameters options);

		protected virtual string GetResponseFileCmdArgs(CompilerParameters options, string cmdArgs)
		{
			string text = options.TempFiles.AddExtension("cmdline");
			using (FileStream stream = new FileStream(text, FileMode.Create, FileAccess.Write, FileShare.Read))
			{
				using StreamWriter streamWriter = new StreamWriter(stream, Encoding.UTF8);
				streamWriter.Write(cmdArgs);
				streamWriter.Flush();
			}
			return "@\"" + text + "\"";
		}

		protected virtual CompilerResults FromSourceBatch(CompilerParameters options, string[] sources)
		{
			if (options == null)
			{
				throw new ArgumentNullException("options");
			}
			if (sources == null)
			{
				throw new ArgumentNullException("sources");
			}
			string[] array = new string[sources.Length];
			for (int i = 0; i < sources.Length; i++)
			{
				string text = options.TempFiles.AddExtension(i + FileExtension);
				using (FileStream stream = new FileStream(text, FileMode.Create, FileAccess.Write, FileShare.Read))
				{
					using StreamWriter streamWriter = new StreamWriter(stream, Encoding.UTF8);
					streamWriter.Write(sources[i]);
					streamWriter.Flush();
				}
				array[i] = text;
			}
			return FromFileBatch(options, array);
		}

		protected static string JoinStringArray(string[] sa, string separator)
		{
			if (sa == null || sa.Length == 0)
			{
				return string.Empty;
			}
			if (sa.Length == 1)
			{
				return "\"" + sa[0] + "\"";
			}
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < sa.Length - 1; i++)
			{
				stringBuilder.Append('"');
				stringBuilder.Append(sa[i]);
				stringBuilder.Append('"');
				stringBuilder.Append(separator);
			}
			stringBuilder.Append('"');
			stringBuilder.Append(sa[^1]);
			stringBuilder.Append('"');
			return stringBuilder.ToString();
		}
	}
	[ToolboxItem(false)]
	public abstract class CodeDomProvider : Component
	{
		private sealed class ConfigurationErrorsException : SystemException
		{
			public ConfigurationErrorsException(string message)
				: base(message)
			{
			}

			public ConfigurationErrorsException(SerializationInfo info, StreamingContext context)
				: base(info, context)
			{
				throw new PlatformNotSupportedException();
			}
		}

		private static readonly Dictionary<string, CompilerInfo> s_compilerLanguages;

		private static readonly Dictionary<string, CompilerInfo> s_compilerExtensions;

		private static readonly List<CompilerInfo> s_allCompilerInfo;

		public virtual string FileExtension => string.Empty;

		public virtual LanguageOptions LanguageOptions => LanguageOptions.None;

		static CodeDomProvider()
		{
			s_compilerLanguages = new Dictionary<string, CompilerInfo>(StringComparer.OrdinalIgnoreCase);
			s_compilerExtensions = new Dictionary<string, CompilerInfo>(StringComparer.OrdinalIgnoreCase);
			s_allCompilerInfo = new List<CompilerInfo>();
			AddCompilerInfo(new CompilerInfo(new CompilerParameters
			{
				WarningLevel = 4
			}, typeof(CSharpCodeProvider).FullName)
			{
				_compilerLanguages = new string[3] { "c#", "cs", "csharp" },
				_compilerExtensions = new string[2] { ".cs", "cs" }
			});
			AddCompilerInfo(new CompilerInfo(new CompilerParameters
			{
				WarningLevel = 4
			}, typeof(VBCodeProvider).FullName)
			{
				_compilerLanguages = new string[4] { "vb", "vbs", "visualbasic", "vbscript" },
				_compilerExtensions = new string[2] { ".vb", "vb" }
			});
		}

		private static void AddCompilerInfo(CompilerInfo compilerInfo)
		{
			string[] compilerLanguages = compilerInfo._compilerLanguages;
			foreach (string key in compilerLanguages)
			{
				s_compilerLanguages[key] = compilerInfo;
			}
			string[] compilerExtensions = compilerInfo._compilerExtensions;
			foreach (string key2 in compilerExtensions)
			{
				s_compilerExtensions[key2] = compilerInfo;
			}
			s_allCompilerInfo.Add(compilerInfo);
		}

		public static CodeDomProvider CreateProvider(string language, IDictionary<string, string> providerOptions)
		{
			CompilerInfo compilerInfo = GetCompilerInfo(language);
			return compilerInfo.CreateProvider(providerOptions);
		}

		public static CodeDomProvider CreateProvider(string language)
		{
			CompilerInfo compilerInfo = GetCompilerInfo(language);
			return compilerInfo.CreateProvider();
		}

		public static string GetLanguageFromExtension(string extension)
		{
			CompilerInfo compilerInfoForExtensionNoThrow = GetCompilerInfoForExtensionNoThrow(extension);
			if (compilerInfoForExtensionNoThrow == null)
			{
				throw new ConfigurationErrorsException(System.SR.CodeDomProvider_NotDefined);
			}
			return compilerInfoForExtensionNoThrow._compilerLanguages[0];
		}

		public static bool IsDefinedLanguage(string language)
		{
			return GetCompilerInfoForLanguageNoThrow(language) != null;
		}

		public static bool IsDefinedExtension(string extension)
		{
			return GetCompilerInfoForExtensionNoThr