1 // ***********************************************************************
2 // Copyright (c) 2015 Charlie Poole
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // ***********************************************************************
25 #define NUNIT_FRAMEWORK
30 using System.Reflection;
31 using NUnit.Compatibility;
33 namespace NUnit.Framework.Interfaces
36 /// The ITypeInfo interface is an abstraction of a .NET Type
38 public interface ITypeInfo : IReflectionInfo
43 /// Gets the underlying Type on which this ITypeInfo is based
48 /// Gets the base type of this type as an ITypeInfo
50 ITypeInfo BaseType { get; }
53 /// Returns true if the Type wrapped is equal to the argument
55 bool IsType(Type type);
58 /// Gets the Name of the Type
63 /// Gets the FullName of the Type
65 string FullName { get; }
68 /// Gets the assembly in which the type is declared
70 Assembly Assembly { get; }
73 /// Gets the Namespace of the Type
75 string Namespace { get; }
78 /// Gets a value indicating whether the type is abstract.
80 bool IsAbstract { get; }
83 /// Gets a value indicating whether the Type is a generic Type
85 bool IsGenericType { get; }
88 /// Gets a value indicating whether the Type has generic parameters that have not been replaced by specific Types.
90 bool ContainsGenericParameters { get; }
93 /// Gets a value indicating whether the Type is a generic Type definition
95 bool IsGenericTypeDefinition { get; }
98 /// Gets a value indicating whether the type is sealed.
100 bool IsSealed { get; }
103 /// Gets a value indicating whether this type is a static class.
105 bool IsStaticClass { get; }
112 /// Get the display name for this typeInfo.
114 string GetDisplayName();
117 /// Get the display name for an oject of this type, constructed with specific arguments
119 string GetDisplayName(object[] args);
122 /// Returns a Type representing a generic type definition from which this Type can be constructed.
124 Type GetGenericTypeDefinition();
127 /// Returns a new ITypeInfo representing an instance of this generic Type using the supplied Type arguments
129 ITypeInfo MakeGenericType(Type[] typeArgs);
132 /// Returns a value indicating whether this type has a method with a specified public attribute
134 bool HasMethodWithAttribute(Type attrType);
137 /// Returns an array of IMethodInfos for methods of this Type
138 /// that match the specified flags.
140 IMethodInfo[] GetMethods(BindingFlags flags);
143 /// Gets the public constructor taking the specified argument Types
145 ConstructorInfo GetConstructor(Type[] argTypes);
148 /// Returns a value indicating whether this Type has a public constructor taking the specified argument Types.
150 bool HasConstructor(Type[] argTypes);
153 /// Construct an object of this Type, using the specified arguments.
155 object Construct(object[] args);