diff --git a/src/Polyfill/InterpolatedStringHandlerArgumentAttribute.cs b/src/Polyfill/InterpolatedStringHandlerArgumentAttribute.cs index 94b5583e..c2ab3559 100644 --- a/src/Polyfill/InterpolatedStringHandlerArgumentAttribute.cs +++ b/src/Polyfill/InterpolatedStringHandlerArgumentAttribute.cs @@ -26,7 +26,7 @@ sealed class InterpolatedStringHandlerArgumentAttribute : /// /// The name of the argument that should be passed to the handler. /// may be used as the name of the receiver in an instance method. - public InterpolatedStringHandlerArgumentAttribute(string argument) => Arguments = new[] { argument }; + public InterpolatedStringHandlerArgumentAttribute(string argument) => Arguments = [argument]; /// /// Initializes a new instance of the class. diff --git a/src/Polyfill/Nullability/NullabilityInfoExtensions.cs b/src/Polyfill/Nullability/NullabilityInfoExtensions.cs index 82af6035..a1dcf842 100644 --- a/src/Polyfill/Nullability/NullabilityInfoExtensions.cs +++ b/src/Polyfill/Nullability/NullabilityInfoExtensions.cs @@ -14,10 +14,10 @@ #endif static partial class PolyfillExtensions { - static ConcurrentDictionary parameterCache = new(); - static ConcurrentDictionary propertyCache = new(); - static ConcurrentDictionary eventCache = new(); - static ConcurrentDictionary fieldCache = new(); + static ConcurrentDictionary parameterCache = []; + static ConcurrentDictionary propertyCache = []; + static ConcurrentDictionary eventCache = []; + static ConcurrentDictionary fieldCache = []; public static NullabilityInfo GetNullabilityInfo(this MemberInfo info) { diff --git a/src/Polyfill/Nullable/MemberNotNullAttribute.cs b/src/Polyfill/Nullable/MemberNotNullAttribute.cs index 99c12264..bfbde6a8 100644 --- a/src/Polyfill/Nullable/MemberNotNullAttribute.cs +++ b/src/Polyfill/Nullable/MemberNotNullAttribute.cs @@ -35,7 +35,7 @@ sealed class MemberNotNullAttribute : /// The field or property member that is promised to be not-null. /// public MemberNotNullAttribute(string member) => - Members = new[] { member }; + Members = [member]; /// /// Initializes the attribute with the list of field and property members. diff --git a/src/Polyfill/Nullable/MemberNotNullWhenAttribute.cs b/src/Polyfill/Nullable/MemberNotNullWhenAttribute.cs index 4f434e83..b9fbd538 100644 --- a/src/Polyfill/Nullable/MemberNotNullWhenAttribute.cs +++ b/src/Polyfill/Nullable/MemberNotNullWhenAttribute.cs @@ -46,7 +46,7 @@ sealed class MemberNotNullWhenAttribute : public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; - Members = new[] { member }; + Members = [member]; } /// diff --git a/src/Polyfill/PolyfillExtensions_String.cs b/src/Polyfill/PolyfillExtensions_String.cs index a3565b0f..790dd9c5 100644 --- a/src/Polyfill/PolyfillExtensions_String.cs +++ b/src/Polyfill/PolyfillExtensions_String.cs @@ -108,7 +108,7 @@ public static bool EndsWith(this string target, char value) /// An array that contains at most count substrings from this instance that are delimited by separator. [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.split#system-string-split(system-char-system-stringsplitoptions)")] public static string[] Split(this string target, char separator, StringSplitOptions options = StringSplitOptions.None) => - target.Split(new[] {separator}, options); + target.Split([separator], options); /// /// Splits a string into a maximum number of substrings based on a specified delimiting character and, optionally, @@ -122,7 +122,7 @@ public static string[] Split(this string target, char separator, StringSplitOpti /// An array that contains at most count substrings from this instance that are delimited by separator. [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.split#system-string-split(system-char-system-int32-system-stringsplitoptions)")] public static string[] Split(this string target, char separator, int count, StringSplitOptions options = StringSplitOptions.None) => - target.Split(new[] {separator}, count, options); + target.Split([separator], count, options); #endif #if NETFRAMEWORK || NETSTANDARD2_0 || NETCOREAPP2_0 diff --git a/src/Tests/PolyfillExtensionsTests_CancellationTokenSource.cs b/src/Tests/PolyfillExtensionsTests_CancellationTokenSource.cs index 8d3fb6e2..8c455fc7 100644 --- a/src/Tests/PolyfillExtensionsTests_CancellationTokenSource.cs +++ b/src/Tests/PolyfillExtensionsTests_CancellationTokenSource.cs @@ -18,9 +18,12 @@ public static void CancelSource_CancelAsync_NoRegistrations_CallbackCompletesImm Assert.True(cancelSource.IsCancellationRequested); cancelSource = new(); - cancelSource.Token.Register(() => - { - }).Dispose(); + cancelSource.Token + .Register( + () => + { + }) + .Dispose(); Assert.True(IsCompletedSuccessfully(cancelSource.CancelAsync())); Assert.True(cancelSource.IsCancellationRequested); }