Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GenerateTestsForBurstCompatibilityAttribute.cs 5.0KB

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