Skip to content

Commit 25baa49

Browse files
committed
Merge remote-tracking branch 'upstream/main' into morecodecleanup
2 parents ab04eb7 + 6068519 commit 25baa49

File tree

77 files changed

+238
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+238
-266
lines changed

src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ public LicenseInteropProxy()
756756

757757
Type licContext = Type.GetType("System.ComponentModel.LicenseContext, System.ComponentModel.TypeConverter", throwOnError: true)!;
758758
_setSavedLicenseKey = licContext.GetMethod("SetSavedLicenseKey", BindingFlags.Instance | BindingFlags.Public)!;
759-
_createWithContext = licManager.GetMethod("CreateWithContext", new[] { typeof(Type), licContext })!;
759+
_createWithContext = licManager.GetMethod("CreateWithContext", [typeof(Type), licContext])!;
760760

761761
Type interopHelper = licManager.GetNestedType("LicenseInteropHelper", BindingFlags.NonPublic)!;
762762
_validateTypeAndReturnDetails = interopHelper.GetMethod("ValidateAndRetrieveLicenseDetails", BindingFlags.Static | BindingFlags.Public)!;
@@ -816,7 +816,7 @@ public void GetLicInfo(Type type, out bool runtimeKeyAvail, out bool licVerified
816816
licVerified = true;
817817
}
818818

819-
parameters = new object?[] { type.AssemblyQualifiedName };
819+
parameters = [type.AssemblyQualifiedName];
820820
runtimeKeyAvail = (bool)_licInfoHelperContains.Invoke(licContext, BindingFlags.DoNotWrapExceptions, binder: null, parameters: parameters, culture: null)!;
821821
}
822822

@@ -863,18 +863,18 @@ public object AllocateAndValidateLicense([DynamicallyAccessedMembers(Dynamically
863863
object? licContext;
864864
if (isDesignTime)
865865
{
866-
parameters = new object[] { type };
866+
parameters = [type];
867867
licContext = _createDesignContext.Invoke(null, BindingFlags.DoNotWrapExceptions, binder: null, parameters: parameters, culture: null);
868868
}
869869
else
870870
{
871-
parameters = new object?[] { type, key };
871+
parameters = [type, key];
872872
licContext = _createRuntimeContext.Invoke(null, BindingFlags.DoNotWrapExceptions, binder: null, parameters: parameters, culture: null);
873873
}
874874

875875
try
876876
{
877-
parameters = new object?[] { type, licContext };
877+
parameters = [type, licContext];
878878
return _createWithContext.Invoke(null, BindingFlags.DoNotWrapExceptions, binder: null, parameters: parameters, culture: null)!;
879879
}
880880
catch (Exception exception) when (exception.GetType() == s_licenseExceptionType)

src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ internal void InitializeSourceInfo(int iSkip, bool fNeedFileInfo, Exception? exc
110110
return;
111111
}
112112

113-
Type[] parameterTypes = new Type[]
114-
{
113+
Type[] parameterTypes =
114+
[
115115
typeof(Assembly), typeof(string), typeof(IntPtr), typeof(int), typeof(bool), typeof(IntPtr),
116116
typeof(int), typeof(int), typeof(int),
117117
typeof(string).MakeByRefType(), typeof(int).MakeByRefType(), typeof(int).MakeByRefType()
118-
};
118+
];
119119
MethodInfo? symbolsMethodInfo = symbolsType.GetMethod("GetSourceLineInfo", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, parameterTypes, null);
120120
if (symbolsMethodInfo == null)
121121
{

src/coreclr/System.Private.CoreLib/src/System/Enum.CoreCLR.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private unsafe CorElementType InternalGetCorElementType()
3333

3434
// Indexed by CorElementType
3535
private static readonly RuntimeType?[] s_underlyingTypes =
36-
{
36+
[
3737
null,
3838
null,
3939
(RuntimeType)typeof(bool),
@@ -60,7 +60,7 @@ private unsafe CorElementType InternalGetCorElementType()
6060
null,
6161
(RuntimeType)typeof(nint),
6262
(RuntimeType)typeof(nuint)
63-
};
63+
];
6464

6565
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6666
internal static unsafe RuntimeType InternalGetUnderlyingType(RuntimeType enumType)

src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,10 @@ private void Init(TypeForwardedToAttribute forwardedTo)
383383
{
384384
Type type = typeof(TypeForwardedToAttribute);
385385

386-
Type[] sig = new Type[] { typeof(Type) };
386+
Type[] sig = [typeof(Type)];
387387
m_ctor = type.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, sig, null)!;
388388

389-
CustomAttributeTypedArgument[] typedArgs = new CustomAttributeTypedArgument[1];
390-
typedArgs[0] = new CustomAttributeTypedArgument(typeof(Type), forwardedTo.Destination);
389+
CustomAttributeTypedArgument[] typedArgs = [new CustomAttributeTypedArgument(typeof(Type), forwardedTo.Destination)];
391390
m_typedCtorArgs = Array.AsReadOnly(typedArgs);
392391

393392
m_namedArgs = Array.Empty<CustomAttributeNamedArgument>();
@@ -1943,8 +1942,8 @@ internal static class PseudoCustomAttribute
19431942
#region Static Constructor
19441943
private static HashSet<RuntimeType> CreatePseudoCustomAttributeHashSet()
19451944
{
1946-
Type[] pcas = new Type[]
1947-
{
1945+
Type[] pcas =
1946+
[
19481947
// See https://github.com/dotnet/runtime/blob/main/src/coreclr/md/compiler/custattr_emit.cpp
19491948
typeof(FieldOffsetAttribute), // field
19501949
typeof(SerializableAttribute), // class, struct, enum, delegate
@@ -1957,7 +1956,7 @@ private static HashSet<RuntimeType> CreatePseudoCustomAttributeHashSet()
19571956
typeof(DllImportAttribute), // method
19581957
typeof(PreserveSigAttribute), // method
19591958
typeof(TypeForwardedToAttribute), // assembly
1960-
};
1959+
];
19611960

19621961
HashSet<RuntimeType> set = new HashSet<RuntimeType>(pcas.Length);
19631962
foreach (RuntimeType runtimeType in pcas)

src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public T[] ToArray()
8383
if (_count == 0)
8484
return Array.Empty<T>();
8585
if (_count == 1)
86-
return new T[1] { _item };
86+
return [_item];
8787

8888
Array.Resize(ref _items, _count);
8989
_capacity = _count;
@@ -3565,7 +3565,7 @@ public override Type MakeGenericType(Type[] instantiation)
35653565
}
35663566
catch (TypeLoadException e)
35673567
{
3568-
ValidateGenericArguments(this, new[] { rt }, e);
3568+
ValidateGenericArguments(this, [rt], e);
35693569
throw;
35703570
}
35713571
}
@@ -4029,7 +4029,7 @@ private extern object InvokeDispMethod(
40294029
paramMod[i] = aArgsIsByRef[i];
40304030
}
40314031

4032-
aParamMod = new ParameterModifier[] { paramMod };
4032+
aParamMod = [paramMod];
40334033
if (aArgsWrapperTypes != null)
40344034
{
40354035
WrapArgsForInvokeCall(aArgs, aArgsWrapperTypes);
@@ -4117,23 +4117,23 @@ private static void WrapArgsForInvokeCall(object[] aArgs, int[] aArgsWrapperType
41174117
ConstructorInfo wrapperCons;
41184118
if (isString)
41194119
{
4120-
wrapperCons = wrapperType.GetConstructor(new Type[] { typeof(string) })!;
4120+
wrapperCons = wrapperType.GetConstructor([typeof(string)])!;
41214121
}
41224122
else
41234123
{
4124-
wrapperCons = wrapperType.GetConstructor(new Type[] { typeof(object) })!;
4124+
wrapperCons = wrapperType.GetConstructor([typeof(object)])!;
41254125
}
41264126

41274127
// Wrap each of the elements of the array.
41284128
for (int currElem = 0; currElem < numElems; currElem++)
41294129
{
41304130
if (isString)
41314131
{
4132-
newArray[currElem] = wrapperCons.Invoke(new object?[] { (string?)oldArray.GetValue(currElem) });
4132+
newArray[currElem] = wrapperCons.Invoke([(string?)oldArray.GetValue(currElem)]);
41334133
}
41344134
else
41354135
{
4136-
newArray[currElem] = wrapperCons.Invoke(new object?[] { oldArray.GetValue(currElem) });
4136+
newArray[currElem] = wrapperCons.Invoke([oldArray.GetValue(currElem)]);
41374137
}
41384138
}
41394139

src/coreclr/System.Private.CoreLib/src/System/__ComObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private object CreateEventProvider(
124124
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] RuntimeType t)
125125
{
126126
// Create the event provider for the specified type.
127-
object EvProvider = Activator.CreateInstance(t, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, new object[] { this }, null)!;
127+
object EvProvider = Activator.CreateInstance(t, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, [this], null)!;
128128

129129
// Attempt to cache the wrapper on the object.
130130
if (!SetData(t, EvProvider))

src/libraries/Common/src/System/Number.Formatting.Common.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,37 @@ internal static partial class Number
2020
private const string PosNumberFormat = "#";
2121

2222
private static readonly string[] s_posCurrencyFormats =
23-
{
23+
[
2424
"$#", "#$", "$ #", "# $"
25-
};
25+
];
2626

2727
private static readonly string[] s_negCurrencyFormats =
28-
{
28+
[
2929
"($#)", "-$#", "$-#", "$#-",
3030
"(#$)", "-#$", "#-$", "#$-",
3131
"-# $", "-$ #", "# $-", "$ #-",
3232
"$ -#", "#- $", "($ #)", "(# $)",
3333
"$- #"
34-
};
34+
];
3535

3636
private static readonly string[] s_posPercentFormats =
37-
{
37+
[
3838
"# %", "#%", "%#", "% #"
39-
};
39+
];
4040

4141
private static readonly string[] s_negPercentFormats =
42-
{
42+
[
4343
"-# %", "-#%", "-%#",
4444
"%-#", "%#-",
4545
"#-%", "#%-",
4646
"-% #", "# %-", "% #-",
4747
"% -#", "#- %"
48-
};
48+
];
4949

5050
private static readonly string[] s_negNumberFormats =
51-
{
51+
[
5252
"(#)", "-#", "- #", "#-", "# -",
53-
};
53+
];
5454

5555
internal static unsafe char ParseFormatSpecifier(ReadOnlySpan<char> format, out int digits)
5656
{

src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public DelegateWrapper(Delegate d, bool wrapArgs)
6363
}
6464
}
6565

66-
return Delegate.DynamicInvoke(WrapArgs ? new object[] { args } : args);
66+
return Delegate.DynamicInvoke(WrapArgs ? [args] : args);
6767
}
6868

6969
private void PreProcessSignature()

src/libraries/System.Private.CoreLib/src/System/AggregateException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public AggregateException(string? message, Exception innerException)
5858
{
5959
ArgumentNullException.ThrowIfNull(innerException);
6060

61-
_innerExceptions = new[] { innerException };
61+
_innerExceptions = [innerException];
6262
}
6363

6464
/// <summary>

src/libraries/System.Private.CoreLib/src/System/AppDomain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private static int ExecuteAssembly(Assembly assembly, string?[]? args)
139139
obj: null,
140140
invokeAttr: BindingFlags.DoNotWrapExceptions,
141141
binder: null,
142-
parameters: entry.GetParametersAsSpan().Length > 0 ? new object?[] { args } : null,
142+
parameters: entry.GetParametersAsSpan().Length > 0 ? [args] : null,
143143
culture: null);
144144

145145
return result != null ? (int)result : 0;

0 commit comments

Comments
 (0)