finished the Remove

finished the Remove

--- src/ImTools/ImTools.cs
+++ src/ImTools/ImTools.cs
@@ -3009,32 +3009,19 @@
                 this == removedEntry ? Empty : this;
         }

-        /// Tombstone for the removed entry. It still keeps the hash to preserve the tree operations.
-        internal sealed class RemovedEntry : Entry
-        {
-            public RemovedEntry(int hash) : base(hash) {}
-            public override string ToString() => "{RemovedE: {H: " + Hash + "}}";
-        }
-
         /// Leaf with 2 hash-ordered entries. Important: the both or either of entries may be null for the removed entries
-        public sealed class Leaf2 : ImHashMap<K, V>
-        {
-            /// Left entry
-            public readonly Entry Entry0;
-            /// Right entry
-            public readonly Entry Entry1;
-            /// Constructs the leaf
+        internal sealed class Leaf2 : ImHashMap<K, V>
+        {
+            public readonly Entry Entry0, Entry1;
             public Leaf2(Entry e0, Entry e1)
             {
                 Debug.Assert(e0.Hash < e1.Hash);
                 Entry0 = e0; Entry1 = e1;
             }

-            /// <inheritdoc />
-            public override int Count() => (Entry0?.Count() ?? 0) + (Entry1?.Count() ?? 0);
+            public override int Count() => Entry0.Count() + Entry1.Count();

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() => "{L2: {E0: " + Entry0 + ", E1: " + Entry1 + "}}";
 #endif

@@ -3070,24 +3057,19 @@
         }

         /// The leaf containing the Leaf2 plus the newest added entry.
-        public sealed class Leaf2Plus1 : ImHashMap<K, V>
-        {
-            /// Plus entry
+        internal sealed class Leaf2Plus1 : ImHashMap<K, V>
+        {
             public readonly Entry Plus;
-            /// The dangling leaf
             public readonly Leaf2 L;
-            /// Constructs the leaf
             public Leaf2Plus1(Entry plus, Leaf2 leaf)
             {
                 Plus = plus;
                 L    = leaf;
             }

-            /// <inheritdoc />
             public override int Count() => Plus.Count() + L.Entry0.Count() + L.Entry1.Count();

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() => "{L21: {P: " + Plus + ", L: " + L + "}}";
 #endif

@@ -3124,25 +3106,20 @@
         }

         /// Leaf with the Leaf2 plus added entry, plus added entry
-        public sealed class Leaf2Plus1Plus1 : ImHashMap<K, V>
-        {
-            /// New entry
+        internal sealed class Leaf2Plus1Plus1 : ImHashMap<K, V>
+        {
             public readonly Entry Plus;
-            /// The existing leaf to add entry to
             public readonly Leaf2Plus1 L;

-            /// Constructs the leaf
             public Leaf2Plus1Plus1(Entry plus, Leaf2Plus1 l)
             {
                 Plus = plus;
                 L = l;
             }

-            /// <inheritdoc />
             public override int Count() => Plus.Count() + L.Plus.Count() + L.L.Entry0.Count() + L.L.Entry1.Count();

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() => "{L211: {P: " + Plus + ", L: " + L + "}}";
 #endif

@@ -3246,20 +3223,10 @@
         }

         /// Leaf with 5 hash-ordered entries
-        public sealed class Leaf5 : ImHashMap<K, V>
-        {
-            /// Left entry
-            public readonly Entry Entry0;
-            /// Middle-left entry
-            public readonly Entry Entry1;
-            /// Middle entry
-            public readonly Entry Entry2;
-            /// Middle-right entry
-            public readonly Entry Entry3;
-            /// Right entry
-            public readonly Entry Entry4;
-
-            /// Constructs the leaf
+        internal sealed class Leaf5 : ImHashMap<K, V>
+        {
+            public readonly Entry Entry0, Entry1, Entry2, Entry3, Entry4;
+
             public Leaf5(Entry e0, Entry e1, Entry e2, Entry e3, Entry e4)
             {
                 Debug.Assert(e0.Hash < e1.Hash, "e0 < e1");
@@ -3269,11 +3236,9 @@
                 Entry0 = e0; Entry1 = e1; Entry2 = e2; Entry3 = e3; Entry4 = e4;
             }

-            /// <inheritdoc />
             public override int Count() => Entry0.Count() + Entry1.Count() + Entry2.Count() + Entry3.Count() + Entry4.Count();

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() =>
                 "{L2: {E0: " + Entry0 + ", E1: " + Entry1 + ", E2: " + Entry2 + ", E3: " + Entry3 + ", E4: " + Entry4 + "}}";
 #endif
@@ -3313,25 +3278,20 @@
         }

         /// Leaf with 5 existing ordered entries plus 1 newly added entry.
-        public sealed class Leaf5Plus1 : ImHashMap<K, V>
-        {
-            /// New entry
+        internal sealed class Leaf5Plus1 : ImHashMap<K, V>
+        {
             public readonly Entry Plus;
-            /// Dangling leaf
             public readonly Leaf5 L;

-            /// Constructs the leaf
             public Leaf5Plus1(Entry plus, Leaf5 l)
             {
                 Plus = plus;
                 L    = l;
             }

-            /// <inheritdoc />
             public override int Count() => Plus.Count() + L.Count();

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() => "{L51: {P: " + Plus + ", L: " + L + "}}";
 #endif

@@ -3421,25 +3381,20 @@
         }

         /// Leaf with 5 existing ordered entries plus 1 newly added, plus 1 newly added.
-        public sealed class Leaf5Plus1Plus1 : ImHashMap<K, V>
-        {
-            /// New entry
+        internal sealed class Leaf5Plus1Plus1 : ImHashMap<K, V>
+        {
             public readonly Entry Plus;
-            /// Dangling leaf
             public readonly Leaf5Plus1 L;

-            /// Constructs the leaf
             public Leaf5Plus1Plus1(Entry plus, Leaf5Plus1 l)
             {
                 Plus = plus;
                 L    = l;
             }

-            /// <inheritdoc />
             public override int Count() => Plus.Count() + L.Count();

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() => "{L511: {P: " + Plus + ", L: " + L + "}}";
 #endif

@@ -3671,15 +3626,12 @@
         }

         /// Branch of 2 leafs or branches with entry in the middle
-        public class Branch2 : ImHashMap<K, V>
-        {
-            /// Left branch
+        internal class Branch2 : ImHashMap<K, V>
+        {
             public readonly ImHashMap<K, V> Left;
-            /// Entry in the middle
             public readonly Entry MidEntry;
-            /// Right branch
             public readonly ImHashMap<K, V> Right;
-            /// Constructs
+
             public Branch2(ImHashMap<K, V> left, Entry entry, ImHashMap<K, V> right)
             {
                 Debug.Assert(left != Empty && right != Empty, $"left:{left} != Empty && right:{right} != Empty");
@@ -3688,11 +3640,9 @@
                 Right    = right;
             }

-            /// <inheritdoc />
-            public sealed override int Count() => (MidEntry is RemovedEntry ? 0 : 1) + Left.Count() + Right.Count();
+            public sealed override int Count() => 1 + Left.Count() + Right.Count();

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() => "{B2: {E: " + MidEntry + ", L: " + Left + ", R: " + Right + "}}";
 #endif

@@ -3704,7 +3654,7 @@
                 var mh = MidEntry.Hash;
                 return hash > mh ? Right.GetEntryOrDefault(hash)
                     :  hash < mh ? Left .GetEntryOrDefault(hash)
-                    :  MidEntry is RemovedEntry ? null : MidEntry;
+                    :  MidEntry;
             }

             internal override ImHashMap<K, V> AddOrGetEntry(int hash, Entry entry)
@@ -3728,7 +3678,7 @@
                          ? new LeftyBranch3(newLeft, e, Right) : new Branch2(newLeft, e, Right);
                 }

-                return e is RemovedEntry ? new Branch2(Left, entry, Right) : (ImHashMap<K, V>)e;
+                return e;
             }

             internal override ImHashMap<K, V> ReplaceEntry(int hash, Entry oldEntry, Entry newEntry)
@@ -3818,13 +3768,14 @@
         }

         /// Right-skewed Branch of 3 - actually a branch of 2 with the right branch of 2
-        public sealed class RightyBranch3 : Branch2
-        {
-            /// Creating the branch
-            public RightyBranch3(ImHashMap<K, V> left, Entry entry, ImHashMap<K, V>  right) : base(left, entry, right) {}
+        internal sealed class RightyBranch3 : Branch2
+        {
+            public RightyBranch3(ImHashMap<K, V> left, Entry entry, ImHashMap<K, V>  rightBranch) : base(left, entry, rightBranch)
+            {
+                Debug.Assert(rightBranch is Branch2, $"Right:{rightBranch} is Branch2");
+            }

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() => "{RB3: {"  + base.ToString() + "}";
 #endif

@@ -3839,9 +3790,9 @@
                     mh = r.MidEntry.Hash;
                     return hash > mh ? r.Right.GetEntryOrDefault(hash)
                         :  hash < mh ? r.Left .GetEntryOrDefault(hash)
-                        :  r.MidEntry is RemovedEntry ? null : r.MidEntry;
-                }
-                return MidEntry is RemovedEntry ? null : MidEntry;
+                        :  r.MidEntry;
+                }
+                return MidEntry;
             }

             internal override ImHashMap<K, V> AddOrGetEntry(int hash, Entry entry)
@@ -3886,12 +3837,7 @@
                     return new RightyBranch3(Left, MidEntry, new Branch2(newMiddle, rb.MidEntry, rb.Right));
                 }

-                var e0 = MidEntry;
-                if (hash == h0)
-                    return e0 is RemovedEntry ? new RightyBranch3(Left, entry, rb) : (ImHashMap<K, V>)e0;
-
-                var e1 = rb.MidEntry;
-                return  e1 is RemovedEntry ? new RightyBranch3(Left, e0, new Branch2(rb.Left, entry, rb.Right)) : (ImHashMap<K, V>)e1;
+                return hash == h0 ? MidEntry : rb.MidEntry;
             }

             internal override ImHashMap<K, V> ReplaceEntry(int hash, Entry oldEntry, Entry newEntry)
@@ -3904,22 +3850,119 @@

             internal override ImHashMap<K, V> RemoveEntry(Entry removedEntry)
             {
-                var hash = removedEntry.Hash;
-                var h = MidEntry.Hash;
-                return hash > h ? new RightyBranch3(Left, MidEntry, Right.RemoveEntry(removedEntry))
-                    :  hash < h ? new RightyBranch3(Left.RemoveEntry(removedEntry), MidEntry, Right)
-                    :  new RightyBranch3(Left, new RemovedEntry(hash), Right);
+                var midLeft = MidEntry;
+                var rb = (Branch2)Right;
+                var middle   = rb.Left;
+                var midRight = rb.MidEntry;
+                var right    = rb.Right;
+
+                // case 1, downward: swap the predecessor entry (max left entry) with the mid entry, then proceed to remove the predecessor from the Left branch
+                if (removedEntry == midLeft)
+                    removedEntry = midLeft = Left.GetMaxHashEntryOrDefault();
+
+                if (removedEntry.Hash <= midLeft.Hash)
+                {
+                    var newLeft = Left.RemoveEntry(removedEntry);
+                    if (newLeft == Empty)
+                    {
+                        if (middle is Leaf2Plus1Plus1 == false)
+                            return new Branch2(middle.AddOrGetEntry(midLeft.Hash, midLeft), midRight, right); //! the height does not change
+                        return new RightyBranch3(midLeft, removedEntry = middle.GetMinHashEntryOrDefault(), new Branch2(middle.RemoveEntry(removedEntry), midRight, right)); //! the height does not change
+                    }
+
+                    // rebalance is needed because the branch was merged from Br2 to Br3 or to Leaf and the height decrease
+                    if (Left.GetType() == typeof(Branch2) && newLeft.GetType() != typeof(Branch2))
+                    {
+                        // the hole has a 3-node as a parent and a 3-node as a sibling.
+                        if (middle is LeftyBranch3 leftyMiddle) //! the height does not change
+                        {
+                            var mlb = (Branch2)leftyMiddle.Left;
+                            return new RightyBranch3(new Branch2(newLeft, midLeft, mlb.Left), mlb.MidEntry, new Branch2(new Branch2(mlb.Right, leftyMiddle.MidEntry, leftyMiddle.Right), midRight, right));
+                        }
+
+                        // the hole has a 3-node as a parent and a 3-node as a sibling.
+                        if (middle is RightyBranch3 rightyMiddle) //! the height does not change
+                            return new RightyBranch3(new Branch2(newLeft, midLeft, rightyMiddle.Left), rightyMiddle.MidEntry, new Branch2(rightyMiddle.Right, midRight, right));
+
+                        // the hole has a 3-node as a parent and a 2-node as a sibling.
+                        return new Branch2(new RightyBranch3(newLeft, midLeft, middle), midRight, right);
+                    }
+
+                    return new RightyBranch3(newLeft, midLeft, rb); // no rebalance needed
+                }
+
+                if (removedEntry == midRight)
+                    removedEntry = midRight = middle.GetMaxHashEntryOrDefault();
+
+                if (removedEntry.Hash <= midRight.Hash)
+                {
+                    var newMiddle = middle.RemoveEntry(removedEntry);
+                    if (newMiddle == Empty)
+                    {
+                        if (right is Leaf2Plus1Plus1 == false)
+                            return new Branch2(Left, midLeft, right.AddOrGetEntry(midLeft.Hash, midLeft)); // the Br3 become the Br2 but the height did not change - so no rebalance needed
+                        return new RightyBranch3(Left, midLeft, new Branch2(midRight, removedEntry = right.GetMinHashEntryOrDefault(), right.RemoveEntry(removedEntry))); //! the height does not change
+                    }
+
+                    if (middle.GetType() == typeof(Branch2) && newMiddle.GetType() != typeof(Branch2))
+                    {
+                        // the hole has a 3-node as a parent and a 3-node as a sibling.
+                        if (right is LeftyBranch3 leftyRight) //! the height does not change
+                        {
+                            var rlb = (Branch2)leftyRight.Left;
+                            return new RightyBranch3(Left, midLeft, new Branch2(new Branch2(newMiddle, midRight, rlb.Left), rlb.MidEntry, new Branch2(rlb.Right, leftyRight.MidEntry, leftyRight.Right)));
+                        }
+
+                        // the hole has a 3-node as a parent and a 3-node as a sibling.
+                        if (right is RightyBranch3 rightyRight) //! the height does not change
+                            return new RightyBranch3(Left, midLeft, new Branch2(new Branch2(newMiddle, midRight, rightyRight.Left), rightyRight.MidEntry, rightyRight.Right));
+
+                        // the hole has a 3-node as a parent and a 2-node as a sibling.
+                        return new Branch2(Left, midLeft, new RightyBranch3(newMiddle, midRight, right));
+                    }
+
+                    return new RightyBranch3(Left, midLeft, new Branch2(newMiddle, midRight, right));
+                }
+
+                var newRight = right.RemoveEntry(removedEntry);
+                if (newRight == Empty)
+                {
+                    if (middle is Leaf2Plus1Plus1 == false)
+                        return new Branch2(Left, midLeft, middle.AddOrGetEntry(midRight.Hash, midRight));
+                    return new RightyBranch3(Left, midLeft, new Branch2(middle.RemoveEntry(removedEntry = middle.GetMaxHashEntryOrDefault()), removedEntry, midRight));
+                }
+
+                // right was a Br2 but now is Leaf or Br3 - means the branch height is decrease
+                if (right.GetType() == typeof(Branch2) && newRight.GetType() != typeof(Branch2))
+                {
+                    // the hole has a 3-node as a parent and a 3-node as a sibling.
+                    if (middle is LeftyBranch3 leftyMiddle) //! the height does not change
+                        return new RightyBranch3(Left, midLeft, new Branch2(leftyMiddle.Left, leftyMiddle.MidEntry, new Branch2(leftyMiddle.Right, midRight, newRight)));
+
+                    // the hole has a 3-node as a parent and a 3-node as a sibling.new
+                    if (middle is RightyBranch3 rightyMiddle) //! the height does not change
+                    {
+                        var rrb = (Branch2)rightyMiddle.Right;
+                        return new RightyBranch3(Left, midLeft, new Branch2(new Branch2(rightyMiddle.Left, rightyMiddle.MidEntry, rrb.Left), rrb.MidEntry, new Branch2(rrb.Right, midRight, newRight)));
+                    }
+
+                    // the hole has a 3-node as a parent and a 2-node as a sibling.
+                    return new Branch2(Left, midLeft, new LeftyBranch3(middle, midRight, newRight));
+                }
+
+                return new RightyBranch3(Left, midLeft, new Branch2(middle, midRight, newRight));
             }
         }

         /// Left-skewed Branch of 3 - actually a branch of 2 with the left branch of 2
-        public sealed class LeftyBranch3 : Branch2
-        {
-            /// Creating the branch
-            public LeftyBranch3(ImHashMap<K, V> leftBranch, Entry entry, ImHashMap<K, V> right) : base(leftBranch, entry, right) {}
+        internal sealed class LeftyBranch3 : Branch2
+        {
+            public LeftyBranch3(ImHashMap<K, V> leftBranch, Entry entry, ImHashMap<K, V> right) : base(leftBranch, entry, right)
+            {
+                Debug.Assert(leftBranch is Branch2, $"Left:{leftBranch} is Branch2");
+            }

 #if !DEBUG
-            /// <inheritdoc />
             public override string ToString() => "{LB3: {"  + base.ToString() + "}";
 #endif

@@ -3934,9 +3977,9 @@
                     mh = l.MidEntry.Hash;
                     return hash > mh ? l.Right.GetEntryOrDefault(hash)
                         :  hash < mh ? l.Left .GetEntryOrDefault(hash)
-                        :  l.MidEntry is RemovedEntry ? null : l.MidEntry;
-                }
-                return MidEntry is RemovedEntry ? null : MidEntry;
+                        :  l.MidEntry;
+                }
+                return MidEntry;
             }

             internal override ImHashMap<K, V> AddOrGetEntry(int hash, Entry entry)
@@ -3981,11 +4024,7 @@
                     return new LeftyBranch3(new Branch2(lb.Left, lb.MidEntry, newMiddle), MidEntry, Right);
                 }

-                var e0 = lb.MidEntry;
-                var e1 = MidEntry;
-                return hash == h0
-                    ? (e0 is RemovedEntry ? new LeftyBranch3(new Branch2(lb.Left, entry, lb.Right), e1, Right) : (ImHashMap<K, V>)e0)
-                    : (e1 is RemovedEntry ? new LeftyBranch3(lb, entry, Right) : (ImHashMap<K, V>)e1);
+                return hash == h0 ? lb.MidEntry : MidEntry;
             }

             internal override ImHashMap<K, V> ReplaceEntry(int hash, Entry oldEntry, Entry newEntry)
@@ -3998,11 +4037,108 @@

             internal override ImHashMap<K, V> RemoveEntry(Entry removedEntry)
             {
-                var hash = removedEntry.Hash;
-                var h = MidEntry.Hash;
-                return hash > h ? new LeftyBranch3(Left, MidEntry, Right.RemoveEntry(removedEntry))
-                    :  hash < h ? new LeftyBranch3(Left.RemoveEntry(removedEntry), MidEntry, Right)
-                    :  new LeftyBranch3(Left, new RemovedEntry(hash), Right);
+                var lb = (Branch2)Left;
+                var left     = lb.Left;
+                var midLeft  = lb.MidEntry;
+                var middle   = lb.Right;
+                var midRight = MidEntry;
+                var right    = Right;
+
+                // case 1, downward: swap the predecessor entry (max left entry) with the mid entry, then proceed to remove the predecessor from the Left branch
+                if (removedEntry == midLeft)
+                    removedEntry  = midLeft = left.GetMaxHashEntryOrDefault();
+
+                if (removedEntry.Hash <= midLeft.Hash) // `<=` here is because of check on the above line
+                {
+                    var newLeft = left.RemoveEntry(removedEntry);
+                    if (newLeft == Empty)
+                    {
+                        if (middle is Leaf2Plus1Plus1 == false)
+                            return new Branch2(middle.AddOrGetEntry(midLeft.Hash, midLeft), midRight, right); //! the height does not change
+                        return new RightyBranch3(midLeft, removedEntry = middle.GetMinHashEntryOrDefault(), new Branch2(middle.RemoveEntry(removedEntry), midRight, right)); //! the height does not change
+                    }
+
+                    // rebalance is needed because the branch was merged from Br2 to Br3 or to Leaf and the height decrease
+                    if (left.GetType() == typeof(Branch2) && newLeft.GetType() != typeof(Branch2))
+                    {
+                        // the hole has a 3-node as a parent and a 3-node as a sibling.
+                        if (middle is LeftyBranch3 leftyMiddle) //! the height does not change
+                        {
+                            var mlb = (Branch2)leftyMiddle.Left;
+                            return new RightyBranch3(new Branch2(newLeft, midLeft, mlb.Left), mlb.MidEntry, new Branch2(new Branch2(mlb.Right, leftyMiddle.MidEntry, leftyMiddle.Right), midRight, right));
+                        }
+
+                        // the hole has a 3-node as a parent and a 3-node as a sibling.
+                        if (middle is RightyBranch3 rightyMiddle) //! the height does not change
+                            return new RightyBranch3(new Branch2(newLeft, midLeft, rightyMiddle.Left), rightyMiddle.MidEntry, new Branch2(rightyMiddle.Right, midRight, right));
+
+                        // the hole has a 3-node as a parent and a 2-node as a sibling.
+                        return new Branch2(new RightyBranch3(newLeft, midLeft, middle), midRight, right);
+                    }
+
+                    return new LeftyBranch3(new Branch2(newLeft, midLeft, middle), midRight, Right); // no rebalance needed
+                }
+
+                if (removedEntry == midRight)
+                    removedEntry = midRight = middle.GetMaxHashEntryOrDefault();
+
+                if (removedEntry.Hash <= midRight.Hash) // `<=` here is because of check on the above line
+                {
+                    var newMiddle = middle.RemoveEntry(removedEntry);
+                    if (newMiddle == Empty)
+                    {
+                        if (right is Leaf2Plus1Plus1 == false)
+                            return new Branch2(left, midLeft, right.AddOrGetEntry(midLeft.Hash, midLeft)); // the Br3 become the Br2 but the height did not change - so no rebalance needed
+                        return new LeftyBranch3(new Branch2(left, midLeft, midRight), removedEntry = right.GetMinHashEntryOrDefault(), right.RemoveEntry(removedEntry)); //! the height does not change
+                    }
+
+                    if (middle.GetType() == typeof(Branch2) && newMiddle.GetType() != typeof(Branch2))
+                    {
+                        // the hole has a 3-node as a parent and a 3-node as a sibling.
+                        if (right is LeftyBranch3 leftyRight) //! the height does not change
+                        {
+                            var rlb = (Branch2)leftyRight.Left;
+                            return new RightyBranch3(left, midLeft, new Branch2(new Branch2(newMiddle, midRight, rlb.Left), rlb.MidEntry, new Branch2(rlb.Right, leftyRight.MidEntry, leftyRight.Right)));
+                        }
+
+                        // the hole has a 3-node as a parent and a 3-node as a sibling.
+                        if (right is RightyBranch3 rightyRight) //! the height does not change
+                            return new RightyBranch3(left, midLeft, new Branch2(new Branch2(newMiddle, midRight, rightyRight.Left), rightyRight.MidEntry, rightyRight.Right));
+
+                        // the hole has a 3-node as a parent and a 2-node as a sibling.
+                        return new Branch2(left, midLeft, new RightyBranch3(newMiddle, midRight, right));
+                    }
+
+                    return new LeftyBranch3(new Branch2(left, midLeft, newMiddle), midRight, right);
+                }
+
+                var newRight = right.RemoveEntry(removedEntry);
+                if (newRight == Empty)
+                {
+                    if (middle is Leaf2Plus1Plus1 == false)
+                        return new Branch2(left, midLeft, middle.AddOrGetEntry(midRight.Hash, midRight));
+                    return new RightyBranch3(left, midLeft, new Branch2(middle.RemoveEntry(removedEntry = middle.GetMaxHashEntryOrDefault()), removedEntry, midRight));
+                }
+
+                // right was a Br2 but now is Leaf or Br3 - means the branch height is decrease
+                if (right.GetType() == typeof(Branch2) && newRight.GetType() != typeof(Branch2))
+                {
+                    // the hole has a 3-node as a parent and a 3-node as a sibling.
+                    if (middle is LeftyBranch3 leftyMiddle) //! the height does not change
+                        return new RightyBranch3(left, midLeft, new Branch2(leftyMiddle.Left, leftyMiddle.MidEntry, new Branch2(leftyMiddle.Right, midRight, newRight)));
+
+                    // the hole has a 3-node as a parent and a 3-node as a sibling.new
+                    if (middle is RightyBranch3 rightyMiddle) //! the height does not change
+                    {
+                        var rrb = (Branch2)rightyMiddle.Right;
+                        return new RightyBranch3(left, midLeft, new Branch2(new Branch2(rightyMiddle.Left, rightyMiddle.MidEntry, rrb.Left), rrb.MidEntry, new Branch2(rrb.Right, midRight, newRight)));
+                    }
+
+                    // the hole has a 3-node as a parent and a 2-node as a sibling.
+                    return new Branch2(left, midLeft, new LeftyBranch3(middle, midRight, newRight));
+                }
+
+                return new LeftyBranch3(Left, midRight, newRight);
             }
         }
     }


Runner.cs in MediatR.Examples small check

--- samples/MediatR.Examples/Runner.cs
+++ samples/MediatR.Examples/Runner.cs
@@ -280,6 +280,8 @@
         where TException : Exception
     {
         var messages = writer.Contents.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None).ToList();
+        if (messages.Count - 3 < 0)
+            return false;

         // Note: For this handler type to be found in messages, it must be written in all tested exception handlers
         return messages[messages.Count - 2].Contains(typeof(THandler).FullName)


hwhoops.

hwhoops.

--- git-credential-winstore/Program.cs
+++ git-credential-winstore/Program.cs
@@ -115,7 +115,6 @@
             File.Copy(Assembly.GetExecutingAssembly().Location, dest.FullName, true);

             Process.Start("git", "config --global credential.helper !~/AppData/Roaming/GitCredStore/git-credential-winstore");
-            Environment.SetEnvironmentVariable("EDITOR", "~/AppData/Roaming/GitPad/GitPad.exe", EnvironmentVariableTarget.User);
         }

         static IEnumerable<Tuple<string, string>> GetCommand(IDictionary<string, string> args)


Change TeamArea damage interval from 2 to 1

--- Assets/Scripts/TeamArea.cs
+++ Assets/Scripts/TeamArea.cs
@@ -33,7 +33,7 @@
           return;

         target.State.Invincible = true;
-        MonoUtility.Instance.DelaySec(2.0f, () => { target.State.Invincible = false; } );
+        MonoUtility.Instance.DelaySec(1.0f, () => { target.State.Invincible = false; } );

         _synchronizer.SyncAttack(photonView.viewID, target.PhotonView.viewID, _quantity, false, HitEffectType.None);
       }
@@ -50,4 +50,3 @@
     private float _healTimestamp;
   }
 }
-


added blackout ui removed particle blockers 3

--- Assets/Scripts/Transfer.cs
+++ Assets/Scripts/Transfer.cs
@@ -6,7 +6,8 @@
 	protected int stage = 0;
 	protected bool changing = false;
 	protected int changeStage = 0;
-	protected ulong lightTimer = 0;
+	protected int flashTimer = 0;
+	protected int lightTimer = 0;
 	protected ulong worldTimer = 0;
 	protected float lightControl = 1f;
 	private bool[] complete = new bool[8];
@@ -56,11 +57,13 @@
 		} else if (worldTimer >= 42 && !complete[3]) {
 			Ele1Control.callDoor ();
 			complete [3] = true;
-		} else if (worldTimer >= 32 && !complete[2]) {
+		} else if (worldTimer >= 1 && !complete[2]) {
 			stage++;
 			changing = true;
 			complete [2] = true;
+			flashTimer = Random.Range (5,20);
 		} else if (worldTimer >= 28 && !complete[1]) {
+			complete [1] = true;
 			Ele0Control.callDoor ();
 		} else if (worldTimer >= 10 && !complete[0]) {
 			Ele0Control.callDoor ();
@@ -69,25 +72,44 @@
 	}

 	protected void movePlayer(){
+		Debug.Log (changeStage);
 		if (changing) {
-			lightTimer++;
-			if (lightTimer < 10) {
-				lightControl += 0.1f;
-			} else if (lightTimer > 20) {
-				lightControl -= 0.1f;
-			} else if (lightTimer == 15 && stage == 1) {
-				lightControl = 1f;
-				rig.transform.position = new Vector3 (0, 101, 0);
-			} else if (lightTimer == 15 && stage == 2) {
-				lightControl = 1f;
-				rig.transform.position = new Vector3 (0, 201, 0);
+			if (changeStage == 0 || changeStage == 2) {
+				lightTimer++;
+				if (lightTimer <= flashTimer) {
+					lights.color = (new Color (0f, 0f, 0f, 1f));
+				} else if (lightTimer > 40 && changeStage == 2) {
+					lightTimer = 0;
+					changing = false;
+					changeStage = 0;
+				} else if (lightTimer > 40) {
+					changeStage = 1;
+					lightTimer = 0;
+				} else {
+					lights.color = (new Color (0f, 0f, 0f, 0f));
+				}
+			} else if (changeStage == 1) {
+				lightTimer++;
+				Debug.Log (lightTimer);
+				if (lightTimer < 10) {
+					lightControl += 0.1f;
+				} else if (lightTimer > 10) {
+					lightControl -= 0.1f;
+				} else if (lightTimer == 10 && stage == 1) {
+					lightControl = 1f;
+					rig.transform.position = new Vector3 (0, 101, 0);
+				} else if (lightTimer == 10 && stage == 2) {
+					lightControl = 1f;
+					rig.transform.position = new Vector3 (0, 201, 0);
+				}
+				if (lightTimer >= 20) {
+					flashTimer = Random.Range (5, 20);
+					lightControl = 0f;
+					lightTimer = 0;
+					changeStage = 2;
+				}
+				lights.color = (new Color (0f, 0f, 0f, lightControl));
 			}
-			if (lightTimer >= 30) {
-				lightControl = 0f;
-				lightTimer = 0;
-				changing = false;
-			}
-			lights.color = (new Color (0f, 0f, 0f, lightControl));
 		}
 	}
 }


Fixed a virtual list scroll bug.

Fixed a virtual list scroll bug.

--- Assets/Scripts/UI/GList.cs
+++ Assets/Scripts/UI/GList.cs
@@ -1931,7 +1931,7 @@
 			if (deltaSize != 0 || firstItemDeltaSize != 0)
 				this.scrollPane.ChangeContentSizeOnScrolling(0, deltaSize, 0, firstItemDeltaSize);

-			if (curIndex > 0 && this.numChildren > 0 && this.container.y < 0 && GetChildAt(0).y > -this.container.y)//最后一页没填满！
+			if (curIndex > 0 && this.numChildren > 0 && this.container.y <= 0 && GetChildAt(0).y > -this.container.y)//最后一页没填满！
 				return true;
 			else
 				return false;
@@ -2100,7 +2100,7 @@
 			if (deltaSize != 0 || firstItemDeltaSize != 0)
 				this.scrollPane.ChangeContentSizeOnScrolling(deltaSize, 0, firstItemDeltaSize, 0);

-			if (curIndex > 0 && this.numChildren > 0 && this.container.x < 0 && GetChildAt(0).x > -this.container.x)//最后一页没填满！
+			if (curIndex > 0 && this.numChildren > 0 && this.container.x <= 0 && GetChildAt(0).x > -this.container.x)//最后一页没填满！
 				return true;
 			else
 				return false;


新增 获取当前代码所在方法的方法名 方法

新增 获取当前代码所在方法的方法名 方法

--- Core/通用扩展.cs
+++ Core/通用扩展.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.Diagnostics;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Text;
@@ -16,6 +17,25 @@
 public static partial class 通用扩展
 {
     #region 基本
+
+    /// <summary>
+    /// 获取当前代码所在方法的方法名
+    /// </summary>
+    /// <param name="o">任意对象，仅供调用方便，不作任何处理</param>
+    /// <returns>当前代码所在方法的方法名</returns>
+    public static string GetCurrentMethodName(this object o)
+    {
+        var method = new StackFrame(1).GetMethod(); // 这里忽略1层堆栈，也就忽略了当前方法GetMethodName，这样拿到的就正好是外部调用GetMethodName的方法信息
+        var property = (
+                  from p in method.DeclaringType.GetProperties(
+                           BindingFlags.Instance |
+                           BindingFlags.Static |
+                           BindingFlags.Public |
+                           BindingFlags.NonPublic)
+                  where p.GetGetMethod(true) == method || p.GetSetMethod(true) == method
+                  select p).FirstOrDefault();
+        return property == null ? method.Name : property.Name;
+    }

     /// <summary>
     /// 获取表达式选取的目标属性的名称


First working IRequest.GetBody() implementation.  Have not moved anything into Owin.Request yet.

--- spec/RequestSpec.cs
+++ spec/RequestSpec.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Net;
+using System.Text;
 using System.Collections.Generic;
 using System.Collections.Specialized;
 using Owin;
@@ -10,6 +11,8 @@
     // *Simple* struct-like IRequest implementation for RequestSpec
     // we will probably take this class and use it or parts of it for Owin.Request or, if we make it, Owin.Handlers.Request (?)
     public class Req : IRequest {
+	public delegate void DoWork();
+
 	public Req() {
 	    // Make the Request valid
 	    Method = "GET";
@@ -22,13 +25,40 @@
 	    Items["owin.url_scheme"]       = "http";
 	    Items["owin.remote_endpoint"]  = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 80);
 	    Headers = new Dictionary<string, IEnumerable<string>>();
+	    ActuallyReadTheBody = new ReadTheBodyDelegate(ReadTheBody);
 	}
 	public string Method { get; set; }
 	public string Uri { get; set; }
 	public IDictionary<string, IEnumerable<string>> Headers { get; set; }
 	public IDictionary<string, object> Items { get; set; }
-	public IAsyncResult BeginReadBody(byte[] buffer, int offset, int count, AsyncCallback callback, object state){ return null; }
-	public int EndReadBody(IAsyncResult result){ return 0; }
+
+	public string BodyString { get; set; }
+	public byte[] BodyBytes {
+	    get { return Encoding.UTF8.GetBytes(BodyString); }
+	}
+
+	public delegate int ReadTheBodyDelegate(byte[] buffer, int offset, int count);
+	ReadTheBodyDelegate ActuallyReadTheBody { get; set; }
+	int ReadTheBody(byte[] buffer, int offset, int count) {
+	    int bytesRead = 0;
+	    for (int i = 0; i < count; i++) {
+		int index = offset + i;
+		if (index >= BodyBytes.Length)
+		    break; // the BodyBytes doesn't have this index
+		else {
+		    bytesRead++;
+		    buffer[i] = BodyBytes[index];
+		}
+	    }
+	    return bytesRead;
+	}
+
+	public IAsyncResult BeginReadBody(byte[] buffer, int offset, int count, AsyncCallback callback, object state) {
+	    return ActuallyReadTheBody.BeginInvoke(buffer, offset, count, callback, state);
+	}
+	public int EndReadBody(IAsyncResult result) {
+	    return ActuallyReadTheBody.EndInvoke(result);
+	}
     }

     [TestFixture]
@@ -108,9 +138,51 @@
 		Assert.That(R(new Req { Uri = "/foo?a=5&hi=there" }).GET["hi"], Is.EqualTo("there"));
 	    }

+	    // public IAsyncResult BeginReadBody(byte[] buffer, int offset, int count, AsyncCallback callback, object state){ return null; }
+	    // public int EndReadBody(IAsyncResult result){ return 0; }
+	    [Test]
+	    public void Can_read_body_manually() {
+		IRequest r = new Req { BodyString = "I am the posted body" };
+
+		// grab some bytes ...
+		byte[] bytes        = new byte[5];
+		IAsyncResult result = r.BeginReadBody(bytes, 0, 5, null, null); // no callback or state, we want to do this synchronously
+		int bytesRead       = r.EndReadBody(result); // this should block!  per: http://msdn.microsoft.com/en-us/library/ms228967(v=VS.80).aspx
+		Assert.That(Encoding.UTF8.GetString(bytes), Is.EqualTo("I am "));
+
+		// grab the rest
+		byte[] moreBytes = new byte[1000];
+		result           = r.BeginReadBody(moreBytes, 5, 1000, null, null); // no callback or state, we want to do this synchronously
+		bytesRead        = r.EndReadBody(result); // this should block!  per: http://msdn.microsoft.com/en-us/library/ms228967(v=VS.80).aspx
+		Assert.That(Encoding.UTF8.GetString(WithoutTrailingBytes(moreBytes)), Is.EqualTo("the posted body"));
+	    }
+
+	    byte[] WithoutTrailingBytes(byte[] bytes) {
+		int i = bytes.Length - 1;
+		while (bytes[i] == 0)
+		    i--;
+
+		if (i == 0)
+		    return bytes;
+		else {
+		    byte[] newBytes = new byte[i+1];
+		    Array.Copy(bytes, newBytes, i+1);
+		    return newBytes;
+		}
+	    }
+
+	    [Test][Ignore]
+	    public void Can_read_body() {
+		//Request r = R(new Req { BodyString = "I am the posted body" });
+		//Assert.That(r.Body, Is.EqualTo("I am the posted body")); // <--- blocks until it gets the full body
+	    }
+
 	    [Test][Ignore] public void Can_get_the_raw_QueryString_from_header() {}
+
 	    [Test][Ignore] public void Can_get_the_post_body() {}
+
 	    [Test][Ignore] public void Can_get_the_value_of_a_POST_variable() {}
+
 	    [Test][Ignore] public void Can_get_Params_from_either_a_QueryString_or_POST_variable() {}
 	    [Test][Ignore] public void Can_get_referer_or_referrer() {}
 	    [Test][Ignore] public void Can_get_host() {}


Add layout to guidelines page.

Add layout to guidelines page.

--- src/Stories/Views/Home/Guidelines.cshtml
+++ src/Stories/Views/Home/Guidelines.cshtml
@@ -1,18 +1,24 @@
-
What is dotnet signals?

-.NET Signals is a community driven link aggregator for the sharing of knowledge in the .NET community. Our focus is to give the .NET community a place to post ideas and
-knowledge as voted by the community while avoiding the clutter found in traditional sources.
+@{
+    ViewData["Title"] = "Guidelines";
+    Layout = "~/Views/Shared/_Layout.cshtml";
+}
+

+
What is dotnet signals?

+    .NET Signals is a community driven link aggregator for the sharing of knowledge in the .NET community. Our focus is to give the .NET community a place to post ideas and
+    knowledge as voted by the community while avoiding the clutter found in traditional sources.

-
Posts

-

-
Try to keep the title of the post the same as the article except to add information on vague titles,

-
Posts should be related to the .Net ecosystem or to information regarding technologies that the .Net community would find helpful or interesting,

-
Meta posts and bugs should be created on the github issues page as either discussion or bug,

-
Posts seeking help (homework, how do I do X, etc) are not suited for .NET Signals. Consider asking your questions on the .NET subreddit or stackoverflow.

-

+
Posts

+

+
Try to keep the title of the post the same as the article except to add information on vague titles,

+
Posts should be related to the .Net ecosystem or to information regarding technologies that the .Net community would find helpful or interesting,

+
Meta posts and bugs should be created on the github issues page as either discussion or bug,

+
Posts seeking help (homework, how do I do X, etc) are not suited for .NET Signals. Consider asking your questions on the .NET subreddit or stackoverflow.

+

-
Comments

-

-
Do not spam,

-
Avoid Me toos, thanks, "awesome post" comments,

-
Be professional, be polite.

-
+
Comments

+

+
Do not spam,

+
Avoid Me toos, thanks, "awesome post" comments,

+
Be professional, be polite.

+

+


Fixed slash issue with spec url.

Fixed slash issue with spec url.

--- src/Swank/Configuration/Configuration.cs
+++ src/Swank/Configuration/Configuration.cs
@@ -93,22 +93,28 @@
             };
         }

+        private string _appUrl = "api";
+
+        public string AppUrl
+        {
+            get => _appUrl?.Trim('/');
+            set => _appUrl = value;
+        }
+
+        private string _specificationUrl;
+
+        public string SpecificationUrl
+        {
+            get => (_specificationUrl.IsNullOrEmpty()
+                ? $"{AppUrl?.TrimEnd('/')}/spec"
+                : _specificationUrl)?.Trim('/');
+            set => _specificationUrl = value;
+        }
+
+        public string[] IgnoreFolderUrls { get; set; }
         public Type ApiExplorer { get; set; } = typeof(WebApiExplorer);
         public bool DebugMode { get; set; }
         public bool IgnoreFolders { get; set; }
-        public string[] IgnoreFolderUrls { get; set; }
-        public string AppUrl { get; set; } = "api";
-
-        private string _specificationUrl;
-
-        public string SpecificationUrl
-        {
-            get => _specificationUrl.IsNullOrEmpty()
-                ? $"{AppUrl.TrimEnd('/')}/spec"
-                : _specificationUrl;
-            set => _specificationUrl = value;
-        }
-
         public RazorTemplate AppTemplate { get; set; }
         public string FavIconUrl { get; set; }
         public string ApiUrl { get; set; }


Remove unused methods

Remove unused methods

--- src/Tests.Daterpillar/Helper/TestData.cs
+++ src/Tests.Daterpillar/Helper/TestData.cs
@@ -1,5 +1,4 @@
-using Gigobyte.Daterpillar;
-using System;
+using System;
 using System.IO;
 using System.Linq;

@@ -16,51 +15,5 @@
             return new DirectoryInfo(baseDirectory).GetFiles(ext, SearchOption.AllDirectories)
                 .First(x => x.Name == filename);
         }
-
-        public static Table CreateColumn(string name)
-        {
-            return new Table()
-            {
-                Name = name,
-                Comment = "This is a new table"
-            };
-        }
-
-        public static Column CreateColumn(string name, string tableName = "tb1")
-        {
-            return CreateColumn(name, new DataType("varchar", 32, 0), tableName);
-        }
-
-        public static Column CreateColumn(string name, DataType type, string tableName)
-        {
-            return new Column()
-            {
-                Name = name,
-                DataType = type,
-                IsNullable = false,
-                TableRef = new Table(tableName)
-            };
-        }
-
-        public static Index CreateIndex(string name, string tableName = "tb1", params IndexColumn[] columns)
-        {
-            return new Index()
-            {
-                TableRef = new Table(tableName),
-
-                Name = name,
-                Unique = false,
-                Table = tableName,
-                IndexType = IndexType.Index,
-                Columns = new System.Collections.Generic.List<IndexColumn>(columns)
-            };
-        }
-
-        public static ForeignKey CreateForeignKey(string name)
-        {
-            return new ForeignKey()
-            {
-            };
-        }
     }
 }


Make TypeLoader less verbose

Make TypeLoader less verbose

--- src/Umbraco.Core/Composing/TypeLoader.cs
+++ src/Umbraco.Core/Composing/TypeLoader.cs
@@ -211,7 +211,7 @@
         /// file properties (false) or the file contents (true).</remarks>
         private static string GetFileHash(IEnumerable<Tuple<FileSystemInfo, bool>> filesAndFolders, IProfilingLogger logger)
         {
-            using (logger.TraceDuration<TypeLoader>("Determining hash of code files on disk", "Hash determined"))
+            using (logger.DebugDuration<TypeLoader>("Determining hash of code files on disk", "Hash determined"))
             {
                 // get the distinct file infos to hash
                 var uniqInfos = new HashSet<string>();
@@ -269,7 +269,7 @@
         // internal for tests
         internal static string GetFileHash(IEnumerable<FileSystemInfo> filesAndFolders, IProfilingLogger logger)
         {
-            using (logger.TraceDuration<TypeLoader>("Determining hash of code files on disk", "Hash determined"))
+            using (logger.DebugDuration<TypeLoader>("Determining hash of code files on disk", "Hash determined"))
             {
                 using (var generator = new HashGenerator())
                 {
@@ -666,7 +666,7 @@
             var name = GetName(baseType, attributeType);

             lock (_locko)
-            using (_logger.TraceDuration<TypeLoader>(
+            using (_logger.DebugDuration<TypeLoader>(
                 "Getting " + name,
                 "Got " + name)) // cannot contain typesFound.Count as it's evaluated before the find
             {


Post-merge

Post-merge

--- src/Umbraco.Web/UmbracoInjectedModule.cs
+++ src/Umbraco.Web/UmbracoInjectedModule.cs
@@ -489,7 +489,7 @@

             //disable asp.net headers (security)
             // This is the correct place to modify headers according to MS:
-            // https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/65241-Heap-error-from-header-manipulation?p=0#comment220889
+            // https://our.umbraco.com/forum/umbraco-7/using-umbraco-7/65241-Heap-error-from-header-manipulation?p=0#comment220889
             app.PostReleaseRequestState += (sender, args) =>
             {
                 var httpContext = ((HttpApplication) sender).Context;


don't throw NotImplementedException

don't throw NotImplementedException

--- src/Weakly/Collections/WeakCollection.cs
+++ src/Weakly/Collections/WeakCollection.cs
@@ -125,7 +125,7 @@
         /// <returns>true if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false.</returns>
         public bool Contains(T item)
         {
-            throw new NotImplementedException();
+            throw new NotSupportedException();
         }

         /// <summary>
@@ -135,7 +135,7 @@
         /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
         public void CopyTo(T[] array, int arrayIndex)
         {
-            throw new NotImplementedException();
+            throw new NotSupportedException();
         }

         /// <summary>
@@ -145,7 +145,7 @@
         /// <returns>true if <paramref name="item" /> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false. This method also returns false if <paramref name="item" /> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1" />.</returns>
         public bool Remove(T item)
         {
-            throw new NotImplementedException();
+            throw new NotSupportedException();
         }

         /// <summary>


fix border only margin.

fix border only margin.

--- src/Windows/Avalonia.Win32/WindowImpl.cs
+++ src/Windows/Avalonia.Win32/WindowImpl.cs
@@ -861,9 +861,14 @@

                 if (!_isFullScreenActive)
                 {
+                    var margin = newProperties.Decorations == SystemDecorations.BorderOnly ? 1 : 0;
+
                     var margins = new MARGINS
                     {
-                        cyBottomHeight = newProperties.Decorations == SystemDecorations.BorderOnly ? 1 : 0
+                        cyBottomHeight = margin,
+                        cxRightWidth = margin,
+                        cxLeftWidth = margin,
+                        cyTopHeight = margin
                     };

                     DwmExtendFrameIntoClientArea(_hwnd, ref margins);


Returned JSON formatter for simpler web client code.

--- DotOPDS/WebServer.cs
+++ DotOPDS/WebServer.cs
@@ -1,6 +1,8 @@
 using DotOPDS.Middleware;
 using DotOPDS.Utils;
+using DotOPDS.Web.Utils;
 using Microsoft.Owin.Builder;
+using Newtonsoft.Json.Serialization;
 using Nowin;
 using Owin;
 using System;
@@ -41,7 +43,7 @@
             if (Settings.Instance.Log.Level == "trace")
                 config.MessageHandlers.Add(new MessageLoggingHandler());

-            config.Formatters.Remove(config.Formatters.JsonFormatter);
+            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
             config.Formatters.Remove(config.Formatters.XmlFormatter);
             var xmlFormatter = new AtomXmlMediaTypeFormatter();
             config.Formatters.Insert(0, xmlFormatter);


Fluent LogBuilder  - Remove Sonar warning about empty namespace

--- src/NLog/Fluent/Log.cs
+++ src/NLog/Fluent/Log.cs
@@ -31,9 +31,10 @@
 // THE POSSIBILITY OF SUCH DAMAGE.
 //

+#if !NET35 && !NET40
+
 namespace NLog.Fluent
 {
-#if !NET35 && !NET40
     using System;
     using System.IO;
     using System.Runtime.CompilerServices;
@@ -148,5 +149,6 @@
             }
         }
     }
+}
+
 #endif
-}


DateTime.Now is not DateTime.UtcNow

DateTime.Now is not DateTime.UtcNow

No wonder the tracelogging timestamps have been off, despite having the
Zulu indicator.

--- BaseUtils/Misc/TraceLog.cs
+++ BaseUtils/Misc/TraceLog.cs
@@ -124,7 +124,7 @@
                                 }
                                 else
                                 {
-                                    writer.WriteLine($"[{DateTime.Now.ToString("u")}] {msg}");
+                                    writer.WriteLine($"[{DateTime.UtcNow.ToString("u")}] {msg}");
                                     writer.Flush();
                                     msgrepeats[msg] = 0;
                                     linenum++;
@@ -141,10 +141,10 @@
                                 {
                                     if (rptkvp.Value >= 1)
                                     {
-                                        writer.WriteLine($"[{DateTime.Now.ToString("u")}] {rptkvp.Key}");
+                                        writer.WriteLine($"[{DateTime.UtcNow.ToString("u")}] {rptkvp.Key}");
                                         if (rptkvp.Value > 1)
                                         {
-                                            writer.WriteLine($"[{DateTime.Now.ToString("u")}] Last message repeated {(rptkvp.Value)} times");
+                                            writer.WriteLine($"[{DateTime.UtcNow.ToString("u")}] Last message repeated {(rptkvp.Value)} times");
                                         }
                                     }
                                 }


Update CosmosDebugEnginePackage.cs

Update CosmosDebugEnginePackage.cs

--- source/Cosmos.VS.DebugEngine/CosmosDebugEnginePackage.cs
+++ source/Cosmos.VS.DebugEngine/CosmosDebugEnginePackage.cs
@@ -8,23 +8,23 @@
 using Microsoft.VisualStudio.Shell;
 using Task = System.Threading.Tasks.Task;

-//[assembly: ProvideBindingRedirection(
-//    AssemblyName = "SQLitePCLRaw.batteries_v2",
-//    NewVersion = "2.0.6.1341",
-//    OldVersionLowerBound = "1.0.0.0",
-//    OldVersionUpperBound = "2.0.6.1341")]
+[assembly: ProvideBindingRedirection(
+    AssemblyName = "SQLitePCLRaw.batteries_v2",
+    NewVersion = "2.0.6.1341",
+    OldVersionLowerBound = "1.0.0.0",
+    OldVersionUpperBound = "2.0.6.1341")]

-//[assembly: ProvideBindingRedirection(
-//    AssemblyName = "SQLitePCLRaw.core",
-//    NewVersion = "2.0.6.1341",
-//    OldVersionLowerBound = "1.0.0.0",
-//    OldVersionUpperBound = "2.0.6.1341")]
+[assembly: ProvideBindingRedirection(
+    AssemblyName = "SQLitePCLRaw.core",
+    NewVersion = "2.0.6.1341",
+    OldVersionLowerBound = "1.0.0.0",
+    OldVersionUpperBound = "2.0.6.1341")]

-//[assembly: ProvideBindingRedirection(
-//    AssemblyName = "SQLitePCLRaw.provider.e_sqlite3",
-//    NewVersion = "2.0.6.1341",
-//    OldVersionLowerBound = "1.0.0.0",
-//    OldVersionUpperBound = "2.0.6.1341")]
+[assembly: ProvideBindingRedirection(
+    AssemblyName = "SQLitePCLRaw.provider.e_sqlite3",
+    NewVersion = "2.0.6.1341",
+    OldVersionLowerBound = "1.0.0.0",
+    OldVersionUpperBound = "2.0.6.1341")]

 namespace Cosmos.VS.DebugEngine
 {


Make Content(text) not validate text because of validation in server.

--- AIWolfLib/Content.cs
+++ AIWolfLib/Content.cs
@@ -208,29 +208,23 @@
         public Content(string text)
         {
             Text = text;
-            string sentence = GetSentence(Text);
+            var sentence = GetSentence(Text);
             if (sentence != null) // Complex sentence.
             {
                 Topic = Topic.OPERATOR;
                 Operator = Operator.REQUEST;
-                ContentList = new List<Content>();
-                ContentList.Add(new Content(sentence));
+                ContentList = new List<Content> { new Content(sentence) }.AsReadOnly();
             }
             else // Simple sentence.
             {
-                string[] split = Text.Split();
-                int offset = 0;
+                var split = Text.Split();
+                var offset = 0;
                 if (split[0].StartsWith("Agent"))
                 {
                     Subject = Agent.GetAgent(GetInt(split[0]));
                     offset = 1;
                 }
-                Topic topic;
-                if (!Enum.TryParse(split[0 + offset], out topic))
-                {
-                    throw new AIWolfLibException("Content: Can't find any topic in " + split[0 + offset]);
-                }
-                Topic = topic;
+                Topic = (Topic)Enum.Parse(typeof(Topic), split[0 + offset]);
                 if (split.Length >= 2 + offset && split[1 + offset].StartsWith("Agent"))
                 {
                     Target = Agent.GetAgent(GetInt(split[1 + offset]));
@@ -242,7 +236,7 @@
                         break;
                     case Topic.AGREE:
                     case Topic.DISAGREE:
-                        if (split[1 + offset].Equals("TALK"))
+                        if(split[1 + offset] == "TALK")
                         {
                             Utterance = new Talk(GetInt(split[3 + offset]), GetInt(split[2 + offset]));
                         }
@@ -253,21 +247,11 @@
                         break;
                     case Topic.ESTIMATE:
                     case Topic.COMINGOUT:
-                        Role role;
-                        if (!Enum.TryParse(split[2 + offset], out role))
-                        {
-                            throw new AIWolfLibException("Content: Can't find any role in " + split[2 + offset]);
-                        }
-                        Role = role;
+                        Role = (Role)Enum.Parse(typeof(Role), split[2 + offset]);
                         break;
                     case Topic.DIVINED:
                     case Topic.IDENTIFIED:
-                        Species species;
-                        if (!Enum.TryParse(split[2 + offset], out species))
-                        {
-                            throw new AIWolfLibException("Content: Can't find any species in " + split[2 + offset]);
-                        }
-                        Result = species;
+                        Result = (Species)Enum.Parse(typeof(Species), split[2 + offset]);
                         break;
                     case Topic.ATTACK:
                     case Topic.DIVINATION:
@@ -554,5 +538,4 @@
 #endif
         OR
     }
-
 }


Fix bug on null reference exception and transaction not removing actions that are already executed.

--- Blueprint41/Transaction.cs
+++ Blueprint41/Transaction.cs
@@ -112,6 +112,7 @@
                 {
                     action.ExecuteInDatastore();
                 }
+                actions.Clear();
             }

             foreach (var entitySet in registeredEntities.Values)


Tidied up state check; will make it OO & remove statics soon.

--- Engine/StateCheck.cs
+++ Engine/StateCheck.cs
@@ -17,12 +17,13 @@
 /**********************************************************
 * USING NAMESPACES
 **********************************************************/
+
+using System;
 using System.Threading;
 using QuantConnect.Logging;

 namespace QuantConnect.Lean.Engine
 {
-
     /********************************************************
     * CLASS DEFINITIONS
     *********************************************************/
@@ -30,10 +31,22 @@
     /// Algorithm status monitor reads the central command directive for this algorithm/backtest. When it detects
     /// the backtest has been deleted or cancelled the backtest is aborted.
     /// </summary>
-    public static class StateCheck
+    public class StateCheck
     {
+        /********************************************************
+        * CLASS VARIABLES
+        *********************************************************/
+
+        /********************************************************
+        * CLASS CONSTRUCTOR
+        *********************************************************/
+
+        /********************************************************
+        * CLASS METHODS
+        *********************************************************/
+
         /// DB Ping Class
-        public static class Ping
+        public class Ping
         {
             // set to true to break while loop in Run()
             private static bool _exitTriggered;
@@ -52,19 +65,18 @@
                         {
                             //Get the state from the central server:
                             var state = Engine.Api.GetAlgorithmStatus(AlgorithmManager.AlgorithmId);
+                            Log.Debug("StateCheck.Ping.Run(): Algorithm Status: " + state.Status + " Subscription: " + state.ChartSubscription);
+
+                            //Set state via get/set method:
                             AlgorithmManager.SetStatus(state.Status);
+
                             //Set which chart the user is look at, so we can reduce excess messaging (e.g. trading 100 symbols, only send 1).
                             Engine.ResultHandler.SetChartSubscription(state.ChartSubscription);
-                            Log.Debug("StateCheck.Ping.Run(): Algorithm Status: " + state.Status + " Subscription: " + state.ChartSubscription);
                         }
-                        catch
+                        catch (Exception err)
                         {
-                            Log.Debug("StateCheck.Run(): Error in state check.");
+                            Log.Error("StateCheck.Run(): Error in state check: " + err.Message);
                         }
-                    }
-                    else
-                    {
-                        Log.Debug("StateCheck.Ping.Run(): Opted to not ping: " + AlgorithmManager.AlgorithmId + " " + AlgorithmManager.QuitState);
                     }
                     Thread.Sleep(1000);
                 }


preparation required provided

preparation required provided

--- hoServices/src/Auto/AutoCppZfcs.cs
+++ hoServices/src/Auto/AutoCppZfcs.cs
@@ -37,14 +37,14 @@
                 // estimate file names of component
                 // Component and Module implementation file names beneath folder
                 IQueryable<string> fileNamesOfClassTree = from f in db.Files
-                    where f.Name.StartsWith(folderNameOfClass) && ( f.LeafName.EndsWith(".c") || f.LeafName.EndsWith(".cpp"))
+                    where f.Name.StartsWith(folderNameOfClass) && ( f.LeafName.EndsWith(".c") || f.LeafName.ToLower().EndsWith(".cpp"))
                     select f.LeafName;

-                // Get all function implementation
+                // Get all functions of implementation
                 var allFunctionsImpl = (from f in db.CodeItems
                     join file in db.Files on f.FileId equals file.Id
-                    where f.Kind == 22 && (file.LeafName.ToLower().EndsWith(".c") || file.LeafName.EndsWith(".cpp"))
-                    select new ImplFunctionItem("", f.Name, file.Name)).ToList();
+                    where f.Kind == 22 && (file.LeafName.ToLower().EndsWith(".c") || file.LeafName.ToLower().EndsWith(".cpp"))
+                    select new ImplFunctionItem("", f.Name, file.Name, (int)f.StartLine,(int)f.StartColumn,(int)f.EndLine, (int)f.EndColumn)).ToList() ;

                 //var function1 = db.CodeItems.ToList();
@@ -85,7 +85,7 @@
                 // over all files except Class/Component Tree (files not part of component/class/subfolder)
                 var fileNamesCalledImplementation = (from f in db.Files
                     where !fileNamesOfClassTree.Any(x => x == f.LeafName) &&
-                          f.LeafName.ToLower().EndsWith(".c")
+                          (f.LeafName.ToLower().EndsWith(".c") || f.LeafName.ToLower().EndsWith(".cpp"))
                     select f.Name).Distinct();

@@ -93,19 +93,12 @@
                 {
                     string code = File.ReadAllText(fileName);
                     code = hoService.DeleteComment(code);
-                    int count = 0;
                     foreach (var f1 in compImplementations)
                     {
-                        // Call function in code found, the function is a required interface
-                        //Match match = f1.RX.Match(code);
-                        //if (match.Success)
-                        //{
-                        count += 1;
                         if (f1.RX.IsMatch(code)) {
                             //string found = match.Groups[0].Value;
                             f1.Imp.IsCalled = true;
                             f1.Imp.FilePathCallee = fileName;
-                            // string test = found;

                         }
                     }


inject playerDto

inject playerDto

--- src/Arma3BE.Client.Libs/Repositories/PlayerRepository.cs
+++ src/Arma3BE.Client.Libs/Repositories/PlayerRepository.cs
@@ -16,7 +16,7 @@
         {
         }

-        public IEnumerable<Player> GetAllPlayers()
+        public IEnumerable<PlayerDto> GetAllPlayers()
         {
             using (var dc = new Arma3BeClientContext())
             {
@@ -24,15 +24,16 @@
             }
         }

-        public void AddPlayers(IEnumerable<Player> players)
+        public void AddPlayers(IEnumerable<PlayerDto> players)
         {
+            var playerList = players.Select(Map).ToArray();
+
             using (var dc = new Arma3BeClientContext())
             {
-                dc.Player.AddRange(players);
+                dc.Player.AddRange(playerList);
                 dc.SaveChanges();
             }
         }
-

         public IEnumerable<PlayerDto> GetPlayers(Expression<Func<Player, bool>> expression)
         {
@@ -42,7 +43,6 @@
             }
         }

-
         public IEnumerable<PlayerDto> GetPlayers(IEnumerable<string> guids)
         {
             using (var dc = new Arma3BeClientContext())
@@ -51,6 +51,13 @@
             }
         }

+        public PlayerDto GetPlayer(string guid)
+        {
+            using (var dc = new Arma3BeClientContext())
+            {
+                return dc.Player.FirstOrDefault(x => x.GUID == guid);
+            }
+        }

         public Player GetPlayerInfo(string guid)
         {
@@ -96,15 +103,7 @@

         public void AddOrUpdate(IEnumerable<PlayerDto> players)
         {
-            var playerList = players.Select(x => new Player()
-            {
-                Id = x.Id,
-                Comment = x.Comment,
-                GUID = x.GUID,
-                LastIp = x.LastIp,
-                LastSeen = x.LastSeen,
-                Name = x.Name,
-            }).ToArray();
+            var playerList = players.Select(Map).ToArray();

             using (var dc = new Arma3BeClientContext())
             {
@@ -122,14 +121,6 @@
             }
         }

-        public PlayerDto GetPlayer(string guid)
-        {
-            using (var dc = new Arma3BeClientContext())
-            {
-                return dc.Player.FirstOrDefault(x => x.GUID == guid);
-            }
-        }
-
         public void AddNotes(Guid id, string s)
         {
             using (var dc = new Arma3BeClientContext())
@@ -141,6 +132,20 @@
                 });
                 dc.SaveChanges();
             }
+        }
+
+
+        private Player Map(PlayerDto source)
+        {
+            return new Player()
+            {
+                Id = source.Id,
+                Comment = source.Comment,
+                GUID = source.GUID,
+                LastIp = source.LastIp,
+                LastSeen = source.LastSeen,
+                Name = source.Name
+            };
         }
     }


Formatting, cleanup

Formatting, cleanup

--- src/Blargument/Blargument.UnitTests/TypeInspectorTest.cs
+++ src/Blargument/Blargument.UnitTests/TypeInspectorTest.cs
@@ -1,7 +1,7 @@
 using System;
 using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Blargument.UnitTests.Dummies;
-using Microsoft.VisualStudio.TestTools.UnitTesting;

 namespace Blargument.UnitTests
 {
@@ -46,7 +46,7 @@
          var markedProperties = typeInspector.GetMarkedProperties<ClassWithTwoAttributesOneMarkedAsObsolete, ObsoleteAttribute>();

          Assert.AreEqual( 1, markedProperties.Length );
-         Assert.AreEqual( "TheInt", markedProperties[0].PropertyInfo.Name  );
+         Assert.AreEqual( "TheInt", markedProperties[0].PropertyInfo.Name );
       }

       [TestMethod]


Fix docs

Fix docs

--- src/CacheManager.StackExchange.Redis/RedisCacheHandle.cs
+++ src/CacheManager.StackExchange.Redis/RedisCacheHandle.cs
@@ -137,7 +137,6 @@
         /// <summary>
         /// Gets the servers.
         /// </summary>
-        /// <param name="muxer">The muxer.</param>
         /// <returns>The list of servers.</returns>
         public IEnumerable<StackRedis.IServer> GetServers()
         {


Disable warning in ValueStringBuilder.ToString

--- src/Common/src/CoreLib/System/Text/ValueStringBuilder.cs
+++ src/Common/src/CoreLib/System/Text/ValueStringBuilder.cs
@@ -83,7 +83,9 @@
             }
         }

+#pragma warning disable CS8609 // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/23268
         public override string ToString()
+#pragma warning restore CS8609
         {
             var s = _chars.Slice(0, _pos).ToString();
             Dispose();


Fix editing project in Draft Status.

Fix editing project in Draft Status.

--- src/CompetitionPlatform/Views/Project/EditProject.cshtml
+++ src/CompetitionPlatform/Views/Project/EditProject.cshtml
@@ -131,11 +131,21 @@
                             Status

                                 <select asp-for="@Model.Status" class="form-control">
-                                    @foreach (var status in Enum.GetValues(typeof(Status)))
+                                    @if (Model.Status == Status.Draft)
                                     {
-                                        if (status.ToString() != Status.Draft.ToString())
+                                        foreach (var status in Enum.GetValues(typeof(Status)))
                                         {
                                             <option value=@status>Status: @status</option>
+                                        }
+                                    }
+                                    else
+                                    {
+                                        foreach (var status in Enum.GetValues(typeof(Status)))
+                                        {
+                                            if (status.ToString() != Status.Draft.ToString())
+                                            {
+                                                <option value=@status>Status: @status</option>
+                                            }
                                         }
                                     }
                                 </select>
@@ -260,7 +270,7 @@

-
+

programming resources

You can reference a repository that will help with the development of the project.


fixed std to standard to make stylecop happy

--- src/Core/Managed/Shared/DataContracts/MetricTelemetry.cs
+++ src/Core/Managed/Shared/DataContracts/MetricTelemetry.cs
@@ -8,7 +8,7 @@
     using Microsoft.ApplicationInsights.Extensibility.Implementation.External;

     ///
-    /// Telemetry type used to track metrics. Represents a sample set of values with a specified count, sum, max, min, and std deviation.
+    /// Telemetry type used to track metrics. Represents a sample set of values with a specified count, sum, max, min, and standard deviation.
     /// Learn more
     ///
     public sealed class MetricTelemetry : ITelemetry, ISupportProperties


Tweak exception name in headers

Tweak exception name in headers

--- src/DotNetCore.CAP/Internal/IConsumerRegister.Default.cs
+++ src/DotNetCore.CAP/Internal/IConsumerRegister.Default.cs
@@ -181,7 +181,7 @@
                     }
                     catch (Exception e)
                     {
-                        transportMessage.Headers.Add(Headers.Exception, nameof(SerializationException) + "-->" + e.Message);
+                        transportMessage.Headers.Add(Headers.Exception, e.GetType().Name + "-->" + e.Message);
                         if (transportMessage.Headers.TryGetValue(Headers.Type, out var val))
                         {
                             var dataUri = $"data:{val};base64," + Convert.ToBase64String(transportMessage.Body);


added IParameterProvider but is not used yet

--- src/FastExpressionCompiler.LightExpression/Expression.cs
+++ src/FastExpressionCompiler.LightExpression/Expression.cs
@@ -1928,11 +1928,18 @@
         }
     }

+    // todo: @perf is not used yet
     public interface IArgumentProvider
     {
+        int ArgumentCount { get; }
         Expression GetArgument(int index);
-
-        int ArgumentCount { get; }
+    }
+
+    // todo: @perf is not used yet - apply to LambdaExpression, e.g. LambdaExpression of a single argument
+    internal interface IParameterProvider
+    {
+        int ParameterCount { get; }
+        ParameterExpression GetParameter(int index);
     }

     public sealed class ElementInit : IArgumentProvider


Fix a build break after a merge from master to future.

--- src/Features/Core/Portable/FeaturesResources.Designer.cs
+++ src/Features/Core/Portable/FeaturesResources.Designer.cs
@@ -953,6 +953,15 @@
         }

         /// <summary>
+        ///   Looks up a localized string similar to Fix Name Violation: {0}.
+        /// </summary>
+        internal static string FixNamingViolation {
+            get {
+                return ResourceManager.GetString("FixNamingViolation", resourceCulture);
+            }
+        }
+
+        /// <summary>
         ///   Looks up a localized string similar to from {0}.
         /// </summary>
         internal static string from_0 {
@@ -1732,6 +1741,105 @@
         internal static string Namespaces {
             get {
                 return ResourceManager.GetString("Namespaces", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to Naming Styles.
+        /// </summary>
+        internal static string NamingStylesDiagnosticTitle {
+            get {
+                return ResourceManager.GetString("NamingStylesDiagnosticTitle", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to The first word, '{0}', must begin with a lower case character.
+        /// </summary>
+        internal static string NamingViolation_FirstWordMustBeginWithLowercase {
+            get {
+                return ResourceManager.GetString("NamingViolation_FirstWordMustBeginWithLowercase", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to The first word, '{0}', must begin with an upper case character.
+        /// </summary>
+        internal static string NamingViolation_FirstWordMustBeginWithUppercase {
+            get {
+                return ResourceManager.GetString("NamingViolation_FirstWordMustBeginWithUppercase", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to Missing prefix: '{0}'.
+        /// </summary>
+        internal static string NamingViolation_MissingPrefix {
+            get {
+                return ResourceManager.GetString("NamingViolation_MissingPrefix", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to Missing suffix: '{0}'.
+        /// </summary>
+        internal static string NamingViolation_MissingSuffix {
+            get {
+                return ResourceManager.GetString("NamingViolation_MissingSuffix", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to These non-leading words must begin with a lowercase letter: {0}.
+        /// </summary>
+        internal static string NamingViolation_NonLeadingWordsMustBeginWithLowercase {
+            get {
+                return ResourceManager.GetString("NamingViolation_NonLeadingWordsMustBeginWithLowercase", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to These non-leading words must begin with an upper case letter: {0}.
+        /// </summary>
+        internal static string NamingViolation_NonLeadingWordsMustBeginWithUppercase {
+            get {
+                return ResourceManager.GetString("NamingViolation_NonLeadingWordsMustBeginWithUppercase", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to These words cannot contain lower case characters: {0}.
+        /// </summary>
+        internal static string NamingViolation_WordsCannotContainLowercaseLetters {
+            get {
+                return ResourceManager.GetString("NamingViolation_WordsCannotContainLowercaseLetters", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to These words cannot contain upper case characters: {0}.
+        /// </summary>
+        internal static string NamingViolation_WordsCannotContainUppercaseLetters {
+            get {
+                return ResourceManager.GetString("NamingViolation_WordsCannotContainUppercaseLetters", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to These words must begin with upper case characters: {0}.
+        /// </summary>
+        internal static string NamingViolation_WordsMustBeginWithUppercase {
+            get {
+                return ResourceManager.GetString("NamingViolation_WordsMustBeginWithUppercase", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   Looks up a localized string similar to '{0}' naming violation - {1}.
+        /// </summary>
+        internal static string NamingViolationDescription {
+            get {
+                return ResourceManager.GetString("NamingViolationDescription", resourceCulture);
             }
         }


Defaulting back to the TaskPoolScheduler

--- src/LightningQueues/Net/Protocol/V1/ReceivingProtocol.cs
+++ src/LightningQueues/Net/Protocol/V1/ReceivingProtocol.cs
@@ -15,7 +15,7 @@
         readonly ILogger _logger;
         private readonly IScheduler _scheduler;

-        public ReceivingProtocol(IMessageStore store, ILogger logger) : this(store, logger, Scheduler.Default)
+        public ReceivingProtocol(IMessageStore store, ILogger logger) : this(store, logger, TaskPoolScheduler.Default)
         {
         }


Update src/Markdig/Extensions/MediaLinks/HostProviderBuilder.cs

Co-Authored-By: Alexandre Mutel <0616eded61b1ce92e0d66c474dfbd179079dadbc@live.com>

--- src/Markdig/Extensions/MediaLinks/HostProviderBuilder.cs
+++ src/Markdig/Extensions/MediaLinks/HostProviderBuilder.cs
@@ -46,7 +46,7 @@
             return new DelegateProvider { HostPrefix = hostPrefix, Delegate = handler, AllowFullScreen = allowFullScreen, Class = iframeClass };
         }

-        public static Dictionary<string, IHostProvider> KnownHosts { get; }
+        internal static Dictionary<string, IHostProvider> KnownHosts { get; }
             = new Dictionary<string, IHostProvider>(StringComparer.OrdinalIgnoreCase)
             {
                 ["YouTube"] = Create("www.youtube.com", YouTube, iframeClass: "youtube"),


Changes in Details

Changes in Details

--- src/MuksanDemo/Areas/Security/Views/Users/Details.cshtml
+++ src/MuksanDemo/Areas/Security/Views/Users/Details.cshtml
@@ -9,8 +9,8 @@

-
-
+
+

@@ -32,5 +32,5 @@
         Cancel

-    @Html.ActionLink("Edit", "Edit", new { id = Model.Id })
+    @Html.ActionLink("Edit", "Edit", new { id = Model.Id })


Change TransitionType to an unit enum Add [Falgs] attribute as TransitionType can have multiple values Import values from cef_transition_type_t (cef_types.h) Rename some of the values (slightly friendlier names)

--- CefSharp/TransitionType.cs
+++ CefSharp/TransitionType.cs
@@ -1,12 +1,98 @@
-namespace CefSharp
+using System;
+
+namespace CefSharp
 {
-	public enum TransitionType
+	[Flags]
+	public enum TransitionType : uint
 	{
-		LinkClicked,
-		FormSubmitted,
-		BackForward,
-		Reload,
-		FormResubmitted,
-		Other
+		/// <summary>
+		/// Source is a link click or the JavaScript window.open function. This is
+		/// also the default value for requests like sub-resource loads that are not navigations.
+		/// </summary>
+		LinkClicked = 0,
+
+		/// <summary>
+		/// Source is some other "explicit" navigation action such as creating a new
+		/// browser or using the LoadURL function. This is also the default value
+		/// for navigations where the actual type is unknown.
+		/// </summary>
+		Explicit = 1,
+
+		/// <summary>
+		/// Source is a subframe navigation. This is any content that is automatically
+		/// loaded in a non-toplevel frame. For example, if a page consists of several
+		/// frames containing ads, those ad URLs will have this transition type.
+		/// The user may not even realize the content in these pages is a separate
+		/// frame, so may not care about the URL.
+		/// </summary>
+		AutoSubFrame = 3,
+
+		/// <summary>
+		/// Source is a subframe navigation explicitly requested by the user that will
+		/// generate new navigation entries in the back/forward list. These are
+		/// probably more important than frames that were automatically loaded in
+		/// the background because the user probably cares about the fact that this
+		/// link was loaded.
+		/// </summary>
+		ManualSubFrame = 4,
+
+		/// <summary>
+		/// Source is a form submission by the user. NOTE: In some situations
+		/// submitting a form does not result in this transition type. This can happen
+		/// if the form uses a script to submit the contents.
+		/// </summary>
+		FormSubmit = 7,
+
+		/// <summary>
+		/// Source is a "reload" of the page via the Reload function or by re-visiting
+		/// the same URL. NOTE: This is distinct from the concept of whether a
+		/// particular load uses "reload semantics" (i.e. bypasses cached data).
+		/// </summary>
+		Reload = 8,
+
+		/// <summary>
+		/// General mask defining the bits used for the source values.
+		/// </summary>
+		SourceMask = 0xFF,
+
+		/// <summary>
+		/// Attempted to visit a URL but was blocked.
+		/// </summary>
+		Blocked = 0x00800000,
+
+		/// <summary>
+		/// Used the Forward or Back function to navigate among browsing history.
+		/// </summary>
+		ForwardBack = 0x01000000,
+
+		/// <summary>
+		/// The beginning of a navigation chain.
+		/// </summary>
+		ChainStart = 0x10000000,
+
+		/// <summary>
+		/// The last transition in a redirect chain.
+		/// </summary>
+		ChainEnd = 0x20000000,
+
+		/// <summary>
+		/// Redirects caused by JavaScript or a meta refresh tag on the page.
+		/// </summary>
+		CliendRedirect = 0x40000000,
+
+		/// <summary>
+		/// Redirects sent from the server by HTTP headers.
+		/// </summary>
+		ServerRedirect = 0x80000000,
+
+		/// <summary>
+		/// Used to test whether a transition involves a redirect.
+		/// </summary>
+		IsRedirect = 0xC0000000,
+
+		/// <summary>
+		/// General mask defining the bits used for the qualifiers.
+		/// </summary>
+		QualifierMask = 0xFFFFFF00
 	};
 }


More fixes for RSAAsymmetricKey

More fixes for RSAAsymmetricKey

--- RSAAsymmetricKey.cs
+++ RSAAsymmetricKey.cs
@@ -57,41 +57,42 @@
 			if (parameters.D != null)
 			{
 				Array.Copy (parameters.D, 0, this.privateKey, index, parameters.D.Length);
-				d = new ArraySegment<byte> (this.privateKey, index, parameters.D.Length);
+				this.d = new ArraySegment<byte> (this.privateKey, index, parameters.D.Length);
 				index += parameters.D.Length;
 			}

 			if (parameters.DP != null)
 			{
 				Array.Copy (parameters.DP, 0, this.privateKey, index, parameters.DP.Length);
-				dp = new ArraySegment<byte> (this.privateKey, index, parameters.DP.Length);
+				this.dp = new ArraySegment<byte> (this.privateKey, index, parameters.DP.Length);
 				index += parameters.DP.Length;
 			}

 			if (parameters.DQ != null)
 			{
 				Array.Copy (parameters.DQ, 0, this.privateKey, index, parameters.DQ.Length);
-				dq = new ArraySegment<byte> (this.privateKey, index, parameters.DQ.Length);
+				this.dq = new ArraySegment<byte> (this.privateKey, index, parameters.DQ.Length);
 				index += parameters.DQ.Length;
 			}

 			if (parameters.InverseQ != null)
 			{
 				Array.Copy (parameters.InverseQ, 0, this.privateKey, index, parameters.InverseQ.Length);
-				iq = new ArraySegment<byte> (this.privateKey, index, parameters.InverseQ.Length);
+				this.iq = new ArraySegment<byte> (this.privateKey, index, parameters.InverseQ.Length);
+				index += parameters.InverseQ.Length;
 			}

 			if (parameters.P != null)
 			{
 				Array.Copy (parameters.P, 0, this.privateKey, index, parameters.P.Length);
-				p = new ArraySegment<byte> (this.privateKey, index, parameters.P.Length);
+				this.p = new ArraySegment<byte> (this.privateKey, index, parameters.P.Length);
 				index += parameters.P.Length;
 			}

 			if (parameters.Q != null)
 			{
 				Array.Copy (parameters.Q, 0, this.privateKey, index, parameters.Q.Length);
-				q = new ArraySegment<byte> (this.privateKey, index, parameters.Q.Length);
+				this.q = new ArraySegment<byte> (this.privateKey, index, parameters.Q.Length);
 				index += parameters.Q.Length;
 			}

@@ -132,6 +133,9 @@
 		{
 			get
 			{
+				if (this.d.Array == null)
+					return null;
+
 				byte[] copyD = new byte[this.d.Count];

 				ProtectedMemory.Unprotect (this.privateKey, MemoryProtectionScope.SameProcess);
@@ -146,6 +150,9 @@
 		{
 			get
 			{
+				if (this.dp.Array == null)
+					return null;
+
 				byte[] copy = new byte[this.dp.Count];

 				ProtectedMemory.Unprotect (this.privateKey, MemoryProtectionScope.SameProcess);
@@ -160,6 +167,9 @@
 		{
 			get
 			{
+				if (this.dq.Array == null)
+					return null;
+
 				byte[] copy = new byte[this.dq.Count];

 				ProtectedMemory.Unprotect (this.privateKey, MemoryProtectionScope.SameProcess);
@@ -174,6 +184,9 @@
 		{
 			get
 			{
+				if (this.iq.Array == null)
+					return null;
+
 				byte[] copy = new byte[this.iq.Count];

 				ProtectedMemory.Unprotect (this.privateKey, MemoryProtectionScope.SameProcess);
@@ -188,6 +201,9 @@
 		{
 			get
 			{
+				if (this.p.Array == null)
+					return null;
+
 				byte[] copy = new byte[this.p.Count];

 				ProtectedMemory.Unprotect (this.privateKey, MemoryProtectionScope.SameProcess);
@@ -202,6 +218,9 @@
 		{
 			get
 			{
+				if (this.q.Array == null)
+					return null;
+
 				byte[] copyQ = new byte[this.q.Count];

 				ProtectedMemory.Unprotect (this.privateKey, MemoryProtectionScope.SameProcess);
@@ -298,7 +317,9 @@
 				DQ = key.DQ,
 				InverseQ = key.InverseQ,
 				P = key.P,
-				Q = key.Q
+				Q = key.Q,
+				Exponent = key.Exponent,
+				Modulus = key.Modulus
 			};
 		}


Fixed an ef core warning in muteservice

Fixed an ef core warning in muteservice

--- src/NadekoBot/Modules/Administration/Mute/MuteService.cs
+++ src/NadekoBot/Modules/Administration/Mute/MuteService.cs
@@ -42,7 +42,8 @@
         {
             var guildIds = client.Guilds.Select(x => x.Id).ToList();
             var configs = uow.Set<GuildConfig>()
-                             .AsQueryable()
+                             .AsNoTracking()
+                             .AsSplitQuery()
                              .Include(x => x.MutedUsers)
                              .Include(x => x.UnbanTimer)
                              .Include(x => x.UnmuteTimers)


add ldap password was changed support

add ldap password was changed support

--- src/NuGetGallery/Authentication/AuthenticationService.cs
+++ src/NuGetGallery/Authentication/AuthenticationService.cs
@@ -55,6 +55,7 @@
                 var user = FindByUserNameOrEmail(userNameOrEmail);
                 var AuthTest = new LdapAuthentication("LDAP://kontur");
                 string domain = "kontur";
+                var cred = CredentialBuilder.CreatePbkdf2Password(password);
                 // Check if the user exists
                 if (user == null)
                 {
@@ -64,7 +65,7 @@
                     {
                         //create user
                         string SKBEmail = userNameOrEmail + "@skbkontur.ru";
-                        await Register(userNameOrEmail, SKBEmail, CredentialBuilder.CreatePbkdf2Password(password));
+                        await Register(userNameOrEmail, SKBEmail, cred);
                         user = FindByUserNameOrEmail(userNameOrEmail);

                     }
@@ -78,33 +79,41 @@

                 // Validate the password
                 Credential matched;
-                if ((!ValidatePasswordCredential(user.Credentials, password, out matched)) && (!AuthTest.IsAuthenticated(domain, userNameOrEmail, password)))
-                {
-                    /*test if ldap pass changed
-                    if (AuthTest.IsAuthenticated(domain, userNameOrEmail, password))
+                if (!AuthTest.IsAuthenticated(domain, userNameOrEmail, password))
+                {
+                    Trace.Information("LDAP Password validation failed: " + userNameOrEmail);
+                    return null;
+                }
+                else
+                {
+                    if (!ValidatePasswordCredential(user.Credentials, password, out matched))
+                    {
+                        // Replace/Set password credential
+                        await ReplaceCredentialInternal(user, cred);
+                        Entities.SaveChanges();
+                        user = FindByUserNameOrEmail(userNameOrEmail);
+                    }
+                    //try again
+                    if (!ValidatePasswordCredential(user.Credentials, password, out matched))
                     {
-                        //update password in DB
+                        Trace.Information("Password change failed: " + userNameOrEmail);
+                        return null;
                     }
-                    else
-                    {*/
-                        Trace.Information("Password validation failed: " + userNameOrEmail);
-                        return null;
-                   // }
-                }
-
-
-                var passwordCredentials = user
-                    .Credentials
-                    .Where(c => c.Type.StartsWith(CredentialTypes.Password.Prefix, StringComparison.OrdinalIgnoreCase))
-                    .ToList();
-                if (passwordCredentials.Count > 1 || !passwordCredentials.Any(c => String.Equals(c.Type, CredentialTypes.Password.Pbkdf2, StringComparison.OrdinalIgnoreCase)))
-                {
-                    await MigrateCredentials(user, passwordCredentials, password);
-                }
-
-                // Return the result
-                Trace.Verbose("Successfully authenticated '" + user.Username + "' with '" + matched.Type + "' credential");
-                return new AuthenticatedUser(user, matched);
+
+                        var passwordCredentials = user
+                            .Credentials
+                            .Where(c => c.Type.StartsWith(CredentialTypes.Password.Prefix, StringComparison.OrdinalIgnoreCase))
+                            .ToList();
+                        if (passwordCredentials.Count > 1 || !passwordCredentials.Any(c => String.Equals(c.Type, CredentialTypes.Password.Pbkdf2, StringComparison.OrdinalIgnoreCase)))
+                        {
+                            await MigrateCredentials(user, passwordCredentials, password);
+                        }
+
+                        // Return the result
+                        Trace.Verbose("Successfully authenticated '" + user.Username + "' with '" + matched.Type + "' credential");
+                        return new AuthenticatedUser(user, matched);
+
+                }
             }
         }


Fix test glitch in PersistenceProvider_Memory_FixedLatency_WriteRead (#6378)

--- src/OrleansProviders/Storage/MemoryStorageWithLatency.cs
+++ src/OrleansProviders/Storage/MemoryStorageWithLatency.cs
@@ -97,7 +97,12 @@

             if (sw.Elapsed < this.options.Latency)
             {
-                await Task.Delay(this.options.Latency.Subtract(sw.Elapsed));
+                // Work out the remaining time to wait so that this operation exceeds the required Latency.
+                // Also adds an extra fudge factor to account for any system clock resolution edge cases.
+                var extraDelay = TimeSpan.FromTicks(
+                    this.options.Latency.Ticks - sw.Elapsed.Ticks + 1 /* round up */ );
+
+                await Task.Delay(extraDelay);
             }

             if (error != null)


Small fix to OSD of moves. Added an extra line to the display if the FPS is not shown.

--- src/Plugins/Plugin.Display.OpenGL/DisplayControl.xaml.cs
+++ src/Plugins/Plugin.Display.OpenGL/DisplayControl.xaml.cs
@@ -129,9 +129,11 @@
         // TODO: HANDLE UNICODE / REPLACE CHARS
         private void RenderText(SharpGL.OpenGL gl)
         {
-            var numFit = ((int)ActualHeight - 30) / 15;
-
             int y = (int)ActualHeight - 15;
+            int padding = ShowFPS ? 15 : 0;
+            var numFit = (y - padding) / 15;
+
+
             var textToDisplay = m_displayText.Reverse().Take(numFit).Reverse();
             foreach (var text in textToDisplay)
             {


extra timer for windoof

extra timer for windoof

--- Code/Backend/Controller.cs
+++ Code/Backend/Controller.cs
@@ -335,7 +335,15 @@

 			MeasurementPreProcessing ();

-			MeasurementTimer = new System.Threading.Timer (new TimerCallback (OnMeasurementTimerTick), null, 0, 10);
+
+			if (System.Environment.OSVersion.Platform == PlatformID.Unix)
+			{
+				MeasurementTimer = new System.Threading.Timer (new TimerCallback (OnMeasurementTimerTick), null, 0, 10);
+			} else
+			{
+				//because windows sux
+				MeasurementTimer = new System.Threading.Timer (new TimerCallback (OnMeasurementTimerTickWindows), null, 0, 10);
+			}
 			SequencesTimer.Start ();

 			ConLogger.Log ("Controller Started", LogLevel.DEBUG);
@@ -431,12 +439,9 @@
 				if (running)
 				{
 					double time = KeeperOfTime.ElapsedMilliseconds;
-//					var analogPins = Configuration.AnalogPins.Where (o => ((time % o.Interval) <= 10)).ToArray ();
-					var analogPins = Configuration.AnalogPins.Where (o => (o.LastValue + o.Interval) - time <= 0).ToArray ();
+					var analogPins = Configuration.AnalogPins.Where (o => ((time % o.Interval) <= 10)).ToArray ();
 					if (analogPins.Length > 0)
 					{
-						analogPins.ToList ().ForEach (o => o.LastValue = time);
-
 						Console.WriteLine ("Tick");
 						var query = analogPins.Select (o => o.Number).ToArray ();
 						var vals = ArduinoController.ReadAnalogPin (query);
@@ -482,6 +487,68 @@
 		}

 		/// <summary>
+		/// Raised by the <see cref="MeasurementTimer"/>. Collects data from board.
+		/// </summary>
+		private void OnMeasurementTimerTickWindows (object state)
+		{
+			try
+			{
+				if (running)
+				{
+					double time = KeeperOfTime.ElapsedMilliseconds;
+
+					var analogPins = Configuration.AnalogPins.Where (o => (o.LastValue + o.Interval) - time <= 9).ToArray ();
+
+					if (analogPins.Length > 0)
+					{
+						analogPins.ToList ().ForEach (o => o.LastValue = time - (o.LastValue + o.Interval) + o.Interval);
+
+						var query = analogPins.Select (o => o.Number).ToArray ();
+						var vals = ArduinoController.ReadAnalogPin (query);
+
+						var now = DateTime.Now;
+
+						for (int i = 0; i < analogPins.Length; i++)
+						{
+							lock (analogPins)
+							{
+								analogPins [i].Value = new DateTimeValue (vals [i], now);
+							}
+						}
+
+						var analogPinValues = analogPins.Select (o => o.Value.Value).ToList<double> ();
+						var analogPinValuesNames = analogPins.ToList ().Select (o => o.DisplayName).ToList ();
+
+						var MeComValues = Configuration.MeasurementCombinations
+							.Where (o => !double.IsNaN (o.Value.Value))
+							.Select (o => o.Value.Value)
+							.ToList <double> ();
+						var MeComValuesNames = Configuration.MeasurementCombinations
+							.Where (o => !double.IsNaN (o.Value.Value))
+							.Select (o => o.DisplayName)
+							.ToList ();
+
+						var names = analogPinValuesNames;
+						names.AddRange (MeComValuesNames);
+						var values = analogPinValues;
+						values.AddRange (MeComValues);
+
+						MeasurementCSVLogger.Log (names, values);
+					}
+				} else
+				{
+					System.Threading.Timer t = (System.Threading.Timer)state;
+					t.Dispose ();
+				}
+			} catch (Exception e)
+			{
+				ConLogger.Log (e.ToString (), LogLevel.ERROR);
+			}
+		}
+
+
+
+		/// <summary>
 		/// Saves the configuration.
 		/// </summary>
 		/// <returns><c>true</c>, if configuration was saved, <c>false</c> otherwise.</returns>


Refactoring Added logic to handle if dest folder exists or not Added more examples for folder copy

--- Commands/Files/CopyFile.cs
+++ Commands/Files/CopyFile.cs
@@ -27,6 +27,11 @@
         Remarks = "Copies a file named company.docx located in the document library called Documents located in the projects sitecollection under the managed path sites to the site collection otherproject located in the managed path sites. If a file named company.aspx already exists, it will still perform the copy and replace the original company.aspx file.",
         Code = @"PS:>Copy-PnPFile -ServerRelativeUrl /sites/project/Documents/company.docx -TargetUrl /sites/otherproject/Documents/company.docx -OverwriteIfAlreadyExists",
         SortOrder = 3)]
+    [CmdletExample(
+        Remarks = "Copies a folder named MyDocs located in the document library called Documents located in the projects sitecollection under the managed path sites to the site collection otherproject located in the managed path sites. If a folder already exists, it will still perform the copy and replace the original folder.",
+        Code = @"PS:>Copy-PnPFile -ServerRelativeUrl /sites/project/Documents/MyDocs -TargetUrl /sites/otherproject/Documents -OverwriteIfAlreadyExists",
+        SortOrder = 3)]
+

     public class CopyFile : SPOWebCmdlet
     {
@@ -66,13 +71,13 @@

             if (Force || ShouldContinue(string.Format(Resources.CopyFile0To1, ServerRelativeUrl, TargetUrl), Resources.Confirm))
             {
-                Uri uri = new Uri(ClientContext.Url);
-                Uri targetUri = new Uri(uri, TargetUrl);
-                var webUrl = Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect(ClientContext, targetUri);
                 var srcWeb = ClientContext.Web;
                 ClientContext.Load(srcWeb, s => s.Url);
                 ClientContext.ExecuteQueryRetry();

+                Uri uri = new Uri(ClientContext.Url);
+                Uri targetUri = new Uri(uri, TargetUrl);
+                var webUrl = Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect(ClientContext, targetUri);
                 var targetContext = ClientContext.Clone(webUrl.AbsoluteUri);
                 var dstWeb = targetContext.Web;
                 targetContext.Load(dstWeb, s => s.Url);
@@ -95,12 +100,14 @@
                 //different site/site collection
                 Folder targetFolder = null;
                 string fileOrFolderName = null;
+                bool targetFolderExists = false;
                 try
                 {
                     targetFolder = targetContext.Web.GetFolderByServerRelativeUrl(TargetUrl);
                     targetContext.Load(targetFolder, f => f.Name, f => f.Exists);
                     targetContext.ExecuteQueryRetry();
-                    if(!targetFolder.Exists) throw new Exception("TargetUrl is an existing file, not folder");
+                    if (!targetFolder.Exists) throw new Exception("TargetUrl is an existing file, not folder");
+                    targetFolderExists = true;
                 }
                 catch (Exception)
                 {
@@ -120,7 +127,7 @@
                 if (targetFolder == null) throw new Exception("Target does not exist");
                 if (srcIsFolder)
                 {
-                    if (!SkipSourceFolderName)
+                    if (!SkipSourceFolderName && targetFolderExists)
                     {
                         targetFolder = targetFolder.EnsureFolder(folder.Name);
                     }


Fixed spacings

Fixed spacings

--- src/Generator.cs
+++ src/Generator.cs
@@ -549,7 +549,7 @@

 		public string GetTypeSupportMessageFunctionName()
 		{
-            string func = "rosidl_typesupport_introspection_c__get_message_type_support_handle__" + Namespace+"__msg__"+Name;
+            		string func = "rosidl_typesupport_introspection_c__get_message_type_support_handle__" + Namespace+"__msg__"+Name;
 			return func;
 		}


Update Program.cs

Update Program.cs

--- src/SvgDemo/Program.cs
+++ src/SvgDemo/Program.cs
@@ -229,7 +229,10 @@

         public void PrintAttributes(SvgMergeNode svgMergeNode, string indentLine, string indentAttribute)
         {
-            // TODO:
+            if (!string.IsNullOrEmpty(svgMergeNode.Input))
+            {
+                WriteLine($"{indentLine}{indentAttribute}in: {svgMergeNode.Input}", AttributeColor);
+            }
         }

         public void PrintAttributes(SvgFilter svgFilter, string indentLine, string indentAttribute)


Fixed post shortlink bug

Fixed post shortlink bug

--- RedditSharp/Post.cs
+++ RedditSharp/Post.cs
@@ -67,7 +67,7 @@

         public string Shortlink
         {
-            get { return "http://redd.it/" + Id.Substring(3); }
+            get { return "http://redd.it/" + Id; }
         }

         public Comment Comment(string message)