removed unused stuff

removed unused stuff

--- TCC.Core/App.xaml.cs
+++ TCC.Core/App.xaml.cs
@@ -8,18 +8,14 @@
 using System.Text;
 using System.Threading;
 using System.Windows;
+using System.Windows.Controls;
 using System.Windows.Interop;
 using System.Windows.Media;
 using System.Windows.Threading;
 using TCC.Data;
-using TCC.Data.Chat;
 using TCC.Parsing;
-using TCC.Parsing.Messages;
 using TCC.Settings;
 using TCC.Sniffing;
-using TCC.TeraCommon;
-using TCC.TeraCommon.Game;
-using TCC.TeraCommon.Game.Services;
 using TCC.ViewModels;
 using TCC.Windows;
 using MessageBoxImage = TCC.Data.MessageBoxImage;
@@ -30,16 +26,13 @@
     public partial class App
     {
         public const bool Debug = false;
-        public static string AppVersion;
+        public static string AppVersion { get; private set; } //"TCC vX.Y.Z"
         public static SplashScreen SplashScreen;
         public static Dispatcher BaseDispatcher;
-        public static string BasePath = Path.GetDirectoryName(typeof(App).Assembly.Location);
-        public static string DataPath = Path.Combine(BasePath, "resources", "data");
-
-        // ReSharper disable once InconsistentNaming
-        //public const string ThankYou_mEME =
-        //    "Due to the recent events regarding EME's DMCA takedowns of proxy related repositories, TCC will stop to be supported for NA, meaning that all data required to make it work after patch won't be released for this region. Sorry for this and thanks for all your support.";
+        public static string BasePath { get; }= Path.GetDirectoryName(typeof(App).Assembly.Location);
+        public static string DataPath { get; } = Path.Combine(BasePath, "resources", "data");
         public static bool Loading { get; private set; }
+        public static Random Random = new Random(DateTime.Now.DayOfYear + DateTime.Now.Year);

         private void OnStartup(object sender, StartupEventArgs e)
         {
@@ -74,18 +67,14 @@

             SplashScreen.SetText("Initializing windows...");
             WindowManager.Init();
-
-            //SplashScreen.SetText("Initializing Twitch connector...");
-            //TwitchConnector.Instance.Init();
-
+            //debug
+            //WindowManager.Dashboard.ShowWindow();
+            //
             SplashScreen.SetText("Initializing packet processor...");
             PacketAnalyzer.Init();
             WindowManager.FloatingButton.NotifyExtended("TCC", "Ready to connect.", NotificationType.Normal);
             SplashScreen.SetText("Starting");

-            SessionManager.CurrentPlayer.Class = Class.None;
-            SessionManager.CurrentPlayer.Name = "player";
-            SessionManager.CurrentPlayer.EntityId = 10;
             TimeManager.Instance.SetServerTimeZone(Settings.Settings.LastRegion);
             ChatWindowManager.Instance.AddTccMessage(AppVersion);
             SplashScreen.CloseWindowSafe();
@@ -94,11 +83,14 @@

             //if (Settings.Settings.LastRegion == "NA" || Settings.Settings.LastRegion == "")
             //    WindowManager.FloatingButton.NotifyExtended("So long, and thanks for all the fish", ThankYou_mEME, NotificationType.Error, 15000);
+#pragma warning disable 0162
             if (Debug) DebugStuff();
+#pragma warning restore 0162
             Loading = false;
-        }
-
-        private static System.Timers.Timer _t;
+           // new DebugWindow().Show();
+
+        }
+
         private static void DebugStuff()
         {
             //var broken =


adding time equality filter test

adding time equality filter test

--- Tests/FilterTests.cs
+++ Tests/FilterTests.cs
@@ -255,6 +255,15 @@
             var allUsers = client.Search<User>(s => s.Index("test").Filter(filter));
             Check.That(allUsers.Documents).HasSize(5);
         }
+
+        [Fact]
+        public void Time_equality_filter()
+        {
+            AddSimpleTestData();
+
+            var allUsers = client.Search<Car>(s=>s.FilterOn(x=>x.Timestamp == new DateTime(2010,1,1)));
+            Check.That(allUsers.Documents).HasSize(1);
+        }
     }
 }


Add tests for GetFullPath and GetFileName

--- Tests/PackageTest.cs
+++ Tests/PackageTest.cs
@@ -176,6 +176,28 @@
         }

         [Test]
+        public void TestGetFullPath()
+        {
+            var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "VPK", "broken_dir.vpk");
+
+            using (var package = new Package())
+            {
+                package.Read(path);
+
+                Assert.AreEqual("test", package.FindEntry("test")?.GetFullPath());
+                Assert.AreEqual("folder with space/test", package.FindEntry("folder with space/test")?.GetFullPath());
+                Assert.AreEqual("folder with space/space_extension. txt", package.FindEntry("folder with space\\space_extension. txt")?.GetFullPath());
+                Assert.AreEqual("uppercasefolder/bad_file_forfun.txt", package.FindEntry("uppercasefolder/bad_file_forfun.txt")?.GetFullPath());
+                Assert.AreEqual("UpperCaseFolder/UpperCaseFile.txt", package.FindEntry("UpperCaseFolder/UpperCaseFile.txt")?.GetFullPath());
+
+                Assert.AreEqual("test", package.FindEntry("test")?.GetFileName());
+                Assert.AreEqual("test", package.FindEntry("folder with space/test")?.GetFileName());
+                Assert.AreEqual("space_extension. txt", package.FindEntry("folder with space\\space_extension. txt")?.GetFileName());
+                Assert.AreEqual("bad_file_forfun.txt", package.FindEntry("uppercasefolder/bad_file_forfun.txt")?.GetFileName());
+            }
+        }
+
+        [Test]
         public void ExtractInlineVPK()
         {
             var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "VPK", "steamdb_test_single.vpk");


[Modify] Polish it

[Modify] Polish it

--- websocket-sharp/CloseStatusCode.cs
+++ websocket-sharp/CloseStatusCode.cs
@@ -35,11 +35,11 @@
   /// </summary>
   /// <remarks>
   ///   <para>
-  ///   The values of the status code are defined in
+  ///   The values of this enumeration are defined in
   ///   <see href="http://tools.ietf.org/html/rfc6455#section-7.4">Section 7.4</see> of RFC 6455.
   ///   </para>
   ///   <para>
-  ///   "Reserved value" must not be set as a status code in a close control frame by
+  ///   "Reserved value" must not be set as a status code in a connection close frame by
   ///   an endpoint. It's designated for use in applications expecting a status code to
   ///   indicate that the connection was closed due to the system grounds.
   ///   </para>
@@ -47,76 +47,68 @@
   public enum CloseStatusCode : ushort
   {
     /// <summary>
-    /// Equivalent to close status 1000.
-    /// Indicates a normal close.
+    /// Equivalent to close status 1000. Indicates a normal close.
     /// </summary>
     Normal = 1000,
     /// <summary>
-    /// Equivalent to close status 1001.
-    /// Indicates that an endpoint is going away.
+    /// Equivalent to close status 1001. Indicates that an endpoint is going away.
     /// </summary>
     Away = 1001,
     /// <summary>
-    /// Equivalent to close status 1002.
-    /// Indicates that an endpoint is terminating the connection due to a protocol error.
+    /// Equivalent to close status 1002. Indicates that an endpoint is terminating
+    /// the connection due to a protocol error.
     /// </summary>
     ProtocolError = 1002,
     /// <summary>
-    /// Equivalent to close status 1003.
-    /// Indicates that an endpoint is terminating the connection because it has received
-    /// a type of data that it cannot accept.
+    /// Equivalent to close status 1003. Indicates that an endpoint is terminating
+    /// the connection because it has received a type of data that it cannot accept.
     /// </summary>
     UnsupportedData = 1003,
     /// <summary>
-    /// Equivalent to close status 1004.
-    /// Still undefined. A Reserved value.
+    /// Equivalent to close status 1004. Still undefined. A Reserved value.
     /// </summary>
     Undefined = 1004,
     /// <summary>
-    /// Equivalent to close status 1005.
-    /// Indicates that no status code was actually present. A Reserved value.
+    /// Equivalent to close status 1005. Indicates that no status code was actually present.
+    /// A Reserved value.
     /// </summary>
     NoStatus = 1005,
     /// <summary>
-    /// Equivalent to close status 1006.
-    /// Indicates that the connection was closed abnormally. A Reserved value.
+    /// Equivalent to close status 1006. Indicates that the connection was closed abnormally.
+    /// A Reserved value.
     /// </summary>
     Abnormal = 1006,
     /// <summary>
-    /// Equivalent to close status 1007.
-    /// Indicates that an endpoint is terminating the connection because it has received
-    /// a message that contains data that isn't consistent with the type of the message.
+    /// Equivalent to close status 1007. Indicates that an endpoint is terminating
+    /// the connection because it has received a message that contains data that
+    /// isn't consistent with the type of the message.
     /// </summary>
     InvalidData = 1007,
     /// <summary>
-    /// Equivalent to close status 1008.
-    /// Indicates that an endpoint is terminating the connection because it has received
-    /// a message that violates its policy.
+    /// Equivalent to close status 1008. Indicates that an endpoint is terminating
+    /// the connection because it has received a message that violates its policy.
     /// </summary>
     PolicyViolation = 1008,
     /// <summary>
-    /// Equivalent to close status 1009.
-    /// Indicates that an endpoint is terminating the connection because it has received
-    /// a message that is too big to process.
+    /// Equivalent to close status 1009. Indicates that an endpoint is terminating
+    /// the connection because it has received a message that is too big to process.
     /// </summary>
     TooBig = 1009,
     /// <summary>
-    /// Equivalent to close status 1010.
-    /// Indicates that a client is terminating the connection because it has expected
-    /// the server to negotiate one or more extension, but the server didn't return
-    /// them in the handshake response.
+    /// Equivalent to close status 1010. Indicates that a client is terminating
+    /// the connection because it has expected the server to negotiate one or more extension,
+    /// but the server didn't return them in the handshake response.
     /// </summary>
     MandatoryExtension = 1010,
     /// <summary>
-    /// Equivalent to close status 1011.
-    /// Indicates that a server is terminating the connection because it has encountered
-    /// an unexpected condition that prevented it from fulfilling the request.
+    /// Equivalent to close status 1011. Indicates that a server is terminating
+    /// the connection because it has encountered an unexpected condition that
+    /// prevented it from fulfilling the request.
     /// </summary>
     ServerError = 1011,
     /// <summary>
-    /// Equivalent to close status 1015.
-    /// Indicates that the connection was closed due to a failure to perform a TLS handshake.
-    /// A Reserved value.
+    /// Equivalent to close status 1015. Indicates that the connection was closed
+    /// due to a failure to perform a TLS handshake. A Reserved value.
     /// </summary>
     TlsHandshakeFailure = 1015
   }


[Modify] Throw exception

[Modify] Throw exception

--- websocket-sharp/Net/HttpUtility.cs
+++ websocket-sharp/Net/HttpUtility.cs
@@ -1160,7 +1160,7 @@
     public static byte[] UrlDecodeToBytes (string s, Encoding encoding)
     {
       if (s == null)
-        return null;
+        throw new ArgumentNullException ("s");

       if (s.Length == 0)
         return new byte[0];


[Modify] Add it

[Modify] Add it

--- websocket-sharp/Net/HttpUtility.cs
+++ websocket-sharp/Net/HttpUtility.cs
@@ -529,6 +529,20 @@
       output.WriteByte ((byte) num);
     }

+    private static void urlDecodeUnicode (
+      byte[] bytes, int offset, Stream output
+    )
+    {
+      var num = getNumber (bytes, offset + 2, 4);
+      if (num == -1) {
+        output.Write (bytes, offset, 6);
+        return;
+      }
+
+      var decoded = Encoding.Unicode.GetBytes (new[] { (char) num });
+      output.Write (decoded, 0, decoded.Length);
+    }
+
     private static void urlEncode (byte b, Stream output)
     {
       if (b > 31 && b < 127) {


[Modify] Add it

[Modify] Add it

--- websocket-sharp/Net/HttpUtility.cs
+++ websocket-sharp/Net/HttpUtility.cs
@@ -751,6 +751,22 @@
       }
     }

+    internal static bool TryGetEncoding (
+      string contentType, out Encoding result
+    )
+    {
+      result = null;
+
+      try {
+        result = GetEncoding (contentType);
+      }
+      catch {
+        return false;
+      }
+
+      return true;
+    }
+
     #endregion

     #region Public Methods


Add new constructors.

Add new constructors.

- TinySato(string PrinterName, int paper_height, int paper_width) : this(PrinterName)
- TinySato(string PrinterName, bool send_if_not_yet_sent_at_dispose) : this(PrinterName)

--- TinySato/TinySato.cs
+++ TinySato/TinySato.cs
@@ -28,6 +28,8 @@
         }

         private bool disposed = false;
+        protected bool send_at_dispose_if_not_yet_sent = false;
+        protected bool is_sent = false;
         protected IntPtr printer = new IntPtr();
         protected List<byte[]> operations = new List<byte[]> { };
         const byte STX = 0x02, ESC = 0x1b, ETX = 0x03;
@@ -51,6 +53,16 @@
         [DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
         public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten);

+        public TinySato(string PrinterName, int paper_height, int paper_width) : this(PrinterName)
+        {
+            SetPaperSize(paper_height, paper_width);
+        }
+
+        public TinySato(string PrinterName, bool send_at_dispose_if_not_yet_sent) : this(PrinterName)
+        {
+            this.send_at_dispose_if_not_yet_sent = send_at_dispose_if_not_yet_sent;
+        }
+
         public TinySato(string PrinterName, string job_name = "")
         {
             try
@@ -159,6 +171,7 @@
                 throw new TinySatoException("failed to send operations.", inner);
             }
             finally { Marshal.FreeCoTaskMem(raw); }
+            is_sent = true;
         }

         public void Close()
@@ -186,6 +199,12 @@
         {
             if (disposed)
                 return;
+
+            if (!is_sent && send_at_dispose_if_not_yet_sent)
+            {
+                this.Send();
+            }
+
             if (disposing)
             {
                 this.operations.Clear();


ExpressionSample - refactor Expr (use IgnoreCase instead of custom code)

--- projects/ExpressionSample/GWExpr/Expr.cs
+++ projects/ExpressionSample/GWExpr/Expr.cs
@@ -40,7 +40,7 @@
         {
             try
             {
-                return Any.End().Parse(input);
+                return Any.Token().End().Parse(input);
             }
             catch (ParseException e)
             {
@@ -69,46 +69,21 @@

         private static class Kw
         {
-            public static readonly Parser<IEnumerable<char>> And = Word("AND");
-            public static readonly Parser<IEnumerable<char>> Exp = Word("EXP");
-            public static readonly Parser<IEnumerable<char>> Len = Word("LEN");
-            public static readonly Parser<IEnumerable<char>> Not = Word("NOT");
-            public static readonly Parser<IEnumerable<char>> Or = Word("OR");
-            public static readonly Parser<IEnumerable<char>> Sqr = Word("SQR");
-
-            public static readonly Parser<IEnumerable<char>> Left = Word("LEFT");
-            public static readonly Parser<IEnumerable<char>> Mid = Word("MID");
-            public static readonly Parser<IEnumerable<char>> Right = Word("RIGHT");
-
-            public static readonly Parser<IEnumerable<char>> Any =
+            public static readonly Parser<IEnumerable<char>> And = Parse.IgnoreCase("AND");
+            public static readonly Parser<IEnumerable<char>> Exp = Parse.IgnoreCase("EXP");
+            public static readonly Parser<IEnumerable<char>> Len = Parse.IgnoreCase("LEN");
+            public static readonly Parser<IEnumerable<char>> Not = Parse.IgnoreCase("NOT");
+            public static readonly Parser<IEnumerable<char>> Or = Parse.IgnoreCase("OR");
+            public static readonly Parser<IEnumerable<char>> Sqr = Parse.IgnoreCase("SQR");
+
+            public static readonly Parser<IEnumerable<char>> Left = Parse.IgnoreCase("LEFT");
+            public static readonly Parser<IEnumerable<char>> Mid = Parse.IgnoreCase("MID");
+            public static readonly Parser<IEnumerable<char>> Right = Parse.IgnoreCase("RIGHT");
+
+            public static readonly Parser<IEnumerable<char>> AnyNum =
                 And.Or(Exp).Or(Len).Or(Not).Or(Or).Or(Sqr);

             public static readonly Parser<IEnumerable<char>> AnyStr = Left.Or(Mid).Or(Right);
-
-            private static Parser<IEnumerable<char>> Word(string word)
-            {
-                Parser<IEnumerable<char>> parser = null;
-                foreach (char c in word)
-                {
-                    char a = char.ToUpper(c);
-                    char b = char.ToLower(a);
-                    Parser<IEnumerable<char>> next = Parse.Chars(a, b).Once();
-
-                    if (parser == null)
-                    {
-                        parser = next;
-                    }
-                    else
-                    {
-                        parser =
-                            from x in parser
-                            from y in next
-                            select x.Concat(y);
-                    }
-                }
-
-                return parser;
-            }
         }

         private static class Lit
@@ -128,11 +103,11 @@

         private static class Var
         {
-            public static readonly Parser<string> IdUpper =
-                from v in Parse.Identifier(Parse.Letter, Parse.LetterOrDigit)
+            public static readonly Parser<string> IdPrefix = Parse.Identifier(Parse.Letter, Parse.LetterOrDigit);
+
+            public static readonly Parser<string> Id =
+                from v in IdPrefix.Except(Kw.AnyNum)
                 select v.ToUpperInvariant();
-
-            public static readonly Parser<string> Id = IdUpper.Except(Kw.Any);

             public static readonly Parser<string> StrId =
                 from v in Id.Except(Kw.AnyStr)
@@ -297,7 +272,8 @@
                 Parse.ChainOperator(Op.Relational, Add, Op.Apply);

             private static readonly Parser<BasicExpression> Not =
-                from k in Kw.Not.Token()
+                from k in Kw.Not
+                from s in Ch.Space.AtLeastOnce()
                 from x in Add
                 select OperatorExpression.Unary("Not", x);


[Modify] Polish it

[Modify] Polish it


[Modify] Remove it

[Modify] Remove it

--- websocket-sharp/WebSocketFrame.cs
+++ websocket-sharp/WebSocketFrame.cs
@@ -219,12 +219,6 @@
       }
     }

-    public bool IsPerMessageCompressed {
-      get {
-        return (_opcode == Opcode.Binary || _opcode == Opcode.Text) && _rsv1 == Rsv.On;
-      }
-    }
-
     public bool IsPing {
       get {
         return _opcode == Opcode.Ping;


Remove one of the ccTypes.

Remove one of the ccTypes.

--- cocos2d/predefine/CCTypes.cs
+++ cocos2d/predefine/CCTypes.cs
@@ -1,643 +0,0 @@
-/****************************************************************************
-Copyright (c) 2010-2012 cocos2d-x.org
-Copyright (c) 2008-2010 Ricardo Quesada
-Copyright (c) 2011      Zynga Inc.
-Copyright (c) 2011-2012 openxlive.com
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-****************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework;
-
-namespace Cocos2D
-{
-    /// <summary>
-    /// RGB color composed of bytes 3 bytes
-    /// @since v0.8
-    /// </summary>
-    public struct CCColor3B
-    {
-        /*
-        public CCColor3B()
-        {
-            r = 0;
-            g = 0;
-            b = 0;
-        }
-        */
-        public CCColor3B(byte inr, byte ing, byte inb)
-        {
-            R = inr;
-            G = ing;
-            B = inb;
-        }
-
-        /// <summary>
-        /// Convert Color value of XNA Framework to CCColor3B type
-        /// </summary>
-        public CCColor3B(Microsoft.Xna.Framework.Color color)
-        {
-            R = color.R;
-            G = color.G;
-            B = color.B;
-        }
-
-        public byte R;
-        public byte G;
-        public byte B;
-    }
-
-    /// <summary>
-    /// RGBA color composed of 4 bytes
-    /// @since v0.8
-    /// </summary>
-    public struct CCColor4B
-    {
-        /*
-        public CCColor4B()
-        {
-            r = 0;
-            g = 0;
-            b = 0;
-            a = 0;
-        }
-        */
-
-        public CCColor4B(byte inr, byte ing, byte inb, byte ina)
-        {
-            R = inr;
-            G = ing;
-            B = inb;
-            A = ina;
-        }
-
-        public CCColor4B(float inr, float ing, float inb, float ina)
-        {
-            R = (byte)inr;
-            G = (byte)ing;
-            B = (byte)inb;
-            A = (byte)ina;
-        }
-
-        /// <summary>
-        /// Convert Color value of XNA Framework to CCColor4B type
-        /// </summary>
-        public CCColor4B(Microsoft.Xna.Framework.Color color)
-        {
-            R = color.R;
-            G = color.G;
-            B = color.B;
-            A = color.A;
-        }
-
-        public byte R;
-        public byte G;
-        public byte B;
-        public byte A;
-
-        public override string ToString()
-        {
-            return (string.Format("{0},{1},{2},{3}", R, G, B, A));
-        }
-
-        public static CCColor4B Parse(string s)
-        {
-            string[] f = s.Split(',');
-            return (new CCColor4B(byte.Parse(f[0]), byte.Parse(f[1]), byte.Parse(f[2]), byte.Parse(f[3])));
-        }
-    }
-
-    /// <summary>
-    /// RGBA color composed of 4 floats
-    /// @since v0.8
-    /// </summary>
-    public struct CCColor4F
-    {
-        public CCColor4F(float inr, float ing, float inb, float ina)
-        {
-            R = inr;
-            G = ing;
-            B = inb;
-            A = ina;
-        }
-
-        public float R;
-        public float G;
-        public float B;
-        public float A;
-
-        public override string ToString()
-        {
-            return (string.Format("{0},{1},{2},{3}", R, G, B, A));
-        }
-
-        public static CCColor4F Parse(string s)
-        {
-            string[] f = s.Split(',');
-            return (new CCColor4F(float.Parse(f[0]), float.Parse(f[1]), float.Parse(f[2]), float.Parse(f[3])));
-        }
-    }
-
-    /// <summary>
-    /// A vertex composed of 2 floats: x, y
-    /// @since v0.8
-    /// </summary>
-    public struct CCVertex2F
-    {
-        /*
-        public ccVertex2F()
-        {
-            x = 0.0f;
-            y = 0.0f;
-        }
-        */
-
-        public CCVertex2F(float inx, float iny)
-        {
-            X = inx;
-            Y = iny;
-        }
-
-        public float X;
-        public float Y;
-    }
-
-    /// <summary>
-    /// A vertex composed of 2 floats: x, y
-    /// @since v0.8
-    /// </summary>
-    public struct CCVertex3F
-    {
-        public static readonly CCVertex3F Zero = new CCVertex3F();
-
-        public CCVertex3F(float inx, float iny, float inz)
-        {
-            X = inx;
-            Y = iny;
-            Z = inz;
-        }
-
-        public float X;
-        public float Y;
-        public float Z;
-
-        public override string ToString()
-        {
-            return String.Format("ccVertex3F x:{0}, y:{1}, z:{2}", X, Y, Z);
-        }
-    }
-
-    /// <summary>
-    /// A texcoord composed of 2 floats: u, y
-    /// @since v0.8
-    /// </summary>
-    public struct CCTex2F
-    {
-        /*
-        public ccTex2F()
-        {
-            u = 0.0f;
-            v = 0.0f;
-        }
-        */
-        public CCTex2F(float inu, float inv)
-        {
-            U = inu;
-            V = inv;
-        }
-
-        public float U;
-        public float V;
-
-        public override string ToString()
-        {
-            return String.Format("ccTex2F u:{0}, v:{1}", U, V);
-        }
-    }
-
-    /// <summary>
-    /// Point Sprite component
-    /// </summary>
-    public class CCPointSprite
-    {
-        public CCPointSprite()
-        {
-            Position = new CCVertex2F();
-            Color = new CCColor4B();
-            Size = 0.0f;
-        }
-
-        public CCVertex2F Position;		// 8 bytes
-        public CCColor4B Color;		// 4 bytes
-        public float Size;		// 4 bytes
-    }
-
-    /// <summary>
-    /// A 2D Quad. 4 * 2 floats
-    /// </summary>
-    public class CCQuad2
-    {
-        public CCQuad2()
-        {
-            TopLeft = new CCVertex2F();
-            TopRight = new CCVertex2F();
-            BottomLeft = new CCVertex2F();
-            BottomRight = new CCVertex2F();
-        }
-
-        public CCVertex2F TopLeft;
-        public CCVertex2F TopRight;
-        public CCVertex2F BottomLeft;
-        public CCVertex2F BottomRight;
-    }
-
-    /// <summary>
-    /// A 3D Quad. 4 * 3 floats
-    /// </summary>
-    public struct CCQuad3
-    {
-        /*
-        public ccQuad3()
-        {
-            tl = new ccVertex3F();
-            tr = new ccVertex3F();
-            bl = new ccVertex3F();
-            br = new ccVertex3F();
-        }
-        */
-        public CCVertex3F BottomLeft;
-        public CCVertex3F BottomRight;
-        public CCVertex3F TopLeft;
-        public CCVertex3F TopRight;
-    }
-
-    /// <summary>
-    /// A 2D grid size
-    /// </summary>
-    public struct CCGridSize
-    {
-        public CCGridSize(int inx, int iny)
-        {
-            X = inx;
-            Y = iny;
-        }
-
-        public int X;
-        public int Y;
-    }
-
-    /// <summary>
-    /// a Point with a vertex point, a tex coord point and a color 4B
-    /// </summary>
-    public class CCV2F_C4B_T2F
-    {
-        public CCV2F_C4B_T2F()
-        {
-            Vertices = new CCVertex2F();
-            Colors = new CCColor4B();
-            TexCoords = new CCTex2F();
-        }
-
-        /// <summary>
-        /// vertices (2F)
-        /// </summary>
-        public CCVertex2F Vertices;
-
-        /// <summary>
-        /// colors (4B)
-        /// </summary>
-        public CCColor4B Colors;
-
-        /// <summary>
-        /// tex coords (2F)
-        /// </summary>
-        public CCTex2F TexCoords;
-    }
-
-    /// <summary>
-    /// a Point with a vertex point, a tex coord point and a color 4F
-    /// </summary>
-    public class CCV2F_C4F_T2F
-    {
-        public CCV2F_C4F_T2F()
-        {
-            Vertices = new CCVertex2F();
-            Colors = new CCColor4F();
-            TexCoords = new CCTex2F();
-        }
-
-        /// <summary>
-        /// vertices (2F)
-        /// </summary>
-        public CCVertex2F Vertices;
-
-        /// <summary>
-        /// colors (4F)
-        /// </summary>
-        public CCColor4F Colors;
-
-        /// <summary>
-        /// tex coords (2F)
-        /// </summary>
-        public CCTex2F TexCoords;
-    }
-
-    /// <summary>
-    /// a Point with a vertex point, a tex coord point and a color 4B
-    /// </summary>
-    //TODO: Use VertexPositionColorTexture
-    public struct CCV3F_C4B_T2F : IVertexType
-    {
-        /// <summary>
-        /// vertices (3F)
-        /// </summary>
-        public CCVertex3F Vertices;			// 12 bytes
-
-        /// <summary>
-        /// colors (4B)
-        /// </summary>
-        public CCColor4B Colors;				// 4 bytes
-
-        /// <summary>
-        /// tex coords (2F)
-        /// </summary>
-        public CCTex2F TexCoords;			// 8 byts
-
-        public static readonly VertexDeclaration VertexDeclaration;
-
-        static CCV3F_C4B_T2F()
-        {
-            var elements = new VertexElement[]
-                {
-                    new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
-                    new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0),
-                    new VertexElement(0x10, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
-                };
-            VertexDeclaration = new VertexDeclaration(elements);
-        }
-
-        VertexDeclaration IVertexType.VertexDeclaration
-        {
-            get { return VertexDeclaration; }
-        }
-    }
-
-    /// <summary>
-    /// 4 ccVertex2FTex2FColor4B Quad
-    /// </summary>
-    public class CCV2F_C4B_T2F_Quad
-    {
-        public CCV2F_C4B_T2F_Quad()
-        {
-            BottomLeft = new CCV2F_C4B_T2F();
-            BottomRight = new CCV2F_C4B_T2F();
-            TopLeft = new CCV2F_C4B_T2F();
-            TopRight = new CCV2F_C4B_T2F();
-        }
-
-        /// <summary>
-        /// bottom left
-        /// </summary>
-        public CCV2F_C4B_T2F BottomLeft;
-
-        /// <summary>
-        /// bottom right
-        /// </summary>
-        public CCV2F_C4B_T2F BottomRight;
-
-        /// <summary>
-        /// top left
-        /// </summary>
-        public CCV2F_C4B_T2F TopLeft;
-
-        /// <summary>
-        /// top right
-        /// </summary>
-        public CCV2F_C4B_T2F TopRight;
-    }
-
-    /// <summary>
-    /// 4 ccVertex3FTex2FColor4B
-    /// </summary>
-    public struct CCV3F_C4B_T2F_Quad : IVertexType
-    {
-        /// <summary>
-        /// top left
-        /// </summary>
-        public CCV3F_C4B_T2F TopLeft;
-
-        /// <summary>
-        /// bottom left
-        /// </summary>
-        public CCV3F_C4B_T2F BottomLeft;
-
-        /// <summary>
-        /// top right
-        /// </summary>
-        public CCV3F_C4B_T2F TopRight;
-
-        /// <summary>
-        /// bottom right
-        /// </summary>
-        public CCV3F_C4B_T2F BottomRight;
-
-        public static readonly VertexDeclaration VertexDeclaration;
-
-        static CCV3F_C4B_T2F_Quad()
-        {
-            var elements = new VertexElement[]
-                {
-                    new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
-                    new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0),
-                    new VertexElement(0x10, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
-                };
-            VertexDeclaration = new VertexDeclaration(elements);
-        }
-
-        VertexDeclaration IVertexType.VertexDeclaration
-        {
-            get { return VertexDeclaration; }
-        }
-    }
-
-    /// <summary>
-    /// 4 ccVertex2FTex2FColor4F Quad
-    /// </summary>
-    public class CCV2F_C4F_T2F_Quad
-    {
-        public CCV2F_C4F_T2F_Quad()
-        {
-            TopLeft = new CCV2F_C4F_T2F();
-            BottomLeft = new CCV2F_C4F_T2F();
-            TopRight = new CCV2F_C4F_T2F();
-            BottomRight = new CCV2F_C4F_T2F();
-        }
-
-        /// <summary>
-        /// bottom left
-        /// </summary>
-        public CCV2F_C4F_T2F BottomLeft;
-
-        /// <summary>
-        /// bottom right
-        /// </summary>
-        public CCV2F_C4F_T2F BottomRight;
-
-        /// <summary>
-        /// top left
-        /// </summary>
-        public CCV2F_C4F_T2F TopLeft;
-
-        /// <summary>
-        /// top right
-        /// </summary>
-        public CCV2F_C4F_T2F TopRight;
-    }
-
-    /// <summary>
-    /// Blend Function used for textures
-    /// </summary>
-    public struct CCBlendFunc
-    {
-        public CCBlendFunc(int src, int dst)
-        {
-            this.Source = src;
-            this.Destination = dst;
-        }
-
-        /// <summary>
-        /// source blend function
-        /// </summary>
-        public int Source;
-
-        /// <summary>
-        /// destination blend function
-        /// </summary>
-        public int Destination;
-    }
-
-    public enum CCTextAlignment
-    {
-        CCTextAlignmentLeft,
-        CCTextAlignmentCenter,
-        CCTextAlignmentRight,
-    }
-
-    public enum CCVerticalTextAlignment
-    {
-        CCVerticalTextAlignmentTop,
-        CCVerticalTextAlignmentCenter,
-        CCVerticalTextAlignmentBottom
-    }
-
-    public class CCTypes
-    {
-        //ccColor3B predefined colors
-        //! White color (255,255,255)
-        public static readonly CCColor3B CCWhite = new CCColor3B(255, 255, 255);
-        //! Yellow color (255,255,0)
-        public static readonly CCColor3B CCYellow = new CCColor3B(255, 255, 0);
-        //! Blue color (0,0,255)
-        public static readonly CCColor3B CCBlue = new CCColor3B(0, 0, 255);
-        //! Green Color (0,255,0)
-        public static readonly CCColor3B CCGreen = new CCColor3B(0, 255, 0);
-        //! Red Color (255,0,0,)
-        public static readonly CCColor3B CCRed = new CCColor3B(255, 0, 0);
-        //! Magenta Color (255,0,255)
-        public static readonly CCColor3B CCMagenta = new CCColor3B(255, 0, 255);
-        //! Black Color (0,0,0)
-        public static readonly CCColor3B CCBlack = new CCColor3B(0, 0, 0);
-        //! Orange Color (255,127,0)
-        public static readonly CCColor3B CCOrange = new CCColor3B(255, 127, 0);
-        //! Gray Color (166,166,166)
-        public static readonly CCColor3B CCGray = new CCColor3B(166, 166, 166);
-
-        //! helper macro that creates an ccColor3B type
-        static public CCColor3B CreateColor(byte r, byte g, byte b)
-        {
-            CCColor3B c = new CCColor3B(r, g, b);
-            return c;
-        }
-
-        //! helper macro that creates an ccColor4B type
-        public static CCColor4B CreateColor(byte r, byte g, byte b, byte o)
-        {
-            CCColor4B c = new CCColor4B(r, g, b, o);
-            return c;
-        }
-
-        /** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
-         @since v0.99.1
-         */
-        public static CCColor4F CreateColor(CCColor3B c)
-        {
-            CCColor4F c4 = new CCColor4F(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, 1.0f);
-            return c4;
-        }
-
-        /** Returns a ccColor4F from a ccColor4B.
-         @since v0.99.1
-         */
-        public static CCColor4F CreateColor(CCColor4B c)
-        {
-            CCColor4F c4 = new CCColor4F(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, c.A / 255.0f);
-            return c4;
-        }
-
-        /** returns YES if both ccColor4F are equal. Otherwise it returns NO.
-         @since v0.99.1
-         */
-        public static bool ColorsAreEqual(CCColor4F a, CCColor4F b)
-        {
-            return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A;
-        }
-
-        public static CCVertex2F Vertex2(float x, float y)
-        {
-            CCVertex2F c = new CCVertex2F(x, y);
-            return c;
-        }
-
-        public static CCVertex3F Vertex3(float x, float y, float z)
-        {
-            CCVertex3F c = new CCVertex3F(x, y, z);
-            return c;
-        }
-
-        public static CCTex2F Tex2(float u, float v)
-        {
-            CCTex2F t = new CCTex2F(u, v);
-            return t;
-        }
-
-        //! helper function to create a ccGridSize
-        public static CCGridSize GridSize(int x, int y)
-        {
-            CCGridSize v = new CCGridSize(x, y);
-            return v;
-        }
-    }
-
-}//namespace   cocos2d
-


Added new keywords for overridden members.

--- Uiml/Peers/DParam.cs
+++ Uiml/Peers/DParam.cs
@@ -50,9 +50,9 @@
 			Process(n);
 		}

-		public void Process(XmlNode n)
+		public new void Process(XmlNode n)
 		{
-			base.Process(n);
+			base.Process(n, IAM);
 		}

 		public bool HasChildren
@@ -72,11 +72,11 @@
 			return m_children.GetEnumerator();
 		}

-		public ArrayList Children
+		public new ArrayList Children
 		{
 			get { return m_children; }
 		}

-		public const string IAM				= "d-param";
+		public new const string IAM				= "d-param";
 	}
 }


Escape backslashes in JS strings

Escape backslashes in JS strings

--- Utility/JSInterop.cs
+++ Utility/JSInterop.cs
@@ -10,7 +10,7 @@
     {
         public static string StringParameter(string param)
         {
-            return string.Format("\"{0}\"", param.Replace("\"", "\\\"").Replace(Environment.NewLine, "\\n"));
+            return string.Format("\"{0}\"", param.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace(Environment.NewLine, "\\n"));
         }
     }


Revert "Added "final door count" comment at return value."

This reverts commit 51f7b5f62af24188a05afa5a78284b9b0197c39d.

--- 100_Doors_Problem/C#/Davipb/HundredDoors.cs
+++ 100_Doors_Problem/C#/Davipb/HundredDoors.cs
@@ -18,7 +18,7 @@
 				for (int i = pass; i < doors.Length; i += pass)
 					doors[i] = !doors[i];

-			return doors; //final door count
+			return doors;
 		}
 	}
 }


refactor and update docs

refactor and update docs

--- .Net/NotifyIcon.cs
+++ .Net/NotifyIcon.cs
@@ -39,6 +39,14 @@
             set { this.notifyIcon.Text = value; }
         }

+        /// <summary>  Disposes of the icon resources when it is no longer needed. </summary>
+        /// <remarks> If this method is not called, the icon may persist in the system tray until the mouse hovers over it, even after the object instance has lost scope. </remarks>
+        public void Dispose()
+        {
+            this.notifyIcon.Icon.Dispose();
+            this.notifyIcon.Dispose();
+        }
+
         /// <summary> Gets or sets the icon's visibility. A boolean. </summary>
         /// <remarks> Required. Set this property to True after initializing other settings. </remarks>
         public bool Visible
@@ -110,7 +118,7 @@

         /// <summary> Gets an object useful in VBScript for selecting a ToolTipIcon type. The properties Error, Info, None, and Warning may be used with SetBalloonTipIcon. </summary>
         /// <returns> a ToolTipIconT </returns>
-        /// <remarks> VBScript example: <pre>    obj.SetBallonTipIcon obj.ToolTipIcon.Warning </pre></remarks>
+        /// <remarks> VBScript example: <pre> obj.SetBallonTipIcon obj.ToolTipIcon.Warning </pre></remarks>
         public ToolTipIconT ToolTipIcon
         {
             get { return new ToolTipIconT(); }
@@ -138,14 +146,6 @@
             {
                 this.notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Warning;
             }
-        }
-
-        /// <summary>  Disposes of the icon resources when it is no longer needed. </summary>
-        /// <remarks> If this method is not called, the icon may persist in the system tray until the mouse hovers over it, even after the object instance has lost scope. </remarks>
-        public void Dispose()
-        {
-            this.notifyIcon.Icon.Dispose();
-            this.notifyIcon.Dispose();
         }

         /// <summary> Show the balloon tip. </summary>
@@ -186,27 +186,6 @@
                 }
             }
         }
-
-        /// <summary> Disable a menu item </summary>
-        public void DisableMenuItem(int index)
-        {
-            this.contextMenu.MenuItems[index].Enabled = false;
-        }
-
-        /// <summary> Enable a menu item </summary>
-        public void EnableMenuItem(int index)
-        {
-            this.contextMenu.MenuItems[index].Enabled = true;
-        }
-
-        // show the context menu on left mouse click too
-        private void notifyIcon_MouseUp(object Sender, System.Windows.Forms.MouseEventArgs e)
-        {
-            if (e.Button == MouseButtons.Left)
-            {
-                this.ShowContextMenu();
-            }
-        }

         /// <summary> Show the context menu. </summary>
         /// <remarks> Public in order to provide testability from VBScript. </remarks>
@@ -214,6 +193,15 @@
         {
             MethodInfo mi = typeof(System.Windows.Forms.NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
             mi.Invoke(notifyIcon, null);
+        }
+
+        // show the context menu on left mouse click too
+        private void notifyIcon_MouseUp(object Sender, System.Windows.Forms.MouseEventArgs e)
+        {
+            if (e.Button == MouseButtons.Left)
+            {
+                this.ShowContextMenu();
+            }
         }

         private void notifyIcon_BalloonTipClicked(object Sender, EventArgs e)
@@ -232,6 +220,18 @@
         {
             this.balloonTipCallback = callbackRef;
         }
+
+        /// <summary> Disable a menu item </summary>
+        public void DisableMenuItem(int index)
+        {
+            this.contextMenu.MenuItems[index].Enabled = false;
+        }
+
+        /// <summary> Enable a menu item </summary>
+        public void EnableMenuItem(int index)
+        {
+            this.contextMenu.MenuItems[index].Enabled = true;
+        }
     }

     /// <summary> The COM interface for VBScripting.NotifyIcon </summary>
@@ -282,7 +282,7 @@
         /// <summary> </summary>
         [DispId(12)]
         void ShowBalloonTip();
-
+
         /// <summary> </summary>
         [DispId(13)]
         void AddMenuItem(string menuText, object callbackRef);
@@ -309,7 +309,7 @@
     }

     /// <summary> Supplies the type required by NotifyIcon.ToolTipIcon </summary>
-    /// <remarks> This class is not directly accessible from VBScript , however, it is accessible via the <tt>NotifyIcon.ToolTipIcon</tt> property. </remarks>
+    /// <remarks><strong> This class is not directly accessible from VBScript, however, it is accessible via the <tt>NotifyIcon.ToolTipIcon</tt> property. </strong></remarks>
     [Guid("2650C2AB-5DF8-495F-AB4D-6C61BD463EA4")]
     public class ToolTipIconT
     {
@@ -363,13 +363,13 @@
         }
     }
     /// <summary> An orderly way to save the index and callback reference for a single menu item. </summary>
-    /// <remarks> This class is not accessible to VBScript. </remarks>
+    /// <remarks><strong> This class is not accessible to VBScript. </strong> Callback references are instantiated using the AddMenuItem and SetBalloonTipCallback methods. </remarks>
     [Guid("2650C2AB-5FF8-495F-AB4D-6C61BD463EA4")]
     public class CallbackReference
     {
         /// <summary> This Index corresponds to the Index of a menuItem in the context menu. </summary>
         public int Index { get; set; }
-        /// <summary> COM object generated by VBScript's GetRef Function. </summary>
+        /// <summary> COM object reference generated by VBScript's GetRef Function. </summary>
         public object Reference { get; set; }

         /// <summary> Constructor </summary>


Missing NullAllowed attrs.

Missing NullAllowed attrs.

--- AlexTouch.PSPDFKit/ApiDefinition.cs
+++ AlexTouch.PSPDFKit/ApiDefinition.cs
@@ -4335,7 +4335,7 @@
 	interface PSPDFFreeTextAnnotation
 	{
 		[Export ("fontName", ArgumentSemantic.Copy)]
-		string FontName { get; set; }
+		string FontName { get; [NullAllowed]set; }

 		[Export ("fontSize", ArgumentSemantic.Assign)]
 		float FontSize { get; set; }


Updated ToJson method

Updated ToJson method

--- Amido.NAuto/Builders/AutoBuilder.cs
+++ Amido.NAuto/Builders/AutoBuilder.cs
@@ -455,6 +455,7 @@
         /// </returns>
         public string ToJson(bool useCamelCase = true, bool ignoreNulls = true, bool indentJson = true)
         {
+            this.Build();
             return JsonSerializer.ToIndentedJsonString(entity, useCamelCase, ignoreNulls, indentJson);
         }


Improved label width in the GUI

Improved label width in the GUI

--- Assets/NuGet/Editor/NuspecEditor.cs
+++ Assets/NuGet/Editor/NuspecEditor.cs
@@ -63,6 +63,7 @@

             if (isNuspec)
             {
+                EditorGUIUtility.labelWidth = 100;
                 nuspec.Id = EditorGUILayout.TextField(new GUIContent("ID", "The name of the package."), nuspec.Id);
                 nuspec.Version = EditorGUILayout.TextField(new GUIContent("Version", "The semantic version of the package."), nuspec.Version);
                 nuspec.Authors = EditorGUILayout.TextField(new GUIContent("Authors", "The authors of the package."), nuspec.Authors);
@@ -115,6 +116,8 @@
                     {
                         EditorGUILayout.BeginHorizontal();
                         GUILayout.Space(75);
+                        float prevLabelWidth = EditorGUIUtility.labelWidth;
+                        EditorGUIUtility.labelWidth = 50;
                         dependency.Id = EditorGUILayout.TextField(new GUIContent("ID", "The ID of the dependency package."), dependency.Id);
                         EditorGUILayout.EndHorizontal();

@@ -142,6 +145,8 @@
                         EditorGUILayout.EndHorizontal();

                         EditorGUILayout.Separator();
+
+                        EditorGUIUtility.labelWidth = prevLabelWidth;
                     }

                     if (toDelete != null)


replace BtreeInsaneException with InvalidOperationException

--- BtreeDictionary/BtreeDiagnostics.cs
+++ BtreeDictionary/BtreeDiagnostics.cs
@@ -1,7 +1,7 @@
 //
 // Library: KaosCollections
 // File:    BtreeDiagnostics.cs
-// Purpose: Define BtreeDictionary API for Debug builds only.
+// Purpose: Define BtreeDictionary API for Debug build only.
 //
 // Copyright © 2009-2017 Kasey Osborn (github.com/kaosborn)
 // MIT License - Use and redistribute freely
@@ -14,16 +14,9 @@
 namespace Kaos.Collections
 {
 #if DEBUG
-    public class BtreeInsaneException : Exception
-    {
-        public BtreeInsaneException () { }
-        public BtreeInsaneException (string message) : base (message) { }
-        public BtreeInsaneException (string message, Exception inner) : base (message, inner) { }
-    }
-
-
     public partial class BtreeDictionary<TKey, TValue>
     {
+        // Telemetry counters:
         public int BranchSlotCount { get; private set; }
         public int BranchSlotsUsed { get; private set; }
         public int LeafSlotCount { get; private set; }
@@ -38,17 +31,18 @@
         /// </exclude>
         public void SanityCheck()
         {
-            int height = GetHeight();
             BranchSlotCount = 0;
             BranchSlotsUsed = 0;
             LeafSlotCount = 0;
             LeafSlotsUsed = 0;
-            Leaf lastLeaf = Check (root, 1, height, true, default (TKey), null);
+
+            Leaf lastLeaf = Check (root, 1, GetHeight(), true, default (TKey), null);
+
             if (lastLeaf.RightLeaf != null)
-                throw new BtreeInsaneException ("Last leaf has invalid RightLeaf");
+                throw new InvalidOperationException ("Last leaf has invalid RightLeaf");

             if (Count != LeafSlotsUsed)
-                throw new BtreeInsaneException ("Mismatched Count=" + Count + ", expected=" + LeafSlotsUsed);
+                throw new InvalidOperationException ("Mismatched Count=" + Count + ", expected=" + LeafSlotsUsed);
         }

@@ -84,10 +78,10 @@
             BranchSlotsUsed += branch.KeyCount;

             if (! isRightmost && (branch.KeyCount + 1) < maxKeyCount / 2)
-                throw new BtreeInsaneException ("Branch underfilled");
+                throw new InvalidOperationException ("Branch underfilled");

             if (branch.ChildCount != branch.KeyCount + 1)
-                throw new BtreeInsaneException ("Branch ChildCount wrong");
+                throw new InvalidOperationException ("Branch ChildCount wrong");

             for (int i = 0; i < branch.ChildCount; ++i)
             {
@@ -95,7 +89,7 @@
                 bool isRightmost0 = isRightmost && i < branch.ChildCount;
                 if (i < branch.KeyCount - 1)
                     if (branch.GetKey (i).CompareTo (branch.GetKey (i + 1)) >= 0)
-                        throw new BtreeInsaneException ("Branch keys not ascending");
+                        throw new InvalidOperationException ("Branch keys not ascending");

                 if (level + 1 < height)
                 {
@@ -118,23 +112,23 @@
             LeafSlotsUsed += leaf.KeyCount;

             if (! isRightmost && leaf.KeyCount < maxKeyCount / 2)
-                throw new BtreeInsaneException ("Leaf underfilled");
+                throw new InvalidOperationException ("Leaf underfilled");

             if (! anchor.Equals (default (TKey)) && !anchor.Equals (leaf.GetKey (0)))
-                throw new BtreeInsaneException ("Leaf has wrong anchor");
+                throw new InvalidOperationException ("Leaf has wrong anchor");

             for (int i = 0; i < leaf.KeyCount; ++i)
                 if (i < leaf.KeyCount - 1 && leaf.GetKey (i).CompareTo (leaf.GetKey (i + 1)) >= 0)
-                    throw new BtreeInsaneException ("Leaf keys not ascending");
+                    throw new InvalidOperationException ("Leaf keys not ascending");

             if (visited == null)
             {
                 if (! anchor.Equals (default (TKey)))
-                    throw new BtreeInsaneException ("Inconsistent visited, anchor");
+                    throw new InvalidOperationException ("Inconsistent visited, anchor");
             }
             else
                 if (visited.RightLeaf != leaf)
-                    throw new BtreeInsaneException ("Leaf has bad RightLeaf");
+                    throw new InvalidOperationException ("Leaf has bad RightLeaf");

             return leaf;
         }


Spaaaace

Spaaaace

Fixed spacing, also readded the autopop helper

--- CAPPamari.Web/Models/CourseModel.cs
+++ CAPPamari.Web/Models/CourseModel.cs
@@ -36,8 +36,8 @@
             this.Grade = 0.0;
             this.Credits = 0;
             this.Semester = "N00";
-	this.PNC = false;
-this.Communication = false;
+	        this.PNC = false;
+            this.Communication = false;
         }
     }
 }


workaround crash in MegaAesCtrStreamCrypter

--- CompatBot/Utils/BufferCopyStream.cs
+++ CompatBot/Utils/BufferCopyStream.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Buffers;
 using System.IO;

 namespace CompatBot.Utils
@@ -10,8 +11,11 @@
         private bool usedForWrites;
         private long position;
         private readonly int bufSize;
-        private readonly byte[] buf;
+        private readonly byte[] writeBuf;
+        private readonly byte[] readBuf;
         private int bufStart, bufLength;
+        private readonly object sync = new object();
+        private bool disposed;

         public BufferCopyStream(Stream baseStream, int bufferSize = 4096)
         {
@@ -23,7 +27,8 @@

             this.baseStream = baseStream;
             bufSize = bufferSize;
-            buf = new byte[bufSize];
+            writeBuf = ArrayPool<byte>.Shared.Rent(bufSize);
+            readBuf = ArrayPool<byte>.Shared.Rent(16);
         }

         public override void Flush()
@@ -37,9 +42,18 @@
             if (usedForWrites)
                 throw new InvalidOperationException("Stream was used for writes before");

+            var useTempBuf = count < 16;
+            const int mask = ~0b1111;
             try
             {
-                var result = baseStream.Read(buffer, offset, count);
+                int result;
+                if (useTempBuf)
+                {
+                    result = baseStream.Read(readBuf, 0, count);
+                    Buffer.BlockCopy(readBuf, 0, buffer, offset, result);
+                }
+                else
+                    result = baseStream.Read(buffer, offset, count & mask); // make count divisible by 16 to workaround mega client issues
                 position += result;
                 CopyToBuf(buffer, offset, result);
                 return result;
@@ -74,12 +88,32 @@

         protected override void Dispose(bool disposing)
         {
+            if (!disposed)
+                lock (sync)
+                {
+                    if (!disposed)
+                    {
+                        ArrayPool<byte>.Shared.Return(writeBuf);
+                        ArrayPool<byte>.Shared.Return(readBuf);
+                        disposed = true;
+                    }
+                }
             baseStream?.Dispose();
             base.Dispose(disposing);
         }

         void IDisposable.Dispose()
         {
+            if (!disposed)
+                lock (sync)
+                {
+                    if (!disposed)
+                    {
+                        ArrayPool<byte>.Shared.Return(writeBuf);
+                        ArrayPool<byte>.Shared.Return(readBuf);
+                        disposed = true;
+                    }
+                }
             baseStream?.Dispose();
             base.Dispose();
         }
@@ -90,18 +124,18 @@
             {
                 bufStart = 0;
                 bufLength = bufSize;
-                Buffer.BlockCopy(buffer, offset + count - bufSize, buf, bufStart, bufLength);
+                Buffer.BlockCopy(buffer, offset + count - bufSize, writeBuf, bufStart, bufLength);
             }
             else
             {
                 // copy as much data as we can to the end of the buffer
                 bufStart = (bufStart + bufLength) % bufSize;
                 bufLength = Math.Min(bufSize - bufStart, count);
-                Buffer.BlockCopy(buffer, offset, buf, bufStart, bufLength);
+                Buffer.BlockCopy(buffer, offset, writeBuf, bufStart, bufLength);
                 // if there's still more data, loop it around to the beginning
                 if (bufLength < count)
                 {
-                    Buffer.BlockCopy(buffer, offset + bufLength, buf, 0, count-bufLength);
+                    Buffer.BlockCopy(buffer, offset + bufLength, writeBuf, 0, count-bufLength);
                     bufLength = count;
                 }
             }
@@ -111,9 +145,9 @@
         {
             var result = new byte[bufLength];
             var partLength = Math.Min(bufSize - bufStart, bufLength);
-            Buffer.BlockCopy(buf, bufStart, result, 0, partLength);
+            Buffer.BlockCopy(writeBuf, bufStart, result, 0, partLength);
             if (partLength < bufLength)
-                Buffer.BlockCopy(buf, 0, result, partLength, bufLength - partLength);
+                Buffer.BlockCopy(writeBuf, 0, result, partLength, bufLength - partLength);
             return result;
         }


Version 1.1.2

Version 1.1.2

--- DRLPTest/Properties/AssemblyInfo.cs
+++ DRLPTest/Properties/AssemblyInfo.cs
@@ -49,5 +49,5 @@
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.1.1.0")]
-[assembly: AssemblyFileVersion("1.1.1.0")]
+[assembly: AssemblyVersion("1.1.2.0")]
+[assembly: AssemblyFileVersion("1.1.2.0")]


removed unused dependencies from CommandProcessor

--- Dewey.Messaging/CommandProcessor.cs
+++ Dewey.Messaging/CommandProcessor.cs
@@ -1,5 +1,4 @@
-using SimpleInjector;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Reflection;

@@ -7,15 +6,10 @@
 {
     public class CommandProcessor : ICommandProcessor
     {
-        readonly Container _container;
-        readonly IEventAggregator _eventAggregator;
         readonly Dictionary<Type, object> _commandHandlerFactories;

-        public CommandProcessor(Container container, IEventAggregator eventAggregator)
+        public CommandProcessor()
         {
-            _container = container;
-            _eventAggregator = eventAggregator;
-
             _commandHandlerFactories = new Dictionary<Type, object>();
         }


Small corrections

Small corrections

--- AngleSharp.Core.Tests/Library/FormSubmit.cs
+++ AngleSharp.Core.Tests/Library/FormSubmit.cs
@@ -930,7 +930,7 @@
             var result = await form.Submit();
             Assert.IsNotNull(request);
             Assert.AreEqual(HttpMethod.Post, request.Method);
-            Assert.AreEqual("{\"name\":\"Bender\",\"hind\":\"Bitable\",\"shiny\":\"true\"}", Utf8StreamToString(request.Content));
+            Assert.AreEqual("{\"name\":\"Bender\",\"hind\":\"Bitable\",\"shiny\":true}", Utf8StreamToString(request.Content));
         }

         [Test]
@@ -984,8 +984,7 @@
             var document = await LoadWithMockAsync(@"<form enctype='application/json' method='post'>
   <input name='hearbeat[0]' value='thunk'>
   <input name='hearbeat[2]' value='thunk'>
-</form>
-", url, onRequest);
+</form>", url, onRequest);

             var form = document.Forms[0] as HtmlFormElement;
             var result = await form.Submit();


Added Sampler2DArray uniform type to the shader system.

--- Duality/Resources/AbstractShader.cs
+++ Duality/Resources/AbstractShader.cs
@@ -58,7 +58,12 @@
 		/// <summary>
 		/// Represents a texture binding and provides lookups.
 		/// </summary>
-		Sampler2D
+		Sampler2D,
+
+		/// <summary>
+		/// Represents a 2d texture array binding
+		/// </summary>
+		Sampler2DArray
 	}

 	/// <summary>
@@ -373,15 +378,16 @@
 				string[] curLineSplit = curLine.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
 				switch (curLineSplit[1].ToUpper())
 				{
-					case "FLOAT":		varInfo.type = ShaderVarType.Float; break;
-					case "VEC2":		varInfo.type = ShaderVarType.Vec2; break;
-					case "VEC3":		varInfo.type = ShaderVarType.Vec3; break;
-					case "VEC4":		varInfo.type = ShaderVarType.Vec4; break;
-					case "MAT2":		varInfo.type = ShaderVarType.Mat2; break;
-					case "MAT3":		varInfo.type = ShaderVarType.Mat3; break;
-					case "MAT4":		varInfo.type = ShaderVarType.Mat4; break;
-					case "INT":			varInfo.type = ShaderVarType.Int; break;
-					case "SAMPLER2D":	varInfo.type = ShaderVarType.Sampler2D; break;
+					case "FLOAT":			varInfo.type = ShaderVarType.Float; break;
+					case "VEC2":			varInfo.type = ShaderVarType.Vec2; break;
+					case "VEC3":			varInfo.type = ShaderVarType.Vec3; break;
+					case "VEC4":			varInfo.type = ShaderVarType.Vec4; break;
+					case "MAT2":			varInfo.type = ShaderVarType.Mat2; break;
+					case "MAT3":			varInfo.type = ShaderVarType.Mat3; break;
+					case "MAT4":			varInfo.type = ShaderVarType.Mat4; break;
+					case "INT":				varInfo.type = ShaderVarType.Int; break;
+					case "SAMPLER2D":		varInfo.type = ShaderVarType.Sampler2D; break;
+					case "SAMPLER2DARRAY":	varInfo.type = ShaderVarType.Sampler2DArray; break;
 				}

 				curLineSplit = curLineSplit[2].Split(new char[] {'[', ']'}, StringSplitOptions.RemoveEmptyEntries);


Rename that to avoid confusion

Rename that to avoid confusion

--- Espera.Network/NetworkSongSource.cs
+++ Espera.Network/NetworkSongSource.cs
@@ -4,6 +4,6 @@
     {
         Local = 0,
         Youtube = 1,
-        Remote = 2
+        Mobile = 2
     }
 }


Removed lingering reference

Removed lingering reference

Had a reference from my original project for this
that I had missed to uninstall

--- EventSourcing/ApplicationService.cs
+++ EventSourcing/ApplicationService.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace EventSourcing
+namespace EventSourcing
 {
     public interface IApplicationService<TIdentity>
         where TIdentity : IIdentity


Remove using

Remove using

--- FTF.Tests.XUnit/Notes/DeleteTest.cs
+++ FTF.Tests.XUnit/Notes/DeleteTest.cs
@@ -1,6 +1,5 @@
 using System.Linq;
 using FTF.Api.Exceptions;
-using FTF.Api.Responses;
 using Xunit;

 namespace FTF.Tests.XUnit.Notes


Каждый рецепт содержит ссылку на все рецепты автора.

--- AspRecipeStorage/Views/Recipes/Index.cshtml
+++ AspRecipeStorage/Views/Recipes/Index.cshtml
@@ -66,7 +66,7 @@

-
[Автор: @recipe.User.UserName] @recipe.DishType.Name : @recipe.Name

+
Автор: @Html.ActionLink(recipe.User.UserName, "Index", new { id = recipe.AuthorId }, null) | @recipe.DishType.Name : @recipe.Name

                         @Html.ActionLink("Редактировать", "Edit", new { id = recipe.Id }, new { @class = "btn btn-default" })


Block Selector now ordered by BlockName

Block Selector now ordered by BlockName

--- Assets/Fungus/Scripts/Editor/BlockEditor.cs
+++ Assets/Fungus/Scripts/Editor/BlockEditor.cs
@@ -454,6 +454,8 @@
             int selectedIndex = 0;
             blockNames.Add(nullLabel);
             var blocks = flowchart.GetComponents<Block>();
+            blocks = blocks.OrderBy(x => x.BlockName).ToArray();
+
             for (int i = 0; i < blocks.Length; ++i)
             {
                 blockNames.Add(new GUIContent(blocks[i].BlockName));
@@ -492,6 +494,8 @@
             int selectedIndex = 0;
             blockNames.Add(nullLabel);
             Block[] blocks = flowchart.GetComponents<Block>();
+            blocks = blocks.OrderBy(x => x.BlockName).ToArray();
+
             for (int i = 0; i < blocks.Length; ++i)
             {
 				blockNames.Add(new GUIContent(blocks[i].BlockName));


Fixing valid walls

Fixing valid walls

--- Assets/Scripts/CornerHighlightController.cs
+++ Assets/Scripts/CornerHighlightController.cs
@@ -14,6 +14,7 @@
     public Material invalid;

     private bool dragging = false;
+    private bool validWall = false;
     private static CornerHighlightController selected;
     private float animationDirection = 1;
     private float animationSize = 1;
@@ -30,7 +31,11 @@
     // Update is called once per frame
     void Update()
     {
-        // onmousemove -> move wall
+        if (!newWall)
+        {
+            resetSelections();
+        }
+
         if (dragging)
         {
             RaycastHit hitInfo = new RaycastHit();
@@ -41,17 +46,13 @@
                 newWall.transform.localScale = new Vector3(1, 1, (hitInfo.point - transform.position).magnitude);
             }

-            if (this != selected)
+            if (selected && this != selected)
             {
-                if ((selected.transform.position - transform.position).magnitude <= 1.1)
-                {
-                    selected.SetMaterial(valid);
-                }
-                else
-                {
-                    selected.SetMaterial(invalid);
-                }
-
+                validWall = (selected.transform.position - transform.position).magnitude <= 1.1;
+                selected.SetMaterial(validWall ? valid : invalid);
+            } else
+            {
+                validWall = false;
             }

         }
@@ -78,13 +79,14 @@
     {
         if (dragging)
         {
-            if (selected)
+            if (selected != this && validWall)
             {
                 newWall.transform.LookAt(selected.transform.position);
                 newWall.transform.localScale = Vector3.one;
-                selected.SetMaterial(standard);
-                // fix wall
-                // check if path possible
+
+                // recalculate pathing
+                FindObjectOfType<AstarPath>().Scan();
+                //FindObjectOfType<AstarPath>().
             }
             else
             {
@@ -92,10 +94,7 @@
             }
         }

-
-        dragging = false;
-        selected = null;
-        transform.localScale = Vector3.one;
+        resetSelections();
     }

     void OnMouseDown()
@@ -140,4 +139,16 @@
             renderer.material = material;
         }
     }
+
+    private void resetSelections()
+    {
+        if (selected)
+        {
+            selected.SetMaterial(standard);
+        }
+        selected = null;
+        dragging = false;
+        transform.localScale = Vector3.one;
+        validWall = false;
+    }
 }


Removed GeForce VBO hacks, no longer necessary.

git-svn-id: 53f2a8ff3606f182ef4420064c1f4a5cdcbe6bb1@215 bb9bf1cf-960d-0410-9a3a-baeba60cf407

--- Axiom/RenderSystem_OpenGL/GLRenderSystem.cs
+++ Axiom/RenderSystem_OpenGL/GLRenderSystem.cs
@@ -1864,10 +1864,7 @@
                 caps.SetCap(Capabilities.Dot3Bump);

             // check support for vertex buffers in hardware
-            // NOTE: GeForce2 MX and GeForce3 report support, but simply doesn't work
-            if(GLHelper.SupportsExtension("GL_ARB_vertex_buffer_object")
-                && GLHelper.VideoCard.IndexOf("GeForce2 MX") == -1
-                && GLHelper.VideoCard.IndexOf("GeForce3") == -1)
+            if(GLHelper.SupportsExtension("GL_ARB_vertex_buffer_object"))
                 caps.SetCap(Capabilities.VertexBuffer);

             if(GLHelper.SupportsExtension("GL_ARB_texture_cube_map")


PT代名詞の整列順を修正 PT内に同Jobが複数いた場合、PT代名詞の整列順がプレイヤID昇順となっていたが、ゲーム側は降順となっているため、ソートルールを変更

--- ACT.SpecialSpellTimer/LogBuffer.cs
+++ ACT.SpecialSpellTimer/LogBuffer.cs
@@ -332,7 +332,7 @@
                     orderby
                     y.Role,
                     x.Job,
-                    x.ID
+                    x.ID descending
                     select
                     x.Name.Trim();


ソートでプレイヤー本人を優先していなかった不具合を修正した

ソートでプレイヤー本人を優先していなかった不具合を修正した

--- ACT.SpecialSpellTimer/LogBuffer.cs
+++ ACT.SpecialSpellTimer/LogBuffer.cs
@@ -246,7 +246,8 @@
             // ジョブ名プレースホルダを置換する
             // ex. <PLD>, <PLD1> ...
             if (ptmemberCombatant != null &&
-                ptmemberCombatant.Count > 0)
+                ptmemberCombatant.Count > 0 &&
+                player != null)
             {
                 foreach (var job in Job.GetJobList())
                 {
@@ -256,6 +257,7 @@
                         where
                         x.Job == job.JobId
                         orderby
+                        x.ID == player.ID ? 0 : 1,
                         x.Name
                         select
                         x).ToArray();


Bug refs #1372: add tests for empty name cases, can not reproduce

--- AGO.Tasks.Test/TaskTypeCRUDTest.cs
+++ AGO.Tasks.Test/TaskTypeCRUDTest.cs
@@ -92,6 +92,22 @@
 			Assert.IsTrue(vr.Success);
 		}

+		[Test]
+		public void CreateTaskTypeWithEmptyNameReturnError()
+		{
+			var model = new TaskTypeDTO { Name = string.Empty };
+
+			var vr = Controller.EditTaskType(TestProject, model).Validation;
+			_SessionProvider.FlushCurrentSession(!vr.Success);
+
+			var tt = _SessionProvider.CurrentSession.QueryOver<TaskTypeModel>()
+				.Where(m => m.ProjectCode == TestProject && m.Name == string.Empty)
+				.SingleOrDefault();
+			Assert.IsNull(tt);
+			Assert.IsFalse(vr.Success);
+			Assert.IsTrue(vr.FieldErrors.First(e => e.Key == "Name").Value.Any());
+		}
+

 		[Test]
 		public void UpdateTaskType()
@@ -106,6 +122,22 @@
 			testTaskType = _SessionProvider.CurrentSession.Get<TaskTypeModel>(testTaskType.Id);
 			Assert.AreEqual("NewName", testTaskType.Name);
 			Assert.IsTrue(vr.Success);
+		}
+
+		[Test]
+		public void UpdateTaskTypeWithEmptyNameReturnError()
+		{
+			var tt = M.TaskType("aaa");
+			_SessionProvider.FlushCurrentSession();
+
+			var model = new TaskTypeDTO { Id = tt.Id, Name = string.Empty };
+			var vr = Controller.EditTaskType(TestProject, model).Validation;
+			_SessionProvider.FlushCurrentSession(!vr.Success);
+
+			Assert.IsFalse(vr.Success);
+			tt = Session.Get<TaskTypeModel>(tt.Id);
+			Assert.AreEqual("aaa", tt.Name);
+			Assert.IsTrue(vr.FieldErrors.First(e => e.Key == "Name").Value.Any());
 		}

 		[Test]


fix json

fix json

--- APIClient/Models/AccountBalance.cs
+++ APIClient/Models/AccountBalance.cs
@@ -31,29 +31,22 @@
         [JsonProperty("eth_available")]
         public decimal ETHAvailable { get; set; }

-        [JsonProperty("btctry_fee_percentage")]
-        public decimal BTCTRYFeePercentage { get; set; }
+        [JsonProperty("btctry_taker_fee_percentage")]
+        public decimal BTCTRYTakerFeePercentage { get; set; }

         [JsonProperty("btctry_maker_fee_percentage")]
         public decimal BTCTRYMakerFeePercentage { get; set; }

-        [JsonProperty("ethtry_fee_percentage")]
-        public decimal ETHTRYFeePercentage { get; set; }
+        [JsonProperty("ethtry_taker_fee_percentage")]
+        public decimal ETHTRYTakerFeePercentage { get; set; }

         [JsonProperty("ethtry_maker_fee_percentage")]
         public decimal ETHTRYMakerFeePercentage { get; set; }

-        [JsonProperty("ethbtc_fee_percentage")]
-        public decimal ETHBTCFeePercentage { get; set; }
+        [JsonProperty("ethbtc_taker_fee_percentage")]
+        public decimal ETHBTCTakerFeePercentage { get; set; }

         [JsonProperty("ethbtc_maker_fee_percentage")]
         public decimal ETHBTCMakerFeePercentage { get; set; }
-
-        public override string ToString()
-        {
-            return "TRY Balance: " + TRYBalance + "\n" + "BTC Balance: " + BTCBalance + "\n" + "ETH Balance: "
-                   + ETHBalance + "\n" + "TRY Reserved: " + TRYReserved + "\n" + "BTC Reserved: " + BTCReserved + "\n"
-                   + "ETH Reserved: " + ETHReserved + "\n";
-        }
     }
 }


DEV-8914 Wrapping the external object as acrolinxPlugin inside c# code

--- Acrolinx.Sidebar/AcrolinxPlugin.cs
+++ Acrolinx.Sidebar/AcrolinxPlugin.cs
@@ -40,7 +40,7 @@
             sidebar.Eval("if (!window.console) { window.console = {} }; window.console.logOld = window.console.log; window.console.log = function(msg) { window.external.Log(msg); }" );
             sidebar.Eval( "window.onerror = function(msg, url, line, col, error) { window.external.OnError(msg, url, line, col, error); }" );
             //The next line would have the effect that the sidebar exchanges objects instead of strings. This seem to fail in case of .NET internet explorer web control...
-            //webBrowser.Document.InvokeScript("eval", new object[] { "window.acrolinxPlugin = window.external" });
+            webBrowser.Document.InvokeScript("eval", new object[] { "window.acrolinxPlugin =   {requestInit: function(){ window.external.requestInit()}, onInitFinished: function(finishResult) {window.external.onInitFinished(JSON.stringify(finishResult))}, configure: function(configuration) { window.external.configure(JSON.stringify(configuration)) }, requestGlobalCheck: function() { window.external.requestGlobalCheck() }, onCheckResult: function(checkResult) {window.external.onCheckResult(JSON.stringify(checkResult)) }, selectRanges: function(checkId, matches) { window.external.selectRanges(checkId, JSON.stringify(matches))}, replaceRanges: function(checkId, matchesWithReplacements) { window.external.replaceRanges(checkId, JSON.stringify(matchesWithReplacements)) }, download: function(downloadInfo) { window.external.download(JSON.stringify(downloadInfo))}, openWindow: function(openWindowParameters) { window.external.openWindow(JSON.stringify(openWindowParameters)) }}; "});
         }

         public void Log(params dynamic[] o)
@@ -94,9 +94,10 @@
             System.Diagnostics.Trace.WriteLine("request init");

             var initParams = sidebar.InitParameters.ToString();
-
-            sidebar.Eval( "acrolinxSidebar.init(" + initParams + ")");
+
+            sidebar.Eval("acrolinxSidebar.init(" + initParams + ")");
         }
+
         public void onInitFinished(params object[] o)
         {
             sidebar.FireInitFinished();


Initial hack at implementing the queue

Initial hack at implementing the queue

--- Akavache.Sqlite3/OperationQueue.cs
+++ Akavache.Sqlite3/OperationQueue.cs
@@ -5,16 +5,21 @@
 using System.Text;
 using System.Threading.Tasks;
 using System.Collections.Concurrent;
-using Akavache.Sqlite3.Internal;
 using System.Reactive.Concurrency;
 using System.Reactive.Subjects;
+using System.Reactive.Threading.Tasks;
 using System.Reactive;
+
+using Akavache.Sqlite3.Internal;
+using AsyncLock = Akavache.Sqlite3.Internal.AsyncLock;
+using System.Threading;
+using System.Reactive.Disposables;

 namespace Akavache.Sqlite3
 {
     class SqliteOperationQueue
     {
-        readonly Queue<Tuple<OperationType, IEnumerable, object>> operationQueue = new Queue<Tuple<OperationType, IEnumerable, object>>();
+        readonly AsyncLock flushLock = new AsyncLock();

         readonly BulkSelectSqliteOperation bulkSelectKey;
         readonly BulkSelectByTypeSqliteOperation bulkSelectType;
@@ -25,6 +30,9 @@
         readonly VacuumSqliteOperation vacuum;
         readonly GetKeysSqliteOperation getAllKeys;

+        BlockingCollection<Tuple<OperationType, IEnumerable, object>> operationQueue =
+            new BlockingCollection<Tuple<OperationType, IEnumerable, object>>();
+
         public SqliteOperationQueue(SQLiteConnection conn, IScheduler scheduler)
         {
             bulkSelectKey = new BulkSelectSqliteOperation(conn, false);
@@ -37,18 +45,133 @@
             getAllKeys = new GetKeysSqliteOperation(conn, scheduler);
         }

-        public void ProcessItems()
-        {
-            var toProcess = new List<Tuple<OperationType, IEnumerable, object>>();
-            lock (operationQueue)
-            {
-                while (operationQueue.Count > 0 && toProcess.Count < Constants.OperationQueueChunkSize)
+        IDisposable start;
+        public IDisposable Start()
+        {
+            if (start != null) return start;
+
+            bool shouldQuit = false;
+            var task = Task.Run(async () =>
+            {
+                var toProcess = new List<Tuple<OperationType, IEnumerable, object>>();
+
+                while (!shouldQuit)
                 {
-                    if (operationQueue.Count == 0) break;
-                    toProcess.Add(operationQueue.Dequeue());
+                    toProcess.Clear();
+
+                    using (await flushLock.LockAsync())
+                    {
+                        // NB: We special-case the first item because we want to
+                        // in the empty list case, we want to wait until we have an item.
+                        // Once we have a single item, we try to fetch as many as possible
+                        // until we've got enough items.
+                        var item = default(Tuple<OperationType, IEnumerable, object>);
+                        if (!operationQueue.TryTake(out item, 2000)) continue;
+
+                        toProcess.Add(item);
+                        while (toProcess.Count < Constants.OperationQueueChunkSize && operationQueue.TryTake(out item))
+                        {
+                            toProcess.Add(item);
+                        }
+
+                        ProcessItems(toProcess);
+                    }
                 }
-            }
-
+            });
+
+            return (start = Disposable.Create(() =>
+            {
+                shouldQuit = true;
+                task.Wait();
+
+                var newQueue = new BlockingCollection<Tuple<OperationType, IEnumerable, object>>();
+                ProcessItems(Interlocked.Exchange(ref operationQueue, newQueue).ToList());
+                start = null;
+            }));
+        }
+
+        public IObservable<Unit> Flush()
+        {
+            var ret = new AsyncSubject<Unit>();
+
+            return Task.Run(async () =>
+            {
+                using (await flushLock.LockAsync())
+                {
+                    var newQueue = new BlockingCollection<Tuple<OperationType, IEnumerable, object>>();
+                    var existingItems = Interlocked.Exchange(ref operationQueue, newQueue).ToList();
+
+                    ProcessItems(existingItems);
+                }
+            }).ToObservable();
+        }
+
+        public AsyncSubject<List<CacheElement>> Select(IEnumerable<string> keys)
+        {
+            var ret = new AsyncSubject<List<CacheElement>>();
+
+            operationQueue.Add(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkSelectSqliteOperation, keys, ret));
+            return ret;
+        }
+
+        public AsyncSubject<List<CacheElement>> SelectTypes(IEnumerable<string> types)
+        {
+            var ret = new AsyncSubject<List<CacheElement>>();
+
+            operationQueue.Add(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkSelectByTypeSqliteOperation, types, ret));
+            return ret;
+        }
+
+        public AsyncSubject<Unit> Insert(IEnumerable<CacheElement> items)
+        {
+            var ret = new AsyncSubject<Unit>();
+
+            operationQueue.Add(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkInsertSqliteOperation, items, ret));
+            return ret;
+        }
+
+        public AsyncSubject<Unit> Invalidate(IEnumerable<string> keys)
+        {
+            var ret = new AsyncSubject<Unit>();
+
+            operationQueue.Add(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkInvalidateSqliteOperation, keys, ret));
+            return ret;
+        }
+
+        public AsyncSubject<Unit> InvalidateTypes(IEnumerable<string> types)
+        {
+            var ret = new AsyncSubject<Unit>();
+
+            operationQueue.Add(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkInvalidateByTypeSqliteOperation, types, ret));
+            return ret;
+        }
+
+        public AsyncSubject<Unit> InvalidateAll()
+        {
+            var ret = new AsyncSubject<Unit>();
+
+            operationQueue.Add(new Tuple<OperationType, IEnumerable, object>(OperationType.InvalidateAllSqliteOperation, null, ret));
+            return ret;
+        }
+
+        public AsyncSubject<Unit> Vacuum()
+        {
+            var ret = new AsyncSubject<Unit>();
+
+            operationQueue.Add(new Tuple<OperationType, IEnumerable, object>(OperationType.VacuumSqliteOperation, null, ret));
+            return ret;
+        }
+
+        public AsyncSubject<List<string>> GetAllKeys()
+        {
+            var ret = new AsyncSubject<List<string>>();
+
+            operationQueue.Add(new Tuple<OperationType, IEnumerable, object>(OperationType.GetKeysSqliteOperation, null, ret));
+            return ret;
+        }
+
+        void ProcessItems(List<Tuple<OperationType, IEnumerable, object>> toProcess)
+        {
             foreach (var item in toProcess)
             {
                 switch (item.Item1) {
@@ -82,70 +205,6 @@
             }
         }

-        public AsyncSubject<List<CacheElement>> Select(IEnumerable<string> keys)
-        {
-            var ret = new AsyncSubject<List<CacheElement>>();
-            lock (operationQueue)
-                operationQueue.Enqueue(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkSelectSqliteOperation, keys, ret));
-            return ret;
-        }
-
-        public AsyncSubject<List<CacheElement>> SelectTypes(IEnumerable<string> types)
-        {
-            var ret = new AsyncSubject<List<CacheElement>>();
-            lock (operationQueue)
-                operationQueue.Enqueue(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkSelectByTypeSqliteOperation, types, ret));
-            return ret;
-        }
-
-        public AsyncSubject<Unit> Insert(IEnumerable<CacheElement> items)
-        {
-            var ret = new AsyncSubject<Unit>();
-            lock (operationQueue)
-                operationQueue.Enqueue(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkInsertSqliteOperation, items, ret));
-            return ret;
-        }
-
-        public AsyncSubject<Unit> Invalidate(IEnumerable<string> keys)
-        {
-            var ret = new AsyncSubject<Unit>();
-            lock (operationQueue)
-                operationQueue.Enqueue(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkInvalidateSqliteOperation, keys, ret));
-            return ret;
-        }
-
-        public AsyncSubject<Unit> InvalidateTypes(IEnumerable<string> types)
-        {
-            var ret = new AsyncSubject<Unit>();
-            lock (operationQueue)
-                operationQueue.Enqueue(new Tuple<OperationType, IEnumerable, object>(OperationType.BulkInvalidateByTypeSqliteOperation, types, ret));
-            return ret;
-        }
-
-        public AsyncSubject<Unit> InvalidateAll()
-        {
-            var ret = new AsyncSubject<Unit>();
-            lock (operationQueue)
-                operationQueue.Enqueue(new Tuple<OperationType, IEnumerable, object>(OperationType.InvalidateAllSqliteOperation, null, ret));
-            return ret;
-        }
-
-        public AsyncSubject<Unit> Vacuum()
-        {
-            var ret = new AsyncSubject<Unit>();
-            lock (operationQueue)
-                operationQueue.Enqueue(new Tuple<OperationType, IEnumerable, object>(OperationType.VacuumSqliteOperation, null, ret));
-            return ret;
-        }
-
-        public AsyncSubject<List<string>> GetAllKeys()
-        {
-            var ret = new AsyncSubject<List<string>>();
-            lock (operationQueue)
-                operationQueue.Enqueue(new Tuple<OperationType, IEnumerable, object>(OperationType.GetKeysSqliteOperation, null, ret));
-            return ret;
-        }
-
         void MarshalCompletion<T>(object completion, Func<T> block)
         {
             var subj = (AsyncSubject<T>)completion;