summaryrefslogtreecommitdiff
path: root/Runtime/Export/UnityEngineInternal/TypeInferenceRuleAttribute.cs
blob: f2c7fc21bed2b90ab6b2d9cadc5cb8d8debe5e4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;

namespace UnityEngineInternal
{
	public enum TypeInferenceRules
	{
		/// <summary>
		/// (typeof(T)) as T
		/// </summary>
		TypeReferencedByFirstArgument,

		/// <summary>
		/// (, typeof(T)) as T
		/// </summary>
		TypeReferencedBySecondArgument,

		/// <summary>
		/// (typeof(T)) as (T)
		/// </summary>
		ArrayOfTypeReferencedByFirstArgument,

		/// <summary>
		/// (T) as T
		/// </summary>
		TypeOfFirstArgument,
	}

	/// <summary>
	/// Adds a special type inference rule to a method.
	/// </summary>
	[Serializable]
	[AttributeUsage(AttributeTargets.Method)]
	public class TypeInferenceRuleAttribute : Attribute
	{
		private readonly string _rule;

		public TypeInferenceRuleAttribute(TypeInferenceRules rule)
			: this(rule.ToString())
		{
		}

		public TypeInferenceRuleAttribute(string rule)
		{
			_rule = rule;
		}

		public override string ToString()
		{
			return _rule;
		}
	}
}