using System; using Godot.Collections; using Array = Godot.Collections.Array; namespace Godot.SourceGenerators.Sample; public class MustBeVariantMethods { public void MustBeVariantMethodCalls() { Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); Method(); // This call fails because generic type is not Variant-compatible. //Method(); } public void Method<[MustBeVariant] T>() { } public void MustBeVariantClasses() { new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); new ClassWithGenericVariant(); // This class fails because generic type is not Variant-compatible. //new ClassWithGenericVariant(); } } public class ClassWithGenericVariant<[MustBeVariant] T> { } public class MustBeVariantAnnotatedMethods { [GenericTypeAttribute()] public void MethodWithAttributeBool() { } [GenericTypeAttribute()] public void MethodWithAttributeChar() { } [GenericTypeAttribute()] public void MethodWithAttributeSByte() { } [GenericTypeAttribute()] public void MethodWithAttributeByte() { } [GenericTypeAttribute()] public void MethodWithAttributeInt16() { } [GenericTypeAttribute()] public void MethodWithAttributeUInt16() { } [GenericTypeAttribute()] public void MethodWithAttributeInt32() { } [GenericTypeAttribute()] public void MethodWithAttributeUInt32() { } [GenericTypeAttribute()] public void MethodWithAttributeInt64() { } [GenericTypeAttribute()] public void MethodWithAttributeUInt64() { } [GenericTypeAttribute()] public void MethodWithAttributeSingle() { } [GenericTypeAttribute()] public void MethodWithAttributeDouble() { } [GenericTypeAttribute()] public void MethodWithAttributeString() { } [GenericTypeAttribute()] public void MethodWithAttributeVector2() { } [GenericTypeAttribute()] public void MethodWithAttributeVector2I() { } [GenericTypeAttribute()] public void MethodWithAttributeRect2() { } [GenericTypeAttribute()] public void MethodWithAttributeRect2I() { } [GenericTypeAttribute()] public void MethodWithAttributeTransform2D() { } [GenericTypeAttribute()] public void MethodWithAttributeVector3() { } [GenericTypeAttribute()] public void MethodWithAttributeVector3I() { } [GenericTypeAttribute()] public void MethodWithAttributeVector4() { } [GenericTypeAttribute()] public void MethodWithAttributeVector4I() { } [GenericTypeAttribute()] public void MethodWithAttributeBasis() { } [GenericTypeAttribute()] public void MethodWithAttributeQuaternion() { } [GenericTypeAttribute()] public void MethodWithAttributeTransform3D() { } [GenericTypeAttribute()] public void MethodWithAttributeProjection() { } [GenericTypeAttribute()] public void MethodWithAttributeAabb() { } [GenericTypeAttribute()] public void MethodWithAttributeColor() { } [GenericTypeAttribute()] public void MethodWithAttributePlane() { } [GenericTypeAttribute()] public void MethodWithAttributeCallable() { } [GenericTypeAttribute()] public void MethodWithAttributeSignal() { } [GenericTypeAttribute()] public void MethodWithAttributeGodotObject() { } [GenericTypeAttribute()] public void MethodWithAttributeStringName() { } [GenericTypeAttribute()] public void MethodWithAttributeNodePath() { } [GenericTypeAttribute()] public void MethodWithAttributeRid() { } [GenericTypeAttribute()] public void MethodWithAttributeDictionary() { } [GenericTypeAttribute()] public void MethodWithAttributeArray() { } [GenericTypeAttribute()] public void MethodWithAttributeByteArray() { } [GenericTypeAttribute()] public void MethodWithAttributeInt32Array() { } [GenericTypeAttribute()] public void MethodWithAttributeInt64Array() { } [GenericTypeAttribute()] public void MethodWithAttributeSingleArray() { } [GenericTypeAttribute()] public void MethodWithAttributeDoubleArray() { } [GenericTypeAttribute()] public void MethodWithAttributeStringArray() { } [GenericTypeAttribute()] public void MethodWithAttributeVector2Array() { } [GenericTypeAttribute()] public void MethodWithAttributeVector3Array() { } [GenericTypeAttribute()] public void MethodWithAttributeColorArray() { } [GenericTypeAttribute()] public void MethodWithAttributeGodotObjectArray() { } [GenericTypeAttribute()] public void MethodWithAttributeStringNameArray() { } [GenericTypeAttribute()] public void MethodWithAttributeNodePathArray() { } [GenericTypeAttribute()] public void MethodWithAttributeRidArray() { } // This method definition fails because generic type is not Variant-compatible. /* [GenericTypeAttribute()] public void MethodWithWrongAttribute() { } */ } [GenericTypeAttribute()] public class ClassVariantAnnotatedBool { } [GenericTypeAttribute()] public class ClassVariantAnnotatedChar { } [GenericTypeAttribute()] public class ClassVariantAnnotatedSByte { } [GenericTypeAttribute()] public class ClassVariantAnnotatedByte { } [GenericTypeAttribute()] public class ClassVariantAnnotatedInt16 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedUInt16 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedInt32 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedUInt32 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedInt64 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedUInt64 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedSingle { } [GenericTypeAttribute()] public class ClassVariantAnnotatedDouble { } [GenericTypeAttribute()] public class ClassVariantAnnotatedString { } [GenericTypeAttribute()] public class ClassVariantAnnotatedVector2 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedVector2I { } [GenericTypeAttribute()] public class ClassVariantAnnotatedRect2 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedRect2I { } [GenericTypeAttribute()] public class ClassVariantAnnotatedTransform2D { } [GenericTypeAttribute()] public class ClassVariantAnnotatedVector3 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedVector3I { } [GenericTypeAttribute()] public class ClassVariantAnnotatedVector4 { } [GenericTypeAttribute()] public class ClassVariantAnnotatedVector4I { } [GenericTypeAttribute()] public class ClassVariantAnnotatedBasis { } [GenericTypeAttribute()] public class ClassVariantAnnotatedQuaternion { } [GenericTypeAttribute()] public class ClassVariantAnnotatedTransform3D { } [GenericTypeAttribute()] public class ClassVariantAnnotatedProjection { } [GenericTypeAttribute()] public class ClassVariantAnnotatedAabb { } [GenericTypeAttribute()] public class ClassVariantAnnotatedColor { } [GenericTypeAttribute()] public class ClassVariantAnnotatedPlane { } [GenericTypeAttribute()] public class ClassVariantAnnotatedCallable { } [GenericTypeAttribute()] public class ClassVariantAnnotatedSignal { } [GenericTypeAttribute()] public class ClassVariantAnnotatedGodotObject { } [GenericTypeAttribute()] public class ClassVariantAnnotatedStringName { } [GenericTypeAttribute()] public class ClassVariantAnnotatedNodePath { } [GenericTypeAttribute()] public class ClassVariantAnnotatedRid { } [GenericTypeAttribute()] public class ClassVariantAnnotatedDictionary { } [GenericTypeAttribute()] public class ClassVariantAnnotatedArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedByteArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedInt32Array { } [GenericTypeAttribute()] public class ClassVariantAnnotatedInt64Array { } [GenericTypeAttribute()] public class ClassVariantAnnotatedSingleArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedDoubleArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedStringArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedVector2Array { } [GenericTypeAttribute()] public class ClassVariantAnnotatedVector3Array { } [GenericTypeAttribute()] public class ClassVariantAnnotatedColorArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedGodotObjectArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedStringNameArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedNodePathArray { } [GenericTypeAttribute()] public class ClassVariantAnnotatedRidArray { } // This class definition fails because generic type is not Variant-compatible. /* [GenericTypeAttribute()] public class ClassNonVariantAnnotated { } */ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] public class GenericTypeAttribute<[MustBeVariant] T> : Attribute { }