NumberList integration refined

NumberList integration refined

Roots of unity are now represented in trigonometric form. The correct number of roots are now displayed from the Fractional exponent, Rational base branch of exponentiate(). Need to consider the Exponentiation base case. There is a stack overflow bug for 8^(1/3).

--- Program.cs
+++ Program.cs
@@ -36,8 +36,7 @@
         }
         public abstract class Term : Number
         {
-            public static Term createTerm(Rational coefficient,
-                List<Factor> factors)
+            public static Term createTerm(Rational coefficient, List<Factor> factors)
             {//To be used instead of the Product constructor if it's unkown whether the given input
              //could be represented by a simpler type.
                 if (factors.Count == 0)
@@ -103,7 +102,7 @@
             protected override abstract Number multiply(Number number);
             public override abstract Number negative();
             public override abstract Number reciprocal();
-            public abstract bool isIntegral();
+            public abstract bool isGaussian();
             public override abstract int CompareTo(Object obj);
             public static Number operator +(Rational a, Factor b)
             {
@@ -174,7 +173,7 @@
             {
                 return new Fraction(Denominator, Numerator);
             }
-            public override bool isIntegral()
+            public override bool isGaussian()
             {
                 return Denominator == 1;
             }
@@ -270,7 +269,7 @@
                 return new ComplexNumber((Fraction)(Real / denominator),
                     (Fraction)(Imaginary.negative() / denominator));
             }
-            public override bool isIntegral()
+            public override bool isGaussian()
             {
                 return Real.Denominator == 1 && Imaginary.Denominator == 1;
             }
@@ -320,6 +319,126 @@
                 return output.ToString();
             }
         }
+        public enum Constant
+        {
+            TAU
+        }
+        public class Transcendental : Factor
+        {
+            public Constant Value { get; }
+            public Transcendental(Constant value)
+            {
+                Value = value;
+            }
+            protected override Number add(Number number)
+            {
+                if (number is Transcendental)
+                {
+                    Transcendental transcendental = (Transcendental)number;
+                    if (transcendental.Value == Value)
+                        return new Product(new Fraction(2, 1), new List<Factor> { this });
+                }
+                return number + this;
+            }
+            public override Number negative()
+            {
+                return new Product(new Fraction(-1, 1), new List<Factor> { this });
+            }
+            protected override Number multiply(Number number)
+            {
+                if (number is Transcendental)
+                {
+                    Transcendental transcendental = (Transcendental)number;
+                    if (transcendental.Value == Value)
+                        return new Exponentiation(this, new Fraction(2, 1));
+                }
+                if (number is Rational)
+                    return new Product((Rational)number, new List<Factor> { this });
+                if (number is Factor)
+                    return new Product(new Fraction(1, 1),
+                        new List<Factor> { (Factor)number, this });
+                return number * this;
+            }
+            public override Number reciprocal()
+            {
+                return new Exponentiation(this, new Fraction(-1, 1));
+            }
+            public override int CompareTo(object obj)
+            {
+                if (obj is Transcendental)
+                {
+                    Transcendental transcendental = (Transcendental)obj;
+                    return Value - transcendental.Value;
+                }
+                return getTypeIndex(this) - getTypeIndex((Number)obj);
+            }
+            public override string ToString()
+            {
+                return "tau";
+            }
+        }
+        public class Sine : Factor
+        {
+            public Number Argument { get; }
+            public Sine(Number argument)
+            {
+                Argument = argument;
+            }
+            protected override Number add(Number number)
+            {
+                if (number is Fraction)
+                {
+                    Fraction fraction = (Fraction)number;
+                    if (fraction.Numerator == 0)
+                        return this;
+                }
+                if (number is Sine)
+                {
+                    Sine sine = (Sine)number;
+                    if (sine.Argument == Argument)
+                        return new Product(new Fraction(2, 1), new List<Factor> { this });
+                }
+                if (number is Term)
+                    return new Sum(new List<Term> { this, (Term)number });
+                return number + this;
+            }
+            public override Number negative()
+            {
+                return new Sine(Argument.negative());
+            }
+            protected override Number multiply(Number number)
+            {
+                if (number is Fraction)
+                {
+                    Fraction fraction = (Fraction)number;
+                    if (fraction.Numerator == fraction.Denominator)
+                        return this;
+                }
+                if (number is Rational)
+                    return new Product((Rational)number, new List<Factor> { this });
+                if (number is Factor)
+                    return new Product(new Fraction(1, 1),
+                        new List<Factor> { (Factor)number, this });
+                return number * this;
+            }
+            public override Number reciprocal()
+            {
+                return new Exponentiation(this, new Fraction(-1, 1));
+            }
+            public override int CompareTo(object obj)
+            {
+                if (obj is Sine)
+                {
+                    Sine sine = (Sine)obj;
+                    return Argument.CompareTo(sine.Argument);
+                }
+                return getTypeIndex(this) - getTypeIndex((Number)obj);
+            }
+            public override string ToString()
+            {
+                return "sin(" + Argument.ToString() + ')';
+            }
+        }
         public class Exponentiation : Factor
         {
             public Number Base { get; }
@@ -372,9 +491,9 @@
                 {
                     Exponentiation exponentiation = (Exponentiation)number;
                     if (Exponent.Equals(exponentiation.Exponent))
-                        return exponentiate(Base * exponentiation.Base, Exponent);
+                        return exponentiate(Base * exponentiation.Base, Exponent, true);
                     if (Base.Equals(exponentiation.Base))
-                        return exponentiate(Base, Exponent + exponentiation.Exponent);
+                        return exponentiate(Base, Exponent + exponentiation.Exponent, true);
                     return new Product(new Fraction(1, 1),
                         new List<Factor> { this, exponentiation });
                 }
@@ -437,65 +556,6 @@
                         return output.Append('i').ToString();
                 }
                 return output.Append('(' + Exponent.ToString() + ')').ToString();
-            }
-        }
-        public enum Constant
-        {
-            PI,
-            E
-        }
-        public class Transcendental : Factor
-        {
-            Constant Value { get; }
-            public Transcendental(Constant value)
-            {
-                Value = value;
-            }
-            protected override Number add(Number number)
-            {
-                if (number is Transcendental)
-                {
-                    Transcendental transcendental = (Transcendental)number;
-                    if (transcendental.Value == Value)
-                        return new Product(new Fraction(2, 1), new List<Factor> { this });
-                }
-                return number + this;
-            }
-            public override Number negative()
-            {
-                return new Product(new Fraction(-1, 1), new List<Factor> { this });
-            }
-            protected override Number multiply(Number number)
-            {
-                if (number is Transcendental)
-                {
-                    Transcendental transcendental = (Transcendental)number;
-                    if (transcendental.Value == Value)
-                        return new Exponentiation(this, new Fraction(2, 1));
-                }
-                if (number is Factor)
-                    return new Product(new Fraction(1, 1),
-                        new List<Factor> { (Factor)number, this });
-                return number * this;
-            }
-            public override Number reciprocal()
-            {
-                return new Exponentiation(this, new Fraction(-1, 1));
-            }
-            public override int CompareTo(object obj)
-            {
-                if (obj is Transcendental)
-                {
-                    Transcendental transcendental = (Transcendental)obj;
-                    return Value - transcendental.Value;
-                }
-                return getTypeIndex(this) - getTypeIndex((Number)obj);
-            }
-            public override string ToString()
-            {
-                if (Value == Constant.PI)
-                    return "PI";
-                return "e";
             }
         }
         public class Product : Term
@@ -726,9 +786,9 @@
                 return output.ToString();
             }
         }
-        public class NumberList : Number
-        {
-            List<Number> Numbers { get; }
+        public class NumberList : Term
+        {
+            public List<Number> Numbers { get; }
             public NumberList(List<Number> numbers)
             {
                 Numbers = numbers;
@@ -745,7 +805,7 @@
                         {
                             Number sum = n + m;
                             bool addSum = true;
-                            for (int i = 0; 0 < outputList.Count; ++i)
+                            for (int i = 0; i < outputList.Count; ++i)
                                 if (sum.Equals(outputList[i]))
                                 {
                                     addSum = false;
@@ -760,7 +820,7 @@
                     {
                         Number sum = n + number;
                         bool addSum = true;
-                        for (int i = 0; 0 < outputList.Count; ++i)
+                        for (int i = 0; i < outputList.Count; ++i)
                             if (sum.Equals(outputList[i]))
                             {
                                 addSum = false;
@@ -791,7 +851,7 @@
                         {
                             Number product = n * m;
                             bool addProduct = true;
-                            for (int i = 0; 0 < outputList.Count; ++i)
+                            for (int i = 0; i < outputList.Count; ++i)
                                 if (product.Equals(outputList[i]))
                                 {
                                     addProduct = false;
@@ -806,7 +866,7 @@
                     {
                         Number product = n * number;
                         bool addProduct = true;
-                        for (int i = 0; 0 < outputList.Count; ++i)
+                        for (int i = 0; i < outputList.Count; ++i)
                             if (product.Equals(outputList[i]))
                             {
                                 addProduct = false;
@@ -865,6 +925,29 @@
                 return 6;
             return 7;
         }
+        static public Dictionary<int, int> getFactorization(int x)
+        {//The keys respresent the factors, and the values represent their multiplicities.
+            Dictionary<int, int> factors = new Dictionary<int, int>();
+            if (x < 0)
+                x *= -1;
+            int factor = 2;
+            while (factor <= x / 2)
+                if (x % factor == 0)
+                {
+                    if (factors.ContainsKey(factor))
+                        factors[factor] += 1;
+                    else
+                        factors.Add(factor, 1);
+                    x /= factor;
+                }
+                else
+                    ++factor;
+            if (factors.ContainsKey(x))
+                factors[x] += 1;
+            else if (x != 1)
+                factors.Add(x, 1);
+            return factors;
+        }
         static public Dictionary<Rational, int> getFactorization(Rational gaussian)
         {
             Dictionary<Rational, int> factors = new Dictionary<Rational, int>();
@@ -876,22 +959,26 @@
                 for (int i = 0; realPart - i >= 0;)
                 {
                     int gaussianMagnitudeSquared;
+                    Fraction fractionGaussian = null;
+                    ComplexNumber complexGaussian = null;
                     if (gaussian is Fraction)
                     {
-                        Fraction fractionGaussian = (Fraction)gaussian;
+                        fractionGaussian = (Fraction)gaussian;
                         gaussianMagnitudeSquared = fractionGaussian.Numerator *
                             fractionGaussian.Numerator;
                     }
                     else
                     {
-                        ComplexNumber complexGaussian = (ComplexNumber)gaussian;
+                        complexGaussian = (ComplexNumber)gaussian;
                         gaussianMagnitudeSquared = complexGaussian.Real.Numerator *
                             complexGaussian.Real.Numerator + complexGaussian.Imaginary.Numerator *
                             complexGaussian.Imaginary.Numerator;
                     }
                     if ((realPart - i) * (realPart - i) + (imaginaryPart + i) *
-                    (imaginaryPart + i) > gaussianMagnitudeSquared)
-                    {
+                        (imaginaryPart + i) > gaussianMagnitudeSquared)
+                    {
+                        if (gaussian is Fraction && fractionGaussian.Numerator == fractionGaussian.Denominator)
+                            return factors;
                         if (factors.ContainsKey(gaussian))
                             factors[gaussian] += 1;
                         else
@@ -902,7 +989,7 @@
                     bool testFactor()
                     {
                         Rational quotient = (Rational)(gaussian / factor);
-                        if (quotient.isIntegral())
+                        if (quotient.isGaussian())
                         {
                             if (factors.ContainsKey(factor))
                                 factors[factor] += 1;
@@ -957,12 +1044,84 @@
         {
             return x / getGCD(x, y) * y;
         }
-        static public Number exponentiate(Number expBase, Number exponent)
-        {
+        static public Number sin(Number argument)
+        {
+            if (argument is Fraction)
+            {
+                Fraction fraction = (Fraction)argument;
+                if (fraction.Numerator == 0)
+                    return fraction;
+            }
+            else if (argument is Transcendental)
+            {
+                Transcendental transcendental = (Transcendental)argument;
+                if (transcendental.Value == Constant.TAU)
+                    return new Fraction(0, 1);
+            }
+            else if (argument is Product)
+            {
+                Product product = (Product)argument;
+                if (product.Factors.Count == 1 && product.Coefficient is Fraction &&
+                    product.Factors[0] is Transcendental)
+                {
+                    Transcendental transcendental = (Transcendental)product.Factors[0];
+                    if (transcendental.Value == Constant.TAU)
+                    {
+                        Fraction fraction = (Fraction)product.Coefficient;
+                        Number sine;
+                        switch(fraction.Denominator)
+                        {
+                            case 1:
+                            case 2:
+                                sine = new Fraction(0, 1);
+                                break;
+                            case 3:
+                                sine = new Product(new Fraction(1, 2), new List<Factor> {
+                                    new Exponentiation(new Fraction(3, 1), new Fraction(1, 2)) });
+                                break;
+                            case 4:
+                                sine = new Fraction(1, 1);
+                                break;
+                            default:
+                                return new Sine(argument);
+                        }
+                        Number angleMultipleSine = sine;
+                        Number cosine = exponentiate(new Fraction(1, 1) - sine * sine,
+                            new Fraction(1, 2), false);
+                        if (fraction.Denominator < fraction.Numerator % fraction.Denominator &&
+                            fraction.Numerator % fraction.Denominator < fraction.Denominator + 2)
+                            cosine = cosine.negative();
+                        Number angleMultipleCosine;
+                        for (int i = 1; i < fraction.Numerator; ++i)
+                        {
+                            angleMultipleCosine = exponentiate(new Fraction(1, 1) -
+                                angleMultipleSine * angleMultipleSine, new Fraction(1, 2), false);
+                            if (fraction.Denominator < fraction.Numerator + i %
+                                fraction.Denominator && fraction.Numerator + i %
+                                fraction.Denominator < fraction.Denominator + 2)
+                                angleMultipleCosine = angleMultipleCosine.negative();
+                            angleMultipleSine = sine * angleMultipleCosine +
+                                angleMultipleSine * cosine;
+                        }
+                        return angleMultipleSine;
+                    }
+                }
+            }
+            return new Sine(argument);
+        }
+        static public Number exponentiate(Number expBase, Number exponent, bool returnAllRoots)
+        {
+            if (expBase is Fraction)
+            {
+                Fraction baseFraction = (Fraction)expBase;
+                if (baseFraction.Numerator == baseFraction.Denominator ||
+                    baseFraction.Numerator == 0)
+                    return baseFraction;
+            }
             if (exponent is Fraction)
             {
                 Fraction exponentFraction = (Fraction)exponent;
-                if (exponentFraction.Denominator == 1)
+                if (exponentFraction.Denominator == 1)
                 {
                     Number output = new Fraction(1, 1);
                     if (exponentFraction.Numerator < 1)
@@ -1051,46 +1210,81 @@
                                 coefficient = (Rational)coefficient.negative();
                                 termComponentstoPower.Remove(exponentFraction.Denominator);
                             }
-                            else if ((exponentFraction.Denominator + 2) % 4 == 0)
+                            else if (exponentFraction.Denominator % 4 == 0)
+                            {
+                                if (termComponentstoPower.ContainsKey(2))
+                                    termComponentstoPower[2] = (Rational)(termComponentstoPower[2] *
+                                        new ComplexNumber(0, 1));
+                                else
+                                    termComponentstoPower.Add(2, new ComplexNumber(0, 1));
+                                termComponentstoPower.Remove(exponentFraction.Denominator);
+                            }
+                            else if (exponentFraction.Denominator % 2 == 0)
                             {
                                 coefficient = (Rational)(coefficient * new ComplexNumber(0, 1));
                                 termComponentstoPower.Remove(exponentFraction.Denominator);
                             }
                         }
                     }
+                    else if (termComponentstoPower[exponentFraction.Denominator] is ComplexNumber)
+                    {
+                        ComplexNumber complexRadicand =
+                            (ComplexNumber)termComponentstoPower[exponentFraction.Denominator];
+                        if (complexRadicand.Real.Numerator == 0)
+                            if (complexRadicand.Imaginary.Numerator ==
+                                complexRadicand.Imaginary.Denominator)
+                            {
+                                if (exponentFraction.Denominator % 4 == 3)
+                                {
+                                    coefficient =
+                                        (Rational)(coefficient * new ComplexNumber(0, -1));
+                                    termComponentstoPower.Remove(exponentFraction.Denominator);
+                                }
+                                else if (exponentFraction.Denominator % 4 == 1)
+                                {
+                                    coefficient = (Rational)(coefficient * new ComplexNumber(0, 1));
+                                    termComponentstoPower.Remove(exponentFraction.Denominator);
+                                }
+                            }
+                    }
                     List<Factor> factors = new List<Factor>();
+                    int largestIndex = 1;
                     foreach (int index in termComponentstoPower.Keys)
+                    {
                         factors.Add(new Exponentiation(termComponentstoPower[index],
                             new Fraction(1, index)));
-                    Number rootOfUnity = new Exponentiation(new Transcendental(Constant.E),
-                        new Product(new ComplexNumber(new Fraction(0, 1),
-                        new Fraction(2, exponentFraction.Denominator)),
-                        new List<Factor> { new Transcendental(Constant.PI) }));
-                    List<Number> roots = new List<Number> { Term.createTerm(coefficient, factors) };
-                    for (int i = 1; i < exponentFraction.Denominator; ++i)
-                        roots.Add(roots[i - 1] * rootOfUnity);
-                    return new NumberList(roots);
-                }
-            }
-            if (expBase is Fraction)
-            {
-                Fraction baseFraction = (Fraction)expBase;
-                if (baseFraction.Numerator == baseFraction.Denominator ||
-                    baseFraction.Numerator == 0)
-                    return baseFraction;
+                        if (index > largestIndex)
+                            largestIndex = index;
+                    }
+                    if (returnAllRoots && largestIndex < exponentFraction.Denominator)
+                    {
+                        Number rootOfUnity = sin(new Transcendental(Constant.TAU) *
+                            new Fraction(4 + exponentFraction.Denominator,
+                            4 * exponentFraction.Denominator)) +
+                            sin(new Transcendental(Constant.TAU) *
+                            new Fraction(1, exponentFraction.Denominator)) *
+                            new ComplexNumber(0, 1);
+                        List<Number> roots =
+                            new List<Number> { Term.createTerm(coefficient, factors) };
+                        for (int i = 1; i < exponentFraction.Denominator / largestIndex; ++i)
+                            roots.Add(roots[i - 1] * rootOfUnity);
+                        return new NumberList(roots);
+                    }
+                    return Term.createTerm(coefficient, factors);
+                }
             }
             if (expBase is Exponentiation)
             {
                 Exponentiation baseExponentiation = (Exponentiation)expBase;
                 return exponentiate(baseExponentiation.Base,
-                    baseExponentiation.Exponent * exponent);
+                    baseExponentiation.Exponent * exponent, true);
             }
             if (expBase is Product)
             {
                 Product baseProduct = (Product)expBase;
                 Number output = baseProduct.Coefficient;
                 foreach (Factor factor in baseProduct.Factors)
-                    output *= exponentiate(factor, exponent);
+                    output *= exponentiate(factor, exponent, true);
                 return output;
             }
             return new Exponentiation(expBase, exponent);
@@ -1152,7 +1346,7 @@
             {
                 if (operations[i] == '^')
                 {
-                    numbers[i - 1] = Math.exponentiate(numbers[i - 1], numbers[i + 1]);
+                    numbers[i - 1] = Math.exponentiate(numbers[i - 1], numbers[i + 1], true);
                     numbers.RemoveRange(i, 2);
                     operations.RemoveRange(i, 2);
                 }


using more c# 6.0 features other cleanup

--- Program.cs
+++ Program.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Console;
 using System.Collections.Generic;
 using System.Linq;

@@ -14,9 +15,6 @@
 			}
 		}
 		//-- helper functions
-		static string ToUpper(string s) => s.ToUpper();
-		static string ToLower(string s) => s.ToLower();
-		static string Trim(string s) => s.Trim();
 		static string Substring(string s) => s.Substring(30);
 		static Number Length(string s) => new Number(s.Length);
 		static string ExtractVowels(string text) {
@@ -53,40 +51,39 @@
 			var maybeM = new MaybeM<string>("I'm a string, wrapped up in the Maybe Monad!");
 			var result1 = maybeM.Bind(ExtractVowels)
 											 	  .Bind(Length);
-			Console.WriteLine("Result is: \{result1.Value}");
+			WriteLine("Result is: \{result1.Show()}");

 			//-2) Maybe monad usage: null string
 			maybeM = new MaybeM<string>(null);
 			var result2 = maybeM.Bind(ExtractVowels)
 													.Bind(Length);
-			Console.WriteLine("Result is: \{result2.Value}");
+			WriteLine("Result is: \{result2.Show()}");

 			//-3) Writer monad usage
 			var writerM = new WriterM<string>("I'm a string, wrapped up in the Maybe Monad!");
 			var result3 = writerM.Bind(ExtractVowels)
 													 .Bind(Length);
-			Console.WriteLine("Result is: \{result3.Value}");
+			WriteLine("Result is: \{result3.Show()}");

-			Console.ReadLine();
+			ReadLine();
 		}
 	}

 	//-- monad interface
 	//--
 	public interface IMonad<T> {
-		//note: 'From' is implemented by constructor
-		//IMonad<T> From(T @value);
+		//IMonad<T> From(T @value);//note: implemented as constructor
+
 		IMonad<T2> Bind<T2>(Func<T, T2> f) where T2 : class;

-		// simple public access the wrapped value(s), optional but helpfull :)
-		string Value { get; }
+		// simple access the wrapped value(s), optional but helpfull :)
+		string Show();
 	}

 	//-- Maybe monad
 	//--
 	class MaybeM<T> : IMonad<T> {
 		internal T _value;
-		public string Value {	get { return _value == null ? "null" :  _value.ToString(); }}

 		public MaybeM(T value) {
 			_value = value;
@@ -98,20 +95,16 @@
 			}
 			return new MaybeM<T2>(null);
 		}
+
+		public string Show() {
+			return _value == null ? "null" : _value.ToString();
+		}
 	}

 	//-- Writer monad
 	//--
 	class WriterM<T> : IMonad<T> {
 		internal T _value;
-		public string Value {
-			get {
-				var valStr = _value.ToString();
-				_info.ForEach(s => valStr += ", " + s);
-				return valStr;
-			}
-		}
-
 		List<string> _info;

 		public WriterM(T @value) {
@@ -135,5 +128,11 @@
 				return new WriterM<T2>(default(T2), _info);
 			}
 		}
+
+		public string Show() {
+			var valStr = _value.ToString();
+			_info.ForEach(s => valStr += "\r\n\t" + s);
+			return valStr;
+		}
 	}
 }


Improve documentation.

Improve documentation.

--- Ctl.Core/Extensions/StringExtensions.cs
+++ Ctl.Core/Extensions/StringExtensions.cs
@@ -39,7 +39,7 @@
     public static class StringExtensions
     {
         /// <summary>
-        /// Trims all whitespace from a string, returning null if the result is empty.
+        /// Trims leading and trailing whitespace from a string, returning null if the result is empty.
         /// </summary>
         /// <param name="s">A string to trim.</param>
         [Pure]
@@ -49,7 +49,7 @@
         }

         /// <summary>
-        /// Trims all whitespace from a string, returning null if the result is empty.
+        /// Trims leading and trailing whitespace from a string, returning null if the result is empty.
         /// If the string is over <paramref name="length"/> characters long, it is truncated.
         /// </summary>
         /// <param name="s">A string to truncate.</param>


Adding proper disposal to test fixture

Adding proper disposal to test fixture

--- test/WebJobs.Script.Tests.Integration/ApplicationInsights/ApplicationInsightsTestFixture.cs
+++ test/WebJobs.Script.Tests.Integration/ApplicationInsights/ApplicationInsightsTestFixture.cs
@@ -16,10 +16,11 @@

 namespace Microsoft.Azure.WebJobs.Script.Tests.ApplicationInsights
 {
-    public abstract class ApplicationInsightsTestFixture
+    public abstract class ApplicationInsightsTestFixture : IDisposable
     {
         private readonly ScriptSettingsManager _settingsManager;
         private readonly HttpConfiguration _config = new HttpConfiguration();
+        private readonly HttpServer _httpServer;

         public ApplicationInsightsTestFixture(string scriptRoot, string testId)
         {
@@ -43,8 +44,8 @@

             InitializeConfig(hostConfig);

-            var httpServer = new HttpServer(_config);
-            HttpClient = new HttpClient(httpServer)
+            _httpServer = new HttpServer(_config);
+            HttpClient = new HttpClient(_httpServer)
             {
                 BaseAddress = new Uri("https://localhost/")
             };
@@ -68,6 +69,12 @@
                 // Overwrite the generated function whitelist to only include two functions.
                 c.Functions = new[] { "Scenarios", "HttpTrigger-Scenarios" };
             };
+        }
+
+        public void Dispose()
+        {
+            _httpServer?.Dispose();
+            HttpClient?.Dispose();
         }

         private class TestLoggerFactoryBuilder : DefaultLoggerFactoryBuilder


Removed pagination from search template.

It's not necessary and breaks some clients.

--- DotOPDS/Controllers/SearchController.cs
+++ DotOPDS/Controllers/SearchController.cs
@@ -14,7 +14,7 @@
     public class SearchController : ApiController
     {
         private const string Prefix = "/opds";
-        private static FeedLink SearchLink = new FeedLink { Rel = FeedLinkRel.Search, Type = FeedLinkType.Atom, Href = Prefix + "/search?q={searchTerms}&page={startPage?}" };
+        private static FeedLink SearchLink = new FeedLink { Rel = FeedLinkRel.Search, Type = FeedLinkType.Atom, Href = Prefix + "/search?q={searchTerms}" };
         private static FeedLink StartLink = new FeedLink { Rel = FeedLinkRel.Start, Type = FeedLinkType.AtomNavigation, Href = Prefix.StartsWith("/") ? Prefix : "/" };

         [Route("")]


Rename discord help option

Rename discord help option

--- EDDiscovery/EDDiscoveryForm.Designer.cs
+++ EDDiscovery/EDDiscoveryForm.Designer.cs
@@ -384,7 +384,7 @@
             //
             this.aboutToolStripMenuItem.Image = global::EDDiscovery.Properties.Resources.stats;
             this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
-            this.aboutToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
+            this.aboutToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
             this.aboutToolStripMenuItem.Text = "&About";
             this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
             //
@@ -393,28 +393,28 @@
             this.eDDiscoveryHomepageToolStripMenuItem.Image = global::EDDiscovery.Properties.Resources.star;
             this.eDDiscoveryHomepageToolStripMenuItem.Name = "eDDiscoveryHomepageToolStripMenuItem";
             this.eDDiscoveryHomepageToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F1;
-            this.eDDiscoveryHomepageToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
+            this.eDDiscoveryHomepageToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
             this.eDDiscoveryHomepageToolStripMenuItem.Text = "&View Help";
             this.eDDiscoveryHomepageToolStripMenuItem.Click += new System.EventHandler(this.eDDiscoveryHomepageToolStripMenuItem_Click);
             //
             // helpMenuSeparatorTop
             //
             this.helpMenuSeparatorTop.Name = "helpMenuSeparatorTop";
-            this.helpMenuSeparatorTop.Size = new System.Drawing.Size(203, 6);
+            this.helpMenuSeparatorTop.Size = new System.Drawing.Size(239, 6);
             //
             // eDDiscoveryChatDiscordToolStripMenuItem
             //
             this.eDDiscoveryChatDiscordToolStripMenuItem.Image = global::EDDiscovery.Properties.Resources.engineercraft;
             this.eDDiscoveryChatDiscordToolStripMenuItem.Name = "eDDiscoveryChatDiscordToolStripMenuItem";
-            this.eDDiscoveryChatDiscordToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
-            this.eDDiscoveryChatDiscordToolStripMenuItem.Text = "&Developer Chat (Discord)";
+            this.eDDiscoveryChatDiscordToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
+            this.eDDiscoveryChatDiscordToolStripMenuItem.Text = "&Discord - EDD Community Chat";
             this.eDDiscoveryChatDiscordToolStripMenuItem.Click += new System.EventHandler(this.eDDiscoveryChatDiscordToolStripMenuItem_Click);
             //
             // frontierForumThreadToolStripMenuItem
             //
             this.frontierForumThreadToolStripMenuItem.Image = global::EDDiscovery.Properties.Resources.Stationenter;
             this.frontierForumThreadToolStripMenuItem.Name = "frontierForumThreadToolStripMenuItem";
-            this.frontierForumThreadToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
+            this.frontierForumThreadToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
             this.frontierForumThreadToolStripMenuItem.Text = "&Frontier Forum Thread";
             this.frontierForumThreadToolStripMenuItem.Click += new System.EventHandler(this.frontierForumThreadToolStripMenuItem_Click);
             //
@@ -422,7 +422,7 @@
             //
             this.gitHubToolStripMenuItem.Image = global::EDDiscovery.Properties.Resources.Homeicon;
             this.gitHubToolStripMenuItem.Name = "gitHubToolStripMenuItem";
-            this.gitHubToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
+            this.gitHubToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
             this.gitHubToolStripMenuItem.Text = "&Project Page (GitHub)";
             this.gitHubToolStripMenuItem.Click += new System.EventHandler(this.gitHubToolStripMenuItem_Click);
             //
@@ -430,20 +430,20 @@
             //
             this.reportIssueIdeasToolStripMenuItem.Image = global::EDDiscovery.Properties.Resources.repairall;
             this.reportIssueIdeasToolStripMenuItem.Name = "reportIssueIdeasToolStripMenuItem";
-            this.reportIssueIdeasToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
+            this.reportIssueIdeasToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
             this.reportIssueIdeasToolStripMenuItem.Text = "&Report Issue / Idea";
             this.reportIssueIdeasToolStripMenuItem.Click += new System.EventHandler(this.reportIssueIdeasToolStripMenuItem_Click);
             //
             // helpMenuSeparatorBottom
             //
             this.helpMenuSeparatorBottom.Name = "helpMenuSeparatorBottom";
-            this.helpMenuSeparatorBottom.Size = new System.Drawing.Size(203, 6);
+            this.helpMenuSeparatorBottom.Size = new System.Drawing.Size(239, 6);
             //
             // checkForNewReleaseToolStripMenuItem
             //
             this.checkForNewReleaseToolStripMenuItem.Image = global::EDDiscovery.Properties.Resources.rebootrepair;
             this.checkForNewReleaseToolStripMenuItem.Name = "checkForNewReleaseToolStripMenuItem";
-            this.checkForNewReleaseToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
+            this.checkForNewReleaseToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
             this.checkForNewReleaseToolStripMenuItem.Text = "&Check for Updates";
             this.checkForNewReleaseToolStripMenuItem.Click += new System.EventHandler(this.checkForNewReleaseToolStripMenuItem_Click);
             //


Fixed shader5 extension switching being in reverse.


Wrap it all in a try

Wrap it all in a try

--- Espera/Espera.Core/YoutubeSongFinder.cs
+++ Espera/Espera.Core/YoutubeSongFinder.cs
@@ -22,34 +22,42 @@
                 SafeSearch = YouTubeQuery.SafeSearchValues.None
             };

-            // NB: I have no idea where this API blocks exactly
-            var settings = new YouTubeRequestSettings("Espera", ApiKey);
-            var request = new YouTubeRequest(settings);
-            Feed<Video> feed = await Task.Run(() => request.Get<Video>(query));
-            List<Video> entries = await Task.Run(() => feed.Entries.ToList());
+            try // The API gives no clue what can throw, wrap it all up
+            {
+                // NB: I have no idea where this API blocks exactly
+                var settings = new YouTubeRequestSettings("Espera", ApiKey);
+                var request = new YouTubeRequest(settings);
+                Feed<Video> feed = await Task.Run(() => request.Get<Video>(query));
+                List<Video> entries = await Task.Run(() => feed.Entries.ToList());

-            var songs = new List<YoutubeSong>();
+                var songs = new List<YoutubeSong>();

-            foreach (Video video in entries)
-            {
-                var duration = TimeSpan.FromSeconds(Int32.Parse(video.YouTubeEntry.Duration.Seconds));
-                string url = video.WatchPage.OriginalString
-                    .Replace("&feature=youtube_gdata_player", String.Empty) // Unnecessary long url
-                    .Replace("https://", "http://"); // Secure connections are not always easy to handle when streaming
+                foreach (Video video in entries)
+                {
+                    var duration = TimeSpan.FromSeconds(Int32.Parse(video.YouTubeEntry.Duration.Seconds));
+                    string url = video.WatchPage.OriginalString
+                        .Replace("&feature=youtube_gdata_player", String.Empty) // Unnecessary long url
+                        .Replace("https://", "http://"); // Secure connections are not always easy to handle when streaming

-                var song = new YoutubeSong(url, duration)
-                {
-                    Title = video.Title,
-                    Description = video.Description,
-                    Rating = video.RatingAverage >= 1 ? video.RatingAverage : (double?)null,
-                    ThumbnailSource = new Uri(video.Thumbnails[0].Url),
-                    Views = video.ViewCount
-                };
+                    var song = new YoutubeSong(url, duration)
+                    {
+                        Title = video.Title,
+                        Description = video.Description,
+                        Rating = video.RatingAverage >= 1 ? video.RatingAverage : (double?)null,
+                        ThumbnailSource = new Uri(video.Thumbnails[0].Url),
+                        Views = video.ViewCount
+                    };

-                songs.Add(song);
+                    songs.Add(song);
+                }
+
+                return songs;
             }

-            return songs;
+            catch (Exception ex)
+            {
+                throw new NetworkSongFinderException("YoutubeSongFinder search failed", ex);
+            }
         }

         public async Task<YoutubeSong> ResolveYoutubeSongFromUrl(Uri url)


disable racy FlowAskSpec

disable racy FlowAskSpec

--- src/core/Akka.Streams.Tests/Dsl/FlowAskSpec.cs
+++ src/core/Akka.Streams.Tests/Dsl/FlowAskSpec.cs
@@ -244,7 +244,7 @@
                 .Should().BeOfType<AskTimeoutException>();
         }, _materializer);

-        [Fact]
+        [Fact(Skip = "Racy on Azure DevOps")]
         public void Flow_with_ask_must_signal_ask_failure() => this.AssertAllStagesStopped(() =>
         {
             var failsOn = ReplierFailOn(1);


Fixing selection issues for ribbon tabs

Fixing selection issues for ribbon tabs

--- Fluent.Ribbon/Controls/RibbonTabItem.cs
+++ Fluent.Ribbon/Controls/RibbonTabItem.cs
@@ -784,10 +784,10 @@
             var newValue = (bool)e.NewValue;
             if (newValue)
             {
-                if (container.TabControlParent != null
+                if (container.TabControlParent?.SelectedTabItem != null
                     && ReferenceEquals(container.TabControlParent.SelectedTabItem, container) == false)
                 {
-                    ((RibbonTabItem)container.TabControlParent.SelectedItem).IsSelected = false;
+                    container.TabControlParent.SelectedTabItem.IsSelected = false;
                 }

                 container.OnSelected(new RoutedEventArgs(Selector.SelectedEvent, container));


Add readonly to Label members

Add readonly to Label members

--- src/csharp/Intel/Iced/Intel/Assembler/Label.cs
+++ src/csharp/Intel/Iced/Intel/Assembler/Label.cs
@@ -48,24 +48,24 @@
 		/// <summary>
 		/// Gets the instruction index associated with this label. This is setup after calling <see cref="Assembler.Label"/>.
 		/// </summary>
-		public int InstructionIndex { get; internal set; }
+		public int InstructionIndex { readonly get; internal set; }

 		/// <summary>
 		/// <c>true</c> if this label is empty and was not created by <see cref="Assembler.CreateLabel"/>.
 		/// </summary>
-		public bool IsEmpty => Id == 0;
+		public readonly bool IsEmpty => Id == 0;

 		/// <inheritdoc />
-		public override string ToString() => $"{Name}@{Id}";
+		public override readonly string ToString() => $"{Name}@{Id}";

 		/// <inheritdoc />
-		public bool Equals(Label other) => Name == other.Name && Id == other.Id;
+		public readonly bool Equals(Label other) => Name == other.Name && Id == other.Id;

 		/// <inheritdoc />
-		public override bool Equals(object? obj) => obj is Label other && Equals(other);
+		public override readonly bool Equals(object? obj) => obj is Label other && Equals(other);

 		/// <inheritdoc />
-		public override int GetHashCode() {
+		public override readonly int GetHashCode() {
 			unchecked {
 				return (Name.GetHashCode() * 397) ^ Id.GetHashCode();
 			}


[Rust] Change arg order of OnUserBanned, add IP address

--- Games/Unity/Oxide.Game.Rust/RustCore.cs
+++ Games/Unity/Oxide.Game.Rust/RustCore.cs
@@ -286,6 +286,43 @@
         #region Player Hooks

         /// <summary>
+        /// Called when a player is attempting to connect
+        /// </summary>
+        /// <param name="connection"></param>
+        /// <returns></returns>
+        [HookMethod("IOnUserApprove")]
+        private object IOnUserApprove(Connection connection)
+        {
+            var name = connection.username;
+            var id = connection.userid.ToString();
+            var authLevel = connection.authLevel;
+            var ip = Regex.Replace(connection.ipaddress, ipPattern, "");
+
+            if (permission.IsLoaded && authLevel <= DefaultGroups.Length)
+            {
+                permission.UpdateNickname(id, name);
+                if (!permission.UserHasGroup(id, DefaultGroups[0])) permission.AddUserGroup(id, DefaultGroups[0]);
+                if (authLevel >= 1 && !permission.UserHasGroup(id, DefaultGroups[authLevel])) permission.AddUserGroup(id, DefaultGroups[authLevel]);
+            }
+
+            Covalence.PlayerManager.PlayerJoin(connection.userid, name);
+
+            var loginSpecific = Interface.Call("CanClientLogin", connection);
+            var loginCovalence = Interface.Call("CanUserLogin", name, id, ip);
+            var canLogin = loginSpecific ?? loginCovalence; // TODO: Fix 'RustCore' hook conflict when both return
+
+            if (canLogin is string || (canLogin is bool && !(bool)canLogin))
+            {
+                ConnectionAuth.Reject(connection, canLogin is string ? canLogin.ToString() : lang.GetMessage("ConnectionRejected", this, id));
+                return true;
+            }
+
+            var approvedSpecific = Interface.Call("OnUserApprove", connection);
+            var approvedCovalence = Interface.Call("OnUserApproved", name, id, ip);
+            return approvedSpecific ?? approvedCovalence; // TODO: Fix 'RustCore' hook conflict when both return
+        }
+
+        /// <summary>
         /// Called when a server group is set for an ID
         /// </summary>
         /// <param name="id"></param>
@@ -296,44 +333,8 @@
         [HookMethod("IOnServerUsersSet")]
         private void IOnServerUsersSet(ulong id, ServerUsers.UserGroup group, string name, string reason)
         {
-            if (group == ServerUsers.UserGroup.Banned) Interface.Oxide.CallHook("OnUserBanned", id.ToString(), name, reason);
-        }
-
-        /// <summary>
-        /// Called when a player is attempting to connect
-        /// </summary>
-        /// <param name="connection"></param>
-        /// <returns></returns>
-        [HookMethod("IOnUserApprove")]
-        private object IOnUserApprove(Connection connection)
-        {
-            var name = connection.username;
-            var id = connection.userid.ToString();
-            var authLevel = connection.authLevel;
-            var ip = Regex.Replace(connection.ipaddress, ipPattern, "");
-
-            if (permission.IsLoaded && authLevel <= DefaultGroups.Length)
-            {
-                permission.UpdateNickname(id, name);
-                if (!permission.UserHasGroup(id, DefaultGroups[0])) permission.AddUserGroup(id, DefaultGroups[0]);
-                if (authLevel >= 1 && !permission.UserHasGroup(id, DefaultGroups[authLevel])) permission.AddUserGroup(id, DefaultGroups[authLevel]);
-            }
-
-            Covalence.PlayerManager.PlayerJoin(connection.userid, name);
-
-            var loginSpecific = Interface.Call("CanClientLogin", connection);
-            var loginCovalence = Interface.Call("CanUserLogin", name, id, ip);
-            var canLogin = loginSpecific ?? loginCovalence; // TODO: Fix 'RustCore' hook conflict when both return
-
-            if (canLogin is string || (canLogin is bool && !(bool)canLogin))
-            {
-                ConnectionAuth.Reject(connection, canLogin is string ? canLogin.ToString() : lang.GetMessage("ConnectionRejected", this, id));
-                return true;
-            }
-
-            var approvedSpecific = Interface.Call("OnUserApprove", connection);
-            var approvedCovalence = Interface.Call("OnUserApproved", name, id, ip);
-            return approvedSpecific ?? approvedCovalence; // TODO: Fix 'RustCore' hook conflict when both return
+            var iplayer = Covalence.PlayerManager.FindPlayerById(id.ToString());
+            if (group == ServerUsers.UserGroup.Banned) Interface.Oxide.CallHook("OnUserBanned", name, id.ToString(), iplayer.Address, reason);
         }

         /// <summary>
@@ -343,7 +344,11 @@
         /// <param name="reason"></param>
         /// <returns></returns>
         [HookMethod("OnPlayerBanned")]
-        private void OnPlayerBanned(Connection connection, string reason) => Interface.Oxide.CallHook("OnUserBanned", connection.userid.ToString(), connection.username, reason);
+        private void OnPlayerBanned(Connection connection, string reason)
+        {
+            var ip = Regex.Replace(connection.ipaddress, ipPattern, "");
+            Interface.Oxide.CallHook("OnUserBanned", connection.username, connection.userid.ToString(), ip, reason);
+        }

         /// <summary>
         /// Called when the player has been initialized


Remove unnecessary focus overriding.

Remove unnecessary focus overriding.

--- osu.Framework/Graphics/UserInterface/Tab/TabDropDownMenu.cs
+++ osu.Framework/Graphics/UserInterface/Tab/TabDropDownMenu.cs
@@ -1,7 +1,5 @@
 // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
 // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
-
-using osu.Framework.Input;

 // TODO: Hide header when no items in dropdown
 namespace osu.Framework.Graphics.UserInterface.Tab
@@ -42,8 +40,5 @@
             if (ItemDictionary.TryGetValue(val, out index))
                 ItemList[index]?.Show();
         }
-
-        // Don't give focus or it will cover tabs
-        protected override bool OnFocus(InputState state) => false;
     }
 }


Trace in console folders with duplicated projects

--- DotNetProjectsDependenciesViewer.ConsoleUI/DependencyGenerator.cs
+++ DotNetProjectsDependenciesViewer.ConsoleUI/DependencyGenerator.cs
@@ -120,11 +120,29 @@
                     foreach (var projectReference in projectReferences)
                     {
                         string projectReferenceName = projectReference.Element(ns + "Name").Value;
-                        var prj = solution.Projects.SingleOrDefault(p => p.Name == projectReferenceName);
-                        if (prj != null)
-                            project.Projects.Add(prj);
+
+                        IEnumerable<Project> referencesProjects = solution.Projects.Where(p => p.Name == projectReferenceName);
+
+                        if (referencesProjects.Count() > 1)
+                        {
+                            Console.WriteLine(String.Format("[ERROR] Project Reference: {0}. Maybe you may have projects (.csproj) in folder {1}  that are not in solution file {2}", projectReferenceName, solution.Path, solution.PathAndName));
+                            foreach (Project p in referencesProjects)
+                            {
+                                Console.WriteLine(String.Format(p.PathAndName));
+                            }
+                        }
                         else
-                            Console.WriteLine(String.Format("Project Reference: {0}, project not found in: {1}", projectReferenceName, project.Path));
+                        {
+                                if (referencesProjects.Any())
+                                {
+                                    Project prj = referencesProjects.First();
+                                    project.Projects.Add(prj);
+                                }
+                                else
+                                {
+                                    Console.WriteLine(String.Format("[WARNING] Project Reference: {0}, project not found in: {1}", projectReferenceName, project.Path));
+                                }
+                        }
                     }

                     //Local libraries and GAC references


Use pattern match

Use pattern match

--- Source/HelixToolkit.SharpDX.Shared/Model/Collection/FastList.cs
+++ Source/HelixToolkit.SharpDX.Shared/Model/Collection/FastList.cs
@@ -41,8 +41,7 @@

         public FastList(IEnumerable<T> collection)
         {
-            var is2 = collection as ICollection<T>;
-            if (is2 != null)
+            if (collection is ICollection<T> is2)
             {
                 var count = is2.Count;
                 Items = new T[count];
@@ -406,8 +405,7 @@

         public void InsertRange(int index, IEnumerable<T> collection)
         {
-            var is2 = collection as ICollection<T>;
-            if (is2 != null)
+            if (collection is ICollection<T> is2)
             {
                 var count = is2.Count;
                 if (count > 0)
@@ -420,7 +418,7 @@
                     if (this == is2)
                     {
                         Array.Copy(Items, 0, Items, index, index);
-                        Array.Copy(Items, (index + count), Items, (index*2), (_size - index));
+                        Array.Copy(Items, (index + count), Items, (index * 2), (_size - index));
                     }
                     else
                     {


Nicer comments and fixed a bug that meant that 'else' clauses with no expression would never be executed

--- YarnSpinner/CodeGenerator.cs
+++ YarnSpinner/CodeGenerator.cs
@@ -381,6 +381,7 @@

 		void GenerateCode(Node node, Parser.IfStatement statement) {

+			// We'll jump to this label at the end of every clause
 			var endOfIfStatementLabel = RegisterLabel ("endif");

 			foreach (var clause in statement.clauses) {
@@ -396,15 +397,15 @@

 				GenerateCode (node, clause.statements);

-				Emit (node, ByteCode.Label, endOfClauseLabel);
-
+				Emit (node, ByteCode.JumpTo, endOfIfStatementLabel);
+
+				if (clause.expression != null) {
+					Emit (node, ByteCode.Label, endOfClauseLabel);
+				}
 				// Clean up the stack by popping the expression that was tested earlier
 				if (clause.expression != null) {
 					Emit (node, ByteCode.Pop);
 				}
-
-				Emit (node, ByteCode.JumpTo, endOfIfStatementLabel);
-
 			}

 			Emit (node, ByteCode.Label, endOfIfStatementLabel);
@@ -433,7 +434,7 @@
 				// Stack now contains [destinationValue]
 			} else {

-				// It's a combined operation plus assignment
+				// It's a combined operation-plus-assignment

 				// Get the current value of the variable
 				Emit(node, ByteCode.PushVariable, statement.destinationVariableName);
@@ -467,25 +468,36 @@

 			// Store the top of the stack in the variable
 			Emit(node, ByteCode.StoreVariable, statement.destinationVariableName);
+
+			// Clean up the stack
 			Emit (node, ByteCode.Pop);

 		}

 		void GenerateCode(Node node, Parser.Expression expression) {
+
+			// Expressions are either plain values, or function calls
 			switch (expression.type) {
 			case Parser.Expression.Type.Value:
+				// Plain value? Emit that
 				GenerateCode (node, expression.value);
 				break;
 			case Parser.Expression.Type.FunctionCall:
+				// Evaluate all parameter expressions (which will
+				// push them to the stack)
 				foreach (var parameter in expression.parameters) {
 					GenerateCode (node, parameter);
 				}
+				// And then call the function
 				Emit (node, ByteCode.CallFunc, expression.function.name);
 				break;
 			}
 		}

 		void GenerateCode(Node node, Parser.ValueNode value) {
+
+			// Push a value onto the stack
+
 			switch (value.value.type) {
 			case Value.Type.Number:
 				Emit (node, ByteCode.PushNumber, value.value.numberValue);


"Collected money" property in ProjectListItemResponseModel added!

--- Source/Server/Startkicker.Api/Controllers/ProjectsController.cs
+++ Source/Server/Startkicker.Api/Controllers/ProjectsController.cs
@@ -129,7 +129,8 @@
                             Id = y.Id.ToString(),
                             Name = y.Name,
                             GoalMoney = y.GoalMoney,
-                            EstimatedDate = y.EstimatedDate
+                            EstimatedDate = y.EstimatedDate,
+                            CollectedMoney = y.CollectedMoney
                         })
                     .ToList<ProjectListItemResponseModel>();


--- CSharp/Linq/Update.cs
+++ CSharp/Linq/Update.cs
@@ -1,10 +1,6 @@
-foreach (var item in clientes) {
-    item.NomeFantasia.Replace("*", "");
-}
+foreach (var item in clientes) item.NomeFantasia.Replace("*", "");

-foreach (var item in clientes) {
-    item.NomeFantasia.TrimStart('*');
-}
+foreach (var item in clientes) item.NomeFantasia.TrimStart('*');

 var resultado = clientes.Select(item => { item.NomeFantasia.TrimStart('*'); return item; })


Queue BUG

Queue BUG

--- Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs
+++ Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs
@@ -965,7 +965,12 @@
                             addParameters.Add(parameter);
                         }
                         parsmeters.AddRange(addParameters);
-                        itemSql = itemSql.TrimEnd(';')+";";
+                        itemSql = itemSql
+                            .TrimEnd('\r')
+                            .TrimEnd('\n')
+                            .TrimEnd('\r')
+                            .TrimEnd('\n')
+                            .TrimEnd(';')+";";
                         sqlBuilder.AppendLine(itemSql);
                         index++;
                     }


Porting changeset 1209431 to build preview branch:

fixed smart indentation for lambda

calculated indentation incorrectly for one of indent block option. (changeset 1211452)

--- Src/Workspaces/Core/Formatting/BottomUpBaseIndentationFinder.cs
+++ Src/Workspaces/Core/Formatting/BottomUpBaseIndentationFinder.cs
@@ -188,7 +188,7 @@

                 if (operation.Option == IndentBlockOption.RelativeToFirstTokenOnBaseTokenLine)
                 {
-                    return ValueTuple.Create(0, operation);
+                    return ValueTuple.Create(indentationLevel, operation);
                 }

                 if (operation.IsRelativeIndentation)


Made chunk update at login async (with task), this way the current login thread is free to call other events.

--- Chraft/Client.Send.cs
+++ Chraft/Client.Send.cs
@@ -6,6 +6,7 @@
 using Chraft.Properties;
 using System.Threading;
 using Chraft.World.Weather;
+using System.Threading.Tasks;

 namespace Chraft
 {
@@ -151,11 +152,8 @@
             OnJoined();
             SendMotd();
             SendMessage("§cLoading complete.");
-            UpdateChunks(Settings.Default.SightRadius);
-            /*Thread thread = new Thread(UpdateChunksThread);
-            thread.IsBackground = true;
-            thread.Priority = ThreadPriority.Highest;
-            thread.Start();*/
+            _UpdateChunks = new Task(() => { UpdateChunks(Settings.Default.SightRadius); });
+            _UpdateChunks.Start();
         }

         #endregion


Implemented custom enumerator for DisjoinedReadOnlyDictionary.

--- WmcSoft.Core/Collections/Generic/DisjoinedReadOnlyDictionary.cs
+++ WmcSoft.Core/Collections/Generic/DisjoinedReadOnlyDictionary.cs
@@ -45,29 +45,32 @@
         {
             private readonly TKey[] _keys;
             private readonly TValue[] _values;
-
-            int _index;
+            private int _index;
+            private KeyValuePair<TKey, TValue> _current;

             internal Enumerator(TKey[] keys, TValue[] values) {
                 _keys = keys;
                 _values = values;
-                _index = -1;
-            }
-
-            public KeyValuePair<TKey, TValue> Current {
+                _index = 0;
+                _current = default(KeyValuePair<TKey, TValue>);
+            }
+
+            public KeyValuePair<TKey, TValue> Current { get { return _current; } }
+
+            object IEnumerator.Current {
                 get {
-                    var i = _index;
-                    return new KeyValuePair<TKey, TValue>(_keys[i], _values[i]);
+                    if (_index == 0 | _index >= _keys.Length)
+                        throw new InvalidOperationException();
+                    return Current;
                 }
             }
-
-            object IEnumerator.Current { get { return Current; } }

             public void Dispose() {
             }

             public bool MoveNext() {
                 if (_index < _keys.Length) {
+                    _current = new KeyValuePair<TKey, TValue>(_keys[_index], _values[_index]);
                     _index++;
                     return true;
                 }
@@ -100,9 +103,7 @@
         /// An enumerator that can be used to iterate through the collection.
         /// </returns>
         public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() {
-            for (int i = 0; i < _keys.Length; i++) {
-                yield return new KeyValuePair<TKey, TValue>(_keys[i], _values[i]);
-            }
+            return new Enumerator(_keys, _values);
         }

         /// <summary>


Cleaning a unit test

Cleaning a unit test

--- ZScriptTests/CodeGeneration/Analysis/StaticTypeAnalyzerTests.cs
+++ ZScriptTests/CodeGeneration/Analysis/StaticTypeAnalyzerTests.cs
@@ -388,12 +388,6 @@

         #endregion

-        #region Explicit casting
-
-
-
-        #endregion
-
         #region General function resolving

         /// <summary>


PG-771: Added copyright info for target and reference text(s) to Comments property in the Excel file.

--- GlyssenEngine/Export/ProjectExporter.cs
+++ GlyssenEngine/Export/ProjectExporter.cs
@@ -374,9 +374,27 @@
 			//		row[clipFileColIndex] = "= HYPERLINK(\"" + row[clipFileColIndex] + "\")";
 			//}
 			dataArray.Insert(0, GetHeaders().ToArray());
+
+			void AppendReferenceTextCopyrightInfo(ReferenceText referenceText, List<string> list)
+			{
+				var primaryCopyrightInfo = referenceText.Metadata.Copyright?.Statement?.InternalNodes.Select(n => n.InnerText).ToList();
+				if (primaryCopyrightInfo != null && primaryCopyrightInfo.Any())
+				{
+					primaryCopyrightInfo.Insert(0, $"{referenceText.LanguageName} reference text: {referenceText.Metadata.Identification?.Name}");
+					list.AddRange(primaryCopyrightInfo);
+				}
+			}
+
 			using (var xls = new ExcelPackage(new FileInfo(path)))
 			{
 				xls.Workbook.Properties.Title = OutputName;
+				var copyrightInfo = Project.Metadata.Copyright?.Statement?.InternalNodes?.Select(n => n.InnerText).ToList() ??
+					new List<string>();
+				AppendReferenceTextCopyrightInfo(Project.ReferenceText, copyrightInfo);
+				if (Project.ReferenceText.HasSecondaryReferenceText)
+					AppendReferenceTextCopyrightInfo(Project.ReferenceText.SecondaryReferenceText, copyrightInfo);
+				if (copyrightInfo.Any())
+					xls.Workbook.Properties.Comments = string.Join(Environment.NewLine, copyrightInfo);
 				var sheet = xls.Workbook.Worksheets.Add("Script");
 				var firstCell = sheet.Cells["A1"];
 				firstCell.LoadFromArrays(dataArray);


modify: RoutineBuilder.csをC#6.0に対応

modify: RoutineBuilder.csをC#6.0に対応

--- LuryIR/Compiling/IR/RoutineBuilder.cs
+++ LuryIR/Compiling/IR/RoutineBuilder.cs
@@ -59,13 +59,13 @@

         public string SourceName { get; private set; }

-        public IList<Routine> Children { get { return this.children; } }
-
-        public IList<Instruction> Instructions { get { return this.instructions; } }
-
-        public IDictionary<string, int> JumpLabels { get { return this.jumpLabels; } }
-
-        public IDictionary<int, CodePosition> CodePosition { get { return this.codePosition; } }
+        public IList<Routine> Children => this.children;
+
+        public IList<Instruction> Instructions => this.instructions;
+
+        public IDictionary<string, int> JumpLabels => this.jumpLabels;
+
+        public IDictionary<int, CodePosition> CodePosition => this.codePosition;

         #endregion

@@ -74,10 +74,10 @@
         public RoutineBuilder(string name, string sourceName)
         {
             if (name == null)
-                throw new ArgumentNullException("name");
+                throw new ArgumentNullException(nameof(name));

             if (sourceName == null)
-                throw new ArgumentNullException("sourceName");
+                throw new ArgumentNullException(nameof(sourceName));

             this.Name = name;
             this.SourceName = sourceName;
@@ -92,48 +92,42 @@
         #region -- Public Methods --

         public void NoOperation()
-        {
-            this.instructions.Add(new Instruction(Operation.Nop));
-        }
-
-        public int Load(Parameter x, int dest)
-        {
-            if (x == null)
-                throw new ArgumentNullException("x");
+            => this.instructions.Add(new Instruction(Operation.Nop));
+
+        public int Load(Parameter from, int dest)
+        {
+            if (from == null)
+                throw new ArgumentNullException(nameof(from));

             if (dest == NoAssign)
-                throw new ArgumentOutOfRangeException("dest");
-
-            this.CheckAndAssignRegister(ref dest);
-            this.instructions.Add(new Instruction(dest, Operation.Load, x));
-            return dest;
-        }
-
-        public void Store(int dest, Parameter x)
-        {
-            if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (dest < 0)
-                throw new ArgumentOutOfRangeException("dest");
+                throw new ArgumentOutOfRangeException(nameof(dest));
+
+            this.CheckAndAssignRegister(ref dest);
+            this.instructions.Add(new Instruction(dest, Operation.Load, from));
+            return dest;
+        }
+
+        public void Store(int from, Parameter dest)
+        {
+            if (dest == null)
+                throw new ArgumentNullException(nameof(from));
+
+            if (from < 0)
+                throw new ArgumentOutOfRangeException(nameof(dest));

-            this.instructions.Add(new Instruction(Operation.Store, Parameter.GetReference(dest), x));
+            this.instructions.Add(new Instruction(Operation.Store, Parameter.GetRegister(from), dest));
         }

         public void BeginScope()
-        {
-            this.instructions.Add(new Instruction(Operation.Scope));
-        }
+            => this.instructions.Add(new Instruction(Operation.Scope));

         public void EndScope()
-        {
-            this.instructions.Add(new Instruction(Operation.Break));
-        }
+            => this.instructions.Add(new Instruction(Operation.Break));

         public int Increment(Parameter x, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Inc, x));
@@ -143,7 +137,7 @@
         public int Decrement(Parameter x, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Dec, x));
@@ -153,7 +147,7 @@
         public int Positive(Parameter x, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Pos, x));
@@ -163,7 +157,7 @@
         public int Negative(Parameter x, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Neg, x));
@@ -173,7 +167,7 @@
         public int BitwiseNot(Parameter x, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Bnot, x));
@@ -183,10 +177,10 @@
         public int Power(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Pow, x, y));
@@ -196,10 +190,10 @@
         public int Multiply(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Mul, x, y));
@@ -209,10 +203,10 @@
         public int Divide(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Div, x, y));
@@ -222,10 +216,10 @@
         public int IntDivide(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Idiv, x, y));
@@ -235,10 +229,10 @@
         public int Modulo(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Mod, x, y));
@@ -248,10 +242,10 @@
         public int Add(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Add, x, y));
@@ -261,10 +255,10 @@
         public int Subtract(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Sub, x, y));
@@ -274,10 +268,10 @@
         public int Concat(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Con, x, y));
@@ -287,10 +281,10 @@
         public int ShiftLeft(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Shl, x, y));
@@ -300,10 +294,10 @@
         public int ShiftRight(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Shr, x, y));
@@ -313,10 +307,10 @@
         public int BitwiseAnd(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.And, x, y));
@@ -326,10 +320,10 @@
         public int BitwiseXor(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Xor, x, y));
@@ -339,10 +333,10 @@
         public int BitwiseOr(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Or, x, y));
@@ -352,10 +346,10 @@
         public int CompareLessThan(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Lt, x, y));
@@ -365,10 +359,10 @@
         public int CompareGreaterThan(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Gt, x, y));
@@ -378,10 +372,10 @@
         public int CompareLessThanOrEquals(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Ltq, x, y));
@@ -391,10 +385,10 @@
         public int CompareGreaterThanOrEquals(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Gtq, x, y));
@@ -404,10 +398,10 @@
         public int CompareEquals(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Eq, x, y));
@@ -417,10 +411,10 @@
         public int CompareNotEquals(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Neq, x, y));
@@ -430,10 +424,10 @@
         public int CompareIs(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Is, x, y));
@@ -443,10 +437,10 @@
         public int CompareIsNot(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Isn, x, y));
@@ -456,20 +450,20 @@
         public int LogicalNot(Parameter x, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.CheckAndAssignRegister(ref dest);
-            this.instructions.Add(new Instruction(dest, Operation.Lnot, x));
+            this.instructions.Add(new Instruction(dest, Operation.Not, x));
             return dest;
         }

         public int LogicalAnd(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Land, x, y));
@@ -479,10 +473,10 @@
         public int LogicalOr(Parameter x, Parameter y, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
-
-            if (y == null)
-                throw new ArgumentNullException("y");
+                throw new ArgumentNullException(nameof(x));
+
+            if (y == null)
+                throw new ArgumentNullException(nameof(y));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Lor, x, y));
@@ -492,33 +486,30 @@
         public void Return(Parameter x)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.instructions.Add(new Instruction(Operation.Ret, x));
         }

         public void Return()
-        {
-            this.instructions.Add(new Instruction(Operation.Ret, Parameter.Nil));
-        }
+            => this.instructions.Add(new Instruction(Operation.Ret, Parameter.Nil));

         public void Yield(Parameter x)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.instructions.Add(new Instruction(Operation.Yield, x));
         }

         public void Yield()
-        {
-            this.instructions.Add(new Instruction(Operation.Yield, Parameter.Nil));
-        }
+            => this.instructions.Add(new Instruction(Operation.Yield, Parameter.Nil));
+

         public void Throw(Parameter x)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.instructions.Add(new Instruction(Operation.Throw, x));
         }
@@ -526,16 +517,16 @@
         public int Call(Parameter x, int dest, params Parameter[] parameters)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             if (dest == NoAssign)
-                throw new ArgumentOutOfRangeException("dest");
+                throw new ArgumentOutOfRangeException(nameof(dest));

             if (parameters == null)
-                throw new ArgumentNullException("parameters");
+                throw new ArgumentNullException(nameof(parameters));

             if (parameters.Any(p => p == null))
-                throw new ArgumentNullException("parameters");
+                throw new ArgumentNullException(nameof(parameters));

             this.CheckAndAssignRegister(ref dest);

@@ -549,13 +540,13 @@
         public void CallWithoutReturn(Parameter x, params Parameter[] parameters)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             if (parameters == null)
-                throw new ArgumentNullException("parameters");
+                throw new ArgumentNullException(nameof(parameters));

             if (parameters.Any(p => p == null))
-                throw new ArgumentNullException("parameters");
+                throw new ArgumentNullException(nameof(parameters));

             var callParams = new Parameter[parameters.Length + 1];
             callParams[0] = x;
@@ -566,7 +557,7 @@
         public int Eval(Parameter x, int dest = NoAssign)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Eval, x));
@@ -574,14 +565,12 @@
         }

         public void Jump(string label)
-        {
-            this.instructions.Add(new Instruction(Operation.Jmp, Parameter.GetLabel(label)));
-        }
+            => this.instructions.Add(new Instruction(Operation.Jmp, Parameter.GetLabel(label)));

         public void JumpIfTrue(string label, Parameter x)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.instructions.Add(new Instruction(Operation.Jmpt, Parameter.GetLabel(label), x));
         }
@@ -589,7 +578,7 @@
         public void JumpIfFalse(string label, Parameter x)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.instructions.Add(new Instruction(Operation.Jmpf, Parameter.GetLabel(label), x));
         }
@@ -597,7 +586,7 @@
         public void JumpIfNil(string label, Parameter x)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             this.instructions.Add(new Instruction(Operation.Jmpn, Parameter.GetLabel(label), x));
         }
@@ -610,17 +599,15 @@
         }

         public void Overlook()
-        {
-            this.instructions.Add(new Instruction(Operation.Ovlok));
-        }
+            => this.instructions.Add(new Instruction(Operation.Ovlok));

         public int CreateFunction(Routine routine, int dest)
         {
             if (routine == null)
-                throw new ArgumentNullException("routine");
+                throw new ArgumentNullException(nameof(routine));

             if (dest == NoAssign)
-                throw new ArgumentOutOfRangeException("dest");
+                throw new ArgumentOutOfRangeException(nameof(dest));

             this.CheckAndAssignRegister(ref dest);
             this.instructions.Add(new Instruction(dest, Operation.Func, Parameter.GetLabel(routine.Name)));
@@ -630,16 +617,16 @@
         public int CreateClass(Routine initializeRoutine, int dest, params Parameter[] derivation)
         {
             if (initializeRoutine == null)
-                throw new ArgumentNullException("initializeRoutine");
+                throw new ArgumentNullException(nameof(initializeRoutine));

             if (dest == NoAssign)
-                throw new ArgumentOutOfRangeException("dest");
+                throw new ArgumentOutOfRangeException(nameof(dest));

             if (derivation == null)
-                throw new ArgumentNullException("derivation");
+                throw new ArgumentNullException(nameof(derivation));

             if (derivation.Any(p => p == null))
-                throw new ArgumentNullException("derivation");
+                throw new ArgumentNullException(nameof(derivation));

             this.CheckAndAssignRegister(ref dest);

@@ -653,24 +640,22 @@
         public void SetAnnotation(Parameter x, Parameter target)
         {
             if (x == null)
-                throw new ArgumentNullException("x");
+                throw new ArgumentNullException(nameof(x));

             if (target == null)
-                throw new ArgumentNullException("target");
+                throw new ArgumentNullException(nameof(target));

             this.instructions.Add(new Instruction(Operation.Annot, target, x));
         }

         public Routine Build()
-        {
-            return new Routine(
+            => new Routine(
                 this.Name,
                 this.registerCount,
                 this.children,
                 this.instructions,
                 this.jumpLabels,
                 this.codePosition);
-        }

         public string GetLabelName(string name)
         {
@@ -687,20 +672,18 @@
         }

         public void SetLabelAtCurrent(string name)
-        {
-            this.jumpLabels.Add(name, this.instructions.Count);
-        }
+            => this.jumpLabels.Add(name, this.instructions.Count);

         public void SetRoutinePosition(int line, int column, int length = 0)
         {
             if (line < 1)
-                throw new ArgumentOutOfRangeException("line");
+                throw new ArgumentOutOfRangeException(nameof(line));

             if (column < 1)
-                throw new ArgumentOutOfRangeException("column");
+                throw new ArgumentOutOfRangeException(nameof(column));

             if (length < 0)
-                throw new ArgumentOutOfRangeException("length");
+                throw new ArgumentOutOfRangeException(nameof(length));

             this.codePosition.Add(
                 -1,
@@ -710,13 +693,13 @@
         public void SetPositionAtCurrent(int line, int column, int length = 0)
         {
             if (line < 1)
-                throw new ArgumentOutOfRangeException("line");
+                throw new ArgumentOutOfRangeException(nameof(line));

             if (column < 1)
-                throw new ArgumentOutOfRangeException("column");
+                throw new ArgumentOutOfRangeException(nameof(column));

             if (length < 0)
-                throw new ArgumentOutOfRangeException("length");
+                throw new ArgumentOutOfRangeException(nameof(length));

             this.codePosition.Add(
                 this.instructions.Count - 1,
@@ -738,8 +721,8 @@
                 registerCount++;
                 return;
             }
-
-            throw new ArgumentOutOfRangeException("register");
+            else
+                throw new ArgumentOutOfRangeException(nameof(register));
         }

         #endregion


Fix exeption when detect complex property

--- EntityFramework.Include/Internal/Expressions/ExpressionBuilder.cs
+++ EntityFramework.Include/Internal/Expressions/ExpressionBuilder.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Data.Entity;
+using System.Data.Entity.Infrastructure;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Reflection;
@@ -69,7 +70,7 @@
                             visiter.Visit(Expression.MakeMemberAccess(MakeConvert(param, source), _)));
                     }

-                    if (_.PropertyType.IsPrimitive || entry.ComplexProperty(_.Name) != null)
+                    if (_.PropertyType.IsPrimitive || IsComplexProperty(entry, _.Name))
                     {
                         return Expression.Bind(result.GetProperty(_.Name),
                             visiter.Visit(Expression.MakeMemberAccess(MakeConvert(param, source), _)));
@@ -86,5 +87,17 @@
         {
             return Expression.Convert(source, resultType);
         }
+
+        private bool IsComplexProperty(DbEntityEntry entry, string property)
+        {
+            try
+            {
+                return entry?.ComplexProperty(property) != null;
+            }
+            catch (Exception)
+            {
+                return false;
+            }
+        }
     }
 }


Better implementation of the cancellable task pattern.

--- GoogleCloudExtension/GoogleCloudExtension.OAuth/OAuthLoginFlow.cs
+++ GoogleCloudExtension/GoogleCloudExtension.OAuth/OAuthLoginFlow.cs
@@ -97,18 +97,13 @@
                     listener.Start();
                     Debug.WriteLine($"Starting listening for OAUTH code in url {redirectUrl}");

-                    // Main task for waiting for the request.
-                    var contextTask = listener.GetContextAsync();
-                    var cancellationTask = GetCancellationTask(token);
+                    // Wait for the context and possibly the cancellation of the operation.
+                    var contextTask = await GetCancellableTaskAsync(
+                        listener.GetContextAsync(),
+                        token);

-                    var completedTask = await Task.WhenAny(contextTask, cancellationTask);
-                    if (completedTask == cancellationTask)
-                    {
-                        // Because the cancellation task is marked as cancelled this means that the cancellation token
-                        // is cancelled, propagate the cancellation to the caller.
-                        token.ThrowIfCancellationRequested();
-                    }
-
+                    // Awaits the resulting task. If the task is the cancelled one it will throw, otherwise
+                    // it will just return the context.
                     var context = await contextTask;
                     var accessCode = context.Request.QueryString["code"];
                     var error = context.Request.QueryString["error"];
@@ -169,16 +164,21 @@
         }

         /// <summary>
-        /// Returns a task that will never complete succesfully, but will bet set to cancelled if the given
-        /// cancellation token is cancelled.
+        /// Returns a task that can be awaited to get the task with the data. (There are two levels of await here). If
+        /// the operation completed normally then <paramref name="sourceTask"/> is returend and when awaited the result of the
+        /// operation is returned. If the operation is cancelled then a cancelled dummy task is returned, when awaited
+        /// <seealso cref="TaskCanceledException"/> is thrown. This way any task can be made cancellable if the original
+        /// source of the task doesn't support cancellation.
         /// </summary>
-        /// <param name="token">The cancellation token to wrap in a task.</param>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="sourceTask"></param>
+        /// <param name="token"></param>
         /// <returns></returns>
-        private static Task GetCancellationTask(CancellationToken token)
+        private static Task<Task<T>> GetCancellableTaskAsync<T>(Task<T> sourceTask, CancellationToken token)
         {
-            var taskSource = new TaskCompletionSource<object>();
+            var taskSource = new TaskCompletionSource<T>();
             token.Register(() => taskSource.TrySetCanceled());
-            return taskSource.Task;
+            return Task.WhenAny<T>(sourceTask, taskSource.Task);
         }
     }
 }