Skip to content

Deprecate ForceEnc: remove implicit debugger-attach EnC enablement, migrate to DOTNET_MODIFIABLE_ASSEMBLIES#130495

Draft
steveisok with Copilot wants to merge 3 commits into
mainfrom
copilot/deprecate-forceenc-migrate-dotnet-modifiable-assem
Draft

Deprecate ForceEnc: remove implicit debugger-attach EnC enablement, migrate to DOTNET_MODIFIABLE_ASSEMBLIES#130495
steveisok with Copilot wants to merge 3 commits into
mainfrom
copilot/deprecate-forceenc-migrate-dotnet-modifiable-assem

Conversation

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

ForceEnc was an undocumented, broken mechanism where attaching a debugger would implicitly set MetadataUpdater.IsSupported = true — even though MetadataUpdater.ApplyUpdate throws NotSupportedException when a debugger is attached. The correct path is DOTNET_MODIFIABLE_ASSEMBLIES=debug.

Changes

  • src/coreclr/vm/assemblynative.cpp — Simplified AssemblyNative_IsApplyUpdateSupported() to require explicit opt-in:

    // Before: implicit ForceEnc via debugger attachment
    result = (g_pConfig->ModifiableAssemblies() != MODIFIABLE_ASSM_NONE) &&
             (CORDebuggerAttached() || g_pConfig->ModifiableAssemblies() == MODIFIABLE_ASSM_DEBUG);
    
    // After: explicit opt-in only
    result = g_pConfig->ModifiableAssemblies() == MODIFIABLE_ASSM_DEBUG;

    The CORDebuggerAttached() path was doubly broken: ApplyUpdate throws when a debugger is attached, and since IsSupported is a cached static property, the check was also unreliable depending on when the MetadataUpdater type was first loaded relative to debugger attachment.

  • src/mono/mono/component/hot_reload.c — Fixed error messages to use lowercase 'debug' (matching the actual accepted env var value) instead of 'Debug'.

@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.

…ror messages

Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot July 10, 2026 16:04
Copilot AI changed the title [WIP] Deprecate ForceEnc and migrate tests to DOTNET_MODIFIABLE_ASSEMBLIES Deprecate ForceEnc: remove implicit debugger-attach EnC enablement, migrate to DOTNET_MODIFIABLE_ASSEMBLIES Jul 10, 2026
Copilot AI requested a review from steveisok July 10, 2026 16:05
@rcj1 rcj1 marked this pull request as ready for review July 10, 2026 16:31
@rcj1 rcj1 requested a review from vitek-karas as a code owner July 10, 2026 16:31
Copilot AI review requested due to automatic review settings July 10, 2026 16:31
@rcj1 rcj1 had a problem deploying to copilot-pat-pool July 10, 2026 16:31 — with GitHub Actions Failure
@rcj1 rcj1 marked this pull request as draft July 10, 2026 16:31
@rcj1 rcj1 removed the request for review from vitek-karas July 10, 2026 16:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 tightens metadata update / Hot Reload enablement to require explicit opt-in via DOTNET_MODIFIABLE_ASSEMBLIES=debug, and aligns Mono’s user-facing error text with the canonical value.

Changes:

  • CoreCLR: AssemblyNative_IsApplyUpdateSupported() now returns true only when g_pConfig->ModifiableAssemblies() == MODIFIABLE_ASSM_DEBUG (removing the implicit “debugger attached” enablement).
  • Mono: error messages now refer to 'debug' instead of 'Debug' when explaining the required DOTNET_MODIFIABLE_ASSEMBLIES value.
Show a summary per file
File Description
src/coreclr/vm/assemblynative.cpp Removes debugger-attach-based enablement for IsApplyUpdateSupported, requiring explicit MODIFIABLE_ASSM_DEBUG.
src/mono/mono/component/hot_reload.c Adjusts Hot Reload error messages to use lowercase 'debug' to match the documented/canonical env var value.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment on lines 1445 to 1447
#ifdef FEATURE_METADATA_UPDATER
result = (g_pConfig->ModifiableAssemblies() != MODIFIABLE_ASSM_NONE) &&
(CORDebuggerAttached() || g_pConfig->ModifiableAssemblies() == MODIFIABLE_ASSM_DEBUG);
result = g_pConfig->ModifiableAssemblies() == MODIFIABLE_ASSM_DEBUG;
#endif
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.

Deprecate ForceEnc and migrate scenarios to DOTNET_MODIFIABLE_ASSEMBLIES

4 participants