From e2099f62f1ee28241f857edaf0ef7420018d11d8 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 23 Nov 2020 15:48:27 -0500 Subject: [PATCH] Use Type.EmptyTypes consistently (#45112) We currently have several hundred uses of `Array.Empty()` and several hundred uses of `Type.EmptyTypes`. This just changes the repo to use the latter consistently. --- .../src/System/Attribute.CoreCLR.cs | 2 +- .../System/Reflection/Emit/MethodBuilder.cs | 6 +- .../System/Reflection/Emit/SymbolMethod.cs | 2 +- .../src/System/Reflection/Emit/TypeBuilder.cs | 4 +- .../src/System/Reflection/MdFieldInfo.cs | 4 +- .../System/Reflection/RuntimeMethodInfo.cs | 2 +- .../src/System/RuntimeType.CoreCLR.cs | 4 +- .../JitTraceRuntime.cs | 2 +- .../RuntimeBinder/CSharpInvokeBinder.cs | 2 +- .../CSharpInvokeConstructorBinder.cs | 2 +- .../RuntimeBinder/RuntimeBinderExtensions.cs | 2 +- .../TrimmingTests/ActivatorUtilitiesTests.cs | 2 +- .../ComponentModel/AttributeCollection.cs | 2 +- .../src/System/ComponentModel/BindingList.cs | 2 +- .../ReflectPropertyDescriptor.cs | 12 +- .../ReflectTypeDescriptionProvider.cs | 2 +- .../Convention/PartConventionBuilder.cs | 2 +- .../Compiler/LambdaCompiler.Expressions.cs | 2 +- .../Expressions/Interpreter/LightCompiler.cs | 2 +- .../DelegateType/DelegateCreationTests.cs | 2 +- .../ExceptionHandlingExpressions.cs | 6 +- .../src/System/Reflection/ParameterInfo.cs | 4 +- .../src/System/Reflection/PropertyInfo.cs | 4 +- .../SignatureGenericParameterType.cs | 4 +- .../Reflection/SignatureHasElementType.cs | 4 +- .../System.Private.CoreLib/src/System/Type.cs | 2 +- .../Serialization/ClassDataContract.cs | 4 +- .../Runtime/Serialization/CodeGenerator.cs | 2 +- .../Serialization/CollectionDataContract.cs | 6 +- .../Runtime/Serialization/DataContract.cs | 2 +- .../Serialization/DataContractSerializer.cs | 2 +- .../Json/DataContractJsonSerializer.cs | 4 +- .../Json/JsonFormatGeneratorStatics.cs | 6 +- .../Json/JsonFormatReaderGenerator.cs | 4 +- .../Json/JsonFormatWriterGenerator.cs | 4 +- .../Serialization/ReflectionClassWriter.cs | 2 +- .../Runtime/Serialization/ReflectionReader.cs | 2 +- .../Runtime/Serialization/XmlDataContract.cs | 2 +- .../XmlFormatGeneratorStatics.cs | 10 +- .../Serialization/XmlFormatReaderGenerator.cs | 2 +- .../Serialization/XmlFormatWriterGenerator.cs | 4 +- .../System/Xml/Serialization/CodeGenerator.cs | 2 +- .../Xml/Serialization/CodeIdentifier.cs | 2 +- .../src/System/Xml/Serialization/Models.cs | 2 +- .../System/Xml/Serialization/SourceInfo.cs | 2 +- .../src/System/Xml/Serialization/Types.cs | 6 +- .../Serialization/XmlSerializationILGen.cs | 36 ++-- .../XmlSerializationReaderILGen.cs | 192 +++++++++--------- .../XmlSerializationWriterILGen.cs | 66 +++--- .../System/Xml/Serialization/XmlSerializer.cs | 4 +- .../Xml/Serialization/XmlSerializerFactory.cs | 4 +- .../System/Xml/Xsl/IlGen/GenerateHelper.cs | 2 +- .../src/System/Xml/Xsl/XmlIlGenerator.cs | 6 +- .../tests/DispatchProxyTests.cs | 2 +- .../MethodBuilderGetGenericArguments.cs | 2 +- .../tests/RuntimeReflectionExtensionTests.cs | 2 +- .../TypeLoading/Modules/RoResourceModule.cs | 2 +- .../tests/src/TestUtils/NetStandardBridge.cs | 2 +- .../tests/src/Tests/Type/TypeInvariants.cs | 2 +- .../Reflection/BindingFlagsDoNotWrap.cs | 6 +- .../Security/Cryptography/XmlKeyHelper.cs | 2 +- .../tests/CryptoConfigTests.cs | 2 +- .../System/Reflection/Emit/DynamicMethod.cs | 2 +- .../src/System/RuntimeType.Mono.cs | 6 +- src/tests/JIT/Stress/ABI/Stubs.cs | 2 +- 65 files changed, 248 insertions(+), 248 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs index e7ca19e8076e3..a9505dc646664 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Attribute.CoreCLR.cs @@ -377,7 +377,7 @@ private static Type[] GetIndexParameterTypes(PropertyInfo element) return indexParamTypes; } - return Array.Empty(); + return Type.EmptyTypes; } private static void AddAttributesToList(List attributeList, Attribute[] attributes, Dictionary types) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs index e99c584074c1f..0807751b2999b 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs @@ -268,7 +268,7 @@ internal void ReleaseBakedStructures() m_exceptions = null; } - internal override Type[] GetParameterTypes() => m_parameterTypes ??= Array.Empty(); + internal override Type[] GetParameterTypes() => m_parameterTypes ??= Type.EmptyTypes; internal static Type? GetMethodBaseReturnType(MethodBase? method) { @@ -306,7 +306,7 @@ internal void SetToken(int token) internal SignatureHelper GetMethodSignature() { - m_parameterTypes ??= Array.Empty(); + m_parameterTypes ??= Type.EmptyTypes; m_signature = SignatureHelper.GetMethodSigHelper(m_module, m_callingConvention, m_inst != null ? m_inst.Length : 0, m_returnType, m_returnTypeRequiredCustomModifiers, m_returnTypeOptionalCustomModifiers, @@ -538,7 +538,7 @@ public override bool IsDefined(Type attributeType, bool inherit) public override bool IsGenericMethod => m_inst != null; - public override Type[] GetGenericArguments() => m_inst ?? Array.Empty(); + public override Type[] GetGenericArguments() => m_inst ?? Type.EmptyTypes; public override MethodInfo MakeGenericMethod(params Type[] typeArguments) { diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs index 9e9aab8fcac4b..10ae4bca5f7dc 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs @@ -39,7 +39,7 @@ internal SymbolMethod(ModuleBuilder mod, int token, Type arrayClass, string meth } else { - m_parameterTypes = Array.Empty(); + m_parameterTypes = Type.EmptyTypes; } m_module = mod; diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs index d485dc69c1cc4..d87985db96d3c 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs @@ -846,7 +846,7 @@ public override Type[] GetInterfaces() if (m_typeInterfaces == null) { - return Array.Empty(); + return Type.EmptyTypes; } return m_typeInterfaces.ToArray(); @@ -1188,7 +1188,7 @@ public override Type MakeGenericType(params Type[] typeArguments) return TypeBuilderInstantiation.MakeGenericType(this, typeArguments); } - public override Type[] GetGenericArguments() => m_inst ?? Array.Empty(); + public override Type[] GetGenericArguments() => m_inst ?? Type.EmptyTypes; // If a TypeBuilder is generic, it must be a generic type definition // All instantiated generic types are TypeBuilderInstantiation. diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs index e4d240d598ba9..7d5a8f9f64cc7 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs @@ -113,12 +113,12 @@ public override Type FieldType public override Type[] GetRequiredCustomModifiers() { - return Array.Empty(); + return Type.EmptyTypes; } public override Type[] GetOptionalCustomModifiers() { - return Array.Empty(); + return Type.EmptyTypes; } #endregion diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs index 9dfffd64a2e2c..e0d87e7821d8e 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs @@ -579,7 +579,7 @@ internal RuntimeType[] GetGenericArgumentsInternal() => RuntimeMethodHandle.GetMethodInstantiationInternal(this); public override Type[] GetGenericArguments() => - RuntimeMethodHandle.GetMethodInstantiationPublic(this) ?? Array.Empty(); + RuntimeMethodHandle.GetMethodInstantiationPublic(this) ?? Type.EmptyTypes; public override MethodInfo GetGenericMethodDefinition() { diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs index f76df3efa4915..0c1ba940fc7e9 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs @@ -3230,7 +3230,7 @@ internal RuntimeType[] GetGenericArgumentsInternal() public override Type[] GetGenericArguments() { Type[] types = GetRootElementType().GetTypeHandleInternal().GetInstantiationPublic(); - return types ?? Array.Empty(); + return types ?? Type.EmptyTypes; } public override Type MakeGenericType(Type[] instantiation) @@ -3315,7 +3315,7 @@ public override Type[] GetGenericParameterConstraints() throw new InvalidOperationException(SR.Arg_NotGenericParameter); Type[] constraints = new RuntimeTypeHandle(this).GetConstraints(); - return constraints ?? Array.Empty(); + return constraints ?? Type.EmptyTypes; } #endregion diff --git a/src/coreclr/src/tools/dotnet-pgo/Microsoft.Diagnostics.JitTrace/JitTraceRuntime.cs b/src/coreclr/src/tools/dotnet-pgo/Microsoft.Diagnostics.JitTrace/JitTraceRuntime.cs index 68a0febb281d4..d817bd437b44a 100644 --- a/src/coreclr/src/tools/dotnet-pgo/Microsoft.Diagnostics.JitTrace/JitTraceRuntime.cs +++ b/src/coreclr/src/tools/dotnet-pgo/Microsoft.Diagnostics.JitTrace/JitTraceRuntime.cs @@ -120,7 +120,7 @@ public static void Prepare(StreamReader jittraceStream, out int successfulPrepar int signatureLen = int.Parse(methodStrComponents[2]); string[] methodInstantiationArgComponents = SplitAndUnescape(methodStrComponents[3], innerCsvEscapeChar, innerCsvEscapeCharArray); int genericMethodArgCount = int.Parse(methodInstantiationArgComponents[0]); - Type[] methodArgs = genericMethodArgCount != 0 ? new Type[genericMethodArgCount] : Array.Empty(); + Type[] methodArgs = genericMethodArgCount != 0 ? new Type[genericMethodArgCount] : Type.EmptyTypes; bool abortMethodDiscovery = false; for (int iMethodArg = 0; iMethodArg < genericMethodArgCount; iMethodArg++) { diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeBinder.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeBinder.cs index b4314c6c6c597..dd25a30c4dbcd 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeBinder.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeBinder.cs @@ -30,7 +30,7 @@ public void PopulateSymbolTableWithName(Type callingType, ArgumentObject[] argum string ICSharpBinder.Name => "Invoke"; - Type[] ICSharpInvokeOrInvokeMemberBinder.TypeArguments => Array.Empty(); + Type[] ICSharpInvokeOrInvokeMemberBinder.TypeArguments => Type.EmptyTypes; CSharpCallFlags ICSharpInvokeOrInvokeMemberBinder.Flags => _flags; diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeConstructorBinder.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeConstructorBinder.cs index 3f991ba9d839c..f4c1d1cacc918 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeConstructorBinder.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeConstructorBinder.cs @@ -29,7 +29,7 @@ public void PopulateSymbolTableWithName(Type callingType, ArgumentObject[] argum public bool StaticCall => true; - public Type[] TypeArguments => Array.Empty(); + public Type[] TypeArguments => Type.EmptyTypes; public string Name => ".ctor"; diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderExtensions.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderExtensions.cs index c2e01a3e58d6f..1323e2c24bb29 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderExtensions.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinderExtensions.cs @@ -276,7 +276,7 @@ private static bool IsTypeParameterEquivalentToTypeInst(this Type typeParam, Typ } // See if MetadataToken property is available. - PropertyInfo property = memberInfo.GetProperty("MetadataToken", typeof(int), Array.Empty()); + PropertyInfo property = memberInfo.GetProperty("MetadataToken", typeof(int), Type.EmptyTypes); if (property is not null && property.CanRead) { diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/TrimmingTests/ActivatorUtilitiesTests.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/TrimmingTests/ActivatorUtilitiesTests.cs index 2a3e22724e26f..f62dd89545af5 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/TrimmingTests/ActivatorUtilitiesTests.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/TrimmingTests/ActivatorUtilitiesTests.cs @@ -10,7 +10,7 @@ static int Main(string[] args) { ServiceProvider provider = new ServiceCollection().BuildServiceProvider(); - ObjectFactory factory = ActivatorUtilities.CreateFactory(typeof(ServiceA), Array.Empty()); + ObjectFactory factory = ActivatorUtilities.CreateFactory(typeof(ServiceA), Type.EmptyTypes); ServiceA serviceA = factory(provider, null) as ServiceA; ServiceB serviceB = ActivatorUtilities.CreateInstance(provider, typeof(ServiceB)) as ServiceB; ServiceC serviceC = ActivatorUtilities.CreateInstance(provider); diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs index 49b1c4f9d5127..cc18c601d0eb6 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs @@ -285,7 +285,7 @@ protected Attribute GetDefaultAttribute(Type attributeType) } else { - ConstructorInfo ci = reflect.UnderlyingSystemType.GetConstructor(Array.Empty()); + ConstructorInfo ci = reflect.UnderlyingSystemType.GetConstructor(Type.EmptyTypes); if (ci != null) { attr = (Attribute)ci.Invoke(Array.Empty()); diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs index 7e13fec0e86e2..de3d0e2f80afb 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs @@ -81,7 +81,7 @@ private bool ItemTypeHasDefaultConstructor } const BindingFlags BindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance; - return itemType.GetConstructor(BindingFlags, null, Array.Empty(), null) != null; + return itemType.GetConstructor(BindingFlags, null, Type.EmptyTypes, null) != null; } } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs index 1b55a0f17e943..975804a488169 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs @@ -298,7 +298,7 @@ private MethodInfo GetMethodValue if (_propInfo == null) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty; - _propInfo = _componentClass.GetProperty(Name, bindingFlags, binder: null, PropertyType, Array.Empty(), Array.Empty()); + _propInfo = _componentClass.GetProperty(Name, bindingFlags, binder: null, PropertyType, Type.EmptyTypes, Array.Empty()); } if (_propInfo != null) { @@ -351,7 +351,7 @@ private MethodInfo ResetMethodValue if (_receiverType == null) { - args = Array.Empty(); + args = Type.EmptyTypes; } else { @@ -382,7 +382,7 @@ private MethodInfo SetMethodValue for (Type t = ComponentType.BaseType; t != null && t != typeof(object); t = t.BaseType) { BindingFlags bindingFlags = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance; - PropertyInfo p = t.GetProperty(name, bindingFlags, binder: null, PropertyType, Array.Empty(), null); + PropertyInfo p = t.GetProperty(name, bindingFlags, binder: null, PropertyType, Type.EmptyTypes, null); if (p != null) { _setMethod = p.GetSetMethod(nonPublic: false); @@ -403,7 +403,7 @@ private MethodInfo SetMethodValue if (_propInfo == null) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty; - _propInfo = _componentClass.GetProperty(Name, bindingFlags, binder: null, PropertyType, Array.Empty(), Array.Empty()); + _propInfo = _componentClass.GetProperty(Name, bindingFlags, binder: null, PropertyType, Type.EmptyTypes, Array.Empty()); } if (_propInfo != null) { @@ -435,7 +435,7 @@ private MethodInfo ShouldSerializeMethodValue if (_receiverType == null) { - args = Array.Empty(); + args = Type.EmptyTypes; } else { @@ -767,7 +767,7 @@ protected override void FillAttributes(IList attributes) } else { - memberInfo = currentReflectType.GetProperty(Name, bindingFlags, binder: null, PropertyType, Array.Empty(), Array.Empty()); + memberInfo = currentReflectType.GetProperty(Name, bindingFlags, binder: null, PropertyType, Type.EmptyTypes, Array.Empty()); } // Get custom attributes for the member info. diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs index ff4cd113da6f0..d8de50a61aeec 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs @@ -247,7 +247,7 @@ public override object CreateInstance(IServiceProvider provider, Type objectType } else { - argTypes = Array.Empty(); + argTypes = Type.EmptyTypes; } obj = objectType.GetConstructor(argTypes)?.Invoke(args); diff --git a/src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilder.cs b/src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilder.cs index 0ae9618a77ab5..8fbfd3d51ec4e 100644 --- a/src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilder.cs +++ b/src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilder.cs @@ -13,7 +13,7 @@ namespace System.Composition.Convention /// public class PartConventionBuilder { - private readonly Type[] _emptyTypeArray = Array.Empty(); + private readonly Type[] _emptyTypeArray = Type.EmptyTypes; private static List s_onImportsSatisfiedAttributeList; private static readonly List s_importingConstructorList = new List() { new ImportingConstructorAttribute() }; private static readonly Type s_exportAttributeType = typeof(ExportAttribute); diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Expressions.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Expressions.cs index aab1e749747cc..ce0cb7eb03275 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Expressions.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Expressions.cs @@ -183,7 +183,7 @@ private void EmitInvocationExpression(Expression expr, CompilationFlags flags) if (typeof(LambdaExpression).IsAssignableFrom(expr.Type)) { // if the invoke target is a lambda expression tree, first compile it into a delegate - expr = Expression.Call(expr, expr.Type.GetMethod("Compile", Array.Empty())!); + expr = Expression.Call(expr, expr.Type.GetMethod("Compile", Type.EmptyTypes)!); } EmitMethodCall(expr, expr.Type.GetInvokeMethod(), node, CompilationFlags.EmitAsNoTail | CompilationFlags.EmitExpressionStart); diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs index 534a3f7369887..6f9f915169e4d 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs @@ -2671,7 +2671,7 @@ private void CompileInvocationExpression(Expression expr) if (typeof(LambdaExpression).IsAssignableFrom(node.Expression.Type)) { - MethodInfo compMethod = node.Expression.Type.GetMethod("Compile", Array.Empty())!; + MethodInfo compMethod = node.Expression.Type.GetMethod("Compile", Type.EmptyTypes)!; CompileMethodCallExpression( Expression.Call( node.Expression, diff --git a/src/libraries/System.Linq.Expressions/tests/DelegateType/DelegateCreationTests.cs b/src/libraries/System.Linq.Expressions/tests/DelegateType/DelegateCreationTests.cs index 264edef5ad3cb..9237cf4ee61d1 100644 --- a/src/libraries/System.Linq.Expressions/tests/DelegateType/DelegateCreationTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/DelegateType/DelegateCreationTests.cs @@ -41,7 +41,7 @@ public static IEnumerable ExcessiveLengthOpenGenericTypeArgs() public static IEnumerable EmptyTypeArgs() { - yield return new object[] { Array.Empty() }; + yield return new object[] { Type.EmptyTypes }; } public static IEnumerable ByRefTypeArgs() diff --git a/src/libraries/System.Linq.Expressions/tests/ExceptionHandling/ExceptionHandlingExpressions.cs b/src/libraries/System.Linq.Expressions/tests/ExceptionHandling/ExceptionHandlingExpressions.cs index dea5dfc3c092a..d9d1d951a4418 100644 --- a/src/libraries/System.Linq.Expressions/tests/ExceptionHandling/ExceptionHandlingExpressions.cs +++ b/src/libraries/System.Linq.Expressions/tests/ExceptionHandling/ExceptionHandlingExpressions.cs @@ -258,7 +258,7 @@ public void CatchFromExternallyThrownString(bool useInterpreter) ModuleBuilder module = assembly.DefineDynamicModule("Name"); TypeBuilder type = module.DefineType("Type"); MethodBuilder throwingMethod = type.DefineMethod( - "WillThrow", MethodAttributes.Public | MethodAttributes.Static, typeof(void), Array.Empty()); + "WillThrow", MethodAttributes.Public | MethodAttributes.Static, typeof(void), Type.EmptyTypes); ILGenerator ilGen = throwingMethod.GetILGenerator(); ilGen.Emit(OpCodes.Ldstr, "An Exceptional Exception!"); ilGen.Emit(OpCodes.Throw); @@ -887,7 +887,7 @@ public void FilterBeforeInnerFinally(bool useInterpreter) */ ConstantExpression builder = Expression.Constant(sb); - Type[] noTypes = Array.Empty(); + Type[] noTypes = Type.EmptyTypes; TryExpression tryExp = Expression.TryCatch( Expression.TryFinally( Expression.Block( @@ -911,7 +911,7 @@ public void FilterBeforeInnerFault(bool useInterpreter) { StringBuilder sb = new StringBuilder(); ConstantExpression builder = Expression.Constant(sb); - Type[] noTypes = Array.Empty(); + Type[] noTypes = Type.EmptyTypes; TryExpression tryExp = Expression.TryCatch( Expression.TryFault( Expression.Block( diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterInfo.cs index c9ec1cfb7dd25..bae3bdea9ff37 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterInfo.cs @@ -46,8 +46,8 @@ public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) return Array.Empty(); } - public virtual Type[] GetOptionalCustomModifiers() => Array.Empty(); - public virtual Type[] GetRequiredCustomModifiers() => Array.Empty(); + public virtual Type[] GetOptionalCustomModifiers() => Type.EmptyTypes; + public virtual Type[] GetRequiredCustomModifiers() => Type.EmptyTypes; public virtual int MetadataToken => MetadataToken_ParamDef; diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/PropertyInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/PropertyInfo.cs index c13ad761a0752..1208a88b6b3d8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/PropertyInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/PropertyInfo.cs @@ -33,8 +33,8 @@ protected PropertyInfo() { } public MethodInfo? GetSetMethod() => GetSetMethod(nonPublic: false); public abstract MethodInfo? GetSetMethod(bool nonPublic); - public virtual Type[] GetOptionalCustomModifiers() => Array.Empty(); - public virtual Type[] GetRequiredCustomModifiers() => Array.Empty(); + public virtual Type[] GetOptionalCustomModifiers() => Type.EmptyTypes; + public virtual Type[] GetRequiredCustomModifiers() => Type.EmptyTypes; [DebuggerHidden] [DebuggerStepThrough] diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureGenericParameterType.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureGenericParameterType.cs index dcc0fa88211cf..58662a655a49e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureGenericParameterType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureGenericParameterType.cs @@ -30,8 +30,8 @@ protected SignatureGenericParameterType(int position) internal sealed override SignatureType? ElementType => null; public sealed override int GetArrayRank() => throw new ArgumentException(SR.Argument_HasToBeArrayClass); public sealed override Type GetGenericTypeDefinition() => throw new InvalidOperationException(SR.InvalidOperation_NotGenericType); - public sealed override Type[] GetGenericArguments() => Array.Empty(); - public sealed override Type[] GenericTypeArguments => Array.Empty(); + public sealed override Type[] GetGenericArguments() => Type.EmptyTypes; + public sealed override Type[] GenericTypeArguments => Type.EmptyTypes; public sealed override int GenericParameterPosition => _position; public abstract override string Name { get; } public sealed override string? Namespace => null; diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureHasElementType.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureHasElementType.cs index 9c4d73d5b1890..4226d61270ad7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureHasElementType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/SignatureHasElementType.cs @@ -31,8 +31,8 @@ protected SignatureHasElementType(SignatureType elementType) internal sealed override SignatureType? ElementType => _elementType; public abstract override int GetArrayRank(); public sealed override Type GetGenericTypeDefinition() => throw new InvalidOperationException(SR.InvalidOperation_NotGenericType); - public sealed override Type[] GetGenericArguments() => Array.Empty(); - public sealed override Type[] GenericTypeArguments => Array.Empty(); + public sealed override Type[] GetGenericArguments() => Type.EmptyTypes; + public sealed override Type[] GenericTypeArguments => Type.EmptyTypes; public sealed override int GenericParameterPosition => throw new InvalidOperationException(SR.Arg_NotGenericParameter); public sealed override string Name => _elementType.Name + Suffix; public sealed override string? Namespace => _elementType.Namespace; diff --git a/src/libraries/System.Private.CoreLib/src/System/Type.cs b/src/libraries/System.Private.CoreLib/src/System/Type.cs index fe4f1710657b2..9f6d3cbe595ba 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Type.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Type.cs @@ -60,7 +60,7 @@ protected Type() { } public virtual int GetArrayRank() => throw new NotSupportedException(SR.NotSupported_SubclassOverride); public virtual Type GetGenericTypeDefinition() => throw new NotSupportedException(SR.NotSupported_SubclassOverride); - public virtual Type[] GenericTypeArguments => (IsGenericType && !IsGenericTypeDefinition) ? GetGenericArguments() : Array.Empty(); + public virtual Type[] GenericTypeArguments => (IsGenericType && !IsGenericTypeDefinition) ? GetGenericArguments() : Type.EmptyTypes; public virtual Type[] GetGenericArguments() => throw new NotSupportedException(SR.NotSupported_SubclassOverride); public virtual int GenericParameterPosition => throw new InvalidOperationException(SR.Arg_NotGenericParameter); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ClassDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ClassDataContract.cs index db5869fde713e..36f35e3177d8d 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ClassDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ClassDataContract.cs @@ -388,7 +388,7 @@ internal static bool IsNonAttributedTypeValidForSerialization(Type type) else { return (type.IsVisible && - type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, Array.Empty()) != null); + type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, Type.EmptyTypes) != null); } } @@ -1425,7 +1425,7 @@ internal MethodInfo? GetKeyValuePairMethodInfo if (type.IsValueType) return null; - ConstructorInfo? ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, Array.Empty()); + ConstructorInfo? ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, Type.EmptyTypes); if (ctor == null) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.NonAttributedSerializableTypesMustHaveDefaultConstructor, DataContract.GetClrTypeFullName(type)))); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CodeGenerator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CodeGenerator.cs index 132a76b6da6a2..3362c7a7bf550 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CodeGenerator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CodeGenerator.cs @@ -66,7 +66,7 @@ private static MethodInfo ObjectToString { if (s_objectToString == null) { - s_objectToString = typeof(object).GetMethod("ToString", Array.Empty()); + s_objectToString = typeof(object).GetMethod("ToString", Type.EmptyTypes); Debug.Assert(s_objectToString != null); } return s_objectToString; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs index 55945694336f5..66e671cfaeb6c 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs @@ -883,7 +883,7 @@ internal Type GetCollectionElementType() enumeratorType = GetEnumeratorMethod.ReturnType; } - MethodInfo? getCurrentMethod = enumeratorType.GetMethod(Globals.GetCurrentMethodName, BindingFlags.Instance | BindingFlags.Public, Array.Empty()); + MethodInfo? getCurrentMethod = enumeratorType.GetMethod(Globals.GetCurrentMethodName, BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes); if (getCurrentMethod == null) { if (enumeratorType.IsInterface) @@ -1145,7 +1145,7 @@ private static bool IsCollectionOrTryCreate(Type type, bool tryCreate, out DataC ConstructorInfo? defaultCtor = null; if (!type.IsValueType) { - defaultCtor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Array.Empty()); + defaultCtor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.EmptyTypes); if (defaultCtor == null && constructorRequired) { // All collection types could be considered read-only collections except collection types that are marked [Serializable]. @@ -1364,7 +1364,7 @@ private static void GetCollectionMethods(Type type, Type interfaceType, Type[] a if (getEnumeratorMethod == null) { - getEnumeratorMethod = type.GetMethod(Globals.GetEnumeratorMethodName, BindingFlags.Instance | BindingFlags.Public, Array.Empty()); + getEnumeratorMethod = type.GetMethod(Globals.GetEnumeratorMethodName, BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes); if (getEnumeratorMethod == null || !Globals.TypeOfIEnumerator.IsAssignableFrom(getEnumeratorMethod.ReturnType)) { Type? ienumerableInterface = interfaceType.GetInterfaces().Where(t => t.FullName!.StartsWith("System.Collections.Generic.IEnumerable")).FirstOrDefault(); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs index 8e1f6bc4f1d0a..008658e6aad03 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs @@ -1979,7 +1979,7 @@ private static void ImportKnownTypeAttributes(Type? type, Dictionary if (methodName.Length == 0) DataContract.ThrowInvalidDataContractException(SR.Format(SR.KnownTypeAttributeEmptyString, DataContract.GetClrTypeFullName(type)), type); - MethodInfo? method = type.GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, Array.Empty()); + MethodInfo? method = type.GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, Type.EmptyTypes); if (method == null) DataContract.ThrowInvalidDataContractException(SR.Format(SR.KnownTypeAttributeUnknownMethod, methodName, DataContract.GetClrTypeFullName(type)), type); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs index 53a1840c9cdc1..30ae159058ff2 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs @@ -162,7 +162,7 @@ public ReadOnlyCollection KnownTypes } else { - _knownTypeCollection = new ReadOnlyCollection(Array.Empty()); + _knownTypeCollection = new ReadOnlyCollection(Type.EmptyTypes); } } return _knownTypeCollection; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/DataContractJsonSerializer.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/DataContractJsonSerializer.cs index 604040e59e8db..ebf49e42ac6eb 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/DataContractJsonSerializer.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/DataContractJsonSerializer.cs @@ -92,7 +92,7 @@ public ReadOnlyCollection KnownTypes } else { - _knownTypeCollection = new ReadOnlyCollection(Array.Empty()); + _knownTypeCollection = new ReadOnlyCollection(Type.EmptyTypes); } } return _knownTypeCollection; @@ -547,7 +547,7 @@ public ReadOnlyCollection KnownTypes } else { - _knownTypeCollection = new ReadOnlyCollection(Array.Empty()); + _knownTypeCollection = new ReadOnlyCollection(Type.EmptyTypes); } } return _knownTypeCollection; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatGeneratorStatics.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatGeneratorStatics.cs index 6020b107db6b9..ea6c9f016b29b 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatGeneratorStatics.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatGeneratorStatics.cs @@ -96,7 +96,7 @@ public static PropertyInfo CollectionItemNameProperty public static ConstructorInfo ExtensionDataObjectCtor => s_extensionDataObjectCtor ?? (s_extensionDataObjectCtor = - typeof(ExtensionDataObject).GetConstructor(Globals.ScanAllMembers, Array.Empty()))!; + typeof(ExtensionDataObject).GetConstructor(Globals.ScanAllMembers, Type.EmptyTypes))!; public static PropertyInfo ExtensionDataProperty => s_extensionDataProperty ?? (s_extensionDataProperty = typeof(IExtensibleDataObject).GetProperty("ExtensionData")!); @@ -180,7 +180,7 @@ public static MethodInfo IsStartElementMethod0 { if (s_isStartElementMethod0 == null) { - s_isStartElementMethod0 = typeof(XmlReaderDelegator).GetMethod("IsStartElement", Globals.ScanAllMembers, Array.Empty()); + s_isStartElementMethod0 = typeof(XmlReaderDelegator).GetMethod("IsStartElement", Globals.ScanAllMembers, Type.EmptyTypes); Debug.Assert(s_isStartElementMethod0 != null); } return s_isStartElementMethod0; @@ -383,7 +383,7 @@ public static MethodInfo WriteEndElementMethod { if (s_writeEndElementMethod == null) { - s_writeEndElementMethod = typeof(XmlWriterDelegator).GetMethod("WriteEndElement", Globals.ScanAllMembers, Array.Empty()); + s_writeEndElementMethod = typeof(XmlWriterDelegator).GetMethod("WriteEndElement", Globals.ScanAllMembers, Type.EmptyTypes); Debug.Assert(s_writeEndElementMethod != null); } return s_writeEndElementMethod; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatReaderGenerator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatReaderGenerator.cs index 79bfe7bbf9a39..47bd84821c9e3 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatReaderGenerator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatReaderGenerator.cs @@ -573,11 +573,11 @@ private void ReadCollection(CollectionDataContract collectionContract) { case CollectionKind.GenericDictionary: type = Globals.TypeOfDictionaryGeneric.MakeGenericType(itemType.GetGenericArguments()); - constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Array.Empty())!; + constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.EmptyTypes)!; break; case CollectionKind.Dictionary: type = Globals.TypeOfHashtable; - constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Array.Empty())!; + constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.EmptyTypes)!; break; case CollectionKind.Collection: case CollectionKind.GenericCollection: diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs index c219893b3d78a..5248b9420c304 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs @@ -346,8 +346,8 @@ private void WriteCollection(CollectionDataContract collectionContract) { enumeratorType = collectionContract.GetEnumeratorMethod.ReturnType; } - MethodInfo? moveNextMethod = enumeratorType.GetMethod(Globals.MoveNextMethodName, BindingFlags.Instance | BindingFlags.Public, Array.Empty()); - MethodInfo? getCurrentMethod = enumeratorType.GetMethod(Globals.GetCurrentMethodName, BindingFlags.Instance | BindingFlags.Public, Array.Empty()); + MethodInfo? moveNextMethod = enumeratorType.GetMethod(Globals.MoveNextMethodName, BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes); + MethodInfo? getCurrentMethod = enumeratorType.GetMethod(Globals.GetCurrentMethodName, BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes); if (moveNextMethod == null || getCurrentMethod == null) { if (enumeratorType.IsInterface) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionClassWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionClassWriter.cs index 6253555eadd3c..4b0f10bd2cfc0 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionClassWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionClassWriter.cs @@ -66,7 +66,7 @@ public void ReflectionWriteValue(XmlWriterDelegator xmlWriter, XmlObjectSerializ } else { - MethodInfo getValue = memberType.GetMethod("get_Value", Array.Empty())!; + MethodInfo getValue = memberType.GetMethod("get_Value", Type.EmptyTypes)!; memberValue = getValue.Invoke(memberValue, Array.Empty())!; memberType = memberValue.GetType(); } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs index f1392a84328f5..2b7103688045c 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs @@ -441,7 +441,7 @@ private object ReflectionCreateCollection(CollectionDataContract collectionContr else if (collectionContract.Kind == CollectionKind.GenericDictionary && collectionContract.UnderlyingType.IsInterface) { Type type = Globals.TypeOfDictionaryGeneric.MakeGenericType(collectionContract.ItemType.GetGenericArguments()); - ConstructorInfo ci = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, Array.Empty())!; + ConstructorInfo ci = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes)!; object newGenericDict = ci.Invoke(Array.Empty()); return newGenericDict; } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlDataContract.cs index 703fa385cb57b..c8974ea1975f9 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlDataContract.cs @@ -241,7 +241,7 @@ internal CreateXmlSerializableDelegate? CreateXmlSerializableDelegate if (type.IsValueType) return null; - ConstructorInfo? ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, Array.Empty()); + ConstructorInfo? ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, Type.EmptyTypes); if (ctor == null) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.IXmlSerializableMustHaveDefaultConstructor, DataContract.GetClrTypeFullName(type)))); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs index 4867266a5408b..654ab81627bce 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatGeneratorStatics.cs @@ -45,7 +45,7 @@ internal static MethodInfo WriteEndElementMethod { if (s_writeEndElementMethod == null) { - s_writeEndElementMethod = typeof(XmlWriterDelegator).GetMethod("WriteEndElement", Globals.ScanAllMembers, Array.Empty()); + s_writeEndElementMethod = typeof(XmlWriterDelegator).GetMethod("WriteEndElement", Globals.ScanAllMembers, Type.EmptyTypes); Debug.Assert(s_writeEndElementMethod != null); } return s_writeEndElementMethod; @@ -147,7 +147,7 @@ internal static MethodInfo IsStartElementMethod0 { if (s_isStartElementMethod0 == null) { - s_isStartElementMethod0 = typeof(XmlReaderDelegator).GetMethod("IsStartElement", Globals.ScanAllMembers, Array.Empty()); + s_isStartElementMethod0 = typeof(XmlReaderDelegator).GetMethod("IsStartElement", Globals.ScanAllMembers, Type.EmptyTypes); Debug.Assert(s_isStartElementMethod0 != null); } return s_isStartElementMethod0; @@ -199,7 +199,7 @@ internal static PropertyInfo NodeTypeProperty private static ConstructorInfo? s_extensionDataObjectCtor; internal static ConstructorInfo ExtensionDataObjectCtor => s_extensionDataObjectCtor ?? (s_extensionDataObjectCtor = - typeof(ExtensionDataObject).GetConstructor(Globals.ScanAllMembers, Array.Empty())!); + typeof(ExtensionDataObject).GetConstructor(Globals.ScanAllMembers, Type.EmptyTypes)!); private static ConstructorInfo? s_hashtableCtor; internal static ConstructorInfo HashtableCtor @@ -208,7 +208,7 @@ internal static ConstructorInfo HashtableCtor { if (s_hashtableCtor == null) { - s_hashtableCtor = Globals.TypeOfHashtable.GetConstructor(Globals.ScanAllMembers, Array.Empty()); + s_hashtableCtor = Globals.TypeOfHashtable.GetConstructor(Globals.ScanAllMembers, Type.EmptyTypes); Debug.Assert(s_hashtableCtor != null); } return s_hashtableCtor; @@ -264,7 +264,7 @@ internal static MethodInfo ResetCollectionMemberInfoMethod { if (s_resetCollectionMemberInfoMethod == null) { - s_resetCollectionMemberInfoMethod = typeof(XmlObjectSerializerReadContext).GetMethod("ResetCollectionMemberInfo", Globals.ScanAllMembers, Array.Empty()); + s_resetCollectionMemberInfoMethod = typeof(XmlObjectSerializerReadContext).GetMethod("ResetCollectionMemberInfo", Globals.ScanAllMembers, Type.EmptyTypes); Debug.Assert(s_resetCollectionMemberInfoMethod != null); } return s_resetCollectionMemberInfoMethod; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatReaderGenerator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatReaderGenerator.cs index 095cd8278ce7d..9c5d3cf710598 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatReaderGenerator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatReaderGenerator.cs @@ -596,7 +596,7 @@ private void ReadCollection(CollectionDataContract collectionContract) { case CollectionKind.GenericDictionary: type = Globals.TypeOfDictionaryGeneric.MakeGenericType(itemType.GetGenericArguments()); - constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, Array.Empty())!; + constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes)!; break; case CollectionKind.Dictionary: type = Globals.TypeOfHashtable; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatWriterGenerator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatWriterGenerator.cs index ee7dbdba7a059..0dc6946c5029a 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatWriterGenerator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatWriterGenerator.cs @@ -409,8 +409,8 @@ private void WriteCollection(CollectionDataContract collectionContract) { enumeratorType = collectionContract.GetEnumeratorMethod.ReturnType; } - MethodInfo? moveNextMethod = enumeratorType.GetMethod(Globals.MoveNextMethodName, BindingFlags.Instance | BindingFlags.Public, Array.Empty()); - MethodInfo? getCurrentMethod = enumeratorType.GetMethod(Globals.GetCurrentMethodName, BindingFlags.Instance | BindingFlags.Public, Array.Empty()); + MethodInfo? moveNextMethod = enumeratorType.GetMethod(Globals.MoveNextMethodName, BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes); + MethodInfo? getCurrentMethod = enumeratorType.GetMethod(Globals.GetCurrentMethodName, BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes); if (moveNextMethod == null || getCurrentMethod == null) { if (enumeratorType.IsInterface) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeGenerator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeGenerator.cs index 70a208bc8059a..f7ded1c2176cd 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeGenerator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeGenerator.cs @@ -309,7 +309,7 @@ internal void EndFor() MethodInfo ICollection_get_Count = typeof(ICollection).GetMethod( "get_Count", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; Call(ICollection_get_Count); } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeIdentifier.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeIdentifier.cs index edfddffb6b782..89afc4d625d1e 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeIdentifier.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeIdentifier.cs @@ -234,7 +234,7 @@ internal static string GetCSharpName(Type t) } } - Type[] arguments = t.IsGenericType || t.ContainsGenericParameters ? t.GetGenericArguments() : Array.Empty(); + Type[] arguments = t.IsGenericType || t.ContainsGenericParameters ? t.GetGenericArguments() : Type.EmptyTypes; GetCSharpName(t, arguments, 0, sb); for (int i = 0; i < rank; i++) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs index d8ecf30322ff5..2e84e276bfc0b 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs @@ -280,7 +280,7 @@ internal FieldModel(MemberInfo memberInfo, Type fieldType, TypeDesc fieldTypeDes _fieldType = fieldType; _fieldTypeDesc = fieldTypeDesc; _memberInfo = memberInfo; - _checkShouldPersistMethodInfo = memberInfo.DeclaringType!.GetMethod("ShouldSerialize" + memberInfo.Name, Array.Empty()); + _checkShouldPersistMethodInfo = memberInfo.DeclaringType!.GetMethod("ShouldSerialize" + memberInfo.Name, Type.EmptyTypes); _checkShouldPersist = _checkShouldPersistMethodInfo != null; FieldInfo? specifiedField = memberInfo.DeclaringType.GetField(memberInfo.Name + "Specified"); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SourceInfo.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SourceInfo.cs index 7b70029ddcbee..d299f299f6cbd 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SourceInfo.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SourceInfo.cs @@ -216,7 +216,7 @@ private void ConvertNullableValue(Type nullableType, Type targetType) MethodInfo Nullable_get_Value = nullableType.GetMethod( "get_Value", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ILG.Call(Nullable_get_Value); if (targetType != null) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Types.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Types.cs index db191768f82bb..d9c83f45719a8 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Types.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Types.cs @@ -1216,7 +1216,7 @@ private static bool ShouldBeReplaced(MemberInfo memberInfoToBeReplaced, Type der private static TypeFlags GetConstructorFlags(Type type, ref Exception? exception) { - ConstructorInfo? ctor = type.GetConstructor(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic, Array.Empty()); + ConstructorInfo? ctor = type.GetConstructor(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic, Type.EmptyTypes); if (ctor != null) { TypeFlags flags = TypeFlags.HasDefaultConstructor; @@ -1243,7 +1243,7 @@ private static TypeFlags GetConstructorFlags(Type type, ref Exception? exception { if (typeof(IEnumerable).IsAssignableFrom(type)) { - MethodInfo? enumerator = type.GetMethod("GetEnumerator", Array.Empty()); + MethodInfo? enumerator = type.GetMethod("GetEnumerator", Type.EmptyTypes); if (enumerator == null || !typeof(IEnumerator).IsAssignableFrom(enumerator.ReturnType)) { @@ -1267,7 +1267,7 @@ private static TypeFlags GetConstructorFlags(Type type, ref Exception? exception { // and finally private interface implementation flags |= TypeFlags.UsePrivateImplementation; - enumerator = type.GetMethod("System.Collections.IEnumerable.GetEnumerator", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic, Array.Empty()); + enumerator = type.GetMethod("System.Collections.IEnumerable.GetEnumerator", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic, Type.EmptyTypes); } } if (enumerator == null || !typeof(IEnumerator).IsAssignableFrom(enumerator.ReturnType)) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationILGen.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationILGen.cs index 933a04563bd95..6ff443ee3c6f9 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationILGen.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationILGen.cs @@ -165,7 +165,7 @@ internal FieldBuilder GenerateHashtableGetBegin(string privateName, string publi ilg.BeginMethod( typeof(Hashtable), "get_" + publicName, - Array.Empty(), + Type.EmptyTypes, Array.Empty(), CodeGenerator.PublicOverrideMethodAttributes | MethodAttributes.SpecialName); propertyBuilder.SetGetMethod(ilg.MethodBuilder!); @@ -178,7 +178,7 @@ internal FieldBuilder GenerateHashtableGetBegin(string privateName, string publi ConstructorInfo Hashtable_ctor = typeof(Hashtable).GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; LocalBuilder _tmpLoc = ilg.DeclareLocal(typeof(Hashtable), "_tmp"); ilg.New(Hashtable_ctor); @@ -278,16 +278,16 @@ internal string GenerateBaseSerializer(string baseSerializer, string readerClass CodeIdentifier.GetCSharpName(baseSerializer), TypeAttributes.Public | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, typeof(XmlSerializer), - Array.Empty()); + Type.EmptyTypes); ConstructorInfo readerCtor = CreatedTypes[readerClass].GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg = new CodeGenerator(baseSerializerTypeBuilder); ilg.BeginMethod(typeof(XmlSerializationReader), "CreateReader", - Array.Empty(), + Type.EmptyTypes, Array.Empty(), CodeGenerator.ProtectedOverrideMethodAttributes); ilg.New(readerCtor); @@ -295,11 +295,11 @@ internal string GenerateBaseSerializer(string baseSerializer, string readerClass ConstructorInfo writerCtor = CreatedTypes[writerClass].GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.BeginMethod(typeof(XmlSerializationWriter), "CreateWriter", - Array.Empty(), + Type.EmptyTypes, Array.Empty(), CodeGenerator.ProtectedOverrideMethodAttributes); ilg.New(writerCtor); @@ -323,7 +323,7 @@ internal string GenerateTypedSerializer(string readMethod, string writeMethod, X CodeIdentifier.GetCSharpName(serializerName), TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, CreatedTypes[baseSerializer], - Array.Empty() + Type.EmptyTypes ); ilg = new CodeGenerator(typedSerializerTypeBuilder); @@ -395,7 +395,7 @@ internal string GenerateTypedSerializer(string readMethod, string writeMethod, X MethodInfo readerType_readMethod = CreatedTypes[readerClass].GetMethod( readMethod, CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg("reader"); ilg.Castclass(CreatedTypes[readerClass]); @@ -423,7 +423,7 @@ private FieldBuilder GenerateTypedSerializers(Dictionary seriali { ConstructorInfo ctor = CreatedTypes[(string)serializers[key]].GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg!.Ldloc(typeof(Hashtable), "_tmp"); ilg.Ldstr(GetCSharpString(key)); @@ -463,7 +463,7 @@ private void GenerateGetSerializer(Dictionary serializers, XmlMa { ConstructorInfo ctor = CreatedTypes[(string)serializers[xmlMappings[i].Key!]].GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.New(ctor); ilg.Stloc(ilg.ReturnLocal); @@ -487,7 +487,7 @@ internal void GenerateSerializerContract(string className, XmlMapping[] xmlMappi "XmlSerializerContract", TypeAttributes.Public | TypeAttributes.BeforeFieldInit, typeof(XmlSerializerImplementation), - Array.Empty() + Type.EmptyTypes ); ilg = new CodeGenerator(serializerContractTypeBuilder); @@ -499,13 +499,13 @@ internal void GenerateSerializerContract(string className, XmlMapping[] xmlMappi ilg.BeginMethod( typeof(XmlSerializationReader), "get_Reader", - Array.Empty(), + Type.EmptyTypes, Array.Empty(), CodeGenerator.PublicOverrideMethodAttributes | MethodAttributes.SpecialName); propertyBuilder.SetGetMethod(ilg.MethodBuilder!); ConstructorInfo ctor = CreatedTypes[readerType].GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.New(ctor); ilg.EndMethod(); @@ -519,13 +519,13 @@ internal void GenerateSerializerContract(string className, XmlMapping[] xmlMappi ilg.BeginMethod( typeof(XmlSerializationWriter), "get_Writer", - Array.Empty(), + Type.EmptyTypes, Array.Empty(), CodeGenerator.PublicOverrideMethodAttributes | MethodAttributes.SpecialName); propertyBuilder.SetGetMethod(ilg.MethodBuilder!); ctor = CreatedTypes[writerType].GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.New(ctor); ilg.EndMethod(); @@ -539,13 +539,13 @@ internal void GenerateSerializerContract(string className, XmlMapping[] xmlMappi // Default ctor ConstructorInfo baseCtor = typeof(XmlSerializerImplementation).GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg = new CodeGenerator(serializerContractTypeBuilder); ilg.BeginMethod( typeof(void), ".ctor", - Array.Empty(), + Type.EmptyTypes, Array.Empty(), CodeGenerator.PublicMethodAttributes | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName ); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs index 31c149ad8c5d3..5e9de6e59784e 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs @@ -193,7 +193,7 @@ internal void GenerateBegin() ClassName, TypeAttributes | TypeAttributes.BeforeFieldInit, typeof(XmlSerializationReader), - Array.Empty()); + Type.EmptyTypes); foreach (TypeScope scope in Scopes) { foreach (TypeMapping mapping in scope.TypeMappings) @@ -230,17 +230,17 @@ internal void GenerateEnd(string[] methods, XmlMapping[] xmlMappings, Type[] typ GenerateInitCallbacksMethod(); ilg = new CodeGenerator(this.typeBuilder); - ilg.BeginMethod(typeof(void), "InitIDs", Array.Empty(), Array.Empty(), + ilg.BeginMethod(typeof(void), "InitIDs", Type.EmptyTypes, Array.Empty(), CodeGenerator.ProtectedOverrideMethodAttributes); MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_NameTable = typeof(XmlReader).GetMethod( "get_NameTable", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlNameTable_Add = typeof(XmlNameTable).GetMethod( "Add", @@ -287,7 +287,7 @@ private void WriteIsStartTag(string? name, string? ns) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_IsStartElement = typeof(XmlReader).GetMethod( "IsStartElement", @@ -345,7 +345,7 @@ private void WriteUnknownNode(string func, string node, ElementAccessor? e, bool private void GenerateInitCallbacksMethod() { ilg = new CodeGenerator(this.typeBuilder); - ilg.BeginMethod(typeof(void), "InitCallbacks", Array.Empty(), Array.Empty(), + ilg.BeginMethod(typeof(void), "InitCallbacks", Type.EmptyTypes, Array.Empty(), CodeGenerator.ProtectedOverrideMethodAttributes); ilg.EndMethod(); } @@ -394,7 +394,7 @@ private string GenerateLiteralMembersElement(XmlMembersMapping xmlMembersMapping ilg.BeginMethod( typeof(object[]), methodName, - Array.Empty(), + Type.EmptyTypes, Array.Empty(), CodeGenerator.PublicMethodAttributes ); @@ -403,12 +403,12 @@ private string GenerateLiteralMembersElement(XmlMembersMapping xmlMembersMapping MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_MoveToContent = typeof(XmlReader).GetMethod( "MoveToContent", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -523,7 +523,7 @@ private string GenerateLiteralMembersElement(XmlMembersMapping xmlMembersMapping MethodInfo XmlReader_MoveToElement = typeof(XmlReader).GetMethod( "MoveToElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -538,7 +538,7 @@ private string GenerateLiteralMembersElement(XmlMembersMapping xmlMembersMapping MethodInfo XmlReader_get_IsEmptyElement = typeof(XmlReader).GetMethod( "get_IsEmptyElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -548,7 +548,7 @@ private string GenerateLiteralMembersElement(XmlMembersMapping xmlMembersMapping MethodInfo XmlReader_Skip = typeof(XmlReader).GetMethod( "Skip", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -563,7 +563,7 @@ private string GenerateLiteralMembersElement(XmlMembersMapping xmlMembersMapping MethodInfo XmlReader_ReadStartElement = typeof(XmlReader).GetMethod( "ReadStartElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -592,7 +592,7 @@ private string GenerateLiteralMembersElement(XmlMembersMapping xmlMembersMapping MethodInfo XmlSerializationReader_ReadEndElement = typeof(XmlSerializationReader).GetMethod( "ReadEndElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_ReadEndElement); @@ -637,7 +637,7 @@ private string GenerateTypeElement(XmlTypeMapping xmlTypeMapping) ilg.BeginMethod( typeof(object), methodName, - Array.Empty(), + Type.EmptyTypes, Array.Empty(), CodeGenerator.PublicMethodAttributes ); @@ -652,12 +652,12 @@ private string GenerateTypeElement(XmlTypeMapping xmlTypeMapping) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_MoveToContent = typeof(XmlReader).GetMethod( "MoveToContent", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -705,12 +705,12 @@ private void WritePrimitive(TypeMapping mapping, string source) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_ReadXXXString = typeof(XmlReader).GetMethod( source == "Reader.ReadElementString()" ? "ReadElementContentAsString" : "ReadContentAsString", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -721,12 +721,12 @@ private void WritePrimitive(TypeMapping mapping, string source) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_Value = typeof(XmlReader).GetMethod( "get_Value", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -755,12 +755,12 @@ private void WritePrimitive(TypeMapping mapping, string source) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_ReadXXXString = typeof(XmlReader).GetMethod( source == "Reader.ReadElementString()" ? "ReadElementContentAsString" : "ReadContentAsString", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -771,12 +771,12 @@ private void WritePrimitive(TypeMapping mapping, string source) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_Value = typeof(XmlReader).GetMethod( "get_Value", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -820,12 +820,12 @@ private void WritePrimitive(TypeMapping mapping, string source) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_method = typeof(XmlReader).GetMethod( source == "Reader.Value" ? "get_Value" : "ReadElementContentAsString", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; if (mapping.TypeDesc.CollapseWhitespace) ilg.Ldarg(0); @@ -878,12 +878,12 @@ private void WritePrimitive(TypeMapping mapping, string source) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_ReadXXXString = typeof(XmlReader).GetMethod( source == "Reader.ReadElementString()" ? "ReadElementContentAsString" : "ReadContentAsString", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -894,12 +894,12 @@ private void WritePrimitive(TypeMapping mapping, string source) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_Value = typeof(XmlReader).GetMethod( "get_Value", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -970,7 +970,7 @@ private string WriteHashtable(EnumMapping mapping, string typeName, out MethodBu ilg.BeginMethod( typeof(Hashtable), "get_" + propName, - Array.Empty(), + Type.EmptyTypes, Array.Empty(), MethodAttributes.Assembly | MethodAttributes.HideBySig | MethodAttributes.SpecialName); @@ -981,7 +981,7 @@ private string WriteHashtable(EnumMapping mapping, string typeName, out MethodBu ConstructorInfo Hashtable_ctor = typeof(Hashtable).GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; LocalBuilder hLoc = ilg.DeclareLocal(typeof(Hashtable), "h"); ilg.New(Hashtable_ctor); @@ -1190,12 +1190,12 @@ private void WriteEnumAndArrayTypes() MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_ReadStartElement = typeof(XmlReader).GetMethod( "ReadStartElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -1220,7 +1220,7 @@ private void WriteEnumAndArrayTypes() MethodInfo XmlReader_ReadString = typeof(XmlReader).GetMethod( "ReadContentAsString", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Ldarg(0); @@ -1234,7 +1234,7 @@ private void WriteEnumAndArrayTypes() MethodInfo XmlSerializationReader_ReadEndElement = typeof(XmlSerializationReader).GetMethod( "ReadEndElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_ReadEndElement); @@ -1300,7 +1300,7 @@ private void WriteNullableMethod(NullableMapping nullableMapping) MethodInfo XmlSerializationReader_ReadNull = typeof(XmlSerializationReader).GetMethod( "ReadNull", CodeGenerator.InstanceBindingFlags, - Array.Empty())!; + Type.EmptyTypes)!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_ReadNull); ilg.If(); @@ -1358,12 +1358,12 @@ private void WriteLiteralStructMethod(StructMapping structMapping) MethodInfo XmlSerializationReader_GetXsiType = typeof(XmlSerializationReader).GetMethod( "GetXsiType", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlSerializationReader_ReadNull = typeof(XmlSerializationReader).GetMethod( "ReadNull", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; Label labelTrue = ilg.DefineLabel(); Label labelEnd = ilg.DefineLabel(); @@ -1622,12 +1622,12 @@ private void WriteLiteralStructMethod(StructMapping structMapping) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_MoveToElement = typeof(XmlReader).GetMethod( "MoveToElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -1637,7 +1637,7 @@ private void WriteLiteralStructMethod(StructMapping structMapping) MethodInfo XmlReader_get_IsEmptyElement = typeof(XmlReader).GetMethod( "get_IsEmptyElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -1646,7 +1646,7 @@ private void WriteLiteralStructMethod(StructMapping structMapping) MethodInfo XmlReader_Skip = typeof(XmlReader).GetMethod( "Skip", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -1660,7 +1660,7 @@ private void WriteLiteralStructMethod(StructMapping structMapping) MethodInfo XmlReader_ReadStartElement = typeof(XmlReader).GetMethod( "ReadStartElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -1676,7 +1676,7 @@ private void WriteLiteralStructMethod(StructMapping structMapping) MethodInfo XmlReader_MoveToContent = typeof(XmlReader).GetMethod( "MoveToContent", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -1689,7 +1689,7 @@ private void WriteLiteralStructMethod(StructMapping structMapping) MethodInfo XmlSerializationReader_ReadEndElement = typeof(XmlSerializationReader).GetMethod( "ReadEndElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_ReadEndElement); @@ -1710,12 +1710,12 @@ private void WriteQNameEqual(string source, string? name, string? ns) MethodInfo XmlQualifiedName_get_Name = typeof(XmlQualifiedName).GetMethod( "get_Name", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlQualifiedName_get_Namespace = typeof(XmlQualifiedName).GetMethod( "get_Namespace", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; Label labelEnd = ilg.DefineLabel(); Label labelFalse = ilg.DefineLabel(); @@ -1753,17 +1753,17 @@ private void WriteXmlNodeEqual(string source, string name, string? ns, bool doAn MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_" + source, CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_LocalName = typeof(XmlReader).GetMethod( "get_LocalName", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_NamespaceURI = typeof(XmlReader).GetMethod( "get_NamespaceURI", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; Label labelFalse = ilg.DefineLabel(); @@ -1824,12 +1824,12 @@ private void WriteAttributes(Member[] members, Member? anyAttribute, string else MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_MoveToNextAttribute = typeof(XmlReader).GetMethod( "MoveToNextAttribute", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.WhileBegin(); @@ -1888,17 +1888,17 @@ private void WriteAttributes(Member[] members, Member? anyAttribute, string else MethodInfo XmlReader_get_Name = typeof(XmlReader).GetMethod( "get_Name", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_LocalName = typeof(XmlReader).GetMethod( "get_LocalName", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_Value = typeof(XmlReader).GetMethod( "get_Value", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Ldarg(0); @@ -1914,7 +1914,7 @@ private void WriteAttributes(Member[] members, Member? anyAttribute, string else WriteSourceBegin(xmlnsMember.Source); ConstructorInfo ctor = xmlnsMember.Mapping.TypeDesc!.Type!.GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.New(ctor); WriteSourceEnd(xmlnsMember.Source, xmlnsMember.Mapping.TypeDesc.Type!); @@ -1930,7 +1930,7 @@ private void WriteAttributes(Member[] members, Member? anyAttribute, string else MethodInfo String_get_Length = typeof(string).GetMethod( "get_Length", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ILGenLoad(xmlnsMember.ArraySource, xmlnsMember.Mapping.TypeDesc.Type); ilg.Ldarg(0); @@ -1963,7 +1963,7 @@ private void WriteAttributes(Member[] members, Member? anyAttribute, string else MethodInfo XmlReader_get_Name = typeof(XmlReader).GetMethod( "get_Name", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Ldarg(0); @@ -1979,7 +1979,7 @@ private void WriteAttributes(Member[] members, Member? anyAttribute, string else MethodInfo XmlSerializationReader_get_Document = typeof(XmlSerializationReader).GetMethod( "get_Document", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlDocument_ReadNode = typeof(XmlDocument).GetMethod( "ReadNode", @@ -2094,12 +2094,12 @@ private void WriteAttribute(Member member) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_Value = typeof(XmlReader).GetMethod( "get_Value", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -2253,12 +2253,12 @@ private void WriteMemberElements(Member[] members, string elementElseString, str MethodInfo XmlReader_get_NodeType = typeof(XmlReader).GetMethod( "get_NodeType", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; int XmlNodeType_Element = 1; ilg.Ldarg(0); @@ -2285,12 +2285,12 @@ private void WriteMemberText(Member anyText, string elseString) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_NodeType = typeof(XmlReader).GetMethod( "get_NodeType", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -2342,17 +2342,17 @@ private void WriteText(Member member) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_ReadString = typeof(XmlReader).GetMethod( "ReadContentAsString", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlSerializationReader_get_Document = typeof(XmlSerializationReader).GetMethod( "get_Document", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlDocument_CreateTextNode = typeof(XmlDocument).GetMethod( "CreateTextNode", @@ -2386,12 +2386,12 @@ private void WriteText(Member member) MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_ReadString = typeof(XmlReader).GetMethod( "ReadContentAsString", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -2526,7 +2526,7 @@ private void WriteMemberElementsIf(Member[] members, Member? anyElement, string MethodInfo XmlSerializationReader_get_IsReturnValue = typeof(XmlSerializationReader).GetMethod( "get_IsReturnValue", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_IsReturnValue); @@ -2869,7 +2869,7 @@ private void WriteArray(string source, string? arrayName, ArrayMapping arrayMapp MethodInfo XmlSerializationReader_ReadNull = typeof(XmlSerializationReader).GetMethod( "ReadNull", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_ReadNull); @@ -2904,12 +2904,12 @@ private void WriteArray(string source, string? arrayName, ArrayMapping arrayMapp MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_IsEmptyElement = typeof(XmlReader).GetMethod( "get_IsEmptyElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -2925,7 +2925,7 @@ private void WriteArray(string source, string? arrayName, ArrayMapping arrayMapp MethodInfo XmlReader_Skip = typeof(XmlReader).GetMethod( "Skip", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -2935,7 +2935,7 @@ private void WriteArray(string source, string? arrayName, ArrayMapping arrayMapp MethodInfo XmlReader_ReadStartElement = typeof(XmlReader).GetMethod( "ReadStartElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -2947,7 +2947,7 @@ private void WriteArray(string source, string? arrayName, ArrayMapping arrayMapp MethodInfo XmlReader_MoveToContent = typeof(XmlReader).GetMethod( "MoveToContent", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -2958,7 +2958,7 @@ private void WriteArray(string source, string? arrayName, ArrayMapping arrayMapp MethodInfo XmlSerializationReader_ReadEndElement = typeof(XmlSerializationReader).GetMethod( "ReadEndElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_ReadEndElement); @@ -3015,7 +3015,7 @@ private void WriteElement(string source, string? arrayName, string? choiceSource MethodInfo XmlSerializationReader_ReadNull = typeof(XmlSerializationReader).GetMethod( "ReadNull", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_ReadNull); @@ -3038,12 +3038,12 @@ private void WriteElement(string source, string? arrayName, string? choiceSource MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_IsEmptyElement = typeof(XmlReader).GetMethod( "get_IsEmptyElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -3052,7 +3052,7 @@ private void WriteElement(string source, string? arrayName, string? choiceSource MethodInfo XmlReader_Skip = typeof(XmlReader).GetMethod( "Skip", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -3069,12 +3069,12 @@ private void WriteElement(string source, string? arrayName, string? choiceSource MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_IsEmptyElement = typeof(XmlReader).GetMethod( "get_IsEmptyElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -3084,7 +3084,7 @@ private void WriteElement(string source, string? arrayName, string? choiceSource MethodInfo XmlReader_Skip = typeof(XmlReader).GetMethod( "Skip", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -3112,7 +3112,7 @@ private void WriteElement(string source, string? arrayName, string? choiceSource MethodInfo XmlSerializationReader_ReadElementQualifiedName = typeof(XmlSerializationReader).GetMethod( "ReadElementQualifiedName", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_ReadElementQualifiedName); @@ -3153,12 +3153,12 @@ private void WriteElement(string source, string? arrayName, string? choiceSource MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_Skip = typeof(XmlReader).GetMethod( "Skip", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldloc(arrayName!); ilg.Load(null); @@ -3219,7 +3219,7 @@ private void WriteElement(string source, string? arrayName, string? choiceSource MethodInfo XmlSerializationReader_GetXsiType = typeof(XmlSerializationReader).GetMethod( "GetXsiType", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; Label labelTrue = ilg.DefineLabel(); Label labelEnd = ilg.DefineLabel(); @@ -3372,12 +3372,12 @@ private void WriteWhileNotLoopStart() MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_MoveToContent = typeof(XmlReader).GetMethod( "MoveToContent", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_get_Reader); @@ -3397,12 +3397,12 @@ private void WriteWhileLoopEnd() MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod( "get_Reader", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlReader_get_NodeType = typeof(XmlReader).GetMethod( "get_NodeType", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; Label labelFalse = ilg.DefineLabel(); Label labelEnd = ilg.DefineLabel(); @@ -3586,7 +3586,7 @@ private void ILGenElementElseString(string elementElseString) MethodInfo XmlSerializationReader_CreateUnknownNodeException = typeof(XmlSerializationReader).GetMethod( "CreateUnknownNodeException", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationReader_CreateUnknownNodeException); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs index abf082b98b8ee..48c39db732c44 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs @@ -29,7 +29,7 @@ internal void GenerateBegin() ClassName, TypeAttributes | TypeAttributes.BeforeFieldInit, typeof(XmlSerializationWriter), - Array.Empty()); + Type.EmptyTypes); foreach (TypeScope scope in Scopes) { @@ -84,7 +84,7 @@ internal Type GenerateEnd() private void GenerateInitCallbacksMethod() { ilg = new CodeGenerator(this.typeBuilder); - ilg.BeginMethod(typeof(void), "InitCallbacks", Array.Empty(), Array.Empty(), + ilg.BeginMethod(typeof(void), "InitCallbacks", Type.EmptyTypes, Array.Empty(), CodeGenerator.ProtectedOverrideMethodAttributes); ilg.EndMethod(); } @@ -315,7 +315,7 @@ private void WriteEndElement() MethodInfo XmlSerializationWriter_WriteEndElement = typeof(XmlSerializationWriter).GetMethod( "WriteEndElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationWriter_WriteEndElement); @@ -363,7 +363,7 @@ private string GenerateMembersElement(XmlMembersMapping xmlMembersMapping) MethodInfo XmlSerializationWriter_WriteStartDocument = typeof(XmlSerializationWriter).GetMethod( "WriteStartDocument", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationWriter_WriteStartDocument); @@ -371,7 +371,7 @@ private string GenerateMembersElement(XmlMembersMapping xmlMembersMapping) MethodInfo XmlSerializationWriter_TopLevelElement = typeof(XmlSerializationWriter).GetMethod( "TopLevelElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationWriter_TopLevelElement); @@ -554,7 +554,7 @@ private string GenerateTypeElement(XmlTypeMapping xmlTypeMapping) MethodInfo XmlSerializationWriter_WriteStartDocument = typeof(XmlSerializationWriter).GetMethod( "WriteStartDocument", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationWriter_WriteStartDocument); @@ -574,7 +574,7 @@ private string GenerateTypeElement(XmlTypeMapping xmlTypeMapping) MethodInfo XmlSerializationWriter_TopLevelElement = typeof(XmlSerializationWriter).GetMethod( "TopLevelElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationWriter_TopLevelElement); @@ -698,7 +698,7 @@ private void WriteEnumMethod(EnumMapping mapping) MethodInfo CultureInfo_get_InvariantCulture = typeof(CultureInfo).GetMethod( "get_InvariantCulture", CodeGenerator.StaticBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo Int64_ToString = typeof(long).GetMethod( "ToString", @@ -799,7 +799,7 @@ private void WriteEnumAndArrayTypes() MethodInfo XmlSerializationWriter_get_Writer = typeof(XmlSerializationWriter).GetMethod( "get_Writer", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlWriter_WriteStartElement = typeof(XmlWriter).GetMethod( "WriteStartElement", @@ -842,7 +842,7 @@ private void WriteEnumAndArrayTypes() MethodInfo XmlWriter_WriteEndElement = typeof(XmlWriter).GetMethod( "WriteEndElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationWriter_get_Writer); @@ -865,7 +865,7 @@ private void WriteEnumAndArrayTypes() MethodInfo XmlSerializationWriter_get_Writer = typeof(XmlSerializationWriter).GetMethod( "get_Writer", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlWriter_WriteStartElement = typeof(XmlWriter).GetMethod( "WriteStartElement", @@ -892,7 +892,7 @@ private void WriteEnumAndArrayTypes() MethodInfo XmlWriter_WriteEndElement = typeof(XmlWriter).GetMethod( "WriteEndElement", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationWriter_get_Writer); @@ -957,7 +957,7 @@ private void WriteStructMethod(StructMapping mapping) MethodInfo Object_GetType = typeof(object).GetMethod( "GetType", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ArgBuilder oArg = ilg.GetArg("o"); ilg.LdargAddress(oArg); @@ -1171,7 +1171,7 @@ private void WriteMember(SourceInfo source, AttributeAccessor attribute, TypeDes MethodInfo XmlSerializationWriter_get_Writer = typeof(XmlSerializationWriter).GetMethod( "get_Writer", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlWriter_WriteStartAttribute = typeof(XmlWriter).GetMethod( "WriteStartAttribute", @@ -1190,7 +1190,7 @@ private void WriteMember(SourceInfo source, AttributeAccessor attribute, TypeDes LocalBuilder sbLoc = ilg.DeclareOrGetLocal(typeof(StringBuilder), "sb"); ConstructorInfo StringBuilder_ctor = typeof(StringBuilder).GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.New(StringBuilder_ctor); ilg.Stloc(sbLoc); @@ -1222,7 +1222,7 @@ private void WriteMember(SourceInfo source, AttributeAccessor attribute, TypeDes MethodInfo XmlSerializationWriter_get_Writer = typeof(XmlSerializationWriter).GetMethod( "get_Writer", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlWriter_WriteString = typeof(XmlWriter).GetMethod( "WriteString", @@ -1286,12 +1286,12 @@ private void WriteMember(SourceInfo source, AttributeAccessor attribute, TypeDes MethodInfo XmlSerializationWriter_get_Writer = typeof(XmlSerializationWriter).GetMethod( "get_Writer", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlWriter_WriteEndAttribute = typeof(XmlWriter).GetMethod( "WriteEndAttribute", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldarg(0); ilg.Call(XmlSerializationWriter_get_Writer); @@ -1302,7 +1302,7 @@ private void WriteMember(SourceInfo source, AttributeAccessor attribute, TypeDes MethodInfo StringBuilder_get_Length = typeof(StringBuilder).GetMethod( "get_Length", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldloc("sb"); ilg.Call(StringBuilder_get_Length); @@ -1322,7 +1322,7 @@ private void WriteMember(SourceInfo source, AttributeAccessor attribute, TypeDes MethodInfo Object_ToString = typeof(object).GetMethod( "ToString", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldloc("sb"); ilg.Call(Object_ToString); @@ -1480,7 +1480,7 @@ private void WriteArrayItems(ElementAccessor[] elements, TextAccessor? text, Cho getEnumeratorMethod = typeIEnumerable.GetMethod( "GetEnumerator", CodeGenerator.InstanceBindingFlags, - Array.Empty())!; + Type.EmptyTypes)!; ilg.ConvertValue(arrayTypeDesc.Type!, typeIEnumerable); } @@ -1491,7 +1491,7 @@ private void WriteArrayItems(ElementAccessor[] elements, TextAccessor? text, Cho getEnumeratorMethod = typeIEnumerable.GetMethod( "GetEnumerator", CodeGenerator.InstanceBindingFlags, - Array.Empty())!; + Type.EmptyTypes)!; ilg.ConvertValue(arrayTypeDesc.Type!, typeIEnumerable); } @@ -1499,7 +1499,7 @@ private void WriteArrayItems(ElementAccessor[] elements, TextAccessor? text, Cho { getEnumeratorMethod = arrayTypeDesc.Type!.GetMethod( "GetEnumerator", - Array.Empty())!; + Type.EmptyTypes)!; } ilg.Call(getEnumeratorMethod); ilg.ConvertValue(getEnumeratorMethod.ReturnType, typeof(IEnumerator)); @@ -1518,7 +1518,7 @@ private void WriteArrayItems(ElementAccessor[] elements, TextAccessor? text, Cho MethodInfo IEnumerator_MoveNext = typeof(IEnumerator).GetMethod( "MoveNext", CodeGenerator.InstanceBindingFlags, - Array.Empty())!; + Type.EmptyTypes)!; ilg.Ldloc(eLoc); ilg.Call(IEnumerator_MoveNext); ilg.WhileEndCondition(); @@ -1699,12 +1699,12 @@ private void WriteElements(SourceInfo source, string? enumSource, ElementAccesso MethodInfo XmlNode_get_Name = typeof(XmlNode).GetMethod( "get_Name", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlNode_get_NamespaceURI = typeof(XmlNode).GetMethod( "get_NamespaceURI", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Ldloc(elemLoc); ilg.Call(XmlNode_get_Name); @@ -1769,12 +1769,12 @@ private void WriteElements(SourceInfo source, string? enumSource, ElementAccesso MethodInfo XmlNode_get_Name = typeof(XmlNode).GetMethod( "get_Name", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; MethodInfo XmlNode_get_NamespaceURI = typeof(XmlNode).GetMethod( "get_NamespaceURI", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; ilg.Call(XmlNode_get_Name); ilg.Ldloc(elemLoc); @@ -1870,7 +1870,7 @@ private void WriteText(SourceInfo source, TextAccessor text) MethodInfo XmlSerializationWriter_get_Writer = typeof(XmlSerializationWriter).GetMethod( "get_Writer", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; source.Load(source.Type); ilg.Ldarg(0); @@ -1894,7 +1894,7 @@ private void WriteElement(SourceInfo source, ElementAccessor element, string arr MethodInfo Nullable_get_HasValue = element.Mapping.TypeDesc.Type!.GetMethod( "get_HasValue", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; source.LoadAddress(element.Mapping.TypeDesc.Type); ilg.Call(Nullable_get_HasValue); @@ -2087,7 +2087,7 @@ private void WriteCheckDefault(SourceInfo source, object value, bool isNullable) MethodInfo String_get_Length = typeof(string).GetMethod( "get_Length", CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; source.Load(typeof(string)); ilg.Call(String_get_Length); @@ -2351,7 +2351,7 @@ internal void ILGenForCreateInstance(CodeGenerator ilg, Type type, bool ctorInac { ConstructorInfo ctor = type.GetConstructor( CodeGenerator.InstanceBindingFlags, - Array.Empty() + Type.EmptyTypes )!; if (ctor != null) ilg.New(ctor); @@ -2458,7 +2458,7 @@ internal void ILGenForCreateInstance(CodeGenerator ilg, Type type, Type? cast, b MethodInfo IEnumeratorMoveNext = typeof(IEnumerator).GetMethod( "MoveNext", CodeGenerator.InstanceBindingFlags, - Array.Empty())!; + Type.EmptyTypes)!; ilg.Ldloc(enumerator); ilg.Call(IEnumeratorMoveNext); ilg.WhileEndCondition(); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs index 678cdc26c3444..8c9b1d98859e8 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs @@ -160,7 +160,7 @@ public XmlSerializer(Type type, XmlAttributeOverrides? overrides, Type[]? extraT { } - public XmlSerializer(Type type, XmlRootAttribute? root) : this(type, null, Array.Empty(), root, null, null) + public XmlSerializer(Type type, XmlRootAttribute? root) : this(type, null, Type.EmptyTypes, root, null, null) { } @@ -168,7 +168,7 @@ public XmlSerializer(Type type, Type[]? extraTypes) : this(type, null, extraType { } - public XmlSerializer(Type type, XmlAttributeOverrides? overrides) : this(type, overrides, Array.Empty(), null, null, null) + public XmlSerializer(Type type, XmlAttributeOverrides? overrides) : this(type, overrides, Type.EmptyTypes, null, null, null) { } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializerFactory.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializerFactory.cs index e2dba5894b618..746698cc20964 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializerFactory.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializerFactory.cs @@ -24,7 +24,7 @@ public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides? override public XmlSerializer CreateSerializer(Type type, XmlRootAttribute? root) { - return CreateSerializer(type, null, Array.Empty(), root, null, null); + return CreateSerializer(type, null, Type.EmptyTypes, root, null, null); } public XmlSerializer CreateSerializer(Type type, Type[]? extraTypes) @@ -34,7 +34,7 @@ public XmlSerializer CreateSerializer(Type type, Type[]? extraTypes) public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides? overrides) { - return CreateSerializer(type, overrides, Array.Empty(), null, null, null); + return CreateSerializer(type, overrides, Type.EmptyTypes, null, null, null); } public XmlSerializer CreateSerializer(XmlTypeMapping xmlTypeMapping) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs index 8130d26d8f2a2..6891f91bf6851 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs @@ -145,7 +145,7 @@ internal static class XmlILConstructors private static ConstructorInfo GetConstructor(Type className) { - ConstructorInfo constrInfo = className.GetConstructor(Array.Empty())!; + ConstructorInfo constrInfo = className.GetConstructor(Type.EmptyTypes)!; Debug.Assert(constrInfo != null, "Constructor " + className + " cannot be null."); return constrInfo; } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XmlIlGenerator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XmlIlGenerator.cs index e5314b4d8f81a..610a883ecfb0e 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XmlIlGenerator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XmlIlGenerator.cs @@ -124,13 +124,13 @@ public XmlILGenerator() // Create metadata for the Execute function, which is the entry point to the query // public static void Execute(XmlQueryRuntime); - MethodInfo methExec = _module.DefineMethod("Execute", typeof(void), Array.Empty(), Array.Empty(), XmlILMethodAttributes.NonUser); + MethodInfo methExec = _module.DefineMethod("Execute", typeof(void), Type.EmptyTypes, Array.Empty(), XmlILMethodAttributes.NonUser); // Create metadata for the root expression // public void Root() Debug.Assert(_qil.Root != null); XmlILMethodAttributes methAttrs = (_qil.Root.SourceLine == null) ? XmlILMethodAttributes.NonUser : XmlILMethodAttributes.None; - MethodInfo methRoot = _module.DefineMethod("Root", typeof(void), Array.Empty(), Array.Empty(), methAttrs); + MethodInfo methRoot = _module.DefineMethod("Root", typeof(void), Type.EmptyTypes, Array.Empty(), methAttrs); // Declare all early bound function objects foreach (EarlyBoundInfo info in _qil.EarlyBoundTypes) @@ -253,7 +253,7 @@ private void CreateGlobalValueMetadata(IList globalList) // public T GlobalValue() typReturn = XmlILTypeHelper.GetStorageType(ndRef.XmlType!); methAttrs = ndRef.SourceLine == null ? XmlILMethodAttributes.NonUser : XmlILMethodAttributes.None; - methInfo = _module!.DefineMethod(ndRef.DebugName!.ToString(), typReturn, Array.Empty(), Array.Empty(), methAttrs); + methInfo = _module!.DefineMethod(ndRef.DebugName!.ToString(), typReturn, Type.EmptyTypes, Array.Empty(), methAttrs); // Annotate function with MethodBuilder XmlILAnnotation.Write(ndRef).FunctionBinding = methInfo; diff --git a/src/libraries/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs b/src/libraries/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs index e2595dfa366f0..ac7be18e97ac5 100644 --- a/src/libraries/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs +++ b/src/libraries/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs @@ -413,7 +413,7 @@ public static void Invoke_Event_Add_And_Remove_And_Raise_Invokes_Correct_Methods List invokedMethods = new List(); object proxy = typeof(DispatchProxy) - .GetRuntimeMethod("Create", Array.Empty()).MakeGenericMethod(ieventServiceTypeInfo.AsType(), typeof(TestDispatchProxy)) + .GetRuntimeMethod("Create", Type.EmptyTypes).MakeGenericMethod(ieventServiceTypeInfo.AsType(), typeof(TestDispatchProxy)) .Invoke(null, null); ((TestDispatchProxy)proxy).CallOnInvoke = (method, args) => { diff --git a/src/libraries/System.Reflection.Emit/tests/MethodBuilder/MethodBuilderGetGenericArguments.cs b/src/libraries/System.Reflection.Emit/tests/MethodBuilder/MethodBuilderGetGenericArguments.cs index aebde174eb5ff..220141d05d24a 100644 --- a/src/libraries/System.Reflection.Emit/tests/MethodBuilder/MethodBuilderGetGenericArguments.cs +++ b/src/libraries/System.Reflection.Emit/tests/MethodBuilder/MethodBuilderGetGenericArguments.cs @@ -14,7 +14,7 @@ public void GetGenericArguments_NonGenericMethod_ReturnsEmptyArray() { TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract); MethodBuilder method = type.DefineMethod("Name", MethodAttributes.Public); - Assert.Equal(Array.Empty(), method.GetGenericArguments()); + Assert.Equal(Type.EmptyTypes, method.GetGenericArguments()); } [Fact] diff --git a/src/libraries/System.Reflection.Extensions/tests/RuntimeReflectionExtensionTests.cs b/src/libraries/System.Reflection.Extensions/tests/RuntimeReflectionExtensionTests.cs index 928db6c0e0740..21ee42cf39176 100644 --- a/src/libraries/System.Reflection.Extensions/tests/RuntimeReflectionExtensionTests.cs +++ b/src/libraries/System.Reflection.Extensions/tests/RuntimeReflectionExtensionTests.cs @@ -235,7 +235,7 @@ public void GetRuntimeMethod() } } - Assert.Equal(typeof(TestType).GetMethod("Flush"), typeof(TestType).GetRuntimeMethod("Flush", Array.Empty())); + Assert.Equal(typeof(TestType).GetMethod("Flush"), typeof(TestType).GetRuntimeMethod("Flush", Type.EmptyTypes)); } [Fact] diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoResourceModule.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoResourceModule.cs index 8c8183a37fdee..9bff8aba7a8f1 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoResourceModule.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoResourceModule.cs @@ -46,7 +46,7 @@ public sealed override void GetPEKind(out PortableExecutableKinds peKind, out Im public sealed override bool IsResource() => true; - public sealed override Type[] GetTypes() => Array.Empty(); + public sealed override Type[] GetTypes() => Type.EmptyTypes; protected sealed override RoDefinitionType? GetTypeCoreNoCache(ReadOnlySpan ns, ReadOnlySpan name, out Exception? e) { e = new TypeLoadException(SR.Format(SR.TypeNotFound, ns.ToUtf16().AppendTypeName(name.ToUtf16()), Assembly)); diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/TestUtils/NetStandardBridge.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/TestUtils/NetStandardBridge.cs index 8eba47ba1fbcf..95ae7cea3e3e1 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/TestUtils/NetStandardBridge.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/TestUtils/NetStandardBridge.cs @@ -43,7 +43,7 @@ public static bool IsByRefLike(this Type t) // public static T CallUsingReflection(this object _this, string name, Type[] parameterTypes = null, object[] arguments = null) { - parameterTypes = parameterTypes ?? Array.Empty(); + parameterTypes = parameterTypes ?? Type.EmptyTypes; arguments = arguments ?? Array.Empty(); Type implementationType = _this.GetType(); MethodInfo m = implementationType.GetMethod(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.ExactBinding, null, parameterTypes, null); diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Type/TypeInvariants.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Type/TypeInvariants.cs index bb077cd54e448..9a45ff1e03014 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Type/TypeInvariants.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Type/TypeInvariants.cs @@ -603,7 +603,7 @@ private static void TestGenericParameterCommonInvariants(this Type type) Assert.True(position >= 0); GenericParameterAttributes attributes = type.GenericParameterAttributes; - Assert.Equal(Array.Empty(), type.GetGenericArguments()); + Assert.Equal(Type.EmptyTypes, type.GetGenericArguments()); Assert.False(type.IsByRefLike()); diff --git a/src/libraries/System.Runtime/tests/System/Reflection/BindingFlagsDoNotWrap.cs b/src/libraries/System.Runtime/tests/System/Reflection/BindingFlagsDoNotWrap.cs index ecd025108299a..98cc175c84da4 100644 --- a/src/libraries/System.Runtime/tests/System/Reflection/BindingFlagsDoNotWrap.cs +++ b/src/libraries/System.Runtime/tests/System/Reflection/BindingFlagsDoNotWrap.cs @@ -20,14 +20,14 @@ public static void MethodInvoke() [Fact] public static void ConstructorInvoke() { - ConstructorInfo c = typeof(TestClass).GetConstructor(BindingFlags.Public|BindingFlags.Instance, null, Array.Empty(), null); + ConstructorInfo c = typeof(TestClass).GetConstructor(BindingFlags.Public|BindingFlags.Instance, null, Type.EmptyTypes, null); TestDoNotWrap((bf) => c.Invoke(bf, null, Array.Empty(), null)); } [Fact] public static void ConstructorInvokeTwoArgs() { - ConstructorInfo c = typeof(TestClass).GetConstructor(BindingFlags.Public | BindingFlags.Instance, Array.Empty()); + ConstructorInfo c = typeof(TestClass).GetConstructor(BindingFlags.Public | BindingFlags.Instance, Type.EmptyTypes); TestDoNotWrap((bf) => c.Invoke(bf, null, Array.Empty(), null)); } @@ -49,7 +49,7 @@ public static void ConstructorInvokeStringCtorTwoArgs() [Fact] public static void ConstructorInvokeUsingMethodInfoInvoke() { - ConstructorInfo c = typeof(TestClass).GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, Array.Empty(), null); + ConstructorInfo c = typeof(TestClass).GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null); TestDoNotWrap((bf) => c.Invoke(new TestClass(0), bf, null, Array.Empty(), null)); } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/XmlKeyHelper.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/XmlKeyHelper.cs index b810f22935f57..be6c871a1b6c7 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/XmlKeyHelper.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/XmlKeyHelper.cs @@ -277,7 +277,7 @@ private static class Functions "Elements", BindingFlags.Instance | BindingFlags.Public, null, - Array.Empty(), + Type.EmptyTypes, null)!; private static readonly PropertyInfo s_elementNameProperty = s_docRootProperty.PropertyType.GetProperty("Name")!; private static readonly PropertyInfo s_nameNameProperty = s_elementNameProperty.PropertyType.GetProperty("LocalName")!; diff --git a/src/libraries/System.Security.Cryptography.Primitives/tests/CryptoConfigTests.cs b/src/libraries/System.Security.Cryptography.Primitives/tests/CryptoConfigTests.cs index 7dcdd650ea27f..dbd140ad5465a 100644 --- a/src/libraries/System.Security.Cryptography.Primitives/tests/CryptoConfigTests.cs +++ b/src/libraries/System.Security.Cryptography.Primitives/tests/CryptoConfigTests.cs @@ -55,7 +55,7 @@ public static void NamedHashAlgorithmCreate(string identifier, Type baseType) Assert.IsAssignableFrom(baseType, created); using (HashAlgorithm equivalent = - (HashAlgorithm)baseType.GetMethod("Create", Array.Empty()).Invoke(null, null)) + (HashAlgorithm)baseType.GetMethod("Create", Type.EmptyTypes).Invoke(null, null)) { byte[] input = { 1, 2, 3, 4, 5 }; byte[] equivHash = equivalent.ComputeHash(input); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs index 4c84b6c4f985b..8ca3550833601 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs @@ -352,7 +352,7 @@ public override string ToString() sbName.Append(' '); sbName.Append(Name); sbName.Append('('); - AppendParameters(ref sbName, parameters ?? Array.Empty(), CallingConvention); + AppendParameters(ref sbName, parameters ?? Type.EmptyTypes, CallingConvention); sbName.Append(')'); return sbName.ToString(); } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs index a5f0724cb7431..66b0bbb9b4f80 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs @@ -1206,7 +1206,7 @@ public override Type[] GetGenericArguments() Type[] types = GetGenericArgumentsInternal(false); if (types == null) - types = Array.Empty(); + types = Type.EmptyTypes; return types; } @@ -1858,7 +1858,7 @@ internal RuntimeType(object obj) ListBuilder ctors = GetConstructorCandidates( null, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly, CallingConventions.Any, - Array.Empty(), false); + Type.EmptyTypes, false); if (ctors.Count == 1) cache.default_ctor = ctor = (RuntimeConstructorInfo)ctors[0]; @@ -2265,7 +2265,7 @@ public override Type[] GetGenericParameterConstraints() var paramInfo = new Mono.RuntimeGenericParamInfoHandle(RuntimeTypeHandle.GetGenericParameterInfo(this)); Type[] constraints = paramInfo.Constraints; - return constraints ?? Array.Empty(); + return constraints ?? Type.EmptyTypes; } internal static object CreateInstanceForAnotherGenericParameter(Type genericType, RuntimeType genericArgument) diff --git a/src/tests/JIT/Stress/ABI/Stubs.cs b/src/tests/JIT/Stress/ABI/Stubs.cs index 35b5220e52b14..09e9154c6281e 100644 --- a/src/tests/JIT/Stress/ABI/Stubs.cs +++ b/src/tests/JIT/Stress/ABI/Stubs.cs @@ -168,7 +168,7 @@ private static bool DoStubCall(int callerIndex, bool staticMethod, bool onValueT ILGenerator g = cb.GetILGenerator(); g.Emit(OpCodes.Ldarg, 0); - g.Emit(OpCodes.Call, typeof(object).GetConstructor(Array.Empty())); + g.Emit(OpCodes.Call, typeof(object).GetConstructor(Type.EmptyTypes)); g.Emit(OpCodes.Ldarg, 0); g.Emit(OpCodes.Ldarg_1); g.Emit(OpCodes.Stfld, fieldInfoMagicValueField);