diff --git a/PolyShim/NamespaceDummies.cs b/PolyShim/NamespaceDummies.cs index c05cc61..4bf079e 100644 --- a/PolyShim/NamespaceDummies.cs +++ b/PolyShim/NamespaceDummies.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -// ReSharper disable RedundantUsingDirective +// ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace // ReSharper disable InconsistentNaming // ReSharper disable PartialTypeWithSinglePart diff --git a/PolyShim/Net50/DynamicallyAccessedMemberTypes.cs b/PolyShim/Net50/DynamicallyAccessedMemberTypes.cs index e4cfa54..0a4b259 100644 --- a/PolyShim/Net50/DynamicallyAccessedMemberTypes.cs +++ b/PolyShim/Net50/DynamicallyAccessedMemberTypes.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -29,6 +26,6 @@ internal enum DynamicallyAccessedMemberTypes NonPublicProperties = 1024, PublicEvents = 2048, NonPublicEvents = 4096, - Interfaces = 8192 + Interfaces = 8192, } #endif diff --git a/PolyShim/Net50/DynamicallyAccessedMembersAttribute.cs b/PolyShim/Net50/DynamicallyAccessedMembersAttribute.cs index f9a5b55..4e112e8 100644 --- a/PolyShim/Net50/DynamicallyAccessedMembersAttribute.cs +++ b/PolyShim/Net50/DynamicallyAccessedMembersAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/Environment.cs b/PolyShim/Net50/Environment.cs index 9942d5d..4620fdf 100644 --- a/PolyShim/Net50/Environment.cs +++ b/PolyShim/Net50/Environment.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -15,7 +12,7 @@ internal static partial class PolyfillExtensions { extension(Environment) { -// No Process class in .NET Standard 1.x + // No Process class in .NET Standard 1.x #if !NETSTANDARD || NETSTANDARD2_0_OR_GREATER // https://learn.microsoft.com/dotnet/api/system.environment.processid public static int ProcessId @@ -29,4 +26,4 @@ public static int ProcessId #endif } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net50/HttpClient.cs b/PolyShim/Net50/HttpClient.cs index fa57001..911ac2c 100644 --- a/PolyShim/Net50/HttpClient.cs +++ b/PolyShim/Net50/HttpClient.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_HTTPCLIENT +#if FEATURE_HTTPCLIENT #if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective diff --git a/PolyShim/Net50/HttpContent.cs b/PolyShim/Net50/HttpContent.cs index c019569..267c1ba 100644 --- a/PolyShim/Net50/HttpContent.cs +++ b/PolyShim/Net50/HttpContent.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_HTTPCLIENT +#if FEATURE_HTTPCLIENT #if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective diff --git a/PolyShim/Net50/IsExternalInit.cs b/PolyShim/Net50/IsExternalInit.cs index c713720..c9c0ae6 100644 --- a/PolyShim/Net50/IsExternalInit.cs +++ b/PolyShim/Net50/IsExternalInit.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/MemberNotNullAttribute.cs b/PolyShim/Net50/MemberNotNullAttribute.cs index 97fc3f5..54322fa 100644 --- a/PolyShim/Net50/MemberNotNullAttribute.cs +++ b/PolyShim/Net50/MemberNotNullAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/MemberNotNullWhenAttribute.cs b/PolyShim/Net50/MemberNotNullWhenAttribute.cs index ee524f6..cc5d160 100644 --- a/PolyShim/Net50/MemberNotNullWhenAttribute.cs +++ b/PolyShim/Net50/MemberNotNullWhenAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/ModuleInitializerAttribute.cs b/PolyShim/Net50/ModuleInitializerAttribute.cs index 760edac..d15fbd6 100644 --- a/PolyShim/Net50/ModuleInitializerAttribute.cs +++ b/PolyShim/Net50/ModuleInitializerAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/OSPlatformAttribute.cs b/PolyShim/Net50/OSPlatformAttribute.cs index 0a270a5..c3b816f 100644 --- a/PolyShim/Net50/OSPlatformAttribute.cs +++ b/PolyShim/Net50/OSPlatformAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/OperatingSystem.cs b/PolyShim/Net50/OperatingSystem.cs index fe98369..74f6d61 100644 --- a/PolyShim/Net50/OperatingSystem.cs +++ b/PolyShim/Net50/OperatingSystem.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -15,7 +12,7 @@ internal static partial class PolyfillExtensions { extension(OperatingSystem) { -// Can only detect the platform on .NET Standard 1.3+ + // Can only detect the platform on .NET Standard 1.3+ #if !NETSTANDARD || NETSTANDARD1_3_OR_GREATER // https://learn.microsoft.com/dotnet/api/system.operatingsystem.isfreebsd public static bool IsFreeBSD() => RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD); @@ -29,7 +26,7 @@ internal static partial class PolyfillExtensions // https://learn.microsoft.com/dotnet/api/system.operatingsystem.iswindows public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); -// Can only detect OS version on .NET Standard 2.0+ and .NET Core 2.0 + // Can only detect OS version on .NET Standard 2.0+ and .NET Core 2.0 #if (!NETSTANDARD || NETSTANDARD2_0_OR_GREATER) && (!NETCOREAPP || NETCOREAPP2_0_OR_GREATER) // https://learn.microsoft.com/dotnet/api/system.operatingsystem.iswindowsversionatleast public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) @@ -54,4 +51,4 @@ public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = #endif } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net50/Process.cs b/PolyShim/Net50/Process.cs index 7a8b28c..c7ce48c 100644 --- a/PolyShim/Net50/Process.cs +++ b/PolyShim/Net50/Process.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_PROCESS +#if FEATURE_PROCESS #if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective diff --git a/PolyShim/Net50/RequiresUnreferencedCodeAttribute.cs b/PolyShim/Net50/RequiresUnreferencedCodeAttribute.cs index c4a176c..c127fa8 100644 --- a/PolyShim/Net50/RequiresUnreferencedCodeAttribute.cs +++ b/PolyShim/Net50/RequiresUnreferencedCodeAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/SkipLocalsInitAttribute.cs b/PolyShim/Net50/SkipLocalsInitAttribute.cs index b20a331..7fd914a 100644 --- a/PolyShim/Net50/SkipLocalsInitAttribute.cs +++ b/PolyShim/Net50/SkipLocalsInitAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/SupportedOSPlatformAttribute.cs b/PolyShim/Net50/SupportedOSPlatformAttribute.cs index 4ba88e7..6e15f58 100644 --- a/PolyShim/Net50/SupportedOSPlatformAttribute.cs +++ b/PolyShim/Net50/SupportedOSPlatformAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/TargetPlatformAttribute.cs b/PolyShim/Net50/TargetPlatformAttribute.cs index 5eceff8..2de6acf 100644 --- a/PolyShim/Net50/TargetPlatformAttribute.cs +++ b/PolyShim/Net50/TargetPlatformAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/TaskCompletionSource.cs b/PolyShim/Net50/TaskCompletionSource.cs index 526bf79..3e4e564 100644 --- a/PolyShim/Net50/TaskCompletionSource.cs +++ b/PolyShim/Net50/TaskCompletionSource.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_TASK +#if FEATURE_TASK #if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective @@ -19,17 +16,14 @@ internal class TaskCompletionSource(object? state, TaskCreationOptions creationO { private readonly TaskCompletionSource _source = new(state, creationOptions); - public TaskCompletionSource(object? state) : this(state, TaskCreationOptions.None) - { - } + public TaskCompletionSource(object? state) + : this(state, TaskCreationOptions.None) { } - public TaskCompletionSource(TaskCreationOptions creationOptions) : this(null, creationOptions) - { - } + public TaskCompletionSource(TaskCreationOptions creationOptions) + : this(null, creationOptions) { } - public TaskCompletionSource() : this(null, TaskCreationOptions.None) - { - } + public TaskCompletionSource() + : this(null, TaskCreationOptions.None) { } public Task Task => _source.Task; @@ -39,7 +33,8 @@ public TaskCompletionSource() : this(null, TaskCreationOptions.None) public void SetCanceled() => _source.SetCanceled(); - public void SetCanceled(CancellationToken cancellationToken) => _source.SetCanceled(cancellationToken); + public void SetCanceled(CancellationToken cancellationToken) => + _source.SetCanceled(cancellationToken); public bool TrySetResult() => _source.TrySetResult(null); @@ -47,7 +42,8 @@ public TaskCompletionSource() : this(null, TaskCreationOptions.None) public bool TrySetCanceled() => _source.TrySetCanceled(); - public bool TrySetCanceled(CancellationToken cancellationToken) => _source.TrySetCanceled(cancellationToken); + public bool TrySetCanceled(CancellationToken cancellationToken) => + _source.TrySetCanceled(cancellationToken); } #endif -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net50/TaskCompletionSourceOfT.cs b/PolyShim/Net50/TaskCompletionSourceOfT.cs index a11a2a8..44251c3 100644 --- a/PolyShim/Net50/TaskCompletionSourceOfT.cs +++ b/PolyShim/Net50/TaskCompletionSourceOfT.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_TASK +#if FEATURE_TASK #if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective @@ -21,9 +18,11 @@ internal static partial class PolyfillExtensions public void SetCanceled(CancellationToken cancellationToken) { if (!source.TrySetCanceled(cancellationToken)) - throw new InvalidOperationException("The task is already completed, canceled, or failed."); + throw new InvalidOperationException( + "The task is already completed, canceled, or failed." + ); } } } #endif -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net50/Type.cs b/PolyShim/Net50/Type.cs index 2d61cb1..73beeec 100644 --- a/PolyShim/Net50/Type.cs +++ b/PolyShim/Net50/Type.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -16,8 +13,7 @@ internal static partial class PolyfillExtensions extension(Type type) { // https://learn.microsoft.com/dotnet/api/system.type.isassignableto - public bool IsAssignableTo(Type? otherType) => - otherType?.IsAssignableFrom(type) == true; + public bool IsAssignableTo(Type? otherType) => otherType?.IsAssignableFrom(type) == true; } } #endif diff --git a/PolyShim/Net50/UnconditionalSuppressMessageAttribute.cs b/PolyShim/Net50/UnconditionalSuppressMessageAttribute.cs index 6d70127..dd696fa 100644 --- a/PolyShim/Net50/UnconditionalSuppressMessageAttribute.cs +++ b/PolyShim/Net50/UnconditionalSuppressMessageAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net50/UnsupportedOSPlatformAttribute.cs b/PolyShim/Net50/UnsupportedOSPlatformAttribute.cs index 8d1ce0a..b4df195 100644 --- a/PolyShim/Net50/UnsupportedOSPlatformAttribute.cs +++ b/PolyShim/Net50/UnsupportedOSPlatformAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET5_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net60/ArgumentNullException.cs b/PolyShim/Net60/ArgumentNullException.cs index ae13e10..97c0b05 100644 --- a/PolyShim/Net60/ArgumentNullException.cs +++ b/PolyShim/Net60/ArgumentNullException.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -16,11 +13,14 @@ internal static partial class PolyfillExtensions extension(ArgumentNullException) { // https://learn.microsoft.com/dotnet/api/system.argumentnullexception.throwifnull#system-argumentnullexception-throwifnull(system-object-system-string) - public static void ThrowIfNull(object? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) + public static void ThrowIfNull( + object? argument, + [CallerArgumentExpression(nameof(argument))] string? paramName = null + ) { if (argument is null) throw new ArgumentNullException(paramName); } } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net60/EnumerableExtensions.cs b/PolyShim/Net60/EnumerableExtensions.cs index 3b49423..01da98e 100644 --- a/PolyShim/Net60/EnumerableExtensions.cs +++ b/PolyShim/Net60/EnumerableExtensions.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,13 +14,13 @@ internal static partial class PolyfillExtensions extension(IEnumerable source) { // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.elementat#system-linq-enumerable-elementat-1(system-collections-generic-ienumerable((-0))-system-index) - public T ElementAt( Index index) + public T ElementAt(Index index) { if (index.IsFromEnd) { var asCollection = #if NETFRAMEWORK && !NET45_OR_GREATER - source as ICollection ?? + source as ICollection ?? #else source as IReadOnlyCollection ?? #endif @@ -38,13 +35,13 @@ source as IReadOnlyCollection ?? } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.elementatordefault#system-linq-enumerable-elementatordefault-1(system-collections-generic-ienumerable((-0))-system-index) - public T? ElementAtOrDefault( Index index) + public T? ElementAtOrDefault(Index index) { if (index.IsFromEnd) { var asCollection = #if NETFRAMEWORK && !NET45_OR_GREATER - source as ICollection ?? + source as ICollection ?? #else source as IReadOnlyCollection ?? #endif @@ -59,7 +56,7 @@ source as IReadOnlyCollection ?? } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.firstordefault#system-linq-enumerable-firstordefault-1(system-collections-generic-ienumerable((-0))-0) - public T FirstOrDefault( T defaultValue) + public T FirstOrDefault(T defaultValue) { foreach (var item in source) return item; @@ -68,11 +65,7 @@ public T FirstOrDefault( T defaultValue) } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.firstordefault#system-linq-enumerable-firstordefault-1(system-collections-generic-ienumerable((-0))-system-func((-0-system-boolean))-0) - public T FirstOrDefault( - - Func predicate, - T defaultValue - ) + public T FirstOrDefault(Func predicate, T defaultValue) { foreach (var item in source) { @@ -84,7 +77,7 @@ T defaultValue } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.lastordefault#system-linq-enumerable-lastordefault-1(system-collections-generic-ienumerable((-0))-0) - public T LastOrDefault( T defaultValue) + public T LastOrDefault(T defaultValue) { var result = defaultValue; @@ -95,11 +88,7 @@ public T LastOrDefault( T defaultValue) } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.lastordefault#system-linq-enumerable-lastordefault-1(system-collections-generic-ienumerable((-0))-system-func((-0-system-boolean))-0) - public T LastOrDefault( - - Func predicate, - T defaultValue - ) + public T LastOrDefault(Func predicate, T defaultValue) { var result = defaultValue; @@ -113,7 +102,7 @@ T defaultValue } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.singleordefault#system-linq-enumerable-singleordefault-1(system-collections-generic-ienumerable((-0))-0) - public T SingleOrDefault( T defaultValue) + public T SingleOrDefault(T defaultValue) { var result = defaultValue; var isResultSet = false; @@ -131,11 +120,7 @@ public T SingleOrDefault( T defaultValue) } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.singleordefault#system-linq-enumerable-singleordefault-1(system-collections-generic-ienumerable((-0))-system-func((-0-system-boolean))-0) - public T SingleOrDefault( - - Func predicate, - T defaultValue - ) + public T SingleOrDefault(Func predicate, T defaultValue) { var result = defaultValue; var isResultSet = false; @@ -145,7 +130,9 @@ T defaultValue if (predicate(item)) { if (isResultSet) - throw new InvalidOperationException("Sequence contains more than one element."); + throw new InvalidOperationException( + "Sequence contains more than one element." + ); result = item; isResultSet = true; @@ -156,11 +143,11 @@ T defaultValue } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.take#system-linq-enumerable-take-1(system-collections-generic-ienumerable((-0))-system-range) - public IEnumerable Take( Range range) + public IEnumerable Take(Range range) { var asCollection = #if NETFRAMEWORK && !NET45_OR_GREATER - source as ICollection ?? + source as ICollection ?? #else source as IReadOnlyCollection ?? #endif @@ -172,51 +159,40 @@ source as IReadOnlyCollection ?? } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.min#system-linq-enumerable-min-1(system-collections-generic-ienumerable((-0))-system-collections-generic-icomparer((-0))) - public T? Min( IComparer? comparer) => - source.OrderBy(x => x, comparer).FirstOrDefault(); + public T? Min(IComparer? comparer) => source.OrderBy(x => x, comparer).FirstOrDefault(); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.minby#system-linq-enumerable-minby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1))-system-collections-generic-icomparer((-1))) - public T? MinBy( - - Func keySelector, - IComparer? comparer - ) => source.OrderBy(keySelector, comparer).FirstOrDefault(); + public T? MinBy(Func keySelector, IComparer? comparer) => + source.OrderBy(keySelector, comparer).FirstOrDefault(); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.minby#system-linq-enumerable-minby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1))) - public T? MinBy( Func keySelector) => + public T? MinBy(Func keySelector) => source.MinBy(keySelector, Comparer.Default); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.max#system-linq-enumerable-max-1(system-collections-generic-ienumerable((-0))-system-collections-generic-icomparer((-0))) - public T? Max( IComparer? comparer) => + public T? Max(IComparer? comparer) => source.OrderByDescending(x => x, comparer).FirstOrDefault(); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.maxby#system-linq-enumerable-maxby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1))-system-collections-generic-icomparer((-1))) - public T? MaxBy( - - Func keySelector, - IComparer? comparer - ) => source.OrderByDescending(keySelector, comparer).FirstOrDefault(); + public T? MaxBy(Func keySelector, IComparer? comparer) => + source.OrderByDescending(keySelector, comparer).FirstOrDefault(); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.maxby#system-linq-enumerable-maxby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1))) - public T? MaxBy( Func keySelector) => + public T? MaxBy(Func keySelector) => source.MaxBy(keySelector, Comparer.Default); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.distinctby#system-linq-enumerable-distinctby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1))-system-collections-generic-iequalitycomparer((-1))) public IEnumerable DistinctBy( - Func keySelector, IEqualityComparer? comparer ) => source.GroupBy(keySelector, comparer).Select(x => x.First()); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.distinctby#system-linq-enumerable-distinctby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1))) - public IEnumerable DistinctBy( - - Func keySelector - ) => source.DistinctBy(keySelector, EqualityComparer.Default); + public IEnumerable DistinctBy(Func keySelector) => + source.DistinctBy(keySelector, EqualityComparer.Default); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.exceptby#system-linq-enumerable-exceptby-2(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-1))-system-func((-0-1))-system-collections-generic-iequalitycomparer((-1))) public IEnumerable ExceptBy( - IEnumerable other, Func keySelector, IEqualityComparer? comparer @@ -232,15 +208,11 @@ public IEnumerable ExceptBy( } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.exceptby#system-linq-enumerable-exceptby-2(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-1))-system-func((-0-1))) - public IEnumerable ExceptBy( - - IEnumerable other, - Func keySelector - ) => source.ExceptBy(other, keySelector, EqualityComparer.Default); + public IEnumerable ExceptBy(IEnumerable other, Func keySelector) => + source.ExceptBy(other, keySelector, EqualityComparer.Default); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.intersectby#system-linq-enumerable-intersectby-2(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-1))-system-func((-0-1))-system-collections-generic-iequalitycomparer((-1))) public IEnumerable IntersectBy( - IEnumerable other, Func keySelector, IEqualityComparer? comparer @@ -257,14 +229,12 @@ public IEnumerable IntersectBy( // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.intersectby#system-linq-enumerable-intersectby-2(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-1))-system-func((-0-1))) public IEnumerable IntersectBy( - IEnumerable other, Func keySelector ) => source.IntersectBy(other, keySelector, EqualityComparer.Default); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.unionby#system-linq-enumerable-unionby-2(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-func((-0-1))-system-collections-generic-iequalitycomparer((-1))) public IEnumerable UnionBy( - IEnumerable other, Func keySelector, IEqualityComparer? comparer @@ -286,14 +256,11 @@ public IEnumerable UnionBy( } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.unionby#system-linq-enumerable-unionby-2(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-func((-0-1))) - public IEnumerable UnionBy( - - IEnumerable other, - Func keySelector - ) => source.UnionBy(other, keySelector, EqualityComparer.Default); + public IEnumerable UnionBy(IEnumerable other, Func keySelector) => + source.UnionBy(other, keySelector, EqualityComparer.Default); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.chunk - public IEnumerable Chunk( int size) + public IEnumerable Chunk(int size) { var chunk = new List(size); foreach (var item in source) diff --git a/PolyShim/Net60/Environment.cs b/PolyShim/Net60/Environment.cs index c0f4c27..23a3454 100644 --- a/PolyShim/Net60/Environment.cs +++ b/PolyShim/Net60/Environment.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -15,7 +12,7 @@ internal static partial class PolyfillExtensions { extension(Environment) { -// No Process class in .NET Standard 1.x + // No Process class in .NET Standard 1.x #if !NETSTANDARD || NETSTANDARD2_0_OR_GREATER // https://learn.microsoft.com/dotnet/api/system.environment.processpath public static string? ProcessPath @@ -36,4 +33,4 @@ public static string? ProcessPath #endif } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net60/Math.cs b/PolyShim/Net60/Math.cs index 363daf9..1e44e44 100644 --- a/PolyShim/Net60/Math.cs +++ b/PolyShim/Net60/Math.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -31,4 +28,4 @@ public static IntPtr Clamp(IntPtr value, IntPtr min, IntPtr max) } } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net60/Random.cs b/PolyShim/Net60/Random.cs index d33eaf0..ec317dc 100644 --- a/PolyShim/Net60/Random.cs +++ b/PolyShim/Net60/Random.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -21,4 +18,4 @@ internal static partial class PolyfillExtensions public static Random Shared => _threadRandom ??= new Random(); } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net60/RequiresAssemblyFilesAttribute.cs b/PolyShim/Net60/RequiresAssemblyFilesAttribute.cs index 977ffd5..9d64e3d 100644 --- a/PolyShim/Net60/RequiresAssemblyFilesAttribute.cs +++ b/PolyShim/Net60/RequiresAssemblyFilesAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net60/String.cs b/PolyShim/Net60/String.cs index 508fee3..2d9a3fa 100644 --- a/PolyShim/Net60/String.cs +++ b/PolyShim/Net60/String.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -21,8 +18,7 @@ public string ReplaceLineEndings(string replacementText) => .Replace("\n", replacementText, StringComparison.Ordinal); // https://learn.microsoft.com/dotnet/api/system.string.replacelineendings#system-string-replacelineendings - public string ReplaceLineEndings() => - str.ReplaceLineEndings(Environment.NewLine); + public string ReplaceLineEndings() => str.ReplaceLineEndings(Environment.NewLine); } } #endif diff --git a/PolyShim/Net60/SupportedOSPlatformGuardAttribute.cs b/PolyShim/Net60/SupportedOSPlatformGuardAttribute.cs index ec3da70..a15ef5a 100644 --- a/PolyShim/Net60/SupportedOSPlatformGuardAttribute.cs +++ b/PolyShim/Net60/SupportedOSPlatformGuardAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net60/Task.cs b/PolyShim/Net60/Task.cs index 642efb2..e101010 100644 --- a/PolyShim/Net60/Task.cs +++ b/PolyShim/Net60/Task.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_TASK +#if FEATURE_TASK #if (NETCOREAPP && !NET6_0_OR_GREATER) || (NET45_OR_GREATER) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective diff --git a/PolyShim/Net60/UnsupportedOSPlatformGuardAttribute.cs b/PolyShim/Net60/UnsupportedOSPlatformGuardAttribute.cs index 14fadb3..8e92d2c 100644 --- a/PolyShim/Net60/UnsupportedOSPlatformGuardAttribute.cs +++ b/PolyShim/Net60/UnsupportedOSPlatformGuardAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net70/ArgumentException.cs b/PolyShim/Net70/ArgumentException.cs index 396cef0..62277be 100644 --- a/PolyShim/Net70/ArgumentException.cs +++ b/PolyShim/Net70/ArgumentException.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -16,7 +13,10 @@ internal static partial class PolyfillExtensions extension(ArgumentException) { // https://learn.microsoft.com/dotnet/api/system.argumentexception.throwifnullorempty - public static void ThrowIfNullOrEmpty(string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) + public static void ThrowIfNullOrEmpty( + string? argument, + [CallerArgumentExpression(nameof(argument))] string? paramName = null + ) { if (argument is null) throw new ArgumentNullException(paramName); @@ -26,13 +26,19 @@ public static void ThrowIfNullOrEmpty(string? argument, [CallerArgumentExpressio } // https://learn.microsoft.com/dotnet/api/system.argumentexception.throwifnullorwhitespace - public static void ThrowIfNullOrWhiteSpace(string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) + public static void ThrowIfNullOrWhiteSpace( + string? argument, + [CallerArgumentExpression(nameof(argument))] string? paramName = null + ) { if (argument is null) throw new ArgumentNullException(paramName); if (string.IsNullOrWhiteSpace(argument)) - throw new ArgumentException("The value cannot be an empty string or composed entirely of whitespace.", paramName); + throw new ArgumentException( + "The value cannot be an empty string or composed entirely of whitespace.", + paramName + ); } } } diff --git a/PolyShim/Net70/CompilerFeatureRequiredAttribute.cs b/PolyShim/Net70/CompilerFeatureRequiredAttribute.cs index 813aaaa..fb735c3 100644 --- a/PolyShim/Net70/CompilerFeatureRequiredAttribute.cs +++ b/PolyShim/Net70/CompilerFeatureRequiredAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net70/EnumerableExtensions.cs b/PolyShim/Net70/EnumerableExtensions.cs index 7af5103..8d5e252 100644 --- a/PolyShim/Net70/EnumerableExtensions.cs +++ b/PolyShim/Net70/EnumerableExtensions.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,11 +14,11 @@ internal static partial class PolyfillExtensions extension(IEnumerable source) { // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.order#system-linq-enumerable-order-1(system-collections-generic-ienumerable((-0))-system-collections-generic-icomparer((-0))) - public IOrderedEnumerable Order(IComparer? comparer) => source.OrderBy(x => x, comparer); + public IOrderedEnumerable Order(IComparer? comparer) => + source.OrderBy(x => x, comparer); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.order#system-linq-enumerable-order-1(system-collections-generic-ienumerable((-0))) - public IOrderedEnumerable Order() => - source.Order(Comparer.Default); + public IOrderedEnumerable Order() => source.Order(Comparer.Default); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.orderdescending#system-linq-enumerable-orderdescending-1(system-collections-generic-ienumerable((-0))-system-collections-generic-icomparer((-0))) public IOrderedEnumerable OrderDescending(IComparer? comparer) => diff --git a/PolyShim/Net70/LibraryImportAttribute.cs b/PolyShim/Net70/LibraryImportAttribute.cs index 2a79a1a..81289c7 100644 --- a/PolyShim/Net70/LibraryImportAttribute.cs +++ b/PolyShim/Net70/LibraryImportAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net70/ObsoletedOSPlatformAttribute.cs b/PolyShim/Net70/ObsoletedOSPlatformAttribute.cs index 83f17f4..ca62bc0 100644 --- a/PolyShim/Net70/ObsoletedOSPlatformAttribute.cs +++ b/PolyShim/Net70/ObsoletedOSPlatformAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net70/RequiredMemberAttribute.cs b/PolyShim/Net70/RequiredMemberAttribute.cs index c3c48f4..5c6614c 100644 --- a/PolyShim/Net70/RequiredMemberAttribute.cs +++ b/PolyShim/Net70/RequiredMemberAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net70/RequiresDynamicCodeAttribute.cs b/PolyShim/Net70/RequiresDynamicCodeAttribute.cs index 947fba0..198cdec 100644 --- a/PolyShim/Net70/RequiresDynamicCodeAttribute.cs +++ b/PolyShim/Net70/RequiresDynamicCodeAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net70/SetsRequiredMembersAttribute.cs b/PolyShim/Net70/SetsRequiredMembersAttribute.cs index ca96c8b..8d59b65 100644 --- a/PolyShim/Net70/SetsRequiredMembersAttribute.cs +++ b/PolyShim/Net70/SetsRequiredMembersAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net70/Stream.cs b/PolyShim/Net70/Stream.cs index 8d6cf12..4140a23 100644 --- a/PolyShim/Net70/Stream.cs +++ b/PolyShim/Net70/Stream.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -19,11 +16,7 @@ internal static partial class PolyfillExtensions { // Signature-compatible replacement for ReadAtLeast(Span, ...) // https://learn.microsoft.com/dotnet/api/system.io.stream.readatleast - public int ReadAtLeast( - byte[] buffer, - int minimumBytes, - bool throwOnEndOfStream = true - ) + public int ReadAtLeast(byte[] buffer, int minimumBytes, bool throwOnEndOfStream = true) { var totalBytesRead = 0; while (totalBytesRead < buffer.Length) @@ -47,12 +40,16 @@ public int ReadAtLeast( } // https://learn.microsoft.com/dotnet/api/system.io.stream.readexactly#system-io-stream-readexactly(system-byte()-system-int32-system-int32) - public void ReadExactly( byte[] buffer, int offset, int count) + public void ReadExactly(byte[] buffer, int offset, int count) { var totalBytesRead = 0; while (totalBytesRead < count) { - var bytesRead = stream.Read(buffer, offset + totalBytesRead, count - totalBytesRead); + var bytesRead = stream.Read( + buffer, + offset + totalBytesRead, + count - totalBytesRead + ); if (bytesRead <= 0) throw new EndOfStreamException(); @@ -63,8 +60,7 @@ public void ReadExactly( byte[] buffer, int offset, int count) // Signature-compatible replacement for ReadExactly(Span) // https://learn.microsoft.com/dotnet/api/system.io.stream.readexactly#system-io-stream-readexactly(system-span((system-byte))) - public void ReadExactly( byte[] buffer) => - stream.ReadExactly(buffer, 0, buffer.Length); + public void ReadExactly(byte[] buffer) => stream.ReadExactly(buffer, 0, buffer.Length); #if FEATURE_TASK // Signature-compatible replacement for ReadAtLeastAsync(Memory, ...) @@ -129,7 +125,10 @@ public async Task ReadExactlyAsync( // Signature-compatible replacement for ReadExactlyAsync(Memory, ...) // https://learn.microsoft.com/dotnet/api/system.io.stream.readexactlyasync#system-io-stream-readexactlyasync(system-memory((system-byte))-system-threading-cancellationtoken) - public async Task ReadExactlyAsync(byte[] buffer, CancellationToken cancellationToken = default) => + public async Task ReadExactlyAsync( + byte[] buffer, + CancellationToken cancellationToken = default + ) => await stream .ReadExactlyAsync(buffer, 0, buffer.Length, cancellationToken) .ConfigureAwait(false); @@ -137,11 +136,7 @@ await stream #if FEATURE_MEMORY // https://learn.microsoft.com/dotnet/api/system.io.stream.readatleast - public int ReadAtLeast( - Span buffer, - int minimumBytes, - bool throwOnEndOfStream = true - ) + public int ReadAtLeast(Span buffer, int minimumBytes, bool throwOnEndOfStream = true) { var totalBytesRead = 0; while (totalBytesRead < buffer.Length) @@ -160,7 +155,7 @@ public int ReadAtLeast( } // https://learn.microsoft.com/dotnet/api/system.io.stream.readexactly#system-io-stream-readexactly(system-byte()-system-int32-system-int32) - public void ReadExactly( Span buffer) + public void ReadExactly(Span buffer) { var bufferArray = buffer.ToArray(); stream.ReadExactly(bufferArray, 0, bufferArray.Length); diff --git a/PolyShim/Net70/StringMarshalling.cs b/PolyShim/Net70/StringMarshalling.cs index c825dfd..2e6a7e8 100644 --- a/PolyShim/Net70/StringMarshalling.cs +++ b/PolyShim/Net70/StringMarshalling.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,6 +14,6 @@ internal enum StringMarshalling { Custom = 0, Utf8, - Utf16 + Utf16, } #endif diff --git a/PolyShim/Net70/StringSyntaxAttribute.cs b/PolyShim/Net70/StringSyntaxAttribute.cs index d5d0bfd..d8992f3 100644 --- a/PolyShim/Net70/StringSyntaxAttribute.cs +++ b/PolyShim/Net70/StringSyntaxAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/Net80/CancellationTokenSource.cs b/PolyShim/Net80/CancellationTokenSource.cs index d5f913a..d28a3be 100644 --- a/PolyShim/Net80/CancellationTokenSource.cs +++ b/PolyShim/Net80/CancellationTokenSource.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_TASK +#if FEATURE_TASK #if (NETCOREAPP && !NET8_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective diff --git a/PolyShim/Net90/EnumerableExtensions.cs b/PolyShim/Net90/EnumerableExtensions.cs index b43ddbe..2cea1d0 100644 --- a/PolyShim/Net90/EnumerableExtensions.cs +++ b/PolyShim/Net90/EnumerableExtensions.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -21,7 +18,8 @@ internal static partial class PolyfillExtensions source.Select((value, index) => (index, value)); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.countby - public IEnumerable> CountBy(Func keySelector, + public IEnumerable> CountBy( + Func keySelector, IEqualityComparer? comparer = null ) where TKey : notnull @@ -38,9 +36,8 @@ public IEnumerable> CountBy(Func keySelec } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.aggregateby#system-linq-enumerable-aggregateby-3(system-collections-generic-ienumerable((-0))-system-func((-0-1))-system-func((-1-2))-system-func((-2-0-2))-system-collections-generic-iequalitycomparer((-1))) - public IEnumerable> AggregateBy(Func keySelector, + public IEnumerable> AggregateBy( + Func keySelector, Func seedSelector, Func accumulator, IEqualityComparer? keyComparer = null @@ -63,9 +60,8 @@ public IEnumerable> CountBy(Func keySelec } // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.aggregateby#system-linq-enumerable-aggregateby-3(system-collections-generic-ienumerable((-0))-system-func((-0-1))-2-system-func((-2-0-2))-system-collections-generic-iequalitycomparer((-1))) - public IEnumerable> AggregateBy(Func keySelector, + public IEnumerable> AggregateBy( + Func keySelector, TAccumulate seed, Func accumulator, IEqualityComparer? keyComparer = null diff --git a/PolyShim/Net90/FeatureGuardAttribute.cs b/PolyShim/Net90/FeatureGuardAttribute.cs index ffabb07..d976edc 100644 --- a/PolyShim/Net90/FeatureGuardAttribute.cs +++ b/PolyShim/Net90/FeatureGuardAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable #pragma warning disable CS9216 // ReSharper disable RedundantUsingDirective @@ -13,9 +10,9 @@ namespace System.Diagnostics.CodeAnalysis; // https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.featureguardattribute [ExcludeFromCodeCoverage] -[AttributeUsage(AttributeTargets.Property, AllowMultiple=true)] +[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)] internal class FeatureGuardAttribute(Type featureType) : Attribute { public Type FeatureType { get; } = featureType; } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net90/FeatureSwitchDefinitionAttribute.cs b/PolyShim/Net90/FeatureSwitchDefinitionAttribute.cs index df7aa9f..9b4809e 100644 --- a/PolyShim/Net90/FeatureSwitchDefinitionAttribute.cs +++ b/PolyShim/Net90/FeatureSwitchDefinitionAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable #pragma warning disable CS9216 // ReSharper disable RedundantUsingDirective @@ -18,4 +15,4 @@ internal class FeatureSwitchDefinitionAttribute(string switchName) : Attribute { public string SwitchName { get; } = switchName; } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/Net90/File.cs b/PolyShim/Net90/File.cs index 1fc124d..eda5e3f 100644 --- a/PolyShim/Net90/File.cs +++ b/PolyShim/Net90/File.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -14,7 +11,7 @@ internal static partial class PolyfillExtensions { -// No file I/O on .NET Standard prior to 1.3 + // No file I/O on .NET Standard prior to 1.3 #if !NETSTANDARD || NETSTANDARD1_3_OR_GREATER extension(File) { diff --git a/PolyShim/Net90/Lock.cs b/PolyShim/Net90/Lock.cs index 9471417..66e36ab 100644 --- a/PolyShim/Net90/Lock.cs +++ b/PolyShim/Net90/Lock.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable #pragma warning disable CS9216 // ReSharper disable RedundantUsingDirective diff --git a/PolyShim/Net90/OverloadResolutionPriorityAttribute.cs b/PolyShim/Net90/OverloadResolutionPriorityAttribute.cs index 106e653..43e5b86 100644 --- a/PolyShim/Net90/OverloadResolutionPriorityAttribute.cs +++ b/PolyShim/Net90/OverloadResolutionPriorityAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NET9_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable #pragma warning disable CS9216 // ReSharper disable RedundantUsingDirective @@ -16,13 +13,11 @@ namespace System.Runtime.CompilerServices; // https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.overloadresolutionpriorityattribute [ExcludeFromCodeCoverage] [AttributeUsage( - AttributeTargets.Constructor - | AttributeTargets.Method - | AttributeTargets.Property, + AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, Inherited = false )] internal class OverloadResolutionPriorityAttribute(int priority) : Attribute { public int Priority { get; } = priority; } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore10/AggregateException.cs b/PolyShim/NetCore10/AggregateException.cs index af91220..5b106fb 100644 --- a/PolyShim/NetCore10/AggregateException.cs +++ b/PolyShim/NetCore10/AggregateException.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET40_OR_GREATER) +#if (NETFRAMEWORK && !NET40_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore10/AppContext.cs b/PolyShim/NetCore10/AppContext.cs index b608dcb..1342ba1 100644 --- a/PolyShim/NetCore10/AppContext.cs +++ b/PolyShim/NetCore10/AppContext.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET47_OR_GREATER) || (NETSTANDARD && !NETSTANDARD1_6_OR_GREATER) +#if (NETFRAMEWORK && !NET47_OR_GREATER) || (NETSTANDARD && !NETSTANDARD1_6_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -18,14 +15,15 @@ internal static partial class PolyfillExtensions { extension(AppContext) { -// No reflection on .NET Standard prior to 1.5 + // No reflection on .NET Standard prior to 1.5 #if !NETSTANDARD || NETSTANDARD1_5_OR_GREATER // https://learn.microsoft.com/dotnet/api/system.appcontext.targetframeworkname - public static string? TargetFrameworkName => (Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly()) - .GetCustomAttributes(true) - .OfType() - .FirstOrDefault()? - .FrameworkName; + public static string? TargetFrameworkName => + (Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly()) + .GetCustomAttributes(true) + .OfType() + .FirstOrDefault() + ?.FrameworkName; #endif } } @@ -38,4 +36,4 @@ namespace System internal static class AppContext; } #endif -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore10/EnumerableExtensions.cs b/PolyShim/NetCore10/EnumerableExtensions.cs index 8015b20..e290af3 100644 --- a/PolyShim/NetCore10/EnumerableExtensions.cs +++ b/PolyShim/NetCore10/EnumerableExtensions.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET471_OR_GREATER) || (NETSTANDARD && !NETSTANDARD1_6_OR_GREATER) +#if (NETFRAMEWORK && !NET471_OR_GREATER) || (NETSTANDARD && !NETSTANDARD1_6_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore10/ExtensionAttribute.cs b/PolyShim/NetCore10/ExtensionAttribute.cs index ba297fd..4911e6c 100644 --- a/PolyShim/NetCore10/ExtensionAttribute.cs +++ b/PolyShim/NetCore10/ExtensionAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET35_OR_GREATER) +#if (NETFRAMEWORK && !NET35_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore10/OSPlatform.cs b/PolyShim/NetCore10/OSPlatform.cs index b1c5a5c..f94193d 100644 --- a/PolyShim/NetCore10/OSPlatform.cs +++ b/PolyShim/NetCore10/OSPlatform.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if !FEATURE_RUNTIMEINFORMATION +#if !FEATURE_RUNTIMEINFORMATION #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore10/Path.cs b/PolyShim/NetCore10/Path.cs index fbebc1f..1396f94 100644 --- a/PolyShim/NetCore10/Path.cs +++ b/PolyShim/NetCore10/Path.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET40_OR_GREATER) +#if (NETFRAMEWORK && !NET40_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -20,4 +17,4 @@ public static string Combine(params string[] paths) => paths.Aggregate(string.Empty, Path.Combine); } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore10/RuntimeInformation.cs b/PolyShim/NetCore10/RuntimeInformation.cs index 6d02023..7f83a1d 100644 --- a/PolyShim/NetCore10/RuntimeInformation.cs +++ b/PolyShim/NetCore10/RuntimeInformation.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if !FEATURE_RUNTIMEINFORMATION +#if !FEATURE_RUNTIMEINFORMATION #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,7 +14,7 @@ namespace System.Runtime.InteropServices; [ExcludeFromCodeCoverage] internal static class RuntimeInformation { -// No way to detect on .NET Standard lower than 1.3 + // No way to detect on .NET Standard lower than 1.3 #if !(NETSTANDARD && !NETSTANDARD1_3_OR_GREATER) public static bool IsOSPlatform(OSPlatform osPlatform) { diff --git a/PolyShim/NetCore10/Stream.cs b/PolyShim/NetCore10/Stream.cs index b41a5bd..22ead75 100644 --- a/PolyShim/NetCore10/Stream.cs +++ b/PolyShim/NetCore10/Stream.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET40_OR_GREATER) +#if (NETFRAMEWORK && !NET40_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -29,8 +26,7 @@ public void CopyTo(Stream destination, int bufferSize) } // https://learn.microsoft.com/dotnet/api/system.io.stream.copyto#system-io-stream-copyto(system-io-stream) - public void CopyTo(Stream destination) => - source.CopyTo(destination, 81920); + public void CopyTo(Stream destination) => source.CopyTo(destination, 81920); } } #endif diff --git a/PolyShim/NetCore10/String.cs b/PolyShim/NetCore10/String.cs index cb00525..e60da93 100644 --- a/PolyShim/NetCore10/String.cs +++ b/PolyShim/NetCore10/String.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET40_OR_GREATER) +#if (NETFRAMEWORK && !NET40_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -20,4 +17,4 @@ public static bool IsNullOrWhiteSpace(string? value) => value is null || value.All(char.IsWhiteSpace); } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore10/TargetFrameworkAttribute.cs b/PolyShim/NetCore10/TargetFrameworkAttribute.cs index 418c4bd..d10502d 100644 --- a/PolyShim/NetCore10/TargetFrameworkAttribute.cs +++ b/PolyShim/NetCore10/TargetFrameworkAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET40_OR_GREATER) +#if (NETFRAMEWORK && !NET40_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -21,4 +18,4 @@ internal class TargetFrameworkAttribute(string frameworkName) : Attribute public string? FrameworkDisplayName { get; set; } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore10/Task.cs b/PolyShim/NetCore10/Task.cs index 3140bd3..014014f 100644 --- a/PolyShim/NetCore10/Task.cs +++ b/PolyShim/NetCore10/Task.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_TASK +#if FEATURE_TASK #if (NETFRAMEWORK && !NET46_OR_GREATER) || (NETSTANDARD && !NETSTANDARD1_3_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective @@ -33,4 +30,4 @@ internal static partial class PolyfillExtensions } } #endif -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore10/TaskCompletionSource.cs b/PolyShim/NetCore10/TaskCompletionSource.cs index 08bb882..5bd27bb 100644 --- a/PolyShim/NetCore10/TaskCompletionSource.cs +++ b/PolyShim/NetCore10/TaskCompletionSource.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_TASK +#if FEATURE_TASK #if (NETFRAMEWORK && !NET46_OR_GREATER) || (NETSTANDARD && !NETSTANDARD1_3_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective diff --git a/PolyShim/NetCore10/Version.cs b/PolyShim/NetCore10/Version.cs index 7631693..e211965 100644 --- a/PolyShim/NetCore10/Version.cs +++ b/PolyShim/NetCore10/Version.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETFRAMEWORK && !NET40_OR_GREATER) +#if (NETFRAMEWORK && !NET40_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -36,4 +33,4 @@ public static bool TryParse(string? input, out Version? result) } } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore20/CollectionExtensions.cs b/PolyShim/NetCore20/CollectionExtensions.cs index 24b5a94..897814c 100644 --- a/PolyShim/NetCore20/CollectionExtensions.cs +++ b/PolyShim/NetCore20/CollectionExtensions.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -18,13 +15,11 @@ IDictionary dictionary #else IReadOnlyDictionary dictionary #endif - ) + ) { // https://learn.microsoft.com/dotnet/api/system.collections.generic.collectionextensions.getvalueordefault#system-collections-generic-collectionextensions-getvalueordefault-2(system-collections-generic-ireadonlydictionary((-0-1))-0-1) - public TValue? GetValueOrDefault( - TKey key, - TValue? defaultValue - ) => dictionary.TryGetValue(key, out var value) ? value : defaultValue; + public TValue? GetValueOrDefault(TKey key, TValue? defaultValue) => + dictionary.TryGetValue(key, out var value) ? value : defaultValue; // https://learn.microsoft.com/dotnet/api/system.collections.generic.collectionextensions.getvalueordefault#system-collections-generic-collectionextensions-getvalueordefault-2(system-collections-generic-ireadonlydictionary((-0-1))-0) public TValue? GetValueOrDefault(TKey key) => dictionary.GetValueOrDefault(key, default); diff --git a/PolyShim/NetCore20/DictionaryEntry.cs b/PolyShim/NetCore20/DictionaryEntry.cs index 9842023..3113964 100644 --- a/PolyShim/NetCore20/DictionaryEntry.cs +++ b/PolyShim/NetCore20/DictionaryEntry.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore20/EnumerableExtensions.cs b/PolyShim/NetCore20/EnumerableExtensions.cs index ff4af35..63f3fef 100644 --- a/PolyShim/NetCore20/EnumerableExtensions.cs +++ b/PolyShim/NetCore20/EnumerableExtensions.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,20 +14,17 @@ internal static partial class PolyfillExtensions extension(IEnumerable source) { // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.takelast - public IEnumerable TakeLast(int count) => - source.Reverse().Take(count).Reverse(); + public IEnumerable TakeLast(int count) => source.Reverse().Take(count).Reverse(); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.skiplast - public IEnumerable SkipLast(int count) => - source.Reverse().Skip(count).Reverse(); + public IEnumerable SkipLast(int count) => source.Reverse().Skip(count).Reverse(); #if !NET472_OR_GREATER // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.tohashset#system-linq-enumerable-tohashset-1(system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0))) public HashSet ToHashSet(IEqualityComparer comparer) => new(source, comparer); // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.tohashset#system-linq-enumerable-tohashset-1(system-collections-generic-ienumerable((-0))) - public HashSet ToHashSet() => - source.ToHashSet(EqualityComparer.Default); + public HashSet ToHashSet() => source.ToHashSet(EqualityComparer.Default); #endif } } diff --git a/PolyShim/NetCore20/ExcludeFromCodeCoverageAttribute.cs b/PolyShim/NetCore20/ExcludeFromCodeCoverageAttribute.cs index d942373..5e73cb8 100644 --- a/PolyShim/NetCore20/ExcludeFromCodeCoverageAttribute.cs +++ b/PolyShim/NetCore20/ExcludeFromCodeCoverageAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK && !NET40_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK && !NET40_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore20/File.cs b/PolyShim/NetCore20/File.cs index d18cb83..c62c15d 100644 --- a/PolyShim/NetCore20/File.cs +++ b/PolyShim/NetCore20/File.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -16,7 +13,7 @@ internal static partial class PolyfillExtensions { -// No file I/O on .NET Standard prior to 1.3 + // No file I/O on .NET Standard prior to 1.3 #if !NETSTANDARD || NETSTANDARD1_3_OR_GREATER extension(File) { @@ -233,4 +230,4 @@ public static async Task WriteAllTextAsync(string path, string contents, Encodin } #endif } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore20/KeyValuePair.cs b/PolyShim/NetCore20/KeyValuePair.cs index 2b30f0d..8e628ee 100644 --- a/PolyShim/NetCore20/KeyValuePair.cs +++ b/PolyShim/NetCore20/KeyValuePair.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore20/MatchCollection.cs b/PolyShim/NetCore20/MatchCollection.cs index c066002..47999d1 100644 --- a/PolyShim/NetCore20/MatchCollection.cs +++ b/PolyShim/NetCore20/MatchCollection.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -20,14 +17,11 @@ internal static partial class PolyfillExtensions extension(MatchCollection matchCollection) { // https://learn.microsoft.com/dotnet/api/system.text.regularexpressions.matchcollection.system-collections-generic-ienumerable-system-text-regularexpressions-match--getenumerator - public IEnumerable AsEnumerable() => - matchCollection.Cast(); + public IEnumerable AsEnumerable() => matchCollection.Cast(); - public IEnumerator GetEnumerator() => - matchCollection.AsEnumerable().GetEnumerator(); + public IEnumerator GetEnumerator() => matchCollection.AsEnumerable().GetEnumerator(); - public Match[] ToArray() => - matchCollection.AsEnumerable().ToArray(); + public Match[] ToArray() => matchCollection.AsEnumerable().ToArray(); } } #endif diff --git a/PolyShim/NetCore20/Math.cs b/PolyShim/NetCore20/Math.cs index 5b259f7..b9f3788 100644 --- a/PolyShim/NetCore20/Math.cs +++ b/PolyShim/NetCore20/Math.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,7 +14,8 @@ internal static partial class PolyfillExtensions // https://learn.microsoft.com/dotnet/api/system.math.clamp // Technically, the original implementation has overloads for each separate numeric type, // but this generic version is fully source-compatible and simpler to maintain. - public static T Clamp(T value, T min, T max) where T : IComparable + public static T Clamp(T value, T min, T max) + where T : IComparable { if (value.CompareTo(min) < 0) return min; diff --git a/PolyShim/NetCore20/OperatingSystem.cs b/PolyShim/NetCore20/OperatingSystem.cs index ac839f4..0642b70 100644 --- a/PolyShim/NetCore20/OperatingSystem.cs +++ b/PolyShim/NetCore20/OperatingSystem.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,4 +14,4 @@ namespace System; internal class OperatingSystem; // This should include members, but currently this polyfill is incomplete and // serves only as a placeholder so that polyfills for static methods have a type to extend. -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore20/Path.cs b/PolyShim/NetCore20/Path.cs index a2a6519..935e23c 100644 --- a/PolyShim/NetCore20/Path.cs +++ b/PolyShim/NetCore20/Path.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,7 +14,7 @@ internal static partial class PolyfillExtensions { extension(Path) { -// Can only detect the platform on .NET Standard 1.3+ + // Can only detect the platform on .NET Standard 1.3+ #if !NETSTANDARD || NETSTANDARD1_3_OR_GREATER // https://learn.microsoft.com/dotnet/api/system.io.path.getrelativepath public static string GetRelativePath(string relativeTo, string path) @@ -26,13 +23,17 @@ public static string GetRelativePath(string relativeTo, string path) ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; - var basePathSegments = relativeTo.Split( - Path.DirectorySeparatorChar, - Path.AltDirectorySeparatorChar - ).Where(s => !string.IsNullOrEmpty(s)).ToArray(); + var basePathSegments = relativeTo + .Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) + .Where(s => !string.IsNullOrEmpty(s)) + .ToArray(); - var pathSegments = path.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) - .Where(s => !string.IsNullOrEmpty(s)).ToArray(); + var pathSegments = path.Split( + Path.DirectorySeparatorChar, + Path.AltDirectorySeparatorChar + ) + .Where(s => !string.IsNullOrEmpty(s)) + .ToArray(); var commonSegmentsCount = 0; for (var i = 0; i < basePathSegments.Length && i < pathSegments.Length; i++) @@ -44,13 +45,20 @@ public static string GetRelativePath(string relativeTo, string path) } // All segments are common, return "." - if (commonSegmentsCount == basePathSegments.Length && commonSegmentsCount == pathSegments.Length) + if ( + commonSegmentsCount == basePathSegments.Length + && commonSegmentsCount == pathSegments.Length + ) { return "."; } // No segments are common and the first segment is a disk label, return the original path - if (commonSegmentsCount == 0 && pathSegments.Length > 0 && pathSegments[0].EndsWith(":", StringComparison.Ordinal)) + if ( + commonSegmentsCount == 0 + && pathSegments.Length > 0 + && pathSegments[0].EndsWith(":", StringComparison.Ordinal) + ) { return path; } diff --git a/PolyShim/NetCore20/String.cs b/PolyShim/NetCore20/String.cs index a4f1b95..33dddc3 100644 --- a/PolyShim/NetCore20/String.cs +++ b/PolyShim/NetCore20/String.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -26,10 +23,7 @@ internal static partial class PolyfillExtensions public bool Contains(char c) => str.IndexOf(c) >= 0; // https://learn.microsoft.com/dotnet/api/system.string.replace#system-string-replace(system-string-system-string-system-stringcomparison) - public string Replace(string oldValue, - string? newValue, - StringComparison comparison - ) + public string Replace(string oldValue, string? newValue, StringComparison comparison) { var buffer = new StringBuilder(); @@ -55,7 +49,8 @@ StringComparison comparison } // https://learn.microsoft.com/dotnet/api/system.string.replace#system-string-replace(system-string-system-string-system-boolean-system-globalization-cultureinfo) - public string Replace(string oldValue, + public string Replace( + string oldValue, string? newValue, bool ignoreCase, CultureInfo? culture @@ -91,24 +86,28 @@ public string Replace(string oldValue, } // https://learn.microsoft.com/dotnet/api/system.string.split#system-string-split(system-char-system-int32-system-stringsplitoptions) - public string[] Split(char separator, + public string[] Split( + char separator, int count, StringSplitOptions options = StringSplitOptions.None ) => str.Split([separator], count, options); // https://learn.microsoft.com/dotnet/api/system.string.split#system-string-split(system-char-system-stringsplitoptions) - public string[] Split(char separator, + public string[] Split( + char separator, StringSplitOptions options = StringSplitOptions.None ) => str.Split([separator], options); // https://learn.microsoft.com/dotnet/api/system.string.split#system-string-split(system-string-system-int32-system-stringsplitoptions) - public string[] Split(string? separator, + public string[] Split( + string? separator, int count, StringSplitOptions options = StringSplitOptions.None ) => str.Split([separator ?? ""], count, options); // https://learn.microsoft.com/dotnet/api/system.string.split#system-string-split(system-string-system-stringsplitoptions) - public string[] Split(string? separator, + public string[] Split( + string? separator, StringSplitOptions options = StringSplitOptions.None ) => str.Split([separator ?? ""], options); } diff --git a/PolyShim/NetCore20/SystemException.cs b/PolyShim/NetCore20/SystemException.cs index bf4f07c..53e2c7b 100644 --- a/PolyShim/NetCore20/SystemException.cs +++ b/PolyShim/NetCore20/SystemException.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore20/Task.cs b/PolyShim/NetCore20/Task.cs index 0a728bf..012f3b3 100644 --- a/PolyShim/NetCore20/Task.cs +++ b/PolyShim/NetCore20/Task.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if FEATURE_TASK +#if FEATURE_TASK #if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective @@ -19,9 +16,8 @@ internal static partial class PolyfillExtensions extension(Task task) { // https://learn.microsoft.com/dotnet/api/system.threading.tasks.task.iscompletedsuccessfully - public bool IsCompletedSuccessfully => - task.Status == TaskStatus.RanToCompletion; + public bool IsCompletedSuccessfully => task.Status == TaskStatus.RanToCompletion; } } #endif -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore20/ThreadAbortException.cs b/PolyShim/NetCore20/ThreadAbortException.cs index b4de45d..d2d860b 100644 --- a/PolyShim/NetCore20/ThreadAbortException.cs +++ b/PolyShim/NetCore20/ThreadAbortException.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore20/TupleElementNamesAttribute.cs b/PolyShim/NetCore20/TupleElementNamesAttribute.cs index 5ce46e0..96be63d 100644 --- a/PolyShim/NetCore20/TupleElementNamesAttribute.cs +++ b/PolyShim/NetCore20/TupleElementNamesAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if !FEATURE_VALUETUPLE +#if !FEATURE_VALUETUPLE #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore20/Type.cs b/PolyShim/NetCore20/Type.cs index 5a3783c..ba328a7 100644 --- a/PolyShim/NetCore20/Type.cs +++ b/PolyShim/NetCore20/Type.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_0_OR_GREATER) || (NETSTANDARD && !NETSTANDARD2_0_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore20/ValueTuple.cs b/PolyShim/NetCore20/ValueTuple.cs index f45bf1e..f7d9786 100644 --- a/PolyShim/NetCore20/ValueTuple.cs +++ b/PolyShim/NetCore20/ValueTuple.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if !FEATURE_VALUETUPLE +#if !FEATURE_VALUETUPLE #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -28,7 +25,7 @@ public int CompareTo(object? obj) => { null => 1, ValueTuple => 0, - _ => throw new ArgumentException("Object must be of type ValueTuple") + _ => throw new ArgumentException("Object must be of type ValueTuple"), }; public override int GetHashCode() => 0; @@ -121,7 +118,7 @@ public int CompareTo(object? obj) => { null => 1, ValueTuple other => CompareTo(other), - _ => throw new ArgumentException("Object must be of type ValueTuple") + _ => throw new ArgumentException("Object must be of type ValueTuple"), }; public override int GetHashCode() => HashCode.Combine(Item1); @@ -172,7 +169,7 @@ public int CompareTo(object? obj) => { null => 1, ValueTuple other => CompareTo(other), - _ => throw new ArgumentException("Object must be of type ValueTuple") + _ => throw new ArgumentException("Object must be of type ValueTuple"), }; public override int GetHashCode() => HashCode.Combine(Item1, Item2); @@ -220,16 +217,16 @@ public bool Equals(ValueTuple other) => public int CompareTo(ValueTuple other) => Comparer.Default.Compare(Item1, other.Item1) != 0 ? Comparer.Default.Compare(Item1, other.Item1) - : Comparer.Default.Compare(Item2, other.Item2) != 0 - ? Comparer.Default.Compare(Item2, other.Item2) - : Comparer.Default.Compare(Item3, other.Item3); + : Comparer.Default.Compare(Item2, other.Item2) != 0 + ? Comparer.Default.Compare(Item2, other.Item2) + : Comparer.Default.Compare(Item3, other.Item3); public int CompareTo(object? obj) => obj switch { null => 1, ValueTuple other => CompareTo(other), - _ => throw new ArgumentException("Object must be of type ValueTuple") + _ => throw new ArgumentException("Object must be of type ValueTuple"), }; public override int GetHashCode() => HashCode.Combine(Item1, Item2, Item3); @@ -279,18 +276,18 @@ public bool Equals(ValueTuple other) => public int CompareTo(ValueTuple other) => Comparer.Default.Compare(Item1, other.Item1) != 0 ? Comparer.Default.Compare(Item1, other.Item1) - : Comparer.Default.Compare(Item2, other.Item2) != 0 - ? Comparer.Default.Compare(Item2, other.Item2) - : Comparer.Default.Compare(Item3, other.Item3) != 0 - ? Comparer.Default.Compare(Item3, other.Item3) - : Comparer.Default.Compare(Item4, other.Item4); + : Comparer.Default.Compare(Item2, other.Item2) != 0 + ? Comparer.Default.Compare(Item2, other.Item2) + : Comparer.Default.Compare(Item3, other.Item3) != 0 + ? Comparer.Default.Compare(Item3, other.Item3) + : Comparer.Default.Compare(Item4, other.Item4); public int CompareTo(object? obj) => obj switch { null => 1, ValueTuple other => CompareTo(other), - _ => throw new ArgumentException("Object must be of type ValueTuple") + _ => throw new ArgumentException("Object must be of type ValueTuple"), }; public override int GetHashCode() => HashCode.Combine(Item1, Item2, Item3, Item4); @@ -360,23 +357,22 @@ public bool Equals(ValueTuple other) => public int CompareTo(ValueTuple other) => Comparer.Default.Compare(Item1, other.Item1) != 0 ? Comparer.Default.Compare(Item1, other.Item1) - : Comparer.Default.Compare(Item2, other.Item2) != 0 - ? Comparer.Default.Compare(Item2, other.Item2) - : Comparer.Default.Compare(Item3, other.Item3) != 0 - ? Comparer.Default.Compare(Item3, other.Item3) - : Comparer.Default.Compare(Item4, other.Item4) != 0 - ? Comparer.Default.Compare(Item4, other.Item4) - : Comparer.Default.Compare(Item5, other.Item5); + : Comparer.Default.Compare(Item2, other.Item2) != 0 + ? Comparer.Default.Compare(Item2, other.Item2) + : Comparer.Default.Compare(Item3, other.Item3) != 0 + ? Comparer.Default.Compare(Item3, other.Item3) + : Comparer.Default.Compare(Item4, other.Item4) != 0 + ? Comparer.Default.Compare(Item4, other.Item4) + : Comparer.Default.Compare(Item5, other.Item5); public int CompareTo(object? obj) => obj switch { null => 1, ValueTuple other => CompareTo(other), - _ - => throw new ArgumentException( - "Object must be of type ValueTuple" - ) + _ => throw new ArgumentException( + "Object must be of type ValueTuple" + ), }; public override int GetHashCode() => HashCode.Combine(Item1, Item2, Item3, Item4, Item5); @@ -449,25 +445,24 @@ public bool Equals(ValueTuple other) => public int CompareTo(ValueTuple other) => Comparer.Default.Compare(Item1, other.Item1) != 0 ? Comparer.Default.Compare(Item1, other.Item1) - : Comparer.Default.Compare(Item2, other.Item2) != 0 - ? Comparer.Default.Compare(Item2, other.Item2) - : Comparer.Default.Compare(Item3, other.Item3) != 0 - ? Comparer.Default.Compare(Item3, other.Item3) - : Comparer.Default.Compare(Item4, other.Item4) != 0 - ? Comparer.Default.Compare(Item4, other.Item4) - : Comparer.Default.Compare(Item5, other.Item5) != 0 - ? Comparer.Default.Compare(Item5, other.Item5) - : Comparer.Default.Compare(Item6, other.Item6); + : Comparer.Default.Compare(Item2, other.Item2) != 0 + ? Comparer.Default.Compare(Item2, other.Item2) + : Comparer.Default.Compare(Item3, other.Item3) != 0 + ? Comparer.Default.Compare(Item3, other.Item3) + : Comparer.Default.Compare(Item4, other.Item4) != 0 + ? Comparer.Default.Compare(Item4, other.Item4) + : Comparer.Default.Compare(Item5, other.Item5) != 0 + ? Comparer.Default.Compare(Item5, other.Item5) + : Comparer.Default.Compare(Item6, other.Item6); public int CompareTo(object? obj) => obj switch { null => 1, ValueTuple other => CompareTo(other), - _ - => throw new ArgumentException( - "Object must be of type ValueTuple" - ) + _ => throw new ArgumentException( + "Object must be of type ValueTuple" + ), }; public override int GetHashCode() => HashCode.Combine(Item1, Item2, Item3, Item4, Item5, Item6); @@ -543,27 +538,26 @@ public bool Equals(ValueTuple other) => public int CompareTo(ValueTuple other) => Comparer.Default.Compare(Item1, other.Item1) != 0 ? Comparer.Default.Compare(Item1, other.Item1) - : Comparer.Default.Compare(Item2, other.Item2) != 0 - ? Comparer.Default.Compare(Item2, other.Item2) - : Comparer.Default.Compare(Item3, other.Item3) != 0 - ? Comparer.Default.Compare(Item3, other.Item3) - : Comparer.Default.Compare(Item4, other.Item4) != 0 - ? Comparer.Default.Compare(Item4, other.Item4) - : Comparer.Default.Compare(Item5, other.Item5) != 0 - ? Comparer.Default.Compare(Item5, other.Item5) - : Comparer.Default.Compare(Item6, other.Item6) != 0 - ? Comparer.Default.Compare(Item6, other.Item6) - : Comparer.Default.Compare(Item7, other.Item7); + : Comparer.Default.Compare(Item2, other.Item2) != 0 + ? Comparer.Default.Compare(Item2, other.Item2) + : Comparer.Default.Compare(Item3, other.Item3) != 0 + ? Comparer.Default.Compare(Item3, other.Item3) + : Comparer.Default.Compare(Item4, other.Item4) != 0 + ? Comparer.Default.Compare(Item4, other.Item4) + : Comparer.Default.Compare(Item5, other.Item5) != 0 + ? Comparer.Default.Compare(Item5, other.Item5) + : Comparer.Default.Compare(Item6, other.Item6) != 0 + ? Comparer.Default.Compare(Item6, other.Item6) + : Comparer.Default.Compare(Item7, other.Item7); public int CompareTo(object? obj) => obj switch { null => 1, ValueTuple other => CompareTo(other), - _ - => throw new ArgumentException( - "Object must be of type ValueTuple" - ) + _ => throw new ArgumentException( + "Object must be of type ValueTuple" + ), }; public override int GetHashCode() => @@ -644,29 +638,28 @@ public bool Equals(ValueTuple other) => public int CompareTo(ValueTuple other) => Comparer.Default.Compare(Item1, other.Item1) != 0 ? Comparer.Default.Compare(Item1, other.Item1) - : Comparer.Default.Compare(Item2, other.Item2) != 0 - ? Comparer.Default.Compare(Item2, other.Item2) - : Comparer.Default.Compare(Item3, other.Item3) != 0 - ? Comparer.Default.Compare(Item3, other.Item3) - : Comparer.Default.Compare(Item4, other.Item4) != 0 - ? Comparer.Default.Compare(Item4, other.Item4) - : Comparer.Default.Compare(Item5, other.Item5) != 0 - ? Comparer.Default.Compare(Item5, other.Item5) - : Comparer.Default.Compare(Item6, other.Item6) != 0 - ? Comparer.Default.Compare(Item6, other.Item6) - : Comparer.Default.Compare(Item7, other.Item7) != 0 - ? Comparer.Default.Compare(Item7, other.Item7) - : Comparer.Default.Compare(Rest, other.Rest); + : Comparer.Default.Compare(Item2, other.Item2) != 0 + ? Comparer.Default.Compare(Item2, other.Item2) + : Comparer.Default.Compare(Item3, other.Item3) != 0 + ? Comparer.Default.Compare(Item3, other.Item3) + : Comparer.Default.Compare(Item4, other.Item4) != 0 + ? Comparer.Default.Compare(Item4, other.Item4) + : Comparer.Default.Compare(Item5, other.Item5) != 0 + ? Comparer.Default.Compare(Item5, other.Item5) + : Comparer.Default.Compare(Item6, other.Item6) != 0 + ? Comparer.Default.Compare(Item6, other.Item6) + : Comparer.Default.Compare(Item7, other.Item7) != 0 + ? Comparer.Default.Compare(Item7, other.Item7) + : Comparer.Default.Compare(Rest, other.Rest); public int CompareTo(object? obj) => obj switch { null => 1, ValueTuple other => CompareTo(other), - _ - => throw new ArgumentException( - "Object must be of type ValueTuple" - ) + _ => throw new ArgumentException( + "Object must be of type ValueTuple" + ), }; public override int GetHashCode() => diff --git a/PolyShim/NetCore21/DateTime.cs b/PolyShim/NetCore21/DateTime.cs index 751f5d7..26b2a78 100644 --- a/PolyShim/NetCore21/DateTime.cs +++ b/PolyShim/NetCore21/DateTime.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -18,4 +15,4 @@ internal static partial class PolyfillExtensions public static DateTime UnixEpoch => new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore21/DateTimeOffset.cs b/PolyShim/NetCore21/DateTimeOffset.cs index 6568d97..c0dddc5 100644 --- a/PolyShim/NetCore21/DateTimeOffset.cs +++ b/PolyShim/NetCore21/DateTimeOffset.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -18,4 +15,4 @@ internal static partial class PolyfillExtensions2 public static DateTimeOffset UnixEpoch => new(1970, 1, 1, 0, 0, 0, TimeSpan.Zero); } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore21/HashCode.cs b/PolyShim/NetCore21/HashCode.cs index 3144118..03b5611 100644 --- a/PolyShim/NetCore21/HashCode.cs +++ b/PolyShim/NetCore21/HashCode.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if !FEATURE_HASHCODE +#if !FEATURE_HASHCODE #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore21/Random.cs b/PolyShim/NetCore21/Random.cs index d495213..c943612 100644 --- a/PolyShim/NetCore21/Random.cs +++ b/PolyShim/NetCore21/Random.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore21/Stream.cs b/PolyShim/NetCore21/Stream.cs index c556741..696361a 100644 --- a/PolyShim/NetCore21/Stream.cs +++ b/PolyShim/NetCore21/Stream.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -19,13 +16,11 @@ internal static partial class PolyfillExtensions { // Signature-compatible replacement for Read(Span) // https://learn.microsoft.com/dotnet/api/system.io.stream.read#system-io-stream-read(system-span((system-byte))) - public int Read(byte[] buffer) => - stream.Read(buffer, 0, buffer.Length); + public int Read(byte[] buffer) => stream.Read(buffer, 0, buffer.Length); // Signature-compatible replacement for Write(ReadOnlySpan) // https://learn.microsoft.com/dotnet/api/system.io.stream.write#system-io-stream-write(system-readonlyspan((system-byte))) - public void Write(byte[] buffer) => - stream.Write(buffer, 0, buffer.Length); + public void Write(byte[] buffer) => stream.Write(buffer, 0, buffer.Length); #if FEATURE_TASK // https://learn.microsoft.com/dotnet/api/system.io.stream.copytoasync#system-io-stream-copytoasync(system-io-stream-system-threading-cancellationtoken) @@ -39,14 +34,20 @@ public async Task CopyToAsync( public async Task ReadAsync( byte[] buffer, CancellationToken cancellationToken = default - ) => await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false); + ) => + await stream + .ReadAsync(buffer, 0, buffer.Length, cancellationToken) + .ConfigureAwait(false); // Signature-compatible replacement for WriteAsync(ReadOnlyMemory, ...) // https://learn.microsoft.com/dotnet/api/system.io.stream.writeasync#system-io-stream-writeasync(system-readonlymemory((system-byte))-system-threading-cancellationtoken) public async Task WriteAsync( byte[] buffer, CancellationToken cancellationToken = default - ) => await stream.WriteAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false); + ) => + await stream + .WriteAsync(buffer, 0, buffer.Length, cancellationToken) + .ConfigureAwait(false); #endif #if FEATURE_MEMORY diff --git a/PolyShim/NetCore21/StreamReader.cs b/PolyShim/NetCore21/StreamReader.cs index 1ca0471..3c6bda8 100644 --- a/PolyShim/NetCore21/StreamReader.cs +++ b/PolyShim/NetCore21/StreamReader.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -19,8 +16,7 @@ internal static partial class PolyfillExtensions { // Signature-compatible replacement for Read(Span) // https://learn.microsoft.com/dotnet/api/system.io.streamreader.read#system-io-streamreader-read(system-span((system-char))) - public int Read(char[] buffer) => - reader.Read(buffer, 0, buffer.Length); + public int Read(char[] buffer) => reader.Read(buffer, 0, buffer.Length); #if FEATURE_TASK // Signature-compatible replacement for ReadAsync(Memory, ...) diff --git a/PolyShim/NetCore21/StreamWriter.cs b/PolyShim/NetCore21/StreamWriter.cs index f548b00..260a353 100644 --- a/PolyShim/NetCore21/StreamWriter.cs +++ b/PolyShim/NetCore21/StreamWriter.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore21/String.cs b/PolyShim/NetCore21/String.cs index afa4411..e86ac77 100644 --- a/PolyShim/NetCore21/String.cs +++ b/PolyShim/NetCore21/String.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP2_1_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/AllowNullAttribute.cs b/PolyShim/NetCore30/AllowNullAttribute.cs index f74eedc..17b9b7c 100644 --- a/PolyShim/NetCore30/AllowNullAttribute.cs +++ b/PolyShim/NetCore30/AllowNullAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/CallerArgumentExpressionAttribute.cs b/PolyShim/NetCore30/CallerArgumentExpressionAttribute.cs index 88a4604..1dbb4fc 100644 --- a/PolyShim/NetCore30/CallerArgumentExpressionAttribute.cs +++ b/PolyShim/NetCore30/CallerArgumentExpressionAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/DisallowNullAttribute.cs b/PolyShim/NetCore30/DisallowNullAttribute.cs index d3a1644..4d69c51 100644 --- a/PolyShim/NetCore30/DisallowNullAttribute.cs +++ b/PolyShim/NetCore30/DisallowNullAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/DoesNotReturnAttribute.cs b/PolyShim/NetCore30/DoesNotReturnAttribute.cs index dcdaca2..832caee 100644 --- a/PolyShim/NetCore30/DoesNotReturnAttribute.cs +++ b/PolyShim/NetCore30/DoesNotReturnAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/DoesNotReturnIfAttribute.cs b/PolyShim/NetCore30/DoesNotReturnIfAttribute.cs index f560db5..7938e7c 100644 --- a/PolyShim/NetCore30/DoesNotReturnIfAttribute.cs +++ b/PolyShim/NetCore30/DoesNotReturnIfAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/EnumerableExtensions.cs b/PolyShim/NetCore30/EnumerableExtensions.cs index ab7cb7d..44640a5 100644 --- a/PolyShim/NetCore30/EnumerableExtensions.cs +++ b/PolyShim/NetCore30/EnumerableExtensions.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -17,8 +14,9 @@ internal static partial class PolyfillExtensions extension(IEnumerable first) { // https://learn.microsoft.com/dotnet/api/system.linq.enumerable.zip#system-linq-enumerable-zip-2(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-1))) - public IEnumerable<(TFirst left, TSecond right)> Zip(IEnumerable second) => - first.Zip(second, (x, y) => (x, y)); + public IEnumerable<(TFirst left, TSecond right)> Zip( + IEnumerable second + ) => first.Zip(second, (x, y) => (x, y)); } } #endif diff --git a/PolyShim/NetCore30/File.cs b/PolyShim/NetCore30/File.cs index eda62a0..cb02f11 100644 --- a/PolyShim/NetCore30/File.cs +++ b/PolyShim/NetCore30/File.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -12,7 +9,7 @@ internal static partial class PolyfillExtensions { -// No file I/O on .NET Standard prior to 1.3 + // No file I/O on .NET Standard prior to 1.3 #if !NETSTANDARD || NETSTANDARD1_3_OR_GREATER extension(File) { @@ -25,4 +22,4 @@ public static void Move(string sourceFileName, string destFileName, bool overwri } #endif } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore30/Index.cs b/PolyShim/NetCore30/Index.cs index 16c24c8..d7ed14d 100644 --- a/PolyShim/NetCore30/Index.cs +++ b/PolyShim/NetCore30/Index.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if !FEATURE_INDEXRANGE +#if !FEATURE_INDEXRANGE #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/MaybeNullAttribute.cs b/PolyShim/NetCore30/MaybeNullAttribute.cs index 0c530a9..06b8e85 100644 --- a/PolyShim/NetCore30/MaybeNullAttribute.cs +++ b/PolyShim/NetCore30/MaybeNullAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/MaybeNullWhenAttribute.cs b/PolyShim/NetCore30/MaybeNullWhenAttribute.cs index a588b6f..7b10005 100644 --- a/PolyShim/NetCore30/MaybeNullWhenAttribute.cs +++ b/PolyShim/NetCore30/MaybeNullWhenAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/NotNullAttribute.cs b/PolyShim/NetCore30/NotNullAttribute.cs index 45bb4e8..17c4fcf 100644 --- a/PolyShim/NetCore30/NotNullAttribute.cs +++ b/PolyShim/NetCore30/NotNullAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/NotNullIfNotNullAttribute.cs b/PolyShim/NetCore30/NotNullIfNotNullAttribute.cs index 2fe9cb9..5882a49 100644 --- a/PolyShim/NetCore30/NotNullIfNotNullAttribute.cs +++ b/PolyShim/NetCore30/NotNullIfNotNullAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/NotNullWhenAttribute.cs b/PolyShim/NetCore30/NotNullWhenAttribute.cs index 8a0f5b0..b91ae1b 100644 --- a/PolyShim/NetCore30/NotNullWhenAttribute.cs +++ b/PolyShim/NetCore30/NotNullWhenAttribute.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD && !NETSTANDARD2_1_OR_GREATER) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/OSPlatform.cs b/PolyShim/NetCore30/OSPlatform.cs index 88df89b..790dde9 100644 --- a/PolyShim/NetCore30/OSPlatform.cs +++ b/PolyShim/NetCore30/OSPlatform.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/Path.cs b/PolyShim/NetCore30/Path.cs index 0d1de89..3eba775 100644 --- a/PolyShim/NetCore30/Path.cs +++ b/PolyShim/NetCore30/Path.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace @@ -23,7 +20,8 @@ public static bool EndsInDirectorySeparator(string? path) var lastChar = path![^1]; #if !NETSTANDARD || NETSTANDARD1_3_OR_GREATER - return lastChar == Path.DirectorySeparatorChar || lastChar == Path.AltDirectorySeparatorChar; + return lastChar == Path.DirectorySeparatorChar + || lastChar == Path.AltDirectorySeparatorChar; #else return lastChar is '\\' or '/'; #endif @@ -31,9 +29,10 @@ public static bool EndsInDirectorySeparator(string? path) // https://learn.microsoft.com/dotnet/api/system.io.path.trimendingdirectoryseparator#system-io-path-trimendingdirectoryseparator(system-string) public static string TrimEndingDirectorySeparator(string path) => - EndsInDirectorySeparator(path) && !Path.GetPathRoot(path).Equals(path, System.StringComparison.Ordinal) + EndsInDirectorySeparator(path) + && !Path.GetPathRoot(path).Equals(path, System.StringComparison.Ordinal) ? path[..^1] : path; } } -#endif \ No newline at end of file +#endif diff --git a/PolyShim/NetCore30/Process.cs b/PolyShim/NetCore30/Process.cs index bc5784f..f35d031 100644 --- a/PolyShim/NetCore30/Process.cs +++ b/PolyShim/NetCore30/Process.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NET35_OR_GREATER) || (NETSTANDARD) +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NET35_OR_GREATER) || (NETSTANDARD) #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/Range.cs b/PolyShim/NetCore30/Range.cs index eebd5f5..e1ff944 100644 --- a/PolyShim/NetCore30/Range.cs +++ b/PolyShim/NetCore30/Range.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if !FEATURE_INDEXRANGE +#if !FEATURE_INDEXRANGE #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/NetCore30/RuntimeHelpers.cs b/PolyShim/NetCore30/RuntimeHelpers.cs index 571f1c6..6601899 100644 --- a/PolyShim/NetCore30/RuntimeHelpers.cs +++ b/PolyShim/NetCore30/RuntimeHelpers.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -#if !FEATURE_INDEXRANGE +#if !FEATURE_INDEXRANGE #nullable enable // ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace diff --git a/PolyShim/PolyfillExtensions.cs b/PolyShim/PolyfillExtensions.cs index 3aff020..0488328 100644 --- a/PolyShim/PolyfillExtensions.cs +++ b/PolyShim/PolyfillExtensions.cs @@ -1,7 +1,4 @@ -// The following comment is required to instruct analyzers to skip this file -// - -// ReSharper disable RedundantUsingDirective +// ReSharper disable RedundantUsingDirective // ReSharper disable CheckNamespace // ReSharper disable InconsistentNaming // ReSharper disable PartialTypeWithSinglePart