diff --git a/corlib/System.Reflection/ICustomAttributeProvider.cs b/corlib/System.Reflection/ICustomAttributeProvider.cs new file mode 100644 index 0000000..3950b63 --- /dev/null +++ b/corlib/System.Reflection/ICustomAttributeProvider.cs @@ -0,0 +1,36 @@ +// Copyright (c) 2012 DotNetAnywhere +// +// 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. + +#if !LOCALTEST + +namespace System.Reflection { + + public interface ICustomAttributeProvider { + + bool IsDefined(Type attributeType, bool inherit); + + Object[] GetCustomAttributes(bool inherit); + + Object[] GetCustomAttributes(Type attributeType, bool inherit); + } + +} + +#endif diff --git a/corlib/System.Reflection/MemberInfo.cs b/corlib/System.Reflection/MemberInfo.cs index 3a239db..3a3c77d 100644 --- a/corlib/System.Reflection/MemberInfo.cs +++ b/corlib/System.Reflection/MemberInfo.cs @@ -20,18 +20,19 @@ #if !LOCALTEST -using System; -using System.Collections.Generic; -using System.Text; - namespace System.Reflection { - public abstract class MemberInfo { + public abstract class MemberInfo : ICustomAttributeProvider { protected MemberInfo() { } public abstract string Name { get;} + public abstract bool IsDefined(Type attributeType, bool inherit); + + public abstract Object[] GetCustomAttributes(bool inherit); + + public abstract Object[] GetCustomAttributes(Type attributeType, bool inherit); } } diff --git a/corlib/System/Attribute.cs b/corlib/System/Attribute.cs index 83b3af6..4b48459 100644 --- a/corlib/System/Attribute.cs +++ b/corlib/System/Attribute.cs @@ -18,10 +18,24 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using System.Collections.Generic; +using System.Reflection; + #if !LOCALTEST namespace System { public abstract class Attribute { + + public virtual object TypeId { + get { + return this.GetType(); + } + } + + public static IEnumerable GetCustomAttributes(MemberInfo element, bool inherit) + { + return null; + } } } diff --git a/corlib/System/RuntimeType.cs b/corlib/System/RuntimeType.cs index 6293476..1395f58 100644 --- a/corlib/System/RuntimeType.cs +++ b/corlib/System/RuntimeType.cs @@ -20,13 +20,14 @@ #if !LOCALTEST +using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using System.Collections.Generic; namespace System { - class RuntimeType : Type { + sealed class RuntimeType : Type { [MethodImpl(MethodImplOptions.InternalCall)] extern private RuntimeType GetNestingParentType(); @@ -93,6 +94,24 @@ [MethodImpl(MethodImplOptions.InternalCall)] extern public override Type[] GetGenericArguments(); + [MethodImpl(MethodImplOptions.InternalCall)] + extern public override bool IsDefined(Type attributeType, bool inherit); + + public override Object[] GetCustomAttributes(bool inherit) + { + return Internal_GetCustomAttributes(null, inherit); + } + + public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + { + if (attributeType == null) + throw new ArgumentNullException(); + + return Internal_GetCustomAttributes(attributeType, inherit); + } + + [MethodImpl(MethodImplOptions.InternalCall)] + extern private Object[] Internal_GetCustomAttributes(Type attributeType, bool inherit); } } diff --git a/dna/InternalCall.c b/dna/InternalCall.c index 4e7a3ab..30c5c2c 100644 --- a/dna/InternalCall.c +++ b/dna/InternalCall.c @@ -106,6 +106,8 @@ {NULL, NULL, "get_IsGenericType", System_RuntimeType_get_IsGenericType, TYPE_SYSTEM_BOOLEAN, 0}, {NULL, NULL, "Internal_GetGenericTypeDefinition", System_RuntimeType_Internal_GetGenericTypeDefinition, TYPE_SYSTEM_RUNTIMETYPE, 0}, {NULL, NULL, "GetGenericArguments", System_RuntimeType_GetGenericArguments, TYPE_SYSTEM_ARRAY_TYPE, 0}, + {NULL, NULL, "IsDefined", System_RuntimeType_IsDefined, TYPE_SYSTEM_BOOLEAN, 2, {TYPE_SYSTEM_TYPE, TYPE_SYSTEM_BOOLEAN}}, + {NULL, NULL, "Internal_GetCustomAttributes", System_RuntimeType_GetCustomAttributes, TYPE_SYSTEM_ARRAY_OBJECT, 2, {TYPE_SYSTEM_TYPE, TYPE_SYSTEM_BOOLEAN}}, {NULL, "Char", "GetUnicodeCategory", System_Char_GetUnicodeCategory, TYPE_SYSTEM_GLOBALIZATION_UNICODECATEGORY, 1, {TYPE_SYSTEM_CHAR}}, {NULL, NULL , "ToLowerInvariant", System_Char_ToLowerInvariant, TYPE_SYSTEM_CHAR, 1, {TYPE_SYSTEM_CHAR}}, diff --git a/dna/System.RuntimeType.c b/dna/System.RuntimeType.c index 363ea07..e5409b6 100644 --- a/dna/System.RuntimeType.c +++ b/dna/System.RuntimeType.c @@ -146,6 +146,16 @@ return NULL; } +tAsyncCall* System_RuntimeType_IsDefined(PTR pThis_, PTR pParams, PTR pReturnValue) { + tMD_TypeDef *pType = ((tRuntimeType*)pThis_)->pTypeDef; + return NULL; +} + +tAsyncCall* System_RuntimeType_GetCustomAttributes(PTR pThis_, PTR pParams, PTR pReturnValue) { + tMD_TypeDef *pType = ((tRuntimeType*)pThis_)->pTypeDef; + return NULL; +} + tMD_TypeDef* RuntimeType_DeRef(PTR type) { return ((tRuntimeType*)type)->pTypeDef; } \ No newline at end of file diff --git a/dna/System.RuntimeType.h b/dna/System.RuntimeType.h index 66c191e..8376112 100644 --- a/dna/System.RuntimeType.h +++ b/dna/System.RuntimeType.h @@ -38,6 +38,8 @@ tAsyncCall* System_RuntimeType_get_IsGenericType(PTR pThis_, PTR pParams, PTR pReturnValue); tAsyncCall* System_RuntimeType_Internal_GetGenericTypeDefinition(PTR pThis_, PTR pParams, PTR pReturnValue); tAsyncCall* System_RuntimeType_GetGenericArguments(PTR pThis_, PTR pParams, PTR pReturnValue); +tAsyncCall* System_RuntimeType_IsDefined(PTR pThis_, PTR pParams, PTR pReturnValue); +tAsyncCall* System_RuntimeType_GetCustomAttributes(PTR pThis_, PTR pParams, PTR pReturnValue); // Create a new heap object which is the RuntimeType object for the given type. HEAP_PTR RuntimeType_New(tMD_TypeDef *pTypeDef);