Skip to content

Commit

Permalink
Update to Corvus.HighPerformance 1.0 (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
idg10 authored Sep 10, 2024
1 parent fa84769 commit 37f1e60
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 102 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ branches:
- feature
- support
- hotfix
next-version: "2.0"
next-version: "2.1"

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.10" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.12">
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
116 changes: 38 additions & 78 deletions Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand All @@ -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, )",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -441,30 +421,30 @@
"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, )"
}
},
"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, )"
}
},
"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, )"
Expand Down Expand Up @@ -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, )",
Expand All @@ -590,22 +555,22 @@
},
"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"
}
},
"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"
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -882,29 +842,29 @@
"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, )"
}
},
"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, )"
}
},
"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, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.12">
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.3.0" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@


<ItemGroup>
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.12">
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.3.0" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.8" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ private static bool ProcessString(ReadOnlySpan<char> 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;
Expand All @@ -292,7 +295,9 @@ private static bool ProcessString(ReadOnlySpan<char> 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;
}

Expand Down
8 changes: 4 additions & 4 deletions Solutions/Corvus.UriTemplates/Corvus.UriTemplates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
<PackageReference Include="Corvus.HighPerformance" Version="0.2.0" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.12">
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.3.0" />
<PackageReference Include="Corvus.HighPerformance" Version="1.0.0" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 37f1e60

Please sign in to comment.