Skip to content

Commit

Permalink
Use .NET 8 SDK to add .NET 8 target
Browse files Browse the repository at this point in the history
This is a squashed merge of PR #1041.
---------

Co-authored-by: Stuart Turner <[email protected]>
  • Loading branch information
atifaziz and viceroypenguin authored Nov 16, 2023
1 parent 97dbe98 commit 9a4ea61
Show file tree
Hide file tree
Showing 27 changed files with 802 additions and 31 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,15 @@ dotnet_diagnostic.IDE0055.severity = suggestion

# IDE0046: Convert to conditional expression
dotnet_diagnostic.IDE0046.severity = suggestion

# CA1510: Use 'ArgumentNullException.ThrowIfNull' instead of explicitly throwing a new exception instance
# TODO: Remove post https://github.com/morelinq/MoreLINQ/issues/903
dotnet_diagnostic.CA1510.severity = suggestion

# CA1512: Use 'ArgumentOutOfRangeException.ThrowIfNegativeOrZero' instead of explicitly throwing a new exception instance
# TODO: Remove post https://github.com/morelinq/MoreLINQ/issues/903
dotnet_diagnostic.CA1512.severity = suggestion

# CA1513: Use 'ObjectDisposedException.ThrowIf' instead of explicitly throwing a new exception instance
# TODO: Remove post https://github.com/morelinq/MoreLINQ/issues/903
dotnet_diagnostic.CA1513.severity = suggestion
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>7.0-all</AnalysisLevel>
<AnalysisLevel>8.0-all</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<!-- Workaround for IDE0005 (Remove unnecessary usings/imports); see https://github.com/dotnet/roslyn/issues/41640 -->
<NoWarn>EnableGenerateDocumentationFile</NoWarn>
Expand Down
3 changes: 3 additions & 0 deletions MoreLinq.Test/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ dotnet_diagnostic.IDE0047.severity = suggestion

[*{Test,Tests}.cs]

# CA1861: Avoid constant arrays as arguments
dotnet_diagnostic.CA1861.severity = none

# IDE0022: Use expression/block body for methods
dotnet_diagnostic.IDE0022.severity = none

Expand Down
30 changes: 30 additions & 0 deletions MoreLinq.Test/Make.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#region License and Terms
// MoreLINQ - Extensions to LINQ to Objects
// Copyright (c) 2018 Atif Aziz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

global using static MoreLinq.Test.Make;

namespace MoreLinq.Test
{
using System.Collections.Generic;

static class Make
{
public static IEnumerable<T> Seq<T>(params T[] values) =>
from value in values
select value;
}
}
2 changes: 1 addition & 1 deletion MoreLinq.Test/MemoizeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void Run()
[Test]
public static void MemoizeIteratorThrowsWhenCacheDisposedDuringIteration()
{
var sequence = Enumerable.Range(1, 10);
var sequence = Seq(1, 2, 3);
var memoized = sequence.Memoize();
var disposable = (IDisposable)memoized;

Expand Down
2 changes: 1 addition & 1 deletion MoreLinq.Test/MoreLinq.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AssemblyTitle>MoreLinq.Test</AssemblyTitle>
<TargetFrameworks>net7.0;net6.0;net471</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net471</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>MoreLinq.Test</AssemblyName>
<OutputType Condition="'$(TargetFramework)' == 'net471'">Exe</OutputType>
Expand Down
2 changes: 0 additions & 2 deletions MoreLinq.Test/OrderedMergeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ namespace MoreLinq.Test
[TestFixture]
public class OrderedMergeTest
{
static IEnumerable<T> Seq<T>(params T[] values) => values;

public static readonly IEnumerable<ITestCaseData> TestData =
from e in new[]
{
Expand Down
2 changes: 0 additions & 2 deletions MoreLinq.Test/SegmentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ public void VerifyCanSegmentByPrevious()
Assert.That(result.All(s => s.Count() == repCount), Is.True);
}

static IEnumerable<T> Seq<T>(params T[] values) => values;

public static readonly IEnumerable<ITestCaseData> TestData =
from e in new[]
{
Expand Down
14 changes: 9 additions & 5 deletions MoreLinq.Test/SliceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void TestSliceIdentity()
{
const int count = 100;
var sequenceA = Enumerable.Range(1, count);
var sequenceB = sequenceA.ToList();
var sequenceB = sequenceA.ToList().AsEnumerable();

var resultA = sequenceA.Slice(0, count);
var resultB = sequenceB.Slice(0, count);
Expand All @@ -64,7 +64,8 @@ public void TestSliceFirstItem()
{
const int count = 10;
var sequenceA = Enumerable.Range(1, count);
var sequenceB = sequenceA.ToList();
var sequenceB = sequenceA.ToList().AsEnumerable();

var resultA = sequenceA.Slice(0, 1);
var resultB = sequenceB.Slice(0, 1);

Expand All @@ -82,7 +83,8 @@ public void TestSliceLastItem()
{
const int count = 10;
var sequenceA = Enumerable.Range(1, count);
var sequenceB = sequenceA.ToList();
var sequenceB = sequenceA.ToList().AsEnumerable();

var resultA = sequenceA.Slice(count - 1, 1);
var resultB = sequenceB.Slice(count - 1, 1);

Expand All @@ -101,7 +103,8 @@ public void TestSliceSmallerThanSequence()
{
const int count = 10;
var sequenceA = Enumerable.Range(1, count);
var sequenceB = sequenceA.ToList();
var sequenceB = sequenceA.ToList().AsEnumerable();

var resultA = sequenceA.Slice(4, 5);
var resultB = sequenceB.Slice(4, 5);

Expand All @@ -120,7 +123,8 @@ public void TestSliceLongerThanSequence()
{
const int count = 100;
var sequenceA = Enumerable.Range(1, count);
var sequenceB = sequenceA.ToList();
var sequenceB = sequenceA.ToList().AsEnumerable();

var resultA = sequenceA.Slice(count / 2, count);
var resultB = sequenceB.Slice(count / 2, count);

Expand Down
8 changes: 3 additions & 5 deletions MoreLinq.Test/ZipLongestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ namespace MoreLinq.Test
[TestFixture]
public class ZipLongestTest
{
static IEnumerable<T> Seq<T>(params T[] values) => values;

public static readonly IEnumerable<ITestCaseData> TestData =
from e in new[]
{
Expand All @@ -44,10 +42,10 @@ from e in new[]


[Test, TestCaseSource(nameof(TestData))]
public IEnumerable<(int, string)> ZipLongest(int[] first, string[] second)
public IEnumerable<(int, string)> ZipLongest(IEnumerable<int> first, IEnumerable<string> second)
{
using var ts1 = TestingSequence.Of(first);
using var ts2 = TestingSequence.Of(second);
using var ts1 = first.AsTestingSequence();
using var ts2 = second.AsTestingSequence();
return ts1.ZipLongest(ts2, Tuple.Create).ToArray();
}

Expand Down
6 changes: 6 additions & 0 deletions MoreLinq/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.SequenceException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)</Target>
<Left>lib/net6.0/MoreLinq.dll</Left>
<Right>lib/net8.0/MoreLinq.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.SkipLast``1(System.Collections.Generic.IEnumerable{``0},System.Int32)</Target>
Expand Down
4 changes: 4 additions & 0 deletions MoreLinq/Experimental/Async/Merge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ async IAsyncEnumerable<T> Async([EnumeratorCancellation]CancellationToken cancel
// Signal cancellation to those in flight. Unfortunately, this relies on all
// iterators to honour the cancellation.

#if NET8_0_OR_GREATER
await thisCancellationTokenSource.CancelAsync().ConfigureAwait(false);
#else
thisCancellationTokenSource.Cancel();
#endif

// > The caller of an async-iterator method should only call `DisposeAsync()`
// > when the method completed or was suspended by a `yield return`.
Expand Down
2 changes: 2 additions & 0 deletions MoreLinq/Experimental/Await.cs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,9 @@ await concurrencyGate.EnterAsync(cancellationToken)
static class AwaitQuery
{
public static IAwaitQuery<T>
#pragma warning disable CA1859 // Use concrete types when possible for improved performance (by-design)
Create<T>(
#pragma warning restore CA1859 // Use concrete types when possible for improved performance
Func<AwaitQueryOptions, IEnumerable<T>> impl,
AwaitQueryOptions? options = null) =>
new AwaitQuery<T>(impl, options);
Expand Down
3 changes: 1 addition & 2 deletions MoreLinq/Flatten.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
namespace MoreLinq
{
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

Expand Down Expand Up @@ -135,7 +134,7 @@ public static IEnumerable<

try
{
while (stack.Any())
while (stack.Count > 0)
{
e = stack.Pop();

Expand Down
2 changes: 1 addition & 1 deletion MoreLinq/GroupAdjacent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ static IEnumerable<TResult> GroupAdjacentImpl<TSource, TKey, TElement, TResult>(
}
}

static IGrouping<TKey, TElement> CreateGroupAdjacentGrouping<TKey, TElement>(TKey key, IList<TElement> members) =>
static Grouping<TKey, TElement> CreateGroupAdjacentGrouping<TKey, TElement>(TKey key, IList<TElement> members) =>
Grouping.Create(key, members.IsReadOnly ? members : new ReadOnlyCollection<TElement>(members));

static class Grouping
Expand Down
2 changes: 1 addition & 1 deletion MoreLinq/MoreLinq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<NeutralLanguage>en-US</NeutralLanguage>
<VersionPrefix>4.1.0</VersionPrefix>
<Authors>MoreLINQ Developers.</Authors>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<DebugType>portable</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>MoreLinq</AssemblyName>
Expand Down
4 changes: 2 additions & 2 deletions MoreLinq/Permutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ void NextPermutation()
/// be surprised to discover that all of the permutations looked the
/// same.
/// </remarks>
/// <returns>List of permuted source sequence values</returns>
IList<T> PermuteValueSet()
/// <returns>Array of permuted source sequence values</returns>
T[] PermuteValueSet()
{
var permutedSet = new T[_permutation.Length];
for (var i = 0; i < _permutation.Length; i++)
Expand Down
1 change: 1 addition & 0 deletions MoreLinq/PublicAPI/net8.0/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Loading

0 comments on commit 9a4ea61

Please sign in to comment.