#14898 fix hydration ordering

#14898 fix hydration ordering

--- Cake.DocumentDb/Operations/Hydrations.cs
+++ Cake.DocumentDb/Operations/Hydrations.cs
@@ -41,257 +41,239 @@

             var operation = new DocumentOperations(settings.Connection, context);

-            var groupedHydrations = hydrations.OrderBy(h => h.Attribute.Timestamp)
-                                              .GroupBy(m => m.Task.DatabaseName + "." + m.Task.CollectionName);
-
-            foreach (var groupedHydration in groupedHydrations)
-            {
-                var key = groupedHydration.Key.Split('.');
+            var orderedHydrations = hydrations.OrderBy(h => h.Attribute.Timestamp);
+            foreach (var hydration in orderedHydrations)
+            {
                 var versionInfo = operation.GetVersionInfo(
-                    key[0],
-                    key[1]);
-
-                foreach (var hydration in groupedHydration)
-                {
-                    var task = hydration.Task;
-
+                    hydration.Task.DatabaseName,
+                    hydration.Task.CollectionName);
+                var task = hydration.Task;
+
+                context.Log.Write(Verbosity.Normal, LogLevel.Information,
+                    "Running Hydration: " + task.Description + " On Collection: " + task.CollectionName +
+                    " On Database: " + task.DatabaseName);
+
+                if (versionInfo.ProcessedMigrations.Any(pm =>
+                    pm.Name == hydration.GetType().Name &&
+                    pm.Timestamp == hydration.Attribute.Timestamp))
+                {
                     context.Log.Write(Verbosity.Normal, LogLevel.Information,
-                        "Running Hydration: " + task.Description + " On Collection: " + task.CollectionName +
-                        " On Database: " + task.DatabaseName);
-
-                    if (versionInfo.ProcessedMigrations.Any(pm =>
-                        pm.Name == hydration.GetType().Name &&
-                        pm.Timestamp == hydration.Attribute.Timestamp))
+                        "Hydration: " + task.Description + " On Collection: " + task.CollectionName +
+                        " On Database: " + task.DatabaseName + " Has Already Been Executed");
+                    continue;
+                }
+
+                var data = new Dictionary<string, IList<dynamic>>();
+
+                if (task.AdditionalSqlStatements != null)
+                {
+                    foreach (var sqlStatement in task.AdditionalSqlStatements)
                     {
                         context.Log.Write(Verbosity.Normal, LogLevel.Information,
-                            "Hydration: " + task.Description + " On Collection: " + task.CollectionName +
-                            " On Database: " + task.DatabaseName + " Has Already Been Executed");
-                        continue;
-                    }
-
-                    var data = new Dictionary<string, IList<dynamic>>();
-
-                    if (task.AdditionalSqlStatements != null)
-                    {
-                        foreach (var sqlStatement in task.AdditionalSqlStatements)
+                            $"Executing Sql Using Source {sqlStatement.DataSource} and Statement {sqlStatement.Statement}");
+                        using (
+                            var conn =
+                                new SqlConnection(GetConnection(sqlStatement.DataSource, settings.SqlConnections))
+                        )
                         {
-                            context.Log.Write(Verbosity.Normal, LogLevel.Information,
-                                $"Executing Sql Using Source {sqlStatement.DataSource} and Statement {sqlStatement.Statement}");
-                            using (
-                                var conn =
-                                    new SqlConnection(GetConnection(sqlStatement.DataSource, settings.SqlConnections))
-                            )
-                            {
-                                conn.Open();
-                                data.Add(sqlStatement.StatementLookupKey ?? sqlStatement.DataSource, conn.Query<dynamic>(sqlStatement.Statement).ToList());
-                            }
+                            conn.Open();
+                            data.Add(sqlStatement.StatementLookupKey ?? sqlStatement.DataSource, conn.Query<dynamic>(sqlStatement.Statement).ToList());
                         }
                     }
-
-                    using (var conn = new SqlConnection(GetConnection(task.SqlStatement.DataSource, settings.SqlConnections)))
-                    {
-                        conn.Open();
-
-                        var records = conn.Query<dynamic>(task.SqlStatement.Statement).ToList();
-
-                        foreach (var record in records)
-                        {
-                            var document = task.DocumentCreator(context.Log, record, data);
-
-                            operation.CreateDocument(
-                                task.DatabaseName,
-                                task.CollectionName,
-                                document);
-                        }
-                    }
-
-                    versionInfo.ProcessedMigrations.Add(new MigrationInfo
-                    {
-                        Name = hydration.GetType().Name,
-                        Description = task.Description,
-                        Timestamp = hydration.Attribute.Timestamp,
-                        AppliedOn = DateTime.UtcNow
-                    });
-                }
-
-                operation.UpsertVersionInfo(
-                        key[0],
-                        versionInfo);
-            }
-
-            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Finished Running Hydrations");
-        }
-
-        private static void RunDocumentHydrations(ICakeContext context, string assembly, DocumentDbMigrationSettings settings)
-        {
-            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Running Hydrations");
-
-            var hydrations = InstanceProvider.GetInstances<DocumentHydration>(assembly, settings.Profile);
-            foreach (var hydration in hydrations)
-            {
-                var migrationAttribute = hydration.GetType().GetCustomAttribute<MigrationAttribute>();
-
-                if (migrationAttribute == null)
-                    throw new InvalidOperationException($"Hydration {hydration.GetType().Name} must have a migration attribute");
-
-                hydration.Attribute = migrationAttribute;
-            }
-
-            var operation = new DocumentOperations(settings.Connection, context);
-
-            var groupedHydrations = hydrations.OrderBy(h => h.Attribute.Timestamp)
-                                              .GroupBy(m => m.Task.DatabaseName + "." + m.Task.CollectionName);
-
-            foreach (var groupedHydration in groupedHydrations)
-            {
-                var key = groupedHydration.Key.Split('.');
-                var versionInfo = operation.GetVersionInfo(
-                    key[0],
-                    key[1]);
-
-                foreach (var hydration in groupedHydration)
-                {
-                    var task = hydration.Task;
-
-                    context.Log.Write(Verbosity.Normal, LogLevel.Information,
-                        "Running Hydration: " + task.Description + " On Collection: " + task.CollectionName +
-                        " On Database: " + task.DatabaseName);
-
-                    if (versionInfo.ProcessedMigrations.Any(pm =>
-                        pm.Name == hydration.GetType().Name &&
-                        pm.Timestamp == hydration.Attribute.Timestamp))
-                    {
-                        context.Log.Write(Verbosity.Normal, LogLevel.Information,
-                            "Hydration: " + task.Description + " On Collection: " + task.CollectionName +
-                            " On Database: " + task.DatabaseName + " Has Already Been Executed");
-                        continue;
-                    }
-
-                    var data = new Dictionary<string, IList<JObject>>();
-
-                    if (task.AdditionalDocumentStatements != null)
-                    {
-                        foreach (var sqlStatement in task.AdditionalDocumentStatements)
-                        {
-                            context.Log.Write(Verbosity.Normal, LogLevel.Information,
-                                $"Executing Sql Using Source {sqlStatement.DatabaseName} on Collection {sqlStatement.CollectionName}");
-
-                            data.Add(sqlStatement.AccessKey, operation.GetDocuments(
-                                sqlStatement.DatabaseName,
-                                sqlStatement.CollectionName,
-                                sqlStatement.Filter).ToList());
-                        }
-                    }
-
-                    var records = operation.GetDocuments(
-                        task.DocumentStatement.DatabaseName,
-                        task.DocumentStatement.CollectionName,
-                        task.DocumentStatement.Filter).ToList();
+                }
+
+                using (var conn = new SqlConnection(GetConnection(task.SqlStatement.DataSource, settings.SqlConnections)))
+                {
+                    conn.Open();
+
+                    var records = conn.Query<dynamic>(task.SqlStatement.Statement).ToList();

                     foreach (var record in records)
                     {
-                        var documents = new List<JObject>();
-
-                        if (task.DocumentCreator != null)
-                            documents.Add(task.DocumentCreator(context.Log, record, data));
-
-                        if (task.DocumentsCreator != null)
-                            documents.AddRange(task.DocumentsCreator(context.Log, record, data));
-
-                        foreach (var document in documents)
-                        {
-                            operation.CreateDocument(
-                                task.DatabaseName,
-                                task.CollectionName,
-                                document);
-                        }
-                    }
-
-                    versionInfo.ProcessedMigrations.Add(new MigrationInfo
-                    {
-                        Name = hydration.GetType().Name,
-                        Description = task.Description,
-                        Timestamp = hydration.Attribute.Timestamp,
-                        AppliedOn = DateTime.UtcNow
-                    });
-                }
-
-                operation.UpsertVersionInfo(
-                        key[0],
-                        versionInfo);
-            }
-
-            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Finished Running Hydrations");
-        }
-
-        private static void RunDataHydrations(ICakeContext context, string assembly, DocumentDbMigrationSettings settings)
-        {
-            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Running Hydrations");
-
-            var hydrations = InstanceProvider.GetInstances<DataHydration>(assembly, settings.Profile);
-            foreach (var hydration in hydrations)
-            {
-                var migrationAttribute = hydration.GetType().GetCustomAttribute<MigrationAttribute>();
-
-                if (migrationAttribute == null)
-                    throw new InvalidOperationException($"Hydration {hydration.GetType().Name} must have a migration attribute");
-
-                hydration.Attribute = migrationAttribute;
-            }
-
-            var operation = new DocumentOperations(settings.Connection, context);
-
-            var groupedHydrations = hydrations.OrderBy(h => h.Attribute.Timestamp)
-                .GroupBy(m => m.Task.DatabaseName + "." + m.Task.CollectionName);
-
-            foreach (var groupedHydration in groupedHydrations)
-            {
-                var key = groupedHydration.Key.Split('.');
-                var versionInfo = operation.GetVersionInfo(
-                    key[0],
-                    key[1]);
-
-                foreach (var hydration in groupedHydration)
-                {
-                    var task = hydration.Task;
-
-                    context.Log.Write(Verbosity.Normal, LogLevel.Information,
-                        "Running Hydration: " + task.Description + " On Collection: " + task.CollectionName +
-                        " On Database: " + task.DatabaseName);
-
-                    if (versionInfo.ProcessedMigrations.Any(pm =>
-                        pm.Name == hydration.GetType().Name &&
-                        pm.Timestamp == hydration.Attribute.Timestamp))
-                    {
-                        context.Log.Write(Verbosity.Normal, LogLevel.Information,
-                            "Hydration: " + task.Description + " On Collection: " + task.CollectionName +
-                            " On Database: " + task.DatabaseName + " Has Already Been Executed");
-                        continue;
-                    }
-
-                    var data = task.DataProvider(context.Log, settings);
-
-                    foreach (var record in data)
-                    {
-                        var document = task.DocumentCreator(context.Log, record);
+                        var document = task.DocumentCreator(context.Log, record, data);

                         operation.CreateDocument(
                             task.DatabaseName,
                             task.CollectionName,
                             document);
                     }
-
-                    versionInfo.ProcessedMigrations.Add(new MigrationInfo
-                    {
-                        Name = hydration.GetType().Name,
-                        Description = task.Description,
-                        Timestamp = hydration.Attribute.Timestamp,
-                        AppliedOn = DateTime.UtcNow
-                    });
-                }
+                }
+
+                versionInfo.ProcessedMigrations.Add(new MigrationInfo
+                {
+                    Name = hydration.GetType().Name,
+                    Description = task.Description,
+                    Timestamp = hydration.Attribute.Timestamp,
+                    AppliedOn = DateTime.UtcNow
+                });

                 operation.UpsertVersionInfo(
-                    key[0],
+                        hydration.Task.DatabaseName,
+                        versionInfo);
+            }
+
+            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Finished Running Hydrations");
+        }
+
+        private static void RunDocumentHydrations(ICakeContext context, string assembly, DocumentDbMigrationSettings settings)
+        {
+            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Running Hydrations");
+
+            var hydrations = InstanceProvider.GetInstances<DocumentHydration>(assembly, settings.Profile);
+            foreach (var hydration in hydrations)
+            {
+                var migrationAttribute = hydration.GetType().GetCustomAttribute<MigrationAttribute>();
+
+                if (migrationAttribute == null)
+                    throw new InvalidOperationException($"Hydration {hydration.GetType().Name} must have a migration attribute");
+
+                hydration.Attribute = migrationAttribute;
+            }
+
+            var operation = new DocumentOperations(settings.Connection, context);
+
+            var orderedHydrations = hydrations.OrderBy(h => h.Attribute.Timestamp);
+            foreach (var hydration in orderedHydrations)
+            {
+                var versionInfo = operation.GetVersionInfo(
+                    hydration.Task.DatabaseName,
+                    hydration.Task.CollectionName);
+
+                var task = hydration.Task;
+
+                context.Log.Write(Verbosity.Normal, LogLevel.Information,
+                    "Running Hydration: " + task.Description + " On Collection: " + task.CollectionName +
+                    " On Database: " + task.DatabaseName);
+
+                if (versionInfo.ProcessedMigrations.Any(pm =>
+                    pm.Name == hydration.GetType().Name &&
+                    pm.Timestamp == hydration.Attribute.Timestamp))
+                {
+                    context.Log.Write(Verbosity.Normal, LogLevel.Information,
+                        "Hydration: " + task.Description + " On Collection: " + task.CollectionName +
+                        " On Database: " + task.DatabaseName + " Has Already Been Executed");
+                    continue;
+                }
+
+                var data = new Dictionary<string, IList<JObject>>();
+
+                if (task.AdditionalDocumentStatements != null)
+                {
+                    foreach (var sqlStatement in task.AdditionalDocumentStatements)
+                    {
+                        context.Log.Write(Verbosity.Normal, LogLevel.Information,
+                            $"Executing Sql Using Source {sqlStatement.DatabaseName} on Collection {sqlStatement.CollectionName}");
+
+                        data.Add(sqlStatement.AccessKey, operation.GetDocuments(
+                            sqlStatement.DatabaseName,
+                            sqlStatement.CollectionName,
+                            sqlStatement.Filter).ToList());
+                    }
+                }
+
+                var records = operation.GetDocuments(
+                    task.DocumentStatement.DatabaseName,
+                    task.DocumentStatement.CollectionName,
+                    task.DocumentStatement.Filter).ToList();
+
+                foreach (var record in records)
+                {
+                    var documents = new List<JObject>();
+
+                    if (task.DocumentCreator != null)
+                        documents.Add(task.DocumentCreator(context.Log, record, data));
+
+                    if (task.DocumentsCreator != null)
+                        documents.AddRange(task.DocumentsCreator(context.Log, record, data));
+
+                    foreach (var document in documents)
+                    {
+                        operation.CreateDocument(
+                            task.DatabaseName,
+                            task.CollectionName,
+                            document);
+                    }
+                }
+
+                versionInfo.ProcessedMigrations.Add(new MigrationInfo
+                {
+                    Name = hydration.GetType().Name,
+                    Description = task.Description,
+                    Timestamp = hydration.Attribute.Timestamp,
+                    AppliedOn = DateTime.UtcNow
+                });
+
+                operation.UpsertVersionInfo(
+                        hydration.Task.DatabaseName,
+                        versionInfo);
+            }
+
+            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Finished Running Hydrations");
+        }
+
+        private static void RunDataHydrations(ICakeContext context, string assembly, DocumentDbMigrationSettings settings)
+        {
+            context.Log.Write(Verbosity.Normal, LogLevel.Information, "Running Hydrations");
+
+            var hydrations = InstanceProvider.GetInstances<DataHydration>(assembly, settings.Profile);
+            foreach (var hydration in hydrations)
+            {
+                var migrationAttribute = hydration.GetType().GetCustomAttribute<MigrationAttribute>();
+
+                if (migrationAttribute == null)
+                    throw new InvalidOperationException($"Hydration {hydration.GetType().Name} must have a migration attribute");
+
+                hydration.Attribute = migrationAttribute;
+            }
+
+            var operation = new DocumentOperations(settings.Connection, context);
+
+            var orderedHydrations = hydrations.OrderBy(h => h.Attribute.Timestamp);
+
+            foreach (var hydration in orderedHydrations)
+            {
+                var versionInfo = operation.GetVersionInfo(
+                    hydration.Task.DatabaseName,
+                    hydration.Task.CollectionName);
+
+                var task = hydration.Task;
+
+                context.Log.Write(Verbosity.Normal, LogLevel.Information,
+                    "Running Hydration: " + task.Description + " On Collection: " + task.CollectionName +
+                    " On Database: " + task.DatabaseName);
+
+                if (versionInfo.ProcessedMigrations.Any(pm =>
+                    pm.Name == hydration.GetType().Name &&
+                    pm.Timestamp == hydration.Attribute.Timestamp))
+                {
+                    context.Log.Write(Verbosity.Normal, LogLevel.Information,
+                        "Hydration: " + task.Description + " On Collection: " + task.CollectionName +
+                        " On Database: " + task.DatabaseName + " Has Already Been Executed");
+                    continue;
+                }
+
+                var data = task.DataProvider(context.Log, settings);
+
+                foreach (var record in data)
+                {
+                    var document = task.DocumentCreator(context.Log, record);
+
+                    operation.CreateDocument(
+                        task.DatabaseName,
+                        task.CollectionName,
+                        document);
+                }
+
+                versionInfo.ProcessedMigrations.Add(new MigrationInfo
+                {
+                    Name = hydration.GetType().Name,
+                    Description = task.Description,
+                    Timestamp = hydration.Attribute.Timestamp,
+                    AppliedOn = DateTime.UtcNow
+                });
+
+                operation.UpsertVersionInfo(
+                    hydration.Task.DatabaseName,
                     versionInfo);
             }


OffScreen - ChromiumWebBrowser.Dispose add comment for Interlocked.CompareExchange

--- CefSharp.OffScreen/ChromiumWebBrowser.cs
+++ CefSharp.OffScreen/ChromiumWebBrowser.cs
@@ -344,6 +344,8 @@
         /// <param name="disposing"><see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
         protected virtual void Dispose(bool disposing)
         {
+            // Attempt to move the disposeSignaled state from 0 to 1. If successful, we can be assured that
+            // this thread is the first thread to do so, and can safely dispose of the object.
             if (Interlocked.CompareExchange(ref disposeSignaled, 1, 0) != 0)
             {
                 return;


fix: ResourceOf handles special characters

--- src/Yaapii.Atoms/IO/ResourceOf.cs
+++ src/Yaapii.Atoms/IO/ResourceOf.cs
@@ -11,8 +11,8 @@
     /// </summary>
     public class ResourceOf : IInput
     {
-        private readonly IScalar<string> _resourceName;
-        private readonly IScalar<Assembly> _container;
+        private readonly string name;
+        private readonly IScalar<Assembly> container;

         /// <summary>
         /// <para>A resource embedded in the container.</para>
@@ -53,21 +53,10 @@
         /// </summary>
         /// <param name="name">name of the resource</param>
         /// <param name="container">container to search in. Use Assembly.GetExecutingAssembly() for the assembly your current code is in.</param>
-        public ResourceOf(string name, IScalar<Assembly> container) : this(
-            new ScalarOf<string>(() => container.Value().GetName().Name + "." + name.Replace('/', '.').Replace('\\', '.')),
-            container
-            )
-        { }
-
-        /// <summary>
-        /// ctor.
-        /// </summary>
-        /// <param name="name"></param>
-        /// <param name="container"></param>
-        private ResourceOf(IScalar<string> name, IScalar<Assembly> container)
+        public ResourceOf(string name, IScalar<Assembly> container)
         {
-            this._container = container;
-            this._resourceName = name;
+            this.name = name;
+            this.container = container;
         }

         /// <summary>
@@ -77,8 +66,8 @@
         /// <returns>stream of the resource</returns>
         public Stream Stream()
         {
-            var asm = this._container.Value();
-            var fullName = this._resourceName.Value();
+            var asm = this.container.Value();
+            var fullName = FullName();
             var s = asm.GetManifestResourceStream(fullName);

             if (s == null)
@@ -88,5 +77,78 @@

             return s;
         }
+
+        private string FullName()
+        {
+            var folders = this.name.Split('\\', '/');
+            for (int current = 0; current < folders.Length - 1; current++)
+            {
+                folders[current] =
+                    TranslateDash(
+                        TranslateNumbers(
+                            TranslateDots(folders[current])
+                        )
+                    );
+            }
+            return container.Value().GetName().Name + "." + String.Join(".", folders);
+        }
+
+        /// <summary>
+        /// Replace all occurence of '.' by "._"
+        /// Existing "._" will be considered.
+        /// Example: "_version8.1" -> "_version8._1"
+        /// </summary>
+        /// <param name="folder">The folder to translate</param>
+        /// <returns>Result</returns>
+        private string TranslateDots(string folder)
+        {
+            var pieces = folder.Split('.');
+            for (int piece = 1; piece < pieces.Length; piece++)
+            {
+                if (pieces[piece].StartsWith("_"))
+                {
+                    pieces[piece] = pieces[piece].Substring(1);
+                }
+            }
+            folder = String.Join("._", pieces);
+            return folder;
+        }
+
+        /// <summary>
+        /// When the folder begins with a digit it will be amended by a leading '_'.
+        /// Example: "7text7" -> "_7text7"
+        /// </summary>
+        /// <param name="folder">The folder to translate</param>
+        /// <returns>Result</returns>
+        private string TranslateNumbers(string folder)
+        {
+            if (folder.Length > 0)
+            {
+                var first = folder.Substring(0, 1).ToCharArray()[0];
+                if (first >= '0' && first <= '9')
+                {
+                    folder = "_" + folder;
+                }
+            }
+            return folder;
+        }
+
+        /// <summary>
+        /// Replaces all '-' by '_'.
+        /// When the folder name is equal "-" is will be replaced by "__".
+        /// Example: "unique-name" -> "unique_name"
+        /// Example: "-" -> "__"
+        /// </summary>
+        /// <param name="folder">The folder to translate</param>
+        /// <returns>Result</returns>
+        private string TranslateDash(string folder)
+        {
+            if (folder.Equals("-"))
+            {
+                folder = "__";
+            }
+            folder = folder.Replace("-", "_");
+            return folder;
+        }
     }
 }


New failing case.

New failing case.

--- CheckoutKata/CheckoutKata.Tests/Tests.cs
+++ CheckoutKata/CheckoutKata.Tests/Tests.cs
@@ -81,6 +81,7 @@
         [Theory]
         [InlineData(2, 100.0)]
         [InlineData(3, 130.0)]
+        [InlineData(5, 230.0)]
         public void It_should_calculate_correct_price(int numberOfUnits, double expected)
         {
             var sut = new ItemPrice('A', 50.0, new GetXForY(3, 130.0));


Add Parse move

Add Parse move

--- GTPWrapper/DataTypes/Move.cs
+++ GTPWrapper/DataTypes/Move.cs
@@ -27,5 +27,20 @@
             this.Color = color;
             this.Vertex = vertex;
         }
+
+        /// <summary>
+        /// Converts input string to a Move.
+        /// </summary>
+        /// <param name="input">The input string.</param>
+        public static Move Parse(string input) {
+            try {
+                string[] args = input.ToUpper().Split(' ');
+                Color color = (Color)Enum.Parse(typeof(Color), args[0], true);
+                Vertex vertex = new Vertex(args[1]);
+                return new Move(color, vertex);
+            } catch {
+                throw new FormatException();
+            }
+        }
     }
 }


woops

woops

--- GUI/SearchTaskWindow.xaml.cs
+++ GUI/SearchTaskWindow.xaml.cs
@@ -353,11 +353,6 @@
             else
                 TheTask.CommonParameters.TaskDescriptor = "SearchTask";

-            if (OutputFileNameTextBox.Text != "")
-                TheTask.CommonParameters.TaskDescriptor = OutputFileNameTextBox.Text;
-            else
-                TheTask.CommonParameters.TaskDescriptor = "SearchTask";
-
             TheTask.CommonParameters.TrimMs1Peaks = trimMs1.IsChecked.Value;
             TheTask.CommonParameters.TrimMsMsPeaks = trimMsMs.IsChecked.Value;
             TheTask.CommonParameters.TopNpeaks = int.TryParse(TopNPeaksCheckBox.Text, out int TopNPeak) ? (int?)TopNPeak : null;


Update Parse for ReadOnly FileAccess (#876)

At the moment the Parse method with sourceFile needs write permission because of the FileStream Constructor setting FileAccess to ReadWrite wth the current FileStream constructor. Specify FileAccess.Read will force to open with Read permission instead of readwrite

Co-authored-by: M.P. Korstanje <7699da5561edc2c3925bee0dcaf7acbb1d7ddaf7@users.noreply.github.com>

--- Gherkin/Parser.Extensions.cs
+++ Gherkin/Parser.Extensions.cs
@@ -21,7 +21,7 @@

         public GherkinDocument Parse(string sourceFile)
         {
-            using (var stream = new FileStream(sourceFile, FileMode.Open))
+            using (var stream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read))
             {
                 using (var reader = new StreamReader(stream))
                 {


ExecutionContext.IsDefaultFTContext incorrectly checks the "current" context

Fixed: ExecutionContext.IsDefaultFTContext incorrectly checks the thread's current context instead of the context that is it called on. This prevents Overlapped from running it's callback on the captured execution context, and hence, async locals don't flow for overlapped callbacks. There are no tests with this change, because the only thing that is broken currently is Overlapped. I've written new tests for the new overlapped APIs that were broken *before* this change, and pass after this change, these will be checked in with the overlapped feature.
Changed: Marked ExecutionContext.Default private, as it was accidently made public.

[tfs-changeset: 1440483]

--- src/mscorlib/src/System/Threading/ExecutionContext.cs
+++ src/mscorlib/src/System/Threading/ExecutionContext.cs
@@ -52,7 +52,7 @@

     public sealed class ExecutionContext : IDisposable
     {
-        public static readonly ExecutionContext Default = new ExecutionContext();
+        private static readonly ExecutionContext Default = new ExecutionContext();

         [ThreadStatic]
         [SecurityCritical]
@@ -240,8 +240,7 @@
         [SecurityCritical]
         internal bool IsDefaultFTContext(bool ignoreSyncCtx)
         {
-            ExecutionContext current = t_currentMaybeNull;
-            return current == null || current == Default;
+            return this == Default;
         }

         [SecuritySafeCritical]


Added WarmUpHistory method

Added WarmUpHistory method

--- TestEDITOR/EditorContext.cs
+++ TestEDITOR/EditorContext.cs
@@ -247,7 +247,7 @@
                 .StyleGroups.FirstOrDefault(g => g.Name == "Template")
                 .Styles.FirstOrDefault(s => s.Name == "Grid");
             var settings = LineGrid.Settings.Create(0, 0, container.Width, container.Height, 30, 30);
-            var shapes = LineGrid.Create(gs, settings, project.PointShape);
+            var shapes = LineGrid.Create(gs, settings, project.Options.PointShape);
             var layer = container.Layers.FirstOrDefault();

             foreach (var shape in shapes)
@@ -992,6 +992,7 @@
                 (item) => IsEditMode());

             WarmUpCSharpScript();
+            WarmUpHistory();
         }

         /// <summary>
@@ -1291,7 +1292,7 @@
             // reset point shape to container default
             foreach (var point in Editor.GetAllPoints(shapes))
             {
-                point.Shape = _editor.Project.PointShape;
+                point.Shape = _editor.Project.Options.PointShape;
             }

             // try to restore shape styles
@@ -1640,13 +1641,45 @@
             // NOTE: Warmup Roslyn script engine.
             try
             {
-                Task.Run(() => Eval("Action a = () => { };", this, Execute));
+                Task.Run(
+                    () =>
+                    {
+                        Eval("Action a = () => { };", this, Execute);
+                    });
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.Print(ex.Message);
                 System.Diagnostics.Debug.Print(ex.StackTrace);
             }
+        }
+
+        /// <summary>
+        ///
+        /// </summary>
+        private void WarmUpHistory()
+        {
+            // NOTE: Warmup history serializer and compressor.
+            try
+            {
+                Task.Run(
+                    () =>
+                    {
+                        var history = new History<Project>(_serializer, _compressor);
+                        var project = DefaultProject();
+                        history.Snapshot(project);
+                        history.Undo(project);
+                    });
+            }
+            catch (Exception ex)
+            {
+                System.Diagnostics.Debug.Print(ex.Message);
+                System.Diagnostics.Debug.Print(ex.StackTrace);
+            }
+
+
+
+
         }

         /// <summary>


manually added try / catch as per pull request #73 @matthijsneven

--- source/nuPickers/Helper.cs
+++ source/nuPickers/Helper.cs
@@ -53,8 +53,15 @@
             string assemblyFilePath = HostingEnvironment.MapPath(string.Concat("~/bin/", assemblyName));
             if (!string.IsNullOrEmpty(assemblyFilePath))
             {
-                // HACK: http://stackoverflow.com/questions/1031431/system-reflection-assembly-loadfile-locks-file
-                return Assembly.Load(File.ReadAllBytes(assemblyFilePath));
+                try
+                {
+                    // HACK: http://stackoverflow.com/questions/1031431/system-reflection-assembly-loadfile-locks-file
+                    return Assembly.Load(File.ReadAllBytes(assemblyFilePath));
+                }
+                catch
+                {
+                    return null;
+                }
             }

             return null;


Fixed the bug of missing one parenthesis.

--- TimerTriggerCSharp1/run.csx
+++ TimerTriggerCSharp1/run.csx
@@ -57,7 +57,7 @@
         foreach(var existingItem in targetList)
         {
             if (existingItem.Id == newItem.Id ||
-                (!string.IsNullOrWhiteSpace(newItem.ArticleUrl) && existingItem.ArticleUrl.Trim() == newItem.ArticleUrl.Trim()) {
+            (!string.IsNullOrWhiteSpace(newItem.ArticleUrl) && existingItem.ArticleUrl.Trim() == newItem.ArticleUrl.Trim())) {

                 isFeedExist = true;


Check if thread is running before suspending

--- Torch.Server/TorchServer.cs
+++ Torch.Server/TorchServer.cs
@@ -30,6 +30,8 @@
 using VRage.ObjectBuilders;
 using VRage.Plugins;
 using VRage.Utils;
+using ThreadState = System.Threading.ThreadState;
+
 #pragma warning disable 618

 namespace Torch.Server
@@ -182,7 +184,8 @@
             if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
             {
                 var mainThread = MySandboxGame.Static.UpdateThread;
-                mainThread.Suspend();
+                if (mainThread.ThreadState == ThreadState.Running)
+                    mainThread.Suspend();
                 var stackTrace = new StackTrace(mainThread, true);
                 throw new TimeoutException($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds.\n{stackTrace}");
             }


KSINETAPI-95 Fixed a typo.

KSINETAPI-95 Fixed a typo.

--- ksi-net-api-test/Service/ExtenderConfigRequestStaticTests.cs
+++ ksi-net-api-test/Service/ExtenderConfigRequestStaticTests.cs
@@ -33,7 +33,7 @@
     /// Extender configuration tests with static response
     /// </summary>
     [TestFixture]
-    public class EtenderConfigRequestStaticTests
+    public class ExtenderConfigRequestStaticTests
     {
         /// <summary>
         /// Test extender configuration request


Optional Callbacks

Optional Callbacks

• Wrote overloads for setEmail(), logoutEmail(), and postNotification() so that the callback parameters are optional

--- Com.OneSignal.Abstractions/IOneSignal.cs
+++ Com.OneSignal.Abstractions/IOneSignal.cs
@@ -17,11 +17,15 @@
       void IdsAvailable(IdsAvailableCallback idsAvailableCallback);
       void SetSubscription(bool enable);
       void PostNotification(Dictionary<string, object> data, OnPostNotificationSuccess success, OnPostNotificationFailure failure);
+      void PostNotification(Dictionary<string, object> data);
       void SyncHashedEmail(string email);
       void PromptLocation();
       void SetEmail(string email, string emailAuthToken, OnSetEmailSuccess success, OnSetEmailFailure failure);
+      void SetEmail(string email, string emailAuthToken);
       void SetEmail(string email, OnSetEmailSuccess success, OnSetEmailFailure failure);
+      void SetEmail(string email);
       void LogoutEmail(OnSetEmailSuccess success, OnSetEmailFailure failure);
+      void LogoutEmail();
    }
 }


remove in scope for not logged in user

remove in scope for not logged in user

--- Controllers/Services/BundleController.cs
+++ Controllers/Services/BundleController.cs
@@ -68,8 +68,8 @@

         public TransferBundle GetTransferBundle(String apbnKey, String regionId)
         {
-            if (KawalDesaController.GetCurrentUser() == null &&regionId == "0")
-                return GetInScopeTransferBundle(apbnKey);
+            //if (KawalDesaController.GetCurrentUser() == null &&regionId == "0")
+            //    return GetInScopeTransferBundle(apbnKey);
             var region = GetRegion(regionId);

             var result = new TransferBundle


No longer using Check, allows null comparer

--- Core/Theraot/Collections/ExtendedList.cs
+++ Core/Theraot/Collections/ExtendedList.cs
@@ -157,12 +157,15 @@

         public bool Overlaps(IEnumerable<T> other)
         {
-            var _other = Check.NotNullArgument(other, "other");
+            if (other == null)
+            {
+                throw new ArgumentNullException("other");
+            }
             if (Count == 0)
             {
                 return false;
             }
-            foreach (T item in _other)
+            foreach (T item in other)
             {
                 if (Contains(item))
                 {
@@ -174,9 +177,9 @@

         public bool Remove(T item)
         {
-            foreach (var _item in _wrapped.RemoveWhereEnumerable(input => _comparer.Equals(input, item)))
-            {
-                GC.KeepAlive(_item);
+            foreach (var foundItem in _wrapped.RemoveWhereEnumerable(input => _comparer.Equals(input, item)))
+            {
+                GC.KeepAlive(foundItem);
                 return true;
             }
             return false;
@@ -184,10 +187,13 @@

         public bool Remove(T item, IEqualityComparer<T> comparer)
         {
-            var __comparer = Check.NotNullArgument(comparer, "comparer");
-            foreach (var _item in _wrapped.RemoveWhereEnumerable(input => __comparer.Equals(input, item)))
-            {
-                GC.KeepAlive(_item);
+            if (comparer == null)
+            {
+                comparer = EqualityComparer<T>.Default;
+            }
+            foreach (var foundItem in _wrapped.RemoveWhereEnumerable(input => comparer.Equals(input, item)))
+            {
+                GC.KeepAlive(foundItem);
                 return true;
             }
             return false;


Updated WPF renderer

Updated WPF renderer

--- Dependencies/Renderer.Wpf/WpfRenderer.cs
+++ Dependencies/Renderer.Wpf/WpfRenderer.cs
@@ -23,6 +23,7 @@
     {
         private const bool _enableGuidelines = true;
         private bool _enableStyleCache = true;
+        private bool _enableArrowStyleCache = true;
         private bool _enableArcCache = true;
         private bool _enableBezierCache = true;
         private bool _enableQBezierCache = true;
@@ -30,6 +31,7 @@
         private bool _enableImageCache = true;
         private bool _enablePathCache = true;
         private IDictionary<ShapeStyle, Tuple<Brush, Pen>> _styleCache;
+        private IDictionary<ArrowStyle, Tuple<Brush, Pen>> _arrowStyleCache;
         private IDictionary<XArc, PathGeometry> _arcCache;
         private IDictionary<XBezier, PathGeometry> _bezierCache;
         private IDictionary<XQBezier, PathGeometry> _qbezierCache;
@@ -126,15 +128,13 @@
         /// <summary>
         ///
         /// </summary>
-        /// <param name="ls"></param>
-        /// <param name="color"></param>
-        /// <param name="thickness"></param>
+        /// <param name="style"></param>
         /// <returns></returns>
-        private static Pen CreatePen(LineStyle ls, ArgbColor color, double thickness)
-        {
-            var brush = CreateBrush(color);
+        private static Pen CreatePen(BaseStyle style, double thickness)
+        {
+            var brush = CreateBrush(style.Stroke);
             var pen = new Pen(brush, thickness);
-            switch (ls.LineCap)
+            switch (style.LineCap)
             {
                 case LineCap.Flat:
                     pen.StartLineCap = PenLineCap.Flat;
@@ -152,8 +152,8 @@
                     pen.DashCap = PenLineCap.Round;
                     break;
             }
-            pen.DashStyle = new DashStyle(ls.Dashes, ls.DashOffset);
-            pen.DashStyle.Offset = ls.DashOffset;
+            pen.DashStyle = new DashStyle(style.Dashes, style.DashOffset);
+            pen.DashStyle.Offset = style.DashOffset;
             pen.Freeze();
             return pen;
         }
@@ -359,6 +359,7 @@
         public void ClearCache()
         {
             _styleCache = new Dictionary<ShapeStyle, Tuple<Brush, Pen>>();
+            _arrowStyleCache = new Dictionary<ArrowStyle, Tuple<Brush, Pen>>();
             _arcCache = new Dictionary<XArc, PathGeometry>();
             _bezierCache = new Dictionary<XBezier, PathGeometry>();
             _qbezierCache = new Dictionary<XQBezier, PathGeometry>();
@@ -433,30 +434,69 @@
         {
             var _dc = dc as DrawingContext;

-            double thickness = line.Style.Thickness / _state.Zoom;
-            double half = thickness / 2.0;
+            double zoom = _state.Zoom;
+            double thicknessLine = line.Style.Thickness / zoom;
+            double halfLine = thicknessLine / 2.0;
+            double thicknessStartArrow = line.Style.StartArrowStyle.Thickness / zoom;
+            double halfStartArrow = thicknessStartArrow / 2.0;
+            double thicknessEndArrow = line.Style.EndArrowStyle.Thickness / zoom;
+            double halfEndArrow = thicknessEndArrow / 2.0;

-            Tuple<Brush, Pen> cache = null;
-            Brush fill;
-            Pen stroke;
+            // line style
+            Tuple<Brush, Pen> lineCache = null;
+            Brush fillLine;
+            Pen strokeLine;
             if (_enableStyleCache
-                && _styleCache.TryGetValue(line.Style, out cache))
-            {
-                fill = cache.Item1;
-                stroke = cache.Item2;
-            }
-            else
-            {
-                fill = CreateBrush(line.Style.Fill);
-                stroke = CreatePen(
-                    line.Style.LineStyle,
-                    line.Style.Stroke,
-                    thickness);
-
+                && _styleCache.TryGetValue(line.Style, out lineCache))
+            {
+                fillLine = lineCache.Item1;
+                strokeLine = lineCache.Item2;
+            }
+            else
+            {
+                fillLine = CreateBrush(line.Style.Fill);
+                strokeLine = CreatePen(line.Style, thicknessLine);
                 if (_enableStyleCache)
-                    _styleCache.Add(line.Style, Tuple.Create(fill, stroke));
-            }
-
+                    _styleCache.Add(line.Style, Tuple.Create(fillLine, strokeLine));
+            }
+
+            // start arrow style
+            Tuple<Brush, Pen> startArrowCache = null;
+            Brush fillStartArrow;
+            Pen strokeStartArrow;
+            if (_enableArrowStyleCache
+                && _arrowStyleCache.TryGetValue(line.Style.StartArrowStyle, out startArrowCache))
+            {
+                fillStartArrow = startArrowCache.Item1;
+                strokeStartArrow = startArrowCache.Item2;
+            }
+            else
+            {
+                fillStartArrow = CreateBrush(line.Style.StartArrowStyle.Fill);
+                strokeStartArrow = CreatePen(line.Style.StartArrowStyle, thicknessStartArrow);
+                if (_enableArrowStyleCache)
+                    _arrowStyleCache.Add(line.Style.StartArrowStyle, Tuple.Create(fillStartArrow, strokeStartArrow));
+            }
+
+            // end arrow style
+            Tuple<Brush, Pen> endArrowCache = null;
+            Brush fillEndArrow;
+            Pen strokeEndArrow;
+            if (_enableArrowStyleCache
+                && _arrowStyleCache.TryGetValue(line.Style.EndArrowStyle, out endArrowCache))
+            {
+                fillEndArrow = endArrowCache.Item1;
+                strokeEndArrow = endArrowCache.Item2;
+            }
+            else
+            {
+                fillEndArrow = CreateBrush(line.Style.EndArrowStyle.Fill);
+                strokeEndArrow = CreatePen(line.Style.EndArrowStyle, thicknessEndArrow);
+                if (_enableArrowStyleCache)
+                    _arrowStyleCache.Add(line.Style.EndArrowStyle, Tuple.Create(fillStartArrow, strokeEndArrow));
+            }
+
+            // line max length
             double x1 = line.Start.X + dx;
             double y1 = line.Start.Y + dy;
             double x2 = line.End.X + dx;
@@ -464,8 +504,9 @@

             XLine.SetMaxLength(line, ref x1, ref y1, ref x2, ref y2);

-            var sas = line.Style.LineStyle.StartArrowStyle;
-            var eas = line.Style.LineStyle.EndArrowStyle;
+            // arrow transforms
+            var sas = line.Style.StartArrowStyle;
+            var eas = line.Style.EndArrowStyle;
             double a1 = Math.Atan2(y1 - y2, x1 - x2) * 180.0 / Math.PI;
             double a2 = Math.Atan2(y2 - y1, x2 - x1) * 180.0 / Math.PI;
             bool doRectTransform1 = a1 % 90.0 != 0.0;
@@ -476,12 +517,13 @@

             Point pt1;
             Point pt2;
-
+
+            // draw start arrow
             double radiusX1 = sas.RadiusX;
             double radiusY1 = sas.RadiusY;
             double sizeX1 = 2.0 * radiusX1;
             double sizeY1 = 2.0 * radiusY1;
-
+
             switch (sas.ArrowType)
             {
                 default:
@@ -497,13 +539,13 @@
                         if (doRectTransform1)
                         {
                             _dc.PushTransform(t1);
-                            DrawRectangleInternal(_dc, half, fill, stroke, sas.IsFilled, ref rect);
+                            DrawRectangleInternal(_dc, halfStartArrow, fillStartArrow, strokeStartArrow, sas.IsFilled, ref rect);
                             _dc.Pop();
                         }
                         else
                         {
                             var bounds = t1.TransformBounds(rect);
-                            DrawRectangleInternal(_dc, half, fill, stroke, sas.IsFilled, ref bounds);
+                            DrawRectangleInternal(_dc, halfStartArrow, fillStartArrow, strokeStartArrow, sas.IsFilled, ref bounds);
                         }
                     }
                     break;
@@ -512,7 +554,7 @@
                         pt1 = t1.Transform(new Point(x1 - sizeX1, y1));
                         _dc.PushTransform(t1);
                         var c = new Point(x1 - radiusX1, y1);
-                        DrawEllipseInternal(_dc, half, fill, stroke, sas.IsFilled, ref c, radiusX1, radiusY1);
+                        DrawEllipseInternal(_dc, halfStartArrow, fillStartArrow, strokeStartArrow, sas.IsFilled, ref c, radiusX1, radiusY1);
                         _dc.Pop();
                     }
                     break;
@@ -523,12 +565,13 @@
                         var p21 = t1.Transform(new Point(x1, y1));
                         var p12 = t1.Transform(new Point(x1 - sizeX1, y1 - sizeY1));
                         var p22 = t1.Transform(new Point(x1, y1));
-                        DrawLineInternal(_dc, half, stroke, ref p11, ref p21);
-                        DrawLineInternal(_dc, half, stroke, ref p12, ref p22);
+                        DrawLineInternal(_dc, halfStartArrow, strokeStartArrow, ref p11, ref p21);
+                        DrawLineInternal(_dc, halfStartArrow, strokeStartArrow, ref p12, ref p22);
                     }
                     break;
             }

+            // draw end arrow
             double radiusX2 = eas.RadiusX;
             double radiusY2 = eas.RadiusY;
             double sizeX2 = 2.0 * radiusX2;
@@ -549,13 +592,13 @@
                         if (doRectTransform2)
                         {
                             _dc.PushTransform(t2);
-                            DrawRectangleInternal(_dc, half, fill, stroke, eas.IsFilled, ref rect);
+                            DrawRectangleInternal(_dc, halfEndArrow, fillEndArrow, strokeEndArrow, eas.IsFilled, ref rect);
                             _dc.Pop();
                         }
                         else
                         {
                             var bounds = t2.TransformBounds(rect);
-                            DrawRectangleInternal(_dc, half, fill, stroke, eas.IsFilled, ref bounds);
+                            DrawRectangleInternal(_dc, halfEndArrow, fillEndArrow, strokeEndArrow, eas.IsFilled, ref bounds);
                         }
                     }
                     break;
@@ -564,7 +607,7 @@
                         pt2 = t2.Transform(new Point(x2 - sizeX2, y2));
                         _dc.PushTransform(t2);
                         var c = new Point(x2 - radiusX2, y2);
-                        DrawEllipseInternal(_dc, half, fill, stroke, eas.IsFilled, ref c, radiusX2, radiusY2);
+                        DrawEllipseInternal(_dc, halfEndArrow, fillEndArrow, strokeEndArrow, eas.IsFilled, ref c, radiusX2, radiusY2);
                         _dc.Pop();
                     }
                     break;
@@ -575,13 +618,14 @@
                          var p21 = t2.Transform(new Point(x2, y2));
                          var p12 = t2.Transform(new Point(x2 - sizeX2, y2 - sizeY2));
                          var p22 = t2.Transform(new Point(x2, y2));
-                         DrawLineInternal(_dc, half, stroke, ref p11, ref p21);
-                         DrawLineInternal(_dc, half, stroke, ref p12, ref p22);
-                    }
-                    break;
-            }
-
-            DrawLineInternal(_dc, half, stroke, ref pt1, ref pt2);
+                         DrawLineInternal(_dc, halfEndArrow, strokeEndArrow, ref p11, ref p21);
+                         DrawLineInternal(_dc, halfEndArrow, strokeEndArrow, ref p12, ref p22);
+                    }
+                    break;
+            }
+
+            // draw line using points from arrow transforms
+            DrawLineInternal(_dc, halfLine, strokeLine, ref pt1, ref pt2);
         }

         /// <summary>
@@ -612,11 +656,7 @@
             else
             {
                 fill = CreateBrush(rectangle.Style.Fill);
-                stroke = CreatePen(
-                    rectangle.Style.LineStyle,
-                    rectangle.Style.Stroke,
-                    thickness);
-
+                stroke = CreatePen(rectangle.Style, thickness);
                 if (_enableStyleCache)
                     _styleCache.Add(rectangle.Style, Tuple.Create(fill, stroke));
             }
@@ -657,11 +697,7 @@
             else
             {
                 fill = CreateBrush(ellipse.Style.Fill);
-                stroke = CreatePen(
-                    ellipse.Style.LineStyle,
-                    ellipse.Style.Stroke,
-                    thickness);
-
+                stroke = CreatePen(ellipse.Style, thickness);
                 if (_enableStyleCache)
                     _styleCache.Add(ellipse.Style, Tuple.Create(fill, stroke));
             }
@@ -711,11 +747,7 @@
             else
             {
                 fill = CreateBrush(arc.Style.Fill);
-                stroke = CreatePen(
-                    arc.Style.LineStyle,
-                    arc.Style.Stroke,
-                    thickness);
-
+                stroke = CreatePen(arc.Style, thickness);
                 if (_enableStyleCache)
                     _styleCache.Add(arc.Style, Tuple.Create(fill, stroke));
             }
@@ -791,11 +823,7 @@
             else
             {
                 fill = CreateBrush(bezier.Style.Fill);
-                stroke = CreatePen(
-                    bezier.Style.LineStyle,
-                    bezier.Style.Stroke,
-                    thickness);
-
+                stroke = CreatePen(bezier.Style, thickness);
                 if (_enableStyleCache)
                     _styleCache.Add(bezier.Style, Tuple.Create(fill, stroke));
             }
@@ -866,11 +894,7 @@
             else
             {
                 fill = CreateBrush(qbezier.Style.Fill);
-                stroke = CreatePen(
-                    qbezier.Style.LineStyle,
-                    qbezier.Style.Stroke,
-                    thickness);
-
+                stroke = CreatePen(qbezier.Style, thickness);
                 if (_enableStyleCache)
                     _styleCache.Add(qbezier.Style, Tuple.Create(fill, stroke));
             }
@@ -940,11 +964,7 @@
             else
             {
                 fill = CreateBrush(text.Style.Fill);
-                stroke = CreatePen(
-                    text.Style.LineStyle,
-                    text.Style.Stroke,
-                    thickness);
-
+                stroke = CreatePen(text.Style, thickness);
                 if (_enableStyleCache)
                     _styleCache.Add(text.Style, Tuple.Create(fill, stroke));
             }
@@ -1073,11 +1093,7 @@
             else
             {
                 fill = CreateBrush(image.Style.Fill);
-                stroke = CreatePen(
-                    image.Style.LineStyle,
-                    image.Style.Stroke,
-                    thickness);
-
+                stroke = CreatePen(image.Style, thickness);
                 if (_enableStyleCache)
                     _styleCache.Add(image.Style, Tuple.Create(fill, stroke));
             }
@@ -1161,11 +1177,7 @@
             else
             {
                 fill = CreateBrush(path.Style.Fill);
-                stroke = CreatePen(
-                    path.Style.LineStyle,
-                    path.Style.Stroke,
-                    thickness);
-
+                stroke = CreatePen(path.Style, thickness);
                 if (_enableStyleCache)
                     _styleCache.Add(path.Style, Tuple.Create(fill, stroke));
             }


Sort/group functions

Sort/group functions

--- WGemCombiner/GemCombiner.cs
+++ WGemCombiner/GemCombiner.cs
@@ -168,6 +168,17 @@
 			}
 		}

+		private void HelpButton_Click(object sender, EventArgs e)
+		{
+			this.helpForm.Show();
+		}
+
+		private void OptionsButton_Click(object sender, EventArgs e)
+		{
+			// Open modally or we can trigger the combine while setting the hotkey. Could be worked around in other ways, but it's unlikely that a user will want to leave the Options screen open for any reason.
+			this.optionsForm.ShowDialog(this);
+		}
+
 		private void ParseRecipeButton_Click(object sender, EventArgs e)
 		{
 			var parsedText = this.formulaInputRichTextBox.Text;
@@ -195,15 +206,9 @@
 			}
 		}

-		private void HelpButton_Click(object sender, EventArgs e)
-		{
-			this.helpForm.Show();
-		}
-
-		private void OptionsButton_Click(object sender, EventArgs e)
-		{
-			// Open modally or we can trigger the combine while setting the hotkey. Could be worked around in other ways, but it's unlikely that a user will want to leave the Options screen open for any reason.
-			this.optionsForm.ShowDialog(this);
+		private void SlotLimitUpDown_ValueChanged(object sender, EventArgs e)
+		{
+			Combiner.SlotLimit = (int)this.slotLimitUpDown.Value;
 		}

 		private void StepNumeric_ValueChanged(object sender, EventArgs e)
@@ -383,10 +388,5 @@
 			SettingsHandler.ApplySkin(this);
 		}
 		#endregion
-
-		private void SlotLimitUpDown_ValueChanged(object sender, EventArgs e)
-		{
-			Combiner.SlotLimit = (int)this.slotLimitUpDown.Value;
-		}
 	}
 }


Add degree conversion methods

Add degree conversion methods

--- DynamixelServo.Driver/DynamixelDriver.cs
+++ DynamixelServo.Driver/DynamixelDriver.cs
@@ -358,6 +358,30 @@
          }
       }

+      public static float UnitsToDegrees(int units)
+      {
+         return Constrain(MapFloat(units, 0, 1023, 0, 300), 0, 300);
+      }
+
+      public static int DegreesToUnits(float degrees)
+      {
+         return (int)Math.Round(Constrain(MapFloat(degrees, 0, 300, 0, 1023), 0, 1023));
+      }
+
+      private static float MapFloat(float value, float inMin, float inMax, float outMin, float outMax)
+      {
+         return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
+      }
+
+      private static float Constrain(float value, float min, float max)
+      {
+         float tempMin = Math.Min(min, max);
+         max = Math.Max(min, max);
+         min = tempMin;
+         value = Math.Max(value, min);
+         return Math.Min(value, max);
+      }
+
       public void Dispose()
       {
          dynamixel.closePort(_portNumber);


extracting multiple classes from source

extracting multiple classes from source

--- src/poc/HackingClasses/HackingClassesTests/Tests.cs
+++ src/poc/HackingClasses/HackingClassesTests/Tests.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System.Collections.Generic;
+using System.Linq;
 using HackingClasses;
 using Microsoft.CodeAnalysis.CSharp;
 using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -55,6 +56,21 @@
             Assert.AreEqual(lines, c.LOC);
         }

+        [TestCase("class Foo{} class Bar{}", 2)]
+        [TestCase("class Foo{} class Bar{} class Baz{}", 3)]
+        public void test_multiple_classes_found(string source, int classCount)
+        {
+            var classes = GetAllClassesFromSource(source);
+            Assert.AreEqual(classCount, classes.Count());
+        }
+
+        private IEnumerable<Class> GetAllClassesFromSource(string source)
+        {
+            var syntaxTree = CSharpSyntaxTree.ParseText(source);
+            var classDeclarations = syntaxTree.GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>();
+            return classDeclarations.Select(c => new Class(c));
+        }
+
         private static Class GetSingleClassFromSource(string source)
         {
             var syntaxTree = CSharpSyntaxTree.ParseText(source);


Typos.

Typos.

--- dotnet/example_code/ec2/Ec2SpotCRUD.cs
+++ dotnet/example_code/ec2/Ec2SpotCRUD.cs
@@ -142,7 +142,7 @@
         // snippet-start:[ec2.dotnet.spot_instance_terminate_spot_request]
         /* Terminates a spot instance request
          * Takes two args:
-         *   AmazonEC2Client ec2Client is the EC2 client through which the spot instance is termitted
+         *   AmazonEC2Client ec2Client is the EC2 client through which the spot instance is terminated
          *   string spotRequestId is the ID of the spot instance
          *
          * See https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/EC2/MEC2TerminateInstancesTerminateInstancesRequest.html
@@ -188,7 +188,7 @@
         // snippet-start:[ec2.dotnet.spot_instance_main]
         /* Creates, cancels, and terminates a spot instance request
          *
-         *   AmazonEC2Client ec2Client is the EC2 client through which the spot instance is termitted
+         *   AmazonEC2Client ec2Client is the EC2 client through which the spot instance is manipulated
          *   string spotRequestId is the ID of the spot instance
          *
          * See https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/EC2/MEC2TerminateInstancesTerminateInstancesRequest.html


Added AppRoleAssignment

Added AppRoleAssignment

Added Snippet to show AppRoleAssignment (Direct Permission)

--- GraphConsoleAppV3/Program.cs
+++ GraphConsoleAppV3/Program.cs
@@ -772,7 +772,7 @@
             //*********************************************************************************************
             // Create a new Application object with App Role Assignment (Direct permission)
             //*********************************************************************************************
-            Application appObject = new Application { DisplayName = "Test-Demo App" + Helper.GetRandomString(8) };
+            Application appObject = new Application {DisplayName = "Test-Demo App" + Helper.GetRandomString(8)};
             appObject.IdentifierUris.Add("https://localhost/demo/" + Guid.NewGuid());
             appObject.ReplyUrls.Add("https://localhost/demo");
             AppRole appRole = new AppRole();
@@ -857,6 +857,7 @@
             }

             #endregion
+
             #region Get Devices

             //*********************************************************************************************


styling

styling

--- gView.Interoperability.ArcXML/Dataset/ArcIMSDataset.cs
+++ gView.Interoperability.ArcXML/Dataset/ArcIMSDataset.cs
@@ -37,7 +37,10 @@

         internal ArcIMSClass WebServiceClass
         {
-            get { return _class as ArcIMSClass; }
+            get
+            {
+                return _class as ArcIMSClass;
+            }
         }

         public XmlDocument Properties


Added Archive.GetFilesFromDir and Archive.AddDirectory

--- HedgeLib/Archives/Archive.cs
+++ HedgeLib/Archives/Archive.cs
@@ -32,7 +32,7 @@
             {
                 if (includeSubDirectories && data is ArchiveDirectory dir)
                 {
-                    list.AddRange(GetFiles(dir.Files));
+                    list.AddRange(GetFiles(dir.Data));
                 }
                 else if (data is ArchiveFile file)
                 {
@@ -56,5 +56,35 @@
                 entry.Extract(Helpers.CombinePaths(directory, entry.Name));
             }
         }
+
+        public void AddDirectory(string dir, bool includeSubDirectories = false)
+        {
+            Data.AddRange(GetFilesFromDir(dir, includeSubDirectories));
+        }
+
+        public static List<ArchiveData> GetFilesFromDir(string dir,
+            bool includeSubDirectories = false)
+        {
+            // Add each file in the current sub-directory
+            var data = new List<ArchiveData>();
+            foreach (string filePath in Directory.GetFiles(dir))
+            {
+                data.Add(new ArchiveFile(filePath));
+            }
+
+            // Repeat for each sub directory
+            if (includeSubDirectories)
+            {
+                foreach (string subDir in Directory.GetDirectories(dir))
+                {
+                    data.Add(new ArchiveDirectory()
+                    {
+                        Data = GetFilesFromDir(subDir, includeSubDirectories)
+                    });
+                }
+            }
+
+            return data;
+        }
     }
 }


Delete OISFuture.cs

Delete OISFuture.cs

--- src/src/Qwack.Core/Instruments/Funding/OISFuture.cs
+++ src/src/Qwack.Core/Instruments/Funding/OISFuture.cs
@@ -1,64 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Qwack.Core.Basic;
-using Qwack.Core.Models;
-using Qwack.Dates;
-
-namespace Qwack.Core.Instruments.Funding
-{
-    public class OISFuture : IFundingInstrument
-    {
-        public double Price { get; set; } = 100.0;
-        public double ContractSize { get; set; } = 1.0;
-        public double Position { get; set; } = 1.0;
-        public FloatRateIndex Index { get; set; }
-        public double DCF { get; set; } = 1.0/12.0;
-        public Currency CCY { get; set; }
-        public DateTime AverageStartDate { get; set; }
-        public DateTime AverageEndDate { get; set; }
-
-        public string ForecastCurve { get; set; }
-        public string SolveCurve { get; set; }
-        public DateTime PillarDate { get; set; }
-        public string TradeId { get; set; }
-        public string Counterparty { get; set; }
-
-        public DateTime LastSensitivityDate => AverageEndDate;
-
-        public double Pv(IFundingModel Model, bool updateState)
-        {
-            var forecastCurve = Model.Curves[ForecastCurve];
-            var fwdRate = forecastCurve.GetForwardRate(AverageStartDate, AverageEndDate, RateType.Linear, Index.DayCountBasis);
-
-            var fairPrice = 100.0 - fwdRate * 100.0;
-            var PV = (Price - fairPrice) * Position * ContractSize * DCF;
-
-            return PV;
-        }
-
-        public CashFlowSchedule ExpectedCashFlows(IFundingModel model) => throw new NotImplementedException();
-
-        public Dictionary<string, Dictionary<DateTime, double>> Sensitivities(IFundingModel model)
-        {
-            var forecastDict =  new Dictionary<DateTime, double>();
-            var forecastCurve = model.Curves[ForecastCurve];
-
-            var ts = forecastCurve.Basis.CalculateYearFraction(forecastCurve.BuildDate, AverageStartDate);
-            var te = forecastCurve.Basis.CalculateYearFraction(forecastCurve.BuildDate, AverageEndDate);
-            var fwdRate = forecastCurve.GetForwardRate(AverageStartDate, AverageEndDate, RateType.Linear, Index.DayCountBasis);
-            var dPVdR = -100.0;
-            var dPVdS = dPVdR * (-ts * (fwdRate + 1.0 / DCF));
-            var dPVdE = dPVdR * (te * (fwdRate + 1.0 / DCF));
-
-            forecastDict.Add(AverageStartDate, dPVdS);
-            forecastDict.Add(AverageEndDate, dPVdE);
-
-            return new Dictionary<string, Dictionary<DateTime, double>>()
-            {
-                {ForecastCurve, forecastDict },
-            };
-        }
-    }
-}


Fix null object exception in class interface for csnex

--- exec/csnex/Bytecode.cs
+++ exec/csnex/Bytecode.cs
@@ -191,6 +191,7 @@
             classes = new List<ClassInfo>();
             while (classsize > 0) {
                 ClassInfo cls = new ClassInfo();
+                cls.interfaces = new List<Interface>();
                 cls.name = Get_VInt(obj, ref i);
                 int interfacesize = Get_VInt(obj, ref i);
                 while (interfacesize > 0) {


Add code backend for zoom buttons

Add code backend for zoom buttons

...now i just need to figure out where to place the buttons

--- JC2MapViewer/Window1.xaml.cs
+++ JC2MapViewer/Window1.xaml.cs
@@ -328,5 +328,17 @@
             				loadSavedInfo();
          			}
         }
+
+        private void ZoomInButton_Click( object sender, RoutedEventArgs e )
+        {
+            map.Transform.Resolution /= 2;
+            map.Refresh();
+        }
+
+        private void ZoomOutButton_Click( object sender, RoutedEventArgs e )
+        {
+            map.Transform.Resolution *= 2;
+            map.Refresh();
+        }
     }
 }


test for when type indicator is misconfigured

--- JilTests/DeserializeTests.cs
+++ JilTests/DeserializeTests.cs
@@ -6428,10 +6428,55 @@
             Assert.IsNull(empty.AsStr);
             Assert.AreEqual(0, empty.AsInt);
             Assert.IsNull(empty.WhatType);
-
-            // TODO: Test the misconfiguration errors for IsUnionType
-        }
-
+        }
+
+        class _UnionTypeMisconfiguration_1
+        {
+            [JilDirective(IsUnion = true, Name = "Data")]
+            public string AStr { get; set; }
+            [JilDirective(IsUnion = true, Name = "Data")]
+            public int AInt { get; set; }
+
+            [JilDirective(IsUnion = true, Name = "Data", IsUnionType = true)]
+            public string Data_Type { get; set; }
+        }
+
+        class _UnionTypeMisconfiguration_2
+        {
+            [JilDirective(IsUnion = true, Name = "Data")]
+            public string AStr { get; set; }
+            [JilDirective(IsUnion = true, Name = "Data")]
+            public int AInt { get; set; }
+
+            [JilDirective(IsUnion = true, Name = "Data", IsUnionType = true)]
+            public Type Data_Type1 { get; set; }
+            [JilDirective(IsUnion = true, Name = "Data", IsUnionType = true)]
+            public Type Data_Type2 { get; set; }
+        }
+
+        [TestMethod]
+        public void UnionTypeMisconfiguration()
+        {
+            try
+            {
+                JSON.Deserialize<_UnionTypeMisconfiguration_1>("{}");
+                Assert.Fail("Shouldn't be possible");
+            }
+            catch (DeserializationException e)
+            {
+                Assert.AreEqual("Error occurred building a deserializer for JilTests.DeserializeTests+_UnionTypeMisconfiguration_1: Member [Data_Type] has IsUnionType set, but is not of type System.Type", e.Message);
+            }
+
+            try
+            {
+                JSON.Deserialize<_UnionTypeMisconfiguration_2>("{}");
+                Assert.Fail("Shouldn't be possible");
+            }
+            catch (DeserializationException e)
+            {
+                Assert.AreEqual("Error occurred building a deserializer for JilTests.DeserializeTests+_UnionTypeMisconfiguration_2: Member [Data_Type2] has IsUnionType set, but IsUnionType is also set for [Data_Type1]", e.Message);
+            }
+        }
 #if !DEBUG
         #region SlowSpinUp Types


[QLTY] Adding comments.

[QLTY] Adding comments.

--- XGraph/Controls/NodeView.cs
+++ XGraph/Controls/NodeView.cs
@@ -6,6 +6,9 @@

 namespace XGraph.Controls
 {
+    /// <summary>
+    /// Class defining a node in the graph view.
+    /// </summary>
     [TemplatePart(Name = PART_PORT_CONTAINER, Type = typeof(PortContainer))]
     public class NodeView : ListBoxItem
     {


new: added constant for 2 PI

new: added constant for 2 PI

--- Zw.Geometry/Trigonometry.cs
+++ Zw.Geometry/Trigonometry.cs
@@ -24,6 +24,11 @@
         /// Constant value of Pi*1.5.
         /// </summary>
         public const double ONEHALF_PI = PI + HALF_PI;
+
+        /// <summary>
+        /// Constant value of Pi*2.
+        /// </summary>
+        public const double TWO_PI = Math.PI * 2;

         #endregion


Same thing, Client-only tests.

Same thing, Client-only tests.

--- targets/csharp-unity/testing/PlayFabApiTest_Client.cs
+++ targets/csharp-unity/testing/PlayFabApiTest_Client.cs
@@ -357,16 +357,16 @@
         [UUnitTest]
         public void LeaderBoard()
         {
-            var clientRequest = new ClientModels.GetLeaderboardAroundCurrentUserRequest();
+            var clientRequest = new ClientModels.GetLeaderboardRequest();
             clientRequest.MaxResultsCount = 3;
             clientRequest.StatisticName = TEST_STAT_NAME;
-            PlayFabClientAPI.GetLeaderboardAroundCurrentUser(clientRequest, GetClientLbCallback, SharedErrorCallback);
+            PlayFabClientAPI.GetLeaderboard(clientRequest, GetClientLbCallback, SharedErrorCallback);
             WaitForApiCalls();

             UUnitAssert.Equals("Get Client Leaderboard Successful", lastReceivedMessage);
             // Testing anything more would be testing actual functionality of the Leaderboard, which is outside the scope of this test.
         }
-        public void GetClientLbCallback(PlayFab.ClientModels.GetLeaderboardAroundCurrentUserResult result)
+        public void GetClientLbCallback(PlayFab.ClientModels.GetLeaderboardResult result)
         {
             if (result.Leaderboard.Count > 0)
                 lastReceivedMessage = "Get Client Leaderboard Successful";
@@ -417,15 +417,15 @@

             var request = new RunCloudScriptRequest();
             request.ActionId = "helloWorld";
-            PlayFabClientAPI.RunCloudScript(request, CloudScriptHWCallback, SharedErrorCallback);
-                WaitForApiCalls();
+            PlayFabClientAPI.RunCloudScript(request, CloudScriptHwCallback, SharedErrorCallback);
+            WaitForApiCalls();
             UUnitAssert.Equals("Hello " + playFabId + "!", lastReceivedMessage);
         }
         private void CloudScriptUrlCallback(GetCloudScriptUrlResult result)
         {
             lastReceivedMessage = "CloudScript setup complete: " + result.Url;
         }
-        private void CloudScriptHWCallback(RunCloudScriptResult result)
+        private void CloudScriptHwCallback(RunCloudScriptResult result)
         {
             UUnitAssert.NotNull(result.ResultsEncoded);
             JObject jobj = result.Results as JObject;


Update ToDoItemMarkCompleteShould

Update ToDoItemMarkCompleteShould

Changed Assertion to Single

--- tests/CleanArchitecture.Tests/Core/Entities/ToDoItemMarkCompleteShould.cs
+++ tests/CleanArchitecture.Tests/Core/Entities/ToDoItemMarkCompleteShould.cs
@@ -24,8 +24,8 @@

             item.MarkComplete();

-            Assert.Equal(1, item.Events.Count());
+            Assert.Single(item.Events);
             Assert.IsType<ToDoItemCompletedEvent>(item.Events.First());
         }
     }
-}+}


Remove ref to login page

Remove ref to login page

--- core/Piranha.Manager/ManagerExtensions.cs
+++ core/Piranha.Manager/ManagerExtensions.cs
@@ -310,7 +310,6 @@
             .AddRazorPagesOptions(options =>
             {
                 options.Conventions.AuthorizeAreaFolder("Manager", "/");
-                options.Conventions.AllowAnonymousToAreaPage("Manager", "/login");
             })
             .AddViewLocalization()
             .AddDataAnnotationsLocalization()


Version

Version

--- EngineLayer/GlobalEngineLevelSettings.cs
+++ EngineLayer/GlobalEngineLevelSettings.cs
@@ -40,8 +40,8 @@
             }

             MetaMorpheusVersion = typeof(GlobalEngineLevelSettings).Assembly.GetName().Version.ToString();
-            if (MetaMorpheusVersion.Equals("1.0.0.0"))
-                MetaMorpheusVersion = "Not a release version";
+            //if (MetaMorpheusVersion.Equals("1.0.0.0"))
+            //    MetaMorpheusVersion = "Not a release version";

             ProteaseDictionary = LoadProteaseDictionary();
             AllModsKnown = new List<Modification>();


Removed delay in test

Removed delay in test

--- ExFat.DiscUtils.Tests/TestEnvironment.cs
+++ ExFat.DiscUtils.Tests/TestEnvironment.cs
@@ -83,7 +83,6 @@
         {
             var previousDrives = DriveInfo.GetDrives();
             RunDiskPart("attach", _vhdxPath);
-            Thread.Sleep(500);
             var newDrives = DriveInfo.GetDrives();
             var mountedDrive = newDrives.FirstOrDefault(d => previousDrives.All(p => p.Name != d.Name));
             bool success = true;
@@ -98,7 +97,7 @@
             return Tuple.Create(success, checkResult);
         }

-        private void RunDiskPart(string action, string vdiskPath)
+        private static void RunDiskPart(string action, string vdiskPath)
         {
             var scriptPath = Path.GetTempFileName();
             using (var scriptStream = File.CreateText(scriptPath))


クローズしようとしたウインドウがアクティブなときは閉じないようにした。

クローズしようとしたウインドウがアクティブなときは閉じないようにした。

--- ExplorerWindowCleaner/ExplorerCleaner.cs
+++ ExplorerWindowCleaner/ExplorerCleaner.cs
@@ -5,6 +5,7 @@
 using System.Diagnostics;
 using System.IO;
 using System.Linq;
+using System.Runtime.InteropServices;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Data;
@@ -18,6 +19,9 @@
 {
     public class ExplorerCleaner
     {
+        [DllImport("user32.dll")]
+        static extern IntPtr GetForegroundWindow();
+
         private const string NowFileName = "now.json";
         private const string HistoryFileName = "history.json";
         private static int _seqNo = 0;
@@ -254,6 +258,7 @@
         private bool CloseExplorer(Explorer explorer)
         {
             if (explorer.IsPined) return false;
+            if (GetForegroundWindow() == (IntPtr) explorer.Handle) return false;
             var handle = explorer.Exit();
             _explorerDic.Remove(handle);
             UpdateClosedDictionary(explorer);


Fix DES-13064

Fix DES-13064

--- minuet/Paragon.Runtime/Kernel/Windowing/ApplicationWindow.cs
+++ minuet/Paragon.Runtime/Kernel/Windowing/ApplicationWindow.cs
@@ -1181,7 +1181,6 @@
                     BeginDownload(this, e);
                 }
             }
-
         }

         #region downloaderHandler
@@ -1220,10 +1219,10 @@

             IntPtr outPath;
             String DownloadFolderGuid = "{374DE290-123F-4565-9164-39C4925E467B}";
-            String DocumentFolderGuid = "{FDD39AD0-238F-46AF-ADB4-6C85480369C7}";
+            String DocumentFolderGuid = "{FDD39AD0-238F-46AF-ADB4-6C85480369C7}";
             Boolean defaultUser = false;
-
-            //1st: Try to get "Downloads" folder.
+
+            //1st: Try to get "Downloads" folder.
             int result = NativeMethods.SHGetKnownFolderPath(new Guid(DownloadFolderGuid),
                 (uint)NativeMethods.KnownFolderFlags.DontVerify, new IntPtr(defaultUser ? -1 : 0), out outPath);

@@ -1234,44 +1233,44 @@

             if (String.IsNullOrEmpty(pathDownload) || !System.IO.Directory.Exists(pathDownload) || !hasDirWritePerms(pathDownload))
             {
-                //2st: Try to get "Documents\Downloads" folder.
-                result = NativeMethods.SHGetKnownFolderPath(new Guid(DocumentFolderGuid),
-                (uint)NativeMethods.KnownFolderFlags.DontVerify, new IntPtr(defaultUser ? -1 : 0), out outPath);
-                if (result >= 0)
-                {
-                    pathDownload = Marshal.PtrToStringUni(outPath);
-                }
-                pathDownload = Path.Combine(pathDownload, "Downloads");
-
-                if (String.IsNullOrEmpty(pathDownload) || !System.IO.Directory.Exists(pathDownload) || !hasDirWritePerms(pathDownload))
-                {
-                    try
-                    {
-                        //3nd: Try to create Documents\Downloads older.
-                        Directory.CreateDirectory(pathDownload);
-                    }
-                    catch (Exception)
-                    {
-                        using (var folderDialog = new System.Windows.Forms.SaveFileDialog())
-                        {
-                            //Launches Save As dialog in case previous attempts fails.
-                            folderDialog.Filter = "All files (*.*)|*.*";
-                            folderDialog.Title = "Save As";
-                            folderDialog.FileName = fileName;
-                            folderDialog.OverwritePrompt = false;
-                            System.Windows.Forms.DialogResult option = folderDialog.ShowDialog();
-
-                            if (option == System.Windows.Forms.DialogResult.OK && !String.IsNullOrEmpty(folderDialog.FileName))
-                            {
-                                return folderDialog.FileName;
-                            }
-                            else
-                            {
-                                return null;
-                            }
-                        }
-                    }
-                }
+                //2st: Try to get "Documents\Downloads" folder.
+                result = NativeMethods.SHGetKnownFolderPath(new Guid(DocumentFolderGuid),
+                (uint)NativeMethods.KnownFolderFlags.DontVerify, new IntPtr(defaultUser ? -1 : 0), out outPath);
+                if (result >= 0)
+                {
+                    pathDownload = Marshal.PtrToStringUni(outPath);
+                }
+                pathDownload = Path.Combine(pathDownload, "Downloads");
+
+                if (String.IsNullOrEmpty(pathDownload) || !System.IO.Directory.Exists(pathDownload) || !hasDirWritePerms(pathDownload))
+                {
+                    try
+                    {
+                        //3nd: Try to create Documents\Downloads older.
+                        Directory.CreateDirectory(pathDownload);
+                    }
+                    catch (Exception)
+                    {
+                        using (var folderDialog = new System.Windows.Forms.SaveFileDialog())
+                        {
+                            //Launches Save As dialog in case previous attempts fails.
+                            folderDialog.Filter = "All files (*.*)|*.*";
+                            folderDialog.Title = "Save As";
+                            folderDialog.FileName = fileName;
+                            folderDialog.OverwritePrompt = false;
+                            System.Windows.Forms.DialogResult option = folderDialog.ShowDialog();
+
+                            if (option == System.Windows.Forms.DialogResult.OK && !String.IsNullOrEmpty(folderDialog.FileName))
+                            {
+                                return folderDialog.FileName;
+                            }
+                            else
+                            {
+                                return null;
+                            }
+                        }
+                    }
+                }
             }

             return Path.Combine(pathDownload, fileName);


level generator, first steps

level generator, first steps

--- GGJ2015/Assets/Scripts/LevelGenerator.cs
+++ GGJ2015/Assets/Scripts/LevelGenerator.cs
@@ -1,18 +1,123 @@
 using UnityEngine;
+using System;
 using System.Collections;
+
+public class Room
+{
+	public string[] tiles;
+
+	public Room(char type) {
+		switch (type) {
+			case '.':
+				tiles = new string[] { "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX" };
+				break;
+			case 'v':
+				tiles = new string[] { "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "..........",
+									   "..........",
+									   "XXXX..XXXX",
+									   "XXXX..XXXX",
+									   "XXXX..XXXX",
+									   "XXXX..XXXX" };
+				break;
+			case '^':
+				tiles = new string[] { "XXXX..XXXX",
+									   "XXXX..XXXX",
+									   "XXXX..XXXX",
+									   "XXXX..XXXX",
+									   "..........",
+									   "..........",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX" };
+				break;
+			case '-':
+				tiles = new string[] { "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "..........",
+									   "..........",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX",
+									   "XXXXXXXXXX" };
+				break;
+		}
+	}
+}

 public class LevelGenerator : MonoBehaviour {

 	public char[,] GenerateLevel() {

-		char[,] data = new char[10, 10];
+		const int roomsx = 12;
+		const int roomsy = 12;

-		for (int i = 0; i < 100; i++) {
-			for (int j = 0; j < 100; j++) {
-				data[i, j] = ' ';
+		const int tilesx = 10;
+		const int tilesy = 10;
+
+		char[,] rooms;
+		char[,] tiles;
+
+		rooms = new char[roomsx, roomsy];
+		tiles = new char[roomsx * tilesx, roomsy * tilesy];
+		Random rnd = new Random();
+
+		// generate rooms
+		for (int j = 0; j < roomsy; j++) {
+			for (int i = 0; i < roomsx; i++) {
+				rooms[i, j] = '-';
+			}
+		}
+		for (int j = 0; j < roomsy - 1; j++) {
+			for (;;) {
+				int i = rnd.Next(0, roomsx);
+				if (rooms[i, j] == '-') {
+					rooms[i, j] = 'v';
+					rooms[i, j + 1] = '^';
+					break;
+				}
+			}
+		}
+		for (int j = 0; j < roomsy; j++) {
+			int l = 0;
+			while (rooms[l, j] == '-' && l < roomsx) l++;
+			int r = roomsx - 1;
+			while (rooms[r, j] == '-' && r >= 0) r--;
+			l = rnd.Next(0, l);
+			r = rnd.Next(r + 1, roomsx);
+			for (int i = 0; i < l; i++) rooms[i, j] = '.';
+			for (int i = r; i < roomsx; i++) rooms[i, j] = '.';
+		}
+
+		// generate tiles from rooms
+		for (int j = 0; j < roomsy; j++) {
+			for (int i = 0; i < roomsx; i++) {
+				Room rm = new Room(rooms[i, j]);
+				for (int l = 0; l < tilesy; l++) {
+					for (int k = 0; k < tilesx; k++) {
+						tiles[i * tilesx + k, j * tilesy + l] = rm.tiles[l][k];
+					}
+				}
 			}
 		}

-		return data;
+		return tiles;
+
 	}
+
 }


Delete MyLoggingFilterAttribute.cs

Delete MyLoggingFilterAttribute.cs

--- GagyiBankMVC/MyLoggingFilterAttribute.cs
+++ GagyiBankMVC/MyLoggingFilterAttribute.cs
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Web.Mvc;
-
-namespace GagyiBankMVC
-{
-    public class MyLoggingFilterAttribute : ActionFilterAttribute
-    {
-        public override void OnActionExecuted(ActionExecutedContext filterContext)
-        {
-            var request = filterContext.HttpContext.Request;
-            base.OnActionExecuted(filterContext);
-        }
-    }
-}


Fix margin color for addition or modification

--- GitDiffMargin/ViewModel/DiffViewModel.cs
+++ GitDiffMargin/ViewModel/DiffViewModel.cs
@@ -44,7 +44,7 @@

             var bc = new BrushConverter();

-            DiffBrush = _hunkRangeInfo.IsAddition ? (Brush) bc.ConvertFrom("#E0FFE0") : (Brush) bc.ConvertFrom("#E0F0FF");
+            DiffBrush = _hunkRangeInfo.IsModification ? (Brush)bc.ConvertFrom("#0DC0FF") : (Brush)bc.ConvertFrom("#0DCE0E");

             ShowPopup = false;


Fix to enable TLS 1.2.

Fix to enable TLS 1.2.

--- Libraries/Sources/Network.cs
+++ Libraries/Sources/Network.cs
@@ -75,17 +75,21 @@

         /* ----------------------------------------------------------------- */
         ///
-        /// DisableOptions
+        /// Setup
         ///
         /// <summary>
-        /// Disables some network options.
+        /// Setup some network settings.
         /// </summary>
         ///
         /* ----------------------------------------------------------------- */
-        public static void DisableOptions()
+        public static void Setup()
         {
             ServicePointManager.Expect100Continue = false;
             ServicePointManager.UseNagleAlgorithm = false;
+            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls |
+                                                    SecurityProtocolType.Tls11 |
+                                                    SecurityProtocolType.Tls12;
+
             WebRequest.DefaultWebProxy = null;
         }


extracted TryConvertArguments from MethodBinder.Bind

--- src/runtime/methodbinder.cs
+++ src/runtime/methodbinder.cs
@@ -280,7 +280,6 @@
             // loop to find match, return invoker w/ or /wo error
             MethodBase[] _methods = null;
             var pynargs = (int)Runtime.PyTuple_Size(args);
-            object arg;
             var isGeneric = false;
             if (info != null)
             {
@@ -301,59 +300,15 @@
                 }
                 ParameterInfo[] pi = mi.GetParameters();
                 ArrayList defaultArgList;
-                int arrayStart;
-
-                if (!MatchesArgumentCount(pynargs, pi, out arrayStart, out defaultArgList)) {
+                bool paramsArray;
+
+                if (!MatchesArgumentCount(pynargs, pi, out paramsArray, out defaultArgList)) {
                     continue;
                 }
                 var outs = 0;
-                var margs = new object[pi.Length];
-
-                for (int paramIndex = 0; paramIndex < pi.Length; paramIndex++)
-                {
-                    if (paramIndex >= pynargs)
-                    {
-                        if (defaultArgList != null)
-                        {
-                            margs[paramIndex] = defaultArgList[paramIndex - pynargs];
-                        }
-
-                        continue;
-                    }
-
-                    IntPtr op = (arrayStart == paramIndex)
-                        // map remaining Python arguments to a tuple since
-                        // the managed function accepts it - hopefully :]
-                        ? Runtime.PyTuple_GetSlice(args, arrayStart, pynargs)
-                        : Runtime.PyTuple_GetItem(args, paramIndex);
-
-                    var parameter = pi[paramIndex];
-
-                    var clrtype = TryComputeClrArgumentType(parameter.ParameterType, op, needsResolution: _methods.Length > 1);
-                    if (clrtype == null) {
-                        margs = null;
-                        break;
-                    }
-
-                    if (parameter.IsOut || clrtype.IsByRef)
-                    {
-                        outs++;
-                    }
-
-                    if (!Converter.ToManaged(op, clrtype, out arg, false))
-                    {
-                        Exceptions.Clear();
-                        margs = null;
-                        break;
-                    }
-                    if (arrayStart == paramIndex)
-                    {
-                        // GetSlice() creates a new reference but GetItem()
-                        // returns only a borrow reference.
-                        Runtime.XDecref(op);
-                    }
-                    margs[paramIndex] = arg;
-                }
+                var margs = TryConvertArguments(pi, paramsArray, args, pynargs, defaultArgList,
+                    needsResolution: _methods.Length > 1,
+                    outs: out outs);

                 if (margs == null)
                 {
@@ -392,6 +347,65 @@
                 return Bind(inst, args, kw, mi, null);
             }
             return null;
+        }
+
+        static object[] TryConvertArguments(ParameterInfo[] pi, bool paramsArray,
+            IntPtr args, int pyArgCount,
+            ArrayList defaultArgList,
+            bool needsResolution,
+            out int outs)
+        {
+            outs = 0;
+            var margs = new object[pi.Length];
+            int arrayStart = paramsArray ? pi.Length - 1 : -1;
+
+            for (int paramIndex = 0; paramIndex < pi.Length; paramIndex++)
+            {
+                if (paramIndex >= pyArgCount)
+                {
+                    if (defaultArgList != null)
+                    {
+                        margs[paramIndex] = defaultArgList[paramIndex - pyArgCount];
+                    }
+
+                    continue;
+                }
+
+                IntPtr op = (arrayStart == paramIndex)
+                    // map remaining Python arguments to a tuple since
+                    // the managed function accepts it - hopefully :]
+                    ? Runtime.PyTuple_GetSlice(args, arrayStart, pyArgCount)
+                    : Runtime.PyTuple_GetItem(args, paramIndex);
+
+                var parameter = pi[paramIndex];
+
+                var clrtype = TryComputeClrArgumentType(parameter.ParameterType, op, needsResolution: needsResolution);
+                if (clrtype == null)
+                {
+                    return null;
+                }
+
+                if (parameter.IsOut || clrtype.IsByRef)
+                {
+                    outs++;
+                }
+
+                object arg;
+                if (!Converter.ToManaged(op, clrtype, out arg, false))
+                {
+                    Exceptions.Clear();
+                    return null;
+                }
+                if (arrayStart == paramIndex)
+                {
+                    // GetSlice() creates a new reference but GetItem()
+                    // returns only a borrow reference.
+                    Runtime.XDecref(op);
+                }
+                margs[paramIndex] = arg;
+            }
+
+            return margs;
         }

         static Type TryComputeClrArgumentType(Type parameterType, IntPtr argument, bool needsResolution)
@@ -465,12 +479,12 @@
         }

         static bool MatchesArgumentCount(int argumentCount, ParameterInfo[] parameters,
-            out int paramsArrayStart,
+            out bool paramsArray,
             out ArrayList defaultArgList)
         {
             defaultArgList = null;
             var match = false;
-            paramsArrayStart = -1;
+            paramsArray = false;

             if (argumentCount == parameters.Length)
             {
@@ -491,7 +505,7 @@
             {
                 // This is a `foo(params object[] bar)` style method
                 match = true;
-                paramsArrayStart = parameters.Length - 1;
+                paramsArray = true;
             }

             return match;


Modify allocator test to allow more threads and to switch between them.

--- allocator/Program.cs
+++ allocator/Program.cs
@@ -5,10 +5,14 @@
 {
     public class Program
     {
-        const int NumThreads = 2;
+        static int NumThreads = 2;

         public static void Main(string[] args)
         {
+            if(args.Length >= 1)
+            {
+                NumThreads = Convert.ToInt32(args[0]);
+            }
             Console.WriteLine($"Starting {NumThreads} threads.");

             Task[] workers = new Task[NumThreads];
@@ -31,8 +35,12 @@

             while(true)
             {
-                object o = new object();
-                GC.KeepAlive(o);
+                for(int i=0; i<10000; i++)
+                {
+                    object o = new object();
+                    GC.KeepAlive(o);
+                }
+                System.Threading.Thread.Sleep(0);
             }
         }
     }