Moved variables scope closer to usage. Other minor refactoring.

--- ImageTracerNet/ImageTracer.cs
+++ ImageTracerNet/ImageTracer.cs
@@ -116,7 +116,7 @@
                 imgd = Blur(imgd, options.Blur.BlurRadius, options.Blur.BlurDelta);
             }

-            var paletteacc = new long[palette.Length][].InitInner(5);
+            var paletteAcc = new long[palette.Length][].InitInner(5);

             // Repeat clustering step "cycles" times
             for (var cnt = 0; cnt < options.ColorQuantization.ColorQuantCycles; cnt++)
@@ -125,19 +125,18 @@
                 if (cnt > 0)
                 {
                     // averaging paletteacc for palette
-                    double ratio;
                     for (var k = 0; k < palette.Length; k++)
                     {
                         const int shift = 0; // MJY: From -128
                         // averaging
-                        if (paletteacc[k][3] > 0)
+                        if (paletteAcc[k][3] > 0)
                         {
-                            palette[k][0] = (byte)(shift + Math.Floor(paletteacc[k][0] / (double)paletteacc[k][4]));
-                            palette[k][1] = (byte)(shift + Math.Floor(paletteacc[k][1] / (double)paletteacc[k][4]));
-                            palette[k][2] = (byte)(shift + Math.Floor(paletteacc[k][2] / (double)paletteacc[k][4]));
-                            palette[k][3] = (byte)(shift + Math.Floor(paletteacc[k][3] / (double)paletteacc[k][4]));
+                            palette[k][0] = (byte)(shift + Math.Floor(paletteAcc[k][0] / (double)paletteAcc[k][4]));
+                            palette[k][1] = (byte)(shift + Math.Floor(paletteAcc[k][1] / (double)paletteAcc[k][4]));
+                            palette[k][2] = (byte)(shift + Math.Floor(paletteAcc[k][2] / (double)paletteAcc[k][4]));
+                            palette[k][3] = (byte)(shift + Math.Floor(paletteAcc[k][3] / (double)paletteAcc[k][4]));
                         }
-                        ratio = paletteacc[k][4] / (double)(imgd.Width * imgd.Height);
+                        var ratio = paletteAcc[k][4] / (double)(imgd.Width * imgd.Height);

                         // Randomizing a color, if there are too few pixels and there will be a new cycle
                         if ((ratio < options.ColorQuantization.MinColorRatio) && (cnt < options.ColorQuantization.ColorQuantCycles - 1))
@@ -154,11 +153,11 @@
                 // Reseting palette accumulator for averaging
                 for (var i = 0; i < palette.Length; i++)
                 {
-                    paletteacc[i][0] = 0;
-                    paletteacc[i][1] = 0;
-                    paletteacc[i][2] = 0;
-                    paletteacc[i][3] = 0;
-                    paletteacc[i][4] = 0;
+                    paletteAcc[i][0] = 0;
+                    paletteAcc[i][1] = 0;
+                    paletteAcc[i][2] = 0;
+                    paletteAcc[i][3] = 0;
+                    paletteAcc[i][4] = 0;
                 }

                 // loop through all pixels
@@ -188,11 +187,11 @@
                         const int shift = 0; // MJY: From 128

                         // add to palettacc
-                        paletteacc[ci][0] += shift + imgd.Data[idx];
-                        paletteacc[ci][1] += shift + imgd.Data[idx + 1];
-                        paletteacc[ci][2] += shift + imgd.Data[idx + 2];
-                        paletteacc[ci][3] += shift + imgd.Data[idx + 3];
-                        paletteacc[ci][4]++;
+                        paletteAcc[ci][0] += shift + imgd.Data[idx];
+                        paletteAcc[ci][1] += shift + imgd.Data[idx + 1];
+                        paletteAcc[ci][2] += shift + imgd.Data[idx + 2];
+                        paletteAcc[ci][3] += shift + imgd.Data[idx + 3];
+                        paletteAcc[ci][4]++;

                         arr[j + 1][i + 1] = ci;
                     }// End of i loop
@@ -256,10 +255,10 @@

         private static byte[][] SamplePalette(int numberofcolors, ImageData imgd)
         {
-            var idx = 0; var palette = new byte[numberofcolors][].InitInner(4);
+            var palette = new byte[numberofcolors][].InitInner(4);
             for (var i = 0; i < numberofcolors; i++)
             {
-                idx = (int)(Math.Floor(Rng.NextDouble() * imgd.Data.Length / 4) * 4);
+                var idx = (int)(Math.Floor(Rng.NextDouble() * imgd.Data.Length / 4) * 4);
                 palette[i][0] = imgd.Data[idx];
                 palette[i][1] = imgd.Data[idx + 1];
                 palette[i][2] = imgd.Data[idx + 2];
@@ -277,7 +276,7 @@
         private static int[][][] Layering(IndexedImage ii)
         {
             // Creating layers for each indexed color in arr
-            int val = 0, aw = ii.Array[0].Length, ah = ii.Array.Length, n1, n2, n3, n4, n5, n6, n7, n8;
+            int aw = ii.Array[0].Length, ah = ii.Array.Length;
             var layers = new int[ii.Palette.Length][][].InitInner(ah, aw);

             // Looping through all pixels and calculating edge node type
@@ -287,16 +286,24 @@
                 {

                     // This pixel's indexed color
-                    val = ii.Array[j][i];
+                    var val = ii.Array[j][i];

                     // Are neighbor pixel colors the same?
+                    int n1;
                     if ((j > 0) && (i > 0)) { n1 = ii.Array[j - 1][i - 1] == val ? 1 : 0; } else { n1 = 0; }
+                    int n2;
                     if (j > 0) { n2 = ii.Array[j - 1][i] == val ? 1 : 0; } else { n2 = 0; }
+                    int n3;
                     if ((j > 0) && (i < aw - 1)) { n3 = ii.Array[j - 1][i + 1] == val ? 1 : 0; } else { n3 = 0; }
+                    int n4;
                     if (i > 0) { n4 = ii.Array[j][i - 1] == val ? 1 : 0; } else { n4 = 0; }
+                    int n5;
                     if (i < aw - 1) { n5 = ii.Array[j][i + 1] == val ? 1 : 0; } else { n5 = 0; }
+                    int n6;
                     if ((j < ah - 1) && (i > 0)) { n6 = ii.Array[j + 1][i - 1] == val ? 1 : 0; } else { n6 = 0; }
+                    int n7;
                     if (j < ah - 1) { n7 = ii.Array[j + 1][i] == val ? 1 : 0; } else { n7 = 0; }
+                    int n8;
                     if ((j < ah - 1) && (i < aw - 1)) { n8 = ii.Array[j + 1][i + 1] == val ? 1 : 0; } else { n8 = 0; }

                     // this pixel"s type and looking back on previous pixels
@@ -321,9 +328,8 @@
         private static List<List<int[]>> PathScan(int[][] arr, int pathomit)
         {
             var paths = new List<List<int[]>>();
-            List<int[]> thispath;
-            int px = 0, py = 0, w = arr[0].Length, h = arr.Length, dir = 0;
-            bool pathfinished = true, holepath = false;
+            int w = arr[0].Length, h = arr.Length, dir = 0;
+            bool holepath = false;

             for (var j = 0; j < h; j++)
             {
@@ -332,10 +338,10 @@
                     if ((arr[j][i] != 0) && (arr[j][i] != 15))
                     {
                         // Init
-                        px = i; py = j;
+                        var px = i; var py = j;
                         paths.Add(new List<int[]>());
-                        thispath = paths[paths.Count - 1];
-                        pathfinished = false;
+                        var thispath = paths[paths.Count - 1];
+                        var pathfinished = false;
                         // fill paths will be drawn, but hole paths are also required to remove unnecessary edge nodes
                         if (arr[py][px] == 1) { dir = 0; }
                         if (arr[py][px] == 2) { dir = 3; }
@@ -606,27 +612,24 @@
         private static List<List<double[]>> InterNodes(List<List<int[]>> paths)
         {
             var ins = new List<List<double[]>>();
-            List<double[]> thisinp;
-            double[] thispoint, nextpoint = new double[2];
-            int[] pp1, pp2, pp3;
-
-            int palen = 0, nextidx = 0, nextidx2 = 0;
+            double[] nextpoint = new double[2];
+
             // paths loop
             for (var pacnt = 0; pacnt < paths.Count; pacnt++)
             {
                 ins.Add(new List<double[]>());
-                thisinp = ins[ins.Count - 1];
-                palen = paths[pacnt].Count;
+                var thisinp = ins[ins.Count - 1];
+                var palen = paths[pacnt].Count;
                 // pathpoints loop
                 for (var pcnt = 0; pcnt < palen; pcnt++)
                 {
                     // interpolate between two path points
-                    nextidx = (pcnt + 1) % palen; nextidx2 = (pcnt + 2) % palen;
+                    var nextidx = (pcnt + 1) % palen; var nextidx2 = (pcnt + 2) % palen;
                     thisinp.Add(new double[3]);
-                    thispoint = thisinp[thisinp.Count - 1];
-                    pp1 = paths[pacnt][pcnt];
-                    pp2 = paths[pacnt][nextidx];
-                    pp3 = paths[pacnt][nextidx2];
+                    var thispoint = thisinp[thisinp.Count - 1];
+                    var pp1 = paths[pacnt][pcnt];
+                    var pp2 = paths[pacnt][nextidx];
+                    var pp3 = paths[pacnt][nextidx2];
                     thispoint[0] = (pp1[0] + pp2[0]) / 2.0;
                     thispoint[1] = (pp1[1] + pp2[1]) / 2.0;
                     nextpoint[0] = (pp2[0] + pp3[0]) / 2.0;
@@ -690,7 +693,7 @@

         private static List<double[]> TracePath(List<double[]> path, double ltreshold, double qtreshold)
         {
-            int pcnt = 0, seqend = 0; double segtype1, segtype2;
+            int pcnt = 0;
             var smp = new List<double[]>();
             //Double [] thissegment;
             var pathlength = path.Count;
@@ -698,7 +701,7 @@
             while (pcnt < pathlength)
             {
                 // 5.1. Find sequences of points with only 2 segment types
-                segtype1 = path[pcnt][2]; segtype2 = -1; seqend = pcnt + 1;
+                var segtype1 = path[pcnt][2]; double segtype2 = -1; var seqend = pcnt + 1;
                 while ((path[seqend][2].AreEqual(segtype1) || path[seqend][2].AreEqual(segtype2) || segtype2.AreEqual(-1)) && (seqend < pathlength - 1))
                 {
                     if (path[seqend][2].AreNotEqual(segtype1) && segtype2.AreEqual(-1)) { segtype2 = path[seqend][2]; }
@@ -737,10 +740,9 @@

             // 5.2. Fit a straight line on the sequence
             var pcnt = (seqstart + 1) % pathlength;
-            double pl;
             while (pcnt != seqend)
             {
-                pl = pcnt - seqstart; if (pl < 0) { pl += pathlength; }
+                double pl = pcnt - seqstart; if (pl < 0) { pl += pathlength; }
                 px = path[seqstart][0] + vx * pl; py = path[seqstart][1] + vy * pl;
                 dist2 = (path[pcnt][0] - px) * (path[pcnt][0] - px) + (path[pcnt][1] - py) * (path[pcnt][1] - py);
                 if (dist2 > ltreshold) { curvepass = false; }
@@ -919,7 +921,6 @@

             // creating Z-index
             var zindex = new SortedDictionary<double, int[]>(); //TreeMap<Double, Integer[]> zindex = new TreeMap<Double, Integer[]>();
-            double label;
             // Layer loop
             for (var k = 0; k < ii.Layers.Count; k++)
             {
@@ -927,7 +928,7 @@
                 for (var pcnt = 0; pcnt < ii.Layers[k].Count; pcnt++)
                 {
                     // Label (Z-index key) is the startpoint of the path, linearized
-                    label = ii.Layers[k][pcnt][0][2] * w + ii.Layers[k][pcnt][0][1];
+                    var label = ii.Layers[k][pcnt][0][2] * w + ii.Layers[k][pcnt][0][1];
                     // Creating new list if required
                     if (!zindex.ContainsKey(label)) { zindex[label] = new int[2]; }
                     // Adding layer and path number to list
@@ -940,9 +941,9 @@

             // Drawing
             // Z-index loop
-            var thisdesc = "";
             foreach(var entry in zindex)
             {
+                var thisdesc = "";
                 if (options.SvgRendering.Desc.IsNotZero()) { thisdesc = "desc=\"l " + entry.Value[0] + " p " + entry.Value[1] + "\" "; } else { thisdesc = ""; }
                 SvgPathString(svgstr,
                         thisdesc,
@@ -977,7 +978,8 @@
         // Selective Gaussian blur for preprocessing
         private static ImageData Blur(ImageData imgd, int rad, double del)
         {
-            int i, j, k, d, idx;
+            int i, j, k;
+            int idx;
             double racc, gacc, bacc, aacc, wacc;
             var imgd2 = new ImageData(imgd.Width, imgd.Height, new byte[imgd.Width * imgd.Height * 4]);

@@ -1056,7 +1058,7 @@
                 {
                     idx = (j * imgd.Width + i) * 4;
                     // d is the difference between the blurred and the original pixel
-                    d = Math.Abs(imgd2.Data[idx] - imgd.Data[idx]) + Math.Abs(imgd2.Data[idx + 1] - imgd.Data[idx + 1]) +
+                    var d = Math.Abs(imgd2.Data[idx] - imgd.Data[idx]) + Math.Abs(imgd2.Data[idx + 1] - imgd.Data[idx + 1]) +
                             Math.Abs(imgd2.Data[idx + 2] - imgd.Data[idx + 2]) + Math.Abs(imgd2.Data[idx + 3] - imgd.Data[idx + 3]);
                     // selective blur: if d>delta, put the original pixel back
                     if (d > delta)


Fix init condition

Fix init condition

--- Infinni.NodeWorker/Program.cs
+++ Infinni.NodeWorker/Program.cs
@@ -43,7 +43,8 @@

             // Инициализация окружения для приложения

-            if (serviceOptions.StartOptions.IndexOf("init", StringComparison.OrdinalIgnoreCase) >= 0)
+            if (!string.IsNullOrWhiteSpace(serviceOptions.StartOptions) &&
+                serviceOptions.StartOptions.IndexOf("init", StringComparison.OrdinalIgnoreCase) >= 0)
             {
                 var initAppServiceHost = new AppServiceHost();
                 initAppServiceHost.Init(TimeSpan.FromSeconds(10));


Minor

Minor

--- ApiExamples/CSharp/ApiExamples/ExStructuredDocumentTag.cs
+++ ApiExamples/CSharp/ApiExamples/ExStructuredDocumentTag.cs
@@ -199,6 +199,7 @@
         public void SmartTagProperties()
         {
             //ExStart
+            //ExFor:CustomXmlProperty.Uri
             //ExFor:CustomXmlPropertyCollection
             //ExFor:CustomXmlPropertyCollection.Add(CustomXmlProperty)
             //ExFor:CustomXmlPropertyCollection.Clear
@@ -266,7 +267,6 @@
             //ExFor:CustomXmlProperty
             //ExFor:CustomXmlProperty.#ctor(String,String,String)
             //ExFor:CustomXmlProperty.Name
-            //ExFor:CustomXmlProperty.Uri
             //ExFor:CustomXmlProperty.Value
             //ExSummary:Shows how to work with smart tag properties.
             Document doc = new Document();


パーティクルの処理でMesh.trianglesのsetが余分に呼ばれているのを修正 FragmentDrawParts.BootUp内ですでにsetされている

--- Assets/SpriteStudio/ScriptLibrary/Library_SpriteStudio.cs
+++ Assets/SpriteStudio/ScriptLibrary/Library_SpriteStudio.cs
@@ -3252,7 +3252,6 @@
 					InstanceMesh.uv2 = UV2;
 					InstanceMesh.colors32 = ColorVertex;
 					InstanceMesh.vertices = Coordinate;
-					InstanceMesh.triangles = Library_SpriteStudio.ArrayVertexIndex_Triangle2;

 					DataPartsDrawManager.DrawParts.Data.CurrentMeshVertices = Coordinate;
 					DataPartsDrawManager.DrawParts.Data.CurrentMeshUv = UV;


- removed code contracts from FacebookSignedRequest

--- Source/Facebook.Web/FacebookSignedRequest.cs
+++ Source/Facebook.Web/FacebookSignedRequest.cs
@@ -11,8 +11,6 @@
 {
     using System;
     using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Diagnostics.Contracts;
     using System.Linq;
     using System.Runtime.CompilerServices;
     using System.Text;
@@ -69,7 +67,8 @@
         /// </param>
         public FacebookSignedRequest(IDictionary<string, object> data)
         {
-            Contract.Requires(data != null);
+            if (data == null)
+                throw new ArgumentNullException("data");

             Data = data;
         }
@@ -81,13 +80,13 @@
         {
             get
             {
-                Contract.Ensures(Contract.Result<object>() != null);
                 return _data;
             }

             private set
             {
-                Contract.Requires(value != null);
+                if (value == null)
+                    throw new ArgumentNullException("value");

                 var data = (IDictionary<string, object>)(value is JsonObject ? value : FacebookUtils.ToDictionary(value));

@@ -204,9 +203,10 @@
         /// </returns>
         public static bool TryParse(string secret, string signedRequestValue, out FacebookSignedRequest signedRequest)
         {
-            Contract.Requires(!String.IsNullOrEmpty(signedRequestValue));
-            Contract.Requires(!String.IsNullOrEmpty(secret));
-            Contract.Requires(signedRequestValue.Contains("."), Properties.Resources.InvalidSignedRequest);
+            if (string.IsNullOrEmpty(signedRequestValue))
+                throw new ArgumentNullException("signedRequestValue");
+            if (string.IsNullOrEmpty(secret))
+                throw new ArgumentNullException("secret");

             var result = TryParse(secret, signedRequestValue, 0, DateTimeConvertor.ToUnixTime(DateTime.UtcNow), false);
             signedRequest = result == null ? null : new FacebookSignedRequest(result);
@@ -230,10 +230,8 @@
         /// </returns>
         public static bool TryParse(IFacebookApplication facebookApplication, string signedRequestValue, out FacebookSignedRequest signedRequest)
         {
-            Contract.Requires(facebookApplication != null);
-            Contract.Requires(!string.IsNullOrEmpty(facebookApplication.AppSecret));
-            Contract.Requires(!String.IsNullOrEmpty(signedRequestValue));
-            Contract.Requires(signedRequestValue.Contains("."), Properties.Resources.InvalidSignedRequest);
+            if (facebookApplication == null)
+                throw new ArgumentNullException("facebookApplication");

             return TryParse(facebookApplication.AppSecret, signedRequestValue, out signedRequest);
         }
@@ -252,10 +250,6 @@
         /// </returns>
         public static FacebookSignedRequest Parse(string secret, string signedRequestValue)
         {
-            Contract.Requires(!string.IsNullOrEmpty(secret));
-            Contract.Requires(!String.IsNullOrEmpty(signedRequestValue));
-            Contract.Requires(signedRequestValue.Contains("."), Properties.Resources.InvalidSignedRequest);
-
             var result = TryParse(secret, signedRequestValue, 0, DateTimeConvertor.ToUnixTime(DateTime.UtcNow), true);
             return result == null ? null : new FacebookSignedRequest(result);
         }
@@ -274,10 +268,8 @@
         /// </returns>
         public static FacebookSignedRequest Parse(IFacebookApplication facebookApplication, string signedRequestValue)
         {
-            Contract.Requires(facebookApplication != null);
-            Contract.Requires(!string.IsNullOrEmpty(facebookApplication.AppSecret));
-            Contract.Requires(!String.IsNullOrEmpty(signedRequestValue));
-            Contract.Requires(signedRequestValue.Contains("."), Properties.Resources.InvalidSignedRequest);
+            if (facebookApplication == null)
+                throw new ArgumentNullException("facebookApplication");

             return Parse(facebookApplication.AppSecret, signedRequestValue);
         }
@@ -354,9 +346,8 @@
         /// </returns>
         internal static FacebookSignedRequest GetSignedRequest(string appId, string appSecret, HttpContextBase httpContext)
         {
-            Contract.Requires(httpContext != null);
-            Contract.Requires(httpContext.Request != null);
-            Contract.Requires(httpContext.Request.Params != null);
+            if (httpContext == null)
+                throw new ArgumentNullException("httpContext");

             var items = httpContext.Items;
             var httpRequest = httpContext.Request;
@@ -405,11 +396,14 @@
         /// </returns>
         internal static IDictionary<string, object> TryParse(string secret, string signedRequestValue, int maxAge, double currentTime, bool throws)
         {
-            Contract.Requires(!String.IsNullOrEmpty(signedRequestValue));
-            Contract.Requires(!String.IsNullOrEmpty(secret));
-            Contract.Requires(maxAge >= 0);
-            Contract.Requires(currentTime >= 0);
-            Contract.Requires(signedRequestValue.Contains("."), Properties.Resources.InvalidSignedRequest);
+            if (string.IsNullOrEmpty(secret))
+                throw new ArgumentNullException("secret");
+            if (string.IsNullOrEmpty(signedRequestValue))
+                throw new ArgumentNullException("signedRequestValue");
+            if (maxAge < 0)
+                throw new ArgumentOutOfRangeException("maxAge", "maxAge must be greater than 0");
+            if (currentTime < 0)
+                throw new ArgumentOutOfRangeException("currentTime", "currentTime must be greater than 0");

             try
             {
@@ -503,29 +497,20 @@
         /// <returns>The name of the cookie that would house the signed request.</returns>
         internal static string GetSignedRequestCookieName(string appId)
         {
-            Contract.Requires(!string.IsNullOrEmpty(appId));
-            Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>()));
+            if (string.IsNullOrEmpty(appId))
+                throw new ArgumentNullException("appId");

             return string.Concat("fbsr_", appId);
         }

         internal static string GetSignedRequestCookieValue(string appId, HttpRequestBase httpRequest)
         {
-            Contract.Requires(!string.IsNullOrEmpty(appId));
-            Contract.Requires(httpRequest != null);
-            Contract.Requires(httpRequest.Params != null);
+            if (httpRequest == null)
+                throw new ArgumentNullException("httpRequest");

             var cookieName = GetSignedRequestCookieName(appId);

             return httpRequest.Params.AllKeys.Contains(cookieName) ? httpRequest.Params[cookieName] : null;
-        }
-
-        [SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented",
-            Justification = "Reviewed. Suppression is OK here.")]
-        [ContractInvariantMethod]
-        private void InvariantObject()
-        {
-            Contract.Invariant(_data != null);
         }
     }
 }


Simplified code.

Simplified code.

--- AudioWorks/AudioWorks.Commands.Tests/GetAudioFileTests.cs
+++ AudioWorks/AudioWorks.Commands.Tests/GetAudioFileTests.cs
@@ -2,7 +2,6 @@
 using AudioWorks.Common;
 using JetBrains.Annotations;
 using System;
-using System.Collections.ObjectModel;
 using System.IO;
 using System.Management.Automation;
 using Xunit;
@@ -196,25 +195,14 @@
                         new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.FullName,
                         "TestFiles",
                         "Valid"));
-                ps.Invoke();
-            }
-
-            Collection<PSObject> result;
-            using (var ps = PowerShell.Create())
-            {
-                ps.Runspace = _moduleFixture.Runspace;
+                ps.AddStatement();
                 ps.AddCommand("Get-AudioFile").AddArgument(fileName);
-                result = ps.Invoke();
-            }
-
-            using (var ps = PowerShell.Create())
-            {
-                ps.Runspace = _moduleFixture.Runspace;
+                var result = ps.Invoke();
+                ps.Commands.Clear();
                 ps.AddCommand("Pop-Location");
                 ps.Invoke();
-            }
-
-            Assert.True(result.Count == 1 && result[0].BaseObject is AudioFile);
+                Assert.True(result.Count == 1 && result[0].BaseObject is AudioFile);
+            }
         }
     }
 }


Removed link

Removed link

--- Source/ForloopWebApp/Views/Home/Index.cshtml
+++ Source/ForloopWebApp/Views/Home/Index.cshtml
@@ -202,7 +202,6 @@

         Podcasts:

-
Adventures in Angular

StartUp

Hanselminutes

Freelancers Show


Fix save button visibility

Fix save button visibility

Former-commit-id: e5df971db8d2e1ba68d164a092fb6eebb055e4d7 [formerly a5a5b929c4a99b5954963d2bab7d43ffb67487fc] [formerly f1a37b559876769c504deb2072e76b07ac92eb46 [formerly 6457692a2acd61497219206dc3676fff281bcb0c] [formerly 93e9b08316f6807a8615f471188d73d37d0474b4] [formerly 15ef31657b20324dcf5e9b456ec367210efd03bd [formerly fde485f088192a636cbc1796cca059e601a0c57d]] [formerly f1a37b559876769c504deb2072e76b07ac92eb46 [formerly 6457692a2acd61497219206dc3676fff281bcb0c] [formerly 93e9b08316f6807a8615f471188d73d37d0474b4] [formerly 15ef31657b20324dcf5e9b456ec367210efd03bd [formerly fde485f088192a636cbc1796cca059e601a0c57d]] [formerly 1cb7a0425f3bb3d5ba2ee2e7e7afa9ed9482a2a0 [formerly 86c0ce1072913b162a9a663d87b068372bd5d63e]]]]
Former-commit-id: ec74c0862a5221238f4188cc7dce5dd08724a6c6
Former-commit-id: e32f6cdb8fa5876767940733ceed6a858eb30820
Former-commit-id: 37a4bb9c8fa61efb304d49417400318cb6a7623a
Former-commit-id: 07a049386754247fcf2d77910b6bec1f997181cf
Former-commit-id: ce85d00a8ece16387f12e8e38f2558ae85c92434 [formerly 2732adfb8dcb1d6e77c76361594d16ebe1abf454]
Former-commit-id: a1280c2d89bd930e1c70d894b50c0be217494750
Former-commit-id: 90c25b82e91d8eebba3c47e77e9fba9ae768f605

--- Source/RawParser/View/Pages/MainPage.xaml.cs
+++ Source/RawParser/View/Pages/MainPage.xaml.cs
@@ -208,6 +208,7 @@
                      contrastSlider.IsEnabled = v;
                      //brightnessSlider.IsEnabled = v;
                      saturationSlider.IsEnabled = v;
+                     saveButton.IsEnabled = v;
                  });
         }


コメント追加

コメント追加

--- Sources/BrownSugar/ExpandableMemoryStream.cs
+++ Sources/BrownSugar/ExpandableMemoryStream.cs
@@ -10,6 +10,8 @@

     ///
     /// バッファを自動伸長しつつ内部バッファ参照可能なメモリーストリーム
+    /// System.IO.MemoryStream はバッファを与えると自動伸長動作しない
+    /// visible でインスタンスを作成した場合 GetBuffer() が利用できない
     ///
     public class ExpandableMemoryStream : Stream {

@@ -50,6 +52,9 @@
         /// 書き込み操作可能か
         public override bool CanWrite { get { return true; } }

+        //
+        //
+        //

         /// コンストラクタ
         /// <param name="calc_expand_size">拡張量計算デリゲート</param>
@@ -69,6 +74,11 @@
             if (calc_expand_size != null) {
                 CalcExpandSize = calc_expand_size;
             }
+        }
+
+        /// ディスポーズ
+        protected override void Dispose(bool disposing) {
+            Buffer_ = null;
         }

         /// 新規バッファを割り当てる
@@ -228,10 +238,5 @@
         public override void Flush() {
         }

-        /// ディスポーズ
-        protected override void Dispose(bool disposing) {
-            Buffer_ = null;
-        }
-
     }
 }


Simplify FirstOrDefault method call

Simplify FirstOrDefault method call

--- BTCPayServer/HostedServices/WebhookNotificationManager.cs
+++ BTCPayServer/HostedServices/WebhookNotificationManager.cs
@@ -125,7 +125,7 @@
         public async Task<DeliveryResult> TestWebhook(string storeId, string webhookId, WebhookEventType webhookEventType)
         {
             var delivery = NewDelivery(webhookId);
-            var webhook = (await StoreRepository.GetWebhooks(storeId)).Where(w => w.Id == webhookId).FirstOrDefault();
+            var webhook = (await StoreRepository.GetWebhooks(storeId)).FirstOrDefault(w => w.Id == webhookId);
             var deliveryRequest = new WebhookDeliveryRequest(
                 webhookId,
                 GetTestWebHook(storeId, webhookId, webhookEventType, delivery),


Added missing encode/decode for single quote

--- SparkleXrmSource/SparkleXrm/Sdk/XmlHelper.cs
+++ SparkleXrmSource/SparkleXrm/Sdk/XmlHelper.cs
@@ -10,14 +10,14 @@
     public class XmlHelper
     {

-        public static Dictionary _encode_map = new Dictionary("&", "&", @"""", """, "<", "<", ">", ">");
-        public static Dictionary _decode_map = new Dictionary("&", "&", """, @"""", "<", "<", ">", ">");
+        public static Dictionary _encode_map = new Dictionary("&", "&", @"""", """, "<", "<", ">", ">", "'", "'");
+        public static Dictionary _decode_map = new Dictionary("&", "&", """, @"""", "<", "<", ">", ">", "'","'");

         public static string Encode(string value)
         {
             if (value == null)
                 return value;
-            return value.ReplaceRegex(new System.RegularExpression(@"([\&""<>])","g"), replaceCallBackEncode);
+            return value.ReplaceRegex(new System.RegularExpression(@"([\&""<>'])","g"), replaceCallBackEncode);

         }
         public static string SerialiseNode(XmlNode node)
@@ -35,7 +35,7 @@
         {
             if (value == null)
                 return null;
-            return value.ReplaceRegex(new System.RegularExpression(@"("|<|>|&)","g"), replaceCallBackDecode);
+            return value.ReplaceRegex(new System.RegularExpression(@"("|<|>|&|')", "g"), replaceCallBackDecode);
         }

         public static string replaceCallBackEncode(string item)


Added a statement to prevent players to keep attack if below 0 hp

--- SteamBattleBot/Structures/PlayerStructure.cs
+++ SteamBattleBot/Structures/PlayerStructure.cs
@@ -35,126 +35,133 @@
         {
             if (!shopMode)
             {
-                if (enemy.classRandom == 0)
-                {
-                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You are facing a Gaben Clone.");
-                    #region Miss/Hit checker
-                    hitChance = _random.Next(1, 4);
-                    if (hitChance == 3) // Missed
-                    {
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You missed the Gaben Clone!");
-                    }
-                    else
-                    {
-                        enemy.hp -= damageDone;
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("You hit the Gaben Clone for {0} damage!", damageDone));
-                    }
-                    hitChance = _random.Next(1, 4);
-                    if (hitChance == 3) // Missed
-                    {
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The Gaben Clone missed you!");
-                    }
-                    else
-                    {
-                        damageTaken = _random.Next(1, 20); // How much damage did the monster do
-                        hp -= damageTaken;
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("The Gaben Clone hitted you with the Ban Hammer for {0} damage!", damageTaken));
-                    }
-                    #endregion
-
-                    hpCheck(callback, steamFriends);
-                    state(callback, steamFriends);
-                }
-                else if (enemy.classRandom == 1)
-                {
-                    #region Miss/Hit checker
-                    hitChance = _random.Next(1, 4);
-                    if (hitChance == 3) // Missed
-                    {
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You missed the Steam Bot!");
-                    }
-                    else
-                    {
-                        enemy.hp -= damageDone;
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("You hit the Steam Bot for {0} damage!", damageDone));
-                    }
-                    hitChance = _random.Next(1, 4);
-                    if (hitChance == 3) // Missed
-                    {
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The Steam Bot missed you!");
-                    }
-                    else
-                    {
-                        damageTaken = _random.Next(1, 14); // How much damage did the monster do
-                        hp -= damageTaken;
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("The Steam Bot spammed you with phishing links for {0} damage!", damageTaken));
-                    }
-                    #endregion
-
-                    hpCheck(callback, steamFriends);
-                    state(callback, steamFriends);
-                }
-                else if (enemy.classRandom == 2)
-                {
-                    #region Miss/Hit checker
-                    hitChance = _random.Next(1, 4);
-                    if (hitChance == 3) // Missed
-                    {
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You missed the Steam Mod!");
-                    }
-                    else
-                    {
-                        enemy.hp -= damageDone;
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("You hit the Steam Mod for {0} damage!", damageDone));
-                    }
-                    hitChance = _random.Next(1, 4);
-                    if (hitChance == 3) // Missed
-                    {
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The Steam Mod missed you!");
-                    }
-                    else
-                    {
-                        damageTaken = _random.Next(1, 16); // How much damage did the monster do
-                        hp -= damageTaken;
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("The Steam Mod blocks you from posting for {0} damage!", damageTaken));
-                    }
-                    #endregion
-
-                    hpCheck(callback, steamFriends);
-                    state(callback, steamFriends);
-                }
-                else if (enemy.classRandom == 3)
-                {
-                    #region Miss/Hit checker
-                    hitChance = _random.Next(1, 4);
-                    if (hitChance == 3) // Missed
-                    {
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You missed the Steam Admin!");
-                    }
-                    else
-                    {
-                        enemy.hp -= damageDone;
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("You hit the Steam Admin for {0} damage!", damageDone));
-                    }
-                    hitChance = _random.Next(1, 4);
-                    if (hitChance == 3) // Missed
-                    {
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The Steam Admin missed you!");
-                    }
-                    else
-                    {
-                        damageTaken = _random.Next(1, 18); // How much damage did the monster do
-                        hp -= damageTaken;
-                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("The Steam Admin bans you for trading for {0} damage!", damageTaken));
-                    }
-                    #endregion
-
-                    hpCheck(callback, steamFriends);
-                    state(callback, steamFriends);
+                if (hp <= 0) //Stops the user from attacking if below 0 HP
+                {
+                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You cannot attack anymore! Type !restart to start a new game!");
                 }
                 else
                 {
-                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("Something is wrong with the bot. Please contact the owner of the bot."));
+                    if (enemy.classRandom == 0)
+                    {
+                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You are facing a Gaben Clone.");
+                        #region Miss/Hit checker
+                        hitChance = _random.Next(1, 4);
+                        if (hitChance == 3) // Missed
+                        {
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You missed the Gaben Clone!");
+                        }
+                        else
+                        {
+                            enemy.hp -= damageDone;
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("You hit the Gaben Clone for {0} damage!", damageDone));
+                        }
+                        hitChance = _random.Next(1, 4);
+                        if (hitChance == 3) // Missed
+                        {
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The Gaben Clone missed you!");
+                        }
+                        else
+                        {
+                            damageTaken = _random.Next(1, 20); // How much damage did the monster do
+                            hp -= damageTaken;
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("The Gaben Clone hitted you with the Ban Hammer for {0} damage!", damageTaken));
+                        }
+                        #endregion
+
+                        hpCheck(callback, steamFriends);
+                        state(callback, steamFriends);
+                    }
+                    else if (enemy.classRandom == 1)
+                    {
+                        #region Miss/Hit checker
+                        hitChance = _random.Next(1, 4);
+                        if (hitChance == 3) // Missed
+                        {
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You missed the Steam Bot!");
+                        }
+                        else
+                        {
+                            enemy.hp -= damageDone;
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("You hit the Steam Bot for {0} damage!", damageDone));
+                        }
+                        hitChance = _random.Next(1, 4);
+                        if (hitChance == 3) // Missed
+                        {
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The Steam Bot missed you!");
+                        }
+                        else
+                        {
+                            damageTaken = _random.Next(1, 14); // How much damage did the monster do
+                            hp -= damageTaken;
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("The Steam Bot spammed you with phishing links for {0} damage!", damageTaken));
+                        }
+                        #endregion
+
+                        hpCheck(callback, steamFriends);
+                        state(callback, steamFriends);
+                    }
+                    else if (enemy.classRandom == 2)
+                    {
+                        #region Miss/Hit checker
+                        hitChance = _random.Next(1, 4);
+                        if (hitChance == 3) // Missed
+                        {
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You missed the Steam Mod!");
+                        }
+                        else
+                        {
+                            enemy.hp -= damageDone;
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("You hit the Steam Mod for {0} damage!", damageDone));
+                        }
+                        hitChance = _random.Next(1, 4);
+                        if (hitChance == 3) // Missed
+                        {
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The Steam Mod missed you!");
+                        }
+                        else
+                        {
+                            damageTaken = _random.Next(1, 16); // How much damage did the monster do
+                            hp -= damageTaken;
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("The Steam Mod blocks you from posting for {0} damage!", damageTaken));
+                        }
+                        #endregion
+
+                        hpCheck(callback, steamFriends);
+                        state(callback, steamFriends);
+                    }
+                    else if (enemy.classRandom == 3)
+                    {
+                        #region Miss/Hit checker
+                        hitChance = _random.Next(1, 4);
+                        if (hitChance == 3) // Missed
+                        {
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You missed the Steam Admin!");
+                        }
+                        else
+                        {
+                            enemy.hp -= damageDone;
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("You hit the Steam Admin for {0} damage!", damageDone));
+                        }
+                        hitChance = _random.Next(1, 4);
+                        if (hitChance == 3) // Missed
+                        {
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "The Steam Admin missed you!");
+                        }
+                        else
+                        {
+                            damageTaken = _random.Next(1, 18); // How much damage did the monster do
+                            hp -= damageTaken;
+                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("The Steam Admin bans you for trading for {0} damage!", damageTaken));
+                        }
+                        #endregion
+
+                        hpCheck(callback, steamFriends);
+                        state(callback, steamFriends);
+                    }
+                    else
+                    {
+                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, String.Format("Something is wrong with the bot. Please contact the owner of the bot."));
+                    }
                 }
             }
         }


Hotfix/store pending storage bug (#46)

Hotfix/store pending storage bug (#46)

First item in batch was not removed from pending store items

--- Stratis.Bitcoin/BlockStore/BlockStoreLoop.cs
+++ Stratis.Bitcoin/BlockStore/BlockStoreLoop.cs
@@ -95,72 +95,75 @@

 		public void Loop(CancellationToken cancellationToken)
 		{
-            // A loop that writes pending blocks to store
-            // or downloads missing blocks then writing to store
-            AsyncLoop.Run("BlockStoreLoop.DownloadBlocks", async token =>
+			// A loop that writes pending blocks to store
+			// or downloads missing blocks then writing to store
+			AsyncLoop.Run("BlockStoreLoop.DownloadBlocks", async token =>
 			{
 				await DownloadAndStoreBlocks(cancellationToken);
-            },
-            cancellationToken,
-            repeateEvery: TimeSpans.Second,
-            startAfter: TimeSpans.FiveSeconds);
-        }
-
-        public async Task DownloadAndStoreBlocks(CancellationToken token, bool disposemode = false)
-		{
-		    while (!token.IsCancellationRequested)
-		    {
-		        if (StoredBlock.Height >= this.ChainState.HighestValidatedPoW?.Height)
-		            break;
+			},
+			cancellationToken,
+			repeateEvery: TimeSpans.Second,
+			startAfter: TimeSpans.FiveSeconds);
+		}
+
+			public async Task DownloadAndStoreBlocks(CancellationToken token, bool disposemode = false)
+			{
+			while (!token.IsCancellationRequested)
+			{
+				if (StoredBlock.Height >= this.ChainState.HighestValidatedPoW?.Height)
+					break;

 				// find next block to download
 				var next = this.chain.GetBlock(StoredBlock.Height + 1);
-		        if (next == null)
-		            break; //no blocks to store
+				if (next == null)
+					break; //no blocks to store

 				// reorg logic
-			    if (this.StoredBlock.HashBlock != next.Header.HashPrevBlock)
-			    {
+				if (this.StoredBlock.HashBlock != next.Header.HashPrevBlock)
+				{
 					if(disposemode)
 						break;

 					var blockstoremove = new List<uint256>();
-				    var remove = this.StoredBlock;
+					var remove = this.StoredBlock;
 					// reorg - we need to delete blocks, start walking back the chain
-				    while (this.chain.GetBlock(remove.HashBlock) == null)
-				    {
-					    blockstoremove.Add(remove.HashBlock);
-					    remove = remove.Previous;
-				    }
+					while (this.chain.GetBlock(remove.HashBlock) == null)
+					{
+						blockstoremove.Add(remove.HashBlock);
+						remove = remove.Previous;
+					}

 					await this.BlockRepository.DeleteAsync(remove.HashBlock, blockstoremove);
 					this.StoredBlock = remove;
 					this.ChainState.HighestPersistedBlock = this.StoredBlock;
 					break;
-			    }
-
-		        if (await this.BlockRepository.ExistAsync(next.HashBlock))
-		        {
-		            // next block is in storage update StoredBlock
-		            await this.BlockRepository.SetBlockHash(next.HashBlock);
-		            this.StoredBlock = next;
-		            this.ChainState.HighestPersistedBlock = this.StoredBlock;
-		            continue;
-		        }
-
-		        // check if the next block is in pending storage
-			    BlockPair insert;
-			    if (this.PendingStorage.TryGetValue(next.HashBlock, out insert))
-			    {
+				}
+
+				if (await this.BlockRepository.ExistAsync(next.HashBlock))
+				{
+					// next block is in storage update StoredBlock
+					await this.BlockRepository.SetBlockHash(next.HashBlock);
+					this.StoredBlock = next;
+					this.ChainState.HighestPersistedBlock = this.StoredBlock;
+					continue;
+				}
+
+				// check if the next block is in pending storage
+				BlockPair insert;
+				if (this.PendingStorage.TryGetValue(next.HashBlock, out insert))
+				{
 					// if in IBD and batch will not be full then wait for more blocks
 					if (this.ChainState.IsInitialBlockDownload && !disposemode)
 						if (this.PendingStorage.Skip(0).Count() < batchsize) // ConcurrentDictionary perf
 							break;

+					if (!this.PendingStorage.TryRemove(next.HashBlock, out insert))
+						break;
+
 					var tostore = new List<BlockPair>(new[] { insert });
 					var storebest = next;
 					foreach (var index in Enumerable.Range(1, batchsize - 1))
-				    {
+					{
 						var old = next;
 						next = this.chain.GetBlock(next.Height + 1);

@@ -183,38 +186,38 @@
 						await Task.Delay(pushIntervalIBD, token);

 					continue;
-			    }
+				}

 				if(disposemode)
 					break;

-			    // block is not in store and not in pending
-		        // download the block or blocks
-		        // find a batch of blocks to download
-		        var todownload = new List<ChainedBlock>(new[] {next});
-		        var downloadbest = next;
-		        foreach (var index in Enumerable.Range(1, batchsize - 1))
-		        {
-			        var old = next;
-		            next = this.chain.GetBlock(old.Height + 1);
-
-		            // stop if at the tip or block is already in store or pending insertion
-		            if (next == null) break;
+				// block is not in store and not in pending
+				// download the block or blocks
+				// find a batch of blocks to download
+				var todownload = new List<ChainedBlock>(new[] {next});
+				var downloadbest = next;
+				foreach (var index in Enumerable.Range(1, batchsize - 1))
+				{
+					var old = next;
+					next = this.chain.GetBlock(old.Height + 1);
+
+					// stop if at the tip or block is already in store or pending insertion
+					if (next == null) break;
 					if (next.Header.HashPrevBlock != old.HashBlock) break;
 					if (next.Height > this.ChainState.HighestValidatedPoW?.Height) break;
 					if (this.PendingStorage.ContainsKey(next.HashBlock)) break;
 					if (await this.BlockRepository.ExistAsync(next.HashBlock)) break;

-		            todownload.Add(next);
+					todownload.Add(next);
 					downloadbest = next;
-		        }
-
-		        // download and store missing blocks
-		        var blocks = await this.blockPuller.AskBlocks(token, todownload.ToArray());
-		        await this.BlockRepository.PutAsync(downloadbest.HashBlock, blocks);
-		        this.StoredBlock = downloadbest;
-		        this.ChainState.HighestPersistedBlock = this.StoredBlock;
-		    }
+				}
+
+				// download and store missing blocks
+				var blocks = await this.blockPuller.AskBlocks(token, todownload.ToArray());
+				await this.BlockRepository.PutAsync(downloadbest.HashBlock, blocks);
+				this.StoredBlock = downloadbest;
+				this.ChainState.HighestPersistedBlock = this.StoredBlock;
+			}
 		}
 	}
 }


No DocType für installation spaces

No DocType für installation spaces

--- Suplanus.Sepla/Objects/LocationIdentifier.cs
+++ Suplanus.Sepla/Objects/LocationIdentifier.cs
@@ -56,7 +56,6 @@
       this.Plant = GetPageProperty(installationSpace.Properties.DESIGNATION_FULLPLANT);
       this.Location = GetPageProperty(installationSpace.Properties.DESIGNATION_FULLLOCATION);
       this.UserDefinied = GetPageProperty(installationSpace.Properties.DESIGNATION_FULLUSERDEFINED);
-      this.DocType = GetPageProperty(installationSpace.Properties.DESIGNATION_FULLDOCTYPE);
     }

     private string GetPageProperty(PropertyValue propertyValue)


moved code to subcontrols

moved code to subcontrols

--- TCC.Core/Controls/Classes/WarriorBar.xaml.cs
+++ TCC.Core/Controls/Classes/WarriorBar.xaml.cs
@@ -3,14 +3,11 @@
 using System.Runtime.CompilerServices;
 using System.Threading.Tasks;
 using System.Windows;
-using System.Windows.Media;
 using System.Windows.Media.Animation;
-using System.Windows.Media.Effects;
 using TCC.Annotations;
 using TCC.Data;
 using TCC.Data.Pc;
 using TCC.ViewModels;
-using Brushes = System.Windows.Media.Brushes;

 namespace TCC.Controls.Classes
 {
@@ -46,12 +43,12 @@
             _dc = DataContext as WarriorBarManager;
             if (_dc != null)
             {
-                _dc.TraverseCut.PropertyChanged += AnimateTraverseCut;
-                _dc.TraverseCut.ToZero += CooldownTraverseCut;
-                _dc.EdgeCounter.PropertyChanged += EdgeCounter_PropertyChanged;
-                _tc = new DoubleAnimation(1, TimeSpan.FromMilliseconds(200)) {EasingFunction = new QuadraticEase()};
-                _tc.Completed += (_, __) => _tcAnimating = false;
-                _tcCd = new DoubleAnimation(0, TimeSpan.FromMilliseconds(0));
+               //_dc.TraverseCut.PropertyChanged += AnimateTraverseCut;
+               //_dc.TraverseCut.ToZero += CooldownTraverseCut;
+                //_dc.EdgeCounter.PropertyChanged += EdgeCounter_PropertyChanged;
+                //_tc = new DoubleAnimation(1, TimeSpan.FromMilliseconds(200)) {EasingFunction = new QuadraticEase()};
+                //_tc.Completed += (_, __) => _tcAnimating = false;
+                //_tcCd = new DoubleAnimation(0, TimeSpan.FromMilliseconds(0));
                 SessionManager.CurrentPlayer.PropertyChanged += CheckStanceWarning;
                 _dc.Stance.PropertyChanged += CheckStanceWarning;
             }


Onclick event handler for 2d grid

Onclick event handler for 2d grid


Add bing map keys with fake default

Add bing map keys with fake default

--- TestAppUWP/Samples/Map/MapServiceSettings.cs
+++ TestAppUWP/Samples/Map/MapServiceSettings.cs
@@ -2,6 +2,6 @@
 {
     public class MapServiceSettings
     {
-        public static string Token="Pippo";
+        public static string Token = string.Empty;
     }
 }


TextRendererOptionsTest#FormatGetTestメソッドを追加

--- UnitTest/Graphics/TextRendererOptionsTest.cs
+++ UnitTest/Graphics/TextRendererOptionsTest.cs
@@ -82,5 +82,18 @@
                 Assert.AreEqual(font, options.Font);
             }
         }
+
+        [TestMethod]
+        public void FormatGetTest()
+        {
+            const int LineHeight = 10;
+
+            using (FontLoader fontLoader = new FontLoader(NanoDigiPath))
+            using (Font font = new Font(fontLoader.Families[0], 10.0f))
+            using (TextRendererOptions options = new TextRendererOptions(font, LineHeight))
+            {
+                Assert.IsNotNull(options.Format);
+            }
+        }
     }
 }


Make it possible to easily over render the ends of 3d Lines

--- RenderOpenGl/RenderMeshToGl.cs
+++ RenderOpenGl/RenderMeshToGl.cs
@@ -53,7 +53,19 @@
 			return frustum2;
 		}

-
+		public static void ExtendLineEnds(ref Vector3 start, ref Vector3 end, double length)
+		{
+			// extend both sides
+			ExtendLineEnd(start, ref end, length);
+			ExtendLineEnd(end, ref start, length);
+		}
+
+		public static void ExtendLineEnd(Vector3 start, ref Vector3 end, double length)
+		{
+			// extend the start position by the length in the direction of the line
+			var direction = (end - start).GetNormal();
+			end += direction * length;
+		}

 		public static void PrepareFor3DLineRender(bool doDepthTest)
 		{
@@ -143,27 +155,27 @@
 		/// <param name="width"></param>
 		public static void Render3DLine(WorldView world, Vector3 start, Vector3 end, Color color, bool doDepthTest = true, double width = 1)
 		{
-			Render3DLine(GetClippingFrustum(world), world, start, end, color, doDepthTest, width);
+			Render3DLine(world, GetClippingFrustum(world), start, end, color, doDepthTest, width);
 		}

 		/// <summary>
 		/// Draw a line in the scene in 3D but scale it such that it appears as a 2D line in the view.
 		/// </summary>
+		/// <param name="world"></param>
 		/// <param name="clippingFrustum">This is a cache of the frustum from world.
 		/// Much faster to pass this way if drawing lots of lines.</param>
-		/// <param name="world"></param>
 		/// <param name="start"></param>
 		/// <param name="end"></param>
 		/// <param name="color"></param>
 		/// <param name="doDepthTest"></param>
 		/// <param name="width"></param>
-		public static void Render3DLine(Frustum clippingFrustum, WorldView world, Vector3 start, Vector3 end, Color color, bool doDepthTest = true, double width = 1)
+		public static void Render3DLine(this WorldView world, Frustum clippingFrustum, Vector3 start, Vector3 end, Color color, bool doDepthTest = true, double width = 1)
 		{
 			PrepareFor3DLineRender(doDepthTest);
-			Render3DLineNoPrep(clippingFrustum, world, start, end, color, width);
-		}
-
-		public static void Render3DLineNoPrep(Frustum clippingFrustum, WorldView world, Vector3 start, Vector3 end, Color color, double width = 1)
+			world.Render3DLineNoPrep(clippingFrustum, start, end, color, width);
+		}
+
+		public static void Render3DLineNoPrep(this WorldView world, Frustum clippingFrustum, Vector3 start, Vector3 end, Color color, double width = 1)
 		{
 			if (clippingFrustum.ClipLine(ref start, ref end))
 			{


--- src/Admin/HostedServices/DatabaseMigrationHostedService.cs
+++ src/Admin/HostedServices/DatabaseMigrationHostedService.cs
@@ -29,6 +29,9 @@

         public virtual async Task StartAsync(CancellationToken cancellationToken)
         {
+            // Wait 20 seconds to allow database to come online
+            await Task.Delay(20000);
+
             var maxMigrationAttempts = 10;
             for(var i = 1; i <= maxMigrationAttempts; i++)
             {


Need to catch reflection exception and re-throw inner exception

--- src/Aggregates.NET.Domain/Internal/DefaultRouteResolver.cs
+++ src/Aggregates.NET.Domain/Internal/DefaultRouteResolver.cs
@@ -52,7 +52,18 @@
                 if (!methods.Any())
                     return null;

-                return methods.ToDictionary(x => x.Name, x => (Action<IEventSource, Object>)((es, m) => x.Invoke(es, new[] { m })));
+                return methods.ToDictionary(x => x.Name, x => (Action<IEventSource, Object>)((es, m) =>
+                {
+                    try
+                    {
+                        x.Invoke(es, new[] { m });
+                    }
+                    catch (TargetInvocationException e)
+                    {
+                        throw e.InnerException;
+                    }
+                }));
+
             });
         }


Move hardcoded message to resource file

Move hardcoded message to resource file

--- src/Arkivverket.Arkade.Core/Identify/TestSessionFactory.cs
+++ src/Arkivverket.Arkade.Core/Identify/TestSessionFactory.cs
@@ -3,6 +3,7 @@
 using Arkivverket.Arkade.Core.Base;
 using Arkivverket.Arkade.Core.Base.Addml.Definitions;
 using Arkivverket.Arkade.Core.Logging;
+using Arkivverket.Arkade.Core.Resources;
 using Arkivverket.Arkade.Core.Testing.Noark5;
 using Arkivverket.Arkade.Core.Util;
 using Serilog;
@@ -98,7 +99,7 @@
             }
             catch (Exception exception)
             {
-                var message = "Reading file " + archive.AddmlXmlUnit.File.Name + " failed: " + exception.Message;
+                var message = string.Format(ExceptionMessages.FileNotRead, archive.AddmlXmlUnit.File.Name) + " " + exception.Message;
                 _log.Warning(message);//exception, message);
                 _statusEventHandler.RaiseEventOperationMessage(null, message, OperationMessageStatus.Error);
             }


Fix copy pasta error.

Fix copy pasta error.

--- src/Avalonia.Controls/Primitives/HeaderedContentControl.cs
+++ src/Avalonia.Controls/Primitives/HeaderedContentControl.cs
@@ -27,7 +27,7 @@
         /// </summary>
         static HeaderedContentControl()
         {
-            ContentProperty.Changed.AddClassHandler<HeaderedContentControl>((x, e) => x.HeaderChanged(e));
+            HeaderProperty.Changed.AddClassHandler<HeaderedContentControl>((x, e) => x.HeaderChanged(e));
         }

         /// <summary>


Added missing AddDoc(int) method to BitsetDocSet.

--- src/BoboBrowse.Net/BoboBrowse.Net/DocIdSet/BitsetDocSet.cs
+++ src/BoboBrowse.Net/BoboBrowse.Net/DocIdSet/BitsetDocSet.cs
@@ -22,7 +22,12 @@
             _bs = new BitSet(nbits);
         }

-        public int Size
+        public virtual void AddDoc(int docid)
+        {
+            _bs.Set(docid);
+        }
+
+        public virtual int Size
         {
             get { return _bs.Cardinality(); }
         }


Removed Sierra from text

Removed Sierra from text

--- Chalmers.ILL/Views/Partials/Chalmers.ILL.OrderItem.cshtml
+++ Chalmers.ILL/Views/Partials/Chalmers.ILL.OrderItem.cshtml
@@ -35,7 +35,7 @@
                 {

-
 Låntagardata från Sierra saknas!

+
 Låntagardata saknas!

                 }


chore: removing todo

chore: removing todo

--- SMLogging/TraceListenerBase.cs
+++ SMLogging/TraceListenerBase.cs
@@ -488,7 +488,7 @@

         private bool _hasConfiguration = false;
         private bool _isInitialized = false;
-        private readonly object _initializeLock = new object(); //TODO: static?
+        private readonly object _initializeLock = new object();

         private const string _defaultTraceFormat = "{DateTime:yyyy-MM-dd} {DateTime:HH:mm:ss.FFF} {Message}";
         private const string _defaultTraceDataDelimiter = " ";


fix boolean logic mistake in RbacHelper check for valid puid

--- SimpleWAWS/Code/RbackHelper.cs
+++ SimpleWAWS/Code/RbackHelper.cs
@@ -28,8 +28,8 @@
         }
         public static async Task<bool> AddRbacUser(string puidOrAltSec, string emailAddress, Site site)
         {
-            if (!string.IsNullOrEmpty(puidOrAltSec) &&
-                puidOrAltSec.IndexOf("live.com", StringComparison.OrdinalIgnoreCase) != -1)
+            if (string.IsNullOrEmpty(puidOrAltSec) ||
+                puidOrAltSec.IndexOf("live.com", StringComparison.OrdinalIgnoreCase) == -1)
             {
                 return false;
             }


Fix Error Description

Fix Error Description


TestProjectPattern dependent on IsDotNetCoreBuild

--- Cake.Recipe/Content/parameters.cake
+++ Cake.Recipe/Content/parameters.cake
@@ -300,7 +300,7 @@
         SolutionDirectoryPath = solutionDirectoryPath ?? SourceDirectoryPath.Combine(Title);
         RootDirectoryPath = rootDirectoryPath ?? context.MakeAbsolute(context.Environment.WorkingDirectory);
         TestDirectoryPath = testDirectoryPath ?? sourceDirectoryPath;
-        TestProjectPattern = testProjectPattern ?? "/**/*Tests.csproj";
+        TestProjectPattern = testProjectPattern ?? (IsDotNetCoreBuild ? "/**/*Tests.csproj" : "/**/*Tests.dll");
         ResharperSettingsFileName = resharperSettingsFileName ?? string.Format("{0}.sln.DotSettings", Title);
         RepositoryOwner = repositoryOwner ?? string.Empty;
         RepositoryName = repositoryName ?? Title;


Handling UTC dates in java specific format

--- Camunda.Api.Client/CamundaClient.cs
+++ Camunda.Api.Client/CamundaClient.cs
@@ -88,6 +88,11 @@

         private class CustomIsoDateTimeConverter : Newtonsoft.Json.Converters.IsoDateTimeConverter
         {
+            public CustomIsoDateTimeConverter()
+            {
+                Culture = CultureInfo.InvariantCulture;
+            }
+
             public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
             {
                 if (value is DateTime dateTime)
@@ -104,6 +109,27 @@
                 {
                     base.WriteJson(writer, value, serializer);
                 }
+            }
+
+            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+            {
+                bool nullable = objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof(Nullable<>);
+
+                if (reader.TokenType == JsonToken.String)
+                {
+                    string dateText = reader.Value.ToString();
+
+                    if (string.IsNullOrEmpty(dateText) && nullable)
+                        return null;
+
+                    if (dateText.EndsWith("UTC"))
+                    {
+                        if (DateTime.TryParseExact(dateText.Replace("UTC", "Z"), "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFK", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var dt))
+                            return dt;
+                    }
+                }
+
+                return base.ReadJson(reader, objectType, existingValue, serializer);
             }
         }


Update _Layout.cshtml

Update _Layout.cshtml

--- Caritas/Views/Shared/_Layout.cshtml
+++ Caritas/Views/Shared/_Layout.cshtml
@@ -4,10 +4,13 @@
 <head>
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link href="~/Content/bootstrap.css" rel="stylesheet" />
+    <link href="~/Content/site.css" rel="stylesheet" />
     <title>@ViewBag.Title | Caritas University</title>
     @Styles.Render("~/Content/css")
     @Scripts.Render("~/bundles/modernizr")
     <link href="~/Content/jquery-ui.css" rel="stylesheet" />
+
     <link href="~/css/metro-bootstrap.css" rel="stylesheet" />


Added open drive letter.

Added open drive letter.

--- Source/VhdAttach/MainForm.cs
+++ Source/VhdAttach/MainForm.cs
@@ -521,7 +521,21 @@
                 }
             } catch { }
             if (attachedDevice != null) {
-                var volumes = Volume.GetVolumesOnPhysicalDrive(attachedDevice);
+                var volumes = new List<Volume>(Volume.GetVolumesOnPhysicalDrive(attachedDevice));
+                var availableVolumes = new List<Volume>();
+                foreach (var volume in volumes) {
+                    if (volume.DriveLetter2 != null) {
+                        availableVolumes.Add(volume);
+                    }
+                }
+
+                if (availableVolumes.Count > 0) {
+                    mnuTools.DropDownItems.Add(new ToolStripSeparator());
+                    foreach (var volume in availableVolumes) {
+                        mnuTools.DropDownItems.Add(new ToolStripMenuItem("Open " + volume.DriveLetter3, null, mnuOpenDriveLetter_Click) { Tag = volume });
+                    }
+                }
+
                 if (volumes.Count > 0) {
                     mnuTools.DropDownItems.Add(new ToolStripSeparator());
                     foreach (var volume in volumes) {
@@ -583,6 +597,16 @@
                 doNotUpdateAutoMountChecked = true;
                 mnuAutoMount.Checked = isAutoMount;
                 doNotUpdateAutoMountChecked = false;
+            }
+        }
+
+        private void mnuOpenDriveLetter_Click(object sender, EventArgs e) {
+            var volume = (Volume)(((ToolStripMenuItem)sender).Tag);
+            var drive = new DriveInfo(volume.DriveLetter3);
+            if (drive.IsReady) {
+                Process.Start(volume.DriveLetter3);
+            } else {
+                Process.Start("explorer.exe", "/select," + volume.DriveLetter3);
             }
         }


Add support for shallow bulk copying

Add support for shallow bulk copying

--- Coda/Coda.Data.Sql/SqlBulkCopier.cs
+++ Coda/Coda.Data.Sql/SqlBulkCopier.cs
@@ -17,10 +17,10 @@
             typeof(DateTime), typeof(DateTimeOffset), typeof(float), typeof(byte)
         };

-        public SqlBulkCopier(SqlConnection db, string tableName)
+        public SqlBulkCopier(SqlConnection db, string tableName, bool deepProperties = true)
         {
             BulkCopy = new SqlBulkCopy(db);
-            Initialise(tableName);
+            Initialise(tableName, deepProperties);
         }

         protected virtual bool IsMappable(PropertyInfo property)
@@ -30,13 +30,13 @@
             return (!_mappableTypes.Contains(baseType) && !baseType.IsEnum);
         }

-        public void Initialise(string tableName)
+        public void Initialise(string tableName, bool deepProperties = true)
         {
             BulkCopy.DestinationTableName = tableName;

             // Dynamically construct a datatable and force name-based column mapping
             InternalTable = new DataTable();
-            var properties = typeof(TTableType).GetProperties();
+            var properties = deepProperties ? typeof(TTableType).GetProperties() : typeof(TTableType).GetProperties(BindingFlags.DeclaredOnly);
             foreach (var property in properties)
             {
                 var nullableBaseType = Nullable.GetUnderlyingType(property.PropertyType);


Wrapped a RNG in a using block for the dispose method.

--- Coelacanth.Lib/PasswordGenerator.cs
+++ Coelacanth.Lib/PasswordGenerator.cs
@@ -66,13 +66,15 @@

             if (availableCharacters.Length > 0)
             {
-                var randomNumberGenerator = new RNGCryptoServiceProvider();
-                var randomNumbers = new byte[PasswordLength];
-                randomNumberGenerator.GetBytes(randomNumbers);
+                using (var randomNumberGenerator = new RNGCryptoServiceProvider())
+                {
+                    var randomNumbers = new byte[PasswordLength];
+                    randomNumberGenerator.GetBytes(randomNumbers);

-                foreach (var randomNumber in randomNumbers)
-                {
-                    newPassword.Append(availableCharacters[randomNumber % availableCharacters.Length]);
+                    foreach (var randomNumber in randomNumbers)
+                    {
+                        newPassword.Append(availableCharacters[randomNumber % availableCharacters.Length]);
+                    }
                 }
             }


Fixing UI vAlign

Fixing UI vAlign

--- unity/Assets/Scripts/Content/QuestData.cs
+++ unity/Assets/Scripts/Content/QuestData.cs
@@ -464,11 +464,11 @@
             {
                 if (data["valign"].Equals("top"))
                 {
-                    hAlign = -1;
+                    vAlign = -1;
                 }
                 if (data["valign"].Equals("bottom"))
                 {
-                    hAlign = 1;
+                    vAlign = 1;
                 }
             }
         }


minor

minor

--- MbCache/Logic/CacheAdapter.cs
+++ MbCache/Logic/CacheAdapter.cs
@@ -6,7 +6,7 @@
 namespace MbCache.Logic
 {
 	///
-	/// Calls <see cref="ICache"/>, handles null in cache.
+	/// Calls <see cref="ICache"/>
 	///
 	[Serializable]
 	public class CacheAdapter


Small changes.

Small changes.


Something something bigger shotgun debugger

--- ModCore/Commands/Reminders.cs
+++ ModCore/Commands/Reminders.cs
@@ -1,258 +1,308 @@
-using System;
-using System.Collections.Generic;
+using System;
 using System.Linq;
+using System.Threading;
 using System.Threading.Tasks;
-using DSharpPlus.CommandsNext;
-using DSharpPlus.CommandsNext.Attributes;
+using DSharpPlus;
 using DSharpPlus.Entities;
-using DSharpPlus.Interactivity;
-using Humanizer;
-using Humanizer.Localisation;
+using DSharpPlus.EventArgs;
 using ModCore.Database;
 using ModCore.Entities;
-using ModCore.Listeners;
 using ModCore.Logic;
-
-namespace ModCore.Commands
+using System.Collections.Generic;
+
+namespace ModCore.Listeners
 {
-    [Group("reminder", CanInvokeWithoutSubcommand = true), Aliases("remindme"), Description("Commands for managing your reminders.")]
-    public class Reminders
+    public static class Timers
     {
-        private const string ReminderTut = @"
-Sets a new reminder. The time span parser is fluent and will understand many different formats of reminders:
-
-<Time span>, <Message>
-[in] <Time span> to <Message>
-<Short time span> <Message>
-
-Where ""Time span"" represents a time period or a relative date (optionally with time of day specified), such as
-\* Tomorrow at 2:00 PM Chicago time
-\* Next fortnight
-\* 8 hours 20 minutes
-
-A ""Short time span"" represents a time span represented in a single word (we call this a token), such as
-\* 2h
-\* 4m5s
-\* 15min
-\* 30min55sec
-
-See these examples:
-
-```
-+remindme next week to walk the dog
-+remindme tomorrow, fix socket
-+remindme 2h5m watch new stranger things episode
-+remindme 8 hours wake up
-+remindme in an hour to eat something
-+remindme in nine months to have a baby
-```
-
-Note that even if your arguments don't fit the grammar denoted above, they might still be parsed fine.
-If in doubt, just try it! You can always clear the reminders later.
-";
-        public SharedData Shared { get; }
-        public DatabaseContextBuilder Database { get; }
-        public InteractivityExtension Interactivity { get; }
-
-        public Reminders(SharedData shared, DatabaseContextBuilder db, InteractivityExtension interactive)
-        {
-            this.Shared = shared;
-            this.Database = db;
-            this.Interactivity = interactive;
-        }
-
-        [Description(ReminderTut)]
-        public async Task ExecuteGroupAsync(CommandContext ctx, [RemainingText, Description("When the reminder is to be sent.")] string dataToParse)
-        {
-            await SetAsync(ctx, dataToParse);
-        }
-
-        [Command("list"), Description("Lists your active reminders.")]
-        public async Task ListAsync(CommandContext ctx)
-        {
-            await ctx.TriggerTypingAsync();
-            DatabaseTimer[] reminders;
-            using (var db = this.Database.CreateContext())
-                reminders = db.Timers.Where(xt =>
-                    xt.ActionType == TimerActionType.Reminder && xt.GuildId == (long)ctx.Guild.Id &&
-                    xt.UserId == (long)ctx.User.Id).ToArray();
-            if (!reminders.Any())
-            {
-                await ctx.RespondAsync("You have no reminders set.");
-                return;
-            }
-
-            var rms = reminders.OrderByDescending(xt => xt.DispatchAt).ToArray();
-            var interactivity = this.Interactivity;
-            var emoji = DiscordEmoji.FromName(ctx.Client, ":alarm_clock:");
-
-            var page = 1;
-            var total = rms.Length / 5 + (rms.Length % 5 == 0 ? 0 : 1);
-            var pages = new List<Page>();
-            var cembed = new DiscordEmbedBuilder
-            {
-                Title = $"{emoji} Your currently set reminders:",
-                Footer = new DiscordEmbedBuilder.EmbedFooter
-                {
-                    Text = $"Page {page} of {total}"
-                }
-            };
-            foreach (var xr in rms)
-            {
-                var data = xr.GetData<TimerReminderData>();
-                var note = data.ReminderText;
-                if (note.Contains('\n'))
-                    note = string.Concat(note.Substring(0, note.IndexOf('\n')), "...");
-
-                cembed.AddField(
-                    $"In {(DateTimeOffset.UtcNow - xr.DispatchAt).Humanize(4, minUnit: TimeUnit.Second)} (ID: #{xr.Id})",
-                    $"{note}");
-                if (cembed.Fields.Count < 5) continue;
-                page++;
-                pages.Add(new Page {Embed = cembed.Build()});
-                cembed = new DiscordEmbedBuilder
-                {
-                    Title = $"{emoji} Your currently set reminders:",
-                    Footer = new DiscordEmbedBuilder.EmbedFooter
-                    {
-                        Text = $"Page {page} of {total}"
-                    }
-                };
-            }
-            if (cembed.Fields.Count > 0)
-                pages.Add(new Page {Embed = cembed.Build()});
-
-            if (pages.Count > 1)
-                await interactivity.SendPaginatedMessage(ctx.Channel, ctx.User, pages);
-            else
-                await ctx.RespondAsync(embed: pages.First().Embed);
-        }
-
-        [Command("set"), Description(ReminderTut)]
-        public async Task SetAsync(CommandContext ctx, [Description("When the reminder is to be sent"), RemainingText] string dataToParse)
-        {
-            await ctx.TriggerTypingAsync();
-
-            var (duration, text) = await Dates.ParseTime(dataToParse);
-            if (duration == Dates.ParsingError)
-            {
-                /* await ctx.RespondAsync(
-                     $"Sorry, there was an error parsing your reminder.\nIf you see a developer, this info might help them: \n```\n{text}```");
-                     */
-                await ctx.RespondAsync("Sorry, there was an error parsing your reminder.");
-                return;
-            }
-
-            if (string.IsNullOrWhiteSpace(text) || text.Length > 128)
-            {
-                await ctx.RespondAsync(
-                    "Reminder text must to be no longer than 128 characters, not empty and not whitespace.");
-                return;
-            }
-#if !DEBUG
-            if (duration < TimeSpan.FromSeconds(30))
-            {
-                await ctx.RespondAsync("Minimum required time span to set a reminder is 30 seconds.");
-                return;
-            }
-#endif
-
-            if (duration > TimeSpan.FromDays(365)) // 1 year is the maximum
-            {
-                await ctx.RespondAsync("Maximum allowed time span to set a reminder is 1 year.");
-                return;
-            }
-
-            var now = DateTimeOffset.UtcNow;
-            var dispatchAt = now + duration;
-
-            // create a new timer
-            var reminder = new DatabaseTimer
-            {
-                GuildId = (long) ctx.Guild.Id,
-                ChannelId = (long) ctx.Channel.Id,
-                UserId = (long) ctx.User.Id,
-                DispatchAt = dispatchAt.LocalDateTime,
-                ActionType = TimerActionType.Reminder
-            };
-            reminder.SetData(new TimerReminderData {ReminderText = text});
-            using (var db = this.Database.CreateContext())
-            {
-                db.Timers.Add(reminder);
+        [AsyncListener(EventTypes.Ready)]
+        public static async Task OnReady(ModCoreShard shard, ReadyEventArgs ea)
+        {
+            using (var db = shard.Database.CreateContext())
+            {
+                if (!db.Timers.Any())
+                    return;
+
+                var ids = ea.Client.Guilds.Select(xg => (long)xg.Key).ToArray();
+                var timers = db.Timers.Where(xt => ids.Contains(xt.GuildId)).ToArray();
+                if (!timers.Any())
+                    return;
+
+                // lock timers
+                await shard.SharedData.TimerSempahore.WaitAsync();
+
+                var now = DateTimeOffset.UtcNow;
+                var past = timers.Where(xt => xt.DispatchAt <= now.AddSeconds(30)).ToArray();
+                if (past.Any())
+                {
+                    foreach (var xt in past)
+                    {
+                        // dispatch past timers
+                        _ = DispatchTimer(new TimerData(null, xt, shard.Client, shard.Database, shard.SharedData, null));
+                    }
+
+                    db.Timers.RemoveRange(past);
+                    await db.SaveChangesAsync();
+                }
+
+                // unlock the timers
+                shard.SharedData.TimerSempahore.Release();
+
+                RescheduleTimers(shard.Client, shard.Database, shard.SharedData);
+            }
+        }
+
+        public static void TimerCallback(Task t, object state)
+        {
+            var tdata = state as TimerData;
+            var shard = tdata.Context;
+            var shared = tdata.Shared;
+
+            // lock the timers
+            shared.TimerSempahore.Wait();
+
+            // remove the timer
+            using (var db = tdata.Database.CreateContext())
+            {
+                db.Timers.Remove(tdata.DbTimer);
+                db.SaveChanges();
+
+                tdata.Shared.TimerData = null;
+            }
+
+            // release the lock
+            shared.TimerSempahore.Release();
+
+            // dispatch the timer
+            _ = Task.Run(LocalDispatch);
+
+            // schedule new one
+            RescheduleTimers(shard, tdata.Database, tdata.Shared);
+
+            Task LocalDispatch()
+                => DispatchTimer(tdata);
+        }
+
+        private static async Task DispatchTimer(TimerData tdata)
+        {
+            var timer = tdata.DbTimer;
+            var client = tdata.Context;
+            if (timer.ActionType == TimerActionType.Reminder)
+            {
+                DiscordChannel chn = null;
+                try
+                {
+                    chn = await client.GetChannelAsync((ulong)timer.ChannelId);
+                }
+                catch { }
+                if (chn == null)
+                    return;
+
+                var data = timer.GetData<TimerReminderData>();
+                var emoji = DiscordEmoji.FromName(client, ":alarm_clock:");
+                var msg = $"{emoji} <@!{(ulong)timer.UserId}>, you wanted to be reminded of the following:\n\n{data.ReminderText}";
+                await chn.SendMessageAsync(msg);
+            }
+            else if (timer.ActionType == TimerActionType.Unban)
+            {
+                var data = timer.GetData<TimerUnbanData>();
+                if (client.Guilds.Any(x => x.Key == (ulong)timer.GuildId))
+                {
+                    using (var db = tdata.Database.CreateContext())
+                    {
+                        var Guild = client.Guilds[(ulong)timer.GuildId];
+                        try
+                        {
+                            await Guild.UnbanMemberAsync((ulong)data.UserId);
+                        }
+                        catch (Exception) { }
+
+                        var settings = Guild.GetGuildSettings(db);
+                        await client.LogAutoActionAsync(Guild, db, $"Member unbanned: {data.DisplayName}#{data.Discriminator} (ID: {data.UserId})");
+                    }
+                }
+            }
+            else if (timer.ActionType == TimerActionType.Unmute)
+            {
+                var data = timer.GetData<TimerUnmuteData>();
+                if (client.Guilds.Any(x => x.Key == (ulong)timer.GuildId))
+                {
+                    using (var db = tdata.Database.CreateContext())
+                    {
+                        var Guild = client.Guilds[(ulong)timer.GuildId];
+                        var Member = await Guild.GetMemberAsync((ulong)data.UserId);
+                        var Role = (DiscordRole)null;
+                        try
+                        {
+                            Role = Guild.GetRole((ulong)data.MuteRoleId);
+                        }
+                        catch (Exception)
+                        {
+                            try
+                            {
+                                Role = Guild.GetRole(Guild.GetGuildSettings(db).MuteRoleId);
+                            }
+                            catch (Exception)
+                            {
+                                await client.LogAutoActionAsync(Guild, db, $"**[IMPORTANT]**\nFailed to unmute member: {data.DisplayName}#{data.Discriminator} (ID: {data.UserId})\nMute role does not exist!");
+                                return;
+                            }
+                        }
+                        await Member.RevokeRoleAsync(Role, "");
+                        await client.LogAutoActionAsync(Guild, db, $"Member unmuted: {data.DisplayName}#{data.Discriminator} (ID: {data.UserId})");
+                    }
+                }
+            }
+            else if (timer.ActionType == TimerActionType.Pin)
+            {
+                var data = timer.GetData<TimerPinData>();
+                if (client.Guilds.Any(x => x.Key == (ulong)timer.GuildId))
+                {
+                    using (var db = tdata.Database.CreateContext())
+                    {
+                        var Guild = client.Guilds[(ulong)timer.GuildId];
+                        var Channel = Guild.GetChannel((ulong)data.ChannelId);
+                        var Message = await Channel.GetMessageAsync((ulong)data.MessageId);
+                        await Message.PinAsync();
+                        await client.LogAutoActionAsync(Guild, db, $"Scheduled pin: Message with ID: {data.MessageId} in Channel #{Channel.Name} ({Channel.Id})");
+                    }
+                }
+            }
+            else if (timer.ActionType == TimerActionType.Unpin)
+            {
+                var data = timer.GetData<TimerPinData>();
+                if (client.Guilds.Any(x => x.Key == (ulong)timer.GuildId))
+                {
+                    using (var db = tdata.Database.CreateContext())
+                    {
+                        var Guild = client.Guilds[(ulong)timer.GuildId];
+                        var Channel = Guild.GetChannel((ulong)data.ChannelId);
+                        var Message = await Channel.GetMessageAsync((ulong)data.MessageId);
+                        await Message.UnpinAsync();
+                        await client.LogAutoActionAsync(Guild, db, $"Scheduled unpin: Message with ID: {data.MessageId} in Channel #{Channel.Name} ({Channel.Id})");
+                    }
+                }
+            }
+        }
+
+        public static TimerData RescheduleTimers(DiscordClient client, DatabaseContextBuilder database, SharedData shared)
+        {
+            DiscordChannel c = client.Guilds.First(x => x.Key == shared.StartNotify.guild).Value.GetChannel(shared.StartNotify.channel);
+            c.SendMessageAsync("In RescheduleTimers");
+            // lock the timers
+            shared.TimerSempahore.Wait();
+
+            // set a new timer
+            DatabaseTimer[] timers = null;
+            bool force = false;
+            using (var db = database.CreateContext())
+            {
+                var ids = client.Guilds.Select(xg => (long)xg.Key).ToArray();
+                timers = db.Timers.Where(xt => ids.Contains(xt.GuildId))
+                    .OrderBy(xt => xt.DispatchAt)
+                    .ToArray();
+
+                if (shared.TimerData != null)
+                    force = db.Timers.Count(xt => xt.Id == shared.TimerData.DbTimer.Id) == 0; // .Any() throws
+            }
+            c.SendMessageAsync($"Force is {force}");
+
+            var nearest = timers.FirstOrDefault();
+            if (nearest == null)
+            {
+                // there's no nearest timer
+                shared.TimerSempahore.Release();
+                return null;
+            }
+            c.SendMessageAsync("There are timers in the list");
+
+            var tdata = shared.TimerData;
+            if (tdata != null && tdata.DbTimer.Id == nearest.Id)
+            {
+                // it's the same timer
+                shared.TimerSempahore.Release();
+                return tdata;
+            }
+            c.SendMessageAsync("It's not the same timer");
+
+
+            if (CancelIfLaterThan(nearest.DispatchAt, shared, force))
+            {
+                var cts = new CancellationTokenSource();
+                var t = Task.Delay(nearest.DispatchAt - DateTimeOffset.UtcNow, cts.Token);
+                tdata = new TimerData(t, nearest, client, database, shared, cts);
+                _ = t.ContinueWith(TimerCallback, tdata, TaskContinuationOptions.OnlyOnRanToCompletion);
+                shared.TimerData = tdata;
+                c.SendMessageAsync($"{shared.TimerData.DispatchTime} - {shared.TimerData.DbTimer.GetData<TimerReminderData>().ReminderText}");
+
+            }
+
+            // release the lock
+            shared.TimerSempahore.Release();
+
+            return tdata;
+        }
+
+        public static async Task<TimerData> UnscheduleTimerAsync(DatabaseTimer timer, DiscordClient shard, DatabaseContextBuilder database, SharedData shared)
+        {
+            // lock the timers
+            await shared.TimerSempahore.WaitAsync();
+
+            // remove the requested timer
+            using (var db = database.CreateContext())
+            {
+                db.Timers.Remove(timer);
                 await db.SaveChangesAsync();
             }

-            // reschedule timers
-            Timers.RescheduleTimers(ctx.Client, this.Database, this.Shared);
-
-            var emoji = DiscordEmoji.FromName(ctx.Client, ":alarm_clock:");
-            await ctx.RespondAsync(
-                $"{emoji} Ok, in {duration.Humanize(4, minUnit: TimeUnit.Second)} I will remind you about the following:\n\n{text}");
-        }
-
-        [Command("stop"), Aliases("unset", "remove"), Description("Stops and removes a reminder.")]
-        public async Task UnsetAsync(CommandContext ctx, [Description("Which timer to stop. To get a Timer ID, use " +
-                                                                      "the `reminder list` command.")] int timerId)
-        {
-            await ctx.TriggerTypingAsync();
-
-            // find the timer
-            var reminder = Timers.FindTimer(timerId, TimerActionType.Reminder, ctx.User.Id, this.Database);
-            if (reminder == null)
-            {
-                await ctx.RespondAsync($"Timer with specified ID (#{timerId}) was not found.");
-                return;
-            }
-
-            // unschedule and reset timers
-            await Timers.UnscheduleTimerAsync(reminder, ctx.Client, this.Database, this.Shared);
-
-            var duration = reminder.DispatchAt - DateTimeOffset.Now;
-            var data = reminder.GetData<TimerReminderData>();
-            var emoji = DiscordEmoji.FromName(ctx.Client, ":ballot_box_with_check:");
-            await ctx.RespondAsync(
-                $"{emoji} Ok, timer #{reminder.Id} due in {duration.Humanize(4, minUnit: TimeUnit.Second)} was removed. The reminder's message was:\n\n{data.ReminderText}");
-        }
-
-        [Command("clear"), Description("Clears all active reminders.")]
-        public async Task ClearAsync(CommandContext ctx)
-        {
-            await ctx.TriggerTypingAsync();
-
-            await ctx.RespondAsync("Are you sure you want to clear all your active reminders? This action cannot be undone!");
-
-            var m = await this.Interactivity.WaitForMessageAsync(x => x.ChannelId == ctx.Channel.Id && x.Author.Id == ctx.Member.Id, TimeSpan.FromSeconds(30));
-
-            if (m == null)
-            {
-                await ctx.RespondAsync("Timed out.");
-            }
-            else if (InteractivityUtil.Confirm(m))
-            {
-                await ctx.RespondAsync("Brace for impact!");
-                await ctx.TriggerTypingAsync();
-                using (var db = this.Database.CreateContext())
-                {
-                    List<DatabaseTimer> timers = db.Timers.Where(xt => xt.ActionType == TimerActionType.Reminder && xt.UserId == (long)ctx.User.Id).ToList();
-
-                    var count = timers.Count;
-                    await Timers.UnscheduleTimersAsync(timers, ctx.Client, this.Database, this.Shared);
-
-
-                    await ctx.RespondAsync("Alright, cleared " + count + " timers.");
-                }
-
-            }
-            else
-            {
-                await ctx.RespondAsync("Never mind then, maybe next time.");
-            }
-        }
-
-        [Command("test"), Description("WIP.")]
-        public async Task TestAsync(CommandContext ctx)
-        {
-            await ctx.RespondAsync($"Timer will dispatch at: `{Shared.TimerData.DispatchTime}`, and has the message ```{Shared.TimerData.DbTimer.GetData<TimerReminderData>().ReminderText}```.");
+            // release the lock
+            shared.TimerSempahore.Release();
+
+            // trigger a reschedule
+            return RescheduleTimers(shard, database, shared);
+        }
+
+        public static async Task<TimerData> UnscheduleTimersAsync(List<DatabaseTimer> timers, DiscordClient shard, DatabaseContextBuilder database, SharedData shared)
+        {
+            // lock the timers
+            await shared.TimerSempahore.WaitAsync();
+
+            // remove the requested timers
+            using (var db = database.CreateContext())
+            {
+                db.Timers.RemoveRange(timers);
+                await db.SaveChangesAsync();
+            }
+
+            // release the lock
+            shared.TimerSempahore.Release();
+
+            // trigger a reschedule
+            return RescheduleTimers(shard, database, shared);
+        }
+
+        public static DatabaseTimer FindNearestTimer(TimerActionType actionType, ulong userId, ulong channelId, ulong guildId, DatabaseContextBuilder database)
+        {
+            using (var db = database.CreateContext())
+                return db.Timers.FirstOrDefault(xt => xt.ActionType == actionType && xt.UserId == (long)userId && xt.ChannelId == (long)channelId && xt.GuildId == (long)guildId);
+        }
+
+        public static DatabaseTimer FindTimer(int id, TimerActionType actionType, ulong userId, DatabaseContextBuilder database)
+        {
+            using (var db = database.CreateContext())
+                return db.Timers.FirstOrDefault(xt => xt.Id == id && xt.ActionType == actionType && xt.UserId == (long)userId);
+        }
+
+        private static bool CancelIfLaterThan(DateTimeOffset dto, SharedData shared, bool force)
+        {
+            // check if a timer is going
+            if (force || shared.TimerData == null || shared.TimerData.DispatchTime >= dto)
+            {
+                var xtdata = shared.TimerData;
+                xtdata?.Cancel?.Cancel();
+                return true;
+            }
+
+            return false;
         }
     }
 }


Clean up TODO: add difficulty UI option

Clean up TODO: add difficulty UI option

--- OthelloWPF/MainWindow.xaml.cs
+++ OthelloWPF/MainWindow.xaml.cs
@@ -15,7 +15,6 @@
 {
     /// <summary>
     /// Interaction logic for MainWindow.xaml
-    /// TODO: add difficulty configurability UI.
     /// TODO: add a window that shows the game moves by both players.
     /// </summary>
     public partial class MainWindow : Window


Failのテストを一つにまとめた

Failのテストを一つにまとめた

--- ParsecSharpTest/ParserTest.cs
+++ ParsecSharpTest/ParserTest.cs
@@ -102,19 +102,11 @@
             parser.Parse(source).CaseOf(
                 fail => fail.ToString().Is("Parser Fail (Line: 1, Column: 1): Unexpected \"a\""),
                 success => Assert.Fail());
-        }
-
-        [TestMethod]
-        public void FailTest1()
-        {
-            // 失敗したという結果を返すパーサを作成します。
-            // エラーメッセージを記述することができます。
-
-            var parser = Fail<Unit>(_ => "errormessagetest");
-
-            var source = _abcdEFGH;
-            var result = parser.Parse(source);
-            parser.Parse(source).CaseOf(
+
+            // エラーメッセージを記述することができるオーバーロード。
+            var parser2 = Fail<Unit>(_ => "errormessagetest");
+
+            parser2.Parse(source).CaseOf(
                 fail => fail.ToString().Is("Parser Fail (Line: 1, Column: 1): errormessagetest"),
                 success => Assert.Fail());
         }


Doesn't ignore xsi: attributes (from Nels_P_Olsen)

--- Parsers/StandardTypeParser.cs
+++ Parsers/StandardTypeParser.cs
@@ -49,7 +49,8 @@
                 return;

             //   don't include these in the xsd
-            if (atts[0].Name.ToLower() == "xmlns")
+            string attName = atts[0].Name.ToLower();
+            if (attName.StartsWith("xmlns") || attName.StartsWith("xsi:"))
                 return;

             //  this should be a simple built in type, but if we can't


getToken is now setCurrentToken

getToken is now setCurrentToken

This makes it more clear the current token is being set, as before, the
current token was not always being set.  While this fixes no known bugs,
it ensures synchronization between the current byte and the current token.

--- Pdoxcl2Sharp/ParadoxParser.cs
+++ Pdoxcl2Sharp/ParadoxParser.cs
@@ -51,28 +51,29 @@
             return c == SPACE || (c >= HORIZONTAL_TAB && c <= CARRIAGE_RETURN);
         }

-        private static LexerToken getToken(byte c)
+        private LexerToken setCurrentToken(byte c)
         {
             switch (c)
             {
                 case EQUALS:
-                    return LexerToken.Equals;
+                    return currentToken = LexerToken.Equals;
                 case QUOTE:
-                    return LexerToken.Quote;
+                    return currentToken = LexerToken.Quote;
                 case LEFT_CURLY:
-                    return LexerToken.LeftCurly;
+                    return currentToken = LexerToken.LeftCurly;
                 case RIGHT_CURLY:
-                    return LexerToken.RightCurly;
+                    return currentToken = LexerToken.RightCurly;
                 case LEFTPARANTHESIS:
-                    return LexerToken.LeftParanthesis;
+                    return currentToken = LexerToken.LeftParanthesis;
                 case RIGHTPARANTHESIS:
-                    return LexerToken.RightParanthesis;
+                    return currentToken = LexerToken.RightParanthesis;
                 case COMMENT:
                 case EXCLAMATION:
+                    return currentToken = LexerToken.Comment;
                 case COMMA:
-                    return LexerToken.Comment;
+                    return currentToken = LexerToken.Comma;
                 default:
-                    return LexerToken.Untyped;
+                    return currentToken = LexerToken.Untyped;
             }
         }

@@ -165,9 +166,7 @@
             while (IsSpace(currentByte = readByte()) && !eof)
                 ;

-            currentToken = getToken(currentByte);
-
-            switch (currentToken)
+            switch (setCurrentToken(currentByte))
             {
                 case LexerToken.Comment:
                     while ((currentByte = readByte()) != NEWLINE && !eof)
@@ -228,7 +227,7 @@
                     do
                     {
                         stringBuffer.Append((char)currentByte);
-                    } while (!IsSpace(currentByte = readByte()) && getToken(currentByte) == LexerToken.Untyped && !eof);
+                    } while (!IsSpace(currentByte = readByte()) && setCurrentToken(currentByte) == LexerToken.Untyped && !eof);

                     return saveBufferThenClear();
                 default:
@@ -241,7 +240,7 @@
             int result = 0;
             bool negative = false;

-            while ((IsSpace(currentByte = readByte()) || getToken(currentByte) != LexerToken.Untyped) && !eof)
+            while ((IsSpace(currentByte = readByte()) || setCurrentToken(currentByte) != LexerToken.Untyped) && !eof)
                 ;

             if (eof)
@@ -259,7 +258,7 @@
                     negative = true;
                 }
                 //TODO: If another character has been encountered throw an error
-            } while (!IsSpace(currentByte = readByte()) && getToken(currentByte) == LexerToken.Untyped && !eof);
+            } while (!IsSpace(currentByte = readByte()) && setCurrentToken(currentByte) == LexerToken.Untyped && !eof);

             return (negative) ? -result : result;
         }


--- Plugin/DNPlugin/PluginCore.cs
+++ Plugin/DNPlugin/PluginCore.cs
@@ -28,11 +28,11 @@
                 throw new NotSupportedException($"{nameof(previousResult)} is not {nameof(BitmapExecutorResult)}");
             var act = actions.SubActions.Cast<PluginCompareImgAction>().First();

-            var img1 = ((BitmapExecutorResult)previousResult).Bitmap;
-            var img2 = (Bitmap)Image.FromFile(act.SamplePath);
+            var img1 = ((BitmapExecutorResult) previousResult).Bitmap;
+            var img2 = (Bitmap) Image.FromFile(act.SamplePath);
             //2) - resize
-            var w = (img1.Width + img2.Width) / 2;
-            var h = (img1.Height + img2.Height) / 2;
+            var w = (img1.Width + img2.Width)/2;
+            var h = (img1.Height + img2.Height)/2;
             img1 = ImgHelpers.ResizeImg(img1, w, h);
             img2 = ImgHelpers.ResizeImg(img2, w, h);
             //3) GrayScale
@@ -53,9 +53,12 @@
             devRes.Threshold(4);

             var s = devRes.GetMaxIslandSize();
-            var procent = (s * 100) / (w * h);
+            var procent = (s*100)/(w*h);
 #if DEBUG
-            devRes.ToBitmap().Save($"{Name}/debug.png", ImageFormat.Png);
+            try
+            {
+                devRes.ToBitmap().Save($"{Name}/debug.png", ImageFormat.Png);
+            }catch{}
 #endif
             if (procent > act.Procent)
                 return new BooleanExecutorResult(true);