1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Reflection; 7 using System.Diagnostics; 8 using System.Collections.Generic; 9 10 using System.Reflection.Runtime.General; 11 using System.Reflection.Runtime.TypeInfos; 12 using System.Reflection.Runtime.CustomAttributes; 13 14 using Internal.Reflection.Core; 15 using Internal.Reflection.Core.Execution; 16 17 namespace System.Reflection.Runtime.ParameterInfos 18 { 19 // This class is used for the "Get/Set" methods on array types. 20 internal sealed partial class RuntimeSyntheticParameterInfo : RuntimeParameterInfo 21 { RuntimeSyntheticParameterInfo(MemberInfo memberInfo, int position, RuntimeTypeInfo parameterType)22 private RuntimeSyntheticParameterInfo(MemberInfo memberInfo, int position, RuntimeTypeInfo parameterType) 23 : base(memberInfo, position) 24 { 25 _parameterType = parameterType; 26 } 27 28 public sealed override ParameterAttributes Attributes 29 { 30 get 31 { 32 return ParameterAttributes.None; 33 } 34 } 35 36 public sealed override IEnumerable<CustomAttributeData> CustomAttributes 37 { 38 get 39 { 40 return Empty<CustomAttributeData>.Enumerable; 41 } 42 } 43 44 public sealed override Object DefaultValue 45 { 46 get 47 { 48 return null; // Legacy: This is what the desktop returns. 49 } 50 } 51 52 public sealed override Object RawDefaultValue 53 { 54 get 55 { 56 return null; // Legacy: This is what the desktop returns. 57 } 58 } 59 60 public sealed override bool HasDefaultValue 61 { 62 get 63 { 64 // Compat: returning "true" makes no sense but this is how it's always been. 65 return true; 66 } 67 } 68 GetOptionalCustomModifiers()69 public sealed override Type[] GetOptionalCustomModifiers() => Array.Empty<Type>(); 70 GetRequiredCustomModifiers()71 public sealed override Type[] GetRequiredCustomModifiers() => Array.Empty<Type>(); 72 73 public sealed override String Name 74 { 75 get 76 { 77 return null; // Legacy: This is what the dekstop returns. 78 } 79 } 80 81 public sealed override Type ParameterType 82 { 83 get 84 { 85 return _parameterType; 86 } 87 } 88 89 public sealed override int MetadataToken 90 { 91 get 92 { 93 return 0x08000000; // nil ParamDef token 94 } 95 } 96 97 internal sealed override String ParameterTypeString 98 { 99 get 100 { 101 return _parameterType.FormatTypeName(); 102 } 103 } 104 105 private readonly RuntimeTypeInfo _parameterType; 106 } 107 } 108 109