From 9dd2d5e3bb31a6517f9b826e7ca886646d52a456 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Fri, 20 Nov 2020 09:35:58 +0100 Subject: [PATCH] Update to .NET 5.0 SDK (#766) --- .travis.yml | 6 +++++- MoreLinq/MoreLinq.csproj | 4 ++-- MoreLinq/Permutations.cs | 19 +++++++++---------- global.json | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c82769aa..ae20362cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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: - | @@ -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 diff --git a/MoreLinq/MoreLinq.csproj b/MoreLinq/MoreLinq.csproj index ee4dfcdba..d61da8e75 100644 --- a/MoreLinq/MoreLinq.csproj +++ b/MoreLinq/MoreLinq.csproj @@ -120,7 +120,7 @@ 3.3.2 MoreLINQ Developers. net451;netstandard1.0;netstandard2.0 - 8 + 9 enable true portable @@ -247,7 +247,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MoreLinq/Permutations.cs b/MoreLinq/Permutations.cs index 3c96161fd..0fac1001b 100644 --- a/MoreLinq/Permutations.cs +++ b/MoreLinq/Permutations.cs @@ -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 @@ -83,25 +84,23 @@ public PermutationEnumerator(IEnumerable 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? current, ref IEnumerator 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 Current => _current!; diff --git a/global.json b/global.json index aca3f3cb6..a46dc9b06 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.300", + "version": "5.0.100", "rollForward": "latestFeature" } }