// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.TypeSystem
{
///
/// Represents an unresolved class, enum, interface, struct, delegate or VB module.
/// For partial classes, an unresolved type definition represents only a single part.
///
public interface IUnresolvedTypeDefinition : ITypeReference, IUnresolvedEntity
{
TypeKind Kind { get; }
FullTypeName FullTypeName { get; }
IList BaseTypes { get; }
IList TypeParameters { get; }
IList NestedTypes { get; }
IList Members { get; }
IEnumerable Methods { get; }
IEnumerable Properties { get; }
IEnumerable Fields { get; }
IEnumerable Events { get; }
///
/// Gets whether the type definition contains extension methods.
/// Returns null when the type definition needs to be resolved in order to determine whether
/// methods are extension methods.
///
bool? HasExtensionMethods { get; }
///
/// Gets whether the partial modifier is set on this part of the type definition.
///
bool IsPartial { get; }
///
/// Gets whether this unresolved type definition causes the addition of a default constructor
/// if no other constructor is present.
///
bool AddDefaultConstructorIfRequired { get; }
///
/// Looks up the resolved type definition from the corresponding to this unresolved
/// type definition.
///
///
/// Context for looking up the type. The context must specify the current assembly.
/// A that specifies the current assembly is sufficient.
///
///
/// Returns the resolved type definition.
/// In case of an error, returns an instance.
/// Never returns null.
///
new IType Resolve(ITypeResolveContext context);
///
/// This method is used to add language-specific elements like the C# UsingScope
/// to the type resolve context.
///
/// The parent context (e.g. the parent assembly),
/// including the parent type definition for inner classes.
///
/// The parent context, modified to include language-specific elements (e.g. using scope)
/// associated with this type definition.
///
///
/// Use unresolvedTypeDef.CreateResolveContext(parentContext).WithTypeDefinition(typeDef) to
/// create the context for use within the type definition.
///
ITypeResolveContext CreateResolveContext(ITypeResolveContext parentContext);
}
///
/// Represents a class, enum, interface, struct, delegate or VB module.
/// For partial classes, this represents the whole class.
///
public interface ITypeDefinition : IType, IEntity
{
IReadOnlyList NestedTypes { get; }
IReadOnlyList Members { get; }
IEnumerable Fields { get; }
IEnumerable Methods { get; }
IEnumerable Properties { get; }
IEnumerable Events { get; }
///
/// Gets the known type code for this type definition.
///
KnownTypeCode KnownTypeCode { get; }
///
/// For enums: returns the underlying primitive type.
/// For all other types: returns .
///
IType EnumUnderlyingType { get; }
///
/// Gets the full name of this type.
///
FullTypeName FullTypeName { get; }
///
/// Gets/Sets the declaring type (incl. type arguments, if any).
/// This property will return null for top-level types.
///
new IType DeclaringType { get; } // solves ambiguity between IType.DeclaringType and IEntity.DeclaringType
///
/// Gets whether this type contains extension methods.
///
/// This property is used to speed up the search for extension methods.
bool HasExtensionMethods { get; }
///
/// Determines how this type is implementing the specified interface member.
///
///
/// The method on this type that implements the interface member;
/// or null if the type does not implement the interface.
///
IMember GetInterfaceImplementation(IMember interfaceMember);
///
/// Determines how this type is implementing the specified interface members.
///
///
/// For each interface member, this method returns the class member
/// that implements the interface member.
/// For interface members that are missing an implementation, the
/// result collection will contain a null element.
///
IReadOnlyList GetInterfaceImplementation(IReadOnlyList interfaceMembers);
}
}