Skip to content

Commit bb4e41e

Browse files
authored
Merge pull request #394 from heku/correct_type_in_converters
Correct typo in converters
2 parents 9d1a525 + 74e24d6 commit bb4e41e

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

CommunityToolkit.Common/Converters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static string ToFileSizeString(long size)
4242
}
4343
else
4444
{
45-
return ((size >> 50) / 1024F).ToString("F0") + " EB";
45+
return ((size >> 50) / 1024F).ToString("F1") + " EB";
4646
}
4747
}
4848
}

CommunityToolkit.Common/Extensions/EventHandlerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public static Task InvokeAsync<T>(this EventHandler<T>? eventHandler, object sen
5454
invocationDelegate(sender, eventArgs);
5555

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

5959
return deferral?.WaitForCompletion(cancellationToken) ?? Task.CompletedTask;
6060
#pragma warning restore CS0618 // Type or member is obsolete
61-
})
61+
})
6262
.ToArray();
6363

6464
return Task.WhenAll(tasks);

CommunityToolkit.Common/IncrementalLoadingCollection/IIncrementalSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ public interface IIncrementalSource<TSource>
2929
/// <returns>
3030
/// Returns a collection of <typeparamref name="TSource"/>.
3131
/// </returns>
32-
Task<IEnumerable<TSource>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken));
32+
Task<IEnumerable<TSource>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default);
3333
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Microsoft.VisualStudio.TestTools.UnitTesting;
6+
7+
namespace CommunityToolkit.Common.UnitTests;
8+
9+
[TestClass]
10+
public class Test_Converters
11+
{
12+
[TestMethod]
13+
[DataRow(1024L - 1, "1023 bytes")]
14+
[DataRow(1024L, "1.0 KB")]
15+
[DataRow(1024L * 1024, "1.0 MB")]
16+
[DataRow(1024L * 1024 * 1024, "1.0 GB")]
17+
[DataRow(1024L * 1024 * 1024 * 1024, "1.0 TB")]
18+
[DataRow(1024L * 1024 * 1024 * 1024 * 1024, "1.0 PB")]
19+
[DataRow(1024L * 1024 * 1024 * 1024 * 1024 * 1024, "1.0 EB")]
20+
public void Test_ToFileSizeString(long size, string expected)
21+
{
22+
Assert.AreEqual(expected, Converters.ToFileSizeString(size));
23+
}
24+
}

0 commit comments

Comments
 (0)