diff --git a/.gitignore b/.gitignore
index 0b1cfad..f423a61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,9 @@
+.DS_Store
*.sublime-project
*.sublime-workspace
-*.sln
-*.csproj
-*.zip
+/*.sln
+/*.csproj
+/*.zip
.vs/
Temp/
Library/
@@ -14,4 +15,5 @@ obj/
Assets/Plugins/Editor.meta
Assets/Plugins/Editor
*.DotSettings.user
-
+/build/bin
+/build/obj
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 03dbecb..65df470 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,7 +8,7 @@ stages:
build_lib_test:
stage: build
- image: mono:5.8
+ image: mcr.microsoft.com/dotnet/core/sdk:3.1-buster
script:
- ./build.sh
tags:
@@ -22,13 +22,13 @@ build_lib_release:
script:
- export BUILD_VERSION=$(echo $CI_COMMIT_REF_NAME | sed 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\)\-release$/\1/g')
- echo $BUILD_VERSION
- - sed -i -e "s/0.5.1.0/$BUILD_VERSION.0/g" Assets/Plugins/Rayark/Mast/Properties/AssemblyInfo.cs
+ - sed -i -e "s/0.5.1.0/$BUILD_VERSION.0/g" build/Rayark.Mast.csproj
- ./build.sh
artifacts:
expire_in: 5 yrs
name: mast-unity-project
paths:
- - build
+ - pack
tags:
- docker
only:
@@ -38,7 +38,7 @@ mast-release:
stage: release
image: bash
script:
- - cp build/Assets/Plugins/Rayark/Mast/Rayark.Mast.dll .
+ - cp pack/Assets/Plugins/Rayark/Mast/Rayark.Mast.dll .
artifacts:
expire_in: 5 yrs
paths:
@@ -78,4 +78,4 @@ pages:
tags:
- docker
only:
- - master
+ - master
\ No newline at end of file
diff --git a/Assets/Plugins/Rayark/Mast/AggregateException.cs b/Assets/Plugins/Rayark/Mast/AggregateException.cs
deleted file mode 100644
index 1bcc3b5..0000000
--- a/Assets/Plugins/Rayark/Mast/AggregateException.cs
+++ /dev/null
@@ -1,248 +0,0 @@
-// Rayark.Mast.AggregateException
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Runtime.Serialization;
-using System.Security;
-
-namespace Rayark.Mast
-{
- /// Represents one or more errors that occur during application execution.
- [Serializable]
- [DebuggerDisplay("Count = {InnerExceptionCount}")]
- public class AggregateException : Exception
- {
- const string DEFAULT_MESSAGE = "Aggregate Exception";
- private ReadOnlyCollection m_innerExceptions;
-
- /// Gets a read-only collection of the instances that caused the current exception.
- /// Returns a read-only collection of the instances that caused the current exception.
- public ReadOnlyCollection InnerExceptions
- {
- get
- {
- return m_innerExceptions;
- }
- }
-
- private int InnerExceptionCount
- {
- get { return InnerExceptions.Count; }
- }
-
- /// Initializes a new instance of the class with a system-supplied message that describes the error.
- public AggregateException()
- : base(DEFAULT_MESSAGE)
- {
- m_innerExceptions = new ReadOnlyCollection(new Exception[0]);
- }
-
- /// Initializes a new instance of the class with a specified message that describes the error.
- /// The message that describes the exception. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
- public AggregateException(string message)
- : base(message)
- {
- m_innerExceptions = new ReadOnlyCollection(new Exception[0]);
- }
-
- /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
- /// The message that describes the exception. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
- /// The exception that is the cause of the current exception. If the parameter is not , the current exception is raised in a block that handles the inner exception.
- /// The argument is null.
- public AggregateException(string message, Exception innerException)
- : base(message, innerException)
- {
- if (innerException == null)
- {
- throw new ArgumentNullException("innerException");
- }
- m_innerExceptions = new ReadOnlyCollection(new Exception[1]
- {
- innerException
- });
- }
-
- /// Initializes a new instance of the class with references to the inner exceptions that are the cause of this exception.
- /// The exceptions that are the cause of the current exception.
- /// The argument is null.
- /// An element of is null.
- public AggregateException(IEnumerable innerExceptions)
- : this(DEFAULT_MESSAGE, innerExceptions)
- {
- }
-
- /// Initializes a new instance of the class with references to the inner exceptions that are the cause of this exception.
- /// The exceptions that are the cause of the current exception.
- /// The argument is null.
- /// An element of is null.
- public AggregateException(params Exception[] innerExceptions)
- : this(DEFAULT_MESSAGE, innerExceptions)
- {
- }
-
- /// Initializes a new instance of the class with a specified error message and references to the inner exceptions that are the cause of this exception.
- /// The error message that explains the reason for the exception.
- /// The exceptions that are the cause of the current exception.
- /// The argument is null.
- /// An element of is null.
- public AggregateException(string message, IEnumerable innerExceptions)
- : this(message, (innerExceptions as IList) ?? ((innerExceptions == null) ? null : new List(innerExceptions)))
- {
- }
-
- /// Initializes a new instance of the class with a specified error message and references to the inner exceptions that are the cause of this exception.
- /// The error message that explains the reason for the exception.
- /// The exceptions that are the cause of the current exception.
- /// The argument is null.
- /// An element of is null.
- public AggregateException(string message, params Exception[] innerExceptions)
- : this(message, (IList)innerExceptions)
- {
- }
-
- private AggregateException(string message, IList innerExceptions)
- : base(message, (innerExceptions != null && innerExceptions.Count > 0) ? innerExceptions[0] : null)
- {
- if (innerExceptions == null)
- {
- throw new ArgumentNullException("innerExceptions");
- }
- Exception[] array = new Exception[innerExceptions.Count];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = innerExceptions[i];
- if (array[i] == null)
- {
- throw new ArgumentException(DEFAULT_MESSAGE);
- }
- }
- m_innerExceptions = new ReadOnlyCollection(array);
- }
-
- /// Initializes a new instance of the class with serialized data.
- /// The object that holds the serialized object data.
- /// The contextual information about the source or destination.
- /// The argument is null.
- /// The exception could not be deserialized correctly.
- [SecurityCritical]
- protected AggregateException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- if (info == null)
- {
- throw new ArgumentNullException("info");
- }
- Exception[] array = info.GetValue("InnerExceptions", typeof(Exception[])) as Exception[];
- if (array == null)
- {
- throw new SerializationException("AggregateException_DeserializationFailure");
- }
- m_innerExceptions = new ReadOnlyCollection(array);
- }
-
- /// Initializes a new instance of the class with serialized data.
- /// The object that holds the serialized object data.
- /// The contextual information about the source or destination.
- /// The argument is null.
- [SecurityCritical]
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- {
- throw new ArgumentNullException("info");
- }
- base.GetObjectData(info, context);
- Exception[] array = new Exception[m_innerExceptions.Count];
- m_innerExceptions.CopyTo(array, 0);
- info.AddValue("InnerExceptions", array, typeof(Exception[]));
- }
-
- /// Returns the that is the root cause of this exception.
- /// Returns the that is the root cause of this exception.
- public override Exception GetBaseException()
- {
- Exception ex = this;
- AggregateException ex2 = this;
- while (ex2 != null && ex2.InnerExceptions.Count == 1)
- {
- ex = ex.InnerException;
- ex2 = (ex as AggregateException);
- }
- return ex;
- }
-
- /// Invokes a handler on each contained by this .
- /// The predicate to execute for each exception. The predicate accepts as an argument the to be processed and returns a Boolean to indicate whether the exception was handled.
- /// The argument is null.
- /// An exception contained by this was not handled.
- public void Handle(Func predicate)
- {
- if (predicate == null)
- {
- throw new ArgumentNullException("predicate");
- }
- List list = null;
- for (int i = 0; i < m_innerExceptions.Count; i++)
- {
- if (!predicate(m_innerExceptions[i]))
- {
- if (list == null)
- {
- list = new List();
- }
- list.Add(m_innerExceptions[i]);
- }
- }
- if (list == null)
- {
- return;
- }
- throw new AggregateException(Message, list);
- }
-
- /// Flattens an instances into a single, new instance.
- /// A new, flattened .
- public AggregateException Flatten()
- {
- List list = new List();
- List list2 = new List();
- list2.Add(this);
- int num = 0;
- while (list2.Count > num)
- {
- IList innerExceptions = list2[num++].InnerExceptions;
- for (int i = 0; i < innerExceptions.Count; i++)
- {
- Exception ex = innerExceptions[i];
- if (ex != null)
- {
- AggregateException ex2 = ex as AggregateException;
- if (ex2 != null)
- {
- list2.Add(ex2);
- }
- else
- {
- list.Add(ex);
- }
- }
- }
- }
- return new AggregateException(Message, list);
- }
-
- /// Creates and returns a string representation of the current .
- /// A string representation of the current exception.
- public override string ToString()
- {
- string text = base.ToString();
- for (int i = 0; i < m_innerExceptions.Count; i++)
- {
- text = string.Format(CultureInfo.InvariantCulture, "{0}{1} Excepion[{2}]:{3}{4}{5}", text, Environment.NewLine, i, m_innerExceptions[i].ToString(), "<---", Environment.NewLine);
- }
- return text;
- }
- }
-}
\ No newline at end of file
diff --git a/Assets/Plugins/Rayark/Mast/AggregateException.cs.meta b/Assets/Plugins/Rayark/Mast/AggregateException.cs.meta
deleted file mode 100644
index 586280f..0000000
--- a/Assets/Plugins/Rayark/Mast/AggregateException.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 0061a9c9f3931874ea8e6d7dfb4e19dd
-timeCreated: 1533266090
-licenseType: Pro
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/Plugins/Rayark/Mast/Editor/Tests/TestMonad.cs b/Assets/Plugins/Rayark/Mast/Editor/Tests/TestMonad.cs
index 39c7e3b..0c2c391 100644
--- a/Assets/Plugins/Rayark/Mast/Editor/Tests/TestMonad.cs
+++ b/Assets/Plugins/Rayark/Mast/Editor/Tests/TestMonad.cs
@@ -236,7 +236,7 @@ public void ConcurrentMonad2ErrorTest()
var mc = new ConcurrentMonad(m1, m2);
_Wait(mc);
- Assert.IsNull(mc.Result);
+ Assert.AreEqual(default((int,string)), mc.Result);
Assert.AreEqual(mc.Error.Message, "error 2");
}
@@ -276,7 +276,7 @@ public void ConcurrentMonad3ErrorTest()
var mc = new ConcurrentMonad(m1, m2, m4);
_Wait(mc);
- Assert.IsNull(mc.Result);
+ Assert.AreEqual(default((int,string,bool)), mc.Result);
Assert.AreEqual(mc.Error.Message, "error 2");
}
diff --git a/Assets/Plugins/Rayark/Mast/FuncMonad.cs b/Assets/Plugins/Rayark/Mast/FuncMonad.cs
index 186e1fc..c6ad568 100644
--- a/Assets/Plugins/Rayark/Mast/FuncMonad.cs
+++ b/Assets/Plugins/Rayark/Mast/FuncMonad.cs
@@ -11,7 +11,7 @@ namespace Rayark.Mast
/// makes it possible to add some extra operation right before a complex monad.
public class FuncMonad : IMonad, IEnumerator
{
- public readonly Func _func;
+ private readonly Func _func;
public FuncMonad(Func func)
{
diff --git a/Assets/Plugins/Rayark/Mast/Monad.cs b/Assets/Plugins/Rayark/Mast/Monad.cs
index 32fa0e0..0171e63 100644
--- a/Assets/Plugins/Rayark/Mast/Monad.cs
+++ b/Assets/Plugins/Rayark/Mast/Monad.cs
@@ -191,7 +191,7 @@ public static IMonad WhenAll(params IMonad[] ms)
/// The first monad
/// The second monad
///
- public static IMonad> WhenAll(IMonad m1, IMonad m2)
+ public static IMonad<(T1, T2)> WhenAll(IMonad m1, IMonad m2)
{
return new ConcurrentMonad(m1, m2);
}
@@ -207,7 +207,7 @@ public static IMonad> WhenAll(IMonad m1, IMonad m2
/// The second monad
/// The third monad
///
- public static IMonad> WhenAll(IMonad m1, IMonad m2, IMonad m3)
+ public static IMonad<(T1, T2, T3)> WhenAll(IMonad m1, IMonad m2, IMonad m3)
{
return new ConcurrentMonad(m1, m2, m3);
}
@@ -632,7 +632,7 @@ private IEnumerator _Do( IMonad m)
/// When any monad finished with error, the will stop immediately.
/// This class is rarely used directly. Use the extension method or LINQ syntax instead if it is possible.
///
- public class ConcurrentMonad : IMonad>
+ public class ConcurrentMonad : IMonad<(T1, T2)>
{
private readonly IMonad _m1;
private readonly IMonad _m2;
@@ -649,7 +649,7 @@ public ConcurrentMonad(IMonad m1, IMonad m2)
///
/// The Item1 and Item2 field of the result will be the return value of the first and second monad respectively.
///
- public Tuple Result
+ public (T1, T2) Result
{
get;
private set;
@@ -696,7 +696,7 @@ public IEnumerator Do()
}
if (Error != null)
yield break;
- Result = new Tuple(_m1.Result, _m2.Result);
+ Result = (_m1.Result, _m2.Result);
}
}
@@ -718,7 +718,7 @@ private IEnumerator _Do(IMonad m)
/// When any monad finished with error, the will stop immediately.
/// This class is rarely used directly. Use the extension method or LINQ syntax instead if it is possible.
///
- public class ConcurrentMonad : IMonad>
+ public class ConcurrentMonad : IMonad<(T1, T2, T3)>
{
private readonly IMonad _m1;
private readonly IMonad _m2;
@@ -737,7 +737,7 @@ public ConcurrentMonad(IMonad m1, IMonad m2, IMonad m3)
///
/// The Item1, Item2, and Item3 fields of the result will be the return value of the first, second and third monads respectively.
///
- public Tuple Result
+ public (T1, T2, T3) Result
{
get;
private set;
@@ -785,7 +785,7 @@ public IEnumerator Do()
}
if (Error != null)
yield break;
- Result = new Tuple(_m1.Result, _m2.Result, _m3.Result);
+ Result = (_m1.Result, _m2.Result, _m3.Result);
}
}
@@ -821,7 +821,7 @@ public Exception Error
private set;
}
- Func _func;
+ private readonly Func _func;
///
/// Initialize a new instance of the .
diff --git a/Assets/Plugins/Rayark/Mast/Tuple.cs b/Assets/Plugins/Rayark/Mast/Tuple.cs
deleted file mode 100644
index c75b738..0000000
--- a/Assets/Plugins/Rayark/Mast/Tuple.cs
+++ /dev/null
@@ -1,1273 +0,0 @@
-// This is Tuple polyfill modified from CoreCLR
-// https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Tuple.cs
-
-using System;
-using System.Text;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace Rayark.Mast
-{
- ///
- /// This interface is required for types that want to be indexed into by dynamic patterns.
- ///
- public interface ITuple
- {
- ///
- /// The number of positions in this data structure.
- ///
- int Length { get; }
-
- ///
- /// Get the element at position .
- ///
- object this[int index] { get; }
- }
-
- ///
- /// Helper so we can call some tuple methods recursively without knowing the underlying types.
- ///
- internal interface ITupleInternal : ITuple
- {
- string ToString(StringBuilder sb);
- int GetHashCode(IEqualityComparer comparer);
- }
-
- public static class Tuple
- {
- public static Tuple Create(T1 item1)
- {
- return new Tuple(item1);
- }
-
- public static Tuple Create(T1 item1, T2 item2)
- {
- return new Tuple(item1, item2);
- }
-
- public static Tuple Create(T1 item1, T2 item2, T3 item3)
- {
- return new Tuple(item1, item2, item3);
- }
-
- public static Tuple Create(T1 item1, T2 item2, T3 item3, T4 item4)
- {
- return new Tuple(item1, item2, item3, item4);
- }
-
- public static Tuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
- {
- return new Tuple(item1, item2, item3, item4, item5);
- }
-
- public static Tuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
- {
- return new Tuple(item1, item2, item3, item4, item5, item6);
- }
-
- public static Tuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
- {
- return new Tuple(item1, item2, item3, item4, item5, item6, item7);
- }
-
- public static Tuple> Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)
- {
- return new Tuple>(item1, item2, item3, item4, item5, item6, item7, new Tuple(item8));
- }
-
- // From System.Web.Util.HashCodeCombiner
- internal static int CombineHashCodes(int h1, int h2)
- {
- return (((h1 << 5) + h1) ^ h2);
- }
-
- internal static int CombineHashCodes(int h1, int h2, int h3)
- {
- return CombineHashCodes(CombineHashCodes(h1, h2), h3);
- }
-
- internal static int CombineHashCodes(int h1, int h2, int h3, int h4)
- {
- return CombineHashCodes(CombineHashCodes(h1, h2), CombineHashCodes(h3, h4));
- }
-
- internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5)
- {
- return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), h5);
- }
-
- internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6)
- {
- return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), CombineHashCodes(h5, h6));
- }
-
- internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7)
- {
- return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), CombineHashCodes(h5, h6, h7));
- }
-
- internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7, int h8)
- {
- return CombineHashCodes(CombineHashCodes(h1, h2, h3, h4), CombineHashCodes(h5, h6, h7, h8));
- }
- }
-
- [Serializable]
- public class Tuple : IComparable, ITupleInternal, ITuple
- {
- private readonly T1 m_Item1;
-
- public T1 Item1 { get { return m_Item1; } }
-
- public Tuple(T1 item1)
- {
- m_Item1 = item1;
- }
-
- public override Boolean Equals(Object obj)
- {
- Tuple objTuple = obj as Tuple;
- return EqualityComparer