From 69b6ea2f81b89453b2e0cfe15765bc75c42e9bd8 Mon Sep 17 00:00:00 2001 From: myssto Date: Fri, 19 Dec 2025 21:50:17 -0600 Subject: [PATCH 1/3] multi-target net8 for LTS --- OpenSkillSharp/OpenSkillSharp.csproj | 2 +- .../Util/Polyfills/EnumerablePolyfills.cs | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs diff --git a/OpenSkillSharp/OpenSkillSharp.csproj b/OpenSkillSharp/OpenSkillSharp.csproj index a70a49a..e18fb5e 100644 --- a/OpenSkillSharp/OpenSkillSharp.csproj +++ b/OpenSkillSharp/OpenSkillSharp.csproj @@ -1,7 +1,6 @@  - net9.0 enable enable OpenSkillSharp @@ -14,6 +13,7 @@ git ranking, rating, elo, trueskill, openskill, bayesian Copyright (c) 2025 Patrick Lacni + net9.0;net8.0 diff --git a/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs b/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs new file mode 100644 index 0000000..08b1360 --- /dev/null +++ b/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs @@ -0,0 +1,25 @@ +#if !NET9_0_OR_GREATER +// ReSharper disable once CheckNamespace +namespace System.Linq; + +internal static class EnumerableIndexPolyfill +{ + /// Returns an enumerable that incorporates the element's index into a tuple. + /// The type of the elements of . + /// The source enumerable providing the elements. + /// is . + public static IEnumerable<(int Index, TSource Item)> Index(this IEnumerable source) + { + ArgumentNullException.ThrowIfNull(source); + + int index = -1; + + foreach (TSource element in source) + { + index++; + yield return (index, element); + } + } +} + +#endif \ No newline at end of file From d2dbe48561614dba29c64872938ba12f42167fa1 Mon Sep 17 00:00:00 2001 From: myssto Date: Fri, 19 Dec 2025 23:24:49 -0600 Subject: [PATCH 2/3] add polyfill for `IEnumerable.Index()` --- OpenSkillSharp.Tests/OpenSkillSharp.Tests.csproj | 2 +- OpenSkillSharp/OpenSkillSharp.csproj | 6 ++++++ OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenSkillSharp.Tests/OpenSkillSharp.Tests.csproj b/OpenSkillSharp.Tests/OpenSkillSharp.Tests.csproj index 9cf55e8..0afd959 100644 --- a/OpenSkillSharp.Tests/OpenSkillSharp.Tests.csproj +++ b/OpenSkillSharp.Tests/OpenSkillSharp.Tests.csproj @@ -1,7 +1,7 @@ - net9.0 + net8.0 enable enable diff --git a/OpenSkillSharp/OpenSkillSharp.csproj b/OpenSkillSharp/OpenSkillSharp.csproj index e18fb5e..82fb27c 100644 --- a/OpenSkillSharp/OpenSkillSharp.csproj +++ b/OpenSkillSharp/OpenSkillSharp.csproj @@ -25,4 +25,10 @@ + + + <_Parameter1>$(MSBuildProjectName).Tests + + + diff --git a/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs b/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs index 08b1360..d439b35 100644 --- a/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs +++ b/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs @@ -2,7 +2,7 @@ // ReSharper disable once CheckNamespace namespace System.Linq; -internal static class EnumerableIndexPolyfill +internal static class EnumerablePolyfills { /// Returns an enumerable that incorporates the element's index into a tuple. /// The type of the elements of . From 4f1b1eba8c9210ed6cebc0fe8c1fb99b29427a25 Mon Sep 17 00:00:00 2001 From: myssto Date: Sat, 20 Dec 2025 14:55:19 -0600 Subject: [PATCH 3/3] format --- OpenSkillSharp.Tests/Models/PlackettLuceTests.cs | 2 +- OpenSkillSharp/OpenSkillSharp.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSkillSharp.Tests/Models/PlackettLuceTests.cs b/OpenSkillSharp.Tests/Models/PlackettLuceTests.cs index b199fa8..75f4701 100644 --- a/OpenSkillSharp.Tests/Models/PlackettLuceTests.cs +++ b/OpenSkillSharp.Tests/Models/PlackettLuceTests.cs @@ -153,7 +153,7 @@ public void Rate_Balance() [Fact] public void Rate_AllScoresTied() { - PlackettLuce model = new PlackettLuce { Mu = 30, Sigma = 30.0 / 3 }; + PlackettLuce model = new() { Mu = 30, Sigma = 30.0 / 3 }; ITeam[] teams = [new Team { Players = [model.Rating()] }, new Team { Players = [model.Rating()] }]; ITeam[] result = model.Rate(teams, scores: [0, 0]).ToArray(); diff --git a/OpenSkillSharp/OpenSkillSharp.csproj b/OpenSkillSharp/OpenSkillSharp.csproj index 4a049ab..21e4fb9 100644 --- a/OpenSkillSharp/OpenSkillSharp.csproj +++ b/OpenSkillSharp/OpenSkillSharp.csproj @@ -30,5 +30,5 @@ <_Parameter1>$(MSBuildProjectName).Tests - +