Update vendored System.Runtime.CompilerServices.Unsafe#8469
Update vendored System.Runtime.CompilerServices.Unsafe#8469andrewlock wants to merge 2 commits intoandrew/update-vendors-4from
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-16 14:23:18 Comparing candidate commit 3af08ab in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 27 metrics, 0 unstable metrics, 87 known flaky benchmarks.
|
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