From c3c9d97f7def3d85b4ebef4e1284315fc44f9bd6 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Mon, 22 Jul 2024 13:09:42 +0800 Subject: [PATCH] Il2CppSetOptionAttribute --- .../MyNes.Core/Il2CppSetOptionAttribute.cs | 74 +++++++++++++++++++ .../Il2CppSetOptionAttribute.cs.meta | 11 +++ 2 files changed, 85 insertions(+) create mode 100644 AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs create mode 100644 AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs.meta diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs new file mode 100644 index 00000000..e7453df2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs @@ -0,0 +1,74 @@ +using System; + +namespace Unity.IL2CPP.CompilerServices +{ + /// + /// The code generation options available for IL to C++ conversion. + /// Enable or disabled these with caution. + /// + public enum Option + { + /// + /// Enable or disable code generation for null checks. + /// + /// Global null check support is enabled by default when il2cpp.exe + /// is launched from the Unity editor. + /// + /// Disabling this will prevent NullReferenceException exceptions from + /// being thrown in generated code. In *most* cases, code that dereferences + /// a null pointer will crash then. Sometimes the point where the crash + /// happens is later than the location where the null reference check would + /// have been emitted though. + /// + NullChecks = 1, + /// + /// Enable or disable code generation for array bounds checks. + /// + /// Global array bounds check support is enabled by default when il2cpp.exe + /// is launched from the Unity editor. + /// + /// Disabling this will prevent IndexOutOfRangeException exceptions from + /// being thrown in generated code. This will allow reading and writing to + /// memory outside of the bounds of an array without any runtime checks. + /// Disable this check with extreme caution. + /// + ArrayBoundsChecks = 2, + /// + /// Enable or disable code generation for divide by zero checks. + /// + /// Global divide by zero check support is disabled by default when il2cpp.exe + /// is launched from the Unity editor. + /// + /// Enabling this will cause DivideByZeroException exceptions to be + /// thrown in generated code. Most code doesn't need to handle this + /// exception, so it is probably safe to leave it disabled. + /// + DivideByZeroChecks = 3, + } + + /// + /// Use this attribute on an assembly, struct, class, method, or property to inform the IL2CPP code conversion utility to override the + /// global setting for one of a few different runtime checks. + /// + /// Example: + /// + /// [Il2CppSetOption(Option.NullChecks, false)] + /// public static string MethodWithNullChecksDisabled() + /// { + /// var tmp = new Object(); + /// return tmp.ToString(); + /// } + /// + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Delegate, Inherited = false, AllowMultiple = true)] + public class Il2CppSetOptionAttribute : Attribute + { + public Option Option { get; private set; } + public object Value { get; private set; } + + public Il2CppSetOptionAttribute(Option option, object value) + { + Option = option; + Value = value; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs.meta new file mode 100644 index 00000000..956232b5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1fa3bc95a1fade84eb4f44a94a7409b5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: