diff --git a/Functional.Maybe.Json/MaybeConverter.cs b/Functional.Maybe.Json/MaybeConverter.cs
index 5d160ab..885ec74 100644
--- a/Functional.Maybe.Json/MaybeConverter.cs
+++ b/Functional.Maybe.Json/MaybeConverter.cs
@@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Linq;
using Newtonsoft.Json;
+#pragma warning disable 618
namespace Functional.Maybe.Json
{
diff --git a/Functional.Maybe/Either.cs b/Functional.Maybe/Either.cs
index 2d875e0..47b218e 100644
--- a/Functional.Maybe/Either.cs
+++ b/Functional.Maybe/Either.cs
@@ -2,147 +2,147 @@
namespace Functional.Either
{
- ///
- /// A functional monadic concept Either to make validation code more expressive and easier to maintain.
- /// Type of Result item
- /// Type of Error item
- ///
- public readonly struct Either
- {
- private readonly TResult _resultValue;
- private readonly TError _errorValue;
- private readonly bool _success;
-
- private Either(TResult result, TError error, bool success)
- {
- _success = success;
-
- if (success)
- {
- _resultValue = result;
- _errorValue = default;
- }
- else
- {
- _errorValue = error;
- _resultValue = default;
- }
- }
-
- ///
- /// Constructs new with the Result part defined.
- ///
- public static Either Result(TResult result)
- {
- return new Either(result, default, true);
- }
-
- ///
- /// Constructs new with the Error part defined.
- ///
- public static Either Error(TError error)
- {
- return new Either(default, error, false);
- }
-
- ///
- /// Executes result or error function depending on the Either state.
- ///
- public T Match(Func resultFunc, Func errorFunc)
- {
- if (resultFunc == null)
- {
- throw new ArgumentNullException(nameof(resultFunc));
- }
-
- if (errorFunc == null)
- {
- throw new ArgumentNullException(nameof(errorFunc));
- }
-
- return _success ? resultFunc(_resultValue) : errorFunc(_errorValue);
- }
-
- ///
- /// Executes result or error function depending on the Either state.
- ///
- public T Match(Func leftFunc, Func rightFunc)
- {
- if (leftFunc == null)
- {
- throw new ArgumentNullException(nameof(leftFunc));
- }
-
- if (rightFunc == null)
- {
- throw new ArgumentNullException(nameof(rightFunc));
- }
-
- return _success ? leftFunc() : rightFunc();
- }
-
- ///
- /// Executes result or error action depending on the Either state.
- ///
- public void Match(Action resultAction, Action errorAction)
- {
- if (resultAction == null)
- {
- throw new ArgumentNullException(nameof(resultAction));
- }
-
- if (errorAction == null)
- {
- throw new ArgumentNullException(nameof(errorAction));
- }
-
- if (_success)
- {
- resultAction(_resultValue);
- }
- else
- {
- errorAction(_errorValue);
- }
- }
-
- ///
- /// Executes result or error action depending on the Either state.
- ///
- public void Match(Action resultAction, Action errorAction)
- {
- if (resultAction == null)
- {
- throw new ArgumentNullException(nameof(resultAction));
- }
-
- if (errorAction == null)
- {
- throw new ArgumentNullException(nameof(errorAction));
- }
-
- if (_success)
- {
- resultAction();
- }
- else
- {
- errorAction();
- }
- }
-
- public TResult ResultOrDefault() => Match(res => res, err => default);
- public TError ErrorOrDefault() => Match(res => default, err => err);
- public TResult ResultOrDefault(TResult defaultValue) => Match(res => res, err => defaultValue);
- public TError ErrorOrDefault(TError defaultValue) => Match(res => defaultValue, err => err);
-
- public static implicit operator Either(TResult result) => Result(result);
- public static implicit operator Either(TError error) => Error(error);
- }
-
- public static class EitherExtensions
- {
- public static Either ToResult(this TL result) => Either.Result(result);
- public static Either ToError(this TR error) => Either.Error(error);
- }
-}
+ ///
+ /// A functional monadic concept Either to make validation code more expressive and easier to maintain.
+ /// Type of Result item
+ /// Type of Error item
+ ///
+ public readonly struct Either
+ {
+ private readonly TResult _resultValue;
+ private readonly TError _errorValue;
+ private readonly bool _success;
+
+ private Either(TResult result, TError error, bool success)
+ {
+ _success = success;
+
+ if (success)
+ {
+ _resultValue = result;
+ _errorValue = default;
+ }
+ else
+ {
+ _errorValue = error;
+ _resultValue = default;
+ }
+ }
+
+ ///
+ /// Constructs new with the Result part defined.
+ ///
+ public static Either Result(TResult result)
+ {
+ return new Either(result, default, true);
+ }
+
+ ///
+ /// Constructs new with the Error part defined.
+ ///
+ public static Either Error(TError error)
+ {
+ return new Either(default, error, false);
+ }
+
+ ///
+ /// Executes result or error function depending on the Either state.
+ ///
+ public T Match(Func resultFunc, Func errorFunc)
+ {
+ if (resultFunc == null)
+ {
+ throw new ArgumentNullException(nameof(resultFunc));
+ }
+
+ if (errorFunc == null)
+ {
+ throw new ArgumentNullException(nameof(errorFunc));
+ }
+
+ return _success ? resultFunc(_resultValue) : errorFunc(_errorValue);
+ }
+
+ ///
+ /// Executes result or error function depending on the Either state.
+ ///
+ public T Match(Func leftFunc, Func rightFunc)
+ {
+ if (leftFunc == null)
+ {
+ throw new ArgumentNullException(nameof(leftFunc));
+ }
+
+ if (rightFunc == null)
+ {
+ throw new ArgumentNullException(nameof(rightFunc));
+ }
+
+ return _success ? leftFunc() : rightFunc();
+ }
+
+ ///
+ /// Executes result or error action depending on the Either state.
+ ///
+ public void Match(Action resultAction, Action errorAction)
+ {
+ if (resultAction == null)
+ {
+ throw new ArgumentNullException(nameof(resultAction));
+ }
+
+ if (errorAction == null)
+ {
+ throw new ArgumentNullException(nameof(errorAction));
+ }
+
+ if (_success)
+ {
+ resultAction(_resultValue);
+ }
+ else
+ {
+ errorAction(_errorValue);
+ }
+ }
+
+ ///
+ /// Executes result or error action depending on the Either state.
+ ///
+ public void Match(Action resultAction, Action errorAction)
+ {
+ if (resultAction == null)
+ {
+ throw new ArgumentNullException(nameof(resultAction));
+ }
+
+ if (errorAction == null)
+ {
+ throw new ArgumentNullException(nameof(errorAction));
+ }
+
+ if (_success)
+ {
+ resultAction();
+ }
+ else
+ {
+ errorAction();
+ }
+ }
+
+ public TResult ResultOrDefault() => Match(res => res, err => default);
+ public TError ErrorOrDefault() => Match(res => default, err => err);
+ public TResult ResultOrDefault(TResult defaultValue) => Match(res => res, err => defaultValue);
+ public TError ErrorOrDefault(TError defaultValue) => Match(res => defaultValue, err => err);
+
+ public static implicit operator Either(TResult result) => Result(result);
+ public static implicit operator Either(TError error) => Error(error);
+ }
+
+ public static class EitherExtensions
+ {
+ public static Either ToResult(this TL result) => Either.Result(result);
+ public static Either ToError(this TR error) => Either.Error(error);
+ }
+}
\ No newline at end of file
diff --git a/Functional.Maybe/Functional.Maybe.csproj b/Functional.Maybe/Functional.Maybe.csproj
index aee3eaf..1615561 100644
--- a/Functional.Maybe/Functional.Maybe.csproj
+++ b/Functional.Maybe/Functional.Maybe.csproj
@@ -1,9 +1,9 @@
-
+
netstandard1.0
7.2
- 2.0.0
+ 2.1.0
Andrey Tsvetkov; William Cassarin
Functional.Maybe
Functional.Maybe
@@ -21,7 +21,6 @@
both => Console.WriteLine("Result is: {0}", both),
@else: () => Console.WriteLine("Result is Nothing, as one of the inputs was Nothing")
);
- true
https://raw.githubusercontent.com/AndreyTsvetkov/Functional.Maybe/master/License.txt
https://github.com/AndreyTsvetkov/Functional.Maybe
http://findicons.com/files/icons/1462/candy_hearts/32/maybe.png
diff --git a/Functional.Maybe/Functional.Maybe.nuspec b/Functional.Maybe/Functional.Maybe.nuspec
index cfff27c..0e06689 100644
--- a/Functional.Maybe/Functional.Maybe.nuspec
+++ b/Functional.Maybe/Functional.Maybe.nuspec
@@ -6,7 +6,7 @@
Functional.Maybe — Option type for C# with LINQ support and rich fluent syntax for many popular uses
Andrey Tsvetkov; original version by William Casarin
Andrey Tsvetkov
- https://raw.githubusercontent.com/AndreyTsvetkov/Functional.Maybe/master/License.txt
+ Apache-2.0
https://github.com/AndreyTsvetkov/Functional.Maybe
http://findicons.com/files/icons/1462/candy_hearts/32/maybe.png
false
diff --git a/Functional.Maybe/Maybe.cs b/Functional.Maybe/Maybe.cs
index ddc29fd..da28e75 100644
--- a/Functional.Maybe/Maybe.cs
+++ b/Functional.Maybe/Maybe.cs
@@ -1,6 +1,6 @@
using System;
-using System.Collections;
using System.Collections.Generic;
+#pragma warning disable 618
namespace Functional.Maybe
{
@@ -34,7 +34,8 @@ namespace Functional.Maybe
///
/// The value, stored in the monad. Can be accessed only if is really present, otherwise throws
///
- /// is thrown if not value is present
+ /// is thrown if not value is present
+ [Obsolete("Use Select, SelectMany wherever possible, otherwise suppress error explicitly")]
public T Value
{
get
diff --git a/Functional.Maybe/MaybeAsync.cs b/Functional.Maybe/MaybeAsync.cs
index 8f0e67d..3ba577e 100644
--- a/Functional.Maybe/MaybeAsync.cs
+++ b/Functional.Maybe/MaybeAsync.cs
@@ -1,12 +1,13 @@
using System;
using System.Threading.Tasks;
+#pragma warning disable 618
namespace Functional.Maybe
{
public static class MaybeAsync
{
///
- /// Flips Maybe and Task: instead of having Maybe<Task<T>> (as in case of Select) we get Task<Maybe<T>> and have possibility to await on it.
+ /// Flips Maybe and Task: instead of having Maybe{Task{T}} (as in case of Select) we get Task{Maybe{T}} and have possibility to await on it.
///
/// source type
/// async result type
diff --git a/Functional.Maybe/MaybeBoolean.cs b/Functional.Maybe/MaybeBoolean.cs
index 448b6c1..7c9f049 100644
--- a/Functional.Maybe/MaybeBoolean.cs
+++ b/Functional.Maybe/MaybeBoolean.cs
@@ -1,9 +1,10 @@
using System;
+#pragma warning disable 618
namespace Functional.Maybe
{
///
- /// Ternary logic with Maybe<bool> and combining T and bool to a Maybe value
+ /// Ternary logic with Maybe{bool}; and combining T and bool to a Maybe value
///
public static class MaybeBoolean
{
diff --git a/Functional.Maybe/MaybeCompositions.cs b/Functional.Maybe/MaybeCompositions.cs
index 1b60208..d8b7afb 100644
--- a/Functional.Maybe/MaybeCompositions.cs
+++ b/Functional.Maybe/MaybeCompositions.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
// ReSharper disable MemberCanBePrivate.Global
+#pragma warning disable 618
namespace Functional.Maybe
{
diff --git a/Functional.Maybe/MaybeConvertions.cs b/Functional.Maybe/MaybeConvertions.cs
index a7ee15a..f19540a 100644
--- a/Functional.Maybe/MaybeConvertions.cs
+++ b/Functional.Maybe/MaybeConvertions.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+#pragma warning disable 618
namespace Functional.Maybe
{
diff --git a/Functional.Maybe/MaybeEnumerable.cs b/Functional.Maybe/MaybeEnumerable.cs
index 1b369a3..2eccdd2 100644
--- a/Functional.Maybe/MaybeEnumerable.cs
+++ b/Functional.Maybe/MaybeEnumerable.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+#pragma warning disable 618
namespace Functional.Maybe
{
@@ -233,10 +234,10 @@ public static IEnumerable Union(this Maybe @this, IEnumerable others
/// Combines the current value, if exists, with passed IEnumerable
///
///
- ///
- ///
+ ///
+ ///
///
- public static IEnumerable Union(this IEnumerable @these, Maybe other) =>
- @these.Union(other.ToEnumerable());
+ public static IEnumerable Union(this IEnumerable these, Maybe other) =>
+ these.Union(other.ToEnumerable());
}
}
\ No newline at end of file
diff --git a/Functional.Maybe/MaybeFunctionalWrappers.cs b/Functional.Maybe/MaybeFunctionalWrappers.cs
index 91a63af..ea082d2 100644
--- a/Functional.Maybe/MaybeFunctionalWrappers.cs
+++ b/Functional.Maybe/MaybeFunctionalWrappers.cs
@@ -24,13 +24,9 @@ public static class MaybeFunctionalWrappers
///
///
///
- public static Func> Wrap(TryGet tryer) => (T arg) =>
- {
- TR result;
- return tryer(arg, out result)
- ? result.ToMaybe()
- : Maybe.Nothing;
- };
+ public static Func> Wrap(TryGet tryer) => arg => tryer(arg, out var result)
+ ? result.ToMaybe()
+ : Maybe.Nothing;
///
/// Returns a function which calls , wrapped inside a try-catch clause with catched.
@@ -41,7 +37,7 @@ public static Func> Wrap(TryGet tryer) => (T arg) =>
///
///
///
- public static Func> Catcher(Func f) where TEx : Exception => (TA arg) =>
+ public static Func> Catcher(Func f) where TEx : Exception => arg =>
{
try
{
diff --git a/Functional.Maybe/MaybeLinq.cs b/Functional.Maybe/MaybeLinq.cs
index 30fdb26..0a5b7e8 100644
--- a/Functional.Maybe/MaybeLinq.cs
+++ b/Functional.Maybe/MaybeLinq.cs
@@ -1,4 +1,5 @@
using System;
+#pragma warning disable 618
namespace Functional.Maybe
{
diff --git a/Functional.Maybe/MaybeReturns.cs b/Functional.Maybe/MaybeReturns.cs
index e20b09c..e2443e5 100644
--- a/Functional.Maybe/MaybeReturns.cs
+++ b/Functional.Maybe/MaybeReturns.cs
@@ -1,4 +1,5 @@
using System;
+#pragma warning disable 618
namespace Functional.Maybe
{
diff --git a/Functional.Maybe/MaybeSideEffects.cs b/Functional.Maybe/MaybeSideEffects.cs
index b3a99e1..b88fb67 100644
--- a/Functional.Maybe/MaybeSideEffects.cs
+++ b/Functional.Maybe/MaybeSideEffects.cs
@@ -1,4 +1,5 @@
using System;
+#pragma warning disable 618
namespace Functional.Maybe
{