Skip to content

Commit f3f21b4

Browse files
leculverCopilot
andauthored
Change DataTargetOptions init accessors to set (#1491)
* Change DataTargetOptions init accessors to set to fix cross-asset MissingMethodException The package multi-targets netstandard2.0 and net10.0. `init` accessors emit the setter with a required custom modifier (modreq) of System.Runtime.CompilerServices.IsExternalInit. On netstandard2.0 this type does not exist in-box, so the compiler synthesizes it inside Microsoft.Diagnostics.Runtime itself; on net10.0 it resolves to the BCL type in System.Private.CoreLib. Because a modreq is signature-significant, set_X carries a different signature in each asset. A library compiled against the netstandard2.0 asset bakes a call referencing the embedded IsExternalInit; when a net10+ application unifies ClrMD to the net10.0 asset at runtime, that method no longer exists and the consumer gets a MissingMethodException (e.g. a net8/netstandard2.0 library used by a net10 app). Reverting every init accessor on DataTargetOptions to set removes the modreq so set_X is identical across both assets, eliminating the mismatch. The options bag already mixed init and set (ForceCompleteRuntimeEnumeration was set). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Bump VersionPrefix 4.0.0 -> 4.1.0 The init->set change on DataTargetOptions is a binary-breaking change (removes the IsExternalInit modreq from the setters), so bump the minor version. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f289248 commit f3f21b4

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<!-- This repo version -->
5-
<VersionPrefix>4.0.0</VersionPrefix>
5+
<VersionPrefix>4.1.0</VersionPrefix>
66
<PreReleaseVersionLabel>
77
</PreReleaseVersionLabel>
88
<DotNetUseShippingVersions>true</DotNetUseShippingVersions>

src/Microsoft.Diagnostics.Runtime/DataTargetOptions.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class DataTargetOptions
1919
public CacheOptions CacheOptions
2020
{
2121
get => field ??= new CacheOptions();
22-
init;
22+
set;
2323
}
2424

2525
/// <summary>
@@ -28,7 +28,7 @@ public CacheOptions CacheOptions
2828
/// </summary>
2929
public IFileLocator FileLocator
3030
{
31-
init;
31+
set;
3232
get
3333
{
3434
if (field is null)
@@ -53,15 +53,15 @@ public IFileLocator FileLocator
5353
/// resolution.</remarks>
5454
public string SymbolCachePath
5555
{
56-
init;
56+
set;
5757
get => field ??= Path.Combine(Path.GetTempPath(), "symbols");
5858
}
5959

6060
/// <summary>
6161
/// The symbol path used by the default file locator if <see cref="FileLocator"/> is null. If
6262
/// <see cref="FileLocator"/> is non-null, this property has no effect.
6363
/// </summary>
64-
public string[] SymbolPaths { get; init; } = ["https://msdl.microsoft.com/download/symbols"];
64+
public string[] SymbolPaths { get; set; } = ["https://msdl.microsoft.com/download/symbols"];
6565

6666
/// <summary>
6767
/// If true, all runtimes in the target process will be enumerated. This enables us to find single-file runtimes
@@ -73,15 +73,15 @@ public string SymbolCachePath
7373
/// <summary>
7474
/// The TokenCredential to use for any Azure based symbol servers (set to null if not using one).
7575
/// </summary>
76-
public TokenCredential? SymbolTokenCredential { get; init; }
76+
public TokenCredential? SymbolTokenCredential { get; set; }
7777

7878
/// <summary>
7979
/// Gets or sets a value indicating whether detailed information about symbol requests is traced during execution.
8080
/// </summary>
8181
/// <remarks>When enabled, this property allows the tracing of all symbol resolution requests, which can
8282
/// be useful for debugging or analyzing symbol loading behavior. Tracing may produce a large amount of output and
8383
/// could impact performance.</remarks>
84-
public bool TraceSymbolRequests { get; init; }
84+
public bool TraceSymbolRequests { get; set; }
8585

8686
/// <summary>
8787
/// Safety limits for parsing and enumeration operations. These limits prevent excessive memory
@@ -90,7 +90,7 @@ public string SymbolCachePath
9090
public DataTargetLimits Limits
9191
{
9292
get => field ??= new DataTargetLimits();
93-
init;
93+
set;
9494
}
9595

9696
/// <summary>
@@ -99,15 +99,15 @@ public DataTargetLimits Limits
9999
/// from source). This only affects dacs with a signature.
100100
/// Note that disabling this option can lead to security risks, so it should only be disabled if you understand the implications.
101101
/// </summary>
102-
public bool VerifyDacOnWindows { get; init; } = true;
102+
public bool VerifyDacOnWindows { get; set; } = true;
103103

104104
/// <summary>
105105
/// An optional callback that decides, per DAC, whether ClrMD verifies its signature before loading it.
106106
/// When non-null this takes priority over <see cref="VerifyDacOnWindows"/>: it is invoked with the full
107107
/// (absolute) path of the DAC (or cDAC) ClrMD is about to load and if it returns <see langword="true"/>,
108108
/// signature verification is performed; if it returns <see langword="false"/>, verification is skipped.
109109
/// </summary>
110-
public Func<string, bool>? DacSignatureVerificationOverride { get; init; }
110+
public Func<string, bool>? DacSignatureVerificationOverride { get; set; }
111111

112112
/// <summary>
113113
/// When true, <see cref="DataTarget.LoadDump(string, DataTargetOptions?)"/> will wrap the underlying
@@ -134,12 +134,12 @@ public DataTargetLimits Limits
134134
/// as a 64-bit process) when loading large dumps from a 32-bit host.
135135
/// </para>
136136
/// </summary>
137-
public bool UseLockFreeMemoryMapReader { get; init; }
137+
public bool UseLockFreeMemoryMapReader { get; set; }
138138

139139
/// <summary>
140140
/// Optional host-supplied symbol provider. When set, ClrMD's COM data
141141
/// target wrapper exposes <c>ICLRSymbolProvider</c> and forwards its
142142
/// calls to this instance.
143143
/// </summary>
144-
public IClrSymbolProvider? SymbolProvider { get; init; }
144+
public IClrSymbolProvider? SymbolProvider { get; set; }
145145
}

0 commit comments

Comments
 (0)