Skip to content

Commit

Permalink
Merge pull request #808 from polyadic/release-3.5.0
Browse files Browse the repository at this point in the history
Prepare 3.5.0 Release
  • Loading branch information
FreeApophis authored Jan 15, 2025
2 parents fe5eb5c + 73fca1c commit 24289b5
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>
<PropertyGroup Label="NuGet Metadata">
<PackageId>Funcky.Analyzers</PackageId>
<PackageVersion>1.3.0</PackageVersion>
<PackageVersion>1.4.0</PackageVersion>
<Description>Analyzers to guide to the correct usage of Funcky.</Description>
<PackageTags>funcky, analyzers, roslyn</PackageTags>
<DevelopmentDependency>true</DevelopmentDependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ Rule ID | Category | Severity | Notes
λ1007 | Funcky | Warning | OptionMatchAnalyzer
λ1008 | Funcky | Warning | OptionMatchAnalyzer

## Release 1.3
## Release 1.4
### New Rules
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
λ1009 | Funcky | Error | NonDefaultableAnalyzer
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
### New Rules
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
λ1009 | Funcky | Error | NonDefaultableAnalyzer
2 changes: 1 addition & 1 deletion Funcky.Async/Funcky.Async.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<Description>Extends Funcky with support for IAsyncEnumerable and Tasks.</Description>
<PackageTags>Functional Async Monad Linq</PackageTags>
<Version>1.3.0</Version>
<Version>1.4.0</Version>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Funcky.Xunit/Funcky.Xunit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<Description>Package to use Funcky with xUnit</Description>
<PackageTags>Functional Monad xUnit</PackageTags>
<Version>2.0.2</Version>
<Version>2.1.0</Version>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<RootNamespace>Funcky</RootNamespace>
Expand Down
6 changes: 6 additions & 0 deletions Funcky/DownCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ namespace Funcky;
public static class DownCast<TResult>
where TResult : class
{
/// <summary>Downcasts the <c>Some</c> value inside the <c>Option</c> to <typeparamref name="TResult"/>.
/// If the cast fails, <c>None</c> is returned.</summary>
public static Option<TResult> From<TItem>(Option<TItem> option)
where TItem : class
=> option.SelectMany(OptionDownCast);

/// <summary>Downcasts the <c>Ok</c> value inside the <c>Result</c> to <typeparamref name="TResult"/>.
/// If the cast fails, an <c>Error</c> value containing a <see cref="InvalidCastException"/> is returned.</summary>
public static Result<TResult> From<TItem>(Result<TItem> result)
where TItem : class
=> result.SelectMany(ResultDownCast);

/// <summary>Downcasts the <c>Left</c> value inside the <c>Either</c> to <typeparamref name="TResult"/>.
/// If the cast fails, the result from calling <paramref name="failedCast"/> is returned.</summary>
public static Either<TLeft, TResult> From<TLeft, TRight>(Either<TLeft, TRight> either, Func<TLeft> failedCast)
where TRight : class
where TLeft : notnull
Expand Down
2 changes: 1 addition & 1 deletion Funcky/Funcky.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Product>Funcky</Product>
<Description>Funcky is a functional C# library</Description>
<PackageTags>Functional Monad Linq</PackageTags>
<VersionPrefix>3.4.0</VersionPrefix>
<VersionPrefix>3.5.0</VersionPrefix>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
8 changes: 8 additions & 0 deletions Funcky/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable enable
Funcky.Discard
Funcky.DownCast<TResult>
Funcky.EitherOrBoth
Funcky.EitherOrBoth<TLeft, TRight>
Funcky.EitherOrBoth<TLeft, TRight>.EitherOrBoth() -> void
Expand Down Expand Up @@ -188,6 +189,9 @@ override Funcky.Monads.Result<TValidResult>.GetHashCode() -> int
override Funcky.Monads.Result<TValidResult>.ToString() -> string!
override Funcky.Unit.Equals(object? obj) -> bool
override Funcky.Unit.GetHashCode() -> int
static Funcky.DownCast<TResult>.From<TItem>(Funcky.Monads.Option<TItem!> option) -> Funcky.Monads.Option<TResult!>
static Funcky.DownCast<TResult>.From<TItem>(Funcky.Monads.Result<TItem!> result) -> Funcky.Monads.Result<TResult!>
static Funcky.DownCast<TResult>.From<TLeft, TRight>(Funcky.Monads.Either<TLeft, TRight!> either, System.Func<TLeft>! failedCast) -> Funcky.Monads.Either<TLeft, TResult!>
static Funcky.EitherOrBoth.FromOptions<TLeft, TRight>(Funcky.Monads.Option<TLeft> left, Funcky.Monads.Option<TRight> right) -> Funcky.Monads.Option<Funcky.EitherOrBoth<TLeft, TRight>>
static Funcky.EitherOrBoth<TLeft, TRight>.Both(TLeft left, TRight right) -> Funcky.EitherOrBoth<TLeft, TRight>
static Funcky.EitherOrBoth<TLeft, TRight>.Left(TLeft left) -> Funcky.EitherOrBoth<TLeft, TRight>
Expand Down Expand Up @@ -377,6 +381,7 @@ static Funcky.Extensions.ListExtensions.FindLastIndexOrNone<TValue>(this System.
static Funcky.Extensions.ListExtensions.FindLastIndexOrNone<TValue>(this System.Collections.Generic.List<TValue>! list, int startIndex, System.Predicate<TValue>! match) -> Funcky.Monads.Option<int>
static Funcky.Extensions.ListExtensions.FindLastIndexOrNone<TValue>(this System.Collections.Generic.List<TValue>! list, System.Predicate<TValue>! match) -> Funcky.Monads.Option<int>
static Funcky.Extensions.ListExtensions.IndexOfOrNone<TValue>(this System.Collections.Generic.IList<TValue>! list, TValue value) -> Funcky.Monads.Option<int>
static Funcky.Extensions.ParseExtensions.ParseAssemblyNameInfoOrNone(this System.ReadOnlySpan<char> candidate) -> Funcky.Monads.Option<System.Reflection.Metadata.AssemblyNameInfo!>
static Funcky.Extensions.ParseExtensions.ParseAuthenticationHeaderValueOrNone(this string? candidate) -> Funcky.Monads.Option<System.Net.Http.Headers.AuthenticationHeaderValue!>
static Funcky.Extensions.ParseExtensions.ParseBigIntegerOrNone(this string? candidate) -> Funcky.Monads.Option<System.Numerics.BigInteger>
static Funcky.Extensions.ParseExtensions.ParseBigIntegerOrNone(this string? candidate, System.Globalization.NumberStyles style, System.IFormatProvider? provider) -> Funcky.Monads.Option<System.Numerics.BigInteger>
Expand Down Expand Up @@ -558,6 +563,7 @@ static Funcky.Extensions.ParseExtensions.ParseTimeSpanOrNone(this System.ReadOnl
static Funcky.Extensions.ParseExtensions.ParseTimeSpanOrNone(this System.ReadOnlySpan<char> candidate, System.IFormatProvider? formatProvider) -> Funcky.Monads.Option<System.TimeSpan>
static Funcky.Extensions.ParseExtensions.ParseTransferCodingHeaderValueOrNone(this string? candidate) -> Funcky.Monads.Option<System.Net.Http.Headers.TransferCodingHeaderValue!>
static Funcky.Extensions.ParseExtensions.ParseTransferCodingWithQualityHeaderValueOrNone(this string? candidate) -> Funcky.Monads.Option<System.Net.Http.Headers.TransferCodingWithQualityHeaderValue!>
static Funcky.Extensions.ParseExtensions.ParseTypeNameOrNone(this System.ReadOnlySpan<char> candidate, System.Reflection.Metadata.TypeNameParseOptions? options = null) -> Funcky.Monads.Option<System.Reflection.Metadata.TypeName!>
static Funcky.Extensions.ParseExtensions.ParseUInt16OrNone(this string? candidate) -> Funcky.Monads.Option<ushort>
static Funcky.Extensions.ParseExtensions.ParseUInt16OrNone(this string? candidate, System.Globalization.NumberStyles style, System.IFormatProvider? provider) -> Funcky.Monads.Option<ushort>
static Funcky.Extensions.ParseExtensions.ParseUInt16OrNone(this string? candidate, System.IFormatProvider? provider) -> Funcky.Monads.Option<ushort>
Expand Down Expand Up @@ -817,9 +823,11 @@ static Funcky.Monads.ResultExtensions.Traverse<TValidResult, TLeft, TRight>(this
static Funcky.Sequence.Concat<TSource>(params System.Collections.Generic.IEnumerable<TSource>![]! sources) -> System.Collections.Generic.IEnumerable<TSource>!
static Funcky.Sequence.Concat<TSource>(System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<TSource>!>! sources) -> System.Collections.Generic.IEnumerable<TSource>!
static Funcky.Sequence.Cycle<TResult>(TResult element) -> System.Collections.Generic.IEnumerable<TResult>!
static Funcky.Sequence.CycleMaterialized<TSource>(System.Collections.Generic.IReadOnlyCollection<TSource>! source) -> System.Collections.Generic.IEnumerable<TSource>!
static Funcky.Sequence.CycleRange<TSource>(System.Collections.Generic.IEnumerable<TSource>! source) -> Funcky.IBuffer<TSource>!
static Funcky.Sequence.FromNullable<TResult>(TResult? element) -> System.Collections.Generic.IEnumerable<TResult!>!
static Funcky.Sequence.FromNullable<TResult>(TResult? element) -> System.Collections.Generic.IEnumerable<TResult>!
static Funcky.Sequence.RepeatMaterialized<TSource>(System.Collections.Generic.IReadOnlyCollection<TSource>! source, int count) -> System.Collections.Generic.IEnumerable<TSource>!
static Funcky.Sequence.RepeatRange<TSource>(System.Collections.Generic.IEnumerable<TSource>! source, int count) -> Funcky.IBuffer<TSource>!
static Funcky.Sequence.Return<TResult>(params TResult[]! elements) -> System.Collections.Generic.IReadOnlyList<TResult>!
static Funcky.Sequence.Return<TResult>(TResult element) -> System.Collections.Generic.IReadOnlyList<TResult>!
Expand Down
8 changes: 0 additions & 8 deletions Funcky/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
#nullable enable
Funcky.DownCast<TResult>
static Funcky.DownCast<TResult>.From<TItem>(Funcky.Monads.Option<TItem!> option) -> Funcky.Monads.Option<TResult!>
static Funcky.DownCast<TResult>.From<TItem>(Funcky.Monads.Result<TItem!> result) -> Funcky.Monads.Result<TResult!>
static Funcky.DownCast<TResult>.From<TLeft, TRight>(Funcky.Monads.Either<TLeft, TRight!> either, System.Func<TLeft>! failedCast) -> Funcky.Monads.Either<TLeft, TResult!>
static Funcky.Extensions.ParseExtensions.ParseTypeNameOrNone(this System.ReadOnlySpan<char> candidate, System.Reflection.Metadata.TypeNameParseOptions? options = null) -> Funcky.Monads.Option<System.Reflection.Metadata.TypeName!>
static Funcky.Extensions.ParseExtensions.ParseAssemblyNameInfoOrNone(this System.ReadOnlySpan<char> candidate) -> Funcky.Monads.Option<System.Reflection.Metadata.AssemblyNameInfo!>
static Funcky.Sequence.CycleMaterialized<TSource>(System.Collections.Generic.IReadOnlyCollection<TSource>! source) -> System.Collections.Generic.IEnumerable<TSource>!
static Funcky.Sequence.RepeatMaterialized<TSource>(System.Collections.Generic.IReadOnlyCollection<TSource>! source, int count) -> System.Collections.Generic.IEnumerable<TSource>!
58 changes: 57 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@
All notable changes to this project will be documented in this file.
Funcky adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Funcky 3.5.0 | Funcky.Async 1.4.0 | Funcky.Xunit 2.1.0 | Funcky.Analyzers 1.4.0
This update is mainly to update to .NET 9 but also has several smaller improvements.

### .NET 9
Thanks to the new `[OverloadResolutionPriority]` attribute, we've been able finally fix
the ambiguous call errors when using `DictionaryExtensions.GetValueOrNone`:

```csharp
Dictionary<string, string> favouriteFoods = new();
Option<int> tausFavouriteFood = favouriteFoods.GetValueOrNone("Tau");
// ^^^^^^^^^^^^^^
// This used to produce a `error CS0121: The call is ambiguous between ...` error
// and now simply works 🎉
```

In good old fashion, we've also added new parse extensions:
* `ParseExtensions.ParseAssemblyNameInfoOrNone`
* `ParseExtensions.ParseTypeNameOrNone`

### Policy for EOL Target Frameworks
We've [explicitly written down](SupportPolicy.md) our policy for how we deal
with older / EOL target frameworks.

In short: EOL target frameworks are supported by Funcky until the next major version.
However, we may no longer test Funcky against those target frameworks, so we
can't guarantee that everything works smoothly.

## New APIs
In Funcky 3.0 we've changed `CycleRange` and `RepeatRange` to return an `IBuffer`
to enable us to memoize the collection, preventing unnecessary enumeration. This however
is unpractical for uses where you want to cycle an already materialized collection.
This release adds two new methods to accommodate that use case:
`CycleMaterialized` and `RepeatMaterialized`.

For convenient downcasting of `Option<T>`, `Result<T>` and `Either<TLeft, T>` values, we've added a new
`DownCast` class:

```csharp
Option<object> option = Option.Some("hello world");
Option<string> downcasted = DownCast<string>.From(option);
```

### Funcky.XUnit
`Funcky.XUnit` has been updated to the latest version (2.9.3) of xUnit.net.

Due to changes in xUnit we've had to change the exception type thrown by our `FunctionalAssert` methods
from `AssertActualExpectedException` to `XunitException`.

### Funcky.Analyzers
The new analyzer rule `λ1009` prevents you from accidentally `default`-instantiating
`Either`, `Result` and `EitherOrBoth`.

### Funcky.Async
The `PowerSet` and `WithPrevious` extensions now correctly pass along the cancellation token.


## Funcky 3.4.0 | Funcky.Async 1.3.0 | Funcky.XUnit 2.0.2

This update is mainly to update to .NET 8 but also has several smaller improvements.
Expand Down Expand Up @@ -43,7 +99,7 @@ We implemented a few of the IEnumerable extensions which are very useful on stri
* Implemented `InspectEmpty` on `IEnumerable` and `IAsyncEnumerable`
* Implemented `ToAsyncEnumerable` extension on `Option`

### IEnumerator
### IEnumerator

* `MoveNextOrNone` extension on `IEnumerator<T>`

Expand Down

0 comments on commit 24289b5

Please sign in to comment.