Update vendored System.Runtime.CompilerServices.Unsafe#8469
Update vendored System.Runtime.CompilerServices.Unsafe#8469andrewlock merged 2 commits intomasterfrom
Conversation
| <!-- https://www.nuget.org/packages/System.Private.CoreLib/1.0.0 --> | ||
| <PackageReference Include="System.Private.CoreLib" Version="1.0.0" /> | ||
|
|
There was a problem hiding this comment.
This should be in the previous commit, but meh 😅
bdf65ae to
ef58938
Compare
0ec03d2 to
3af08ab
Compare
BenchmarksBenchmark execution time: 2026-04-23 10:32:28 Comparing candidate commit 112589a in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 27 metrics, 0 unstable metrics, 60 known flaky benchmarks, 27 flaky benchmarks without significant changes.
|
ef58938 to
7dc44a2
Compare
3af08ab to
528b407
Compare
7dc44a2 to
481fbc2
Compare
528b407 to
112589a
Compare
NachoEchevarria
left a comment
There was a problem hiding this comment.
Nice! Quick question: is the ultimate goal to stop using dotnet-vendored-code eventually?
Summary of changes
Reason for change
We want to be able to update vendored code as required. For the vendored System.Runtime.CompilerServices.Unsafe package, the source code is written directly as IL, and compiled using Ilasm.exe. So this PR introduces a simple "IL to C#" converter that converts that file to its C# equivalent, using the same
InlineIL.Fodyapproach that we currently have.The final result produces a file that is virtually identical to the existing one (which is good!). The only difference I made was to add the original IL line as a comment next to the Fody equivalent.
This also shows that the code has not actually changed (and it's unlikely it will tbh), so this just means we have a repeatable self-contained approach to regenerate this in the repo as required.
Implementation details
Told 🤖 to make the IL to C# converter, and it did 😄 I've given the code it generated a once-over to look for anything terrible, but the key thing is that the output is sane, and that's visibly basically unchanged, so I think it's fine.
Test coverage
@dudikeleti already wrote some extensive tests for the
Unsafeimplementation back when he originally ported it, which verifies that we can compile the methods, call them, and that the generated IL is identical to the "real" versions 🎉Other details
https://datadoghq.atlassian.net/browse/APMLP-1207
Part of a stack updating our vendored system code