diff --git a/ComparisonBenchmarks/Benchmarks.A_LightResults.cs b/ComparisonBenchmarks/Benchmarks.A_LightResults.cs index ad85496..c4d49d2 100644 --- a/ComparisonBenchmarks/Benchmarks.A_LightResults.cs +++ b/ComparisonBenchmarks/Benchmarks.A_LightResults.cs @@ -17,22 +17,22 @@ private void SetupLightResults() var enumerable = new List<Result>(); for (int i = 0; i < Iterations; i++) - enumerable.Add(random.Next(0, 1) == 0 ? Result.Ok() : Result.Fail(i.ToString())); + enumerable.Add(random.Next(0, 1) == 0 ? Result.Success() : Result.Failure(i.ToString())); _lightResultsEnumerable = enumerable.AsEnumerable(); var readOnlyList = new List<Result>(); for (int i = 0; i < Iterations; i++) - readOnlyList.Add(random.Next(0, 1) == 0 ? Result.Ok() : Result.Fail(i.ToString())); + readOnlyList.Add(random.Next(0, 1) == 0 ? Result.Success() : Result.Failure(i.ToString())); _lightResultsReadOnlyList = readOnlyList; var enumerableT = new List<Result<int>>(); for (int i = 0; i < Iterations; i++) - enumerableT.Add(random.Next(0, 1) == 0 ? Result.Ok(i) : Result.Fail<int>(i.ToString())); + enumerableT.Add(random.Next(0, 1) == 0 ? Result.Success(i) : Result.Failure<int>(i.ToString())); _lightResultsTValueEnumerable = enumerableT.AsEnumerable(); var readOnlyListT = new List<Result<int>>(); for (int i = 0; i < Iterations; i++) - readOnlyListT.Add(random.Next(0, 1) == 0 ? Result.Ok(i) : Result.Fail<int>(i.ToString())); + readOnlyListT.Add(random.Next(0, 1) == 0 ? Result.Success(i) : Result.Failure<int>(i.ToString())); _lightResultsTValueReadOnlyList = readOnlyListT; } diff --git a/src/LightResults.Extensions.EntityFrameworkCore/LightResults.Extensions.EntityFrameworkCore.csproj b/src/LightResults.Extensions.EntityFrameworkCore/LightResults.Extensions.EntityFrameworkCore.csproj index 92298eb..8988041 100644 --- a/src/LightResults.Extensions.EntityFrameworkCore/LightResults.Extensions.EntityFrameworkCore.csproj +++ b/src/LightResults.Extensions.EntityFrameworkCore/LightResults.Extensions.EntityFrameworkCore.csproj @@ -29,7 +29,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="LightResults" Version="8.0.10"/> + <PackageReference Include="LightResults" Version="8.0.11" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/> </ItemGroup> diff --git a/src/LightResults.Extensions.ExceptionHandling/LightResults.Extensions.ExceptionHandling.csproj b/src/LightResults.Extensions.ExceptionHandling/LightResults.Extensions.ExceptionHandling.csproj index 868281f..f5de6b7 100644 --- a/src/LightResults.Extensions.ExceptionHandling/LightResults.Extensions.ExceptionHandling.csproj +++ b/src/LightResults.Extensions.ExceptionHandling/LightResults.Extensions.ExceptionHandling.csproj @@ -18,7 +18,7 @@ <!-- References --> <ItemGroup> - <PackageReference Include="LightResults" Version="8.0.10"/> + <PackageReference Include="LightResults" Version="8.0.11" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/> </ItemGroup> diff --git a/src/LightResults.Extensions.GeneratedIdentifier/GeneratedIdentifierSourceGenerator.cs b/src/LightResults.Extensions.GeneratedIdentifier/GeneratedIdentifierSourceGenerator.cs index eb84188..2efef11 100644 --- a/src/LightResults.Extensions.GeneratedIdentifier/GeneratedIdentifierSourceGenerator.cs +++ b/src/LightResults.Extensions.GeneratedIdentifier/GeneratedIdentifierSourceGenerator.cs @@ -225,10 +225,10 @@ namespace {symbolNamespace}; public static Result<{{symbolName}}> TryCreate({{declaredValueType}} value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<{{symbolName}}>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<{{symbolName}}>(error); - return Result.Ok<{{symbolName}}>(new {{symbolName}}(value, true)); + return Result.Success<{{symbolName}}>(new {{symbolName}}(value, true)); } """ @@ -257,7 +257,7 @@ namespace {symbolNamespace}; if ({{declaredValueType}}.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<{{symbolName}}>("The string is not a valid identifier."); + return Result.Failure<{{symbolName}}>("The string is not a valid identifier."); } """ @@ -644,7 +644,7 @@ public override string ToString() source.AppendLine($$""" private static Result Validate({{declaredValueType}} value) { - return Result.Ok(); + return Result.Success(); } """ ); @@ -653,9 +653,9 @@ private static Result Validate({{declaredValueType}} value) private static Result Validate({{declaredValueType}} value) { if (string.IsNullOrWhiteSpace(value)) - return Result.Fail("The value must not be empty."); + return Result.Failure("The value must not be empty."); - return Result.Ok(); + return Result.Success(); } """ ); @@ -664,9 +664,9 @@ private static Result Validate({{declaredValueType}} value) private static Result Validate({{declaredValueType}} value) { if (value < 0) - return Result.Fail("The value must be equal to or greater than zero."); + return Result.Failure("The value must be equal to or greater than zero."); - return Result.Ok(); + return Result.Success(); } """ ); diff --git a/src/LightResults.Extensions.GeneratedIdentifier/LightResults.Extensions.GeneratedIdentifier.csproj b/src/LightResults.Extensions.GeneratedIdentifier/LightResults.Extensions.GeneratedIdentifier.csproj index e898036..363f87d 100644 --- a/src/LightResults.Extensions.GeneratedIdentifier/LightResults.Extensions.GeneratedIdentifier.csproj +++ b/src/LightResults.Extensions.GeneratedIdentifier/LightResults.Extensions.GeneratedIdentifier.csproj @@ -20,12 +20,12 @@ <!-- References --> <ItemGroup> - <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" PrivateAssets="all"/> + <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" /> <PackageReference Include="PolySharp" Version="1.15.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" PrivateAssets="all" GeneratePathProperty="true"/> + <PackageReference Include="Microsoft.Bcl.HashCode" Version="6.0.0" PrivateAssets="all" GeneratePathProperty="true"/> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all"/> <PackageReference Include="SonarAnalyzer.CSharp" Version="10.4.0.108396"> <PrivateAssets>all</PrivateAssets> diff --git a/src/LightResults.Extensions.Json/LightResults.Extensions.Json.csproj b/src/LightResults.Extensions.Json/LightResults.Extensions.Json.csproj index f16eb12..f53d60e 100644 --- a/src/LightResults.Extensions.Json/LightResults.Extensions.Json.csproj +++ b/src/LightResults.Extensions.Json/LightResults.Extensions.Json.csproj @@ -17,7 +17,7 @@ <!-- References --> <ItemGroup> - <PackageReference Include="LightResults" Version="9.0.0" /> + <PackageReference Include="LightResults" Version="8.0.11" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/> </ItemGroup> diff --git a/src/LightResults.Extensions.Json/ResultJsonConverter.cs b/src/LightResults.Extensions.Json/ResultJsonConverter.cs index acfcfcb..e09cd11 100644 --- a/src/LightResults.Extensions.Json/ResultJsonConverter.cs +++ b/src/LightResults.Extensions.Json/ResultJsonConverter.cs @@ -39,7 +39,7 @@ public override Result Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS public override void Write(Utf8JsonWriter writer, Result value, JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.IsSuccess()) + if (value.IsSuccess) { writer.WriteBoolean(IsSuccess, true); } diff --git a/src/LightResults.Extensions.Json/ResultJsonConverter`1.cs b/src/LightResults.Extensions.Json/ResultJsonConverter`1.cs index 5564a85..4661093 100644 --- a/src/LightResults.Extensions.Json/ResultJsonConverter`1.cs +++ b/src/LightResults.Extensions.Json/ResultJsonConverter`1.cs @@ -41,10 +41,10 @@ public override Result<TValue> Read(ref Utf8JsonReader reader, Type typeToConver public override void Write(Utf8JsonWriter writer, Result<TValue> value, JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.IsSuccess(out var resultValue)) + if (value.IsSuccess) { writer.WriteBoolean(IsSuccess, true); - WriteObject(writer, Value, resultValue); + WriteObject(writer, Value, value.Value); } else { diff --git a/src/LightResults.Extensions.Operations/EnumerableExtensions.cs b/src/LightResults.Extensions.Operations/EnumerableExtensions.cs index a553712..c48d5da 100644 --- a/src/LightResults.Extensions.Operations/EnumerableExtensions.cs +++ b/src/LightResults.Extensions.Operations/EnumerableExtensions.cs @@ -34,7 +34,7 @@ public static Result Collect(this IEnumerable<Result> results) errors.AddRange(next.Errors); } - return errors is { Count: > 0 } ? Result.Fail(errors.AsReadOnly()) : Result.Ok(); + return errors is { Count: > 0 } ? Result.Failure(errors.AsReadOnly()) : Result.Success(); } /// <summary>Combine multiple results into a single result.</summary> @@ -65,7 +65,7 @@ public static Result Collect(this IReadOnlyList<Result> results) errors.AddRange(next.Errors); } - return errors is { Count: > 0 } ? Result.Fail(errors.AsReadOnly()) : Result.Ok(); + return errors is { Count: > 0 } ? Result.Failure(errors.AsReadOnly()) : Result.Success(); } /// <summary>Combine multiple results into a single result.</summary> @@ -106,7 +106,7 @@ public static Result<IReadOnlyList<TValue>> Collect<TValue>(this IEnumerable<Res Debug.Assert(errors is { Count: > 0 } || values is not null); - return errors is { Count: > 0 } ? Result.Fail<IReadOnlyList<TValue>>(errors.AsReadOnly()) : Result.Ok<IReadOnlyList<TValue>>(values!.AsReadOnly()); + return errors is { Count: > 0 } ? Result.Failure<IReadOnlyList<TValue>>(errors.AsReadOnly()) : Result.Success<IReadOnlyList<TValue>>(values!.AsReadOnly()); } /// <summary>Combine multiple results into a single result.</summary> @@ -146,6 +146,6 @@ public static Result<IReadOnlyList<TValue>> Collect<TValue>(this IReadOnlyList<R Debug.Assert(errors is { Count: > 0 } || values is not null); - return errors is { Count: > 0 } ? Result.Fail<IReadOnlyList<TValue>>(errors.AsReadOnly()) : Result.Ok<IReadOnlyList<TValue>>(values!.AsReadOnly()); + return errors is { Count: > 0 } ? Result.Failure<IReadOnlyList<TValue>>(errors.AsReadOnly()) : Result.Success<IReadOnlyList<TValue>>(values!.AsReadOnly()); } } diff --git a/src/LightResults.Extensions.Operations/LightResults.Extensions.Operations.csproj b/src/LightResults.Extensions.Operations/LightResults.Extensions.Operations.csproj index 5762285..1e70031 100644 --- a/src/LightResults.Extensions.Operations/LightResults.Extensions.Operations.csproj +++ b/src/LightResults.Extensions.Operations/LightResults.Extensions.Operations.csproj @@ -17,7 +17,7 @@ <!-- References --> <ItemGroup> - <PackageReference Include="LightResults" Version="9.0.0-preview.15" /> + <PackageReference Include="LightResults" Version="9.0.0" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/> </ItemGroup> diff --git a/src/LightResults.Extensions.ValueObjects/LightResults.Extensions.ValueObjects.csproj b/src/LightResults.Extensions.ValueObjects/LightResults.Extensions.ValueObjects.csproj index e4ee0e5..3d52c6a 100644 --- a/src/LightResults.Extensions.ValueObjects/LightResults.Extensions.ValueObjects.csproj +++ b/src/LightResults.Extensions.ValueObjects/LightResults.Extensions.ValueObjects.csproj @@ -17,7 +17,7 @@ <!-- References --> <ItemGroup> - <PackageReference Include="LightResults" Version="9.0.0-preview.15"/> + <PackageReference Include="LightResults" Version="9.0.0" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/> </ItemGroup> diff --git a/src/LightResults.Extensions.ValueObjects/ValueObjectCollection.cs b/src/LightResults.Extensions.ValueObjects/ValueObjectCollection.cs index 2ff9ebc..17e87c7 100644 --- a/src/LightResults.Extensions.ValueObjects/ValueObjectCollection.cs +++ b/src/LightResults.Extensions.ValueObjects/ValueObjectCollection.cs @@ -41,10 +41,10 @@ public static Result<ValueObjectCollection<TValue>> TryParse(string s) .IsSuccess(out var valueObject, out var error)) builder.Add(valueObject); else - return Result.Fail<ValueObjectCollection<TValue>>(error); + return Result.Failure<ValueObjectCollection<TValue>>(error); } var values = new ValueObjectCollection<TValue>(builder.ToImmutable()); - return Result.Ok(values); + return Result.Success(values); } public static bool TryParse(string s, out ValueObjectCollection<TValue> valueObjectCollection) diff --git a/src/LightResults.Extensions.ValueObjects/ValueObjectException.cs b/src/LightResults.Extensions.ValueObjects/ValueObjectException.cs index e2aa3c5..21196a9 100644 --- a/src/LightResults.Extensions.ValueObjects/ValueObjectException.cs +++ b/src/LightResults.Extensions.ValueObjects/ValueObjectException.cs @@ -20,7 +20,7 @@ public static void ThrowIfFailed(IResult result) { ArgumentNullException.ThrowIfNull(result); - if (result.IsFailed(out var error)) + if (result.IsFailure(out var error)) throw new ValueObjectException(error.Message); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Fixtures/LightResults.Extensions.GeneratedIdentifier.Fixtures.csproj b/tests/LightResults.Extensions.GeneratedIdentifier.Fixtures/LightResults.Extensions.GeneratedIdentifier.Fixtures.csproj index c4379bd..137b104 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Fixtures/LightResults.Extensions.GeneratedIdentifier.Fixtures.csproj +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Fixtures/LightResults.Extensions.GeneratedIdentifier.Fixtures.csproj @@ -22,7 +22,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="LightResults" Version="9.0.0-preview.15"/> + <PackageReference Include="LightResults" Version="9.0.0" /> <PackageReference Include="LightResults.Extensions.ValueObjects" Version="9.0.0-preview.3"/> </ItemGroup> diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateGuidIdentifier_WithNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateGuidIdentifier_WithNamespace.verified.txt index 2f7616c..53a057c 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateGuidIdentifier_WithNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateGuidIdentifier_WithNamespace.verified.txt @@ -57,10 +57,10 @@ public readonly partial struct TestGuidId : public static Result<TestGuidId> TryCreate(Guid value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestGuidId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestGuidId>(error); - return Result.Ok<TestGuidId>(new TestGuidId(value, true)); + return Result.Success<TestGuidId>(new TestGuidId(value, true)); } /// <inheritdoc /> @@ -79,7 +79,7 @@ public readonly partial struct TestGuidId : if (Guid.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<TestGuidId>("The string is not a valid identifier."); + return Result.Failure<TestGuidId>("The string is not a valid identifier."); } /// <inheritdoc /> @@ -195,7 +195,7 @@ public readonly partial struct TestGuidId : private static Result Validate(Guid value) { - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateGuidIdentifier_WithoutNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateGuidIdentifier_WithoutNamespace.verified.txt index 976d1bd..f1e26fa 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateGuidIdentifier_WithoutNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateGuidIdentifier_WithoutNamespace.verified.txt @@ -55,10 +55,10 @@ public readonly partial struct TestGuidId : public static Result<TestGuidId> TryCreate(Guid value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestGuidId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestGuidId>(error); - return Result.Ok<TestGuidId>(new TestGuidId(value, true)); + return Result.Success<TestGuidId>(new TestGuidId(value, true)); } /// <inheritdoc /> @@ -77,7 +77,7 @@ public readonly partial struct TestGuidId : if (Guid.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<TestGuidId>("The string is not a valid identifier."); + return Result.Failure<TestGuidId>("The string is not a valid identifier."); } /// <inheritdoc /> @@ -193,7 +193,7 @@ public readonly partial struct TestGuidId : private static Result Validate(Guid value) { - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateIntIdentifier_WithNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateIntIdentifier_WithNamespace.verified.txt index 05f99c3..a439989 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateIntIdentifier_WithNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateIntIdentifier_WithNamespace.verified.txt @@ -57,10 +57,10 @@ public readonly partial struct TestIntId : public static Result<TestIntId> TryCreate(int value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestIntId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestIntId>(error); - return Result.Ok<TestIntId>(new TestIntId(value, true)); + return Result.Success<TestIntId>(new TestIntId(value, true)); } /// <inheritdoc /> @@ -79,7 +79,7 @@ public readonly partial struct TestIntId : if (int.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<TestIntId>("The string is not a valid identifier."); + return Result.Failure<TestIntId>("The string is not a valid identifier."); } /// <inheritdoc /> @@ -196,9 +196,9 @@ public readonly partial struct TestIntId : private static Result Validate(int value) { if (value < 0) - return Result.Fail("The value must be equal to or greater than zero."); + return Result.Failure("The value must be equal to or greater than zero."); - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateIntIdentifier_WithoutNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateIntIdentifier_WithoutNamespace.verified.txt index 5c9022b..298acf6 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateIntIdentifier_WithoutNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateIntIdentifier_WithoutNamespace.verified.txt @@ -55,10 +55,10 @@ public readonly partial struct TestIntId : public static Result<TestIntId> TryCreate(int value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestIntId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestIntId>(error); - return Result.Ok<TestIntId>(new TestIntId(value, true)); + return Result.Success<TestIntId>(new TestIntId(value, true)); } /// <inheritdoc /> @@ -77,7 +77,7 @@ public readonly partial struct TestIntId : if (int.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<TestIntId>("The string is not a valid identifier."); + return Result.Failure<TestIntId>("The string is not a valid identifier."); } /// <inheritdoc /> @@ -194,9 +194,9 @@ public readonly partial struct TestIntId : private static Result Validate(int value) { if (value < 0) - return Result.Fail("The value must be equal to or greater than zero."); + return Result.Failure("The value must be equal to or greater than zero."); - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateLongIdentifier_WithNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateLongIdentifier_WithNamespace.verified.txt index 0b3e35d..f844564 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateLongIdentifier_WithNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateLongIdentifier_WithNamespace.verified.txt @@ -57,10 +57,10 @@ public readonly partial struct TestLongId : public static Result<TestLongId> TryCreate(long value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestLongId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestLongId>(error); - return Result.Ok<TestLongId>(new TestLongId(value, true)); + return Result.Success<TestLongId>(new TestLongId(value, true)); } /// <inheritdoc /> @@ -79,7 +79,7 @@ public readonly partial struct TestLongId : if (long.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<TestLongId>("The string is not a valid identifier."); + return Result.Failure<TestLongId>("The string is not a valid identifier."); } /// <inheritdoc /> @@ -196,9 +196,9 @@ public readonly partial struct TestLongId : private static Result Validate(long value) { if (value < 0) - return Result.Fail("The value must be equal to or greater than zero."); + return Result.Failure("The value must be equal to or greater than zero."); - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateLongIdentifier_WithoutNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateLongIdentifier_WithoutNamespace.verified.txt index f466b33..dccad8b 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateLongIdentifier_WithoutNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateLongIdentifier_WithoutNamespace.verified.txt @@ -55,10 +55,10 @@ public readonly partial struct TestLongId : public static Result<TestLongId> TryCreate(long value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestLongId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestLongId>(error); - return Result.Ok<TestLongId>(new TestLongId(value, true)); + return Result.Success<TestLongId>(new TestLongId(value, true)); } /// <inheritdoc /> @@ -77,7 +77,7 @@ public readonly partial struct TestLongId : if (long.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<TestLongId>("The string is not a valid identifier."); + return Result.Failure<TestLongId>("The string is not a valid identifier."); } /// <inheritdoc /> @@ -194,9 +194,9 @@ public readonly partial struct TestLongId : private static Result Validate(long value) { if (value < 0) - return Result.Fail("The value must be equal to or greater than zero."); + return Result.Failure("The value must be equal to or greater than zero."); - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateShortIdentifier_WithNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateShortIdentifier_WithNamespace.verified.txt index 8d33b39..5ef37bd 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateShortIdentifier_WithNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateShortIdentifier_WithNamespace.verified.txt @@ -57,10 +57,10 @@ public readonly partial struct TestShortId : public static Result<TestShortId> TryCreate(short value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestShortId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestShortId>(error); - return Result.Ok<TestShortId>(new TestShortId(value, true)); + return Result.Success<TestShortId>(new TestShortId(value, true)); } /// <inheritdoc /> @@ -79,7 +79,7 @@ public readonly partial struct TestShortId : if (short.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<TestShortId>("The string is not a valid identifier."); + return Result.Failure<TestShortId>("The string is not a valid identifier."); } /// <inheritdoc /> @@ -196,9 +196,9 @@ public readonly partial struct TestShortId : private static Result Validate(short value) { if (value < 0) - return Result.Fail("The value must be equal to or greater than zero."); + return Result.Failure("The value must be equal to or greater than zero."); - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateShortIdentifier_WithoutNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateShortIdentifier_WithoutNamespace.verified.txt index d1d8df7..636d527 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateShortIdentifier_WithoutNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateShortIdentifier_WithoutNamespace.verified.txt @@ -55,10 +55,10 @@ public readonly partial struct TestShortId : public static Result<TestShortId> TryCreate(short value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestShortId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestShortId>(error); - return Result.Ok<TestShortId>(new TestShortId(value, true)); + return Result.Success<TestShortId>(new TestShortId(value, true)); } /// <inheritdoc /> @@ -77,7 +77,7 @@ public readonly partial struct TestShortId : if (short.TryParse(s, out var value)) return TryCreate(value); - return Result.Fail<TestShortId>("The string is not a valid identifier."); + return Result.Failure<TestShortId>("The string is not a valid identifier."); } /// <inheritdoc /> @@ -194,9 +194,9 @@ public readonly partial struct TestShortId : private static Result Validate(short value) { if (value < 0) - return Result.Fail("The value must be equal to or greater than zero."); + return Result.Failure("The value must be equal to or greater than zero."); - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateStringIdentifier_WithNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateStringIdentifier_WithNamespace.verified.txt index 863da50..51b3875 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateStringIdentifier_WithNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateStringIdentifier_WithNamespace.verified.txt @@ -53,10 +53,10 @@ public sealed partial class TestStringId : public static Result<TestStringId> TryCreate(string value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestStringId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestStringId>(error); - return Result.Ok<TestStringId>(new TestStringId(value, true)); + return Result.Success<TestStringId>(new TestStringId(value, true)); } /// <inheritdoc /> @@ -188,9 +188,9 @@ public sealed partial class TestStringId : private static Result Validate(string value) { if (string.IsNullOrWhiteSpace(value)) - return Result.Fail("The value must not be empty."); + return Result.Failure("The value must not be empty."); - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateStringIdentifier_WithoutNamespace.verified.txt b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateStringIdentifier_WithoutNamespace.verified.txt index 85b25b7..8433422 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateStringIdentifier_WithoutNamespace.verified.txt +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/GeneratedIdentifierSourceGeneratorTests.GenerateStringIdentifier_WithoutNamespace.verified.txt @@ -51,10 +51,10 @@ public sealed partial class TestStringId : public static Result<TestStringId> TryCreate(string value) { var validation = Validate(value); - if (validation.IsFailed(out var error)) - return Result.Fail<TestStringId>(error); + if (validation.IsFailure(out var error)) + return Result.Failure<TestStringId>(error); - return Result.Ok<TestStringId>(new TestStringId(value, true)); + return Result.Success<TestStringId>(new TestStringId(value, true)); } /// <inheritdoc /> @@ -186,9 +186,9 @@ public sealed partial class TestStringId : private static Result Validate(string value) { if (string.IsNullOrWhiteSpace(value)) - return Result.Fail("The value must not be empty."); + return Result.Failure("The value must not be empty."); - return Result.Ok(); + return Result.Success(); } } diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/LightResults.Extensions.GeneratedIdentifier.Tests.csproj b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/LightResults.Extensions.GeneratedIdentifier.Tests.csproj index ecbccb7..362d92b 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/LightResults.Extensions.GeneratedIdentifier.Tests.csproj +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/LightResults.Extensions.GeneratedIdentifier.Tests.csproj @@ -24,7 +24,6 @@ <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" PrivateAssets="all" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/> <PackageReference Include="SourceGeneratorTestHelpers.XUnit" Version="8.1.0"/> <PackageReference Include="Verify.DiffPlex" Version="3.1.2"/> diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestGuidIdTest.cs b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestGuidIdTest.cs index b0c07c2..061c1b5 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestGuidIdTest.cs +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestGuidIdTest.cs @@ -108,7 +108,7 @@ public void TryParse_InvalidString_ShouldFail(string invalidString) var result = TestGuidId.TryParse(invalidString); // Assert - result.IsFailed() + result.IsFailure() .Should() .BeTrue(); result.Errors diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestIntIdTest.cs b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestIntIdTest.cs index 41ec3d2..9a903f7 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestIntIdTest.cs +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestIntIdTest.cs @@ -71,7 +71,7 @@ public void TryCreate_InvalidValue_ShouldFail() var result = TestIntId.TryCreate(invalidValue); // Assert - result.IsFailed() + result.IsFailure() .Should() .BeTrue(); result.Errors @@ -137,7 +137,7 @@ public void TryParse_InvalidString_ShouldFail(string invalidString) var result = TestIntId.TryParse(invalidString); // Assert - result.IsFailed() + result.IsFailure() .Should() .BeTrue(); result.Errors diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestLongIdTest.cs b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestLongIdTest.cs index 59b7e23..269516d 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestLongIdTest.cs +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestLongIdTest.cs @@ -71,7 +71,7 @@ public void TryCreate_InvalidValue_ShouldFail() var result = TestLongId.TryCreate(invalidValue); // Assert - result.IsFailed() + result.IsFailure() .Should() .BeTrue(); result.Errors @@ -137,7 +137,7 @@ public void TryParse_InvalidString_ShouldFail(string invalidString) var result = TestLongId.TryParse(invalidString); // Assert - result.IsFailed() + result.IsFailure() .Should() .BeTrue(); result.Errors diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestShortIdTest.cs b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestShortIdTest.cs index d420984..6aaad32 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestShortIdTest.cs +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestShortIdTest.cs @@ -71,7 +71,7 @@ public void TryCreate_InvalidValue_ShouldFail() var result = TestShortId.TryCreate(invalidValue); // Assert - result.IsFailed() + result.IsFailure() .Should() .BeTrue(); result.Errors @@ -137,7 +137,7 @@ public void TryParse_InvalidString_ShouldFail(string invalidString) var result = TestShortId.TryParse(invalidString); // Assert - result.IsFailed() + result.IsFailure() .Should() .BeTrue(); result.Errors diff --git a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestStringIdTest.cs b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestStringIdTest.cs index 098de05..efc1769 100644 --- a/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestStringIdTest.cs +++ b/tests/LightResults.Extensions.GeneratedIdentifier.Tests/TestStringIdTest.cs @@ -73,7 +73,7 @@ public void TryCreate_InvalidValue_ShouldFail() var result = TestStringId.TryCreate(invalidValue); // Assert - result.IsFailed() + result.IsFailure() .Should() .BeTrue(); result.Errors diff --git a/tests/LightResults.Extensions.Operations.Tests/EnumerableExtensionsTests.cs b/tests/LightResults.Extensions.Operations.Tests/EnumerableExtensionsTests.cs index 2dd1079..f0c7bdd 100644 --- a/tests/LightResults.Extensions.Operations.Tests/EnumerableExtensionsTests.cs +++ b/tests/LightResults.Extensions.Operations.Tests/EnumerableExtensionsTests.cs @@ -12,8 +12,8 @@ public void Collect_WhenResultsAreSuccessful_ShouldReturnOkResult() // Arrange var results = new[] { - Result.Ok(), - Result.Ok() + Result.Success(), + Result.Success() }; // Act @@ -31,9 +31,9 @@ public void Collect_WhenResultsAreMixed_ShouldReturnFailedResult() var error2 = new Error("Error message 2"); var results = new[] { - Result.Ok(), - Result.Fail(error), - Result.Fail(error2) + Result.Success(), + Result.Failure(error), + Result.Failure(error2) }; // Act @@ -50,8 +50,8 @@ public void CollectTValue_WhenResultsAreSuccessful_ShouldReturnOkResultWithValue // Arrange var results = new[] { - Result.Ok(42), - Result.Ok(43) + Result.Success(42), + Result.Success(43) }; // Act @@ -70,9 +70,9 @@ public void CollectTValue_WhenResultsAreMixed_ShouldReturnFailedResult() var error2 = new Error("Error message 2"); var results = new[] { - Result.Ok(42), - Result.Fail<int>(error), - Result.Fail<int>(error2) + Result.Success(42), + Result.Failure<int>(error), + Result.Failure<int>(error2) }; // Act diff --git a/tests/LightResults.Extensions.Tests/ResultJsonConverterTests.cs b/tests/LightResults.Extensions.Tests/ResultJsonConverterTests.cs index 5161843..7041cfd 100644 --- a/tests/LightResults.Extensions.Tests/ResultJsonConverterTests.cs +++ b/tests/LightResults.Extensions.Tests/ResultJsonConverterTests.cs @@ -13,7 +13,7 @@ public sealed class ResultJsonConverterTests public void SuccessResult() { // Arrange - var result = Result.Success(); + var result = Result.Ok(); // Act var json = JsonSerializer.Serialize(result, Options); @@ -26,7 +26,7 @@ public void SuccessResult() public void SuccessWithValueResult() { // Arrange - var result = Result.Success(42); + var result = Result.Ok(42); // Act var json = JsonSerializer.Serialize(result, Options); @@ -40,7 +40,7 @@ public void FailedResultWithSingleError() { // Arrange const string errorMessage = "Sample error message"; - var result = Result.Failure(errorMessage); + var result = Result.Fail(errorMessage); // Act var json = JsonSerializer.Serialize(result, Options); @@ -54,8 +54,8 @@ public void FailedResultWithSingleErrorAndMetadata() { // Arrange const string errorMessage = "Sample error message"; - IReadOnlyDictionary<string, object> metadata = new Dictionary<string, object> { { "Key", 0 } }; - var result = Result.Failure(errorMessage, metadata); + IDictionary<string, object> metadata = new Dictionary<string, object> { { "Key", 0 } }; + var result = Result.Fail(errorMessage, metadata); // Act var json = JsonSerializer.Serialize(result, Options); @@ -73,8 +73,8 @@ public void FailedResultWithSingleErrorAndMetadataWithException() // Arrange const string errorMessage = "Sample error message"; var exception = new InvalidOperationException(); - IReadOnlyDictionary<string, object> metadata = new Dictionary<string, object> { { "Exception", exception } }; - var result = Result.Failure(errorMessage, metadata); + IDictionary<string, object> metadata = new Dictionary<string, object> { { "Exception", exception } }; + var result = Result.Fail(errorMessage, metadata); // Act var json = JsonSerializer.Serialize(result, Options); @@ -92,8 +92,8 @@ public void FailedResultWithSingleErrorAndMetadataWithExceptionAndInnerException // Arrange const string errorMessage = "Sample error message"; var exception = new InvalidProgramException("Invalid program!", new InvalidOperationException()); - IReadOnlyDictionary<string, object> metadata = new Dictionary<string, object> { { "Exception", exception } }; - var result = Result.Failure(errorMessage, metadata); + IDictionary<string, object> metadata = new Dictionary<string, object> { { "Exception", exception } }; + var result = Result.Fail(errorMessage, metadata); // Act var json = JsonSerializer.Serialize(result, Options); @@ -110,8 +110,8 @@ public void FailedResultWithSingleErrorAndMultipleMetadata() { // Arrange const string errorMessage = "Sample error message"; - IReadOnlyDictionary<string, object> metadata = new Dictionary<string, object> { { "Key", 0 }, { "OtherKey", 1 } }; - var result = Result.Failure(errorMessage, metadata); + IDictionary<string, object> metadata = new Dictionary<string, object> { { "Key", 0 }, { "OtherKey", 1 } }; + var result = Result.Fail(errorMessage, metadata); // Act var json = JsonSerializer.Serialize(result, Options); @@ -128,7 +128,7 @@ public void FailedResultWithMultipleErrors() { // Arrange var errors = new List<IError> { new Error("Error 1"), new Error("Error 2") }; - var result = Result.Failure(errors); + var result = Result.Fail(errors); // Act var json = JsonSerializer.Serialize(result, Options); diff --git a/tools/Benchmarks/Benchmarks.cs b/tools/Benchmarks/Benchmarks.cs index 0a60eb2..7974015 100644 --- a/tools/Benchmarks/Benchmarks.cs +++ b/tools/Benchmarks/Benchmarks.cs @@ -55,7 +55,7 @@ private IEnumerable<Result> GetEnumerableResults(ResultType resultType) var random = new Random(Seed); var enumerableAllOk = new List<Result>(); for (var index = 0; index < Iterations; index++) - enumerableAllOk.Add(random.Next(min, max) == 0 ? Result.Ok() : Result.Fail(index.ToString())); + enumerableAllOk.Add(random.Next(min, max) == 0 ? Result.Success() : Result.Failure(index.ToString())); return enumerableAllOk.AsEnumerable(); } @@ -65,7 +65,7 @@ private IEnumerable<Result<string>> GetEnumerableTResults(ResultType resultType) var random = new Random(Seed); var enumerableTAllOk = new List<Result<string>>(); for (var index = 0; index < Iterations; index++) - enumerableTAllOk.Add(random.Next(min, max) == 0 ? Result.Ok(index.ToString()) : Result.Fail<string>(index.ToString())); + enumerableTAllOk.Add(random.Next(min, max) == 0 ? Result.Success(index.ToString()) : Result.Failure<string>(index.ToString())); return enumerableTAllOk.AsEnumerable(); } @@ -75,7 +75,7 @@ private IReadOnlyList<Result> GetReadOnlyListResults(ResultType resultType) var random = new Random(Seed); var readOnlyListAllOk = new List<Result>(); for (var index = 0; index < Iterations; index++) - readOnlyListAllOk.Add(random.Next(min, max) == 0 ? Result.Ok() : Result.Fail(index.ToString())); + readOnlyListAllOk.Add(random.Next(min, max) == 0 ? Result.Success() : Result.Failure(index.ToString())); return readOnlyListAllOk.AsReadOnly(); } @@ -85,7 +85,7 @@ private IReadOnlyList<Result<string>> GetReadOnlyListTResults(ResultType resultT var random = new Random(Seed); var readOnlyListTAllOk = new List<Result<string>>(); for (var index = 0; index < Iterations; index++) - readOnlyListTAllOk.Add(random.Next(min, max) == 0 ? Result.Ok(index.ToString()) : Result.Fail<string>(index.ToString())); + readOnlyListTAllOk.Add(random.Next(min, max) == 0 ? Result.Success(index.ToString()) : Result.Failure<string>(index.ToString())); return readOnlyListTAllOk.AsReadOnly(); }