diff options
author | David Wrighton <davidwr@microsoft.com> | 2015-12-09 05:31:39 +0300 |
---|---|---|
committer | David Wrighton <davidwr@microsoft.com> | 2015-12-10 00:36:52 +0300 |
commit | 107ce7fbec781d0dab2574f51c708926dfd27896 (patch) | |
tree | 79b17b3bbb69574257f6c6ef334925caa75ec791 /src/Common | |
parent | 7a1eabe48e36ff7c7c9d4ec5cdaba474b2c5dd4c (diff) |
Reduce dependency on Ecma api surface
- Remove unused EcmaMethod extension methods
- Move Nested types api from EcmaType to MetadataType
- Remove nearly all dependency on the Ecma type system api from tests
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/src/TypeSystem/Common/InstantiatedType.cs | 12 | ||||
-rw-r--r-- | src/Common/src/TypeSystem/Common/MetadataType.cs | 12 | ||||
-rw-r--r-- | src/Common/src/TypeSystem/Ecma/EcmaMethod.cs | 11 | ||||
-rw-r--r-- | src/Common/src/TypeSystem/Ecma/EcmaType.cs | 8 |
4 files changed, 28 insertions, 15 deletions
diff --git a/src/Common/src/TypeSystem/Common/InstantiatedType.cs b/src/Common/src/TypeSystem/Common/InstantiatedType.cs index 9e69a4ff0..9b7cbb39c 100644 --- a/src/Common/src/TypeSystem/Common/InstantiatedType.cs +++ b/src/Common/src/TypeSystem/Common/InstantiatedType.cs @@ -281,5 +281,17 @@ namespace Internal.TypeSystem { return _typeDef.HasCustomAttribute(attributeNamespace, attributeName); } + + public override MetadataType GetNestedType(string name) + { + // Return the result from the typical type definition. + return _typeDef.GetNestedType(name); + } + + public override IEnumerable<MetadataType> GetNestedTypes() + { + // Return the result from the typical type definition. + return _typeDef.GetNestedTypes(); + } } } diff --git a/src/Common/src/TypeSystem/Common/MetadataType.cs b/src/Common/src/TypeSystem/Common/MetadataType.cs index 336a9dcb4..fab854fad 100644 --- a/src/Common/src/TypeSystem/Common/MetadataType.cs +++ b/src/Common/src/TypeSystem/Common/MetadataType.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections.Generic; + namespace Internal.TypeSystem { /// <summary> @@ -67,6 +69,16 @@ namespace Internal.TypeSystem /// Returns true if the type has given custom attribute. /// </summary> public abstract bool HasCustomAttribute(string attributeNamespace, string attributeName); + + /// <summary> + /// Get all of the types nested in this type. + /// </summary> + public abstract IEnumerable<MetadataType> GetNestedTypes(); + + /// <summary> + /// Get a specific type nested in this type. + /// </summary> + public abstract MetadataType GetNestedType(string name); } public struct ClassLayoutMetadata diff --git a/src/Common/src/TypeSystem/Ecma/EcmaMethod.cs b/src/Common/src/TypeSystem/Ecma/EcmaMethod.cs index b098a1ac8..6775148a0 100644 --- a/src/Common/src/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/Common/src/TypeSystem/Ecma/EcmaMethod.cs @@ -342,15 +342,4 @@ namespace Internal.TypeSystem.Ecma return new PInvokeMetadata(name, (PInvokeAttributes)import.Attributes); } } - - public static class EcmaMethodExtensions - { - public static bool IsPublic(this EcmaMethod method) { return (method.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; } - public static bool IsPrivate(this EcmaMethod method) { return (method.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; } - public static bool IsStatic(this EcmaMethod method) { return (method.Attributes & MethodAttributes.Static) != 0; } - public static bool IsFinal(this EcmaMethod method) { return (method.Attributes & MethodAttributes.Final) != 0; } - public static bool IsHideBySig(this EcmaMethod method) { return (method.Attributes & MethodAttributes.HideBySig) != 0; } - public static bool IsAbstract(this EcmaMethod method) { return (method.Attributes & MethodAttributes.Abstract) != 0; } - public static bool IsSpecialName(this EcmaMethod method) { return (method.Attributes & MethodAttributes.SpecialName) != 0; } - } } diff --git a/src/Common/src/TypeSystem/Ecma/EcmaType.cs b/src/Common/src/TypeSystem/Ecma/EcmaType.cs index 3aaf79b1f..7b21863c0 100644 --- a/src/Common/src/TypeSystem/Ecma/EcmaType.cs +++ b/src/Common/src/TypeSystem/Ecma/EcmaType.cs @@ -339,15 +339,15 @@ namespace Internal.TypeSystem.Ecma return null; } - public IEnumerable<TypeDesc> GetNestedTypes() + public override IEnumerable<MetadataType> GetNestedTypes() { foreach (var handle in _typeDefinition.GetNestedTypes()) { - yield return (TypeDesc)this.Module.GetObject(handle); + yield return (MetadataType)this.Module.GetObject(handle); } } - public TypeDesc GetNestedType(string name) + public override MetadataType GetNestedType(string name) { var metadataReader = this.MetadataReader; var stringComparer = metadataReader.StringComparer; @@ -355,7 +355,7 @@ namespace Internal.TypeSystem.Ecma foreach (var handle in _typeDefinition.GetNestedTypes()) { if (stringComparer.Equals(metadataReader.GetTypeDefinition(handle).Name, name)) - return (TypeDesc)this.Module.GetObject(handle); + return (MetadataType)this.Module.GetObject(handle); } return null; |