Skip to content

Revert "Work around CS9363 for nameof of pointer-typed fields" - #130308

Merged
akoeplinger merged 1 commit into
mainfrom
revert-nameof
Jul 8, 2026
Merged

Revert "Work around CS9363 for nameof of pointer-typed fields"#130308
akoeplinger merged 1 commit into
mainfrom
revert-nameof

Conversation

@akoeplinger

Copy link
Copy Markdown
Member

This reverts commit 22c452b. The upstream roslyn fix is now in a compiler used by the repo.

This reverts commit 22c452b.
The upstream roslyn fix is now in a compiler used by the repo.
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

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 updates System.Runtime reflection tests to use nameof(...) again for pointer-typed and function-pointer-typed fields, removing the prior string-literal workaround in the test data now that the compiler issue is no longer needed.

Changes:

  • Replace hard-coded field name strings ("s_intPtr", "intPtr", "s_fcnPtr", etc.) with nameof(...) for pointer and function pointer fields in GetValue / SetValue test data.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Copilot Code Review

Holistic Assessment

Motivation: Justified — the PR reverts a temporary workaround (string literals instead of nameof) that was needed due to Roslyn bug CS9363. The upstream fix (dotnet/roslyn#84325) has now flowed into the repo's compiler, making the workaround unnecessary.

Approach: Correct — this is a clean revert restoring the idiomatic nameof(Type.Field) pattern, which provides compile-time verification of field names. The change is test-only and carries zero risk to production code.

Summary: ✅ LGTM. All 8 replacements correctly restore nameof(...) for pointer-typed fields (s_intPtr, intPtr, s_fcnPtr, fcnPtr, s_intPtr_Set, s_fcnPtr_Set). I verified each field name matches the actual declarations in MyStruct and MyStructWithFunctionPointers. No behavioral change — nameof produces the identical string value as the literals it replaces.


Detailed Findings

Detailed Findings

✅ Correctness — All nameof references match declared field names

Verified the struct definitions:

  • MyStruct.s_intPtrpublic unsafe static int* s_intPtr
  • MyStruct.intPtrpublic unsafe int* intPtr
  • MyStruct.s_intPtr_Setpublic unsafe static int* s_intPtr_Set
  • MyStructWithFunctionPointers.s_fcnPtrpublic unsafe static delegate*<void> s_fcnPtr
  • MyStructWithFunctionPointers.fcnPtrpublic unsafe delegate*<void> fcnPtr
  • MyStructWithFunctionPointers.s_fcnPtr_Setpublic unsafe static delegate*<void> s_fcnPtr_Set

✅ Scope — Change is minimal and focused

Only one file modified, only the workaround lines are reverted, no unrelated changes included.

Note

This review was created by GitHub Copilot.

Generated by Code Review for issue #130308 · ● 10.3M ·

@akoeplinger
akoeplinger merged commit 03d7a66 into main Jul 8, 2026
89 of 91 checks passed
@akoeplinger
akoeplinger deleted the revert-nameof branch July 8, 2026 09:01
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 10, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This reverts commit 22c452b. The
upstream roslyn fix is now in a compiler used by the repo.
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