Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CommunityToolkit.Common/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static string ToFileSizeString(long size)
}
else
{
return ((size >> 50) / 1024F).ToString("F0") + " EB";
return ((size >> 50) / 1024F).ToString("F1") + " EB";
}
}
}
4 changes: 2 additions & 2 deletions CommunityToolkit.Common/Extensions/EventHandlerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public static Task InvokeAsync<T>(this EventHandler<T>? eventHandler, object sen
invocationDelegate(sender, eventArgs);

#pragma warning disable CS0618 // Type or member is obsolete
EventDeferral? deferral = eventArgs.GetCurrentDeferralAndReset();
EventDeferral? deferral = eventArgs.GetCurrentDeferralAndReset();

return deferral?.WaitForCompletion(cancellationToken) ?? Task.CompletedTask;
#pragma warning restore CS0618 // Type or member is obsolete
})
})
.ToArray();

return Task.WhenAll(tasks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public interface IIncrementalSource<TSource>
/// <returns>
/// Returns a collection of <typeparamref name="TSource"/>.
/// </returns>
Task<IEnumerable<TSource>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken));
Task<IEnumerable<TSource>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default);
}
24 changes: 24 additions & 0 deletions tests/CommunityToolkit.Common.UnitTests/Test_Converters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CommunityToolkit.Common.UnitTests;

[TestClass]
public class Test_Converters
{
[TestMethod]
[DataRow(1024L - 1, "1023 bytes")]
[DataRow(1024L, "1.0 KB")]
[DataRow(1024L * 1024, "1.0 MB")]
[DataRow(1024L * 1024 * 1024, "1.0 GB")]
[DataRow(1024L * 1024 * 1024 * 1024, "1.0 TB")]
[DataRow(1024L * 1024 * 1024 * 1024 * 1024, "1.0 PB")]
[DataRow(1024L * 1024 * 1024 * 1024 * 1024 * 1024, "1.0 EB")]
public void Test_ToFileSizeString(long size, string expected)
{
Assert.AreEqual(expected, Converters.ToFileSizeString(size));
}
}