A game about forced loneliness, made by TACStudios
at master 106 lines 5.1 kB view raw
1using System; 2 3namespace Unity.Collections 4{ 5 /// <summary> 6 /// 7 /// </summary> 8 [Obsolete("Use GenerateTestsForBurstCompatibility (UnityUpgradable) -> GenerateTestsForBurstCompatibilityAttribute", true)] 9 public class BurstCompatibleAttribute : Attribute 10 { 11 } 12 13 /// <summary> 14 /// Documents and enforces (via generated tests) that the tagged method or property has to stay burst compatible. 15 /// </summary> 16 /// <remarks>This attribute cannot be used with private methods or properties.</remarks> 17 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, AllowMultiple = true)] 18 public class GenerateTestsForBurstCompatibilityAttribute : Attribute 19 { 20 /// <summary> 21 /// Burst compatible compile target. 22 /// </summary> 23 public enum BurstCompatibleCompileTarget 24 { 25 /// <summary> 26 /// Player. 27 /// </summary> 28 Player, 29 30 /// <summary> 31 /// Editor. 32 /// </summary> 33 Editor, 34 35 /// <summary> 36 /// Player and editor. 37 /// </summary> 38 PlayerAndEditor 39 } 40 41 /// <summary> 42 /// Types to be used for the declared generic type or method. 43 /// </summary> 44 /// <remarks> 45 /// The generic type arguments are tracked separately for types and methods. Say a generic type also contains 46 /// a generic method, like in the case of Foo&lt;T&gt;.Bar&lt;U&gt;(T baz, U blah). You must specify 47 /// GenericTypeArguments for Foo and also for Bar to establish the concrete types for T and U. When code 48 /// generation occurs for the Burst compatibility tests, any time T appears (in the definition of Foo) 49 /// it will be replaced with the generic type argument you specified for Foo and whenever U appears 50 /// (in method Bar's body) it will be replaced by whatever generic type argument you specified for the method 51 /// Bar. 52 /// </remarks> 53 public Type[] GenericTypeArguments { get; set; } 54 55 /// <summary> 56 /// Specifies the symbol that must be defined in order for the method to be tested for Burst compatibility. 57 /// </summary> 58 public string RequiredUnityDefine = null; 59 60 /// <summary> 61 /// Specifies whether code should be Burst compiled for the player, editor, or both. 62 /// </summary> 63 /// <remarks> 64 /// When set to BurstCompatibleCompileTarget.Editor, the generated Burst compatibility code will be 65 /// surrounded by #if UNITY_EDITOR to ensure that the Burst compatibility test will only be executed in the 66 /// editor. The code will be compiled with Burst function pointers. If you have a non-null RequiredUnityDefine, 67 /// an #if with the RequiredUnityDefine will also be emitted.<para/> <para/> 68 /// 69 /// When set to BurstCompatibilityCompileTarget.Player, the generated Burst compatibility code will 70 /// only be surrounded by an #if containing the RequiredUnityDefine (or nothing if RequiredUnityDefine is null). 71 /// Instead of compiling with Burst function pointers, a player build is started where the Burst AOT compiler 72 /// will verify the Burst compatibility. This is done to speed up Burst compilation for the compatibility tests 73 /// since Burst function pointer compilation is not done in parallel.<para/> <para/> 74 /// 75 /// When set to BurstCompatibilityCompileTarget.PlayerAndEditor, the generated Burst compatibility code will 76 /// only be surrounded by an #if containing the RequiredUnityDefine (or nothing if RequiredUnityDefine is null). 77 /// The code will be compiled both by the editor (using Burst function pointers) and with a player build (using 78 /// Burst AOT).<para/> <para/> 79 /// 80 /// For best performance of the Burst compatibility tests, prefer to use BurstCompatibilityCompileTarget.Player 81 /// as much as possible. 82 /// </remarks> 83 public BurstCompatibleCompileTarget CompileTarget = BurstCompatibleCompileTarget.Player; 84 } 85 86 /// <summary> 87 /// Attribute to exclude a method from burst compatibility testing even though the containing type is. 88 /// </summary> 89 [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor)] 90 public class ExcludeFromBurstCompatTestingAttribute : Attribute 91 { 92 /// <summary> 93 /// Reason for excluding a method from being included in generated Burst compilation tests 94 /// </summary> 95 public string Reason { get; set; } 96 97 /// <summary> 98 /// Create this attribute with the reason to exclude from burst compatibility testing. 99 /// </summary> 100 /// <param name="_reason">Reason target is not burst compatible.</param> 101 public ExcludeFromBurstCompatTestingAttribute(string _reason) 102 { 103 Reason = _reason; 104 } 105 } 106}