2 // typemanager.cs: C# type manager
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 // Ravi Pratap (ravi@ximian.com)
6 // Marek Safar (marek.safar@gmail.com)
8 // Dual licensed under the terms of the MIT X11 or GNU GPL
10 // Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
11 // Copyright 2003-2011 Novell, Inc.
12 // Copyright 2011 Xamarin Inc
16 using System.Globalization;
17 using System.Collections.Generic;
24 // All compiler built-in types (they have to exist otherwise the compiler will not work)
26 public class BuiltinTypes
28 public readonly BuiltinTypeSpec Object;
29 public readonly BuiltinTypeSpec ValueType;
30 public readonly BuiltinTypeSpec Attribute;
32 public readonly BuiltinTypeSpec Int;
33 public readonly BuiltinTypeSpec UInt;
34 public readonly BuiltinTypeSpec Long;
35 public readonly BuiltinTypeSpec ULong;
36 public readonly BuiltinTypeSpec Float;
37 public readonly BuiltinTypeSpec Double;
38 public readonly BuiltinTypeSpec Char;
39 public readonly BuiltinTypeSpec Short;
40 public readonly BuiltinTypeSpec Decimal;
41 public readonly BuiltinTypeSpec Bool;
42 public readonly BuiltinTypeSpec SByte;
43 public readonly BuiltinTypeSpec Byte;
44 public readonly BuiltinTypeSpec UShort;
45 public readonly BuiltinTypeSpec String;
47 public readonly BuiltinTypeSpec Enum;
48 public readonly BuiltinTypeSpec Delegate;
49 public readonly BuiltinTypeSpec MulticastDelegate;
50 public readonly BuiltinTypeSpec Void;
51 public readonly BuiltinTypeSpec Array;
52 public readonly BuiltinTypeSpec Type;
53 public readonly BuiltinTypeSpec IEnumerator;
54 public readonly BuiltinTypeSpec IEnumerable;
55 public readonly BuiltinTypeSpec IDisposable;
56 public readonly BuiltinTypeSpec IntPtr;
57 public readonly BuiltinTypeSpec UIntPtr;
58 public readonly BuiltinTypeSpec RuntimeFieldHandle;
59 public readonly BuiltinTypeSpec RuntimeTypeHandle;
60 public readonly BuiltinTypeSpec Exception;
63 // These are internal buil-in types which depend on other
64 // build-in type (mostly object)
66 public readonly BuiltinTypeSpec Dynamic;
68 // Predefined operators tables
69 public readonly Binary.PredefinedOperator[] OperatorsBinaryStandard;
70 public readonly Binary.PredefinedOperator[] OperatorsBinaryEquality;
71 public readonly Binary.PredefinedOperator[] OperatorsBinaryUnsafe;
72 public readonly TypeSpec[][] OperatorsUnary;
73 public readonly TypeSpec[] OperatorsUnaryMutator;
75 public readonly TypeSpec[] BinaryPromotionsTypes;
76 public readonly TypeSpec[] SwitchUserTypes;
78 readonly BuiltinTypeSpec[] types;
80 public BuiltinTypes ()
82 Object = new BuiltinTypeSpec (MemberKind.Class, "System", "Object", BuiltinTypeSpec.Type.Object);
83 ValueType = new BuiltinTypeSpec (MemberKind.Class, "System", "ValueType", BuiltinTypeSpec.Type.ValueType);
84 Attribute = new BuiltinTypeSpec (MemberKind.Class, "System", "Attribute", BuiltinTypeSpec.Type.Attribute);
86 Int = new BuiltinTypeSpec (MemberKind.Struct, "System", "Int32", BuiltinTypeSpec.Type.Int);
87 Long = new BuiltinTypeSpec (MemberKind.Struct, "System", "Int64", BuiltinTypeSpec.Type.Long);
88 UInt = new BuiltinTypeSpec (MemberKind.Struct, "System", "UInt32", BuiltinTypeSpec.Type.UInt);
89 ULong = new BuiltinTypeSpec (MemberKind.Struct, "System", "UInt64", BuiltinTypeSpec.Type.ULong);
90 Byte = new BuiltinTypeSpec (MemberKind.Struct, "System", "Byte", BuiltinTypeSpec.Type.Byte);
91 SByte = new BuiltinTypeSpec (MemberKind.Struct, "System", "SByte", BuiltinTypeSpec.Type.SByte);
92 Short = new BuiltinTypeSpec (MemberKind.Struct, "System", "Int16", BuiltinTypeSpec.Type.Short);
93 UShort = new BuiltinTypeSpec (MemberKind.Struct, "System", "UInt16", BuiltinTypeSpec.Type.UShort);
95 IEnumerator = new BuiltinTypeSpec (MemberKind.Interface, "System.Collections", "IEnumerator", BuiltinTypeSpec.Type.IEnumerator);
96 IEnumerable = new BuiltinTypeSpec (MemberKind.Interface, "System.Collections", "IEnumerable", BuiltinTypeSpec.Type.IEnumerable);
97 IDisposable = new BuiltinTypeSpec (MemberKind.Interface, "System", "IDisposable", BuiltinTypeSpec.Type.IDisposable);
99 Char = new BuiltinTypeSpec (MemberKind.Struct, "System", "Char", BuiltinTypeSpec.Type.Char);
100 String = new BuiltinTypeSpec (MemberKind.Class, "System", "String", BuiltinTypeSpec.Type.String);
101 Float = new BuiltinTypeSpec (MemberKind.Struct, "System", "Single", BuiltinTypeSpec.Type.Float);
102 Double = new BuiltinTypeSpec (MemberKind.Struct, "System", "Double", BuiltinTypeSpec.Type.Double);
103 Decimal = new BuiltinTypeSpec (MemberKind.Struct, "System", "Decimal", BuiltinTypeSpec.Type.Decimal);
104 Bool = new BuiltinTypeSpec (MemberKind.Struct, "System", "Boolean", BuiltinTypeSpec.Type.Bool);
105 IntPtr = new BuiltinTypeSpec (MemberKind.Struct, "System", "IntPtr", BuiltinTypeSpec.Type.IntPtr);
106 UIntPtr = new BuiltinTypeSpec (MemberKind.Struct, "System", "UIntPtr", BuiltinTypeSpec.Type.UIntPtr);
108 MulticastDelegate = new BuiltinTypeSpec (MemberKind.Class, "System", "MulticastDelegate", BuiltinTypeSpec.Type.MulticastDelegate);
109 Delegate = new BuiltinTypeSpec (MemberKind.Class, "System", "Delegate", BuiltinTypeSpec.Type.Delegate);
110 Enum = new BuiltinTypeSpec (MemberKind.Class, "System", "Enum", BuiltinTypeSpec.Type.Enum);
111 Array = new BuiltinTypeSpec (MemberKind.Class, "System", "Array", BuiltinTypeSpec.Type.Array);
112 Void = new BuiltinTypeSpec (MemberKind.Void, "System", "Void", BuiltinTypeSpec.Type.Other);
113 Type = new BuiltinTypeSpec (MemberKind.Class, "System", "Type", BuiltinTypeSpec.Type.Type);
114 Exception = new BuiltinTypeSpec (MemberKind.Class, "System", "Exception", BuiltinTypeSpec.Type.Exception);
115 RuntimeFieldHandle = new BuiltinTypeSpec (MemberKind.Struct, "System", "RuntimeFieldHandle", BuiltinTypeSpec.Type.Other);
116 RuntimeTypeHandle = new BuiltinTypeSpec (MemberKind.Struct, "System", "RuntimeTypeHandle", BuiltinTypeSpec.Type.Other);
118 // TODO: Maybe I should promote it to different kind for faster compares
119 Dynamic = new BuiltinTypeSpec ("dynamic", BuiltinTypeSpec.Type.Dynamic);
121 OperatorsBinaryStandard = Binary.CreateStandardOperatorsTable (this);
122 OperatorsBinaryEquality = Binary.CreateEqualityOperatorsTable (this);
123 OperatorsBinaryUnsafe = Binary.CreatePointerOperatorsTable (this);
124 OperatorsUnary = Unary.CreatePredefinedOperatorsTable (this);
125 OperatorsUnaryMutator = UnaryMutator.CreatePredefinedOperatorsTable (this);
127 BinaryPromotionsTypes = ConstantFold.CreateBinaryPromotionsTypes (this);
128 SwitchUserTypes = Switch.CreateSwitchUserTypes (this);
130 types = new BuiltinTypeSpec[] {
131 Object, ValueType, Attribute,
132 Int, UInt, Long, ULong, Float, Double, Char, Short, Decimal, Bool, SByte, Byte, UShort, String,
133 Enum, Delegate, MulticastDelegate, Void, Array, Type, IEnumerator, IEnumerable, IDisposable,
134 IntPtr, UIntPtr, RuntimeFieldHandle, RuntimeTypeHandle, Exception };
137 public BuiltinTypeSpec[] AllTypes {
143 public bool CheckDefinitions (ModuleContainer module)
145 var ctx = module.Compiler;
146 foreach (var p in types) {
147 var found = PredefinedType.Resolve (module, p.Kind, p.Namespace, p.Name, p.Arity, true, true);
148 if (found == null || found == p)
151 var tc = found.MemberDefinition as TypeDefinition;
153 var ns = module.GlobalRootNamespace.GetNamespace (p.Namespace, false);
154 ns.SetBuiltinType (p);
156 tc.SetPredefinedSpec (p);
157 p.SetDefinition (found);
161 if (ctx.Report.Errors != 0)
164 // Set internal build-in types
165 Dynamic.SetDefinition (Object);
172 // Compiler predefined types. Usually used for compiler generated
173 // code or for comparison against well known framework type. They
174 // may not exist as they are optional
176 class PredefinedTypes
178 public readonly PredefinedType ArgIterator;
179 public readonly PredefinedType TypedReference;
180 public readonly PredefinedType MarshalByRefObject;
181 public readonly PredefinedType RuntimeHelpers;
182 public readonly PredefinedType IAsyncResult;
183 public readonly PredefinedType AsyncCallback;
184 public readonly PredefinedType RuntimeArgumentHandle;
185 public readonly PredefinedType CharSet;
186 public readonly PredefinedType IsVolatile;
187 public readonly PredefinedType IEnumeratorGeneric;
188 public readonly PredefinedType IListGeneric;
189 public readonly PredefinedType ICollectionGeneric;
190 public readonly PredefinedType IEnumerableGeneric;
191 public readonly PredefinedType Nullable;
192 public readonly PredefinedType Activator;
193 public readonly PredefinedType Interlocked;
194 public readonly PredefinedType Monitor;
195 public readonly PredefinedType NotSupportedException;
196 public readonly PredefinedType RuntimeFieldHandle;
197 public readonly PredefinedType RuntimeMethodHandle;
198 public readonly PredefinedType SecurityAction;
199 public readonly PredefinedType Dictionary;
200 public readonly PredefinedType Hashtable;
205 public readonly PredefinedType Expression;
206 public readonly PredefinedType ExpressionGeneric;
207 public readonly PredefinedType ParameterExpression;
208 public readonly PredefinedType FieldInfo;
209 public readonly PredefinedType MethodBase;
210 public readonly PredefinedType MethodInfo;
211 public readonly PredefinedType ConstructorInfo;
212 public readonly PredefinedType MemberBinding;
217 public readonly PredefinedType Binder;
218 public readonly PredefinedType CallSite;
219 public readonly PredefinedType CallSiteGeneric;
220 public readonly PredefinedType BinderFlags;
225 public readonly PredefinedType AsyncVoidMethodBuilder;
226 public readonly PredefinedType AsyncTaskMethodBuilder;
227 public readonly PredefinedType AsyncTaskMethodBuilderGeneric;
228 public readonly PredefinedType Action;
229 public readonly PredefinedType Task;
230 public readonly PredefinedType TaskGeneric;
231 public readonly PredefinedType IAsyncStateMachine;
232 public readonly PredefinedType INotifyCompletion;
233 public readonly PredefinedType ICriticalNotifyCompletion;
235 public PredefinedTypes (ModuleContainer module)
237 TypedReference = new PredefinedType (module, MemberKind.Struct, "System", "TypedReference");
238 ArgIterator = new PredefinedType (module, MemberKind.Struct, "System", "ArgIterator");
240 MarshalByRefObject = new PredefinedType (module, MemberKind.Class, "System", "MarshalByRefObject");
241 RuntimeHelpers = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "RuntimeHelpers");
242 IAsyncResult = new PredefinedType (module, MemberKind.Interface, "System", "IAsyncResult");
243 AsyncCallback = new PredefinedType (module, MemberKind.Delegate, "System", "AsyncCallback");
244 RuntimeArgumentHandle = new PredefinedType (module, MemberKind.Struct, "System", "RuntimeArgumentHandle");
245 CharSet = new PredefinedType (module, MemberKind.Enum, "System.Runtime.InteropServices", "CharSet");
246 IsVolatile = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "IsVolatile");
247 IEnumeratorGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "IEnumerator", 1);
248 IListGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "IList", 1);
249 ICollectionGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "ICollection", 1);
250 IEnumerableGeneric = new PredefinedType (module, MemberKind.Interface, "System.Collections.Generic", "IEnumerable", 1);
251 Nullable = new PredefinedType (module, MemberKind.Struct, "System", "Nullable", 1);
252 Activator = new PredefinedType (module, MemberKind.Class, "System", "Activator");
253 Interlocked = new PredefinedType (module, MemberKind.Class, "System.Threading", "Interlocked");
254 Monitor = new PredefinedType (module, MemberKind.Class, "System.Threading", "Monitor");
255 NotSupportedException = new PredefinedType (module, MemberKind.Class, "System", "NotSupportedException");
256 RuntimeFieldHandle = new PredefinedType (module, MemberKind.Struct, "System", "RuntimeFieldHandle");
257 RuntimeMethodHandle = new PredefinedType (module, MemberKind.Struct, "System", "RuntimeMethodHandle");
258 SecurityAction = new PredefinedType (module, MemberKind.Enum, "System.Security.Permissions", "SecurityAction");
259 Dictionary = new PredefinedType (module, MemberKind.Class, "System.Collections.Generic", "Dictionary", 2);
260 Hashtable = new PredefinedType (module, MemberKind.Class, "System.Collections", "Hashtable");
262 Expression = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression");
263 ExpressionGeneric = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression", 1);
264 MemberBinding = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "MemberBinding");
265 ParameterExpression = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "ParameterExpression");
266 FieldInfo = new PredefinedType (module, MemberKind.Class, "System.Reflection", "FieldInfo");
267 MethodBase = new PredefinedType (module, MemberKind.Class, "System.Reflection", "MethodBase");
268 MethodInfo = new PredefinedType (module, MemberKind.Class, "System.Reflection", "MethodInfo");
269 ConstructorInfo = new PredefinedType (module, MemberKind.Class, "System.Reflection", "ConstructorInfo");
271 CallSite = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "CallSite");
272 CallSiteGeneric = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "CallSite", 1);
273 Binder = new PredefinedType (module, MemberKind.Class, "Microsoft.CSharp.RuntimeBinder", "Binder");
274 BinderFlags = new PredefinedType (module, MemberKind.Enum, "Microsoft.CSharp.RuntimeBinder", "CSharpBinderFlags");
276 Action = new PredefinedType (module, MemberKind.Delegate, "System", "Action");
277 AsyncVoidMethodBuilder = new PredefinedType (module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncVoidMethodBuilder");
278 AsyncTaskMethodBuilder = new PredefinedType (module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncTaskMethodBuilder");
279 AsyncTaskMethodBuilderGeneric = new PredefinedType (module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncTaskMethodBuilder", 1);
280 Task = new PredefinedType (module, MemberKind.Class, "System.Threading.Tasks", "Task");
281 TaskGeneric = new PredefinedType (module, MemberKind.Class, "System.Threading.Tasks", "Task", 1);
282 IAsyncStateMachine = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "IAsyncStateMachine");
283 INotifyCompletion = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "INotifyCompletion");
284 ICriticalNotifyCompletion = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "ICriticalNotifyCompletion");
287 // Define types which are used for comparison. It does not matter
288 // if they don't exist as no error report is needed
290 if (TypedReference.Define ())
291 TypedReference.TypeSpec.IsSpecialRuntimeType = true;
293 if (ArgIterator.Define ())
294 ArgIterator.TypeSpec.IsSpecialRuntimeType = true;
296 if (IEnumerableGeneric.Define ())
297 IEnumerableGeneric.TypeSpec.IsGenericIterateInterface = true;
299 if (IListGeneric.Define ())
300 IListGeneric.TypeSpec.IsGenericIterateInterface = true;
302 if (ICollectionGeneric.Define ())
303 ICollectionGeneric.TypeSpec.IsGenericIterateInterface = true;
305 if (Nullable.Define ())
306 Nullable.TypeSpec.IsNullableType = true;
308 if (ExpressionGeneric.Define ())
309 ExpressionGeneric.TypeSpec.IsExpressionTreeType = true;
312 if (TaskGeneric.Define ())
313 TaskGeneric.TypeSpec.IsGenericTask = true;
317 class PredefinedMembers
319 public readonly PredefinedMember<MethodSpec> ActivatorCreateInstance;
320 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderCreate;
321 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderStart;
322 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderSetResult;
323 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderSetException;
324 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderSetStateMachine;
325 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderOnCompleted;
326 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderOnCompletedUnsafe;
327 public readonly PredefinedMember<PropertySpec> AsyncTaskMethodBuilderTask;
328 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderGenericCreate;
329 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderGenericStart;
330 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderGenericSetResult;
331 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderGenericSetException;
332 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderGenericSetStateMachine;
333 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderGenericOnCompleted;
334 public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderGenericOnCompletedUnsafe;
335 public readonly PredefinedMember<PropertySpec> AsyncTaskMethodBuilderGenericTask;
336 public readonly PredefinedMember<MethodSpec> AsyncVoidMethodBuilderCreate;
337 public readonly PredefinedMember<MethodSpec> AsyncVoidMethodBuilderStart;
338 public readonly PredefinedMember<MethodSpec> AsyncVoidMethodBuilderSetException;
339 public readonly PredefinedMember<MethodSpec> AsyncVoidMethodBuilderSetResult;
340 public readonly PredefinedMember<MethodSpec> AsyncVoidMethodBuilderSetStateMachine;
341 public readonly PredefinedMember<MethodSpec> AsyncVoidMethodBuilderOnCompleted;
342 public readonly PredefinedMember<MethodSpec> AsyncVoidMethodBuilderOnCompletedUnsafe;
343 public readonly PredefinedMember<MethodSpec> AsyncStateMachineAttributeCtor;
344 public readonly PredefinedMember<MethodSpec> DebuggerBrowsableAttributeCtor;
345 public readonly PredefinedMember<MethodSpec> DecimalCtor;
346 public readonly PredefinedMember<MethodSpec> DecimalCtorInt;
347 public readonly PredefinedMember<MethodSpec> DecimalCtorLong;
348 public readonly PredefinedMember<MethodSpec> DecimalConstantAttributeCtor;
349 public readonly PredefinedMember<MethodSpec> DefaultMemberAttributeCtor;
350 public readonly PredefinedMember<MethodSpec> DelegateCombine;
351 public readonly PredefinedMember<MethodSpec> DelegateEqual;
352 public readonly PredefinedMember<MethodSpec> DelegateInequal;
353 public readonly PredefinedMember<MethodSpec> DelegateRemove;
354 public readonly PredefinedMember<MethodSpec> DynamicAttributeCtor;
355 public readonly PredefinedMember<MethodSpec> FieldInfoGetFieldFromHandle;
356 public readonly PredefinedMember<MethodSpec> FieldInfoGetFieldFromHandle2;
357 public readonly PredefinedMember<MethodSpec> IDisposableDispose;
358 public readonly PredefinedMember<MethodSpec> IEnumerableGetEnumerator;
359 public readonly PredefinedMember<MethodSpec> InterlockedCompareExchange;
360 public readonly PredefinedMember<MethodSpec> InterlockedCompareExchange_T;
361 public readonly PredefinedMember<MethodSpec> IteratorStateMachineAttributeCtor;
362 public readonly PredefinedMember<MethodSpec> FixedBufferAttributeCtor;
363 public readonly PredefinedMember<MethodSpec> MethodInfoGetMethodFromHandle;
364 public readonly PredefinedMember<MethodSpec> MethodInfoGetMethodFromHandle2;
365 public readonly PredefinedMember<MethodSpec> MonitorEnter;
366 public readonly PredefinedMember<MethodSpec> MonitorEnter_v4;
367 public readonly PredefinedMember<MethodSpec> MonitorExit;
368 public readonly PredefinedMember<PropertySpec> RuntimeCompatibilityWrapNonExceptionThrows;
369 public readonly PredefinedMember<MethodSpec> RuntimeHelpersInitializeArray;
370 public readonly PredefinedMember<PropertySpec> RuntimeHelpersOffsetToStringData;
371 public readonly PredefinedMember<ConstSpec> SecurityActionRequestMinimum;
372 public readonly PredefinedMember<FieldSpec> StringEmpty;
373 public readonly PredefinedMember<MethodSpec> StringEqual;
374 public readonly PredefinedMember<MethodSpec> StringInequal;
375 public readonly PredefinedMember<MethodSpec> StructLayoutAttributeCtor;
376 public readonly PredefinedMember<FieldSpec> StructLayoutCharSet;
377 public readonly PredefinedMember<FieldSpec> StructLayoutSize;
378 public readonly PredefinedMember<MethodSpec> TypeGetTypeFromHandle;
380 public PredefinedMembers (ModuleContainer module)
382 var types = module.PredefinedTypes;
383 var atypes = module.PredefinedAttributes;
384 var btypes = module.Compiler.BuiltinTypes;
386 var tp = new TypeParameter (0, new MemberName ("T"), null, null, Variance.None);
388 ActivatorCreateInstance = new PredefinedMember<MethodSpec> (module, types.Activator,
389 MemberFilter.Method ("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null));
391 AsyncTaskMethodBuilderCreate = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder,
392 MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncTaskMethodBuilder.TypeSpec));
394 AsyncTaskMethodBuilderSetResult = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder,
395 MemberFilter.Method ("SetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, btypes.Void));
397 AsyncTaskMethodBuilderSetStateMachine = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder,
398 "SetStateMachine", MemberKind.Method, () => new[] {
399 types.IAsyncStateMachine.TypeSpec
402 AsyncTaskMethodBuilderSetException = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder,
403 MemberFilter.Method ("SetException", 0,
404 ParametersCompiled.CreateFullyResolved (btypes.Exception), btypes.Void));
406 AsyncTaskMethodBuilderOnCompleted = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder,
407 MemberFilter.Method ("AwaitOnCompleted", 2,
408 new ParametersImported (
410 new ParameterData (null, Parameter.Modifier.REF),
411 new ParameterData (null, Parameter.Modifier.REF)
414 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
415 new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null)
419 AsyncTaskMethodBuilderOnCompletedUnsafe = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder,
420 MemberFilter.Method ("AwaitUnsafeOnCompleted", 2,
421 new ParametersImported (
423 new ParameterData (null, Parameter.Modifier.REF),
424 new ParameterData (null, Parameter.Modifier.REF)
427 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
428 new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null)
432 AsyncTaskMethodBuilderStart = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder,
433 MemberFilter.Method ("Start", 1,
434 new ParametersImported (
436 new ParameterData (null, Parameter.Modifier.REF),
439 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
443 AsyncTaskMethodBuilderTask = new PredefinedMember<PropertySpec> (module, types.AsyncTaskMethodBuilder,
444 MemberFilter.Property ("Task", null));
446 AsyncTaskMethodBuilderGenericCreate = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
447 MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec));
449 AsyncTaskMethodBuilderGenericSetResult = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
450 "SetResult", MemberKind.Method, () => new TypeSpec[] {
451 types.AsyncTaskMethodBuilderGeneric.TypeSpec.MemberDefinition.TypeParameters[0]
454 AsyncTaskMethodBuilderGenericSetStateMachine = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
455 "SetStateMachine", MemberKind.Method, () => new[] {
456 types.IAsyncStateMachine.TypeSpec
459 AsyncTaskMethodBuilderGenericSetException = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
460 MemberFilter.Method ("SetException", 0,
461 ParametersCompiled.CreateFullyResolved (btypes.Exception), btypes.Void));
463 AsyncTaskMethodBuilderGenericOnCompleted = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
464 MemberFilter.Method ("AwaitOnCompleted", 2,
465 new ParametersImported (
467 new ParameterData (null, Parameter.Modifier.REF),
468 new ParameterData (null, Parameter.Modifier.REF)
471 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
472 new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null)
476 AsyncTaskMethodBuilderGenericOnCompletedUnsafe = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
477 MemberFilter.Method ("AwaitUnsafeOnCompleted", 2,
478 new ParametersImported (
480 new ParameterData (null, Parameter.Modifier.REF),
481 new ParameterData (null, Parameter.Modifier.REF)
484 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
485 new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null)
489 AsyncTaskMethodBuilderGenericStart = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric,
490 MemberFilter.Method ("Start", 1,
491 new ParametersImported (
493 new ParameterData (null, Parameter.Modifier.REF),
496 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
500 AsyncTaskMethodBuilderGenericTask = new PredefinedMember<PropertySpec> (module, types.AsyncTaskMethodBuilderGeneric,
501 MemberFilter.Property ("Task", null));
503 AsyncVoidMethodBuilderCreate = new PredefinedMember<MethodSpec> (module, types.AsyncVoidMethodBuilder,
504 MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec));
506 AsyncVoidMethodBuilderSetException = new PredefinedMember<MethodSpec> (module, types.AsyncVoidMethodBuilder,
507 MemberFilter.Method ("SetException", 0, null, btypes.Void));
509 AsyncVoidMethodBuilderSetResult = new PredefinedMember<MethodSpec> (module, types.AsyncVoidMethodBuilder,
510 MemberFilter.Method ("SetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, btypes.Void));
512 AsyncVoidMethodBuilderSetStateMachine = new PredefinedMember<MethodSpec> (module, types.AsyncVoidMethodBuilder,
513 "SetStateMachine", MemberKind.Method, () => new[] {
514 types.IAsyncStateMachine.TypeSpec
517 AsyncVoidMethodBuilderOnCompleted = new PredefinedMember<MethodSpec> (module, types.AsyncVoidMethodBuilder,
518 MemberFilter.Method ("AwaitOnCompleted", 2,
519 new ParametersImported (
521 new ParameterData (null, Parameter.Modifier.REF),
522 new ParameterData (null, Parameter.Modifier.REF)
525 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
526 new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null)
530 AsyncVoidMethodBuilderOnCompletedUnsafe = new PredefinedMember<MethodSpec> (module, types.AsyncVoidMethodBuilder,
531 MemberFilter.Method ("AwaitUnsafeOnCompleted", 2,
532 new ParametersImported (
534 new ParameterData (null, Parameter.Modifier.REF),
535 new ParameterData (null, Parameter.Modifier.REF)
538 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
539 new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null)
543 AsyncVoidMethodBuilderStart = new PredefinedMember<MethodSpec> (module, types.AsyncVoidMethodBuilder,
544 MemberFilter.Method ("Start", 1,
545 new ParametersImported (
547 new ParameterData (null, Parameter.Modifier.REF),
550 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
554 AsyncStateMachineAttributeCtor = new PredefinedMember<MethodSpec> (module, atypes.AsyncStateMachine,
555 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (
558 DebuggerBrowsableAttributeCtor = new PredefinedMember<MethodSpec> (module, atypes.DebuggerBrowsable,
559 MemberFilter.Constructor (null));
561 DecimalCtor = new PredefinedMember<MethodSpec> (module, btypes.Decimal,
562 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (
563 btypes.Int, btypes.Int, btypes.Int, btypes.Bool, btypes.Byte)));
565 DecimalCtorInt = new PredefinedMember<MethodSpec> (module, btypes.Decimal,
566 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.Int)));
568 DecimalCtorLong = new PredefinedMember<MethodSpec> (module, btypes.Decimal,
569 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.Long)));
571 DecimalConstantAttributeCtor = new PredefinedMember<MethodSpec> (module, atypes.DecimalConstant,
572 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (
573 btypes.Byte, btypes.Byte, btypes.UInt, btypes.UInt, btypes.UInt)));
575 DefaultMemberAttributeCtor = new PredefinedMember<MethodSpec> (module, atypes.DefaultMember,
576 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.String)));
578 DelegateCombine = new PredefinedMember<MethodSpec> (module, btypes.Delegate, "Combine", btypes.Delegate, btypes.Delegate);
579 DelegateRemove = new PredefinedMember<MethodSpec> (module, btypes.Delegate, "Remove", btypes.Delegate, btypes.Delegate);
581 DelegateEqual = new PredefinedMember<MethodSpec> (module, btypes.Delegate,
582 new MemberFilter (Operator.GetMetadataName (Operator.OpType.Equality), 0, MemberKind.Operator, null, btypes.Bool));
584 DelegateInequal = new PredefinedMember<MethodSpec> (module, btypes.Delegate,
585 new MemberFilter (Operator.GetMetadataName (Operator.OpType.Inequality), 0, MemberKind.Operator, null, btypes.Bool));
587 DynamicAttributeCtor = new PredefinedMember<MethodSpec> (module, atypes.Dynamic,
588 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (
589 ArrayContainer.MakeType (module, btypes.Bool))));
591 FieldInfoGetFieldFromHandle = new PredefinedMember<MethodSpec> (module, types.FieldInfo,
592 "GetFieldFromHandle", MemberKind.Method, types.RuntimeFieldHandle);
594 FieldInfoGetFieldFromHandle2 = new PredefinedMember<MethodSpec> (module, types.FieldInfo,
595 "GetFieldFromHandle", MemberKind.Method, types.RuntimeFieldHandle, new PredefinedType (btypes.RuntimeTypeHandle));
597 FixedBufferAttributeCtor = new PredefinedMember<MethodSpec> (module, atypes.FixedBuffer,
598 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.Type, btypes.Int)));
600 IDisposableDispose = new PredefinedMember<MethodSpec> (module, btypes.IDisposable, "Dispose", TypeSpec.EmptyTypes);
602 IEnumerableGetEnumerator = new PredefinedMember<MethodSpec> (module, btypes.IEnumerable,
603 "GetEnumerator", TypeSpec.EmptyTypes);
605 InterlockedCompareExchange = new PredefinedMember<MethodSpec> (module, types.Interlocked,
606 MemberFilter.Method ("CompareExchange", 0,
607 new ParametersImported (
609 new ParameterData (null, Parameter.Modifier.REF),
610 new ParameterData (null, Parameter.Modifier.NONE),
611 new ParameterData (null, Parameter.Modifier.NONE)
614 btypes.Int, btypes.Int, btypes.Int
619 InterlockedCompareExchange_T = new PredefinedMember<MethodSpec> (module, types.Interlocked,
620 MemberFilter.Method ("CompareExchange", 1,
621 new ParametersImported (
623 new ParameterData (null, Parameter.Modifier.REF),
624 new ParameterData (null, Parameter.Modifier.NONE),
625 new ParameterData (null, Parameter.Modifier.NONE)
628 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
629 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
630 new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
634 IteratorStateMachineAttributeCtor = new PredefinedMember<MethodSpec> (module, atypes.IteratorStateMachine,
635 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (
638 MethodInfoGetMethodFromHandle = new PredefinedMember<MethodSpec> (module, types.MethodBase,
639 "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle);
641 MethodInfoGetMethodFromHandle2 = new PredefinedMember<MethodSpec> (module, types.MethodBase,
642 "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle, new PredefinedType (btypes.RuntimeTypeHandle));
644 MonitorEnter = new PredefinedMember<MethodSpec> (module, types.Monitor, "Enter", btypes.Object);
646 MonitorEnter_v4 = new PredefinedMember<MethodSpec> (module, types.Monitor,
647 MemberFilter.Method ("Enter", 0,
648 new ParametersImported (new[] {
649 new ParameterData (null, Parameter.Modifier.NONE),
650 new ParameterData (null, Parameter.Modifier.REF)
653 btypes.Object, btypes.Bool
656 MonitorExit = new PredefinedMember<MethodSpec> (module, types.Monitor, "Exit", btypes.Object);
658 RuntimeCompatibilityWrapNonExceptionThrows = new PredefinedMember<PropertySpec> (module, atypes.RuntimeCompatibility,
659 MemberFilter.Property ("WrapNonExceptionThrows", btypes.Bool));
661 RuntimeHelpersInitializeArray = new PredefinedMember<MethodSpec> (module, types.RuntimeHelpers,
662 "InitializeArray", btypes.Array, btypes.RuntimeFieldHandle);
664 RuntimeHelpersOffsetToStringData = new PredefinedMember<PropertySpec> (module, types.RuntimeHelpers,
665 MemberFilter.Property ("OffsetToStringData", btypes.Int));
667 SecurityActionRequestMinimum = new PredefinedMember<ConstSpec> (module, types.SecurityAction, "RequestMinimum",
668 MemberKind.Field, types.SecurityAction);
670 StringEmpty = new PredefinedMember<FieldSpec> (module, btypes.String, MemberFilter.Field ("Empty", btypes.String));
672 StringEqual = new PredefinedMember<MethodSpec> (module, btypes.String,
673 new MemberFilter (Operator.GetMetadataName (Operator.OpType.Equality), 0, MemberKind.Operator, null, btypes.Bool));
675 StringInequal = new PredefinedMember<MethodSpec> (module, btypes.String,
676 new MemberFilter (Operator.GetMetadataName (Operator.OpType.Inequality), 0, MemberKind.Operator, null, btypes.Bool));
678 StructLayoutAttributeCtor = new PredefinedMember<MethodSpec> (module, atypes.StructLayout,
679 MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (btypes.Short)));
681 StructLayoutCharSet = new PredefinedMember<FieldSpec> (module, atypes.StructLayout, "CharSet",
682 MemberKind.Field, types.CharSet);
684 StructLayoutSize = new PredefinedMember<FieldSpec> (module, atypes.StructLayout,
685 MemberFilter.Field ("Size", btypes.Int));
687 TypeGetTypeFromHandle = new PredefinedMember<MethodSpec> (module, btypes.Type, "GetTypeFromHandle", btypes.RuntimeTypeHandle);
691 public class PredefinedType
693 readonly string name;
696 readonly MemberKind kind;
697 protected readonly ModuleContainer module;
698 protected TypeSpec type;
700 public PredefinedType (ModuleContainer module, MemberKind kind, string ns, string name, int arity)
701 : this (module, kind, ns, name)
706 public PredefinedType (ModuleContainer module, MemberKind kind, string ns, string name)
708 this.module = module;
714 public PredefinedType (BuiltinTypeSpec type)
716 this.kind = type.Kind;
717 this.name = type.Name;
718 this.ns = type.Namespace;
730 public bool IsDefined {
742 public string Namespace {
748 public TypeSpec TypeSpec {
756 public bool Define ()
761 type = Resolve (module, kind, ns, name, arity, false, false);
765 public string GetSignatureForError ()
767 return ns + "." + name;
770 public static TypeSpec Resolve (ModuleContainer module, MemberKind kind, string ns, string name, int arity, bool required, bool reportErrors)
773 // Cannot call it with true because it could create non-existent namespaces for
774 // predefined types. It's set to true only for build-in types which all must
775 // exist therefore it does not matter, for predefined types we don't want to create
776 // fake namespaces when type is optional and does not exist (e.g. System.Linq).
778 Namespace type_ns = module.GlobalRootNamespace.GetNamespace (ns, required);
779 IList<TypeSpec> found = null;
781 found = type_ns.GetAllTypes (name);
785 module.Compiler.Report.Error (518, "The predefined type `{0}.{1}' is not defined or imported", ns, name);
790 TypeSpec best_match = null;
791 foreach (var candidate in found) {
792 if (candidate.Kind != kind) {
793 if (candidate.Kind == MemberKind.Struct && kind == MemberKind.Void && candidate.MemberDefinition is TypeContainer) {
794 // Void is declared as struct but we keep it internally as
795 // special kind, the swap will be done by caller
801 if (candidate.Arity != arity)
804 if ((candidate.Modifiers & Modifiers.INTERNAL) != 0 && !candidate.MemberDefinition.IsInternalAsPublic (module.DeclaringAssembly))
807 if (best_match == null) {
808 best_match = candidate;
812 var other_match = best_match;
813 if (!best_match.MemberDefinition.IsImported &&
814 module.Compiler.BuiltinTypes.Object.MemberDefinition.DeclaringAssembly == candidate.MemberDefinition.DeclaringAssembly) {
815 best_match = candidate;
819 if (best_match.MemberDefinition is MemberCore) {
820 location = ((MemberCore) best_match.MemberDefinition).Location.Name;
822 var assembly = (ImportedAssemblyDefinition) best_match.MemberDefinition.DeclaringAssembly;
823 location = Path.GetFileName (assembly.Location);
826 module.Compiler.Report.SymbolRelatedToPreviousError (other_match);
827 module.Compiler.Report.SymbolRelatedToPreviousError (candidate);
829 module.Compiler.Report.Warning (1685, 1,
830 "The predefined type `{0}.{1}' is defined multiple times. Using definition from `{2}'",
836 if (best_match == null && reportErrors) {
838 if (found[0].MemberDefinition is MemberCore) {
839 loc = ((MemberCore) found[0].MemberDefinition).Location;
842 module.Compiler.Report.SymbolRelatedToPreviousError (found[0]);
845 module.Compiler.Report.Error (520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name);
851 public TypeSpec Resolve ()
854 type = Resolve (module, kind, ns, name, arity, false, true);
860 public class PredefinedMember<T> where T : MemberSpec
862 readonly ModuleContainer module;
864 TypeSpec declaring_type;
865 readonly PredefinedType declaring_type_predefined;
867 readonly Func<TypeSpec[]> filter_builder;
869 public PredefinedMember (ModuleContainer module, PredefinedType type, MemberFilter filter)
871 this.module = module;
872 this.declaring_type_predefined = type;
873 this.filter = filter;
876 public PredefinedMember (ModuleContainer module, TypeSpec type, MemberFilter filter)
878 this.module = module;
879 this.declaring_type = type;
880 this.filter = filter;
883 public PredefinedMember (ModuleContainer module, PredefinedType type, string name, params TypeSpec[] types)
884 : this (module, type, MemberFilter.Method (name, 0, ParametersCompiled.CreateFullyResolved (types), null))
888 public PredefinedMember (ModuleContainer module, PredefinedType type, string name, MemberKind kind, params PredefinedType[] types)
889 : this (module, type, new MemberFilter (name, 0, kind, null, null))
891 filter_builder = () => {
892 var ptypes = new TypeSpec[types.Length];
893 for (int i = 0; i < ptypes.Length; ++i) {
898 ptypes[i] = p.TypeSpec;
905 public PredefinedMember (ModuleContainer module, PredefinedType type, string name, MemberKind kind, Func<TypeSpec[]> typesBuilder, TypeSpec returnType)
906 : this (module, type, new MemberFilter (name, 0, kind, null, returnType))
908 filter_builder = typesBuilder;
911 public PredefinedMember (ModuleContainer module, BuiltinTypeSpec type, string name, params TypeSpec[] types)
912 : this (module, type, MemberFilter.Method (name, 0, ParametersCompiled.CreateFullyResolved (types), null))
921 if (declaring_type == null) {
922 if (!declaring_type_predefined.Define ())
925 declaring_type = declaring_type_predefined.TypeSpec;
928 if (filter_builder != null) {
929 var types = filter_builder ();
931 if (filter.Kind == MemberKind.Field)
932 filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind, null, types [0]);
934 filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind,
935 ParametersCompiled.CreateFullyResolved (types), filter.MemberType);
938 member = MemberCache.FindMember (declaring_type, filter, BindingRestriction.DeclaredOnly) as T;
942 if (!member.IsAccessible (module))
948 public T Resolve (Location loc)
956 if (declaring_type == null) {
957 if (declaring_type_predefined.Resolve () == null)
961 if (filter_builder != null) {
962 filter = new MemberFilter (filter.Name, filter.Arity, filter.Kind,
963 ParametersCompiled.CreateFullyResolved (filter_builder ()), filter.MemberType);
966 string method_args = null;
967 if (filter.Parameters != null)
968 method_args = filter.Parameters.GetSignatureForError ();
970 module.Compiler.Report.Error (656, loc, "The compiler required member `{0}.{1}{2}' could not be found or is inaccessible",
971 declaring_type.GetSignatureForError (), filter.Name, method_args);
977 partial class TypeManager {
980 /// Returns the C# name of a type if possible, or the full type name otherwise
982 static public string CSharpName (TypeSpec t)
984 return t.GetSignatureForError ();
987 static public string CSharpName (IList<TypeSpec> types)
989 if (types.Count == 0)
992 StringBuilder sb = new StringBuilder ();
993 for (int i = 0; i < types.Count; ++i) {
997 sb.Append (CSharpName (types [i]));
999 return sb.ToString ();
1002 static public string GetFullNameSignature (MemberSpec mi)
1004 return mi.GetSignatureForError ();
1007 static public string CSharpSignature (MemberSpec mb)
1009 return mb.GetSignatureForError ();
1012 public static bool IsFamilyAccessible (TypeSpec type, TypeSpec parent)
1014 // TypeParameter tparam = LookupTypeParameter (type);
1015 // TypeParameter pparam = LookupTypeParameter (parent);
1017 if (type.Kind == MemberKind.TypeParameter && parent.Kind == MemberKind.TypeParameter) { // (tparam != null) && (pparam != null)) {
1021 throw new NotImplementedException ("net");
1022 // return tparam.IsSubclassOf (parent);
1026 if (IsInstantiationOfSameGenericType (type, parent))
1029 type = type.BaseType;
1030 } while (type != null);
1036 // Checks whether `type' is a nested child of `parent'.
1038 public static bool IsNestedChildOf (TypeSpec type, ITypeDefinition parent)
1043 if (type.MemberDefinition == parent)
1046 type = type.DeclaringType;
1047 while (type != null) {
1048 if (type.MemberDefinition == parent)
1051 type = type.DeclaringType;
1057 public static TypeSpec GetElementType (TypeSpec t)
1059 return ((ElementTypeSpec)t).Element;
1063 /// This method is not implemented by MS runtime for dynamic types
1065 public static bool HasElementType (TypeSpec t)
1067 return t is ElementTypeSpec;
1071 /// Utility function that can be used to probe whether a type
1072 /// is managed or not.
1074 public static bool VerifyUnmanaged (ModuleContainer rc, TypeSpec t, Location loc)
1080 t = ((ElementTypeSpec) t).Element;
1082 rc.Compiler.Report.SymbolRelatedToPreviousError (t);
1083 rc.Compiler.Report.Error (208, loc,
1084 "Cannot take the address of, get the size of, or declare a pointer to a managed type `{0}'",
1090 // This method always return false for non-generic compiler,
1091 // while Type.IsGenericParameter is returned if it is supported.
1092 public static bool IsGenericParameter (TypeSpec type)
1094 return type.IsGenericParameter;
1097 public static bool IsGenericType (TypeSpec type)
1099 return type.IsGeneric;
1102 public static TypeSpec[] GetTypeArguments (TypeSpec t)
1104 // TODO: return empty array !!
1105 return t.TypeArguments;
1109 /// Check whether `type' and `parent' are both instantiations of the same
1110 /// generic type. Note that we do not check the type parameters here.
1112 public static bool IsInstantiationOfSameGenericType (TypeSpec type, TypeSpec parent)
1114 return type == parent || type.MemberDefinition == parent.MemberDefinition;