From 37f1e604745043b8f9b78012bdc2eed06ea30442 Mon Sep 17 00:00:00 2001 From: Ian Griffiths Date: Tue, 10 Sep 2024 15:45:05 +0100 Subject: [PATCH] Update to Corvus.HighPerformance 1.0 (#158) --- GitVersion.yml | 2 +- .../Corvus.UriTemplate.Benchmarking.csproj | 2 +- .../packages.lock.json | 116 ++++++------------ .../UriTemplateTests.csproj | 6 +- ...plates.Resolvers.DictionaryOfObject.csproj | 6 +- .../Corvus.UriTemplates.Resolvers.Json.csproj | 6 +- .../JsonTemplateParameterProvider.cs | 9 +- .../Corvus.UriTemplates.csproj | 8 +- .../VariableSpecification.cs | 8 +- 9 files changed, 61 insertions(+), 102 deletions(-) diff --git a/GitVersion.yml b/GitVersion.yml index 7fd7da9..649d9a3 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -20,5 +20,5 @@ branches: - feature - support - hotfix -next-version: "2.0" +next-version: "2.1" diff --git a/Solutions/Corvus.UriTemplate.Benchmarking/Corvus.UriTemplate.Benchmarking.csproj b/Solutions/Corvus.UriTemplate.Benchmarking/Corvus.UriTemplate.Benchmarking.csproj index f53ff57..00c1685 100644 --- a/Solutions/Corvus.UriTemplate.Benchmarking/Corvus.UriTemplate.Benchmarking.csproj +++ b/Solutions/Corvus.UriTemplate.Benchmarking/Corvus.UriTemplate.Benchmarking.csproj @@ -25,7 +25,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json b/Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json index 253832e..29e8fc2 100644 --- a/Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json +++ b/Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json @@ -37,11 +37,11 @@ }, "Endjin.RecommendedPractices.GitHub": { "type": "Direct", - "requested": "[2.1.12, )", - "resolved": "2.1.12", - "contentHash": "JEOlUQymdvrI6OeVHPTpakLhOJvkLdvmH+wJNNdjqSq3FtZ2LnqKei+4AMFUzTdJcL6RF3KGD3x0AqUfhYgWcw==", + "requested": "[2.1.13, )", + "resolved": "2.1.13", + "contentHash": "ZefZtlE4NE4ajKMzUtdeb9+SSWv95gutAykQmTEuj2Ln13/1etgxha9QFhrALHr+ewvUH7M3X1qh9HBmWMLRFg==", "dependencies": { - "Endjin.RecommendedPractices": "2.1.12", + "Endjin.RecommendedPractices": "2.1.13", "Microsoft.SourceLink.GitHub": "1.1.1" } }, @@ -54,21 +54,6 @@ "Microsoft.NETFramework.ReferenceAssemblies.net481": "1.0.3" } }, - "Roslynator.Analyzers": { - "type": "Direct", - "requested": "[4.12.3, )", - "resolved": "4.12.3", - "contentHash": "6+O9GwAxOxJr1rZ4aaLiBiSH3pxDkJuXLE8qjo/JXLvGkZhKRLbAz30WA32RmJb5Nn1TmjZ2T3kWt3GJmEDj1w==" - }, - "StyleCop.Analyzers": { - "type": "Direct", - "requested": "[1.2.0-beta.556, )", - "resolved": "1.2.0-beta.556", - "contentHash": "llRPgmA1fhC0I0QyFLEcjvtM2239QzKr/tcnbsjArLMJxJlu0AA5G7Fft0OI30pHF3MW63Gf4aSSsjc5m82J1Q==", - "dependencies": { - "StyleCop.Analyzers.Unstable": "1.2.0.556" - } - }, "Tavis.UriTemplates": { "type": "Direct", "requested": "[2.0.0, )", @@ -87,8 +72,8 @@ }, "CommunityToolkit.HighPerformance": { "type": "Transitive", - "resolved": "8.2.2", - "contentHash": "+zIp8d3sbtYaRbM6hqDs4Ui/z34j7DcUmleruZlYLE4CVxXq+MO8XJyIs42vzeTYFX+k0Iq1dEbBUnQ4z/Gnrw==", + "resolved": "8.3.0", + "contentHash": "2zc0Wfr9OtEbLqm6J1Jycim/nKmYv+v12CytJ3tZGNzw7n3yjh1vNCMX0kIBaFBk3sw8g0pMR86QJGXGlArC+A==", "dependencies": { "Microsoft.Bcl.HashCode": "1.1.1", "System.Memory": "4.5.5", @@ -98,8 +83,8 @@ }, "Corvus.HighPerformance": { "type": "Transitive", - "resolved": "0.2.0", - "contentHash": "ZYYx9P1cCMBazWkUqr5YDfZZPJ89ZBqeNEkQBxOjRZjRA5YGK2IVbEEXhC+go+5ffjl2zrT5C+B+BLaL5IYkrQ==", + "resolved": "1.0.0", + "contentHash": "ymxAkH0mhLXEggpIfbMDegA/wg4Q6PjOr2uUkHQX2HubqHD3hcOe2nf0yc3Y5GS9WHkSlc4asjTkP0rHsScDgg==", "dependencies": { "IndexRange": "1.0.3", "System.Buffers": "4.5.1", @@ -108,8 +93,8 @@ }, "Endjin.RecommendedPractices": { "type": "Transitive", - "resolved": "2.1.12", - "contentHash": "OZObdtlvF6isizGzO0Vydwmj2IR8GxydcTMGCoA9lmejnlCRWYPuyJXr3ULknlJ23hHDkyLFnu/xNA4duMr2SQ==", + "resolved": "2.1.13", + "contentHash": "ZXMVKFaBJYaAfRKS/Uv8kUANDsEj2L9H5L4XVXyZULI0UANqZ/ROVTpOqulkukf3UFc/jnnVG2EfByynTiztDg==", "dependencies": { "Microsoft.Build.Tasks.Git": "1.1.1" } @@ -256,8 +241,8 @@ }, "Microsoft.Extensions.ObjectPool": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "4pm+XgxSukskwjzDDfSjG4KNUIOdFF2VaqZZDtTzoyQMOVSnlV6ZM8a9aVu5dg9LVZTB//utzSc8fOi0b0Mb2Q==" + "resolved": "8.0.8", + "contentHash": "wnjTFjEvvSbOs3iMfl6CeJcUgPHZMYUB9uAQbGQGxGwVRl4GydNpMSkVntTzoi7AqQeYumU9yDSNeVbpq+ebow==" }, "Microsoft.Extensions.Options": { "type": "Transitive", @@ -313,11 +298,6 @@ "System.Memory": "4.5.3" } }, - "StyleCop.Analyzers.Unstable": { - "type": "Transitive", - "resolved": "1.2.0.556", - "contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ==" - }, "System.Buffers": { "type": "Transitive", "resolved": "4.5.1", @@ -441,10 +421,10 @@ "corvus.uritemplates": { "type": "Project", "dependencies": { - "CommunityToolkit.HighPerformance": "[8.2.2, )", - "Corvus.HighPerformance": "[0.2.0, )", + "CommunityToolkit.HighPerformance": "[8.3.0, )", + "Corvus.HighPerformance": "[1.0.0, )", "IndexRange": "[1.0.3, )", - "Microsoft.Extensions.ObjectPool": "[8.0.0, )", + "Microsoft.Extensions.ObjectPool": "[8.0.8, )", "System.Buffers": "[4.5.1, )", "System.Collections.Immutable": "[8.0.0, )" } @@ -452,9 +432,9 @@ "corvus.uritemplates.resolvers.dictionaryofobject": { "type": "Project", "dependencies": { - "CommunityToolkit.HighPerformance": "[8.2.2, )", + "CommunityToolkit.HighPerformance": "[8.3.0, )", "Corvus.UriTemplates": "[1.0.0, )", - "Microsoft.Extensions.ObjectPool": "[8.0.0, )", + "Microsoft.Extensions.ObjectPool": "[8.0.8, )", "System.Buffers": "[4.5.1, )", "System.Collections.Immutable": "[8.0.0, )" } @@ -462,9 +442,9 @@ "corvus.uritemplates.resolvers.json": { "type": "Project", "dependencies": { - "CommunityToolkit.HighPerformance": "[8.2.2, )", + "CommunityToolkit.HighPerformance": "[8.3.0, )", "Corvus.UriTemplates": "[1.0.0, )", - "Microsoft.Extensions.ObjectPool": "[8.0.0, )", + "Microsoft.Extensions.ObjectPool": "[8.0.8, )", "System.Buffers": "[4.5.1, )", "System.Collections.Immutable": "[8.0.0, )", "System.Text.Json": "[8.0.4, )" @@ -549,29 +529,14 @@ }, "Endjin.RecommendedPractices.GitHub": { "type": "Direct", - "requested": "[2.1.12, )", - "resolved": "2.1.12", - "contentHash": "JEOlUQymdvrI6OeVHPTpakLhOJvkLdvmH+wJNNdjqSq3FtZ2LnqKei+4AMFUzTdJcL6RF3KGD3x0AqUfhYgWcw==", + "requested": "[2.1.13, )", + "resolved": "2.1.13", + "contentHash": "ZefZtlE4NE4ajKMzUtdeb9+SSWv95gutAykQmTEuj2Ln13/1etgxha9QFhrALHr+ewvUH7M3X1qh9HBmWMLRFg==", "dependencies": { - "Endjin.RecommendedPractices": "2.1.12", + "Endjin.RecommendedPractices": "2.1.13", "Microsoft.SourceLink.GitHub": "1.1.1" } }, - "Roslynator.Analyzers": { - "type": "Direct", - "requested": "[4.12.3, )", - "resolved": "4.12.3", - "contentHash": "6+O9GwAxOxJr1rZ4aaLiBiSH3pxDkJuXLE8qjo/JXLvGkZhKRLbAz30WA32RmJb5Nn1TmjZ2T3kWt3GJmEDj1w==" - }, - "StyleCop.Analyzers": { - "type": "Direct", - "requested": "[1.2.0-beta.556, )", - "resolved": "1.2.0-beta.556", - "contentHash": "llRPgmA1fhC0I0QyFLEcjvtM2239QzKr/tcnbsjArLMJxJlu0AA5G7Fft0OI30pHF3MW63Gf4aSSsjc5m82J1Q==", - "dependencies": { - "StyleCop.Analyzers.Unstable": "1.2.0.556" - } - }, "Tavis.UriTemplates": { "type": "Direct", "requested": "[2.0.0, )", @@ -590,13 +555,13 @@ }, "CommunityToolkit.HighPerformance": { "type": "Transitive", - "resolved": "8.2.2", - "contentHash": "+zIp8d3sbtYaRbM6hqDs4Ui/z34j7DcUmleruZlYLE4CVxXq+MO8XJyIs42vzeTYFX+k0Iq1dEbBUnQ4z/Gnrw==" + "resolved": "8.3.0", + "contentHash": "2zc0Wfr9OtEbLqm6J1Jycim/nKmYv+v12CytJ3tZGNzw7n3yjh1vNCMX0kIBaFBk3sw8g0pMR86QJGXGlArC+A==" }, "Corvus.HighPerformance": { "type": "Transitive", - "resolved": "0.2.0", - "contentHash": "ZYYx9P1cCMBazWkUqr5YDfZZPJ89ZBqeNEkQBxOjRZjRA5YGK2IVbEEXhC+go+5ffjl2zrT5C+B+BLaL5IYkrQ==", + "resolved": "1.0.0", + "contentHash": "ymxAkH0mhLXEggpIfbMDegA/wg4Q6PjOr2uUkHQX2HubqHD3hcOe2nf0yc3Y5GS9WHkSlc4asjTkP0rHsScDgg==", "dependencies": { "System.Buffers": "4.5.1", "System.Memory": "4.5.5" @@ -604,8 +569,8 @@ }, "Endjin.RecommendedPractices": { "type": "Transitive", - "resolved": "2.1.12", - "contentHash": "OZObdtlvF6isizGzO0Vydwmj2IR8GxydcTMGCoA9lmejnlCRWYPuyJXr3ULknlJ23hHDkyLFnu/xNA4duMr2SQ==", + "resolved": "2.1.13", + "contentHash": "ZXMVKFaBJYaAfRKS/Uv8kUANDsEj2L9H5L4XVXyZULI0UANqZ/ROVTpOqulkukf3UFc/jnnVG2EfByynTiztDg==", "dependencies": { "Microsoft.Build.Tasks.Git": "1.1.1" } @@ -736,8 +701,8 @@ }, "Microsoft.Extensions.ObjectPool": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "4pm+XgxSukskwjzDDfSjG4KNUIOdFF2VaqZZDtTzoyQMOVSnlV6ZM8a9aVu5dg9LVZTB//utzSc8fOi0b0Mb2Q==" + "resolved": "8.0.8", + "contentHash": "wnjTFjEvvSbOs3iMfl6CeJcUgPHZMYUB9uAQbGQGxGwVRl4GydNpMSkVntTzoi7AqQeYumU9yDSNeVbpq+ebow==" }, "Microsoft.Extensions.Options": { "type": "Transitive", @@ -793,11 +758,6 @@ "System.Memory": "4.5.3" } }, - "StyleCop.Analyzers.Unstable": { - "type": "Transitive", - "resolved": "1.2.0.556", - "contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ==" - }, "System.Buffers": { "type": "Transitive", "resolved": "4.5.1", @@ -882,9 +842,9 @@ "corvus.uritemplates": { "type": "Project", "dependencies": { - "CommunityToolkit.HighPerformance": "[8.2.2, )", - "Corvus.HighPerformance": "[0.2.0, )", - "Microsoft.Extensions.ObjectPool": "[8.0.0, )", + "CommunityToolkit.HighPerformance": "[8.3.0, )", + "Corvus.HighPerformance": "[1.0.0, )", + "Microsoft.Extensions.ObjectPool": "[8.0.8, )", "System.Buffers": "[4.5.1, )", "System.Collections.Immutable": "[8.0.0, )" } @@ -892,9 +852,9 @@ "corvus.uritemplates.resolvers.dictionaryofobject": { "type": "Project", "dependencies": { - "CommunityToolkit.HighPerformance": "[8.2.2, )", + "CommunityToolkit.HighPerformance": "[8.3.0, )", "Corvus.UriTemplates": "[1.0.0, )", - "Microsoft.Extensions.ObjectPool": "[8.0.0, )", + "Microsoft.Extensions.ObjectPool": "[8.0.8, )", "System.Buffers": "[4.5.1, )", "System.Collections.Immutable": "[8.0.0, )" } @@ -902,9 +862,9 @@ "corvus.uritemplates.resolvers.json": { "type": "Project", "dependencies": { - "CommunityToolkit.HighPerformance": "[8.2.2, )", + "CommunityToolkit.HighPerformance": "[8.3.0, )", "Corvus.UriTemplates": "[1.0.0, )", - "Microsoft.Extensions.ObjectPool": "[8.0.0, )", + "Microsoft.Extensions.ObjectPool": "[8.0.8, )", "System.Buffers": "[4.5.1, )", "System.Collections.Immutable": "[8.0.0, )", "System.Text.Json": "[8.0.4, )" diff --git a/Solutions/Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj b/Solutions/Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj index a2b77b1..5660606 100644 --- a/Solutions/Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj +++ b/Solutions/Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj @@ -32,9 +32,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Solutions/Corvus.UriTemplates.Resolvers.DictionaryOfObject/Corvus.UriTemplates.Resolvers.DictionaryOfObject.csproj b/Solutions/Corvus.UriTemplates.Resolvers.DictionaryOfObject/Corvus.UriTemplates.Resolvers.DictionaryOfObject.csproj index 978d40b..cf554b0 100644 --- a/Solutions/Corvus.UriTemplates.Resolvers.DictionaryOfObject/Corvus.UriTemplates.Resolvers.DictionaryOfObject.csproj +++ b/Solutions/Corvus.UriTemplates.Resolvers.DictionaryOfObject/Corvus.UriTemplates.Resolvers.DictionaryOfObject.csproj @@ -17,14 +17,14 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Solutions/Corvus.UriTemplates.Resolvers.Json/Corvus.UriTemplates.Resolvers.Json.csproj b/Solutions/Corvus.UriTemplates.Resolvers.Json/Corvus.UriTemplates.Resolvers.Json.csproj index 01da2c2..9d341b9 100644 --- a/Solutions/Corvus.UriTemplates.Resolvers.Json/Corvus.UriTemplates.Resolvers.Json.csproj +++ b/Solutions/Corvus.UriTemplates.Resolvers.Json/Corvus.UriTemplates.Resolvers.Json.csproj @@ -22,14 +22,14 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Solutions/Corvus.UriTemplates.Resolvers.Json/Corvus.UriTemplates/JsonTemplateParameterProvider.cs b/Solutions/Corvus.UriTemplates.Resolvers.Json/Corvus.UriTemplates/JsonTemplateParameterProvider.cs index 131f88a..7644cbe 100644 --- a/Solutions/Corvus.UriTemplates.Resolvers.Json/Corvus.UriTemplates/JsonTemplateParameterProvider.cs +++ b/Solutions/Corvus.UriTemplates.Resolvers.Json/Corvus.UriTemplates/JsonTemplateParameterProvider.cs @@ -268,7 +268,10 @@ private static bool ProcessString(ReadOnlySpan span, in AppendValueState s { ValueStringBuilder output = new(span.Length * 2); WriteStringValue(ref output, span, state.PrefixLength, state.AllowReserved); - result = new(output.GetRentedBuffer(), output.Length); + + // TODO: why did none of our tests spot that this was erroneously using a length of 0 before? + (char[]? rentedBuffer, int length) = output.GetRentedBufferAndLengthAndDispose(); + result = new(rentedBuffer, length); // Do not dispose the value string builder, we have borrowed its innards return true; @@ -292,7 +295,9 @@ private static bool ProcessString(ReadOnlySpan span, in AppendNameAndValue WriteStringValue(ref output, span, state.PrefixLength, state.AllowReserved); - result = new(output.GetRentedBuffer(), output.Length); + // TODO: why did none of our tests spot that this was erroneously using a length of 0 before? + (char[]? rentedBuffer, int length) = output.GetRentedBufferAndLengthAndDispose(); + result = new(rentedBuffer, length); return true; } diff --git a/Solutions/Corvus.UriTemplates/Corvus.UriTemplates.csproj b/Solutions/Corvus.UriTemplates/Corvus.UriTemplates.csproj index 139b561..1566367 100644 --- a/Solutions/Corvus.UriTemplates/Corvus.UriTemplates.csproj +++ b/Solutions/Corvus.UriTemplates/Corvus.UriTemplates.csproj @@ -21,15 +21,15 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Solutions/Corvus.UriTemplates/Corvus.UriTemplates/TemplateParameterProviders/VariableSpecification.cs b/Solutions/Corvus.UriTemplates/Corvus.UriTemplates/TemplateParameterProviders/VariableSpecification.cs index aef9021..81b8f17 100644 --- a/Solutions/Corvus.UriTemplates/Corvus.UriTemplates/TemplateParameterProviders/VariableSpecification.cs +++ b/Solutions/Corvus.UriTemplates/Corvus.UriTemplates/TemplateParameterProviders/VariableSpecification.cs @@ -144,12 +144,6 @@ public override string ToString() builder.Append(this.PrefixLength); } - // Note that ValueStringBuilder.ToString is destructive: if it had to rent a buffer, - // it will be returned to the pool, and even if it didn't the position is reset, and - // the builder is essentially empty at this point. The intention is that if we want - // ValueBuilder to provide the result as an allocated string, we call ToString as the - // very last thing we do with the builder. - string result = builder.ToString(); - return result; + return builder.CreateStringAndDispose(); } } \ No newline at end of file