Skip to content

Commit

Permalink
Merge pull request #8 from polyadic/prepare-for-stable-release
Browse files Browse the repository at this point in the history
  • Loading branch information
bash committed May 25, 2022
2 parents 89140d6 + 7ced665 commit 57391a8
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
@@ -1 +1,3 @@
* text=auto eol=lf
*.sln text eol=crlf
*.cs diff=csharp
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
efcore: ['3.1.23', '5.0.15', '6.0.3']
efcore: ['3.1.25', '5.0.15', '6.0.3']
env:
EntityFrameworkCoreVersion: ${{matrix.efcore}}
steps:
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.props
Expand Up @@ -8,7 +8,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Messerli.CodeStyle" PrivateAssets="all" />
<PackageReference Include="Funcky.Analyzers" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup Label="Code Style">
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>5.0</AnalysisLevel>
</PropertyGroup>
<PropertyGroup Label="Deterministic Builds and Source Link">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
Expand Down
@@ -1,4 +1,4 @@
using Funcky.EntityFrameworkCore.Extensions;
using Funcky.Extensions;
using Funcky.Xunit;
using Xunit;

Expand Down
@@ -1,4 +1,4 @@
using Funcky.EntityFrameworkCore.Extensions;
using Funcky.Extensions;
using Funcky.Xunit;
using Xunit;

Expand Down
@@ -1,4 +1,4 @@
using Funcky.EntityFrameworkCore.Extensions;
using Funcky.Extensions;
using Funcky.Xunit;
using Xunit;

Expand Down
Expand Up @@ -2,30 +2,30 @@
using Funcky.Monads;
using Microsoft.EntityFrameworkCore;

namespace Funcky.EntityFrameworkCore.Extensions;
namespace Funcky.Extensions;

public static partial class AsyncQueryableExtensions
public static partial class EntityFrameworkQueryableExtensions
{
/// <summary>
/// Returns the first element of a sequence as an <see cref="Option" />, or a <see cref="Option{T}.None" /> value if the sequence contains no elements.
/// </summary>
/// <typeparam name="TSource">the inner type of the queryable.</typeparam>
public static async Task<Option<TSource>> FirstOrNoneAsync<TSource>(this IQueryable<TSource> source)
public static async Task<Option<TSource>> FirstOrNoneAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default)
where TSource : notnull
=> await source
.Select(x => Option.Some(x))
.FirstOrDefaultAsync()
.FirstOrDefaultAsync(cancellationToken)
.ConfigureAwait(false);

/// <summary>
/// Returns the first element of the sequence as an <see cref="Option{T}" /> that satisfies a condition or a <see cref="Option{T}.None" /> value if no such element is found.
/// </summary>
/// <typeparam name="TSource">the inner type of the queryable.</typeparam>
public static async Task<Option<TSource>> FirstOrNoneAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
public static async Task<Option<TSource>> FirstOrNoneAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default)
where TSource : notnull
=> await source
.Where(predicate)
.Select(x => Option.Some(x))
.FirstOrDefaultAsync()
.FirstOrDefaultAsync(cancellationToken)
.ConfigureAwait(false);
}
Expand Up @@ -2,30 +2,30 @@
using Funcky.Monads;
using Microsoft.EntityFrameworkCore;

namespace Funcky.EntityFrameworkCore.Extensions;
namespace Funcky.Extensions;

public static partial class AsyncQueryableExtensions
public static partial class EntityFrameworkQueryableExtensions
{
/// <summary>
/// Returns the last element of a sequence as an <see cref="Option" />, or a <see cref="Option{T}.None" /> value if the sequence contains no elements.
/// </summary>
/// <typeparam name="TSource">the inner type of the queryable.</typeparam>
public static async Task<Option<TSource>> LastOrNoneAsync<TSource>(this IQueryable<TSource> source)
public static async Task<Option<TSource>> LastOrNoneAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default)
where TSource : notnull
=> await source
.Select(x => Option.Some(x))
.LastOrDefaultAsync()
.LastOrDefaultAsync(cancellationToken)
.ConfigureAwait(false);

/// <summary>
/// Returns the last element of a sequence that satisfies a condition as an <see cref="Option{T}" /> or a <see cref="Option{T}.None" /> value if no such element is found.
/// </summary>
/// <typeparam name="TSource">the inner type of the queryable.</typeparam>
public static async Task<Option<TSource>> LastOrNoneAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
public static async Task<Option<TSource>> LastOrNoneAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default)
where TSource : notnull
=> await source
.Where(predicate)
.Select(x => Option.Some(x))
.LastOrDefaultAsync()
.LastOrDefaultAsync(cancellationToken)
.ConfigureAwait(false);
}
Expand Up @@ -2,29 +2,30 @@
using Funcky.Monads;
using Microsoft.EntityFrameworkCore;

namespace Funcky.EntityFrameworkCore.Extensions;
namespace Funcky.Extensions;

public static partial class AsyncQueryableExtensions
public static partial class EntityFrameworkQueryableExtensions
{
/// <summary>
/// Returns the only element of a sequence as an <see cref="Option" />, or a <see cref="Option{T}.None" /> value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.
/// </summary>
/// <typeparam name="TSource">the inner type of the queryable.</typeparam>
public static async Task<Option<TSource>> SingleOrNoneAsync<TSource>(this IQueryable<TSource> source)
public static async Task<Option<TSource>> SingleOrNoneAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default)
where TSource : notnull
=> await source
.Select(x => Option.Some(x))
.SingleOrDefaultAsync();
.SingleOrDefaultAsync(cancellationToken)
.ConfigureAwait(false);

/// <summary>
/// Returns the only element of a sequence that satisfies a specified condition as an <see cref="Option{T}" /> or a <see cref="Option{T}.None" /> value if no such element exists; this method throws an exception if more than one element satisfies the condition.
/// </summary>
/// <typeparam name="TSource">the inner type of the queryable.</typeparam>
public static async Task<Option<TSource>> SingleOrNoneAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
public static async Task<Option<TSource>> SingleOrNoneAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default)
where TSource : notnull
=> await source
.Where(predicate)
.Select(x => Option.Some(x))
.SingleOrDefaultAsync()
.SingleOrDefaultAsync(cancellationToken)
.ConfigureAwait(false);
}
12 changes: 12 additions & 0 deletions Funcky.EntityFrameworkCore/Funcky.EntityFrameworkCore.csproj
Expand Up @@ -8,11 +8,23 @@
<Description>Interoperability between Funcky and EF Core</Description>
<PackageTags>Functional Monad EFCore EntityFramework</PackageTags>
<Version>0.1.0</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup Label="Symbols">
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<NoWarn>$(NoWarn);RS0026</NoWarn><!-- RS0026: Do not add multiple overloads with optional parameters -->
</PropertyGroup>
<PropertyGroup Label="Analyzers">
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisModeReliability>All</AnalysisModeReliability>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Funcky" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<None Include="..\readme.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions Funcky.EntityFrameworkCore/PublicAPI.Shipped.txt
@@ -0,0 +1 @@
#nullable enable
8 changes: 8 additions & 0 deletions Funcky.EntityFrameworkCore/PublicAPI.Unshipped.txt
@@ -0,0 +1,8 @@
#nullable enable
Funcky.Extensions.EntityFrameworkQueryableExtensions
static Funcky.Extensions.EntityFrameworkQueryableExtensions.FirstOrNoneAsync<TSource>(this System.Linq.IQueryable<TSource>! source, System.Linq.Expressions.Expression<System.Func<TSource, bool>!>! predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Funcky.Monads.Option<TSource>>!
static Funcky.Extensions.EntityFrameworkQueryableExtensions.FirstOrNoneAsync<TSource>(this System.Linq.IQueryable<TSource>! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Funcky.Monads.Option<TSource>>!
static Funcky.Extensions.EntityFrameworkQueryableExtensions.LastOrNoneAsync<TSource>(this System.Linq.IQueryable<TSource>! source, System.Linq.Expressions.Expression<System.Func<TSource, bool>!>! predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Funcky.Monads.Option<TSource>>!
static Funcky.Extensions.EntityFrameworkQueryableExtensions.LastOrNoneAsync<TSource>(this System.Linq.IQueryable<TSource>! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Funcky.Monads.Option<TSource>>!
static Funcky.Extensions.EntityFrameworkQueryableExtensions.SingleOrNoneAsync<TSource>(this System.Linq.IQueryable<TSource>! source, System.Linq.Expressions.Expression<System.Func<TSource, bool>!>! predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Funcky.Monads.Option<TSource>>!
static Funcky.Extensions.EntityFrameworkQueryableExtensions.SingleOrNoneAsync<TSource>(this System.Linq.IQueryable<TSource>! source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Funcky.Monads.Option<TSource>>!
6 changes: 4 additions & 2 deletions Packages.props
Expand Up @@ -2,16 +2,18 @@
<Project>
<ItemGroup Label="Runtime Dependencies">
<PackageReference Update="Funcky" Version="[2.2.0, 3)" />
<PackageReference Update="Microsoft.EntityFrameworkCore" Version="[3.1.0, 7)" />
<PackageReference Update="Microsoft.EntityFrameworkCore" Version="[3.1.25, 7)" />
</ItemGroup>
<ItemGroup Label="Build Dependencies">
<PackageReference Update="Funcky.Analyzers" Version="1.1.0" />
<PackageReference Update="Messerli.CodeStyle" Version="2.1.2" />
<PackageReference Update="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
</ItemGroup>
<ItemGroup Label="Test Dependencies">
<PackageReference Update="Funcky.Xunit" Version="0.1.3" />
<PackageReference Update="Microsoft.EntityFrameworkCore.InMemory" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Update="Microsoft.EntityFrameworkCore.InMemory" Version="[3.1.0, 6)" Condition="'$(EntityFrameworkCoreVersion)' == ''" />
<PackageReference Update="Microsoft.EntityFrameworkCore.InMemory" Version="[3.1.25, 6)" Condition="'$(EntityFrameworkCoreVersion)' == ''" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Update="xunit" Version="2.4.0" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.0" />
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
@@ -1,4 +1,7 @@
# Changelog
## Unreleased
* Breaking: Add an optional `cancellationToken` parameter to all async `IQueryable` extensions. (polyadic/funcky#433)
* Breaking: Move extensions to `Funcky.Extensions` namespace. (polyadic/funcky#460)

## 0.1.0
Initial release
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -14,7 +14,7 @@ These are analogous to the ones provided by [`EntityFrameworkQueryableExtensions
Example:
```csharp
using System;
using Funcky.EntityFrameworkCore.Extensions;
using Funcky.Extensions;
using Microsoft.EntityFrameworkCore;

DbContext context;
Expand Down

0 comments on commit 57391a8

Please sign in to comment.