forked from dreamanlan/il2cpp_ref
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Il2CppSetOptionAttribute.cs
74 lines (71 loc) · 2.89 KB
/
Il2CppSetOptionAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
namespace Unity.IL2CPP.CompilerServices
{
/// <summary>
/// The code generation options available for IL to C++ conversion.
/// Enable or disabled these with caution.
/// </summary>
public enum Option
{
/// <summary>
/// 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.
/// </summary>
NullChecks = 1,
/// <summary>
/// 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.
/// </summary>
ArrayBoundsChecks = 2,
/// <summary>
/// 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.
/// </summary>
DivideByZeroChecks = 3,
}
/// <summary>
/// Use this attribute on a 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();
/// }
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property, 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;
}
}
}