Skip to content

Commit

Permalink
collection expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Dec 5, 2023
1 parent e70f632 commit d036632
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Polyfill/InterpolatedStringHandlerArgumentAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sealed class InterpolatedStringHandlerArgumentAttribute :
/// </summary>
/// <param name="argument">The name of the argument that should be passed to the handler.</param>
/// <remarks><see langword="null"/> may be used as the name of the receiver in an instance method.</remarks>
public InterpolatedStringHandlerArgumentAttribute(string argument) => Arguments = new[] { argument };
public InterpolatedStringHandlerArgumentAttribute(string argument) => Arguments = [argument];

/// <summary>
/// Initializes a new instance of the <see cref="InterpolatedStringHandlerArgumentAttribute"/> class.
Expand Down
8 changes: 4 additions & 4 deletions src/Polyfill/Nullability/NullabilityInfoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#endif
static partial class PolyfillExtensions
{
static ConcurrentDictionary<ParameterInfo, NullabilityInfo> parameterCache = new();
static ConcurrentDictionary<PropertyInfo, NullabilityInfo> propertyCache = new();
static ConcurrentDictionary<EventInfo, NullabilityInfo> eventCache = new();
static ConcurrentDictionary<FieldInfo, NullabilityInfo> fieldCache = new();
static ConcurrentDictionary<ParameterInfo, NullabilityInfo> parameterCache = [];
static ConcurrentDictionary<PropertyInfo, NullabilityInfo> propertyCache = [];
static ConcurrentDictionary<EventInfo, NullabilityInfo> eventCache = [];
static ConcurrentDictionary<FieldInfo, NullabilityInfo> fieldCache = [];

public static NullabilityInfo GetNullabilityInfo(this MemberInfo info)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfill/Nullable/MemberNotNullAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sealed class MemberNotNullAttribute :
/// The field or property member that is promised to be not-null.
/// </param>
public MemberNotNullAttribute(string member) =>
Members = new[] { member };
Members = [member];

/// <summary>
/// Initializes the attribute with the list of field and property members.
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfill/Nullable/MemberNotNullWhenAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sealed class MemberNotNullWhenAttribute :
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new[] { member };
Members = [member];
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Polyfill/PolyfillExtensions_String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static bool EndsWith(this string target, char value)
/// <returns>An array that contains at most count substrings from this instance that are delimited by separator.</returns>
[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);

/// <summary>
/// Splits a string into a maximum number of substrings based on a specified delimiting character and, optionally,
Expand All @@ -122,7 +122,7 @@ public static string[] Split(this string target, char separator, StringSplitOpti
/// <returns>An array that contains at most count substrings from this instance that are delimited by separator.</returns>
[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
Expand Down
9 changes: 6 additions & 3 deletions src/Tests/PolyfillExtensionsTests_CancellationTokenSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit d036632

Please sign in to comment.