From 36fc60f909a94fbf689731df4bf4094be6a93f37 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 26 Feb 2024 11:31:19 +1100 Subject: [PATCH 1/6] Update StringPolyfill.cs --- src/Polyfill/StringPolyfill.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Polyfill/StringPolyfill.cs b/src/Polyfill/StringPolyfill.cs index 7c5769d9..b7f41e99 100644 --- a/src/Polyfill/StringPolyfill.cs +++ b/src/Polyfill/StringPolyfill.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using Link = System.ComponentModel.DescriptionAttribute; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] @@ -24,6 +25,7 @@ public static string Join(char separator, string[] values) #endif } + [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-object())")] public static string Join(char separator, object[] values) { #if NETSTANDARD2_0 || NETFRAMEWORK @@ -33,6 +35,7 @@ public static string Join(char separator, object[] values) #endif } + [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string()-system-int32-system-int32)")] public static string Join(char separator, string?[] value, int startIndex, int count) { #if NETSTANDARD2_0 || NETFRAMEWORK @@ -42,6 +45,7 @@ public static string Join(char separator, string?[] value, int startIndex, int c #endif } + [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join-1(system-char-system-collections-generic-ienumerable((-0)))")] public static string Join(char separator, IEnumerable values) { #if NETSTANDARD2_0 || NETFRAMEWORK From 117cffd345c82d36dbc57266f47105d25771bd45 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 26 Feb 2024 16:12:45 +1100 Subject: [PATCH 2/6] Update api_list.include.md --- api_list.include.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api_list.include.md b/api_list.include.md index e6b66394..1c1539ce 100644 --- a/api_list.include.md +++ b/api_list.include.md @@ -317,8 +317,8 @@ #### StringPolyfill * `String Join(Char, String[])` - * `String Join(Char, Object[])` - * `String Join(Char, String[], Int32, Int32)` - * `String Join(Char, IEnumerable)` + * `String Join(Char, Object[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-object())) + * `String Join(Char, String[], Int32, Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string()-system-int32-system-int32)) + * `String Join(Char, IEnumerable)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join-1(system-char-system-collections-generic-ienumerable((-0)))) From 65efde29c84991654e5355e1dfbacc803eb51950 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 26 Feb 2024 16:13:59 +1100 Subject: [PATCH 3/6] remove IEnumerable.Except params since it conflicts with IEnumerable.Except(IEnumerable) (#141) --- api_list.include.md | 4 - src/Polyfill/Polyfill_IEnumerable.cs | 128 ++++++++++++------------- src/Tests/PolyfillTests_IEnumerable.cs | 12 +-- 3 files changed, 70 insertions(+), 74 deletions(-) diff --git a/api_list.include.md b/api_list.include.md index 1c1539ce..32ce1eb3 100644 --- a/api_list.include.md +++ b/api_list.include.md @@ -21,10 +21,6 @@ * `IEnumerable> AggregateBy(Func, Func, Func, IEqualityComparer)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.aggregateby?view=net-9.0#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)))) * `IEnumerable Chunk(Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.chunk) * `IEnumerable> CountBy(Func, IEqualityComparer)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.countby) - * `IEnumerable Except(TSource)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except?view=net-8.0#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0)))) - * `IEnumerable Except(TSource[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except?view=net-8.0#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0)))) - * `IEnumerable Except(TSource, IEqualityComparer)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0)))) - * `IEnumerable Except(IEqualityComparer, TSource[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0)))) * `IEnumerable> Index()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.index#system-linq-enumerable-index-1(system-collections-generic-ienumerable((-0)))) * `TSource MaxBy(Func)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.maxby#system-linq-enumerable-maxby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1)))) * `TSource MaxBy(Func, IComparer)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.maxby?view=net-8.0#system-linq-enumerable-maxby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1))-system-collections-generic-icomparer((-1)))) diff --git a/src/Polyfill/Polyfill_IEnumerable.cs b/src/Polyfill/Polyfill_IEnumerable.cs index cabf81a7..059cc889 100644 --- a/src/Polyfill/Polyfill_IEnumerable.cs +++ b/src/Polyfill/Polyfill_IEnumerable.cs @@ -9,70 +9,70 @@ static partial class Polyfill { - /// - /// Produces a set items excluding by using the default equality comparer to compare values. - /// - /// An whose elements that are not equal to will be returned. - /// An that is elements equal it will cause those elements to be removed from the returned sequence. - /// The type of the elements of . - /// A sequence that contains the items of but excluding . - [Link("https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except?view=net-8.0#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0)))")] - public static IEnumerable Except( - this IEnumerable target, - TSource item) => - Except(target, item, null); - - /// - /// Produces the set difference of two sequences by using the default equality comparer to compare values. - /// - /// An whose elements that are not equal to will be returned. - /// An that is elements equal it will cause those elements to be removed from the returned sequence. - /// The type of the elements of . - /// A sequence that contains the items of but excluding . - [Link("https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except?view=net-8.0#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0)))")] - public static IEnumerable Except( - this IEnumerable target, - params TSource[] items) => - target.Except((IEnumerable)items); - - /// - /// Produces a set items excluding by using to compare values. - /// - /// An whose elements that are not equal to will be returned. - /// An that is elements equal it will cause those elements to be removed from the returned sequence. - /// An to compare values. - /// The type of the elements of . - /// A sequence that contains the items of but excluding . - [Link("https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0)))")] - public static IEnumerable Except( - this IEnumerable target, - TSource item, - IEqualityComparer? comparer) - { - var set = new HashSet(comparer); - set.Add(item); - foreach (TSource element in target) - { - if (set.Add(element)) - { - yield return element; - } - } - } - - /// - /// Produces the set difference of two sequences by to compare values. - /// - /// An whose elements that are not equal to will be returned. - /// An that is elements equal it will cause those elements to be removed from the returned sequence. - /// The type of the elements of . - /// A sequence that contains the items of but excluding . - [Link("https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0)))")] - public static IEnumerable Except( - this IEnumerable target, - IEqualityComparer comparer, - params TSource[] items) => - target.Except((IEnumerable)items, comparer); + // /// + // /// Produces a set items excluding by using the default equality comparer to compare values. + // /// + // /// An whose elements that are not equal to will be returned. + // /// An that is elements equal it will cause those elements to be removed from the returned sequence. + // /// The type of the elements of . + // /// A sequence that contains the items of but excluding . + // [Link("https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except?view=net-8.0#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0)))")] + // public static IEnumerable Except( + // this IEnumerable target, + // TSource item) => + // Except(target, item, null); + // + // /// + // /// Produces the set difference of two sequences by using the default equality comparer to compare values. + // /// + // /// An whose elements that are not equal to will be returned. + // /// An that is elements equal it will cause those elements to be removed from the returned sequence. + // /// The type of the elements of . + // /// A sequence that contains the items of but excluding . + // [Link("https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except?view=net-8.0#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0)))")] + // public static IEnumerable Except( + // this IEnumerable target, + // params TSource[] items) => + // target.Except((IEnumerable)items); + // + // /// + // /// Produces a set items excluding by using to compare values. + // /// + // /// An whose elements that are not equal to will be returned. + // /// An that is elements equal it will cause those elements to be removed from the returned sequence. + // /// An to compare values. + // /// The type of the elements of . + // /// A sequence that contains the items of but excluding . + // [Link("https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0)))")] + // public static IEnumerable Except( + // this IEnumerable target, + // TSource item, + // IEqualityComparer? comparer) + // { + // var set = new HashSet(comparer); + // set.Add(item); + // foreach (TSource element in target) + // { + // if (set.Add(element)) + // { + // yield return element; + // } + // } + // } + // + // /// + // /// Produces the set difference of two sequences by to compare values. + // /// + // /// An whose elements that are not equal to will be returned. + // /// An that is elements equal it will cause those elements to be removed from the returned sequence. + // /// The type of the elements of . + // /// A sequence that contains the items of but excluding . + // [Link("https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0)))")] + // public static IEnumerable Except( + // this IEnumerable target, + // IEqualityComparer comparer, + // params TSource[] items) => + // target.Except((IEnumerable)items, comparer); #if !NET9_0_OR_GREATER && FeatureValueTuple diff --git a/src/Tests/PolyfillTests_IEnumerable.cs b/src/Tests/PolyfillTests_IEnumerable.cs index 1de5f931..2aff5bc2 100644 --- a/src/Tests/PolyfillTests_IEnumerable.cs +++ b/src/Tests/PolyfillTests_IEnumerable.cs @@ -8,12 +8,12 @@ public void MaxBy() Assert.AreEqual(2, enumerable.MaxBy(_ => _)); } - [Test] - public void Except() - { - var enumerable = new List {1, 2}; - Assert.AreEqual(1, enumerable.Except(2).Single()); - } + // [Test] + // public void Except() + // { + // var enumerable = new List {1, 2}; + // Assert.AreEqual(1, enumerable.Except(2).Single()); + // } [Test] public void MinBy() From 22abae656ab69b5ed0db7496d53362e5763219b7 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 26 Feb 2024 16:14:02 +1100 Subject: [PATCH 4/6] Update Directory.Build.props --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index b3287a2c..48f9830c 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - 2.6.5 + 3.0.0 1.0.0 Polyfill true From 77ad323e3267239373353432779a3ed9b75a6fb3 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 26 Feb 2024 16:15:32 +1100 Subject: [PATCH 5/6] Update readme.md --- readme.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 51a560a7..bb246085 100644 --- a/readme.md +++ b/readme.md @@ -377,10 +377,6 @@ The class `Polyfill` includes the following extension methods: * `IEnumerable> AggregateBy(Func, Func, Func, IEqualityComparer)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.aggregateby?view=net-9.0#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)))) * `IEnumerable Chunk(Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.chunk) * `IEnumerable> CountBy(Func, IEqualityComparer)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.countby) - * `IEnumerable Except(TSource)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except?view=net-8.0#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0)))) - * `IEnumerable Except(TSource[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except?view=net-8.0#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0)))) - * `IEnumerable Except(TSource, IEqualityComparer)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0)))) - * `IEnumerable Except(IEqualityComparer, TSource[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.except#system-linq-enumerable-except-1(system-collections-generic-ienumerable((-0))-system-collections-generic-ienumerable((-0))-system-collections-generic-iequalitycomparer((-0)))) * `IEnumerable> Index()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.index#system-linq-enumerable-index-1(system-collections-generic-ienumerable((-0)))) * `TSource MaxBy(Func)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.maxby#system-linq-enumerable-maxby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1)))) * `TSource MaxBy(Func, IComparer)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.maxby?view=net-8.0#system-linq-enumerable-maxby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1))-system-collections-generic-icomparer((-1)))) @@ -673,9 +669,9 @@ The class `Polyfill` includes the following extension methods: #### StringPolyfill * `String Join(Char, String[])` - * `String Join(Char, Object[])` - * `String Join(Char, String[], Int32, Int32)` - * `String Join(Char, IEnumerable)` + * `String Join(Char, Object[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-object())) + * `String Join(Char, String[], Int32, Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string()-system-int32-system-int32)) + * `String Join(Char, IEnumerable)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join-1(system-char-system-collections-generic-ienumerable((-0)))) From 5c1ea9dfca250e5a57e2e07caa76fc6ee54b4a42 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 26 Feb 2024 16:19:16 +1100 Subject: [PATCH 6/6] docs --- api_list.include.md | 2 +- readme.md | 2 +- src/Polyfill/StringPolyfill.cs | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/api_list.include.md b/api_list.include.md index 32ce1eb3..296d020a 100644 --- a/api_list.include.md +++ b/api_list.include.md @@ -312,7 +312,7 @@ #### StringPolyfill - * `String Join(Char, String[])` + * `String Join(Char, String[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string())) * `String Join(Char, Object[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-object())) * `String Join(Char, String[], Int32, Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string()-system-int32-system-int32)) * `String Join(Char, IEnumerable)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join-1(system-char-system-collections-generic-ienumerable((-0)))) diff --git a/readme.md b/readme.md index bb246085..29ead529 100644 --- a/readme.md +++ b/readme.md @@ -668,7 +668,7 @@ The class `Polyfill` includes the following extension methods: #### StringPolyfill - * `String Join(Char, String[])` + * `String Join(Char, String[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string())) * `String Join(Char, Object[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-object())) * `String Join(Char, String[], Int32, Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string()-system-int32-system-int32)) * `String Join(Char, IEnumerable)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join-1(system-char-system-collections-generic-ienumerable((-0)))) diff --git a/src/Polyfill/StringPolyfill.cs b/src/Polyfill/StringPolyfill.cs index b7f41e99..48aadf51 100644 --- a/src/Polyfill/StringPolyfill.cs +++ b/src/Polyfill/StringPolyfill.cs @@ -16,6 +16,10 @@ #endif static partial class StringPolyfill { + /// + /// Concatenates an array of strings, using the specified separator between each member. + /// + [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string())")] public static string Join(char separator, string[] values) { #if NETSTANDARD2_0 || NETFRAMEWORK @@ -25,6 +29,9 @@ public static string Join(char separator, string[] values) #endif } + /// + /// Concatenates the string representations of an array of objects, using the specified separator between each member. + /// [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-object())")] public static string Join(char separator, object[] values) { @@ -35,6 +42,9 @@ public static string Join(char separator, object[] values) #endif } + /// + /// Concatenates the specified elements of a string array, using the specified separator between each element. + /// [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join(system-char-system-string()-system-int32-system-int32)")] public static string Join(char separator, string?[] value, int startIndex, int count) { @@ -45,6 +55,9 @@ public static string Join(char separator, string?[] value, int startIndex, int c #endif } + /// + /// Concatenates the specified elements of a string array, using the specified separator between each element. + /// [Link("https://learn.microsoft.com/en-us/dotnet/api/system.string.join#system-string-join-1(system-char-system-collections-generic-ienumerable((-0)))")] public static string Join(char separator, IEnumerable values) {