Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to .NET 5.0 SDK #766

Merged
merged 4 commits into from
Nov 20, 2020
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
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ solution: MoreLinq.sln
mono: 5.0.1
dist: xenial
sudo: required
dotnet: 3.1.300
dotnet: 5.0.100
env:
- CONFIGURATION=Debug
- CONFIGURATION=Release
Expand All @@ -19,6 +19,7 @@ addons:
key_url: 'https://packages.microsoft.com/keys/microsoft.asc'
packages:
- dotnet-runtime-2.1
- dotnet-runtime-3.1

before_install:
- |
Expand All @@ -28,6 +29,9 @@ before_install:
# Install dotnet core 2.1 runtime
wget --retry-connrefused --waitretry=1 -O /tmp/dn21.pkg 'https://download.visualstudio.microsoft.com/download/pr/9314da31-774c-4d2b-8743-998f2a21f5ab/bc918ca05ab6b650f2991b205c04f623/dotnet-runtime-2.1.13-osx-x64.pkg'
sudo installer -pkg /tmp/dn21.pkg -target /
# Install dotnet core 3.1 runtime
wget --retry-connrefused --waitretry=1 -O /tmp/dn31.pkg 'https://download.visualstudio.microsoft.com/download/pr/cf89f4c1-b56a-4250-a927-461f17a828ac/3522d5d7cf26727e416d781533d07b65/dotnet-runtime-3.1.10-osx-x64.pkg'
sudo installer -pkg /tmp/dn31.pkg -target /
fi
- dotnet --info

Expand Down
4 changes: 2 additions & 2 deletions MoreLinq/MoreLinq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<VersionPrefix>3.3.2</VersionPrefix>
<Authors>MoreLINQ Developers.</Authors>
<TargetFrameworks>net451;netstandard1.0;netstandard2.0</TargetFrameworks>
<LangVersion>8</LangVersion>
<LangVersion>9</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>portable</DebugType>
Expand Down Expand Up @@ -247,7 +247,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Nullable" Version="1.1.1">
<PackageReference Include="Nullable" Version="1.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
19 changes: 9 additions & 10 deletions MoreLinq/Permutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace MoreLinq
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

public static partial class MoreEnumerable
Expand Down Expand Up @@ -83,25 +84,23 @@ public PermutationEnumerator(IEnumerable<T> valueSet)
// 1) for empty sets and sets of cardinality 1, there exists only a single permutation.
// 2) for sets larger than 1 element, the number of nested loops needed is: set.Count-1
_generator = NestedLoops(NextPermutation, Enumerable.Range(2, Math.Max(0, _valueSet.Count - 1)));
Reset(ref _current, ref _generatorIterator, ref _hasMoreResults);
Reset();
}

public void Reset() =>
Reset(ref _current, ref _generatorIterator, ref _hasMoreResults);

void Reset(ref IList<T>? current, ref IEnumerator<Action> generatorIterator, ref bool hasMoreResults)
[MemberNotNull(nameof(_generatorIterator))]
public void Reset()
{
current = null;
generatorIterator?.Dispose();
_current = null;
_generatorIterator?.Dispose();
// restore lexographic ordering of the permutation indexes
for (var i = 0; i < _permutation.Length; i++)
_permutation[i] = i;
// start a newiteration over the nested loop generator
generatorIterator = _generator.GetEnumerator();
_generatorIterator = _generator.GetEnumerator();
// we must advance the nestedloop iterator to the initial element,
// this ensures that we only ever produce N!-1 calls to NextPermutation()
generatorIterator.MoveNext();
hasMoreResults = true; // there's always at least one permutation: the original set itself
_generatorIterator.MoveNext();
_hasMoreResults = true; // there's always at least one permutation: the original set itself
}

public IList<T> Current => _current!;
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "3.1.300",
"version": "5.0.100",
"rollForward": "latestFeature"
}
}