Skip to content

[cDAC] Multi-target managed reader to net8.0/net9.0/net10.0#129008

Open
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:dev/maxcharlamb/cdac-multitarget
Open

[cDAC] Multi-target managed reader to net8.0/net9.0/net10.0#129008
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:dev/maxcharlamb/cdac-multitarget

Conversation

@max-charlamb
Copy link
Copy Markdown
Member

Note

This PR description was drafted with assistance from GitHub Copilot.

Multi-targets the cDAC managed reader transport packages so the published NuGets can be consumed by diagnostic tools running on older shipped runtimes (net8.0, net9.0, net10.0) in addition to $(NetCoreAppToolCurrent).

Projects changed to multi-target

  • Microsoft.Diagnostics.DataContractReader
  • Microsoft.Diagnostics.DataContractReader.Abstractions
  • Microsoft.Diagnostics.DataContractReader.Contracts
  • Microsoft.Diagnostics.DataContractReader.Legacy
  • Microsoft.Diagnostics.DataContractReader.TestInfrastructure
  • Microsoft.Diagnostics.DataContractReader.Tests

mscordaccore_universal and the dump/host harnesses remain single-target at $(NetCoreAppToolCurrent).

Downlevel source-compatibility fixes

  • Directory.Build.props — gate ExperimentalAttribute injection to net9+ (type does not exist on net8).
  • X86Unwinder.cs — replace ReadOnlySpan.Reverse() LINQ with a manual reverse loop (LINQ Reverse on ReadOnlySpan is net9+).
  • ClrDataModule.cs / MetaDataImportImplTests.cs — use Marshal.QueryInterface(..., ref Guid, ...) and suppress CS9191 (the in Guid overload is net9+).
  • DumpInfo.cs — gate Architecture.RiscV64 / LoongArch64 to net9+ (enum members added in net9).
  • LayoutSetSource.cs / Emitter.cs — drop params ReadOnlySpan<T> and emit collection-expression call sites (params ROS requires C# 13 / net9).
  • SOSDacImpl.cs / ISOSDacInterface.cs — rename vtable parameter to vtableAddr to avoid downlevel codegen ambiguity.
  • Tests.csproj — split mscordaccore_universal vs Legacy ProjectReference by TFM (universal is NAOT-published only at $(NetCoreAppToolCurrent)).

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Changes TargetFramework -> TargetFrameworks on the cDAC managed reader
projects so the shipped NuGet packages can be consumed by diagnostic
tools running on older shipped runtimes (net8.0, net9.0, net10.0) in
addition to $(NetCoreAppToolCurrent):

  Microsoft.Diagnostics.DataContractReader[.Abstractions|.Contracts|.Legacy]
  Microsoft.Diagnostics.DataContractReader.TestInfrastructure
  Microsoft.Diagnostics.DataContractReader.Tests

Source-level downlevel compatibility fixes:
  - Directory.Build.props: gate ExperimentalAttribute injection to net9+
    (the attribute type does not exist on net8).
  - X86Unwinder.cs: replace `ReadOnlySpan.Reverse()` LINQ usage with a
    manual reverse loop (LINQ Reverse on ReadOnlySpan is net9+).
  - ClrDataModule.cs + MetaDataImportImplTests.cs: use
    `Marshal.QueryInterface(..., ref Guid, ...)` and suppress CS9191;
    the `in Guid` overload is net9+.
  - DumpInfo.cs: gate `Architecture.RiscV64` / `LoongArch64` to
    net9+ (enum members added in net9).
  - LayoutSetSource.cs / Emitter.cs: drop `params ReadOnlySpan<T>` and
    emit collection-expression call sites; `params ROS` requires
    C# 13 / net9.
  - SOSDacImpl.cs / ISOSDacInterface.cs: rename `vtable` parameter to
    `vtableAddr` to avoid downlevel codegen ambiguity.
  - Tests.csproj: split mscordaccore_universal vs Legacy ProjectReference
    by TFM (universal is NAOT-published only at NetCoreAppToolCurrent).
@max-charlamb max-charlamb force-pushed the dev/maxcharlamb/cdac-multitarget branch from 76bcb5f to e3bb85d Compare June 4, 2026 19:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the managed cDAC reader (and its test infrastructure) to multi-target net8.0, net9.0, net10.0, and $(NetCoreAppToolCurrent), and applies small source-compatibility changes so the codebase compiles across those TFMs.

Changes:

  • Multi-target several cDAC projects (product + test infra/tests) to $(NetCoreAppToolCurrent);net10.0;net9.0;net8.0.
  • Gate or rewrite API usages that are not available on net8.0 (e.g., ExperimentalAttribute injection, ReadOnlySpan LINQ Reverse, Marshal.QueryInterface overload selection, Architecture enum members).
  • Update generator-emitted callsites and helper APIs to avoid params ReadOnlySpan<T> and to emit collection-expression-style arguments.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/native/managed/cdac/tests/UnitTests/Microsoft.Diagnostics.DataContractReader.Tests.csproj Multi-target unit tests and conditionally reference mscordaccore_universal vs Legacy by TFM.
src/native/managed/cdac/tests/UnitTests/MetaDataImportImplTests.cs Use Marshal.QueryInterface(..., ref Guid, ...) with CS9191 suppression for net8 compatibility.
src/native/managed/cdac/tests/TestInfrastructure/Microsoft.Diagnostics.DataContractReader.TestInfrastructure.csproj Multi-target reusable test infrastructure library.
src/native/managed/cdac/tests/TestInfrastructure/DumpInfo.cs Gate Architecture.RiscV64/LoongArch64 usage behind NET9_0_OR_GREATER.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader/Microsoft.Diagnostics.DataContractReader.csproj Multi-target main DataContractReader project.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs Rename parameter in ISOSDacInterface.GetFrameName implementation to match interface change.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Microsoft.Diagnostics.DataContractReader.Legacy.csproj Multi-target Legacy project.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ISOSDacInterface.cs Renames GetFrameName parameter (vtablevtableAddr).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataModule.cs Use Marshal.QueryInterface(..., ref Guid, ...) with CS9191 suppression for net8 compatibility.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Microsoft.Diagnostics.DataContractReader.Contracts.csproj Multi-target Contracts project.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86/X86Unwinder.cs Replace LINQ Reverse() enumeration with a manual reverse loop.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Microsoft.Diagnostics.DataContractReader.Abstractions.csproj Multi-target Abstractions project (and continue packing the generator analyzer).
src/native/managed/cdac/gen/LayoutSetSource.cs Remove params ReadOnlySpan<string> from generated LayoutSet APIs.
src/native/managed/cdac/gen/Emitter.cs Update generator output to pass name candidates as collection expressions (matching the ReadOnlySpan<string> signature).
src/native/managed/cdac/Directory.Build.props Gate ExperimentalAttribute assembly attribute injection to net9+ TFMs.

Comment on lines 759 to +761
// Frames
[PreserveSig]
int GetFrameName(ClrDataAddress vtable, uint count, char* frameName, uint* pNeeded);
int GetFrameName(ClrDataAddress vtableAddr, uint count, char* frameName, uint* pNeeded);
@noahfalk
Copy link
Copy Markdown
Member

noahfalk commented Jun 4, 2026

Is SOS the only intended target for this or are there other tools you had in mind? SOS needs to be runnable against .NET Framework so downlevel targetting to 8 wouldn't be enough for that one. Multi-targetting will increase our build and test times so I'd only suggest we do it if we've got specific tool scenarios that need an older TFM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants