Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHANGELOG supplementation #127

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ dotnet_diagnostic.SA1642.severity = none

# SA1516: Elements should be separated by blank line
dotnet_diagnostic.SA1516.severity = none

[*.csproj]
indent_size = 2
143 changes: 111 additions & 32 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,135 @@

All notable changes to this project are documented in this file.

## [1.10.0] - 2024-02-14
## [3.0.0-alpha.0] - to be released

### Added
### Breaking Changes

- `ErrorType.Forbidden`
- README to NuGet package
- [#104](https://github.com/amantinband/error-or/pull/104) Support for .NET 6 was removed

## [1.9.0] - 2024-01-06
- [#105](https://github.com/amantinband/error-or/pull/105) Invalid use of library now throws exception instead of return errors

Following actions now throws `InvalidOperationException`:

1. Default `ErrorOr` constructor invocation.
2. Accessing `ErrorOr.Errors` and `ErrorOr.FirstError` on success result.
3. Accessing `ErrorOr.Value` on result with errors.

### Added

- `ToErrorOr`
- [#94](https://github.com/amantinband/error-or/issues/94), [#95](https://github.com/amantinband/error-or/pull/95) Added missing async versions of `FailIf` methods

## [2.0.0] - 2024-03-26
```cs
public async Task<ErrorOr<TValue>> FailIfAsync(Func<TValue, Task<bool>> onValue, Error error)
```

### Added
```cs
public static async Task<ErrorOr<TValue>> FailIf<TValue>(
this Task<ErrorOr<TValue>> errorOr,
Func<TValue, bool> onValue,
Error error)
```

- `FailIf`
```cs
public static async Task<ErrorOr<TValue>> FailIfAsync<TValue>(
this Task<ErrorOr<TValue>> errorOr,
Func<TValue, Task<bool>> onValue,
Error error)
```

- [#104](https://github.com/amantinband/error-or/pull/104) Support for .NET 8 was added

- [#109](https://github.com/amantinband/error-or/issues/109), [#111](https://github.com/amantinband/error-or/pull/111) Added `FailIf` method overloads that allow to use value in error definition using `Func<TValue, Error>` error builder

```cs
public ErrorOr<TValue> FailIf(Func<TValue, bool> onValue, Func<TValue, Error> errorBuilder)
```

```cs
public async Task<ErrorOr<TValue>> FailIfAsync(Func<TValue, Task<bool>> onValue, Func<TValue, Task<Error>> errorBuilder)
```

```cs
public static async Task<ErrorOr<TValue>> FailIf<TValue>(
this Task<ErrorOr<TValue>> errorOr,
Func<TValue, bool> onValue,
Func<TValue, Error> errorBuilder)
```

```cs
public static async Task<ErrorOr<TValue>> FailIfAsync<TValue>(
this Task<ErrorOr<TValue>> errorOr,
Func<TValue, Task<bool>> onValue,
Func<TValue, Task<Error>> errorBuilder)
```

Value can now be used to build the error:

```cs
ErrorOr<int> result = errorOrInt
.FailIf(num => num > 3, (num) => Error.Failure(description: $"{num} is greater than 3"));
```

### Fixed

- [#85](https://github.com/amantinband/error-or/issues/85), [#97](https://github.com/amantinband/error-or/pull/97) `ErrorOr` turned into Value Object by reimplementing `Equals` and `GetHashCode` methods

```csharp
public ErrorOr<TValue> FailIf(Func<TValue, bool> onValue, Error error)
```
New dependency was introduced to [Microsoft.Bcl.HashCode](https://www.nuget.org/packages/Microsoft.Bcl.HashCode) and development dependency was introduced to [Nullable](https://www.nuget.org/packages/Nullable)

```csharp
ErrorOr<int> errorOr = 1;
errorOr.FailIf(x => x > 0, Error.Failure());
```
### Optimized

- [#98](https://github.com/amantinband/error-or/issues/98), [#99](https://github.com/amantinband/error-or/pull/99) Memory consumption optimized by moving static empty errors lists from generic struct into non-generic class

## [2.0.1] - 2024-03-26

### Breaking Changes

- `Then` that receives an action is now called `ThenDo`

```diff
-public ErrorOr<TValue> Then(Action<TValue> action)
+public ErrorOr<TValue> ThenDo(Action<TValue> action)
```
```diff
-public ErrorOr<TValue> Then(Action<TValue> action)
+public ErrorOr<TValue> ThenDo(Action<TValue> action)
```

```diff
-public static async Task<ErrorOr<TValue>> Then<TValue>(this Task<ErrorOr<TValue>> errorOr, Action<TValue> action)
+public static async Task<ErrorOr<TValue>> ThenDo<TValue>(this Task<ErrorOr<TValue>> errorOr, Action<TValue> action)
```
```diff
-public static async Task<ErrorOr<TValue>> Then<TValue>(this Task<ErrorOr<TValue>> errorOr, Action<TValue> action)
+public static async Task<ErrorOr<TValue>> ThenDo<TValue>(this Task<ErrorOr<TValue>> errorOr, Action<TValue> action)
```

- `ThenAsync` that receives an action is now called `ThenDoAsync`

```diff
-public async Task<ErrorOr<TValue>> ThenAsync(Func<TValue, Task> action)
+public async Task<ErrorOr<TValue>> ThenDoAsync(Func<TValue, Task> action)
```
```diff
-public async Task<ErrorOr<TValue>> ThenAsync(Func<TValue, Task> action)
+public async Task<ErrorOr<TValue>> ThenDoAsync(Func<TValue, Task> action)
```

```diff
-public static async Task<ErrorOr<TValue>> ThenAsync<TValue>(this Task<ErrorOr<TValue>> errorOr, Func<TValue, Task> action)
+public static async Task<ErrorOr<TValue>> ThenDoAsync<TValue>(this Task<ErrorOr<TValue>> errorOr, Func<TValue, Task> action)
```

### Added

- `FailIf`

```csharp
public ErrorOr<TValue> FailIf(Func<TValue, bool> onValue, Error error)
```

```csharp
ErrorOr<int> errorOr = 1;
errorOr.FailIf(x => x > 0, Error.Failure());
```

## [1.10.0] - 2024-02-14

```diff
-public static async Task<ErrorOr<TValue>> ThenAsync<TValue>(this Task<ErrorOr<TValue>> errorOr, Func<TValue, Task> action)
+public static async Task<ErrorOr<TValue>> ThenDoAsync<TValue>(this Task<ErrorOr<TValue>> errorOr, Func<TValue, Task> action)
```
### Added

- `ErrorType.Forbidden`
- README to NuGet package

## [1.9.0] - 2024-01-06

### Added

- `ToErrorOr`
3 changes: 2 additions & 1 deletion src/ErrorOr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
</PropertyGroup>
<PropertyGroup>
<PackageId>ErrorOr</PackageId>
<Version>2.0.1</Version>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionSuffix>alpha.0</VersionSuffix>
<Authors>Amichai Mantinband</Authors>
<PackageIcon>icon-square.png</PackageIcon>
<PackageTags>Result,Results,ErrorOr,Error,Handling</PackageTags>
Expand Down