Skip to content

Commit

Permalink
Merge pull request #24 from pfpack/release/v2.0.0-preview.2.0.1
Browse files Browse the repository at this point in the history
release/v2.0.0-preview.2.0.1
  • Loading branch information
pmosk authored Sep 30, 2021
2 parents 6d011c6 + d8c562d commit fd83e72
Show file tree
Hide file tree
Showing 68 changed files with 973 additions and 981 deletions.
2 changes: 2 additions & 0 deletions docs/primitives-linq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# PrimeFuncPack Primitives.Linq
PrimeFuncPack Primitives.Linq is a core library for .NET consisting of useful extensions making work with Linq easier.
2 changes: 2 additions & 0 deletions docs/primitives-pipeline/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# PrimeFuncPack Primitives.Pipeline
PrimeFuncPack Primitives.Pipeline is a core library for .NET consisting of useful extensions making work with functional pipelines easier.
2 changes: 2 additions & 0 deletions docs/primitives-predicates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# PrimeFuncPack Primitives.Predicates
PrimeFuncPack Primitives.Predicates is a core library for .NET consisting of useful extensions and predicates making work with the nullable feature easier.
2 changes: 2 additions & 0 deletions docs/primitives-strings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# PrimeFuncPack Primitives.Strings
PrimeFuncPack Primitives.Strings is a core library for .NET consisting of useful extensions making work with strings easier.
2 changes: 2 additions & 0 deletions docs/primitives/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# PrimeFuncPack Primitives
PrimeFuncPack Primitives is a core library for .NET consisting of useful extensions and predicates making work with functional pipelines, Linq, strings, the nullable feature, etc. easier.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
using System.Linq;
using static PrimeFuncPack.UnitTest.TestData;

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

internal static class ObjectTestData
{
internal static class ObjectTestData
{
public static IEnumerable<object?[]> NullableObjectTestSource
=>
new object?[]
{
null,
PlusFifteenIdRefType,
SomeTextStructType
}
.Select(v => new object?[] { v });
}
public static IEnumerable<object?[]> NullableObjectTestSource
=>
new object?[]
{
null,
PlusFifteenIdRefType,
SomeTextStructType
}
.Select(v => new object?[] { v });
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
using NUnit.Framework;
using System.Linq;

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

partial class YieldExtensionsTest
{
partial class YieldExtensionsTest
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectCollectionLengthEqualsOne(
object? sourceValue)
{
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectCollectionLengthEqualsOne(
object? sourceValue)
{
var actual = sourceValue.YieldSingle();
var actual = sourceValue.YieldSingle();

var actualLength = actual.Count();
Assert.AreEqual(1, actualLength);
}
var actualLength = actual.Count();
Assert.AreEqual(1, actualLength);
}

[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectFirstItemIsSameAsSourceValue(
object? sourceValue)
{
var actual = sourceValue.YieldSingle();
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectFirstItemIsSameAsSourceValue(
object? sourceValue)
{
var actual = sourceValue.YieldSingle();

var actualFirst = actual.FirstOrDefault();
Assert.AreSame(sourceValue, actualFirst);
}
var actualFirst = actual.FirstOrDefault();
Assert.AreSame(sourceValue, actualFirst);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#nullable enable

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

public sealed partial class YieldExtensionsTest
{
public sealed partial class YieldExtensionsTest
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
using PrimeFuncPack.UnitTest;
using System.Linq;

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

partial class YielderTest
{
partial class YielderTest
[Test]
public void YieldEmpty_ExpectEmptyCollection()
{
[Test]
public void YieldEmpty_ExpectEmptyCollection()
{
var actual = Yielder.YieldEmpty<StructType?>();
Assert.IsEmpty(actual);
}
var actual = Yielder.YieldEmpty<StructType?>();
Assert.IsEmpty(actual);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
using NUnit.Framework;
using System.Linq;

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

partial class YielderTest
{
partial class YielderTest
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectCollectionLengthEqualsOne(
object? sourceValue)
{
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectCollectionLengthEqualsOne(
object? sourceValue)
{
var actual = Yielder.YieldSingle(sourceValue);
var actual = Yielder.YieldSingle(sourceValue);

var actualLength = actual.Count();
Assert.AreEqual(1, actualLength);
}
var actualLength = actual.Count();
Assert.AreEqual(1, actualLength);
}

[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectFirstItemIsSameAsSourceValue(
object? sourceValue)
{
var actual = Yielder.YieldSingle(sourceValue);
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectFirstItemIsSameAsSourceValue(
object? sourceValue)
{
var actual = Yielder.YieldSingle(sourceValue);

var actualFirst = actual.FirstOrDefault();
Assert.AreSame(sourceValue, actualFirst);
}
var actualFirst = actual.FirstOrDefault();
Assert.AreSame(sourceValue, actualFirst);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#nullable enable

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

public sealed partial class YielderTest
{
public sealed partial class YielderTest
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
using PrimeFuncPack.UnitTest;
using System.Linq;

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

partial class YielderTypedTest
{
partial class YielderTypedTest
[Test]
public void YieldEmpty_ExpectEmptyCollection()
{
[Test]
public void YieldEmpty_ExpectEmptyCollection()
{
var actual = Yielder<StructType?>.YieldEmpty();
Assert.IsEmpty(actual);
}
var actual = Yielder<StructType?>.YieldEmpty();
Assert.IsEmpty(actual);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
using NUnit.Framework;
using System.Linq;

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

partial class YielderTypedTest
{
partial class YielderTypedTest
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectCollectionLengthEqualsOne(
object? sourceValue)
{
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectCollectionLengthEqualsOne(
object? sourceValue)
{
var actual = Yielder<object?>.YieldSingle(sourceValue);
var actual = Yielder<object?>.YieldSingle(sourceValue);

var actualLength = actual.Count();
Assert.AreEqual(1, actualLength);
}
var actualLength = actual.Count();
Assert.AreEqual(1, actualLength);
}

[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectFirstItemIsSameAsSourceValue(
object? sourceValue)
{
var actual = Yielder<object?>.YieldSingle(sourceValue);
[Test]
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))]
public void YieldSingle_ExpectFirstItemIsSameAsSourceValue(
object? sourceValue)
{
var actual = Yielder<object?>.YieldSingle(sourceValue);

var actualFirst = actual.FirstOrDefault();
Assert.AreSame(sourceValue, actualFirst);
}
var actualFirst = actual.FirstOrDefault();
Assert.AreSame(sourceValue, actualFirst);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#nullable enable

namespace PrimeFuncPack.Primitives.Tests
namespace PrimeFuncPack.Primitives.Tests;

public sealed partial class YielderTypedTest
{
public sealed partial class YielderTypedTest
{
}
}
10 changes: 9 additions & 1 deletion src/primitives-linq/Primitives.Linq/Primitives.Linq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,27 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/pfpack/pfpack-primitives</PackageProjectUrl>
<RepositoryUrl>https://github.com/pfpack/pfpack-primitives</RepositoryUrl>
<Company>pfpack</Company>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Description>PrimeFuncPack Primitives.Linq is a core library for .NET consisting of useful extensions making work with Linq easier.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Primitives.Linq</AssemblyName>
<Version>2.0.0-preview.2.0.0</Version>
<Version>2.0.0-preview.2.0.1</Version>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\..\..\docs\primitives-linq\README.md">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

</Project>
15 changes: 7 additions & 8 deletions src/primitives-linq/Primitives.Linq/YieldExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace System.Linq
namespace System.Linq;

public static class YieldExtensions
{
public static class YieldExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IEnumerable<T> YieldSingle<T>(this T value)
=>
Yielder<T>.YieldSingle(value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IEnumerable<T> YieldSingle<T>(this T value)
=>
Yielder<T>.YieldSingle(value);
}
19 changes: 9 additions & 10 deletions src/primitives-linq/Primitives.Linq/Yielder.T.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

using System.Collections.Generic;

namespace System.Linq
namespace System.Linq;

public static class Yielder<T>
{
public static class Yielder<T>
public static IEnumerable<T> YieldSingle(T value)
{
public static IEnumerable<T> YieldSingle(T value)
{
yield return value;
}
yield return value;
}

public static IEnumerable<T> YieldEmpty()
{
yield break;
}
public static IEnumerable<T> YieldEmpty()
{
yield break;
}
}
19 changes: 9 additions & 10 deletions src/primitives-linq/Primitives.Linq/Yielder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

using System.Collections.Generic;

namespace System.Linq
namespace System.Linq;

public static class Yielder
{
public static class Yielder
public static IEnumerable<T> YieldSingle<T>(T value)
{
public static IEnumerable<T> YieldSingle<T>(T value)
{
yield return value;
}
yield return value;
}

public static IEnumerable<T> YieldEmpty<T>()
{
yield break;
}
public static IEnumerable<T> YieldEmpty<T>()
{
yield break;
}
}
Loading

0 comments on commit fd83e72

Please sign in to comment.