1
// Copyright (c) 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;
23
namespace ICSharpCode.NRefactory.TypeSystem
26
/// Represents an unresolved class, enum, interface, struct, delegate or VB module.
27
/// For partial classes, an unresolved type definition represents only a single part.
29
public interface IUnresolvedTypeDefinition : ITypeReference, IUnresolvedEntity
31
TypeKind Kind { get; }
33
IList<ITypeReference> BaseTypes { get; }
34
IList<IUnresolvedTypeParameter> TypeParameters { get; }
36
IList<IUnresolvedTypeDefinition> NestedTypes { get; }
37
IList<IUnresolvedMember> Members { get; }
39
IEnumerable<IUnresolvedMethod> Methods { get; }
40
IEnumerable<IUnresolvedProperty> Properties { get; }
41
IEnumerable<IUnresolvedField> Fields { get; }
42
IEnumerable<IUnresolvedEvent> Events { get; }
45
/// Gets whether the type definition contains extension methods.
46
/// Returns null when the type definition needs to be resolved in order to determine whether
47
/// methods are extension methods.
49
bool? HasExtensionMethods { get; }
52
/// Looks up the resolved type definition from the <paramref name="context"/> corresponding to this unresolved
55
/// <param name="context">
56
/// Context for looking up the type. The context must specify the current assembly.
57
/// A <see cref="Implementation.SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
60
/// Returns the resolved type definition.
61
/// In case of an error, returns an <see cref="Implementation.UnknownType"/> instance.
62
/// Never returns null.
64
new IType Resolve(ITypeResolveContext context);
67
/// This method is used to add language-specific elements like the C# UsingScope
68
/// to the type resolve context.
70
/// <param name="parentContext">The parent context (e.g. the parent assembly),
71
/// including the parent type definition for inner classes.</param>
73
/// The parent context, modified to include language-specific elements (e.g. using scope)
74
/// associated with this type definition.
77
/// Use <c>unresolvedTypeDef.CreateResolveContext(parentContext).WithTypeDefinition(typeDef)</c> to
78
/// create the context for use within the type definition.
80
ITypeResolveContext CreateResolveContext(ITypeResolveContext parentContext);
84
/// Represents a class, enum, interface, struct, delegate or VB module.
85
/// For partial classes, this represents the whole class.
87
public interface ITypeDefinition : IType, IEntity
90
/// Returns all parts that contribute to this type definition.
91
/// Non-partial classes have a single part that represents the whole class.
93
IList<IUnresolvedTypeDefinition> Parts { get; }
95
IList<ITypeParameter> TypeParameters { get; }
97
IList<ITypeDefinition> NestedTypes { get; }
98
IList<IMember> Members { get; }
100
IEnumerable<IField> Fields { get; }
101
IEnumerable<IMethod> Methods { get; }
102
IEnumerable<IProperty> Properties { get; }
103
IEnumerable<IEvent> Events { get; }
106
/// Gets the known type code for this type definition.
108
KnownTypeCode KnownTypeCode { get; }
111
/// For enums: returns the underlying primitive type.
112
/// For all other types: returns <see cref="SpecialType.UnknownType"/>.
114
IType EnumUnderlyingType { get; }
117
/// Gets/Sets the declaring type (incl. type arguments, if any).
118
/// This property never returns null -- for top-level entities, it returns SharedTypes.UnknownType.
120
new IType DeclaringType { get; } // solves ambiguity between IType.DeclaringType and IEntity.DeclaringType
123
/// Gets whether this type contains extension methods.
125
/// <remarks>This property is used to speed up the search for extension methods.</remarks>
126
bool HasExtensionMethods { get; }