Skip to content

Add [DebuggerStepThrough] to ArgumentNullException.ThrowIfNull #123376

@scoraig52

Description

@scoraig52

Problem

When debugging with .NET Framework source stepping enabled, F11 steps into ArgumentNullException.ThrowIfNull on null input, breaking debugger flow.

Expected: Step through user's if (input == null) or skip via [DebuggerStepThrough]
Actual: Steps into framework source

Reproduction

  1. Enable "Enable .NET Framework source stepping" in VS Options
  2. F11 on ArgumentNullException.ThrowIfNull(input, nameof(input))
  3. Debugger enters framework method

Proposed Fix

[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ThrowIfNull([NotNull] object? argument, string? paramName = null)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions