using System; namespace Unity.Collections { /// /// /// [Obsolete("Use GenerateTestsForBurstCompatibility (UnityUpgradable) -> GenerateTestsForBurstCompatibilityAttribute", true)] public class BurstCompatibleAttribute : Attribute { } /// /// Documents and enforces (via generated tests) that the tagged method or property has to stay burst compatible. /// /// This attribute cannot be used with private methods or properties. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, AllowMultiple = true)] public class GenerateTestsForBurstCompatibilityAttribute : Attribute { /// /// Burst compatible compile target. /// public enum BurstCompatibleCompileTarget { /// /// Player. /// Player, /// /// Editor. /// Editor, /// /// Player and editor. /// PlayerAndEditor } /// /// Types to be used for the declared generic type or method. /// /// /// The generic type arguments are tracked separately for types and methods. Say a generic type also contains /// a generic method, like in the case of Foo<T>.Bar<U>(T baz, U blah). You must specify /// GenericTypeArguments for Foo and also for Bar to establish the concrete types for T and U. When code /// generation occurs for the Burst compatibility tests, any time T appears (in the definition of Foo) /// it will be replaced with the generic type argument you specified for Foo and whenever U appears /// (in method Bar's body) it will be replaced by whatever generic type argument you specified for the method /// Bar. /// public Type[] GenericTypeArguments { get; set; } /// /// Specifies the symbol that must be defined in order for the method to be tested for Burst compatibility. /// public string RequiredUnityDefine = null; /// /// Specifies whether code should be Burst compiled for the player, editor, or both. /// /// /// When set to BurstCompatibleCompileTarget.Editor, the generated Burst compatibility code will be /// surrounded by #if UNITY_EDITOR to ensure that the Burst compatibility test will only be executed in the /// editor. The code will be compiled with Burst function pointers. If you have a non-null RequiredUnityDefine, /// an #if with the RequiredUnityDefine will also be emitted. /// /// When set to BurstCompatibilityCompileTarget.Player, the generated Burst compatibility code will /// only be surrounded by an #if containing the RequiredUnityDefine (or nothing if RequiredUnityDefine is null). /// Instead of compiling with Burst function pointers, a player build is started where the Burst AOT compiler /// will verify the Burst compatibility. This is done to speed up Burst compilation for the compatibility tests /// since Burst function pointer compilation is not done in parallel. /// /// When set to BurstCompatibilityCompileTarget.PlayerAndEditor, the generated Burst compatibility code will /// only be surrounded by an #if containing the RequiredUnityDefine (or nothing if RequiredUnityDefine is null). /// The code will be compiled both by the editor (using Burst function pointers) and with a player build (using /// Burst AOT). /// /// For best performance of the Burst compatibility tests, prefer to use BurstCompatibilityCompileTarget.Player /// as much as possible. /// public BurstCompatibleCompileTarget CompileTarget = BurstCompatibleCompileTarget.Player; } /// /// Attribute to exclude a method from burst compatibility testing even though the containing type is. /// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor)] public class ExcludeFromBurstCompatTestingAttribute : Attribute { /// /// Reason for excluding a method from being included in generated Burst compilation tests /// public string Reason { get; set; } /// /// Create this attribute with the reason to exclude from burst compatibility testing. /// /// Reason target is not burst compatible. public ExcludeFromBurstCompatTestingAttribute(string _reason) { Reason = _reason; } } }