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.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 58d2e5a..21e4fb9 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 @@ -25,4 +25,10 @@ + + + <_Parameter1>$(MSBuildProjectName).Tests + + + diff --git a/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs b/OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs new file mode 100644 index 0000000..d439b35 --- /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 EnumerablePolyfills +{ + /// 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