Sin descripción
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.

AssemblyInfo.cs 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System.Runtime.CompilerServices;
  2. [assembly: InternalsVisibleTo("Unity.RenderPipelines.HighDefinition.Editor")]
  3. [assembly: InternalsVisibleTo("Unity.RenderPipelines.Universal.Editor")]
  4. //WARNING:
  5. // Remember to only use this shared API to cherry pick the code part that you want to
  6. // share but not go directly in user codebase project.
  7. // Every new entry here should be discussed. It is always better to have good public API.
  8. // Don't add logic in this assemblie. It is only to share private methods. Only redirection allowed.
  9. /*EXAMPLE:
  10. //In Unity.RenderPipeline.Core.Editor:
  11. namespace TestNamespace
  12. {
  13. public class PublicType
  14. {
  15. internal static void StaticDoSomething() { }
  16. internal void InstanceDoSomething() { }
  17. }
  18. internal class InternalType
  19. {
  20. internal static void StaticDoSomething() { }
  21. internal void InstanceDoSomething() { }
  22. }
  23. }
  24. //In Unity.RenderPipeline.Core.Editor.Shared:
  25. namespace TestNamespace.Shared
  26. {
  27. internal static class PublicType
  28. {
  29. public static void StaticDoSomething()
  30. => TestNamespace.PublicType.StaticDoSomething();
  31. public static void InstanceDoSomething(TestNamespace.PublicType publicType)
  32. => publicType.InstanceDoSomething();
  33. internal struct Wrapper
  34. {
  35. TestNamespace.PublicType m_wrapped;
  36. public Wrapper(TestNamespace.PublicType publicTypeInstance)
  37. => m_wrapped = publicTypeInstance;
  38. public void InstanceDoSomething()
  39. => m_wrapped.InstanceDoSomething();
  40. }
  41. }
  42. internal static class InternalType
  43. {
  44. public static void StaticDoSomething()
  45. => TestNamespace.InternalType.StaticDoSomething();
  46. public static void InstanceDoSomething(object objectCastedInternalType)
  47. => (objectCastedInternalType as TestNamespace.InternalType).InstanceDoSomething();
  48. internal struct Wrapper
  49. {
  50. TestNamespace.InternalType m_wrapped;
  51. public Wrapper(object objectCastedInternalType)
  52. => m_wrapped = objectCastedInternalType as TestNamespace.InternalType;
  53. public void InstanceDoSomething()
  54. => m_wrapped.InstanceDoSomething();
  55. }
  56. }
  57. }
  58. //In Unity.RenderPipeline.Universal.Editor:
  59. class TestPrivateAPIShared
  60. {
  61. void CallStaticMethodOfPublicType()
  62. => TestNamespace.Shared.PublicType.StaticDoSomething();
  63. void CallInstanceMethodOfPublicTypeThroughStatic()
  64. {
  65. var instance = new TestNamespace.PublicType();
  66. TestNamespace.Shared.PublicType.InstanceDoSomething(instance);
  67. }
  68. void CallInstanceMethodOfPublicTypeThroughWrapper()
  69. {
  70. var instance = new TestNamespace.PublicType();
  71. var wrapper = new TestNamespace.Shared.PublicType.Wrapper(instance);
  72. wrapper.InstanceDoSomething();
  73. }
  74. void CallStaticMethodOfInternalType()
  75. => TestNamespace.Shared.InternalType.StaticDoSomething();
  76. void CallInstanceMethodOfInternalTypeThroughStatic()
  77. {
  78. var instance = new object(); //get the object via an API instead
  79. TestNamespace.Shared.InternalType.InstanceDoSomething(instance);
  80. }
  81. void CallInstanceMethodOfInternalTypeThroughWrapper()
  82. {
  83. var instance = new object(); //get the object via an API instead
  84. var wrapper = new TestNamespace.Shared.InternalType.Wrapper(instance);
  85. wrapper.InstanceDoSomething();
  86. }
  87. }
  88. */