Fix test failures
authorBuyaa Namnan <bunamnan@microsoft.com>
Mon, 29 Apr 2019 04:43:09 +0000 (21:43 -0700)
committerBuyaa Namnan <bunamnan@microsoft.com>
Tue, 30 Apr 2019 17:29:39 +0000 (10:29 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/a0d373b624babea46f8da346bfeb94862f150ef7

16 files changed:
src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/RtType.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Module.cs

index 17101c0..81769f3 100644 (file)
@@ -462,7 +462,7 @@ namespace System
                     return InternalGetCustomAttributes((EventInfo)element, type, inherit);
 
                 default:
-                    return (Attribute[])element.GetCustomAttributes(type, inherit);
+                    return (element.GetCustomAttributes(type, inherit) as Attribute[])!;
             }
         }
 
@@ -485,7 +485,7 @@ namespace System
                     return InternalGetCustomAttributes((EventInfo)element, typeof(Attribute), inherit);
 
                 default:
-                    return (Attribute[])element.GetCustomAttributes(typeof(Attribute), inherit);
+                    return (element.GetCustomAttributes(typeof(Attribute), inherit) as Attribute[])!;
             }
         }
 
@@ -567,9 +567,9 @@ namespace System
 
             MemberInfo member = element.Member;
             if (member.MemberType == MemberTypes.Method && inherit)
-                return InternalParamGetCustomAttributes(element, attributeType, inherit);
+                return InternalParamGetCustomAttributes(element, attributeType, inherit) as Attribute[];
 
-            return (Attribute[])element.GetCustomAttributes(attributeType, inherit);
+            return (element.GetCustomAttributes(attributeType, inherit) as Attribute[])!;
         }
 
         public static Attribute[] GetCustomAttributes(ParameterInfo element, bool inherit)
@@ -583,9 +583,9 @@ namespace System
 
             MemberInfo member = element.Member;
             if (member.MemberType == MemberTypes.Method && inherit)
-                return InternalParamGetCustomAttributes(element, null, inherit);
+                return InternalParamGetCustomAttributes(element, null, inherit) as Attribute[];
 
-            return (Attribute[])element.GetCustomAttributes(typeof(Attribute), inherit);
+            return (element.GetCustomAttributes(typeof(Attribute), inherit) as Attribute[])!;
         }
 
         public static bool IsDefined(ParameterInfo element, Type attributeType)
index 7eba81d..9e6ac21 100644 (file)
@@ -1467,7 +1467,7 @@ namespace System.Reflection
                         else
                         {
                             FieldInfo field = attributeType.GetField(name)!;
-                            field.SetValue(attribute, value!, BindingFlags.Default, Type.DefaultBinder, null);
+                            field.SetValue(attribute, value, BindingFlags.Default, Type.DefaultBinder, null);
                         }
                     }
                     catch (Exception e)
@@ -1504,7 +1504,7 @@ namespace System.Reflection
             isVarArg = false;
 
             // Resolve attribute type from ctor parent token found in decorated decoratedModule scope
-            attributeType = (RuntimeType)decoratedModule.ResolveType(scope.GetParentToken(caCtorToken), null, null);
+            attributeType = (decoratedModule.ResolveType(scope.GetParentToken(caCtorToken), null, null) as RuntimeType)!;
 
             // Test attribute type against user provided attribute type filter
             if (!(attributeFilterType.IsAssignableFrom(attributeType)))
index 10189c1..fd737ce 100644 (file)
@@ -270,13 +270,8 @@ namespace System.Reflection.Emit
                 {
                     if (signature[i] == null)
                         throw new ArgumentException(SR.Arg_InvalidTypeInSignature);
-
-                    if (signature[i].UnderlyingSystemType is RuntimeType rt)
-                        m_parameterTypes[i] = rt;
-                    else
-                        throw new ArgumentException(SR.Arg_InvalidTypeInSignature);
-
-                    if (m_parameterTypes[i] == typeof(void))
+                    m_parameterTypes[i] = (signature[i].UnderlyingSystemType as RuntimeType)!;
+                    if (m_parameterTypes[i] == null || m_parameterTypes[i] == typeof(void))
                         throw new ArgumentException(SR.Arg_InvalidTypeInSignature);
                 }
             }
@@ -468,7 +463,7 @@ namespace System.Reflection.Emit
             object retValue;
             if (actualCount > 0)
             {
-                object[] arguments = CheckArguments(parameters!, binder!, invokeAttr, culture, sig);
+                object[] arguments = CheckArguments(parameters!, binder, invokeAttr, culture, sig);
                 retValue = RuntimeMethodHandle.InvokeMethod(null, arguments, sig, false, wrapExceptions);
                 // copy out. This should be made only if ByRef are present.
                 for (int index = 0; index < arguments.Length; index++)
@@ -590,7 +585,7 @@ namespace System.Reflection.Emit
             {
                 var sbName = new ValueStringBuilder(MethodNameBufferSize);
 
-                sbName.Append(ReturnType!.FormatTypeName());
+                sbName.Append(ReturnType.FormatTypeName());
                 sbName.Append(' ');
                 sbName.Append(Name);
 
index 46a784d..3d0d2b3 100644 (file)
@@ -78,7 +78,7 @@ namespace System.Reflection.Emit
 
         // _TypeBuilder contains both TypeBuilder and EnumBuilder objects
         private Dictionary<string, Type> _typeBuilderDict = null!;
-        private ISymbolWriter? _iSymWriter = null;
+        private ISymbolWriter? _iSymWriter;
         internal ModuleBuilderData _moduleData = null!;
         internal InternalModuleBuilder _internalModuleBuilder;
         // This is the "external" AssemblyBuilder
@@ -439,7 +439,7 @@ namespace System.Reflection.Emit
                 if (masmi != null)
                     tkParent = GetMethodToken(masmi).Token;
                 else
-                    tkParent = GetConstructorToken((ConstructorInfo)method).Token;
+                    tkParent = GetConstructorToken((method as ConstructorInfo)!).Token;
             }
 
             return GetMemberRefFromSignature(tkParent, method.Name, sigBytes, sigLength);
@@ -1288,7 +1288,7 @@ namespace System.Reflection.Emit
                     }
                     else
                     {
-                        tk = GetConstructorToken((ConstructorInfo)method).Token;
+                        tk = GetConstructorToken((method as ConstructorInfo)!).Token;
                     }
                 }
                 else
index 41692ff..9bcad7a 100644 (file)
@@ -92,7 +92,7 @@ namespace System.Reflection.Emit
             if (!(type is TypeBuilderInstantiation))
                 throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
 
-            return MethodOnTypeBuilderInstantiation.GetMethod(method, (TypeBuilderInstantiation)type);
+            return MethodOnTypeBuilderInstantiation.GetMethod(method, (type as TypeBuilderInstantiation)!);
         }
         public static ConstructorInfo GetConstructor(Type type, ConstructorInfo constructor)
         {
@@ -112,7 +112,7 @@ namespace System.Reflection.Emit
             if (type.GetGenericTypeDefinition() != constructor.DeclaringType)
                 throw new ArgumentException(SR.Argument_InvalidConstructorDeclaringType, nameof(type));
 
-            return ConstructorOnTypeBuilderInstantiation.GetConstructor(constructor, (TypeBuilderInstantiation)type);
+            return ConstructorOnTypeBuilderInstantiation.GetConstructor(constructor, (type as TypeBuilderInstantiation)!);
         }
         public static FieldInfo GetField(Type type, FieldInfo field)
         {
@@ -132,7 +132,7 @@ namespace System.Reflection.Emit
             if (type.GetGenericTypeDefinition() != field.DeclaringType)
                 throw new ArgumentException(SR.Argument_InvalidFieldDeclaringType, nameof(type));
 
-            return FieldOnTypeBuilderInstantiation.GetField(field, (TypeBuilderInstantiation)type);
+            return FieldOnTypeBuilderInstantiation.GetField(field, (type as TypeBuilderInstantiation)!);
         }
         #endregion
 
@@ -1167,7 +1167,7 @@ namespace System.Reflection.Emit
             if (!IsCreated())
                 throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
 
-            return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, (RuntimeType)typeof(object), inherit);
+            return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, (typeof(object) as RuntimeType)!, inherit);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
index 58174c2..dd6f7e5 100644 (file)
@@ -270,7 +270,7 @@ namespace System.Reflection
 
         public override object[] GetCustomAttributes(bool inherit)
         {
-            return CustomAttribute.GetCustomAttributes(this, (RuntimeType)typeof(object));
+            return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
index d755cd5..f070980 100644 (file)
@@ -165,7 +165,7 @@ namespace System.Reflection
         #region ICustomAttributeProvider
         public override object[] GetCustomAttributes(bool inherit)
         {
-            return CustomAttribute.GetCustomAttributes(this, (RuntimeType)typeof(object));
+            return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
@@ -435,7 +435,7 @@ namespace System.Reflection
             bool wrapExceptions = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0;
             if (actualCount > 0)
             {
-                object[] arguments = CheckArguments(parameters!, binder!, invokeAttr, culture, sig);
+                object[] arguments = CheckArguments(parameters!, binder, invokeAttr, culture, sig);
                 object retValue = RuntimeMethodHandle.InvokeMethod(null, arguments, sig, true, wrapExceptions);
                 // copy out. This should be made only if ByRef are present.
                 for (int index = 0; index < arguments.Length; index++)
index 8667116..98bfee2 100644 (file)
@@ -17,7 +17,7 @@ namespace System.Reflection
         private string? m_name;
         private void* m_utf8name;
         private RuntimeTypeCache m_reflectedTypeCache = null!;
-        private RuntimeMethodInfo? m_addMethod = null;
+        private RuntimeMethodInfo? m_addMethod;
         private RuntimeMethodInfo? m_removeMethod;
         private RuntimeMethodInfo? m_raiseMethod;
         private MethodInfo[]? m_otherMethod;
@@ -83,7 +83,7 @@ namespace System.Reflection
         #region ICustomAttributeProvider
         public override object[] GetCustomAttributes(bool inherit)
         {
-            return CustomAttribute.GetCustomAttributes(this, (RuntimeType)typeof(object));
+            return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
index 690c381..5be8c9f 100644 (file)
@@ -82,7 +82,7 @@ namespace System.Reflection
         #region ICustomAttributeProvider
         public override object[] GetCustomAttributes(bool inherit)
         {
-            return CustomAttribute.GetCustomAttributes(this, (RuntimeType)typeof(object));
+            return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
index 28ebe4f..70ef2e3 100644 (file)
@@ -42,7 +42,7 @@ namespace System.Reflection
                     //
                     // first take care of all the NO_INVOKE cases. 
                     if (ContainsGenericParameters ||
-                         IsDisallowedByRefType(ReturnType!) ||
+                         IsDisallowedByRefType(ReturnType) ||
                          (declaringType != null && declaringType.ContainsGenericParameters) ||
                          ((CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs))
                     {
@@ -52,7 +52,7 @@ namespace System.Reflection
                     else
                     {
                         // Check for byref-like types
-                        if ((declaringType != null && declaringType.IsByRefLike) || ReturnType!.IsByRefLike)
+                        if ((declaringType != null && declaringType.IsByRefLike) || ReturnType.IsByRefLike)
                             invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_CONTAINS_STACK_POINTERS;
                     }
 
@@ -182,7 +182,7 @@ namespace System.Reflection
             {
                 var sbName = new ValueStringBuilder(MethodNameBufferSize);
 
-                sbName.Append(ReturnType!.FormatTypeName());
+                sbName.Append(ReturnType.FormatTypeName());
                 sbName.Append(' ');
                 sbName.Append(Name);
 
@@ -254,7 +254,7 @@ namespace System.Reflection
         #region ICustomAttributeProvider
         public override object[] GetCustomAttributes(bool inherit)
         {
-            return CustomAttribute.GetCustomAttributes(this, (RuntimeType)typeof(object), inherit);
+            return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!, inherit);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
@@ -441,7 +441,7 @@ namespace System.Reflection
             {
                 throw new MemberAccessException();
             }
-            else if (ReturnType!.IsByRef)
+            else if (ReturnType.IsByRef)
             {
                 Type elementType = ReturnType.GetElementType()!;
                 if (elementType.IsByRefLike)
@@ -457,7 +457,7 @@ namespace System.Reflection
         [Diagnostics.DebuggerHidden]
         public override object? Invoke(object? obj, BindingFlags invokeAttr, Binder? binder, object?[]? parameters, CultureInfo? culture)
         {
-            object[]? arguments = InvokeArgumentsCheck(obj, invokeAttr, binder!, parameters, culture);
+            object[]? arguments = InvokeArgumentsCheck(obj, invokeAttr, binder, parameters, culture);
 
             bool wrapExceptions = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0;
             if (arguments == null || arguments.Length == 0)
@@ -476,7 +476,7 @@ namespace System.Reflection
 
         [DebuggerStepThroughAttribute]
         [Diagnostics.DebuggerHidden]
-        private object[]? InvokeArgumentsCheck(object? obj, BindingFlags invokeAttr, Binder binder, object?[]? parameters, CultureInfo? culture)
+        private object[]? InvokeArgumentsCheck(object? obj, BindingFlags invokeAttr, Binder? binder, object?[]? parameters, CultureInfo? culture)
         {
             Signature sig = Signature;
 
@@ -507,17 +507,18 @@ namespace System.Reflection
         #endregion
 
         #region MethodInfo Overrides
-        public override Type? ReturnType
+
+#pragma warning disable CS8608 // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/23268
+        public override Type ReturnType
         {
             get { return Signature.ReturnType; }
         }
 
-        public override ICustomAttributeProvider? ReturnTypeCustomAttributes
+        public override ICustomAttributeProvider ReturnTypeCustomAttributes
         {
             get { return ReturnParameter; }
         }
 
-#pragma warning disable CS8608 // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/23268
         public override ParameterInfo ReturnParameter
         {
             get
index 500e623..a2e03c5 100644 (file)
@@ -401,7 +401,7 @@ namespace System.Reflection
         #region ICustomAttributeProvider Members
         public override object[] GetCustomAttributes(bool inherit)
         {
-            return CustomAttribute.GetCustomAttributes(this, (RuntimeType)typeof(object));
+            return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
index 34d78a0..517b63c 100644 (file)
@@ -329,7 +329,7 @@ namespace System.Reflection
                             CustomAttributeData.GetCustomAttributes(this), typeof(DateTimeConstantAttribute), 0);
 
                     if (value.ArgumentType != null)
-                        return new DateTime((long)value.Value!); // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
+                        return new DateTime((long)value.Value!);
                 }
                 else
                 {
@@ -405,7 +405,7 @@ namespace System.Reflection
                 {
                     // This is not possible because Decimal cannot be represented directly in the metadata.
                     Debug.Fail("Decimal cannot be represented directly in the metadata.");
-                    return (decimal)namedArgument.TypedValue.Value!; // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
+                    return (decimal)namedArgument.TypedValue.Value!;
                 }
             }
 
@@ -418,22 +418,22 @@ namespace System.Reflection
             if (parameters[2].ParameterType == typeof(uint))
             {
                 // DecimalConstantAttribute(byte scale, byte sign, uint hi, uint mid, uint low)
-                int low = (int)(uint)args[4].Value!; // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
-                int mid = (int)(uint)args[3].Value!; // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
-                int hi = (int)(uint)args[2].Value!;  // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
-                byte sign = (byte)args[1].Value!;    // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
-                byte scale = (byte)args[0].Value!;   // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
+                int low = (int)(uint)args[4].Value!;
+                int mid = (int)(uint)args[3].Value!;
+                int hi = (int)(uint)args[2].Value!;
+                byte sign = (byte)args[1].Value!;
+                byte scale = (byte)args[0].Value!;
 
                 return new System.Decimal(low, mid, hi, (sign != 0), scale);
             }
             else
             {
                 // DecimalConstantAttribute(byte scale, byte sign, int hi, int mid, int low)
-                int low = (int)args[4].Value!;     // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
-                int mid = (int)args[3].Value!;     // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
-                int hi = (int)args[2].Value!;      // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
-                byte sign = (byte)args[1].Value!;  // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
-                byte scale = (byte)args[0].Value!; // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
+                int low = (int)args[4].Value!;
+                int mid = (int)args[3].Value!;
+                int hi = (int)args[2].Value!;
+                byte sign = (byte)args[1].Value!;
+                byte scale = (byte)args[0].Value!;
 
                 return new System.Decimal(low, mid, hi, (sign != 0), scale);
             }
@@ -448,12 +448,12 @@ namespace System.Reflection
             {
                 if (namedArgument.MemberInfo.Name.Equals("Value"))
                 {
-                    return new DateTime((long)namedArgument.TypedValue.Value!); // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
+                    return new DateTime((long)namedArgument.TypedValue.Value!);
                 }
             }
 
             // Look at the ctor argument if the "Value" property was not explicitly defined.
-            return new DateTime((long)attr.ConstructorArguments[0].Value!); // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34976
+            return new DateTime((long)attr.ConstructorArguments[0].Value!);
         }
 
         private static object? GetRawConstant(CustomAttributeData attr)
@@ -511,7 +511,7 @@ namespace System.Reflection
             if (MdToken.IsNullToken(m_tkParamDef))
                 return Array.Empty<object>();
 
-            return CustomAttribute.GetCustomAttributes(this, (RuntimeType)typeof(object));
+            return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
index 0abe93f..26b3fdc 100644 (file)
@@ -144,7 +144,7 @@ namespace System.Reflection
         #region ICustomAttributeProvider
         public override object[] GetCustomAttributes(bool inherit)
         {
-            return CustomAttribute.GetCustomAttributes(this, (RuntimeType)typeof(object));
+            return CustomAttribute.GetCustomAttributes(this, (typeof(object) as RuntimeType)!);
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
index 885c84f..b563ea6 100644 (file)
@@ -1764,9 +1764,9 @@ namespace System
                     // Without this the reflectedType.Cache.GetMethod call below may return a MethodInfo
                     // object whose ReflectedType is string[] and DeclaringType is object[]. That would
                     // be (arguabally) incorrect because string[] is not a subclass of object[].
-                    MethodBase[] methodBases = (MethodBase[])reflectedType.GetMember(
+                    MethodBase[] methodBases = (reflectedType.GetMember(
                         RuntimeMethodHandle.GetName(methodHandle), MemberTypes.Constructor | MemberTypes.Method,
-                        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
+                        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) as MethodBase[])!;
 
                     bool loaderAssuredCompatible = false;
                     for (int i = 0; i < methodBases.Length; i++)
@@ -1787,7 +1787,7 @@ namespace System
                     // ignoring instantiation is the ReflectedType a subtype of the DeclaringType
                     RuntimeType declaringDefinition = (RuntimeType)declaredType.GetGenericTypeDefinition();
 
-                    RuntimeType baseType = reflectedType;
+                    RuntimeType? baseType = reflectedType;
 
                     while (baseType != null)
                     {
@@ -1799,7 +1799,7 @@ namespace System
                         if (baseDefinition == declaringDefinition)
                             break;
 
-                        baseType = baseType.GetBaseType()!;
+                        baseType = baseType.GetBaseType();
                     }
 
                     if (baseType == null)
@@ -2664,23 +2664,23 @@ namespace System
                 throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(ifaceType));
 
             RuntimeTypeHandle ifaceRtTypeHandle = ifaceRtType.GetTypeHandleInternal();
-            GetTypeHandleInternal().VerifyInterfaceIsImplemented(ifaceRtTypeHandle);
 
-                Debug.Assert(ifaceType.IsInterface);  // VerifyInterfaceIsImplemented enforces this invariant
-                Debug.Assert(!IsInterface); // VerifyInterfaceIsImplemented enforces this invariant
+            GetTypeHandleInternal().VerifyInterfaceIsImplemented(ifaceRtTypeHandle);
+            Debug.Assert(ifaceType.IsInterface);  // VerifyInterfaceIsImplemented enforces this invariant
+            Debug.Assert(!IsInterface); // VerifyInterfaceIsImplemented enforces this invariant
 
-                // SZArrays implement the methods on IList`1, IEnumerable`1, and ICollection`1 with
-                // SZArrayHelper and some runtime magic. We don't have accurate interface maps for them.
-                if (IsSZArray && ifaceType.IsGenericType)
-                    throw new ArgumentException(SR.Argument_ArrayGetInterfaceMap);
+            // SZArrays implement the methods on IList`1, IEnumerable`1, and ICollection`1 with
+            // SZArrayHelper and some runtime magic. We don't have accurate interface maps for them.
+            if (IsSZArray && ifaceType.IsGenericType)
+                throw new ArgumentException(SR.Argument_ArrayGetInterfaceMap);
 
-                int ifaceInstanceMethodCount = RuntimeTypeHandle.GetNumVirtuals(ifaceRtType);
+            int ifaceInstanceMethodCount = RuntimeTypeHandle.GetNumVirtuals(ifaceRtType);
 
-                InterfaceMapping im;
-                im.InterfaceType = ifaceType;
-                im.TargetType = this;
-                im.InterfaceMethods = new MethodInfo[ifaceInstanceMethodCount];
-                im.TargetMethods = new MethodInfo[ifaceInstanceMethodCount];
+            InterfaceMapping im;
+            im.InterfaceType = ifaceType;
+            im.TargetType = this;
+            im.InterfaceMethods = new MethodInfo[ifaceInstanceMethodCount];
+            im.TargetMethods = new MethodInfo[ifaceInstanceMethodCount];
 
             for (int i = 0; i < ifaceInstanceMethodCount; i++)
             {
@@ -2703,11 +2703,12 @@ namespace System
                     reflectedType = this;
 
                 // GetMethodBase will convert this to the instantiating/unboxing stub if necessary
-                MethodBase rtTypeMethodBase = GetMethodBase(reflectedType, classRtMethodHandle)!;
+                MethodBase? rtTypeMethodBase = GetMethodBase(reflectedType, classRtMethodHandle);
                 // a class may not implement all the methods of an interface (abstract class) so null is a valid value 
                 Debug.Assert(rtTypeMethodBase is null || rtTypeMethodBase is RuntimeMethodInfo);
                 im.TargetMethods[i] = (MethodInfo)rtTypeMethodBase!;
             }
+
             return im;           
         }
         #endregion
@@ -3153,7 +3154,6 @@ namespace System
         {
             if (type is null)
                 throw new ArgumentNullException(nameof(type));
-
             RuntimeType? rtType = type as RuntimeType;
             if (rtType == null)
                 return false;
@@ -4042,7 +4042,7 @@ namespace System
                         if (argCnt != 1)
                             throw new ArgumentException(SR.Arg_FldSetArgErr, nameof(bindingFlags));
 
-                        selFld.SetValue(target!, providedArgs![0], bindingFlags, binder, culture);
+                        selFld.SetValue(target, providedArgs![0], bindingFlags, binder, culture);
                         return null;
                     }
                 }
@@ -4081,7 +4081,7 @@ namespace System
             if ((bindingFlags & BindingFlags.InvokeMethod) != 0)
             {
                 // Lookup Methods
-                MethodInfo[] semiFinalists = (MethodInfo[])GetMember(name, MemberTypes.Method, bindingFlags);
+                MethodInfo[] semiFinalists = (GetMember(name, MemberTypes.Method, bindingFlags) as MethodInfo[])!;
                 List<MethodInfo>? results = null;
 
                 for (int i = 0; i < semiFinalists.Length; i++)
@@ -4121,7 +4121,7 @@ namespace System
             if (finalist == null && isGetProperty || isSetProperty)
             {
                 // Lookup Property
-                PropertyInfo[] semiFinalists = (PropertyInfo[])GetMember(name, MemberTypes.Property, bindingFlags);
+                PropertyInfo[] semiFinalists = (GetMember(name, MemberTypes.Property, bindingFlags) as PropertyInfo[])!;
                 List<MethodInfo>? results = null;
 
                 for (int i = 0; i < semiFinalists.Length; i++)
index 22a64c9..91c58bf 100644 (file)
@@ -3408,7 +3408,6 @@ namespace System.Diagnostics.Tracing
                         bool hasRelatedActivityID = RemoveFirstArgIfRelatedActivityId(ref args);
                         if (!(source != null && source.SelfDescribingEvents))
                         {
-                            Debug.Assert(eventData != null);
                             manifest.StartEvent(eventName, eventAttribute);
                             for (int fieldIdx = 0; fieldIdx < args.Length; fieldIdx++)
                             {
index b54e707..aac6a85 100644 (file)
@@ -141,7 +141,7 @@ namespace System.Reflection
 
         public override string ToString() => ScopeName;
 
-        public static readonly TypeFilter FilterTypeName = (m, c) => FilterTypeNameImpl(m, c, StringComparison.Ordinal); // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/23268
+        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;