From: Atsushi Kanamori Date: Wed, 22 Mar 2017 18:16:35 +0000 (-0700) Subject: Move the easy files in System\Reflection to the shared partition. (dotnet/coreclr... X-Git-Tag: submit/tizen/20210909.063632~11030^2~7575^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7046a0bd00c0607330d2735884b330d8e6e87cd;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Move the easy files in System\Reflection to the shared partition. (dotnet/coreclr#3060) * Prepare the "easy" System\Reflection .cs files for move to shared partition Files to be moved the shared partition (after https://github.com/dotnet/coreclr/pull/10387 side is in) AmbiguousMatchException.cs AssemblyAttributes.cs AssemblyContentType.cs AssemblyNameFlags.cs Binder.cs BindingFlags.cs CallingConventions.cs CustomAttributeFormatException.cs DefaultMemberAttribute.cs EventAttributes.cs ExceptionHandlingClauseOptions.cs FieldAttributes.cs GenericParameterAttributes.cs ICustomAttributeProvider.cs ImageFileMachine.cs InterfaceMapping.cs IntrospectionExtensions.cs InvalidFilterCriteriaException.cs IReflectableType.cs ManifestResourceInfo.cs MemberFilter.cs MemberTypes.cs MethodAttributes.cs MethodImplAttributes.cs Missing.cs ModuleResolveEventHandler.cs ParameterAttributes.cs ParameterModifier.cs PortableExecutableKinds.cs ProcessorArchitecture.cs PropertyAttributes.cs ReflectionContext.cs ReflectionTypeLoadException.cs ResourceAttributes.cs ResourceLocation.cs StrongNameKeyPair.cs TargetException.cs TargetInvocationException.cs TargetParameterCountException.cs TypeAttributes.cs TypeFilter.cs * Prepare the "easy" System\Reflection .cs files for move to shared partition Files to be moved the shared partition (after https://github.com/dotnet/coreclr/pull/10387 side is in) AmbiguousMatchException.cs AssemblyAttributes.cs AssemblyContentType.cs AssemblyNameFlags.cs Binder.cs BindingFlags.cs CallingConventions.cs CustomAttributeFormatException.cs DefaultMemberAttribute.cs EventAttributes.cs ExceptionHandlingClauseOptions.cs FieldAttributes.cs GenericParameterAttributes.cs ICustomAttributeProvider.cs ImageFileMachine.cs InterfaceMapping.cs IntrospectionExtensions.cs InvalidFilterCriteriaException.cs IReflectableType.cs ManifestResourceInfo.cs MemberFilter.cs MemberTypes.cs MethodAttributes.cs MethodImplAttributes.cs Missing.cs ModuleResolveEventHandler.cs ParameterAttributes.cs ParameterModifier.cs PortableExecutableKinds.cs ProcessorArchitecture.cs PropertyAttributes.cs ReflectionContext.cs ReflectionTypeLoadException.cs ResourceAttributes.cs ResourceLocation.cs StrongNameKeyPair.cs TargetException.cs TargetInvocationException.cs TargetParameterCountException.cs TypeAttributes.cs TypeFilter.cs * Move to shared. Commit migrated from https://github.com/dotnet/coreclr/commit/cd6048c74e97caf3c46429992854074ecaccecf7 --- diff --git a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems index f72f599..57bd169 100644 --- a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -66,6 +66,22 @@ + + + + + + + + + + + + + + + + @@ -87,24 +103,10 @@ - - - - - - - - - - - - - - - + @@ -156,20 +158,53 @@ + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + @@ -229,8 +264,6 @@ - - diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/AmbiguousMatchException.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/AmbiguousMatchException.cs new file mode 100644 index 0000000..459a19c --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/AmbiguousMatchException.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public sealed class AmbiguousMatchException : SystemException + { + public AmbiguousMatchException() + : base(SR.RFLCT_Ambiguous) + { + HResult = __HResults.COR_E_AMBIGUOUSMATCH; + } + + public AmbiguousMatchException(string message) + : base(message) + { + HResult = __HResults.COR_E_AMBIGUOUSMATCH; + } + + public AmbiguousMatchException(string message, Exception inner) + : base(message, inner) + { + HResult = __HResults.COR_E_AMBIGUOUSMATCH; + } + + internal AmbiguousMatchException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyAttributes.cs new file mode 100644 index 0000000..1554403 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyAttributes.cs @@ -0,0 +1,259 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Configuration.Assemblies; + +namespace System.Reflection +{ + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyCopyrightAttribute : Attribute + { + public AssemblyCopyrightAttribute(string copyright) + { + Copyright = copyright; + } + + public string Copyright { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyTrademarkAttribute : Attribute + { + public AssemblyTrademarkAttribute(string trademark) + { + Trademark = trademark; + } + + public string Trademark { get; } + } + + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyProductAttribute : Attribute + { + public AssemblyProductAttribute(string product) + { + Product = product; + } + + public string Product { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyCompanyAttribute : Attribute + { + public AssemblyCompanyAttribute(string company) + { + Company = company; + } + + public string Company { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyDescriptionAttribute : Attribute + { + public AssemblyDescriptionAttribute(string description) + { + Description = description; + } + + public string Description { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyTitleAttribute : Attribute + { + public AssemblyTitleAttribute(string title) + { + Title = title; + } + + public string Title { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyConfigurationAttribute : Attribute + { + public AssemblyConfigurationAttribute(string configuration) + { + Configuration = configuration; + } + + public string Configuration { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyDefaultAliasAttribute : Attribute + { + public AssemblyDefaultAliasAttribute(string defaultAlias) + { + DefaultAlias = defaultAlias; + } + + public string DefaultAlias { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyInformationalVersionAttribute : Attribute + { + public AssemblyInformationalVersionAttribute(string informationalVersion) + { + InformationalVersion = informationalVersion; + } + + public string InformationalVersion { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyFileVersionAttribute : Attribute + { + public AssemblyFileVersionAttribute(string version) + { + if (version == null) + throw new ArgumentNullException(nameof(version)); + Version = version; + } + + public string Version { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public unsafe sealed class AssemblyCultureAttribute : Attribute + { + public AssemblyCultureAttribute(string culture) + { + Culture = culture; + } + + public string Culture { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public unsafe sealed class AssemblyVersionAttribute : Attribute + { + public AssemblyVersionAttribute(string version) + { + Version = version; + } + + public string Version { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyKeyFileAttribute : Attribute + { + public AssemblyKeyFileAttribute(string keyFile) + { + KeyFile = keyFile; + } + + public string KeyFile { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyDelaySignAttribute : Attribute + { + public AssemblyDelaySignAttribute(bool delaySign) + { + DelaySign = delaySign; + } + + public bool DelaySign { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public unsafe sealed class AssemblyAlgorithmIdAttribute : Attribute + { + public AssemblyAlgorithmIdAttribute(AssemblyHashAlgorithm algorithmId) + { + AlgorithmId = (uint)algorithmId; + } + + [CLSCompliant(false)] + public AssemblyAlgorithmIdAttribute(uint algorithmId) + { + AlgorithmId = algorithmId; + } + + [CLSCompliant(false)] + public uint AlgorithmId { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public unsafe sealed class AssemblyFlagsAttribute : Attribute + { + private AssemblyNameFlags _flags; + + [Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [CLSCompliant(false)] + public AssemblyFlagsAttribute(uint flags) + { + _flags = (AssemblyNameFlags)flags; + } + + [Obsolete("This property has been deprecated. Please use AssemblyFlags instead. http://go.microsoft.com/fwlink/?linkid=14202")] + [CLSCompliant(false)] + public uint Flags + { + get { return (uint)_flags; } + } + + public int AssemblyFlags + { + get { return (int)_flags; } + } + + [Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")] + public AssemblyFlagsAttribute(int assemblyFlags) + { + _flags = (AssemblyNameFlags)assemblyFlags; + } + + public AssemblyFlagsAttribute(AssemblyNameFlags assemblyFlags) + { + _flags = assemblyFlags; + } + } + + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public sealed class AssemblyMetadataAttribute : Attribute + { + public AssemblyMetadataAttribute(string key, string value) + { + Key = key; + Value = value; + } + + public string Key { get; } + + public string Value { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] + public sealed class AssemblySignatureKeyAttribute : Attribute + { + public AssemblySignatureKeyAttribute(string publicKey, string countersignature) + { + PublicKey = publicKey; + Countersignature = countersignature; + } + + public string PublicKey { get; } + + public string Countersignature { get; } + } + + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class AssemblyKeyNameAttribute : Attribute + { + public AssemblyKeyNameAttribute(string keyName) + { + KeyName = keyName; + } + + public string KeyName { get; } + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyContentType.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyContentType.cs new file mode 100644 index 0000000..2ee1a00 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyContentType.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public enum AssemblyContentType + { + Default = 0, + WindowsRuntime = 1, + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyNameFlags.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyNameFlags.cs new file mode 100644 index 0000000..d321032 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/AssemblyNameFlags.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum AssemblyNameFlags + { + None = 0x0000, + // Flag used to indicate that an assembly ref contains the full public key, not the compressed token. + // Must match afPublicKey in CorHdr.h. + PublicKey = 0x0001, + //ProcArchMask = 0x00F0, // Bits describing the processor architecture + // Accessible via AssemblyName.ProcessorArchitecture + EnableJITcompileOptimizer = 0x4000, + EnableJITcompileTracking = 0x8000, + Retargetable = 0x0100, + //ContentType = 0x0E00, // Bits describing the ContentType are accessible via AssemblyName.ContentType + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/Binder.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/Binder.cs new file mode 100644 index 0000000..3dc5665 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/Binder.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Globalization; + +namespace System.Reflection +{ + public abstract class Binder + { + protected Binder() { } + public abstract FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, CultureInfo culture); + public abstract MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state); + public abstract object ChangeType(object value, Type type, CultureInfo culture); + public abstract void ReorderArgumentArray(ref object[] args, object state); + public abstract MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers); + public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers); + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/BindingFlags.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/BindingFlags.cs new file mode 100644 index 0000000..26c875d --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/BindingFlags.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum BindingFlags + { + // NOTES: We have lookup masks defined in RuntimeType and Activator. If we + // change the lookup values then these masks may need to change also. + + // a place holder for no flag specifed + Default = 0x00, + + // These flags indicate what to search for when binding + IgnoreCase = 0x01, // Ignore the case of Names while searching + DeclaredOnly = 0x02, // Only look at the members declared on the Type + Instance = 0x04, // Include Instance members in search + Static = 0x08, // Include Static members in search + Public = 0x10, // Include Public members in search + NonPublic = 0x20, // Include Non-Public members in search + FlattenHierarchy = 0x40, // Rollup the statics into the class. + + // These flags are used by InvokeMember to determine + // what type of member we are trying to Invoke. + // BindingAccess = 0xFF00; + InvokeMethod = 0x0100, + CreateInstance = 0x0200, + GetField = 0x0400, + SetField = 0x0800, + GetProperty = 0x1000, + SetProperty = 0x2000, + + // These flags are also used by InvokeMember but they should only + // be used when calling InvokeMember on a COM object. + PutDispProperty = 0x4000, + PutRefDispProperty = 0x8000, + + ExactBinding = 0x010000, // Bind with Exact Type matching, No Change type + SuppressChangeType = 0x020000, + + // DefaultValueBinding will return the set of methods having ArgCount or + // more parameters. This is used for default values, etc. + OptionalParamBinding = 0x040000, + + // These are a couple of misc attributes used + IgnoreReturn = 0x01000000, // This is used in COM Interop + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/CallingConventions.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/CallingConventions.cs new file mode 100644 index 0000000..bb6d6cd --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/CallingConventions.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// CallingConventions is a set of Bits representing the calling conventions in the system. + +namespace System.Reflection +{ + [Flags] + public enum CallingConventions + { + //NOTE: If you change this please update COMMember.cpp. These + // are defined there. + Standard = 0x0001, + VarArgs = 0x0002, + Any = Standard | VarArgs, + HasThis = 0x0020, + ExplicitThis = 0x0040, + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/CustomAttributeFormatException.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/CustomAttributeFormatException.cs new file mode 100644 index 0000000..6e11540 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/CustomAttributeFormatException.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public class CustomAttributeFormatException : FormatException + { + public CustomAttributeFormatException() + : this(SR.Arg_CustomAttributeFormatException) + { + } + + public CustomAttributeFormatException(string message) + : this(message, null) + { + } + + public CustomAttributeFormatException(string message, Exception inner) + : base(message, inner) + { + HResult = __HResults.COR_E_CUSTOMATTRIBUTEFORMAT; + } + + protected CustomAttributeFormatException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/DefaultMemberAttribute.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/DefaultMemberAttribute.cs new file mode 100644 index 0000000..3511433 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/DefaultMemberAttribute.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Serializable] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)] + public sealed class DefaultMemberAttribute : Attribute + { + // You must provide the name of the member, this is required + public DefaultMemberAttribute(string memberName) + { + MemberName = memberName; + } + + // A get accessor to return the name from the attribute. + // NOTE: There is no setter because the name must be provided + // to the constructor. The name is not optional. + public string MemberName { get; } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/EventAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/EventAttributes.cs new file mode 100644 index 0000000..fbc2972 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/EventAttributes.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// EventAttributes are an enum defining the attributes associated with and Event. +// These are defined in CorHdr.h and are a combination of bits and enums. + +namespace System.Reflection +{ + [Flags] + public enum EventAttributes + { + None = 0x0000, + + // This Enum matchs the CorEventAttr defined in CorHdr.h + SpecialName = 0x0200, // event is special. Name describes how. + + RTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding. + + ReservedMask = 0x0400, + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ExceptionHandlingClauseOptions.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ExceptionHandlingClauseOptions.cs new file mode 100644 index 0000000..46285f7 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ExceptionHandlingClauseOptions.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum ExceptionHandlingClauseOptions : int + { + Clause = 0x0, + Filter = 0x1, + Finally = 0x2, + Fault = 0x4, + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/FieldAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/FieldAttributes.cs new file mode 100644 index 0000000..048d0e7 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/FieldAttributes.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + // This Enum matchs the CorFieldAttr defined in CorHdr.h + [Flags] + public enum FieldAttributes + { + // member access mask - Use this mask to retrieve accessibility information. + FieldAccessMask = 0x0007, + PrivateScope = 0x0000, // Member not referenceable. + Private = 0x0001, // Accessible only by the parent type. + FamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly. + Assembly = 0x0003, // Accessibly by anyone in the Assembly. + Family = 0x0004, // Accessible only by type and sub-types. + FamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly. + Public = 0x0006, // Accessibly by anyone who has visibility to this scope. + // end member access mask + + // field contract attributes. + Static = 0x0010, // Defined on type, else per instance. + InitOnly = 0x0020, // Field may only be initialized, not written to after init. + Literal = 0x0040, // Value is compile time constant. + NotSerialized = 0x0080, // Field does not have to be serialized when type is remoted. + + SpecialName = 0x0200, // field is special. Name describes how. + + // interop attributes + PinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke. + + RTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding. + HasFieldMarshal = 0x1000, // Field has marshalling information. + HasDefault = 0x8000, // Field has default. + HasFieldRVA = 0x0100, // Field has RVA. + + ReservedMask = 0x9500, + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/GenericParameterAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/GenericParameterAttributes.cs new file mode 100644 index 0000000..4b579d2 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/GenericParameterAttributes.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum GenericParameterAttributes + { + None = 0x0000, + VarianceMask = 0x0003, + Covariant = 0x0001, + Contravariant = 0x0002, + SpecialConstraintMask = 0x001C, + ReferenceTypeConstraint = 0x0004, + NotNullableValueTypeConstraint = 0x0008, + DefaultConstructorConstraint = 0x0010, + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ICustomAttributeProvider.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ICustomAttributeProvider.cs new file mode 100644 index 0000000..3cae295 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ICustomAttributeProvider.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public interface ICustomAttributeProvider + { + object[] GetCustomAttributes(bool inherit); + object[] GetCustomAttributes(Type attributeType, bool inherit); + bool IsDefined(Type attributeType, bool inherit); + } +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/IReflectableType.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/IReflectableType.cs new file mode 100644 index 0000000..5e2c0eda --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/IReflectableType.cs @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public interface IReflectableType + { + TypeInfo GetTypeInfo(); + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ImageFileMachine.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ImageFileMachine.cs new file mode 100644 index 0000000..230bc95 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ImageFileMachine.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public enum ImageFileMachine + { + I386 = 0x014c, + IA64 = 0x0200, + AMD64 = 0x8664, + ARM = 0x01c4, + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/InterfaceMapping.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/InterfaceMapping.cs new file mode 100644 index 0000000..2e0c0d8 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/InterfaceMapping.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public struct InterfaceMapping + { + public Type TargetType; // The type implementing the interface + public Type InterfaceType; // The type representing the interface + public MethodInfo[] TargetMethods; // The methods implementing the interface + public MethodInfo[] InterfaceMethods; // The methods defined on the interface + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/IntrospectionExtensions.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/IntrospectionExtensions.cs new file mode 100644 index 0000000..6a18fda --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/IntrospectionExtensions.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; + +namespace System.Reflection +{ + public static class IntrospectionExtensions + { + public static TypeInfo GetTypeInfo(this Type type) + { + if (type == null) + throw new ArgumentNullException(nameof(type)); + + return ((IReflectableType)type).GetTypeInfo(); // Unguarded cast is unbecoming but kept for compatibility. + } + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/InvalidFilterCriteriaException.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/InvalidFilterCriteriaException.cs new file mode 100644 index 0000000..e3f882c --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/InvalidFilterCriteriaException.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public class InvalidFilterCriteriaException : ApplicationException + { + public InvalidFilterCriteriaException() + : this(SR.Arg_InvalidFilterCriteriaException) + { + } + + public InvalidFilterCriteriaException(string message) + : this(message, null) + { + } + + public InvalidFilterCriteriaException(string message, Exception inner) + : base(message, inner) + { + HResult = __HResults.COR_E_INVALIDFILTERCRITERIA; + } + + protected InvalidFilterCriteriaException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ManifestResourceInfo.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ManifestResourceInfo.cs new file mode 100644 index 0000000..b9c56ab --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ManifestResourceInfo.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public class ManifestResourceInfo + { + public ManifestResourceInfo(Assembly containingAssembly, + string containingFileName, + ResourceLocation resourceLocation) + { + ReferencedAssembly = containingAssembly; + FileName = containingFileName; + ResourceLocation = resourceLocation; + } + + public virtual Assembly ReferencedAssembly { get; } + public virtual string FileName { get; } + public virtual ResourceLocation ResourceLocation { get; } + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/MemberFilter.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/MemberFilter.cs new file mode 100644 index 0000000..bb1b157 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/MemberFilter.cs @@ -0,0 +1,8 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public delegate bool MemberFilter(MemberInfo m, object filterCriteria); +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/MemberTypes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/MemberTypes.cs new file mode 100644 index 0000000..57072dc --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/MemberTypes.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum MemberTypes + { + Constructor = 0x01, + Event = 0x02, + Field = 0x04, + Method = 0x08, + Property = 0x10, + TypeInfo = 0x20, + Custom = 0x40, + NestedType = 0x80, + All = Constructor | Event | Field | Method | Property | TypeInfo | NestedType, + } +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/MethodAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/MethodAttributes.cs new file mode 100644 index 0000000..1a7c7bf --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/MethodAttributes.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum MethodAttributes + { + // NOTE: This Enum matchs the CorMethodAttr defined in CorHdr.h + + // member access mask - Use this mask to retrieve accessibility information. + MemberAccessMask = 0x0007, + PrivateScope = 0x0000, // Member not referenceable. + Private = 0x0001, // Accessible only by the parent type. + FamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly. + Assembly = 0x0003, // Accessibly by anyone in the Assembly. + Family = 0x0004, // Accessible only by type and sub-types. + FamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly. + Public = 0x0006, // Accessibly by anyone who has visibility to this scope. + // end member access mask + + // method contract attributes. + Static = 0x0010, // Defined on type, else per instance. + Final = 0x0020, // Method may not be overridden. + Virtual = 0x0040, // Method virtual. + HideBySig = 0x0080, // Method hides by name+sig, else just by name. + CheckAccessOnOverride = 0x0200, + + // vtable layout mask - Use this mask to retrieve vtable attributes. + VtableLayoutMask = 0x0100, + ReuseSlot = 0x0000, // The default. + NewSlot = 0x0100, // Method always gets a new slot in the vtable. + // end vtable layout mask + + // method implementation attributes. + Abstract = 0x0400, // Method does not provide an implementation. + SpecialName = 0x0800, // Method is special. Name describes how. + + // interop attributes + PinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke. + UnmanagedExport = 0x0008, // Managed method exported via thunk to unmanaged code. + RTSpecialName = 0x1000, // Runtime should check name encoding. + + HasSecurity = 0x4000, // Method has security associate with it. + RequireSecObject = 0x8000, // Method calls another method containing security code. + + ReservedMask = 0xd000, + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/MethodImplAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/MethodImplAttributes.cs new file mode 100644 index 0000000..0a67e2c --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/MethodImplAttributes.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + // This Enum matchs the CorMethodImpl defined in CorHdr.h + public enum MethodImplAttributes + { + // code impl mask + CodeTypeMask = 0x0003, // Flags about code type. + IL = 0x0000, // Method impl is IL. + Native = 0x0001, // Method impl is native. + /// + OPTIL = 0x0002, // Method impl is OPTIL + Runtime = 0x0003, // Method impl is provided by the runtime. + // end code impl mask + + // managed mask + ManagedMask = 0x0004, // Flags specifying whether the code is managed or unmanaged. + Unmanaged = 0x0004, // Method impl is unmanaged, otherwise managed. + Managed = 0x0000, // Method impl is managed. + // end managed mask + + // implementation info and interop + ForwardRef = 0x0010, // Indicates method is not defined; used primarily in merge scenarios. + PreserveSig = 0x0080, // Indicates method sig is exported exactly as declared. + + InternalCall = 0x1000, // Internal Call... + + Synchronized = 0x0020, // Method is single threaded through the body. + NoInlining = 0x0008, // Method may not be inlined. + AggressiveInlining = 0x0100, // Method should be inlined if possible. + NoOptimization = 0x0040, // Method may not be optimized. + + MaxMethodImplVal = 0xffff, + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/Missing.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/Missing.cs new file mode 100644 index 0000000..fa32d43 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/Missing.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public sealed class Missing : ISerializable + { + public static readonly Missing Value = new Missing(); + + private Missing() { } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + if (info == null) + throw new ArgumentNullException(nameof(info)); + + UnitySerializationHolder.GetUnitySerializationInfo(info, this); + } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ModuleResolveEventHandler.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ModuleResolveEventHandler.cs new file mode 100644 index 0000000..eb8926b --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ModuleResolveEventHandler.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public delegate Module ModuleResolveEventHandler(object sender, ResolveEventArgs e); +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ParameterAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ParameterAttributes.cs new file mode 100644 index 0000000..ce19589 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ParameterAttributes.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// ParameterAttributes is an enum defining the attributes that may be +// associated with a Parameter. These are defined in CorHdr.h. + +namespace System.Reflection +{ + // This Enum matchs the CorParamAttr defined in CorHdr.h + [Flags] + public enum ParameterAttributes + { + None = 0x0000, // no flag is specified + In = 0x0001, // Param is [In] + Out = 0x0002, // Param is [Out] + Lcid = 0x0004, // Param is [lcid] + + Retval = 0x0008, // Param is [Retval] + Optional = 0x0010, // Param is optional + + HasDefault = 0x1000, // Param has default value. + HasFieldMarshal = 0x2000, // Param has FieldMarshal. + + Reserved3 = 0x4000, + Reserved4 = 0x8000, + ReservedMask = 0xf000, + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ParameterModifier.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ParameterModifier.cs new file mode 100644 index 0000000..18d6cf6 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ParameterModifier.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Serializable] + public struct ParameterModifier + { + private readonly bool[] _byRef; + + public ParameterModifier(int parameterCount) + { + if (parameterCount <= 0) + throw new ArgumentException(SR.Arg_ParmArraySize); + + _byRef = new bool[parameterCount]; + } + + public bool this[int index] + { + get + { + return _byRef[index]; + } + set + { + _byRef[index] = value; + } + } + +#if CORECLR + internal bool[] IsByRefArray => _byRef; +#endif + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/PortableExecutableKinds.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/PortableExecutableKinds.cs new file mode 100644 index 0000000..79be338 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/PortableExecutableKinds.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum PortableExecutableKinds + { + NotAPortableExecutableImage = 0x0, + ILOnly = 0x1, + Required32Bit = 0x2, + PE32Plus = 0x4, + Unmanaged32Bit = 0x8, + Preferred32Bit = 0x10, + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ProcessorArchitecture.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ProcessorArchitecture.cs new file mode 100644 index 0000000..becb346 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ProcessorArchitecture.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public enum ProcessorArchitecture + { + None = 0x0000, + MSIL = 0x0001, + X86 = 0x0002, + IA64 = 0x0003, + Amd64 = 0x0004, + Arm = 0x0005 + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/PropertyAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/PropertyAttributes.cs new file mode 100644 index 0000000..31e7a65 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/PropertyAttributes.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// PropertyAttributes is an enum which defines the attributes that may be associated +// with a property. The values here are defined in Corhdr.h. + +namespace System.Reflection +{ + // This Enum matchs the CorPropertyAttr defined in CorHdr.h + [Flags] + public enum PropertyAttributes + { + None = 0x0000, + SpecialName = 0x0200, // property is special. Name describes how. + + RTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding. + HasDefault = 0x1000, // Property has default + + Reserved2 = 0x2000, + Reserved3 = 0x4000, + Reserved4 = 0x8000, + ReservedMask = 0xf400, + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ReflectionContext.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ReflectionContext.cs new file mode 100644 index 0000000..e9e93da --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ReflectionContext.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public abstract class ReflectionContext + { + protected ReflectionContext() { } + + public abstract Assembly MapAssembly(Assembly assembly); + + public abstract TypeInfo MapType(TypeInfo type); + + public virtual TypeInfo GetTypeForObject(object value) + { + if (value == null) + throw new ArgumentNullException(nameof(value)); + + return MapType(value.GetType().GetTypeInfo()); + } + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs new file mode 100644 index 0000000..772620c --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ReflectionTypeLoadException.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public sealed class ReflectionTypeLoadException : SystemException, ISerializable + { + public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions) + : base(null) + { + Types = classes; + LoaderExceptions = exceptions; + HResult = __HResults.COR_E_REFLECTIONTYPELOAD; + } + + public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions, string message) + : base(message) + { + Types = classes; + LoaderExceptions = exceptions; + HResult = __HResults.COR_E_REFLECTIONTYPELOAD; + } + + internal ReflectionTypeLoadException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + Types = (Type[])(info.GetValue("Types", typeof(Type[]))); + LoaderExceptions = (Exception[])(info.GetValue("Exceptions", typeof(Exception[]))); + } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("Types", Types, typeof(Type[])); + info.AddValue("Exceptions", LoaderExceptions, typeof(Exception[])); + } + + public Type[] Types { get; } + + public Exception[] LoaderExceptions { get; } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ResourceAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ResourceAttributes.cs new file mode 100644 index 0000000..2d03f42 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ResourceAttributes.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum ResourceAttributes + { + Public = 0x0001, + Private = 0x0002, + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/ResourceLocation.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/ResourceLocation.cs new file mode 100644 index 0000000..4902333 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/ResourceLocation.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + [Flags] + public enum ResourceLocation + { + ContainedInAnotherAssembly = 2, + ContainedInManifestFile = 4, + Embedded = 1, + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs new file mode 100644 index 0000000..8d2bf1f --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.IO; +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public class StrongNameKeyPair : IDeserializationCallback, ISerializable + { + private bool _keyPairExported; + private byte[] _keyPairArray; + private string _keyPairContainer; + private byte[] _publicKey; + + // Build key pair from file. + public StrongNameKeyPair(FileStream keyPairFile) + { + if (keyPairFile == null) + throw new ArgumentNullException(nameof(keyPairFile)); + + int length = (int)keyPairFile.Length; + _keyPairArray = new byte[length]; + keyPairFile.Read(_keyPairArray, 0, length); + + _keyPairExported = true; + } + + // Build key pair from byte array in memory. + public StrongNameKeyPair(byte[] keyPairArray) + { + if (keyPairArray == null) + throw new ArgumentNullException(nameof(keyPairArray)); + + _keyPairArray = new byte[keyPairArray.Length]; + Array.Copy(keyPairArray, _keyPairArray, keyPairArray.Length); + + _keyPairExported = true; + } + + protected StrongNameKeyPair(SerializationInfo info, StreamingContext context) + { + _keyPairExported = (bool)info.GetValue("_keyPairExported", typeof(bool)); + _keyPairArray = (byte[])info.GetValue("_keyPairArray", typeof(byte[])); + _keyPairContainer = (string)info.GetValue("_keyPairContainer", typeof(string)); + _publicKey = (byte[])info.GetValue("_publicKey", typeof(byte[])); + } + + public StrongNameKeyPair(string keyPairContainer) + { + throw new PlatformNotSupportedException(); + } + + public byte[] PublicKey + { + get + { + throw new PlatformNotSupportedException(); + } + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + info.AddValue("_keyPairExported", _keyPairExported); + info.AddValue("_keyPairArray", _keyPairArray); + info.AddValue("_keyPairContainer", _keyPairContainer); + info.AddValue("_publicKey", _publicKey); + } + + void IDeserializationCallback.OnDeserialization(object sender) { } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/TargetException.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/TargetException.cs new file mode 100644 index 0000000..03f8730 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/TargetException.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public class TargetException : ApplicationException + { + public TargetException() + : this(null) + { + } + + public TargetException(string message) + : this(message, null) + { + } + + public TargetException(string message, Exception inner) + : base(message, inner) + { + HResult = __HResults.COR_E_TARGET; + } + + protected TargetException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/TargetInvocationException.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/TargetInvocationException.cs new file mode 100644 index 0000000..e934e5b --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/TargetInvocationException.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public sealed class TargetInvocationException : ApplicationException + { + public TargetInvocationException(Exception inner) + : base(SR.Arg_TargetInvocationException, inner) + { + HResult = __HResults.COR_E_TARGETINVOCATION; + } + + public TargetInvocationException(string message, Exception inner) + : base(message, inner) + { + HResult = __HResults.COR_E_TARGETINVOCATION; + } + + internal TargetInvocationException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/TargetParameterCountException.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/TargetParameterCountException.cs new file mode 100644 index 0000000..c360454 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/TargetParameterCountException.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public sealed class TargetParameterCountException : ApplicationException + { + public TargetParameterCountException() + : base(SR.Arg_TargetParameterCountException) + { + HResult = __HResults.COR_E_TARGETPARAMCOUNT; + } + + public TargetParameterCountException(string message) + : base(message) + { + HResult = __HResults.COR_E_TARGETPARAMCOUNT; + } + + public TargetParameterCountException(string message, Exception inner) + : base(message, inner) + { + HResult = __HResults.COR_E_TARGETPARAMCOUNT; + } + + internal TargetParameterCountException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/TypeAttributes.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/TypeAttributes.cs new file mode 100644 index 0000000..aa30331 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/TypeAttributes.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; + +namespace System.Reflection +{ + // This Enum matchs the CorTypeAttr defined in CorHdr.h + [Flags] + public enum TypeAttributes + { + VisibilityMask = 0x00000007, + NotPublic = 0x00000000, // Class is not public scope. + Public = 0x00000001, // Class is public scope. + NestedPublic = 0x00000002, // Class is nested with public visibility. + NestedPrivate = 0x00000003, // Class is nested with private visibility. + NestedFamily = 0x00000004, // Class is nested with family visibility. + NestedAssembly = 0x00000005, // Class is nested with assembly visibility. + NestedFamANDAssem = 0x00000006, // Class is nested with family and assembly visibility. + NestedFamORAssem = 0x00000007, // Class is nested with family or assembly visibility. + + // Use this mask to retrieve class layout informaiton + // 0 is AutoLayout, 0x2 is SequentialLayout, 4 is ExplicitLayout + LayoutMask = 0x00000018, + AutoLayout = 0x00000000, // Class fields are auto-laid out + SequentialLayout = 0x00000008, // Class fields are laid out sequentially + ExplicitLayout = 0x00000010, // Layout is supplied explicitly + // end layout mask + + // Use this mask to distinguish whether a type declaration is an interface. (Class vs. ValueType done based on whether it subclasses S.ValueType) + ClassSemanticsMask = 0x00000020, + Class = 0x00000000, // Type is a class (or a value type). + Interface = 0x00000020, // Type is an interface. + + // Special semantics in addition to class semantics. + Abstract = 0x00000080, // Class is abstract + Sealed = 0x00000100, // Class is concrete and may not be extended + SpecialName = 0x00000400, // Class name is special. Name describes how. + + // Implementation attributes. + Import = 0x00001000, // Class / interface is imported + Serializable = 0x00002000, // The class is Serializable. + WindowsRuntime = 0x00004000, // Type is a Windows Runtime type. + + // Use tdStringFormatMask to retrieve string information for native interop + StringFormatMask = 0x00030000, + AnsiClass = 0x00000000, // LPTSTR is interpreted as ANSI in this class + UnicodeClass = 0x00010000, // LPTSTR is interpreted as UNICODE + AutoClass = 0x00020000, // LPTSTR is interpreted automatically + CustomFormatClass = 0x00030000, // A non-standard encoding specified by CustomFormatMask + CustomFormatMask = 0x00C00000, // Use this mask to retrieve non-standard encoding information for native interop. The meaning of the values of these 2 bits is unspecified. + + // end string format mask + + BeforeFieldInit = 0x00100000, // Initialize the class any time before first static field access. + + RTSpecialName = 0x00000800, // Runtime should check name encoding. + HasSecurity = 0x00040000, // Class has security associate with it. + + ReservedMask = 0x00040800, + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/TypeFilter.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/TypeFilter.cs new file mode 100644 index 0000000..eb049f8 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/TypeFilter.cs @@ -0,0 +1,8 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public delegate bool TypeFilter(Type m, object filterCriteria); +}