add products to TestData

add products to TestData

--- LINQ.Exercises/LINQ.Exercises/TestData.cs
+++ LINQ.Exercises/LINQ.Exercises/TestData.cs
@@ -90,6 +90,95 @@
             }
         }

+        // the following is used in common tests
+        internal static List<Product> Products
+        {
+            // Product data created in-memory using collection initializer:
+            get
+            {
+                return new List<Product> {
+                    new Product { ProductID = 1, ProductName = "Chai", Category = "Beverages", UnitPrice = 18.0000M, UnitsInStock = 39 },
+                    new Product { ProductID = 2, ProductName = "Chang", Category = "Beverages", UnitPrice = 19.0000M, UnitsInStock = 17 },
+                    new Product { ProductID = 3, ProductName = "Aniseed Syrup", Category = "Condiments", UnitPrice = 10.0000M, UnitsInStock = 13 },
+                    new Product { ProductID = 4, ProductName = "Chef Anton's Cajun Seasoning", Category = "Condiments", UnitPrice = 22.0000M, UnitsInStock = 53 },
+                    new Product { ProductID = 5, ProductName = "Chef Anton's Gumbo Mix", Category = "Condiments", UnitPrice = 21.3500M, UnitsInStock = 0 },
+                    new Product { ProductID = 6, ProductName = "Grandma's Boysenberry Spread", Category = "Condiments", UnitPrice = 25.0000M, UnitsInStock = 120 },
+                    new Product { ProductID = 7, ProductName = "Uncle Bob's Organic Dried Pears", Category = "Produce", UnitPrice = 30.0000M, UnitsInStock = 15 },
+                    new Product { ProductID = 8, ProductName = "Northwoods Cranberry Sauce", Category = "Condiments", UnitPrice = 40.0000M, UnitsInStock = 6 },
+                    new Product { ProductID = 9, ProductName = "Mishi Kobe Niku", Category = "Meat/Poultry", UnitPrice = 97.0000M, UnitsInStock = 29 },
+                    new Product { ProductID = 10, ProductName = "Ikura", Category = "Seafood", UnitPrice = 31.0000M, UnitsInStock = 31 },
+                    new Product { ProductID = 11, ProductName = "Queso Cabrales", Category = "Dairy Products", UnitPrice = 21.0000M, UnitsInStock = 22 },
+                    new Product { ProductID = 12, ProductName = "Queso Manchego La Pastora", Category = "Dairy Products", UnitPrice = 38.0000M, UnitsInStock = 86 },
+                    new Product { ProductID = 13, ProductName = "Konbu", Category = "Seafood", UnitPrice = 6.0000M, UnitsInStock = 24 },
+                    new Product { ProductID = 14, ProductName = "Tofu", Category = "Produce", UnitPrice = 23.2500M, UnitsInStock = 35 },
+                    new Product { ProductID = 15, ProductName = "Genen Shouyu", Category = "Condiments", UnitPrice = 15.5000M, UnitsInStock = 39 },
+                    new Product { ProductID = 16, ProductName = "Pavlova", Category = "Confections", UnitPrice = 17.4500M, UnitsInStock = 29 },
+                    new Product { ProductID = 17, ProductName = "Alice Mutton", Category = "Meat/Poultry", UnitPrice = 39.0000M, UnitsInStock = 0 },
+                    new Product { ProductID = 18, ProductName = "Carnarvon Tigers", Category = "Seafood", UnitPrice = 62.5000M, UnitsInStock = 42 },
+                    new Product { ProductID = 19, ProductName = "Teatime Chocolate Biscuits", Category = "Confections", UnitPrice = 9.2000M, UnitsInStock = 25 },
+                    new Product { ProductID = 20, ProductName = "Sir Rodney's Marmalade", Category = "Confections", UnitPrice = 81.0000M, UnitsInStock = 40 },
+                    new Product { ProductID = 21, ProductName = "Sir Rodney's Scones", Category = "Confections", UnitPrice = 10.0000M, UnitsInStock = 3 },
+                    new Product { ProductID = 22, ProductName = "Gustaf's Knäckebröd", Category = "Grains/Cereals", UnitPrice = 21.0000M, UnitsInStock = 104 },
+                    new Product { ProductID = 23, ProductName = "Tunnbröd", Category = "Grains/Cereals", UnitPrice = 9.0000M, UnitsInStock = 61 },
+                    new Product { ProductID = 24, ProductName = "Guaraná Fantástica", Category = "Beverages", UnitPrice = 4.5000M, UnitsInStock = 20 },
+                    new Product { ProductID = 25, ProductName = "NuNuCa Nuß-Nougat-Creme", Category = "Confections", UnitPrice = 14.0000M, UnitsInStock = 76 },
+                    new Product { ProductID = 26, ProductName = "Gumbär Gummibärchen", Category = "Confections", UnitPrice = 31.2300M, UnitsInStock = 15 },
+                    new Product { ProductID = 27, ProductName = "Schoggi Schokolade", Category = "Confections", UnitPrice = 43.9000M, UnitsInStock = 49 },
+                    new Product { ProductID = 28, ProductName = "Rössle Sauerkraut", Category = "Produce", UnitPrice = 45.6000M, UnitsInStock = 26 },
+                    new Product { ProductID = 29, ProductName = "Thüringer Rostbratwurst", Category = "Meat/Poultry", UnitPrice = 123.7900M, UnitsInStock = 0 },
+                    new Product { ProductID = 30, ProductName = "Nord-Ost Matjeshering", Category = "Seafood", UnitPrice = 25.8900M, UnitsInStock = 10 },
+                    new Product { ProductID = 31, ProductName = "Gorgonzola Telino", Category = "Dairy Products", UnitPrice = 12.5000M, UnitsInStock = 0 },
+                    new Product { ProductID = 32, ProductName = "Mascarpone Fabioli", Category = "Dairy Products", UnitPrice = 32.0000M, UnitsInStock = 9 },
+                    new Product { ProductID = 33, ProductName = "Geitost", Category = "Dairy Products", UnitPrice = 2.5000M, UnitsInStock = 112 },
+                    new Product { ProductID = 34, ProductName = "Sasquatch Ale", Category = "Beverages", UnitPrice = 14.0000M, UnitsInStock = 111 },
+                    new Product { ProductID = 35, ProductName = "Steeleye Stout", Category = "Beverages", UnitPrice = 18.0000M, UnitsInStock = 20 },
+                    new Product { ProductID = 36, ProductName = "Inlagd Sill", Category = "Seafood", UnitPrice = 19.0000M, UnitsInStock = 112 },
+                    new Product { ProductID = 37, ProductName = "Gravad lax", Category = "Seafood", UnitPrice = 26.0000M, UnitsInStock = 11 },
+                    new Product { ProductID = 38, ProductName = "Côte de Blaye", Category = "Beverages", UnitPrice = 263.5000M, UnitsInStock = 17 },
+                    new Product { ProductID = 39, ProductName = "Chartreuse verte", Category = "Beverages", UnitPrice = 18.0000M, UnitsInStock = 69 },
+                    new Product { ProductID = 40, ProductName = "Boston Crab Meat", Category = "Seafood", UnitPrice = 18.4000M, UnitsInStock = 123 },
+                    new Product { ProductID = 41, ProductName = "Jack's New England Clam Chowder", Category = "Seafood", UnitPrice = 9.6500M, UnitsInStock = 85 },
+                    new Product { ProductID = 42, ProductName = "Singaporean Hokkien Fried Mee", Category = "Grains/Cereals", UnitPrice = 14.0000M, UnitsInStock = 26 },
+                    new Product { ProductID = 43, ProductName = "Ipoh Coffee", Category = "Beverages", UnitPrice = 46.0000M, UnitsInStock = 17 },
+                    new Product { ProductID = 44, ProductName = "Gula Malacca", Category = "Condiments", UnitPrice = 19.4500M, UnitsInStock = 27 },
+                    new Product { ProductID = 45, ProductName = "Rogede sild", Category = "Seafood", UnitPrice = 9.5000M, UnitsInStock = 5 },
+                    new Product { ProductID = 46, ProductName = "Spegesild", Category = "Seafood", UnitPrice = 12.0000M, UnitsInStock = 95 },
+                    new Product { ProductID = 47, ProductName = "Zaanse koeken", Category = "Confections", UnitPrice = 9.5000M, UnitsInStock = 36 },
+                    new Product { ProductID = 48, ProductName = "Chocolade", Category = "Confections", UnitPrice = 12.7500M, UnitsInStock = 15 },
+                    new Product { ProductID = 49, ProductName = "Maxilaku", Category = "Confections", UnitPrice = 20.0000M, UnitsInStock = 10 },
+                    new Product { ProductID = 50, ProductName = "Valkoinen suklaa", Category = "Confections", UnitPrice = 16.2500M, UnitsInStock = 65 },
+                    new Product { ProductID = 51, ProductName = "Manjimup Dried Apples", Category = "Produce", UnitPrice = 53.0000M, UnitsInStock = 20 },
+                    new Product { ProductID = 52, ProductName = "Filo Mix", Category = "Grains/Cereals", UnitPrice = 7.0000M, UnitsInStock = 38 },
+                    new Product { ProductID = 53, ProductName = "Perth Pasties", Category = "Meat/Poultry", UnitPrice = 32.8000M, UnitsInStock = 0 },
+                    new Product { ProductID = 54, ProductName = "Tourtière", Category = "Meat/Poultry", UnitPrice = 7.4500M, UnitsInStock = 21 },
+                    new Product { ProductID = 55, ProductName = "Pâté chinois", Category = "Meat/Poultry", UnitPrice = 24.0000M, UnitsInStock = 115 },
+                    new Product { ProductID = 56, ProductName = "Gnocchi di nonna Alice", Category = "Grains/Cereals", UnitPrice = 38.0000M, UnitsInStock = 21 },
+                    new Product { ProductID = 57, ProductName = "Ravioli Angelo", Category = "Grains/Cereals", UnitPrice = 19.5000M, UnitsInStock = 36 },
+                    new Product { ProductID = 58, ProductName = "Escargots de Bourgogne", Category = "Seafood", UnitPrice = 13.2500M, UnitsInStock = 62 },
+                    new Product { ProductID = 59, ProductName = "Raclette Courdavault", Category = "Dairy Products", UnitPrice = 55.0000M, UnitsInStock = 79 },
+                    new Product { ProductID = 60, ProductName = "Camembert Pierrot", Category = "Dairy Products", UnitPrice = 34.0000M, UnitsInStock = 19 },
+                    new Product { ProductID = 61, ProductName = "Sirop d'érable", Category = "Condiments", UnitPrice = 28.5000M, UnitsInStock = 113 },
+                    new Product { ProductID = 62, ProductName = "Tarte au sucre", Category = "Confections", UnitPrice = 49.3000M, UnitsInStock = 17 },
+                    new Product { ProductID = 63, ProductName = "Vegie-spread", Category = "Condiments", UnitPrice = 43.9000M, UnitsInStock = 24 },
+                    new Product { ProductID = 64, ProductName = "Wimmers gute Semmelknödel", Category = "Grains/Cereals", UnitPrice = 33.2500M, UnitsInStock = 22 },
+                    new Product { ProductID = 65, ProductName = "Louisiana Fiery Hot Pepper Sauce", Category = "Condiments", UnitPrice = 21.0500M, UnitsInStock = 76 },
+                    new Product { ProductID = 66, ProductName = "Louisiana Hot Spiced Okra", Category = "Condiments", UnitPrice = 17.0000M, UnitsInStock = 4 },
+                    new Product { ProductID = 67, ProductName = "Laughing Lumberjack Lager", Category = "Beverages", UnitPrice = 14.0000M, UnitsInStock = 52 },
+                    new Product { ProductID = 68, ProductName = "Scottish Longbreads", Category = "Confections", UnitPrice = 12.5000M, UnitsInStock = 6 },
+                    new Product { ProductID = 69, ProductName = "Gudbrandsdalsost", Category = "Dairy Products", UnitPrice = 36.0000M, UnitsInStock = 26 },
+                    new Product { ProductID = 70, ProductName = "Outback Lager", Category = "Beverages", UnitPrice = 15.0000M, UnitsInStock = 15 },
+                    new Product { ProductID = 71, ProductName = "Flotemysost", Category = "Dairy Products", UnitPrice = 21.5000M, UnitsInStock = 26 },
+                    new Product { ProductID = 72, ProductName = "Mozzarella di Giovanni", Category = "Dairy Products", UnitPrice = 34.8000M, UnitsInStock = 14 },
+                    new Product { ProductID = 73, ProductName = "Röd Kaviar", Category = "Seafood", UnitPrice = 15.0000M, UnitsInStock = 101 },
+                    new Product { ProductID = 74, ProductName = "Longlife Tofu", Category = "Produce", UnitPrice = 10.0000M, UnitsInStock = 4 },
+                    new Product { ProductID = 75, ProductName = "Rhönbräu Klosterbier", Category = "Beverages", UnitPrice = 7.7500M, UnitsInStock = 125 },
+                    new Product { ProductID = 76, ProductName = "Lakkalikööri", Category = "Beverages", UnitPrice = 18.0000M, UnitsInStock = 57 },
+                    new Product { ProductID = 77, ProductName = "Original Frankfurter grüne Soße", Category = "Condiments", UnitPrice = 13.0000M, UnitsInStock = 32 }
+                };
+            }
+
+        }
+
         /// <summary>
         /// The following Data was using for the partioning Tests
         /// </summary>
@@ -103,8 +192,30 @@
             }
         }

-
-
-
+
+        /// <summary>
+        /// The following Data was using for the Orderby Tests
+        /// </summary>
+        ///
+
+        internal static  IEnumerable<string> OrderByWords
+        {
+            get { return new string[] { "cherry", "apple", "blueberry" }; }
+        }
+
+
+        internal static IEnumerable<string> OrderByWords1
+        {
+            get { return new string[] { "cherry", "apple", "blueberry", "tamarind", "zuchini" }; }
+        }
+    }
+
+    public class Product
+    {
+        public int ProductID { get; set; }
+        public string ProductName { get; set; }
+        public string Category { get; set; }
+        public decimal UnitPrice { get; set; }
+        public int UnitsInStock { get; set; }
     }
 }


from @xxMUROxx: set dpi factor to 1 as fallback

--- MahApps.Metro/Controls/GlowWindow.xaml.cs
+++ MahApps.Metro/Controls/GlowWindow.xaml.cs
@@ -132,19 +132,16 @@
                 if (_dpiFactor == null)
                 {

-                    PresentationSource source = PresentationSource.FromVisual(this.Owner);
+                    var source = PresentationSource.FromVisual(this.Owner);
                     double dpiX = 96.0, dpiY = 96.0;
                     if (source != null && source.CompositionTarget != null)
                     {
                         dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
                         dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;
                     }
-                    if (dpiX == dpiY)
-                    {
-                        _dpiFactor = dpiX / 96.0;
-                    }
+                    _dpiFactor = dpiX == dpiY ? dpiX / 96.0 : 1;
                 }
-                return _dpiFactor.HasValue ? _dpiFactor.Value : 1;
+                return _dpiFactor.Value;
             }

         }


fixed tests

fixed tests

--- DotNet.Basics.Tests/Diagnostics/InMemLoggerTests.cs
+++ DotNet.Basics.Tests/Diagnostics/InMemLoggerTests.cs
@@ -57,14 +57,15 @@
             logger.HasFailed().Should().BeTrue(logLevel.ToName());
         }
         [Test]
+        [TestCase(LogLevel.Debug)]
+        [TestCase(LogLevel.Verbose)]
+        [TestCase(LogLevel.Information)]
+        [TestCase(LogLevel.Warning)]
         public void HasFailed_LoggerNotFailed_FailNotDetected(LogLevel logLevel)
         {
             var logger = new InMemLogger();

-            logger.LogDebug("not failure");
-            logger.LogVerbose("not failure");
-            logger.LogInformation("not failure");
-            logger.LogWarning("not failure");
+            logger.Log("not failure", logLevel);

             logger.HasFailed().Should().BeFalse(logLevel.ToName());
         }


Always listen to Error, even after adding filter.

--- Mindscape.Raygun4Net4/RaygunHttpModule.cs
+++ Mindscape.Raygun4Net4/RaygunHttpModule.cs
@@ -18,36 +18,16 @@
       ExcludeErrorsBasedOnHttpStatusCode = HttpStatusCodesToExclude.Any();
       ExcludeErrorsFromLocal = RaygunSettings.Settings.ExcludeErrorsFromLocal;

-      bool addedFilter = false;
       if (GlobalFilters.Filters.Count == 1)
       {
         Filter filter = GlobalFilters.Filters.FirstOrDefault();
         if (filter != null && filter.Instance.GetType().FullName.Equals("System.Web.Mvc.HandleErrorAttribute"))
         {
           GlobalFilters.Filters.Add(new RaygunExceptionFilterAttribute(context, this));
-          addedFilter = true;
         }
       }

-      if (!addedFilter && !HasRaygunFilter)
-      {
-        context.Error += SendError;
-      }
-    }
-
-    private static bool HasRaygunFilter
-    {
-      get
-      {
-        foreach (Filter filter in GlobalFilters.Filters)
-        {
-          if (filter.Instance is RaygunExceptionFilterAttribute)
-          {
-            return true;
-          }
-        }
-        return false;
-      }
+      context.Error += SendError;
     }

     public void Dispose()


specific exception when docker-machine fails to resolve

This is related to Issue #150

--- Ductus.FluentDocker/Extensions/CommandExtensions.cs
+++ Ductus.FluentDocker/Extensions/CommandExtensions.cs
@@ -100,7 +100,7 @@

       if (string.IsNullOrEmpty(cmd))
       {
-        if (!string.IsNullOrEmpty(dockerCommand) && dockerCommand.ToLower() == "")
+        if (!string.IsNullOrEmpty(dockerCommand) && dockerCommand.ToLower() == "docker-machine")
           throw new FluentDockerException(
             $"Could not find {dockerCommand} make sure it is on your path. From 2.2.0 you have to seprately install it via https://github.com/docker/machine/releases");


Fixed bug in host hooks.

Fixed bug in host hooks.

--- EmotionCore/src/Engine/Hosting/Desktop/OtkWindow.cs
+++ EmotionCore/src/Engine/Hosting/Desktop/OtkWindow.cs
@@ -225,14 +225,14 @@
         /// <inheritdoc />
         protected override void OnResize(EventArgs e)
         {
-            _resizeHook();
+            _resizeHook?.Invoke();
         }

         /// <inheritdoc />
         protected override void OnClosing(CancelEventArgs e)
         {
             base.OnClosing(e);
-            _closeHook();
+            _closeHook?.Invoke();
         }

         #endregion


The under-construction packet scheduling still needs to notify of messages sent

--- GTClient/GTClient/Client.cs
+++ GTClient/GTClient/Client.cs
@@ -741,6 +741,8 @@
                     {
                         SendPacket(transport, result.RemovePacket());
                     }
+                    queue.Remove();
+                    NotifyMessageSent(pm.Message, transport);
                 }
                 catch (TransportError e)
                 {


Move image "use orig height" to refresh command

--- src/Band.Personalize/Band.Personalize.App.Universal/ViewModels/BandPageViewModel.cs
+++ src/Band.Personalize/Band.Personalize.App.Universal/ViewModels/BandPageViewModel.cs
@@ -221,10 +221,6 @@

             this.RefreshPersonalizationCommand.Execute(0);
             this.RefreshPersonalizationCommand.Execute(1);
-
-            this.IsUseOriginalBandHeight = this.CurrentBand.HardwareRevision != HardwareRevision.Band
-                ? this.CurrentMeTileImage.PixelHeight <= 102
-                : true;
         }

         /// <summary>
@@ -249,7 +245,11 @@

                     break;
                 case 1:
-                    this.CurrentMeTileImage = await this.bandPersonalizer.GetMeTileImage();
+                    var currentMeTileImage = await this.bandPersonalizer.GetMeTileImage();
+                    this.IsUseOriginalBandHeight = this.CurrentBand.HardwareRevision != HardwareRevision.Band
+                        ? currentMeTileImage.PixelHeight <= 102
+                        : true;
+                    this.CurrentMeTileImage = currentMeTileImage;
                     break;
                 default:
                     throw new ArgumentNullException($"Unhandled pivot index: {selectedPivotIndex}");


CON-3556 some extra logging

CON-3556 some extra logging

--- src/CommitmentsV2/SFA.DAS.CommitmentsV2.Api/Controllers/ApprenticeshipController.cs
+++ src/CommitmentsV2/SFA.DAS.CommitmentsV2.Api/Controllers/ApprenticeshipController.cs
@@ -115,6 +115,8 @@
         [Route("details/editenddate")]
         public async Task<IActionResult> EditEndDate([FromBody]EditEndDateRequest request)
         {
+            _logger.LogInformation("Edit end date apprenticeship api endpoint called for  : " + request.ApprenticeshipId);
+
             var response = await _mediator.Send(new EditEndDateRequestCommand
             {
                 ApprenticeshipId = request.ApprenticeshipId,
@@ -134,6 +136,8 @@
         [Route("{apprenticeshipId}/stop")]
         public async Task<IActionResult> StopApprenticeship(long apprenticeshipId, [FromBody] StopApprenticeshipRequest request)
         {
+            _logger.LogInformation("Stop apprenticeship api endpoint called for  : " + apprenticeshipId);
+
             await _mediator.Send(new StopApprenticeshipCommand(
                 request.AccountId,
                 apprenticeshipId,
@@ -149,6 +153,8 @@
         [Route("details/pause")]
         public async Task<IActionResult> Pause([FromBody]PauseApprenticeshipRequest request)
         {
+            _logger.LogInformation("Pause apprenticeship api endpoint called for  : " + request.ApprenticeshipId);
+
             var response = await _mediator.Send(new PauseApprenticeshipCommand
             {
                 ApprenticeshipId = request.ApprenticeshipId,
@@ -167,6 +173,8 @@
         [Route("details/resume")]
         public async Task<IActionResult> Resume([FromBody] ResumeApprenticeshipRequest request)
         {
+            _logger.LogInformation("Resume apprenticeship api endpoint called for  : " + request.ApprenticeshipId);
+
             var response = await _mediator.Send(new ResumeApprenticeshipCommand
             {
                 ApprenticeshipId = request.ApprenticeshipId,
@@ -178,7 +186,9 @@
         [HttpPut]
         [Route("{apprenticeshipId}/stopdate")]
         public async Task<IActionResult> UpdateApprenticeshipStopDate(long apprenticeshipId, [FromBody] ApprenticeshipStopDateRequest request)
-        {
+        {
+            _logger.LogInformation("Update apprenticeship stop date api endpoint called for  : " + apprenticeshipId);
+
             var response = await _mediator.Send(new UpdateApprenticeshipStopDateCommand(
                 request.AccountId,
                 apprenticeshipId,
@@ -212,6 +222,8 @@
         [Route("edit")]
         public async Task<IActionResult> EditApprenticeship([FromBody] EditApprenticeshipApiRequest request)
         {
+            _logger.LogInformation("Edit apprenticeship api endpoint called for  : " + request.ApprenticeshipId);
+
             var command = new EditApprenticeshipCommand { EditApprenticeshipRequest = request };
             var response = await _mediator.Send(command);


Adjust test based on merge.

Adjust test based on merge.

--- src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_InvalidStatement.cs
+++ src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_InvalidStatement.cs
@@ -396,9 +396,9 @@
                 PropertySubpatterns (0)
 ";
             var expectedDiagnostics = new DiagnosticDescription[] {
-                // file.cs(10,18): error CS0163: Control cannot fall through from one case label ('(string s1, string s2) _') to another
+                // file.cs(10,13): error CS0163: Control cannot fall through from one case label ('case (string s1, string s2) _:') to another
                 //             case (string s1, string s2) _:
-                Diagnostic(ErrorCode.ERR_SwitchFallThrough, "(string s1, string s2) _").WithArguments("(string s1, string s2) _").WithLocation(10, 18),
+                Diagnostic(ErrorCode.ERR_SwitchFallThrough, "case (string s1, string s2) _:").WithArguments("case (string s1, string s2) _:").WithLocation(10, 13),
                 // file.cs(11,27): error CS0029: Cannot implicitly convert type 'bool' to '(string, string)'
                 //                 /*<bind>*/goto case args is (var x1, var x2);/*</bind>*/
                 Diagnostic(ErrorCode.ERR_NoImplicitConv, "goto case args is (var x1, var x2);").WithArguments("bool", "(string, string)").WithLocation(11, 27),


Improved trim

Improved trim

--- src/FluentRestBuilder/Pipes/OrderByClientRequest/OrderByClientRequestInterpreter.cs
+++ src/FluentRestBuilder/Pipes/OrderByClientRequest/OrderByClientRequestInterpreter.cs
@@ -41,7 +41,7 @@
         private Tuple<string, OrderByDirection> ParseOrderBy(string orderByString)
         {
             return orderByString.StartsWith("!")
-                ? Tuple.Create(orderByString.Substring(1).Trim(), OrderByDirection.Descending)
+                ? Tuple.Create(orderByString.TrimStart('!', ' '), OrderByDirection.Descending)
                 : Tuple.Create(orderByString, OrderByDirection.Ascending);
         }
     }


Specify Shard Size when calculated size could be 10k or more.

https://github.com/elastic/elasticsearch/issues/51559

--- src/Foundatio.Parsers.ElasticQueries/Extensions/DefaultAggregationNodeExtensions.cs
+++ src/Foundatio.Parsers.ElasticQueries/Extensions/DefaultAggregationNodeExtensions.cs
@@ -9,7 +9,9 @@

 namespace Foundatio.Parsers.ElasticQueries.Extensions {
     public static class DefaultAggregationNodeExtensions {
-
+        // NOTE: We may want to read this dynamically from server settings.
+        public const int MAX_BUCKET_SIZE = 10000;
+
         public static AggregationBase GetDefaultAggregation(this IQueryNode node, IQueryVisitorContext context) {
             if (node is GroupNode groupNode)
                 return groupNode.GetDefaultAggregation(context);
@@ -54,7 +56,17 @@
                     };

                 case AggregationType.Terms:
-                    return new TermsAggregation("terms_" + node.GetOriginalField()) { Field = field, Size = node.GetProximityAsInt32(), MinimumDocumentCount = node.GetBoostAsInt32(), Meta = new Dictionary<string, object> { { "@field_type", property.Mapping?.Type } } };
+                    var agg = new TermsAggregation("terms_" + node.GetOriginalField()) {
+                        Field = field,
+                        Size = node.GetProximityAsInt32(),
+                        MinimumDocumentCount = node.GetBoostAsInt32(),
+                        Meta = new Dictionary<string, object> { { "@field_type", property.Mapping?.Type } }
+                    };
+
+                    if (agg.Size.HasValue && (agg.Size * 1.5 + 10) > MAX_BUCKET_SIZE)
+                        agg.ShardSize = Math.Max((int)agg.Size, MAX_BUCKET_SIZE);
+
+                    return agg;

                 case AggregationType.TopHits:
                     return new TopHitsAggregation("tophits") { Size = node.GetProximityAsInt32() };
@@ -125,7 +137,17 @@
                     };

                 case AggregationType.Terms:
-                    return new TermsAggregation("terms_" + node.GetOriginalField()) { Field = field, Size = node.GetProximityAsInt32(), MinimumDocumentCount = node.GetBoostAsInt32(), Meta = new Dictionary<string, object> { { "@field_type", mapping.Mapping?.Type } } };
+                    var agg = new TermsAggregation("terms_" + node.GetOriginalField()) {
+                        Field = field,
+                        Size = node.GetProximityAsInt32(),
+                        MinimumDocumentCount = node.GetBoostAsInt32(),
+                        Meta = new Dictionary<string, object> { { "@field_type", mapping.Mapping?.Type } }
+                    };
+
+                    if (agg.Size.HasValue && (agg.Size * 1.5 + 10) > MAX_BUCKET_SIZE)
+                        agg.ShardSize = Math.Max((int)agg.Size, MAX_BUCKET_SIZE);
+
+                    return agg;
             }

             return null;
@@ -149,13 +171,13 @@

         private static AggregationBase GetHistogramAggregation(string originalField, string field, string proximity, string boost, IQueryVisitorContext context) {
             double interval = 50;
-            if (double.TryParse(proximity, out double prox))
+            if (Double.TryParse(proximity, out double prox))
                 interval = prox;

             return new HistogramAggregation(originalField) {
                 Field = field,
                 MinimumDocumentCount = 0,
-                Interval = interval,
+                Interval = interval
             };
         }


cleanup/refactoring

cleanup/refactoring

--- src/Libraries/Thinktecture.IdentityServer.Protocols/OAuth2/OAuth2TokenController.cs
+++ src/Libraries/Thinktecture.IdentityServer.Protocols/OAuth2/OAuth2TokenController.cs
@@ -3,6 +3,7 @@
  * see license.txt
  */

+using System;
 using System.ComponentModel.Composition;
 using System.IdentityModel.Protocols.WSTrust;
 using System.Net;
@@ -27,19 +28,19 @@
         public IClientsRepository ClientsRepository { get; set; }

         [Import]
-        public ICodeTokenRepository RefreshTokenRepository { get; set; }
+        public ICodeTokenRepository CodeTokenRepository { get; set; }

         public OAuth2TokenController()
         {
             Container.Current.SatisfyImportsOnce(this);
         }

-        public OAuth2TokenController(IUserRepository userRepository, IConfigurationRepository configurationRepository, IClientsRepository clientsRepository, ICodeTokenRepository refreshTokenRepository)
+        public OAuth2TokenController(IUserRepository userRepository, IConfigurationRepository configurationRepository, IClientsRepository clientsRepository, ICodeTokenRepository codeTokenRepository)
         {
             UserRepository = userRepository;
             ConfigurationRepository = configurationRepository;
             ClientsRepository = clientsRepository;
-            RefreshTokenRepository = refreshTokenRepository;
+            CodeTokenRepository = codeTokenRepository;
         }

         public HttpResponseMessage Post([FromBody] TokenRequest tokenRequest)
@@ -97,30 +98,35 @@

         private HttpResponseMessage ProcessAuthorizationCodeRequest(Client client, string code, string tokenType)
         {
-            return ProcessRefreshTokenRequest(client, code, tokenType);
-        }
-
+            Tracing.Information("Processing authorization code token request for client: " + client.Name);
+            return ProcessCodeTokenRequest(client, code, tokenType);
+        }
+
         private HttpResponseMessage ProcessRefreshTokenRequest(Client client, string refreshToken, string tokenType)
         {
             Tracing.Information("Processing refresh token request for client: " + client.Name);
-
-            // 1. get refresh token from DB - if not exists: error
+            return ProcessCodeTokenRequest(client, refreshToken, tokenType);
+        }
+
+        private HttpResponseMessage ProcessCodeTokenRequest(Client client, string codeToken, string tokenType)
+        {
+            // 1. get code token from DB - if not exists: error
             CodeToken token;
-            if (RefreshTokenRepository.TryGetCode(refreshToken, out token))
+            if (CodeTokenRepository.TryGetCode(codeToken, out token))
             {
                 // 2. make sure the client is the same - if not: error
                 if (token.ClientId == client.ID)
                 {
                     // 3. call STS
-                    RefreshTokenRepository.DeleteCode(token.Code);
+                    CodeTokenRepository.DeleteCode(token.Code);
                     return CreateTokenResponse(token.UserName, client, new EndpointReference(token.Scope), tokenType, includeRefreshToken: client.AllowRefreshToken);
                 }

-                Tracing.Error("Invalid client for refresh token. " + client.Name + " / " + refreshToken);
-                return OAuthErrorResponseMessage(OAuth2Constants.Errors.InvalidGrant);
-            }
-
-            Tracing.Error("Refresh token not found. " + client.Name + " / " + refreshToken);
+                Tracing.Error("Invalid client for refresh token. " + client.Name + " / " + codeToken);
+                return OAuthErrorResponseMessage(OAuth2Constants.Errors.InvalidGrant);
+            }
+
+            Tracing.Error("Refresh token not found. " + client.Name + " / " + codeToken);
             return OAuthErrorResponseMessage(OAuth2Constants.Errors.InvalidGrant);
         }

@@ -147,7 +153,7 @@
             {
                 if (includeRefreshToken)
                 {
-                    tokenResponse.RefreshToken = RefreshTokenRepository.AddCode(CodeTokenType.RefreshTokenIdentifier, client.ID, userName, scope.Uri.AbsoluteUri);
+                    tokenResponse.RefreshToken = CodeTokenRepository.AddCode(CodeTokenType.RefreshTokenIdentifier, client.ID, userName, scope.Uri.AbsoluteUri);
                 }

                 var resp = Request.CreateResponse<TokenResponse>(HttpStatusCode.OK, tokenResponse);
@@ -168,6 +174,11 @@
         private HttpResponseMessage ValidateRequest(TokenRequest request, out Client client)
         {
             client = null;
+
+            if (request == null)
+            {
+                return OAuthErrorResponseMessage(OAuth2Constants.Errors.InvalidRequest);
+            }

             // grant type is required
             if (string.IsNullOrWhiteSpace(request.Grant_Type))
@@ -184,19 +195,16 @@
             }

             // resource owner password flow requires a well-formed scope
-            EndpointReference appliesTo = null;
             if (request.Grant_Type.Equals(OAuth2Constants.GrantTypes.Password))
             {
-                try
-                {
-                    appliesTo = new EndpointReference(request.Scope);
-                    Tracing.Information("OAuth2 endpoint called for scope: " + request.Scope);
-                }
-                catch
+                Uri appliesTo;
+                if (!Uri.TryCreate(request.Scope, UriKind.Absolute, out appliesTo))
                 {
                     Tracing.Error("Malformed scope: " + request.Scope);
                     return OAuthErrorResponseMessage(OAuth2Constants.Errors.InvalidScope);
                 }
+
+                Tracing.Information("OAuth2 endpoint called for scope: " + request.Scope);
             }

             if (!ValidateClient(out client))


Failing test for appendingevents to a newstream

--- src/Marten.Testing/Events/end_to_end_event_capture_and_fetching_the_stream_Tests.cs
+++ src/Marten.Testing/Events/end_to_end_event_capture_and_fetching_the_stream_Tests.cs
@@ -10,17 +10,7 @@
         [Fact]
         public void capture_events_to_a_new_stream_and_fetch_the_events_back()
         {
-            var store = DocumentStore.For(_ =>
-            {
-                _.AutoCreateSchemaObjects = AutoCreate.All;
-
-                _.Connection(ConnectionSource.ConnectionString);
-
-                _.Events.AddEventType(typeof (MembersJoined));
-                _.Events.AddEventType(typeof (MembersDeparted));
-            });
-
-            store.Advanced.Clean.DeleteAllEventData();
+            var store = InitStore();

             using (var session = store.OpenSession())
             {
@@ -41,17 +31,7 @@
         [Fact]
         public void capture_events_to_a_new_stream_and_fetch_the_events_back_with_stream_id_provided()
         {
-            var store = DocumentStore.For(_ =>
-            {
-                _.AutoCreateSchemaObjects = AutoCreate.All;
-
-                _.Connection(ConnectionSource.ConnectionString);
-
-                _.Events.AddEventType(typeof(MembersJoined));
-                _.Events.AddEventType(typeof(MembersDeparted));
-            });
-
-            store.Advanced.Clean.DeleteAllEventData();
+            var store = InitStore();

             using (var session = store.OpenSession())
             {
@@ -69,5 +49,48 @@
                 streamEvents.ElementAt(1).ShouldBeOfType<MembersDeparted>();
             }
         }
+
+
+        [Fact]
+        public void capture_events_to_a_non_existing_stream_and_fetch_the_events_back()
+        {
+            var store = InitStore();
+
+            using (var session = store.OpenSession())
+            {
+                var joined = new MembersJoined { Members = new string[] { "Rand", "Matt", "Perrin", "Thom" } };
+                var departed = new MembersDeparted { Members = new[] { "Thom" } };
+
+                var id = Guid.NewGuid();
+                session.Events.AppendEvents(id, joined, departed);
+                session.SaveChanges();
+
+                //Throws a   Marten.Testing.Events.end_to_end_event_capture_and_fetching_the_stream_Tests.capture_events_to_a_non_existing_stream_and_fetch_the_events_back [FAIL]
+                //Npgsql.NpgsqlException : 23502: null value in column "type" violates not-null constraint
+                //>>>>  "type" is stream_type in this case.
+                var streamEvents = session.Events.FetchStream<Quest>(id);
+
+                streamEvents.Count().ShouldBe(2);
+                streamEvents.ElementAt(0).ShouldBeOfType<MembersJoined>();
+                streamEvents.ElementAt(1).ShouldBeOfType<MembersDeparted>();
+            }
+        }
+
+
+        private static DocumentStore InitStore()
+        {
+            var store = DocumentStore.For(_ =>
+            {
+                _.AutoCreateSchemaObjects = AutoCreate.All;
+
+                _.Connection(ConnectionSource.ConnectionString);
+
+                _.Events.AddEventType(typeof(MembersJoined));
+                _.Events.AddEventType(typeof(MembersDeparted));
+            });
+
+            store.Advanced.Clean.DeleteAllEventData();
+            return store;
+        }
     }
 }