1
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
// software and associated documentation files (the "Software"), to deal in the Software
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
// to whom the Software is furnished to do so, subject to the following conditions:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
// DEALINGS IN THE SOFTWARE.
20
using System.Collections.Generic;
21
using System.Diagnostics.Contracts;
22
using ICSharpCode.NRefactory.TypeSystem;
24
namespace ICSharpCode.NRefactory.TypeSystem
26
public interface IUnresolvedMethod : IUnresolvedParameterizedMember
29
/// Gets the attributes associated with the return type. (e.g. [return: MarshalAs(...)])
31
IList<IUnresolvedAttribute> ReturnTypeAttributes { get; }
33
IList<IUnresolvedTypeParameter> TypeParameters { get; }
35
bool IsConstructor { get; }
36
bool IsDestructor { get; }
37
bool IsOperator { get; }
40
/// Gets whether the method is a C#-style partial method.
41
/// Check <see cref="HasBody"/> to test if it is a partial method declaration or implementation.
43
bool IsPartial { get; }
46
/// Gets whether the method is a C#-style async method.
50
[Obsolete("Use IsPartial && !HasBody instead")]
51
bool IsPartialMethodDeclaration { get; }
53
[Obsolete("Use IsPartial && HasBody instead")]
54
bool IsPartialMethodImplementation { get; }
57
/// Gets whether the method has a body.
58
/// This property returns <c>false</c> for <c>abstract</c> or <c>extern</c> methods,
59
/// or for <c>partial</c> methods without implementation.
64
/// If this method is an accessor, returns a reference to the corresponding property/event.
65
/// Otherwise, returns null.
67
IUnresolvedMember AccessorOwner { get; }
70
/// Resolves the member.
72
/// <param name="context">
73
/// Context for looking up the member. The context must specify the current assembly.
74
/// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
77
/// Returns the resolved member, or <c>null</c> if the member could not be found.
79
new IMethod Resolve(ITypeResolveContext context);
83
/// Represents a method, constructor, destructor or operator.
85
public interface IMethod : IParameterizedMember
88
/// Gets the unresolved method parts.
89
/// For partial methods, this returns all parts.
90
/// Otherwise, this returns an array with a single element (new[] { UnresolvedMember }).
91
/// NOTE: The type will change to IReadOnlyList<IUnresolvedMethod> in future versions.
93
IList<IUnresolvedMethod> Parts { get; }
96
/// Gets the attributes associated with the return type. (e.g. [return: MarshalAs(...)])
97
/// NOTE: The type will change to IReadOnlyList<IAttribute> in future versions.
99
IList<IAttribute> ReturnTypeAttributes { get; }
102
/// Gets the type parameters of this method; or an empty list if the method is not generic.
103
/// NOTE: The type will change to IReadOnlyList<ITypeParameter> in future versions.
105
IList<ITypeParameter> TypeParameters { get; }
108
/// Gets whether this is a generic method that has been parameterized.
110
bool IsParameterized { get; }
113
/// Gets the type arguments passed to this method.
114
/// If the method is generic but not parameterized yet, this property returns the type parameters,
115
/// as if the method was parameterized with its own type arguments (<c>void M<T>() { M<T>(); }</c>).
117
/// NOTE: The type will change to IReadOnlyList<IType> in future versions.
119
IList<IType> TypeArguments { get; }
121
bool IsExtensionMethod { get; }
122
bool IsConstructor { get; }
123
bool IsDestructor { get; }
124
bool IsOperator { get; }
127
/// Gets whether the method is a C#-style partial method.
128
/// A call to such a method is ignored by the compiler if the partial method has no body.
130
/// <seealso cref="HasBody"/>
131
bool IsPartial { get; }
134
/// Gets whether the method is a C#-style async method.
136
bool IsAsync { get; }
139
/// Gets whether the method has a body.
140
/// This property returns <c>false</c> for <c>abstract</c> or <c>extern</c> methods,
141
/// or for <c>partial</c> methods without implementation.
143
bool HasBody { get; }
146
/// Gets whether the method is a property/event accessor.
148
bool IsAccessor { get; }
151
/// If this method is an accessor, returns the corresponding property/event.
152
/// Otherwise, returns null.
154
IMember AccessorOwner { get; }
157
/// If this method is reduced from an extension method return the original method, <c>null</c> otherwise.
158
/// A reduced method doesn't contain the extension method parameter. That means that has one parameter less than it's definition.
160
IMethod ReducedFrom { get; }
163
/// Specializes this method with the given substitution.
164
/// If this method is already specialized, the new substitution is composed with the existing substition.
166
new IMethod Specialize(TypeParameterSubstitution substitution);