From 35073d9c85f80f21ea7dc86c496660753f846d35 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 5 Jun 2023 21:34:54 +0100 Subject: [PATCH 1/7] chore: bump to 3.2.1 --- X10D.DSharpPlus/X10D.DSharpPlus.csproj | 2 +- X10D.Hosting/X10D.Hosting.csproj | 2 +- X10D.Unity/X10D.Unity.csproj | 2 +- X10D/X10D.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/X10D.DSharpPlus/X10D.DSharpPlus.csproj b/X10D.DSharpPlus/X10D.DSharpPlus.csproj index 79b26aa..4e0144a 100644 --- a/X10D.DSharpPlus/X10D.DSharpPlus.csproj +++ b/X10D.DSharpPlus/X10D.DSharpPlus.csproj @@ -16,7 +16,7 @@ dotnet extension-methods $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) true - 4.0.0 + 3.2.1 enable true true diff --git a/X10D.Hosting/X10D.Hosting.csproj b/X10D.Hosting/X10D.Hosting.csproj index b8e4296..e352556 100644 --- a/X10D.Hosting/X10D.Hosting.csproj +++ b/X10D.Hosting/X10D.Hosting.csproj @@ -16,7 +16,7 @@ dotnet extension-methods $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) true - 4.0.0 + 3.2.1 enable true true diff --git a/X10D.Unity/X10D.Unity.csproj b/X10D.Unity/X10D.Unity.csproj index 90caf27..c628bdf 100644 --- a/X10D.Unity/X10D.Unity.csproj +++ b/X10D.Unity/X10D.Unity.csproj @@ -16,7 +16,7 @@ dotnet extension-methods $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) true - 4.0.0 + 3.2.1 enable true true diff --git a/X10D/X10D.csproj b/X10D/X10D.csproj index e034d06..6f19b46 100644 --- a/X10D/X10D.csproj +++ b/X10D/X10D.csproj @@ -17,7 +17,7 @@ README.md $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) true - 4.0.0 + 3.2.1 enable true true From 455b32407156901600727927e771b9046636cf81 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 5 Jun 2023 21:38:09 +0100 Subject: [PATCH 2/7] feat: add support for new usernames user discriminators become "0" if the user has a new username, distinct from "0000" for webhooks. --- CHANGELOG.md | 26 +++----------------- X10D.DSharpPlus/src/DiscordUserExtensions.cs | 6 +++++ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9482e2e..b3203eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,30 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 4.0.0 - [Unreleased] +## [3.2.1] - 2023-06-05 ### Added -- X10D: Added extension methods for `DateOnly`, for parity with `DateTime` and `DateTimeOffset`. -- X10D: Added math-related extension methods for `BigInteger`. -- X10D: Added `Span.Replace(T, T)`. -- X10D: Added `CountDigits` for integer types. -- X10D: Added `IEnumerable.Except(T)`. -- X10D: Added `Progress.OnProgressChanged([T])`. -- X10D: Added `TextWriter.WriteNoAlloc(int[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteNoAlloc(uint[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteNoAlloc(long[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteNoAlloc(ulong[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteLineNoAlloc(int[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteLineNoAlloc(uint[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteLineNoAlloc(long[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteLineNoAlloc(ulong[, ReadOnlySpan[, IFormatProvider]])`. -- X10D.Unity: Added `RaycastHit.GetComponent` and `RaycastHit.TryGetComponent`. -- X10D.Unity: Added `DebugUtility.DrawFunction`, and `DebugUtility.DrawUnjoinedPolyhedron` on which it relies. - -### Changed - -- X10D: `DateTime.Age(DateTime)` and `DateTimeOffset.Age(DateTimeOffset)` parameter renamed from `asOf` to `referenceDate`. +- X10D.DSharpPlus: Added support for new usernames. See https://discord.com/blog/usernames ## [3.2.0] - 2023-04-03 @@ -592,7 +573,8 @@ please [open an issue](https://github.com/oliverbooth/X10D/issues)! Earlier versions of this package are undocumented and unlisted from package results. -[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.2.0...main +[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.2.1...main +[3.2.1]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.1 [3.2.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.0 [3.1.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.1.0 [3.0.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.0.0 diff --git a/X10D.DSharpPlus/src/DiscordUserExtensions.cs b/X10D.DSharpPlus/src/DiscordUserExtensions.cs index 6ab8314..0cc9483 100644 --- a/X10D.DSharpPlus/src/DiscordUserExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordUserExtensions.cs @@ -77,6 +77,12 @@ public static class DiscordUserExtensions } #endif + if (user.Discriminator == "0") + { + // user has a new username. see: https://discord.com/blog/usernames + return user.Username; + } + return $"{user.Username}#{user.Discriminator}"; } From f84fc044ba3335d7defa9c5aa3681880d3e8b180 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 5 Jun 2023 21:46:51 +0100 Subject: [PATCH 3/7] chore: bump to 3.2.2 --- X10D.DSharpPlus/X10D.DSharpPlus.csproj | 2 +- X10D.Hosting/X10D.Hosting.csproj | 2 +- X10D.Unity/X10D.Unity.csproj | 2 +- X10D/X10D.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/X10D.DSharpPlus/X10D.DSharpPlus.csproj b/X10D.DSharpPlus/X10D.DSharpPlus.csproj index 0bef06b..9626435 100644 --- a/X10D.DSharpPlus/X10D.DSharpPlus.csproj +++ b/X10D.DSharpPlus/X10D.DSharpPlus.csproj @@ -16,7 +16,7 @@ dotnet extension-methods $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) true - 3.2.0 + 3.2.2 enable true true diff --git a/X10D.Hosting/X10D.Hosting.csproj b/X10D.Hosting/X10D.Hosting.csproj index af34b97..3d986d6 100644 --- a/X10D.Hosting/X10D.Hosting.csproj +++ b/X10D.Hosting/X10D.Hosting.csproj @@ -16,7 +16,7 @@ dotnet extension-methods $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) true - 3.2.0 + 3.2.2 enable true true diff --git a/X10D.Unity/X10D.Unity.csproj b/X10D.Unity/X10D.Unity.csproj index efb745c..b426b02 100644 --- a/X10D.Unity/X10D.Unity.csproj +++ b/X10D.Unity/X10D.Unity.csproj @@ -16,7 +16,7 @@ dotnet extension-methods $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) true - 3.2.0 + 3.2.2 enable true true diff --git a/X10D/X10D.csproj b/X10D/X10D.csproj index 2afcbcb..1c5424b 100644 --- a/X10D/X10D.csproj +++ b/X10D/X10D.csproj @@ -17,7 +17,7 @@ README.md $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) true - 3.2.0 + 3.2.2 enable true true From 103e037dc86d32811489bae4d34fa92ab666172c Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 5 Jun 2023 21:47:04 +0100 Subject: [PATCH 4/7] docs: update changelog --- CHANGELOG.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc5c548..4716a77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 3.2.0 - [Unreleased] +## [3.2.2] - 2023-06-05 + +### Added + +- X10D.DSharpPlus: Added support for new usernames. See https://discord.com/blog/usernames + +## 3.2.1 - 2023-06-05 + +ERRONEOUS RELEASE. + +## [3.2.0] - 2023-04-03 ### Added @@ -567,7 +577,8 @@ please [open an issue](https://github.com/oliverbooth/X10D/issues)! Earlier versions of this package are undocumented and unlisted from package results. -[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.1.0...develop +[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.2.2...main +[3.2.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.0 [3.1.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.1.0 [3.0.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.0.0 [2.6.0]: https://github.com/oliverbooth/X10D/releases/tag/2.6.0 From 678dd914d470d9453fe4c4e954e267e68b6bb0a4 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 5 Jun 2023 21:47:24 +0100 Subject: [PATCH 5/7] feat: add support for new usernames user discriminators become "0" if the user has a new username, distinct from "0000" for webhooks. --- X10D.DSharpPlus/src/DiscordUserExtensions.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/X10D.DSharpPlus/src/DiscordUserExtensions.cs b/X10D.DSharpPlus/src/DiscordUserExtensions.cs index 6ab8314..0cc9483 100644 --- a/X10D.DSharpPlus/src/DiscordUserExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordUserExtensions.cs @@ -77,6 +77,12 @@ public static class DiscordUserExtensions } #endif + if (user.Discriminator == "0") + { + // user has a new username. see: https://discord.com/blog/usernames + return user.Username; + } + return $"{user.Username}#{user.Discriminator}"; } From 1a2f92c7002713e515aa2e40505f05f752505c67 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 5 Jun 2023 21:47:42 +0100 Subject: [PATCH 6/7] docs: update version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85d2dbb..36c6e54 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ X10D (pronounced *extend*), is a .NET package that provides extension methods fo ## Installation ### NuGet installation ```ps -Install-Package X10D -Version 3.2.0 +Install-Package X10D -Version 3.2.2 ``` ### Manual installation From a0b07edc823fc6db00ea7615f6c34eb19ce7e18a Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 9 Aug 2023 15:17:50 +0100 Subject: [PATCH 7/7] fix: replace Moq with a library that DOESN'T steal your pii Moq has recently introduced a payload named SponsorLink which takes PII (your email address) to send to a third party server for remote verification. This kind of suspicious data harvesting is simply unacceptable, and the developers have now destroyed all credibility and trust with their user base. This change replaces Moq with NSubstitute. For further information, see: https://github.com/moq/moq/issues/1372 --- X10D.Tests/X10D.Tests.csproj | 2 +- .../CollectionTests.ClearAndDisposeAll.cs | 21 ++++++++++--------- ...CollectionTests.ClearAndDisposeAllAsync.cs | 21 ++++++++++--------- .../Collections/EnumerableTests.DisposeAll.cs | 16 +++++++------- .../EnumerableTests.DisposeAllAsync.cs | 16 +++++++------- 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/X10D.Tests/X10D.Tests.csproj b/X10D.Tests/X10D.Tests.csproj index 00ea605..aa5bbd2 100644 --- a/X10D.Tests/X10D.Tests.csproj +++ b/X10D.Tests/X10D.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs index ebce1e4..3330de8 100644 --- a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs +++ b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs @@ -1,5 +1,5 @@ using System.Collections.ObjectModel; -using Moq; +using NSubstitute; using NUnit.Framework; using X10D.Collections; @@ -13,16 +13,17 @@ public partial class CollectionTests [Test] public void ClearAndDisposeAll_ShouldClearAndDisposeAllItems_WhenCalledWithValidList() { - var mock1 = new Mock(); - var mock2 = new Mock(); - var mock3 = new Mock(); - var list = new List {mock1.Object, mock2.Object, mock3.Object}; + var substitute1 = Substitute.For(); + var substitute2 = Substitute.For(); + var substitute3 = Substitute.For(); + var list = new List {substitute1, substitute2, substitute3}; list.ClearAndDisposeAll(); - mock1.Verify(i => i.Dispose(), Times.Once); - mock2.Verify(i => i.Dispose(), Times.Once); - mock3.Verify(i => i.Dispose(), Times.Once); + substitute1.Received(1).Dispose(); + substitute2.Received(1).Dispose(); + substitute3.Received(1).Dispose(); + Assert.That(list, Is.Empty); } @@ -36,8 +37,8 @@ public partial class CollectionTests [Test] public void ClearAndDisposeAll_ShouldThrowInvalidOperationException_WhenCalledWithReadOnlyList() { - var mock = new Mock(); - var list = new ReadOnlyCollection(new List {mock.Object}); + var substitute = Substitute.For(); + var list = new ReadOnlyCollection(new List {substitute}); Assert.Throws(() => list.ClearAndDisposeAll()); } diff --git a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs index 560eac7..c8b3c6a 100644 --- a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs +++ b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs @@ -1,5 +1,5 @@ using System.Collections.ObjectModel; -using Moq; +using NSubstitute; using NUnit.Framework; using X10D.Collections; @@ -13,16 +13,17 @@ public partial class CollectionTests [Test] public async Task ClearAndDisposeAllAsync_ShouldClearAndDisposeAllItems_WhenCalledWithValidList() { - var mock1 = new Mock(); - var mock2 = new Mock(); - var mock3 = new Mock(); - var list = new List {mock1.Object, mock2.Object, mock3.Object}; + var substitute1 = Substitute.For(); + var substitute2 = Substitute.For(); + var substitute3 = Substitute.For(); + var list = new List {substitute1, substitute2, substitute3}; await list.ClearAndDisposeAllAsync().ConfigureAwait(false); - mock1.Verify(i => i.DisposeAsync(), Times.Once); - mock2.Verify(i => i.DisposeAsync(), Times.Once); - mock3.Verify(i => i.DisposeAsync(), Times.Once); + await substitute1.Received(1).DisposeAsync(); + await substitute2.Received(1).DisposeAsync(); + await substitute3.Received(1).DisposeAsync(); + Assert.That(list, Is.Empty); } @@ -36,8 +37,8 @@ public partial class CollectionTests [Test] public void ClearAndDisposeAllAsync_ShouldThrowInvalidOperationException_WhenCalledWithReadOnlyList() { - var mock = new Mock(); - var list = new ReadOnlyCollection(new List {mock.Object}); + var substitute = Substitute.For(); + var list = new ReadOnlyCollection(new List {substitute}); Assert.ThrowsAsync(list.ClearAndDisposeAllAsync); } diff --git a/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs b/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs index d5a4b8e..a402ceb 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs @@ -1,4 +1,4 @@ -using Moq; +using NSubstitute; using NUnit.Framework; using X10D.Collections; @@ -12,16 +12,16 @@ public partial class EnumerableTests [Test] public void DisposeAll_ShouldDisposeAllItems_WhenCalledWithValidList() { - var mock1 = new Mock(); - var mock2 = new Mock(); - var mock3 = new Mock(); - var list = new List {mock1.Object, mock2.Object, null!, mock3.Object}; + var substitute1 = Substitute.For(); + var substitute2 = Substitute.For(); + var substitute3 = Substitute.For(); + var list = new List { substitute1, substitute2, null!, substitute3 }; list.DisposeAll(); - mock1.Verify(i => i.Dispose(), Times.Once); - mock2.Verify(i => i.Dispose(), Times.Once); - mock3.Verify(i => i.Dispose(), Times.Once); + substitute1.Received(1).Dispose(); + substitute2.Received(1).Dispose(); + substitute3.Received(1).Dispose(); } [Test] diff --git a/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs b/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs index 867006e..1510338 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs @@ -1,4 +1,4 @@ -using Moq; +using NSubstitute; using NUnit.Framework; using X10D.Collections; @@ -12,16 +12,16 @@ public partial class EnumerableTests [Test] public async Task DisposeAllAsync_ShouldDisposeAllItems_WhenCalledWithValidList() { - var mock1 = new Mock(); - var mock2 = new Mock(); - var mock3 = new Mock(); - var list = new List {mock1.Object, mock2.Object, null!, mock3.Object}; + var substitute1 = Substitute.For(); + var substitute2 = Substitute.For(); + var substitute3 = Substitute.For(); + var list = new List { substitute1, substitute2, null!, substitute3 }; await list.DisposeAllAsync().ConfigureAwait(false); - mock1.Verify(i => i.DisposeAsync(), Times.Once); - mock2.Verify(i => i.DisposeAsync(), Times.Once); - mock3.Verify(i => i.DisposeAsync(), Times.Once); + await substitute1.Received(1).DisposeAsync(); + await substitute2.Received(1).DisposeAsync(); + await substitute3.Received(1).DisposeAsync(); } [Test]