Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenSkillSharp.Tests/Models/PlackettLuceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion OpenSkillSharp.Tests/OpenSkillSharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
8 changes: 7 additions & 1 deletion OpenSkillSharp/OpenSkillSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Title>OpenSkillSharp</Title>
Expand All @@ -14,6 +13,7 @@
<RepositoryType>git</RepositoryType>
<PackageTags>ranking, rating, elo, trueskill, openskill, bayesian</PackageTags>
<Copyright>Copyright (c) 2025 Patrick Lacni</Copyright>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -25,4 +25,10 @@
<PackageReference Include="MathNet.Numerics" Version="5.0.0"/>
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions OpenSkillSharp/Util/Polyfills/EnumerablePolyfills.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#if !NET9_0_OR_GREATER
// ReSharper disable once CheckNamespace
namespace System.Linq;

internal static class EnumerablePolyfills
{
/// <summary>Returns an enumerable that incorporates the element's index into a tuple.</summary>
/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
/// <param name="source">The source enumerable providing the elements.</param>
/// <exception cref="ArgumentNullException"><paramref name="source" /> is <see langword="null" />.</exception>
public static IEnumerable<(int Index, TSource Item)> Index<TSource>(this IEnumerable<TSource> source)
{
ArgumentNullException.ThrowIfNull(source);

int index = -1;

foreach (TSource element in source)
{
index++;
yield return (index, element);
}
}
}

#endif