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;
32 namespace NUnit.Framework.Interfaces
35 /// The IMethodInfo class is used to encapsulate information
36 /// about a method in a platform-independent manner.
38 public interface IMethodInfo : IReflectionInfo
43 /// Gets the Type from which this method was reflected.
45 ITypeInfo TypeInfo { get; }
48 /// Gets the MethodInfo for this method.
50 MethodInfo MethodInfo { get; }
53 /// Gets the name of the method.
58 /// Gets a value indicating whether the method is abstract.
60 bool IsAbstract { get; }
63 /// Gets a value indicating whether the method is public.
65 bool IsPublic { get; }
68 /// Gets a value indicating whether the method contains unassigned generic type parameters.
70 bool ContainsGenericParameters { get; }
73 /// Gets a value indicating whether the method is a generic method.
75 bool IsGenericMethod { get; }
78 /// Gets a value indicating whether the MethodInfo represents the definition of a generic method.
80 bool IsGenericMethodDefinition { get; }
83 /// Gets the return Type of the method.
85 ITypeInfo ReturnType { get; }
92 /// Gets the parameters of the method.
94 /// <returns></returns>
95 IParameterInfo[] GetParameters();
98 /// Returns the Type arguments of a generic method or the Type parameters of a generic method definition.
100 Type[] GetGenericArguments();
103 /// Replaces the type parameters of the method with the array of types provided and returns a new IMethodInfo.
105 /// <param name="typeArguments">The type arguments to be used</param>
106 /// <returns>A new IMethodInfo with the type arguments replaced</returns>
107 IMethodInfo MakeGenericMethod(params Type[] typeArguments);
110 /// Invokes the method, converting any TargetInvocationException to an NUnitException.
112 /// <param name="fixture">The object on which to invoke the method</param>
113 /// <param name="args">The argument list for the method</param>
114 /// <returns>The return value from the invoked method</returns>
115 object Invoke(object fixture, params object[] args);