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;
24
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
27
/// Default implementation for IType interface.
30
public abstract class AbstractType : IType
32
public virtual string FullName {
34
string ns = this.Namespace;
35
string name = this.Name;
36
if (string.IsNullOrEmpty(ns)) {
39
return ns + "." + name;
44
public abstract string Name { get; }
46
public virtual string Namespace {
47
get { return string.Empty; }
50
public virtual string ReflectionName {
51
get { return this.FullName; }
54
public abstract bool? IsReferenceType { get; }
56
public abstract TypeKind Kind { get; }
58
public virtual int TypeParameterCount {
62
public virtual IType DeclaringType {
66
public virtual ITypeDefinition GetDefinition()
71
public virtual IEnumerable<IType> DirectBaseTypes {
72
get { return EmptyList<IType>.Instance; }
75
public abstract ITypeReference ToTypeReference();
77
public virtual IEnumerable<IType> GetNestedTypes(Predicate<ITypeDefinition> filter = null, GetMemberOptions options = GetMemberOptions.None)
79
return EmptyList<IType>.Instance;
82
public virtual IEnumerable<IType> GetNestedTypes(IList<IType> typeArguments, Predicate<ITypeDefinition> filter = null, GetMemberOptions options = GetMemberOptions.None)
84
return EmptyList<IType>.Instance;
87
public virtual IEnumerable<IMethod> GetMethods(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
89
return EmptyList<IMethod>.Instance;
92
public virtual IEnumerable<IMethod> GetMethods(IList<IType> typeArguments, Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
94
return EmptyList<IMethod>.Instance;
97
public virtual IEnumerable<IMethod> GetConstructors(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.IgnoreInheritedMembers)
99
return EmptyList<IMethod>.Instance;
102
public virtual IEnumerable<IProperty> GetProperties(Predicate<IUnresolvedProperty> filter = null, GetMemberOptions options = GetMemberOptions.None)
104
return EmptyList<IProperty>.Instance;
107
public virtual IEnumerable<IField> GetFields(Predicate<IUnresolvedField> filter = null, GetMemberOptions options = GetMemberOptions.None)
109
return EmptyList<IField>.Instance;
112
public virtual IEnumerable<IEvent> GetEvents(Predicate<IUnresolvedEvent> filter = null, GetMemberOptions options = GetMemberOptions.None)
114
return EmptyList<IEvent>.Instance;
117
public virtual IEnumerable<IMember> GetMembers(Predicate<IUnresolvedMember> filter = null, GetMemberOptions options = GetMemberOptions.None)
119
IEnumerable<IMember> members = GetMethods(filter, options);
121
.Concat(GetProperties(filter, options))
122
.Concat(GetFields(filter, options))
123
.Concat(GetEvents(filter, options));
126
public override sealed bool Equals(object obj)
128
return Equals(obj as IType);
131
public override int GetHashCode()
133
return base.GetHashCode();
136
public virtual bool Equals(IType other)
138
return this == other; // use reference equality by default
141
public override string ToString()
143
return this.ReflectionName;
146
public virtual IType AcceptVisitor(TypeVisitor visitor)
148
return visitor.VisitOtherType(this);
151
public virtual IType VisitChildren(TypeVisitor visitor)