diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Reflection')
15 files changed, 41 insertions, 41 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs index 78ab61b4a3..569c5f5c8c 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs @@ -92,9 +92,9 @@ namespace System.Reflection public virtual AssemblyName GetName() => GetName(copiedName: false); public virtual AssemblyName GetName(bool copiedName) { throw NotImplemented.ByDesign; } - public virtual Type GetType(string name) => GetType(name, throwOnError: false, ignoreCase: false); - public virtual Type GetType(string name, bool throwOnError) => GetType(name, throwOnError: throwOnError, ignoreCase: false); - public virtual Type GetType(string name, bool throwOnError, bool ignoreCase) { throw NotImplemented.ByDesign; } + public virtual Type? GetType(string name) => GetType(name, throwOnError: false, ignoreCase: false); + public virtual Type? GetType(string name, bool throwOnError) => GetType(name, throwOnError: throwOnError, ignoreCase: false); + public virtual Type? GetType(string name, bool throwOnError, bool ignoreCase) { throw NotImplemented.ByDesign; } public virtual bool IsDefined(Type attributeType, bool inherit) { throw NotImplemented.ByDesign; } @@ -110,7 +110,7 @@ namespace System.Reflection public object? CreateInstance(string typeName, bool ignoreCase) => CreateInstance(typeName, ignoreCase, BindingFlags.Public | BindingFlags.Instance, binder: null, args: null, culture: null, activationAttributes: null); public virtual object? CreateInstance(string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder? binder, object[]? args, CultureInfo? culture, object[]? activationAttributes) { - Type t = GetType(typeName, throwOnError: false, ignoreCase: ignoreCase); + Type? t = GetType(typeName, throwOnError: false, ignoreCase: ignoreCase); if (t == null) return null; @@ -119,8 +119,8 @@ namespace System.Reflection public virtual event ModuleResolveEventHandler ModuleResolve { add { throw NotImplemented.ByDesign; } remove { throw NotImplemented.ByDesign; } } - public virtual Module? ManifestModule { get { throw NotImplemented.ByDesign; } } - public virtual Module GetModule(string name) { throw NotImplemented.ByDesign; } + public virtual Module ManifestModule { get { throw NotImplemented.ByDesign; } } + public virtual Module? GetModule(string name) { throw NotImplemented.ByDesign; } public Module[] GetModules() => GetModules(getResourceModules: false); public virtual Module[] GetModules(bool getResourceModules) { throw NotImplemented.ByDesign; } @@ -324,19 +324,19 @@ namespace System.Reflection return AssemblyLoadContext.Default.LoadFromAssemblyPath(fullPath); } - public static Assembly LoadFrom(string? assemblyFile, byte[]? hashValue, AssemblyHashAlgorithm hashAlgorithm) + public static Assembly LoadFrom(string assemblyFile, byte[]? hashValue, AssemblyHashAlgorithm hashAlgorithm) { throw new NotSupportedException(SR.NotSupported_AssemblyLoadFromHash); } public static Assembly UnsafeLoadFrom(string assemblyFile) => LoadFrom(assemblyFile); - public Module LoadModule(string? moduleName, byte[]? rawModule) => LoadModule(moduleName, rawModule, null); - public virtual Module LoadModule(string? moduleName, byte[]? rawModule, byte[]? rawSymbolStore) { throw NotImplemented.ByDesign; } + public Module LoadModule(string moduleName, byte[]? rawModule) => LoadModule(moduleName, rawModule, null); + public virtual Module LoadModule(string moduleName, byte[]? rawModule, byte[]? rawSymbolStore) { throw NotImplemented.ByDesign; } - public static Assembly ReflectionOnlyLoad(byte[]? rawAssembly) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } - public static Assembly ReflectionOnlyLoad(string? assemblyString) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } - public static Assembly ReflectionOnlyLoadFrom(string? assemblyFile) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } + public static Assembly ReflectionOnlyLoad(byte[] rawAssembly) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } + public static Assembly ReflectionOnlyLoad(string assemblyString) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } + public static Assembly ReflectionOnlyLoadFrom(string assemblyFile) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } public virtual SecurityRuleSet SecurityRuleSet => SecurityRuleSet.None; } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs b/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs index ffdac56665..3de53a1419 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs @@ -172,7 +172,7 @@ namespace System.Reflection // The compressed version of the public key formed from a truncated hash. // Will throw a SecurityException if _publicKey is invalid - public byte[] GetPublicKeyToken() + public byte[]? GetPublicKeyToken() { if (_publicKeyToken == null) _publicKeyToken = ComputePublicKeyToken(); @@ -226,7 +226,7 @@ namespace System.Reflection if (this.Name == null) return string.Empty; // Do not call GetPublicKeyToken() here - that latches the result into AssemblyName which isn't a side effect we want. - byte[] pkt = _publicKeyToken ?? ComputePublicKeyToken(); + byte[]? pkt = _publicKeyToken ?? ComputePublicKeyToken(); return AssemblyNameFormatter.ComputeDisplayName(Name, Version, CultureName, pkt, Flags, ContentType); } } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/CustomAttributeNamedArgument.cs b/src/System.Private.CoreLib/shared/System/Reflection/CustomAttributeNamedArgument.cs index ee30573b76..42d280ccd9 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/CustomAttributeNamedArgument.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/CustomAttributeNamedArgument.cs @@ -47,7 +47,7 @@ namespace System.Reflection public override string ToString() { if (m_memberInfo == null) - return base.ToString(); + return base.ToString()!; return string.Format("{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object))); } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/CustomAttributeTypedArgument.cs b/src/System.Private.CoreLib/shared/System/Reflection/CustomAttributeTypedArgument.cs index 7ccdbe5ba4..6247d73fb8 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/CustomAttributeTypedArgument.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/CustomAttributeTypedArgument.cs @@ -41,7 +41,7 @@ namespace System.Reflection internal string ToString(bool typed) { if (m_argumentType == null) - return base.ToString(); + return base.ToString()!; if (ArgumentType.IsEnum) return string.Format(typed ? "{0}" : "({1}){0}", Value, ArgumentType.FullName); diff --git a/src/System.Private.CoreLib/shared/System/Reflection/FieldInfo.cs b/src/System.Private.CoreLib/shared/System/Reflection/FieldInfo.cs index 3ef9765a42..cbb04d54a4 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/FieldInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/FieldInfo.cs @@ -66,15 +66,15 @@ namespace System.Reflection [DebuggerHidden] [DebuggerStepThrough] - public void SetValue(object? obj, object value) => SetValue(obj, value, BindingFlags.Default, Type.DefaultBinder, null); + public void SetValue(object? obj, object? value) => SetValue(obj, value, BindingFlags.Default, Type.DefaultBinder, null); public abstract void SetValue(object? obj, object? value, BindingFlags invokeAttr, Binder? binder, CultureInfo? culture); [CLSCompliant(false)] public virtual void SetValueDirect(TypedReference obj, object value) { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); } [CLSCompliant(false)] - public virtual object GetValueDirect(TypedReference obj) { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); } + public virtual object? GetValueDirect(TypedReference obj) { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); } - public virtual object GetRawConstantValue() { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); } + public virtual object? GetRawConstantValue() { throw new NotSupportedException(SR.NotSupported_AbstractNonCLS); } public virtual Type[] GetOptionalCustomModifiers() { throw NotImplemented.ByDesign; } public virtual Type[] GetRequiredCustomModifiers() { throw NotImplemented.ByDesign; } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/IReflect.cs b/src/System.Private.CoreLib/shared/System/Reflection/IReflect.cs index f37389c1cd..f3658899d9 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/IReflect.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/IReflect.cs @@ -67,7 +67,7 @@ namespace System.Reflection // For the default binder, the most specific method will be selected. // // This will invoke a specific member... - object? InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters); + object? InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object?[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters); // Return the underlying Type that represents the IReflect Object. For expando object, // this is the (Object) IReflectInstance.GetType(). For Type object it is this. diff --git a/src/System.Private.CoreLib/shared/System/Reflection/MemberFilter.cs b/src/System.Private.CoreLib/shared/System/Reflection/MemberFilter.cs index ae91b620a6..07198cbc4e 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/MemberFilter.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/MemberFilter.cs @@ -4,5 +4,5 @@ namespace System.Reflection { - public delegate bool MemberFilter(MemberInfo m, object filterCriteria); + public delegate bool MemberFilter(MemberInfo m, object? filterCriteria); } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/MethodBase.cs b/src/System.Private.CoreLib/shared/System/Reflection/MethodBase.cs index dcc268228e..96ca09cf35 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/MethodBase.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/MethodBase.cs @@ -16,7 +16,7 @@ namespace System.Reflection public abstract MethodAttributes Attributes { get; } public virtual MethodImplAttributes MethodImplementationFlags => GetMethodImplementationFlags(); public abstract MethodImplAttributes GetMethodImplementationFlags(); - public virtual MethodBody GetMethodBody() { throw new InvalidOperationException(); } + public virtual MethodBody? GetMethodBody() { throw new InvalidOperationException(); } public virtual CallingConventions CallingConvention => CallingConventions.Standard; public bool IsAbstract => (Attributes & MethodAttributes.Abstract) != 0; diff --git a/src/System.Private.CoreLib/shared/System/Reflection/MethodInfo.cs b/src/System.Private.CoreLib/shared/System/Reflection/MethodInfo.cs index ccc67f328c..3624475b16 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/MethodInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/MethodInfo.cs @@ -12,16 +12,16 @@ namespace System.Reflection public override MemberTypes MemberType => MemberTypes.Method; - public virtual ParameterInfo? ReturnParameter { get { throw NotImplemented.ByDesign; } } - public virtual Type? ReturnType { get { throw NotImplemented.ByDesign; } } + public virtual ParameterInfo ReturnParameter { get { throw NotImplemented.ByDesign; } } + public virtual Type ReturnType { get { throw NotImplemented.ByDesign; } } public override Type[] GetGenericArguments() { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } - public virtual MethodInfo? GetGenericMethodDefinition() { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } - public virtual MethodInfo? MakeGenericMethod(params Type[] typeArguments) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } + public virtual MethodInfo GetGenericMethodDefinition() { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } + public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } - public abstract MethodInfo? GetBaseDefinition(); + public abstract MethodInfo GetBaseDefinition(); - public abstract ICustomAttributeProvider? ReturnTypeCustomAttributes { get; } + public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; } public virtual Delegate CreateDelegate(Type delegateType) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } public virtual Delegate CreateDelegate(Type delegateType, object? target) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Module.cs b/src/System.Private.CoreLib/shared/System/Reflection/Module.cs index 72d49d50e2..77fbc0fc65 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/Module.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Module.cs @@ -70,7 +70,7 @@ namespace System.Reflection public virtual Type? GetType(string className, bool ignoreCase) => GetType(className, throwOnError: false, ignoreCase: ignoreCase); public virtual Type? GetType(string className, bool throwOnError, bool ignoreCase) { throw NotImplemented.ByDesign; } - public virtual Type[] FindTypes(TypeFilter? filter, object filterCriteria) + public virtual Type[] FindTypes(TypeFilter? filter, object? filterCriteria) { Type[] c = GetTypes(); int cnt = 0; @@ -140,8 +140,8 @@ namespace System.Reflection public override string ToString() => ScopeName; - public static readonly TypeFilter FilterTypeName = (m, c) => FilterTypeNameImpl(m, c, StringComparison.Ordinal); - public static readonly TypeFilter FilterTypeNameIgnoreCase = (m, c) => FilterTypeNameImpl(m, c, StringComparison.OrdinalIgnoreCase); + public static readonly TypeFilter FilterTypeName = (m, c) => FilterTypeNameImpl(m, c!, StringComparison.Ordinal); + public static readonly TypeFilter FilterTypeNameIgnoreCase = (m, c) => FilterTypeNameImpl(m, c!, StringComparison.OrdinalIgnoreCase); private const BindingFlags DefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public; diff --git a/src/System.Private.CoreLib/shared/System/Reflection/ParameterInfo.cs b/src/System.Private.CoreLib/shared/System/Reflection/ParameterInfo.cs index 4ad145d9e9..eb0692ec18 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/ParameterInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/ParameterInfo.cs @@ -69,7 +69,7 @@ namespace System.Reflection if (PositionImpl == -1) { if (MemberImpl.MemberType == MemberTypes.Method) - return ((MethodInfo)MemberImpl).ReturnParameter!; + return ((MethodInfo)MemberImpl).ReturnParameter; else throw new SerializationException(SR.Serialization_BadParameterInfo); } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/PropertyInfo.cs b/src/System.Private.CoreLib/shared/System/Reflection/PropertyInfo.cs index 65697c1d75..663d52dbb7 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/PropertyInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/PropertyInfo.cs @@ -45,16 +45,16 @@ namespace System.Reflection public virtual object? GetValue(object? obj, object?[]? index) => GetValue(obj, BindingFlags.Default, binder: null, index: index, culture: null); public abstract object? GetValue(object? obj, BindingFlags invokeAttr, Binder? binder, object?[]? index, CultureInfo? culture); - public virtual object GetConstantValue() { throw NotImplemented.ByDesign; } - public virtual object GetRawConstantValue() { throw NotImplemented.ByDesign; } + public virtual object? GetConstantValue() { throw NotImplemented.ByDesign; } + public virtual object? GetRawConstantValue() { throw NotImplemented.ByDesign; } [DebuggerHidden] [DebuggerStepThrough] public void SetValue(object? obj, object? value) => SetValue(obj, value, index: null); [DebuggerHidden] [DebuggerStepThrough] - public virtual void SetValue(object? obj, object? value, object[]? index) => SetValue(obj, value, BindingFlags.Default, binder: null, index: index, culture: null); - public abstract void SetValue(object? obj, object? value, BindingFlags invokeAttr, Binder? binder, object[]? index, CultureInfo? culture); + public virtual void SetValue(object? obj, object? value, object?[]? index) => SetValue(obj, value, BindingFlags.Default, binder: null, index: index, culture: null); + public abstract void SetValue(object? obj, object? value, BindingFlags invokeAttr, Binder? binder, object?[]? index, CultureInfo? culture); public override bool Equals(object? obj) => base.Equals(obj); public override int GetHashCode() => base.GetHashCode(); diff --git a/src/System.Private.CoreLib/shared/System/Reflection/SignatureType.cs b/src/System.Private.CoreLib/shared/System/Reflection/SignatureType.cs index d5674bcb67..b59e245e86 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/SignatureType.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/SignatureType.cs @@ -111,11 +111,11 @@ namespace System.Reflection public sealed override Type GetNestedType(string name, BindingFlags bindingAttr) => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override Type[] GetNestedTypes(BindingFlags bindingAttr) => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override PropertyInfo[] GetProperties(BindingFlags bindingAttr) => throw new NotSupportedException(SR.NotSupported_SignatureType); - public sealed override object InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters) => throw new NotSupportedException(SR.NotSupported_SignatureType); + public sealed override object InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, object?[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters) => throw new NotSupportedException(SR.NotSupported_SignatureType); protected sealed override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[]? types, ParameterModifier[]? modifiers) => throw new NotSupportedException(SR.NotSupported_SignatureType); protected sealed override MethodInfo GetMethodImpl(string name, int genericParameterCount, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[]? types, ParameterModifier[]? modifiers) => throw new NotSupportedException(SR.NotSupported_SignatureType); protected sealed override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder? binder, Type? returnType, Type[]? types, ParameterModifier[]? modifiers) => throw new NotSupportedException(SR.NotSupported_SignatureType); - public sealed override MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter? filter, object filterCriteria) => throw new NotSupportedException(SR.NotSupported_SignatureType); + public sealed override MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter? filter, object? filterCriteria) => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override MemberInfo[] GetMember(string name, BindingFlags bindingAttr) => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override MemberInfo[] GetDefaultMembers() => throw new NotSupportedException(SR.NotSupported_SignatureType); @@ -129,7 +129,7 @@ namespace System.Reflection protected sealed override bool IsCOMObjectImpl() => throw new NotSupportedException(SR.NotSupported_SignatureType); protected sealed override bool IsPrimitiveImpl() => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override IEnumerable<CustomAttributeData> CustomAttributes => throw new NotSupportedException(SR.NotSupported_SignatureType); - public sealed override Type[] FindInterfaces(TypeFilter filter, object filterCriteria) => throw new NotSupportedException(SR.NotSupported_SignatureType); + public sealed override Type[] FindInterfaces(TypeFilter filter, object? filterCriteria) => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override InterfaceMapping GetInterfaceMap(Type interfaceType) => throw new NotSupportedException(SR.NotSupported_SignatureType); protected sealed override bool IsContextfulImpl() => throw new NotSupportedException(SR.NotSupported_SignatureType); public sealed override bool IsEnum => throw new NotSupportedException(SR.NotSupported_SignatureType); diff --git a/src/System.Private.CoreLib/shared/System/Reflection/TypeDelegator.cs b/src/System.Private.CoreLib/shared/System/Reflection/TypeDelegator.cs index 81112c9d10..a31367a000 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/TypeDelegator.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/TypeDelegator.cs @@ -35,7 +35,7 @@ namespace System.Reflection public override int MetadataToken => typeImpl.MetadataToken; public override object? InvokeMember(string name, BindingFlags invokeAttr, Binder? binder, object? target, - object[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters) + object?[]? args, ParameterModifier[]? modifiers, CultureInfo? culture, string[]? namedParameters) { return typeImpl.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters); } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/TypeFilter.cs b/src/System.Private.CoreLib/shared/System/Reflection/TypeFilter.cs index eb049f81f9..befa09ac32 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/TypeFilter.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/TypeFilter.cs @@ -4,5 +4,5 @@ namespace System.Reflection { - public delegate bool TypeFilter(Type m, object filterCriteria); + public delegate bool TypeFilter(Type m, object? filterCriteria); } |