diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj index b23c53fc8..73a735d84 100644 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj +++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj @@ -490,7 +490,6 @@ - @@ -499,15 +498,9 @@ - - - - - - @@ -521,8 +514,6 @@ - - diff --git a/ICSharpCode.Decompiler/TypeSystem/IAssembly.cs b/ICSharpCode.Decompiler/TypeSystem/IAssembly.cs index d682e18fa..216d919ca 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IAssembly.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IAssembly.cs @@ -22,37 +22,6 @@ using ICSharpCode.Decompiler.Metadata; namespace ICSharpCode.Decompiler.TypeSystem { - /// - /// Represents an unresolved assembly. - /// - public interface IUnresolvedAssembly : IAssemblyReference - { - /// - /// Gets the assembly name (short name). - /// - string AssemblyName { get; } - - /// - /// Gets the full assembly name (including public key token etc.) - /// - string FullAssemblyName { get; } - - /// - /// Gets the list of all assembly attributes in the project. - /// - IEnumerable AssemblyAttributes { get; } - - /// - /// Gets the list of all module attributes in the project. - /// - IEnumerable ModuleAttributes { get; } - - /// - /// Gets all non-nested types in the assembly. - /// - IEnumerable TopLevelTypeDefinitions { get; } - } - public interface IAssemblyReference { /// diff --git a/ICSharpCode.Decompiler/TypeSystem/IAttribute.cs b/ICSharpCode.Decompiler/TypeSystem/IAttribute.cs index 504ccf61c..62b4f067b 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IAttribute.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IAttribute.cs @@ -23,18 +23,6 @@ using ICSharpCode.Decompiler.Semantics; namespace ICSharpCode.Decompiler.TypeSystem { - /// - /// Represents an unresolved attribute. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] - public interface IUnresolvedAttribute - { - /// - /// Resolves the attribute. - /// - IAttribute CreateResolvedAttribute(ITypeResolveContext context); - } - /// /// Represents an attribute. /// diff --git a/ICSharpCode.Decompiler/TypeSystem/IConstantValue.cs b/ICSharpCode.Decompiler/TypeSystem/IConstantValue.cs deleted file mode 100644 index 73673365f..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/IConstantValue.cs +++ /dev/null @@ -1,36 +0,0 @@ -// 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 ICSharpCode.Decompiler.Semantics; - -namespace ICSharpCode.Decompiler.TypeSystem -{ - /// - /// Represents an unresolved constant value. - /// - public interface IConstantValue - { - /// - /// Resolves the value of this constant. - /// - /// Context where the constant value will be used. - /// Resolve result representing the constant value. - /// This method never returns null; in case of errors, an ErrorResolveResult will be returned. - ResolveResult Resolve(ITypeResolveContext context); - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/IEntity.cs b/ICSharpCode.Decompiler/TypeSystem/IEntity.cs index fdc1d83f6..3c9cf7109 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IEntity.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IEntity.cs @@ -21,66 +21,6 @@ using System.Collections.Generic; namespace ICSharpCode.Decompiler.TypeSystem { - /// - /// Represents an unresolved entity. - /// - public interface IUnresolvedEntity : INamedElement - { - /// - /// Gets the metadata token for this entity. - /// - /// - /// The token is only valid within the context of the assembly defining this entity. - /// Token may be 0 if this is a generated member. - /// - System.Reflection.Metadata.EntityHandle MetadataToken { get; } - - /// - /// Gets the entity type. - /// - SymbolKind SymbolKind { get; } - - /// - /// Gets the declaring class. - /// For members, this is the class that contains the member. - /// For nested classes, this is the outer class. For top-level entities, this property returns null. - /// - IUnresolvedTypeDefinition DeclaringTypeDefinition { get; } - - /// - /// Gets the attributes on this entity. - /// - IList Attributes { get; } - - /// - /// Gets the accessibility of this entity. - /// - Accessibility Accessibility { get; } - - /// - /// Gets whether this entity is static. - /// Returns true if either the 'static' or the 'const' modifier is set. - /// - bool IsStatic { get; } - - /// - /// Returns whether this entity is abstract. - /// - /// Static classes also count as abstract classes. - bool IsAbstract { get; } - - /// - /// Returns whether this entity is sealed. - /// - /// Static classes also count as sealed classes. - bool IsSealed { get; } - - /// - /// Gets whether this member is declared to be shadowing another member with the same name. - /// - bool IsShadowing { get; } - } - /// /// Represents a resolved entity. /// diff --git a/ICSharpCode.Decompiler/TypeSystem/IEvent.cs b/ICSharpCode.Decompiler/TypeSystem/IEvent.cs index a4f3b45e6..ee17f2b75 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IEvent.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IEvent.cs @@ -18,29 +18,6 @@ namespace ICSharpCode.Decompiler.TypeSystem { - public interface IUnresolvedEvent : IUnresolvedMember - { - bool CanAdd { get; } - bool CanRemove { get; } - bool CanInvoke { get; } - - IUnresolvedMethod AddAccessor { get; } - IUnresolvedMethod RemoveAccessor { get; } - IUnresolvedMethod InvokeAccessor { get; } - - /// - /// Resolves the member. - /// - /// - /// Context for looking up the member. The context must specify the current assembly. - /// A that specifies the current assembly is sufficient. - /// - /// - /// Returns the resolved member, or null if the member could not be found. - /// - new IEvent Resolve(ITypeResolveContext context); - } - public interface IEvent : IMember { bool CanAdd { get; } diff --git a/ICSharpCode.Decompiler/TypeSystem/IField.cs b/ICSharpCode.Decompiler/TypeSystem/IField.cs index 23ca693ac..9551b611a 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IField.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IField.cs @@ -18,48 +18,6 @@ namespace ICSharpCode.Decompiler.TypeSystem { - /// - /// Represents a field or constant. - /// - public interface IUnresolvedField : IUnresolvedMember - { - /// - /// Gets whether this field is readonly. - /// - bool IsReadOnly { get; } - - /// - /// Gets whether this field is volatile. - /// - bool IsVolatile { get; } - - /// - /// Gets whether this field is a constant (C#-like const). - /// - bool IsConst { get; } - - /// - /// Gets whether this field is a fixed size buffer (C#-like fixed). - /// If this is true, then ConstantValue contains the size of the buffer. - /// - bool IsFixed { get; } - - - IConstantValue ConstantValue { get; } - - /// - /// Resolves the member. - /// - /// - /// Context for looking up the member. The context must specify the current assembly. - /// A that specifies the current assembly is sufficient. - /// - /// - /// Returns the resolved member, or null if the member could not be found. - /// - new IField Resolve(ITypeResolveContext context); - } - /// /// Represents a field or constant. /// diff --git a/ICSharpCode.Decompiler/TypeSystem/IMember.cs b/ICSharpCode.Decompiler/TypeSystem/IMember.cs index e8e7ec4c0..2ba6ecb94 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IMember.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IMember.cs @@ -21,66 +21,6 @@ using System.Collections.Generic; namespace ICSharpCode.Decompiler.TypeSystem { - /// - /// Method/field/property/event. - /// - public interface IUnresolvedMember : IUnresolvedEntity, IMemberReference - { - /// - /// Gets the return type of this member. - /// This property never returns null. - /// - ITypeReference ReturnType { get; } - - /// - /// Gets whether this member is explicitly implementing an interface. - /// If this property is true, the member can only be called through the interfaces it implements. - /// - bool IsExplicitInterfaceImplementation { get; } - - /// - /// Gets the interfaces that are explicitly implemented by this member. - /// - IList ExplicitInterfaceImplementations { get; } - - /// - /// Gets if the member is virtual. Is true only if the "virtual" modifier was used, but non-virtual - /// members can be overridden, too; if they are abstract or overriding a method. - /// - bool IsVirtual { get; } - - /// - /// Gets whether this member is overriding another member. - /// - bool IsOverride { get; } - - /// - /// Gets if the member can be overridden. Returns true when the member is "abstract", "virtual" or "override" but not "sealed". - /// - bool IsOverridable { get; } - - /// - /// Resolves the member. - /// - /// - /// Context for looking up the member. The context must specify the current assembly. - /// A that specifies the current assembly is sufficient. - /// - /// - /// Returns the resolved member, or null if the member could not be found. - /// - new IMember Resolve(ITypeResolveContext context); - - /// - /// Creates the resolved member. - /// - /// - /// The language-specific context that includes the parent type definition. - /// - /// - IMember CreateResolved(ITypeResolveContext context); - } - public interface IMemberReference { /// diff --git a/ICSharpCode.Decompiler/TypeSystem/IMethod.cs b/ICSharpCode.Decompiler/TypeSystem/IMethod.cs index d29803a0f..c2161694b 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IMethod.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IMethod.cs @@ -21,56 +21,6 @@ using System.Collections.Generic; namespace ICSharpCode.Decompiler.TypeSystem { - public interface IUnresolvedMethod : IUnresolvedParameterizedMember - { - /// - /// Gets the attributes associated with the return type. (e.g. [return: MarshalAs(...)]) - /// - IList ReturnTypeAttributes { get; } - - IList TypeParameters { get; } - - bool IsConstructor { get; } - bool IsDestructor { get; } - bool IsOperator { get; } - - /// - /// Gets whether the method is a C#-style partial method. - /// Check to test if it is a partial method declaration or implementation. - /// - bool IsPartial { get; } - - /// - /// Gets whether the method is a C#-style async method. - /// - bool IsAsync { get; } - - /// - /// Gets whether the method has a body. - /// This property returns false for abstract or extern methods, - /// or for partial methods without implementation. - /// - bool HasBody { get; } - - /// - /// If this method is an accessor, returns a reference to the corresponding property/event. - /// Otherwise, returns null. - /// - IUnresolvedMember AccessorOwner { get; } - - /// - /// Resolves the member. - /// - /// - /// Context for looking up the member. The context must specify the current assembly. - /// A that specifies the current assembly is sufficient. - /// - /// - /// Returns the resolved member, or null if the member could not be found. - /// - new IMethod Resolve(ITypeResolveContext context); - } - /// /// Represents a method, constructor, destructor or operator. /// diff --git a/ICSharpCode.Decompiler/TypeSystem/IParameter.cs b/ICSharpCode.Decompiler/TypeSystem/IParameter.cs index 8b6acb8b6..06d777f0f 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IParameter.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IParameter.cs @@ -20,46 +20,6 @@ using System.Collections.Generic; namespace ICSharpCode.Decompiler.TypeSystem { - public interface IUnresolvedParameter - { - /// - /// Gets the name of the variable. - /// - string Name { get; } - - /// - /// Gets the type of the variable. - /// - ITypeReference Type { get; } - - /// - /// Gets the list of attributes. - /// - IList Attributes { get; } - - /// - /// Gets whether this parameter is a C# 'ref' parameter. - /// - bool IsRef { get; } - - /// - /// Gets whether this parameter is a C# 'out' parameter. - /// - bool IsOut { get; } - - /// - /// Gets whether this parameter is a C# 'params' parameter. - /// - bool IsParams { get; } - - /// - /// Gets whether this parameter is optional. - /// - bool IsOptional { get; } - - IParameter CreateResolvedParameter(ITypeResolveContext context); - } - public interface IParameter : IVariable { /// diff --git a/ICSharpCode.Decompiler/TypeSystem/IParameterizedMember.cs b/ICSharpCode.Decompiler/TypeSystem/IParameterizedMember.cs index 09ae38980..7f7e055ed 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IParameterizedMember.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IParameterizedMember.cs @@ -20,14 +20,6 @@ using System.Collections.Generic; namespace ICSharpCode.Decompiler.TypeSystem { - /// - /// Represents a method or property. - /// - public interface IUnresolvedParameterizedMember : IUnresolvedMember - { - IList Parameters { get; } - } - /// /// Represents a method or property. /// diff --git a/ICSharpCode.Decompiler/TypeSystem/IProperty.cs b/ICSharpCode.Decompiler/TypeSystem/IProperty.cs index 85e10c666..495f7c22c 100644 --- a/ICSharpCode.Decompiler/TypeSystem/IProperty.cs +++ b/ICSharpCode.Decompiler/TypeSystem/IProperty.cs @@ -18,32 +18,6 @@ namespace ICSharpCode.Decompiler.TypeSystem { - /// - /// Represents a property or indexer. - /// - public interface IUnresolvedProperty : IUnresolvedParameterizedMember - { - bool CanGet { get; } - bool CanSet { get; } - - IUnresolvedMethod Getter { get; } - IUnresolvedMethod Setter { get; } - - bool IsIndexer { get; } - - /// - /// Resolves the member. - /// - /// - /// Context for looking up the member. The context must specify the current assembly. - /// A that specifies the current assembly is sufficient. - /// - /// - /// Returns the resolved member, or null if the member could not be found. - /// - new IProperty Resolve(ITypeResolveContext context); - } - /// /// Represents a property or indexer. /// diff --git a/ICSharpCode.Decompiler/TypeSystem/ITypeDefinition.cs b/ICSharpCode.Decompiler/TypeSystem/ITypeDefinition.cs index a38b05dd5..dbb2e1162 100644 --- a/ICSharpCode.Decompiler/TypeSystem/ITypeDefinition.cs +++ b/ICSharpCode.Decompiler/TypeSystem/ITypeDefinition.cs @@ -20,76 +20,6 @@ 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. diff --git a/ICSharpCode.Decompiler/TypeSystem/ITypeParameter.cs b/ICSharpCode.Decompiler/TypeSystem/ITypeParameter.cs index 34c530a7b..52b659b70 100644 --- a/ICSharpCode.Decompiler/TypeSystem/ITypeParameter.cs +++ b/ICSharpCode.Decompiler/TypeSystem/ITypeParameter.cs @@ -20,35 +20,6 @@ using System.Collections.Generic; namespace ICSharpCode.Decompiler.TypeSystem { - /// - /// Type parameter of a generic class/method. - /// - public interface IUnresolvedTypeParameter : INamedElement - { - /// - /// Get the type of this type parameter's owner. - /// - /// SymbolKind.TypeDefinition or SymbolKind.Method - SymbolKind OwnerType { get; } - - /// - /// Gets the index of the type parameter in the type parameter list of the owning method/class. - /// - int Index { get; } - - /// - /// Gets the list of attributes declared on this type parameter. - /// - IList Attributes { get; } - - /// - /// Gets the variance of this type parameter. - /// - VarianceModifier Variance { get; } - - ITypeParameter CreateResolvedTypeParameter(ITypeResolveContext context); - } - /// /// Type parameter of a generic class/method. /// diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedEntity.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedEntity.cs deleted file mode 100644 index e7f24cdc7..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedEntity.cs +++ /dev/null @@ -1,85 +0,0 @@ -// 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; -using System.Collections.Generic; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - /// - /// Implementation of that resolves an unresolved entity. - /// - public abstract class AbstractResolvedEntity : IEntity - { - protected readonly IUnresolvedEntity unresolved; - protected readonly ITypeResolveContext parentContext; - - protected AbstractResolvedEntity(IUnresolvedEntity unresolved, ITypeResolveContext parentContext) - { - if (unresolved == null) - throw new ArgumentNullException("unresolved"); - if (parentContext == null) - throw new ArgumentNullException("parentContext"); - this.unresolved = unresolved; - this.parentContext = parentContext; - this.Attributes = unresolved.Attributes.CreateResolvedAttributes(parentContext); - } - - public System.Reflection.Metadata.EntityHandle MetadataToken => unresolved.MetadataToken; - - public SymbolKind SymbolKind { - get { return unresolved.SymbolKind; } - } - - public ITypeDefinition DeclaringTypeDefinition { - get { return parentContext.CurrentTypeDefinition; } - } - - public virtual IType DeclaringType { - get { return parentContext.CurrentTypeDefinition; } - } - - public IAssembly ParentAssembly { - get { return parentContext.CurrentAssembly; } - } - - public IReadOnlyList Attributes { get; protected set; } - IEnumerable IEntity.GetAttributes() => Attributes; - - public bool IsStatic { get { return unresolved.IsStatic; } } - public bool IsAbstract { get { return unresolved.IsAbstract; } } - public bool IsSealed { get { return unresolved.IsSealed; } } - public bool IsShadowing { get { return unresolved.IsShadowing; } } - - public ICompilation Compilation { - get { return parentContext.Compilation; } - } - - public string FullName { get { return unresolved.FullName; } } - public string Name { get { return unresolved.Name; } } - public string ReflectionName { get { return unresolved.ReflectionName; } } - public string Namespace { get { return unresolved.Namespace; } } - - public virtual Accessibility Accessibility { get { return unresolved.Accessibility; } } - - public override string ToString() - { - return "[" + this.SymbolKind.ToString() + " " + this.ReflectionName + "]"; - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedMember.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedMember.cs deleted file mode 100644 index adc33e035..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedMember.cs +++ /dev/null @@ -1,138 +0,0 @@ -// 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; -using System.Linq; -using ICSharpCode.Decompiler.Util; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - /// - /// Implementation of that resolves an unresolved member. - /// - public abstract class AbstractResolvedMember : AbstractResolvedEntity, IMember - { - protected new readonly IUnresolvedMember unresolved; - protected readonly ITypeResolveContext context; - volatile IType returnType; - IReadOnlyList implementedInterfaceMembers; - - protected AbstractResolvedMember(IUnresolvedMember unresolved, ITypeResolveContext parentContext) - : base(unresolved, parentContext) - { - this.unresolved = unresolved; - this.context = parentContext.WithCurrentMember(this); - } - - IMember IMember.MemberDefinition { - get { return this; } - } - - public IType ReturnType { - get { - return this.returnType ?? (this.returnType = unresolved.ReturnType.Resolve(context)); - } - } - - public IUnresolvedMember UnresolvedMember { - get { return unresolved; } - } - - public IEnumerable ExplicitlyImplementedInterfaceMembers { - get { - IReadOnlyList result = LazyInit.VolatileRead(ref this.implementedInterfaceMembers); - if (result != null) { - return result; - } else { - return LazyInit.GetOrSet(ref implementedInterfaceMembers, FindImplementedInterfaceMembers()); - } - } - } - - IReadOnlyList FindImplementedInterfaceMembers() - { - if (unresolved.IsExplicitInterfaceImplementation) { - List result = new List(); - foreach (var memberReference in unresolved.ExplicitInterfaceImplementations) { - IMember member = memberReference.Resolve(context); - if (member != null) - result.Add(member); - } - return result.ToArray(); - } else if (unresolved.IsStatic || unresolved.Accessibility != Accessibility.Public || DeclaringTypeDefinition == null || DeclaringTypeDefinition.Kind == TypeKind.Interface) { - return EmptyList.Instance; - } else { - // TODO: implement interface member mappings correctly - var result = InheritanceHelper.GetBaseMembers(this, true) - .Where(m => m.DeclaringTypeDefinition != null && m.DeclaringTypeDefinition.Kind == TypeKind.Interface) - .ToArray(); - - IEnumerable otherMembers = DeclaringTypeDefinition.Members; - if (SymbolKind == SymbolKind.Accessor) - otherMembers = DeclaringTypeDefinition.GetAccessors(options: GetMemberOptions.IgnoreInheritedMembers); - result = result.Where(item => !otherMembers.Any(m => m.IsExplicitInterfaceImplementation && m.ExplicitlyImplementedInterfaceMembers.Contains(item))).ToArray(); - - return result; - } - } - - public bool IsExplicitInterfaceImplementation { - get { return unresolved.IsExplicitInterfaceImplementation; } - } - - public bool IsVirtual { - get { return unresolved.IsVirtual; } - } - - public bool IsOverride { - get { return unresolved.IsOverride; } - } - - public bool IsOverridable { - get { return unresolved.IsOverridable; } - } - - public TypeParameterSubstitution Substitution { - get { return TypeParameterSubstitution.Identity; } - } - - public virtual bool Equals(IMember obj, TypeVisitor typeNormalization) - { - return Equals(obj); - } - - public abstract IMember Specialize(TypeParameterSubstitution substitution); - - internal IMethod GetAccessor(ref IMethod accessorField, IUnresolvedMethod unresolvedAccessor) - { - if (unresolvedAccessor == null) - return null; - IMethod result = LazyInit.VolatileRead(ref accessorField); - if (result != null) { - return result; - } else { - return LazyInit.GetOrSet(ref accessorField, CreateResolvedAccessor(unresolvedAccessor)); - } - } - - protected virtual IMethod CreateResolvedAccessor(IUnresolvedMethod unresolvedAccessor) - { - return (IMethod)unresolvedAccessor.CreateResolved(context); - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedEntity.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedEntity.cs deleted file mode 100644 index d46e441e6..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedEntity.cs +++ /dev/null @@ -1,252 +0,0 @@ -// 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; -using System.Collections.Generic; -using System.Text; -using ICSharpCode.Decompiler.Util; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - /// - /// Base class for implementations. - /// - [Serializable] - public abstract class AbstractUnresolvedEntity : IUnresolvedEntity, IFreezable - { - // possible optimizations to reduce the memory usage of AbstractUnresolvedEntity: - // - store regions in more compact form (e.g. assume both file names are identical; use ushort for columns) - - IUnresolvedTypeDefinition declaringTypeDefinition; - - string name = string.Empty; - IList attributes; - System.Reflection.Metadata.EntityHandle metadataToken; - - // 1 byte per enum + 2 bytes for flags - SymbolKind symbolKind; - Accessibility accessibility; - internal BitVector16 flags; - - // flags for AbstractUnresolvedEntity: - internal const ushort FlagFrozen = 0x0001; - internal const ushort FlagSealed = 0x0002; - internal const ushort FlagAbstract = 0x0004; - internal const ushort FlagShadowing = 0x0008; - //internal const ushort FlagSynthetic = 0x0010; - internal const ushort FlagStatic = 0x0020; - // flags for DefaultUnresolvedTypeDefinition/LazyCecilTypeDefinition - internal const ushort FlagAddDefaultConstructorIfRequired = 0x0040; - internal const ushort FlagHasExtensionMethods = 0x0080; - internal const ushort FlagHasNoExtensionMethods = 0x0100; - internal const ushort FlagPartialTypeDefinition = 0x0200; - // flags for AbstractUnresolvedMember: - internal const ushort FlagExplicitInterfaceImplementation = 0x0040; - internal const ushort FlagVirtual = 0x0080; - internal const ushort FlagOverride = 0x0100; - // flags for DefaultField: - internal const ushort FlagFieldIsReadOnly = 0x1000; - internal const ushort FlagFieldIsVolatile = 0x2000; - internal const ushort FlagFieldIsFixedSize = 0x4000; - // flags for DefaultMethod: - internal const ushort FlagExtensionMethod = 0x1000; - internal const ushort FlagPartialMethod = 0x2000; - internal const ushort FlagHasBody = 0x4000; - internal const ushort FlagAsyncMethod = 0x8000; - - public bool IsFrozen { - get { return flags[FlagFrozen]; } - } - - public void Freeze() - { - if (!flags[FlagFrozen]) { - FreezeInternal(); - flags[FlagFrozen] = true; - } - } - - protected virtual void FreezeInternal() - { - attributes = FreezableHelper.FreezeListAndElements(attributes); - } - - /// - /// Uses the specified interning provider to intern - /// strings and lists in this entity. - /// This method does not test arbitrary objects to see if they implement ISupportsInterning; - /// instead we assume that those are interned immediately when they are created (before they are added to this entity). - /// - public virtual void ApplyInterningProvider(InterningProvider provider) - { - if (provider == null) - throw new ArgumentNullException("provider"); - ThrowIfFrozen(); - name = provider.Intern(name); - attributes = provider.InternList(attributes); - } - - /// - /// Creates a shallow clone of this entity. - /// Collections (e.g. a type's member list) will be cloned as well, but the elements - /// of said list will not be. - /// If this instance is frozen, the clone will be unfrozen. - /// - public virtual object Clone() - { - var copy = (AbstractUnresolvedEntity)MemberwiseClone(); - copy.flags[FlagFrozen] = false; - if (attributes != null) - copy.attributes = new List(attributes); - return copy; - } - - protected void ThrowIfFrozen() - { - FreezableHelper.ThrowIfFrozen(this); - } - - public System.Reflection.Metadata.EntityHandle MetadataToken { - get { return metadataToken; } - set { - ThrowIfFrozen(); - metadataToken = value; - } - } - - public SymbolKind SymbolKind { - get { return symbolKind; } - set { - ThrowIfFrozen(); - symbolKind = value; - } - } - - public IUnresolvedTypeDefinition DeclaringTypeDefinition { - get { return declaringTypeDefinition; } - set { - ThrowIfFrozen(); - declaringTypeDefinition = value; - } - } - - public IList Attributes { - get { - if (attributes == null) - attributes = new List(); - return attributes; - } - } - - public string Name { - get { return name; } - set { - if (value == null) - throw new ArgumentNullException("value"); - ThrowIfFrozen(); - name = value; - } - } - - public virtual string FullName { - get { - if (declaringTypeDefinition != null) - return declaringTypeDefinition.FullName + "." + name; - else if (!string.IsNullOrEmpty(this.Namespace)) - return this.Namespace + "." + name; - else - return name; - } - } - - public virtual string Namespace { - get { - if (declaringTypeDefinition != null) - return declaringTypeDefinition.Namespace; - else - return string.Empty; - } - set { - throw new NotSupportedException(); - } - } - - public virtual string ReflectionName { - get { - if (declaringTypeDefinition != null) - return declaringTypeDefinition.ReflectionName + "." + name; - else - return name; - } - } - - public Accessibility Accessibility { - get { return accessibility; } - set { - ThrowIfFrozen(); - accessibility = value; - } - } - - public bool IsStatic { - get { return flags[FlagStatic]; } - set { - ThrowIfFrozen(); - flags[FlagStatic] = value; - } - } - - public bool IsAbstract { - get { return flags[FlagAbstract]; } - set { - ThrowIfFrozen(); - flags[FlagAbstract] = value; - } - } - - public bool IsSealed { - get { return flags[FlagSealed]; } - set { - ThrowIfFrozen(); - flags[FlagSealed] = value; - } - } - - public bool IsShadowing { - get { return flags[FlagShadowing]; } - set { - ThrowIfFrozen(); - flags[FlagShadowing] = value; - } - } - - public override string ToString() - { - StringBuilder b = new StringBuilder("["); - b.Append(GetType().Name); - b.Append(' '); - if (this.DeclaringTypeDefinition != null) { - b.Append(this.DeclaringTypeDefinition.Name); - b.Append('.'); - } - b.Append(this.Name); - b.Append(']'); - return b.ToString(); - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedMember.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedMember.cs deleted file mode 100644 index 7fcdf75d0..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedMember.cs +++ /dev/null @@ -1,268 +0,0 @@ -// 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; -using System.Collections.Generic; -using System.Linq; -using ICSharpCode.Decompiler.Util; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - /// - /// Base class for implementations. - /// - [Serializable] - public abstract class AbstractUnresolvedMember : AbstractUnresolvedEntity, IUnresolvedMember - { - ITypeReference returnType = SpecialType.UnknownType; - IList interfaceImplementations; - - public override void ApplyInterningProvider(InterningProvider provider) - { - base.ApplyInterningProvider(provider); - interfaceImplementations = provider.InternList(interfaceImplementations); - } - - protected override void FreezeInternal() - { - base.FreezeInternal(); - interfaceImplementations = FreezableHelper.FreezeList(interfaceImplementations); - } - - public override object Clone() - { - var copy = (AbstractUnresolvedMember)base.Clone(); - if (interfaceImplementations != null) - copy.interfaceImplementations = new List(interfaceImplementations); - return copy; - } - - /* - [Serializable] - internal new class RareFields : AbstractUnresolvedEntity.RareFields - { - internal IList interfaceImplementations; - - public override void ApplyInterningProvider(IInterningProvider provider) - { - base.ApplyInterningProvider(provider); - interfaceImplementations = provider.InternList(interfaceImplementations); - } - - protected internal override void FreezeInternal() - { - interfaceImplementations = FreezableHelper.FreezeListAndElements(interfaceImplementations); - base.FreezeInternal(); - } - - override Clone(){} - } - - internal override AbstractUnresolvedEntity.RareFields WriteRareFields() - { - ThrowIfFrozen(); - if (rareFields == null) rareFields = new RareFields(); - return rareFields; - }*/ - - public ITypeReference ReturnType { - get { return returnType; } - set { - if (value == null) - throw new ArgumentNullException("value"); - ThrowIfFrozen(); - returnType = value; - } - } - - public bool IsExplicitInterfaceImplementation { - get { return flags[FlagExplicitInterfaceImplementation]; } - set { - ThrowIfFrozen(); - flags[FlagExplicitInterfaceImplementation] = value; - } - } - - public IList ExplicitInterfaceImplementations { - get { - /* - RareFields rareFields = (RareFields)this.rareFields; - if (rareFields == null || rareFields.interfaceImplementations == null) { - rareFields = (RareFields)WriteRareFields(); - return rareFields.interfaceImplementations = new List(); - } - return rareFields.interfaceImplementations; - */ - if (interfaceImplementations == null) - interfaceImplementations = new List(); - return interfaceImplementations; - } - } - - public bool IsVirtual { - get { return flags[FlagVirtual]; } - set { - ThrowIfFrozen(); - flags[FlagVirtual] = value; - } - } - - public bool IsOverride { - get { return flags[FlagOverride]; } - set { - ThrowIfFrozen(); - flags[FlagOverride] = value; - } - } - - public bool IsOverridable { - get { - // override or virtual or abstract but not sealed - return (flags.Data & (FlagOverride | FlagVirtual | FlagAbstract)) != 0 && !this.IsSealed; - } - } - - ITypeReference IMemberReference.DeclaringTypeReference { - get { return this.DeclaringTypeDefinition; } - } - - #region Resolve - public abstract IMember CreateResolved(ITypeResolveContext context); - - public virtual IMember Resolve(ITypeResolveContext context) - { - ITypeReference interfaceTypeReference = null; - if (this.IsExplicitInterfaceImplementation && this.ExplicitInterfaceImplementations.Count == 1) - interfaceTypeReference = this.ExplicitInterfaceImplementations[0].DeclaringTypeReference; - return Resolve(ExtendContextForType(context, this.DeclaringTypeDefinition), this.SymbolKind, this.Name, interfaceTypeReference); - } - - protected static ITypeResolveContext ExtendContextForType(ITypeResolveContext assemblyContext, IUnresolvedTypeDefinition typeDef) - { - if (typeDef == null) - return assemblyContext; - ITypeResolveContext parentContext; - if (typeDef.DeclaringTypeDefinition != null) - parentContext = ExtendContextForType(assemblyContext, typeDef.DeclaringTypeDefinition); - else - parentContext = assemblyContext; - ITypeDefinition resolvedTypeDef = typeDef.Resolve(assemblyContext).GetDefinition(); - return typeDef.CreateResolveContext(parentContext).WithCurrentTypeDefinition(resolvedTypeDef); - } - - public static IMember Resolve(ITypeResolveContext context, - SymbolKind symbolKind, - string name, - ITypeReference explicitInterfaceTypeReference = null, - IList typeParameterNames = null, - IList parameterTypeReferences = null) - { - if (context.CurrentTypeDefinition == null) - return null; - if (parameterTypeReferences == null) - parameterTypeReferences = EmptyList.Instance; - if (typeParameterNames == null || typeParameterNames.Count == 0) { - // non-generic member - // In this case, we can simply resolve the parameter types in the given context - var parameterTypes = parameterTypeReferences.Resolve(context); - if (explicitInterfaceTypeReference == null) { - foreach (IMember member in context.CurrentTypeDefinition.Members) { - if (member.IsExplicitInterfaceImplementation) - continue; - if (IsNonGenericMatch(member, symbolKind, name, parameterTypes)) - return member; - } - } else { - IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(context); - foreach (IMember member in context.CurrentTypeDefinition.Members) { - if (!member.IsExplicitInterfaceImplementation) - continue; - var interfaceMembers = member.ExplicitlyImplementedInterfaceMembers.ToList(); - if (interfaceMembers.Count != 1) - continue; - if (IsNonGenericMatch(member, symbolKind, name, parameterTypes)) { - if (explicitInterfaceType.Equals(interfaceMembers[0].DeclaringType)) - return member; - } - } - } - } else { - // generic member - // In this case, we must specify the correct context for resolving the parameter types - foreach (IMethod method in context.CurrentTypeDefinition.Methods) { - if (method.SymbolKind != symbolKind) - continue; - if (method.Name != name) - continue; - if (method.Parameters.Count != parameterTypeReferences.Count) - continue; - // Compare type parameter count and names: - if (!typeParameterNames.SequenceEqual(method.TypeParameters.Select(tp => tp.Name))) - continue; - // Once we know the type parameter names are fitting, we can resolve the - // type references in the context of the method: - var contextForMethod = context.WithCurrentMember(method); - var parameterTypes = parameterTypeReferences.Resolve(contextForMethod); - if (!IsParameterTypeMatch(method, parameterTypes)) - continue; - if (explicitInterfaceTypeReference == null) { - if (!method.IsExplicitInterfaceImplementation) - return method; - } else if (method.IsExplicitInterfaceImplementation && method.ExplicitlyImplementedInterfaceMembers.Count() == 1) { - IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(contextForMethod); - if (explicitInterfaceType.Equals(method.ExplicitlyImplementedInterfaceMembers.First().DeclaringType)) - return method; - } - } - } - return null; - } - - static bool IsNonGenericMatch(IMember member, SymbolKind symbolKind, string name, IReadOnlyList parameterTypes) - { - if (member.SymbolKind != symbolKind) - return false; - if (member.Name != name) - return false; - IMethod method = member as IMethod; - if (method != null && method.TypeParameters.Count > 0) - return false; - return IsParameterTypeMatch(member, parameterTypes); - } - - static bool IsParameterTypeMatch(IMember member, IReadOnlyList parameterTypes) - { - IParameterizedMember parameterizedMember = member as IParameterizedMember; - if (parameterizedMember == null) { - return parameterTypes.Count == 0; - } else if (parameterTypes.Count == parameterizedMember.Parameters.Count) { - for (int i = 0; i < parameterTypes.Count; i++) { - IType type1 = parameterTypes[i]; - IType type2 = parameterizedMember.Parameters[i].Type; - if (!type1.Equals(type2)) { - return false; - } - } - return true; - } else { - return false; - } - } - #endregion - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/AccessorOwnerMemberReference.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/AccessorOwnerMemberReference.cs deleted file mode 100644 index efd95d849..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/AccessorOwnerMemberReference.cs +++ /dev/null @@ -1,51 +0,0 @@ -// 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; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - /// - /// Given a reference to an accessor, returns the accessor's owner. - /// - [Serializable] - sealed class AccessorOwnerMemberReference : IMemberReference - { - readonly IMemberReference accessorReference; - - public AccessorOwnerMemberReference(IMemberReference accessorReference) - { - if (accessorReference == null) - throw new ArgumentNullException("accessorReference"); - this.accessorReference = accessorReference; - } - - public ITypeReference DeclaringTypeReference { - get { return accessorReference.DeclaringTypeReference; } - } - - public IMember Resolve(ITypeResolveContext context) - { - IMethod method = accessorReference.Resolve(context) as IMethod; - if (method != null) - return method.AccessorOwner; - else - return null; - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/BlobReader.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/BlobReader.cs deleted file mode 100644 index f0839ed71..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/BlobReader.cs +++ /dev/null @@ -1,399 +0,0 @@ -// -// BlobReader.cs -// -// Author: -// Daniel Grunwald -// -// 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; -using System.Collections.Generic; -using ICSharpCode.Decompiler.Semantics; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - sealed class BlobReader - { - internal static int GetBlobHashCode(byte[] blob) - { - unchecked { - int hash = 0; - foreach (byte b in blob) { - hash *= 257; - hash += b; - } - return hash; - } - } - - internal static bool BlobEquals(byte[] a, byte[] b) - { - if (a.Length != b.Length) - return false; - for (int i = 0; i < a.Length; i++) { - if (a[i] != b[i]) - return false; - } - return true; - } - - byte[] buffer; - int position; - readonly IAssembly currentResolvedAssembly; - - public BlobReader(byte[] buffer, IAssembly currentResolvedAssembly) - { - if (buffer == null) - throw new ArgumentNullException("buffer"); - this.buffer = buffer; - this.currentResolvedAssembly = currentResolvedAssembly; - } - - public byte ReadByte() - { - return buffer[position++]; - } - - public sbyte ReadSByte() - { - unchecked { - return(sbyte) ReadByte(); - } - } - - public byte[] ReadBytes(int length) - { - var bytes = new byte[length]; - Buffer.BlockCopy(buffer, position, bytes, 0, length); - position += length; - return bytes; - } - - public ushort ReadUInt16() - { - unchecked { - ushort value =(ushort)(buffer[position] - |(buffer[position + 1] << 8)); - position += 2; - return value; - } - } - - public short ReadInt16() - { - unchecked { - return(short) ReadUInt16(); - } - } - - public uint ReadUInt32() - { - unchecked { - uint value =(uint)(buffer[position] - |(buffer[position + 1] << 8) - |(buffer[position + 2] << 16) - |(buffer[position + 3] << 24)); - position += 4; - return value; - } - } - - public int ReadInt32() - { - unchecked { - return(int) ReadUInt32(); - } - } - - public ulong ReadUInt64() - { - unchecked { - uint low = ReadUInt32(); - uint high = ReadUInt32(); - - return(((ulong) high) << 32) | low; - } - } - - public long ReadInt64() - { - unchecked { - return(long) ReadUInt64(); - } - } - - public uint ReadCompressedUInt32() - { - unchecked { - byte first = ReadByte(); - if((first & 0x80) == 0) - return first; - - if((first & 0x40) == 0) - return((uint)(first & ~0x80) << 8) - | ReadByte(); - - return((uint)(first & ~0xc0) << 24) - |(uint) ReadByte() << 16 - |(uint) ReadByte() << 8 - | ReadByte(); - } - } - - public float ReadSingle() - { - unchecked { - if(!BitConverter.IsLittleEndian) { - var bytes = ReadBytes(4); - Array.Reverse(bytes); - return BitConverter.ToSingle(bytes, 0); - } - - float value = BitConverter.ToSingle(buffer, position); - position += 4; - return value; - } - } - - public double ReadDouble() - { - unchecked { - if(!BitConverter.IsLittleEndian) { - var bytes = ReadBytes(8); - Array.Reverse(bytes); - return BitConverter.ToDouble(bytes, 0); - } - - double value = BitConverter.ToDouble(buffer, position); - position += 8; - return value; - } - } - - public ResolveResult ReadFixedArg(IType argType) - { - if (argType.Kind == TypeKind.Array) { - if (((ArrayType)argType).Dimensions != 1) { - // Only single-dimensional arrays are supported - return ErrorResolveResult.UnknownError; - } - IType elementType = ((ArrayType)argType).ElementType; - uint numElem = ReadUInt32(); - if (numElem == 0xffffffff) { - // null reference - return new ConstantResolveResult(argType, null); - } else { - ResolveResult[] elements = new ResolveResult[numElem]; - for (int i = 0; i < elements.Length; i++) { - elements[i] = ReadElem(elementType); - // Stop decoding when encountering an error: - if (elements[i].IsError) - return ErrorResolveResult.UnknownError; - } - IType int32 = currentResolvedAssembly.Compilation.FindType(KnownTypeCode.Int32); - ResolveResult[] sizeArgs = { new ConstantResolveResult(int32, elements.Length) }; - return new ArrayCreateResolveResult(argType, sizeArgs, elements); - } - } else { - return ReadElem(argType); - } - } - - public ResolveResult ReadElem(IType elementType) - { - ITypeDefinition underlyingType; - if (elementType.Kind == TypeKind.Enum) { - underlyingType = elementType.GetDefinition().EnumUnderlyingType.GetDefinition(); - } else { - underlyingType = elementType.GetDefinition(); - } - if (underlyingType == null) - return ErrorResolveResult.UnknownError; - KnownTypeCode typeCode = underlyingType.KnownTypeCode; - if (typeCode == KnownTypeCode.Object) { - // boxed value type - IType boxedTyped = ReadCustomAttributeFieldOrPropType(); - ResolveResult elem = ReadFixedArg(boxedTyped); - if (elem.IsCompileTimeConstant && elem.ConstantValue == null) - return new ConstantResolveResult(elementType, null); - else - return new ConversionResolveResult(elementType, elem, Conversion.BoxingConversion); - } else if (typeCode == KnownTypeCode.Type) { - var type = ReadType(); - if (type != null) { - return new TypeOfResolveResult(underlyingType, type); - } else { - return new ConstantResolveResult(underlyingType, null); - } - } else { - return new ConstantResolveResult(elementType, ReadElemValue(typeCode)); - } - } - - object ReadElemValue(KnownTypeCode typeCode) - { - switch (typeCode) { - case KnownTypeCode.Boolean: - return ReadByte() != 0; - case KnownTypeCode.Char: - return (char)ReadUInt16(); - case KnownTypeCode.SByte: - return ReadSByte(); - case KnownTypeCode.Byte: - return ReadByte(); - case KnownTypeCode.Int16: - return ReadInt16(); - case KnownTypeCode.UInt16: - return ReadUInt16(); - case KnownTypeCode.Int32: - return ReadInt32(); - case KnownTypeCode.UInt32: - return ReadUInt32(); - case KnownTypeCode.Int64: - return ReadInt64(); - case KnownTypeCode.UInt64: - return ReadUInt64(); - case KnownTypeCode.Single: - return ReadSingle(); - case KnownTypeCode.Double: - return ReadDouble(); - case KnownTypeCode.String: - return ReadSerString(); - default: - throw new NotSupportedException(); - } - } - - public string ReadSerString () - { - if (buffer [position] == 0xff) { - position++; - return null; - } - - int length = (int) ReadCompressedUInt32(); - if (length == 0) - return string.Empty; - - string @string = System.Text.Encoding.UTF8.GetString( - buffer, position, - buffer [position + length - 1] == 0 ? length - 1 : length); - - position += length; - return @string; - } - - public KeyValuePair ReadNamedArg(IType attributeType) - { - SymbolKind memberType; - var b = ReadByte(); - switch (b) { - case 0x53: - memberType = SymbolKind.Field; - break; - case 0x54: - memberType = SymbolKind.Property; - break; - default: - throw new NotSupportedException(string.Format("Custom member type 0x{0:x} is not supported.", b)); - } - IType type = ReadCustomAttributeFieldOrPropType(); - string name = ReadSerString(); - ResolveResult val = ReadFixedArg(type); - IMember member = null; - // Use last matching member, as GetMembers() returns members from base types first. - foreach (IMember m in attributeType.GetMembers(m => m.SymbolKind == memberType && m.Name == name)) { - if (m.ReturnType.Equals(type)) - member = m; - } - return new KeyValuePair(member, val); - } - - IType ReadCustomAttributeFieldOrPropType() - { - ICompilation compilation = currentResolvedAssembly.Compilation; - var b = ReadByte(); - switch (b) { - case 0x02: - return compilation.FindType(KnownTypeCode.Boolean); - case 0x03: - return compilation.FindType(KnownTypeCode.Char); - case 0x04: - return compilation.FindType(KnownTypeCode.SByte); - case 0x05: - return compilation.FindType(KnownTypeCode.Byte); - case 0x06: - return compilation.FindType(KnownTypeCode.Int16); - case 0x07: - return compilation.FindType(KnownTypeCode.UInt16); - case 0x08: - return compilation.FindType(KnownTypeCode.Int32); - case 0x09: - return compilation.FindType(KnownTypeCode.UInt32); - case 0x0a: - return compilation.FindType(KnownTypeCode.Int64); - case 0x0b: - return compilation.FindType(KnownTypeCode.UInt64); - case 0x0c: - return compilation.FindType(KnownTypeCode.Single); - case 0x0d: - return compilation.FindType(KnownTypeCode.Double); - case 0x0e: - return compilation.FindType(KnownTypeCode.String); - case 0x1d: - return new ArrayType(compilation, ReadCustomAttributeFieldOrPropType()); - case 0x50: - return compilation.FindType(KnownTypeCode.Type); - case 0x51: // boxed value type - return compilation.FindType(KnownTypeCode.Object); - case 0x55: // enum - var type = ReadType(); - if (type == null) { - throw new NotSupportedException("Enum type should not be null."); - } - return type; - default: - throw new NotSupportedException(string.Format("Custom attribute type 0x{0:x} is not supported.", b)); - } - } - - IType ReadType() - { - string typeName = ReadSerString(); - if (typeName == null) { - return null; - } - ITypeReference typeReference = ReflectionHelper.ParseReflectionName(typeName); - IType typeInCurrentAssembly = typeReference.Resolve(new SimpleTypeResolveContext(currentResolvedAssembly)); - if (typeInCurrentAssembly.Kind != TypeKind.Unknown) - return typeInCurrentAssembly; - - // look for the type in mscorlib - ITypeDefinition systemObject = currentResolvedAssembly.Compilation.FindType(KnownTypeCode.Object).GetDefinition(); - if (systemObject != null) { - return typeReference.Resolve(new SimpleTypeResolveContext(systemObject.ParentAssembly)); - } else { - // couldn't find corlib - return the unknown IType for the current assembly - return typeInCurrentAssembly; - } - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultMemberReference.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultMemberReference.cs deleted file mode 100644 index 46210b199..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultMemberReference.cs +++ /dev/null @@ -1,115 +0,0 @@ -// 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; -using System.Collections.Generic; -using ICSharpCode.Decompiler.Util; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - /// - /// References an entity by its type and name. - /// This class can be used to refer to all members except for constructors and explicit interface implementations. - /// - /// - /// Resolving a DefaultMemberReference requires a context that provides enough information for resolving the declaring type reference - /// and the parameter types references. - /// - [Serializable] - public sealed class DefaultMemberReference : IMemberReference, ISupportsInterning - { - readonly SymbolKind symbolKind; - readonly ITypeReference typeReference; - readonly string name; - readonly int typeParameterCount; - readonly IList parameterTypes; - - public DefaultMemberReference(SymbolKind symbolKind, ITypeReference typeReference, string name, int typeParameterCount = 0, IList parameterTypes = null) - { - if (typeReference == null) - throw new ArgumentNullException("typeReference"); - if (name == null) - throw new ArgumentNullException("name"); - if (typeParameterCount != 0 && symbolKind != SymbolKind.Method) - throw new ArgumentException("Type parameter count > 0 is only supported for methods."); - this.symbolKind = symbolKind; - this.typeReference = typeReference; - this.name = name; - this.typeParameterCount = typeParameterCount; - this.parameterTypes = parameterTypes ?? EmptyList.Instance; - } - - public ITypeReference DeclaringTypeReference { - get { return typeReference; } - } - - static readonly NormalizeTypeVisitor normalizeTypeVisitor = new NormalizeTypeVisitor(); - - public IMember Resolve(ITypeResolveContext context) - { - IType type = typeReference.Resolve(context); - IEnumerable members; - if (symbolKind == SymbolKind.Accessor) { - members = type.GetAccessors( - m => m.Name == name && !m.IsExplicitInterfaceImplementation, - GetMemberOptions.IgnoreInheritedMembers); - } else if (symbolKind == SymbolKind.Method) { - members = type.GetMethods( - m => m.Name == name && m.SymbolKind == SymbolKind.Method - && m.TypeParameters.Count == typeParameterCount && !m.IsExplicitInterfaceImplementation, - GetMemberOptions.IgnoreInheritedMembers); - } else { - members = type.GetMembers( - m => m.Name == name && m.SymbolKind == symbolKind && !m.IsExplicitInterfaceImplementation, - GetMemberOptions.IgnoreInheritedMembers); - } - var resolvedParameterTypes = parameterTypes.Resolve(context); - foreach (IMember member in members) { - IParameterizedMember parameterizedMember = member as IParameterizedMember; - if (parameterizedMember == null) { - if (parameterTypes.Count == 0) - return member; - } else if (parameterTypes.Count == parameterizedMember.Parameters.Count) { - bool signatureMatches = true; - for (int i = 0; i < parameterTypes.Count; i++) { - IType type1 = resolvedParameterTypes[i].AcceptVisitor(normalizeTypeVisitor); - IType type2 = parameterizedMember.Parameters[i].Type.AcceptVisitor(normalizeTypeVisitor); - if (!type1.Equals(type2)) { - signatureMatches = false; - break; - } - } - if (signatureMatches) - return member; - } - } - return null; - } - - int ISupportsInterning.GetHashCodeForInterning() - { - return (int)symbolKind ^ typeReference.GetHashCode() ^ name.GetHashCode() ^ parameterTypes.GetHashCode(); - } - - bool ISupportsInterning.EqualsForInterning(ISupportsInterning other) - { - DefaultMemberReference o = other as DefaultMemberReference; - return o != null && symbolKind == o.symbolKind && typeReference == o.typeReference && name == o.name && parameterTypes == o.parameterTypes; - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleConstantValue.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleConstantValue.cs deleted file mode 100644 index b314b9e67..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleConstantValue.cs +++ /dev/null @@ -1,69 +0,0 @@ -// 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; -using ICSharpCode.Decompiler.Semantics; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - /// - /// A simple constant value that is independent of the resolve context. - /// - [Serializable] - public sealed class SimpleConstantValue : IConstantValue, ISupportsInterning - { - readonly ITypeReference type; - readonly object value; - - public SimpleConstantValue(ITypeReference type, object value) - { - if (type == null) - throw new ArgumentNullException("type"); - this.type = type; - this.value = value; - } - - public ResolveResult Resolve(ITypeResolveContext context) - { - return new ConstantResolveResult(type.Resolve(context), value); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", - Justification = "The C# keyword is lower case")] - public override string ToString() - { - if (value == null) - return "null"; - else if (value is bool) - return value.ToString().ToLowerInvariant(); - else - return value.ToString(); - } - - int ISupportsInterning.GetHashCodeForInterning() - { - return type.GetHashCode() ^ (value != null ? value.GetHashCode() : 0); - } - - bool ISupportsInterning.EqualsForInterning(ISupportsInterning other) - { - SimpleConstantValue scv = other as SimpleConstantValue; - return scv != null && type == scv.type && value == scv.value; - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleInterningProvider.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleInterningProvider.cs deleted file mode 100644 index caa491d23..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleInterningProvider.cs +++ /dev/null @@ -1,140 +0,0 @@ -// 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; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Runtime.CompilerServices; -using ICSharpCode.Decompiler.Util; - -namespace ICSharpCode.Decompiler.TypeSystem.Implementation -{ - /// - /// Simple interning provider. - /// - public sealed class SimpleInterningProvider : InterningProvider - { - sealed class InterningComparer : IEqualityComparer - { - public bool Equals(ISupportsInterning x, ISupportsInterning y) - { - return x.EqualsForInterning(y); - } - - public int GetHashCode(ISupportsInterning obj) - { - return obj.GetHashCodeForInterning(); - } - } - - sealed class ListComparer : IEqualityComparer - { - public bool Equals(IEnumerable a, IEnumerable b) - { - if (a.GetType() != b.GetType()) - return false; - IEnumerator e1 = a.GetEnumerator(); - IEnumerator e2 = b.GetEnumerator(); - while (e1.MoveNext()) { - // e1 has more elements than e2; or elements are different - if (!e2.MoveNext() || e1.Current != e2.Current) - return false; - } - if (e2.MoveNext()) // e2 has more elements than e1 - return false; - // No need to dispose e1/e2: non-generic IEnumerator doesn't implement IDisposable, - // and the underlying enumerator will likely be a List.Enumerator which has an empty Dispose() method. - return true; - } - - public int GetHashCode(IEnumerable obj) - { - int hashCode = obj.GetType().GetHashCode(); - unchecked { - foreach (object o in obj) { - hashCode *= 27; - hashCode += RuntimeHelpers.GetHashCode(o); - } - } - return hashCode; - } - } - - Dictionary byValueDict = new Dictionary(); - Dictionary supportsInternDict = new Dictionary(new InterningComparer()); - Dictionary listDict = new Dictionary(new ListComparer()); - - public override ISupportsInterning Intern(ISupportsInterning obj) - { - if (obj == null) - return null; - - // ensure objects are frozen when we put them into the dictionary - // note that Freeze may change the hash code of the object - FreezableHelper.Freeze(obj); - - ISupportsInterning output; - if (supportsInternDict.TryGetValue(obj, out output)) { - return output; - } else { - supportsInternDict.Add(obj, obj); - return obj; - } - } - - public override string Intern(string text) - { - if (text == null) - return null; - - object output; - if (byValueDict.TryGetValue(text, out output)) - return (string)output; - else - return text; - } - - public override object InternValue(object obj) - { - if (obj == null) - return null; - - object output; - if (byValueDict.TryGetValue(obj, out output)) - return output; - else - return obj; - } - - public override IList InternList(IList list) - { - if (list == null) - return null; - if (list.Count == 0) - return EmptyList.Instance; - if (!list.IsReadOnly) - list = new ReadOnlyCollection(list); - IEnumerable output; - if (listDict.TryGetValue(list, out output)) - list = (IList)output; - else - listDict.Add(list, list); - return list; - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs index 2d9609490..0e254dd74 100644 --- a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs +++ b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs @@ -256,15 +256,6 @@ namespace ICSharpCode.Decompiler.TypeSystem #endregion #region GetType/Member - /// - /// Gets all unresolved type definitions from the assembly. - /// For partial classes, each part is returned. - /// - public static IEnumerable GetAllTypeDefinitions (this IUnresolvedAssembly assembly) - { - return TreeTraversal.PreOrder(assembly.TopLevelTypeDefinitions, t => t.NestedTypes); - } - /// /// Gets all type definitions in the compilation. /// This may include types from referenced assemblies that are not accessible in the main assembly. @@ -285,36 +276,6 @@ namespace ICSharpCode.Decompiler.TypeSystem #endregion #region Resolve on collections - public static IReadOnlyList CreateResolvedAttributes(this IList attributes, ITypeResolveContext context) - { - if (attributes == null) - throw new ArgumentNullException("attributes"); - if (attributes.Count == 0) - return EmptyList.Instance; - else - return new ProjectedList(context, attributes, (c, a) => a.CreateResolvedAttribute(c)); - } - - public static IReadOnlyList CreateResolvedTypeParameters(this IList typeParameters, ITypeResolveContext context) - { - if (typeParameters == null) - throw new ArgumentNullException("typeParameters"); - if (typeParameters.Count == 0) - return EmptyList.Instance; - else - return new ProjectedList(context, typeParameters, (c, a) => a.CreateResolvedTypeParameter(c)); - } - - public static IReadOnlyList CreateResolvedParameters(this IList parameters, ITypeResolveContext context) - { - if (parameters == null) - throw new ArgumentNullException("parameters"); - if (parameters.Count == 0) - return EmptyList.Instance; - else - return new ProjectedList(context, parameters, (c, a) => a.CreateResolvedParameter(c)); - } - public static IReadOnlyList Resolve(this IList typeReferences, ITypeResolveContext context) { if (typeReferences == null) @@ -327,16 +288,6 @@ namespace ICSharpCode.Decompiler.TypeSystem // There is intentionally no Resolve() overload for IList: the resulting IList would // contains nulls when there are resolve errors. - - public static IReadOnlyList Resolve(this IList constantValues, ITypeResolveContext context) - { - if (constantValues == null) - throw new ArgumentNullException("constantValues"); - if (constantValues.Count == 0) - return EmptyList.Instance; - else - return new ProjectedList(context, constantValues, (c, t) => t.Resolve(c)); - } #endregion #region GetSubTypeDefinitions