removed some new lang features to support net6.0 and net7.0
All checks were successful
.NET Test / test (push) Successful in 1m5s
.NET Publish / publish (push) Successful in 51s

This commit is contained in:
2023-12-15 12:37:39 +04:00
parent c02fdc5492
commit 57e83fbafa
7 changed files with 76 additions and 60 deletions

View File

@@ -52,7 +52,7 @@ public abstract class Error : IEquatable<Error>, IComparable<Error>
[Pure, MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Error Many(Error error1, Error error2) => (error1, error2) switch
{
(null, null) => new ManyErrors([]),
(null, null) => new ManyErrors(new List<Error>()),
(Error err, null) => err,
(Error err, { IsEmpty: true }) => err,
(null, Error err) => err,
@@ -231,7 +231,7 @@ public sealed class ExceptionalError : Error
var valueString = value.ToString();
if (string.IsNullOrEmpty(keyString) || string.IsNullOrEmpty(valueString)) continue;
values ??= [];
values ??= new List<KeyValuePair<string, string>>(4);
values.Add(new(keyString, valueString));
}
return values?.ToImmutableDictionary() ?? ImmutableDictionary<string, string>.Empty;
@@ -377,7 +377,11 @@ public sealed class ManyErrors : Error, IEnumerable<Error>, IReadOnlyList<Error>
}
[Serializable]
public sealed class ErrorException(string type, string message) : Exception(message)
public sealed class ErrorException : Exception
{
public string Type { get; } = type ?? nameof(ErrorException);
public ErrorException(string type, string message) : base(message)
{
Type = type ?? nameof(ErrorException);
}
public string Type { get; }
}