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