diff options
author | Santiago Fernandez Madero <safern@microsoft.com> | 2019-06-03 23:37:44 -0700 |
---|---|---|
committer | Santiago Fernandez Madero <safern@microsoft.com> | 2019-06-03 23:43:54 -0700 |
commit | 9d98b4875ae456d3f58cae75c009afabf19d0d15 (patch) | |
tree | 06ab88d57e0ec25d838544ebc1da5d02852effb0 /src/System.Private.CoreLib | |
parent | 4adb4abf3dbeff4fb3070315368f49d66c732862 (diff) | |
download | coreclr-9d98b4875ae456d3f58cae75c009afabf19d0d15.tar.gz coreclr-9d98b4875ae456d3f58cae75c009afabf19d0d15.tar.bz2 coreclr-9d98b4875ae456d3f58cae75c009afabf19d0d15.zip |
PR Feedback
Diffstat (limited to 'src/System.Private.CoreLib')
30 files changed, 40 insertions, 90 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs index 6412676f26..b316cf936a 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs @@ -3521,19 +3521,19 @@ namespace System.Diagnostics.Tracing if (!reflectionOnly && (staticFieldType == typeof(EventOpcode)) || AttributeTypeNamesMatch(staticFieldType, typeof(EventOpcode))) { if (providerEnumKind != "Opcodes") goto Error; - int value = (int)staticField.GetRawConstantValue(); + int value = (int)staticField.GetRawConstantValue()!; manifest.AddOpcode(staticField.Name, value); } else if (!reflectionOnly && (staticFieldType == typeof(EventTask)) || AttributeTypeNamesMatch(staticFieldType, typeof(EventTask))) { if (providerEnumKind != "Tasks") goto Error; - int value = (int)staticField.GetRawConstantValue(); + int value = (int)staticField.GetRawConstantValue()!; manifest.AddTask(staticField.Name, value); } else if (!reflectionOnly && (staticFieldType == typeof(EventKeywords)) || AttributeTypeNamesMatch(staticFieldType, typeof(EventKeywords))) { if (providerEnumKind != "Keywords") goto Error; - ulong value = unchecked((ulong)(long)staticField.GetRawConstantValue()); + ulong value = unchecked((ulong)(long)staticField.GetRawConstantValue()!); manifest.AddKeyword(staticField.Name, value); } #if FEATURE_MANAGED_ETW_CHANNELS && FEATURE_ADVANCED_MANAGED_ETW_CHANNELS @@ -3730,7 +3730,7 @@ namespace System.Diagnostics.Tracing #if ES_BUILD_STANDALONE (new ReflectionPermission(ReflectionPermissionFlag.MemberAccess)).Assert(); #endif - byte[] instrs = method.GetMethodBody().GetILAsByteArray()!; + byte[] instrs = method.GetMethodBody()!.GetILAsByteArray()!; int retVal = -1; for (int idx = 0; idx < instrs.Length;) { @@ -5828,7 +5828,7 @@ namespace System.Diagnostics.Tracing bool anyValuesWritten = false; foreach (FieldInfo staticField in staticFields) { - object constantValObj = staticField.GetRawConstantValue(); + object? constantValObj = staticField.GetRawConstantValue(); if (constantValObj != null) { diff --git a/src/System.Private.CoreLib/shared/System/Nullable.cs b/src/System.Private.CoreLib/shared/System/Nullable.cs index 8d308a758d..a347696458 100644 --- a/src/System.Private.CoreLib/shared/System/Nullable.cs +++ b/src/System.Private.CoreLib/shared/System/Nullable.cs @@ -71,12 +71,10 @@ namespace System return hasValue ? value.GetHashCode() : 0; } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) public override string? ToString() { return hasValue ? value.ToString() : ""; } -#pragma warning restore CS8609 [NonVersionable] public static implicit operator Nullable<T>(T value) diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs index aa9cd55055..569c5f5c8c 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs @@ -119,7 +119,7 @@ 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 ManifestModule { get { throw NotImplemented.ByDesign; } } public virtual Module? GetModule(string name) { throw NotImplemented.ByDesign; } public Module[] GetModules() => GetModules(getResourceModules: false); diff --git a/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs b/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs index 9bc3ea099f..3de53a1419 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/AssemblyName.cs @@ -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/Emit/Opcode.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/Opcode.cs index b9b799d2f3..a2d5792c6a 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/Emit/Opcode.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Emit/Opcode.cs @@ -183,11 +183,9 @@ namespace System.Reflection.Emit return Value; } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) public override string? ToString() { return Name; } -#pragma warning restore CS8609 } } diff --git a/src/System.Private.CoreLib/shared/System/Reflection/FieldInfo.cs b/src/System.Private.CoreLib/shared/System/Reflection/FieldInfo.cs index 7af1c782f1..cbb04d54a4 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/FieldInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/FieldInfo.cs @@ -72,9 +72,9 @@ namespace System.Reflection [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/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/Threading/Tasks/TaskContinuation.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskContinuation.cs index 24c756e34d..f275fd9549 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskContinuation.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskContinuation.cs @@ -256,7 +256,7 @@ namespace System.Threading.Tasks #if PROJECTN [DependencyReductionRoot] #endif - internal abstract Delegate[] GetDelegateContinuationsForDebugger(); + internal abstract Delegate[]? GetDelegateContinuationsForDebugger(); } /// <summary>Provides the standard implementation of a task continuation.</summary> @@ -341,7 +341,6 @@ namespace System.Threading.Tasks else continuationTask.InternalCancel(false); } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) internal override Delegate[]? GetDelegateContinuationsForDebugger() { if (m_task.m_action == null) @@ -351,7 +350,6 @@ namespace System.Threading.Tasks return new Delegate[] { m_task.m_action }; } -#pragma warning restore CS8609 } diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs index 123800914b..75c6fd9a32 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs @@ -776,7 +776,6 @@ namespace System.Threading.Tasks public ConfiguredValueTaskAwaitable<TResult> ConfigureAwait(bool continueOnCapturedContext) => new ConfiguredValueTaskAwaitable<TResult>(new ValueTask<TResult>(_obj, _result, _token, continueOnCapturedContext)); -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) /// <summary>Gets a string-representation of this <see cref="ValueTask{TResult}"/>.</summary> public override string? ToString() { @@ -791,6 +790,5 @@ namespace System.Threading.Tasks return string.Empty; } -#pragma warning restore CS8609 } } diff --git a/src/System.Private.CoreLib/shared/System/Type.Enum.cs b/src/System.Private.CoreLib/shared/System/Type.Enum.cs index ac610e8484..308b57aefe 100644 --- a/src/System.Private.CoreLib/shared/System/Type.Enum.cs +++ b/src/System.Private.CoreLib/shared/System/Type.Enum.cs @@ -121,7 +121,7 @@ namespace System for (int i = 0; i < flds.Length; i++) { names[i] = flds[i].Name; - values[i] = flds[i].GetRawConstantValue(); + values[i] = flds[i].GetRawConstantValue()!; } // Insertion Sort these values in ascending order. diff --git a/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs index 6b0b049fe3..d57ee6410f 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs @@ -62,7 +62,7 @@ namespace System.Reflection } [MethodImpl(MethodImplOptions.InternalCall)] - private extern byte[] ComputePublicKeyToken(); + private extern byte[]? ComputePublicKeyToken(); internal void SetProcArchIndex(PortableExecutableKinds pek, ImageFileMachine ifm) { diff --git a/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs b/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs index 9cd4b90d62..999327c6f7 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs @@ -112,7 +112,7 @@ namespace System.Reflection // No pseudo attributes for RuntimeAssembly - return GetCustomAttributes((RuntimeModule)target.ManifestModule!, RuntimeAssembly.GetToken(target.GetNativeHandle())); + return GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle())); } internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeParameterInfo target) diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs index ce0438d396..072b3605ee 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs @@ -497,7 +497,7 @@ namespace System.Reflection.Emit return InternalAssembly.GetType(name, throwOnError, ignoreCase); } - public override Module? ManifestModule => _manifestModuleBuilder.InternalModule; + public override Module ManifestModule => _manifestModuleBuilder.InternalModule; public override bool ReflectionOnly => InternalAssembly.ReflectionOnly; diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs index 0ee2ecd283..4f6e60c604 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs @@ -190,13 +190,10 @@ namespace System.Reflection.Emit return m_methodBuilder.GetModule(); } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) - // This always returns null. Is that what we want? - internal override Type? GetReturnType() + internal override Type GetReturnType() { return m_methodBuilder.ReturnType; } -#pragma warning restore CS8609 public string Signature { diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs index d9a702b3e7..10d67104f6 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs @@ -738,12 +738,10 @@ namespace System.Reflection.Emit return m_localSignature; } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) internal override byte[]? GetRawEHInfo() { return m_exceptionHeader; } -#pragma warning restore CS8609 internal override unsafe void GetEHInfo(int excNumber, void* exc) { @@ -770,10 +768,7 @@ namespace System.Reflection.Emit } } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) internal override string? GetStringLiteral(int token) { return m_scope.GetString(token); } -#pragma warning restore CS8609 - internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle) { @@ -839,12 +834,10 @@ namespace System.Reflection.Emit } } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) internal override byte[]? ResolveSignature(int token, int fromMethod) { return m_scope.ResolveSignature(token, fromMethod); } -#pragma warning restore CS8609 internal override MethodInfo GetDynamicMethod() { diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs index 1b5706d349..51f30ab9f3 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs @@ -86,16 +86,7 @@ namespace System.Reflection.Emit m_strName = name; m_module = mod; m_containingType = type; - - - if (returnType == null) - { - m_returnType = typeof(void); - } - else - { - m_returnType = returnType; - } + m_returnType = returnType ?? typeof(void); if ((attributes & MethodAttributes.Static) == 0) { @@ -649,9 +640,7 @@ namespace System.Reflection.Emit public override bool IsGenericMethod { get { return m_inst != null; } } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) - public override Type[]? GetGenericArguments() { return m_inst; } -#pragma warning restore CS8609 + public override Type[] GetGenericArguments() => m_inst ?? Array.Empty<Type>(); public override MethodInfo MakeGenericMethod(params Type[] typeArguments) { diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs index 458ed260e1..00c5412b03 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs @@ -96,7 +96,7 @@ namespace System.Reflection.Emit } } - public override ParameterInfo ReturnParameter { get { throw new NotSupportedException(); } } + public override ParameterInfo? ReturnParameter { get { throw new NotSupportedException(); } } public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { throw new NotSupportedException(); } } public override MethodInfo GetBaseDefinition() { throw new NotSupportedException(); } #endregion diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.cs index ed96eeedea..790175c6fa 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.cs @@ -14,7 +14,7 @@ namespace System.Reflection.Emit TypeBuilder.SetConstantValue( _methodBuilder.GetModuleBuilder(), _token.Token, - _position == 0 ? _methodBuilder.ReturnType! : _methodBuilder.m_parameterTypes![_position - 1], + _position == 0 ? _methodBuilder.ReturnType : _methodBuilder.m_parameterTypes![_position - 1], defaultValue); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs index 87775e6b24..a2573cc0fb 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs @@ -13,7 +13,7 @@ namespace System.Reflection.Emit private Type m_containingType; private string m_name; private CallingConventions m_callingConvention; - private Type? m_returnType; + private Type m_returnType; private MethodToken m_mdMethod; private Type[] m_parameterTypes; private SignatureHelper m_signature; @@ -33,7 +33,7 @@ namespace System.Reflection.Emit m_mdMethod = token; // The ParameterTypes are also a bit interesting in that they may be unbaked TypeBuilders. - m_returnType = returnType; + m_returnType = returnType ?? typeof(void); if (parameterTypes != null) { m_parameterTypes = new Type[parameterTypes.Length]; @@ -118,8 +118,7 @@ namespace System.Reflection.Emit #endregion #region MethodInfo Overrides -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) - public override Type? ReturnType + public override Type ReturnType { get { @@ -127,6 +126,7 @@ namespace System.Reflection.Emit } } +#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) public override ICustomAttributeProvider? ReturnTypeCustomAttributes { get { return null; } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs index 9d15357ef3..806308fe37 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs @@ -1250,9 +1250,7 @@ namespace System.Reflection.Emit return TypeBuilderInstantiation.MakeGenericType(this, typeArguments); } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) - public override Type[]? GetGenericArguments() { return m_inst; } -#pragma warning restore CS8609 + public override Type[] GetGenericArguments() => m_inst ?? Array.Empty<Type>(); // If a TypeBuilder is generic, it must be a generic type definition // All instantiated generic types are TypeBuilderInstantiation. diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs index 65430397ef..750c3e81f2 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs @@ -75,7 +75,7 @@ namespace System.Reflection.Emit #region Public Abstract\Virtual Members public override Type ReturnType { get { return m_method.ReturnType; } } - public override ParameterInfo ReturnParameter { get { throw new NotSupportedException(); } } + public override ParameterInfo? ReturnParameter { get { throw new NotSupportedException(); } } public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { throw new NotSupportedException(); } } public override MethodInfo GetBaseDefinition() { throw new NotSupportedException(); } #endregion @@ -110,12 +110,10 @@ namespace System.Reflection.Emit return m_ctor.GetParameterTypes(); } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) - internal override Type? GetReturnType() + internal override Type GetReturnType() { - return DeclaringType; + return m_type; } -#pragma warning restore CS8609 #region MemberInfo Overrides public override MemberTypes MemberType { get { return m_ctor.MemberType; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs index 9e7dd0a51d..f4cee246cc 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs @@ -66,14 +66,12 @@ namespace System.Reflection public override bool IsSecuritySafeCritical { get { return DeclaringType!.IsSecuritySafeCritical; } } public override bool IsSecurityTransparent { get { return DeclaringType!.IsSecurityTransparent; } } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] public override object? GetValueDirect(TypedReference obj) { return GetValue(null); } -#pragma warning restore CS8609 [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] @@ -89,9 +87,7 @@ namespace System.Reflection return GetValue(false); } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) public override object? GetRawConstantValue() { return GetValue(true); } -#pragma warning restore CS8609 private object? GetValue(bool raw) { diff --git a/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs index a5dbc61c4a..ca75d25166 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs @@ -188,7 +188,6 @@ namespace System.Reflection public override object GetRawConstantValue() { throw new InvalidOperationException(); } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] public override object? GetValueDirect(TypedReference obj) @@ -202,7 +201,6 @@ namespace System.Reflection return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, &obj, (RuntimeType?)DeclaringType); } } -#pragma warning restore CS8609 [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index d5eda80f7d..9239b12f32 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -103,7 +103,7 @@ namespace System.Reflection GetFlags() | AssemblyNameFlags.PublicKey, null); // strong name key pair - Module? manifestModule = ManifestModule; + Module manifestModule = ManifestModule; if (manifestModule != null) { if (manifestModule.MDStreamVersion > 0x10000) @@ -271,7 +271,7 @@ namespace System.Reflection throw new PlatformNotSupportedException(); } - public override Module? ManifestModule + public override Module ManifestModule { get { diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs index 4c95894dc6..5d8be5db3b 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs @@ -376,7 +376,6 @@ namespace System.Reflection return RuntimeMethodHandle.InvokeMethod(obj, null, sig, false, wrapExceptions); } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) public override MethodBody? GetMethodBody() { RuntimeMethodBody? mb = RuntimeMethodHandle.GetMethodBody(this, ReflectedTypeInternal); @@ -384,7 +383,6 @@ namespace System.Reflection mb._methodBase = this; return mb; } -#pragma warning restore CS8609 public override bool IsSecurityCritical { diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs index 7ff457b485..4378c49074 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs @@ -394,7 +394,6 @@ namespace System.Reflection } } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) public override MethodBody? GetMethodBody() { RuntimeMethodBody? mb = RuntimeMethodHandle.GetMethodBody(this, ReflectedTypeInternal); @@ -402,7 +401,6 @@ namespace System.Reflection mb._methodBase = this; return mb; } -#pragma warning restore CS8609 #endregion @@ -522,16 +520,9 @@ namespace System.Reflection get { return ReturnParameter; } } -#pragma warning disable CS8609 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) - public override ParameterInfo ReturnParameter - { - get - { - FetchReturnParameter(); - return (m_returnParameter as ParameterInfo)!; - } - } -#pragma warning restore CS8609 +#pragma warning disable CS6809 // TODO-NULLABLE: Covariant return types (https://github.com/dotnet/roslyn/issues/23268) + public override ParameterInfo ReturnParameter => FetchReturnParameter(); +#pragma warning restore CS6809 public override bool IsCollectible => (RuntimeMethodHandle.GetIsCollectible(new RuntimeMethodHandleInternal(m_handle)) != Interop.BOOL.FALSE); diff --git a/src/System.Private.CoreLib/src/System/RuntimeHandles.cs b/src/System.Private.CoreLib/src/System/RuntimeHandles.cs index 6555a5a14d..63863277fc 100644 --- a/src/System.Private.CoreLib/src/System/RuntimeHandles.cs +++ b/src/System.Private.CoreLib/src/System/RuntimeHandles.cs @@ -1545,15 +1545,15 @@ namespace System } // ILHeader info - internal abstract RuntimeType GetJitContext(out int securityControlFlags); + internal abstract RuntimeType? GetJitContext(out int securityControlFlags); internal abstract byte[] GetCodeInfo(out int stackSize, out int initLocals, out int EHCount); internal abstract byte[] GetLocalsSignature(); internal abstract unsafe void GetEHInfo(int EHNumber, void* exception); - internal abstract byte[] GetRawEHInfo(); + internal abstract byte[]? GetRawEHInfo(); // token resolution - internal abstract string GetStringLiteral(int token); + internal abstract string? GetStringLiteral(int token); internal abstract void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle); - internal abstract byte[] ResolveSignature(int token, int fromMethod); + internal abstract byte[]? ResolveSignature(int token, int fromMethod); // internal abstract MethodInfo GetDynamicMethod(); } diff --git a/src/System.Private.CoreLib/src/System/ValueType.cs b/src/System.Private.CoreLib/src/System/ValueType.cs index 34edc8f68e..405b88bb50 100644 --- a/src/System.Private.CoreLib/src/System/ValueType.cs +++ b/src/System.Private.CoreLib/src/System/ValueType.cs @@ -88,7 +88,7 @@ namespace System [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern int GetHashCodeOfPtr(IntPtr ptr); - public override string ToString() + public override string? ToString() { return this.GetType().ToString(); } |