Skip to content

Fix evaluations inside ref-returning methods#83037

Merged
AlekseyTs merged 1 commit intodotnet:mainfrom
asundheimMSFT:main
Apr 3, 2026
Merged

Fix evaluations inside ref-returning methods#83037
AlekseyTs merged 1 commit intodotnet:mainfrom
asundheimMSFT:main

Conversation

@asundheimMSFT
Copy link
Copy Markdown
Contributor

@asundheimMSFT asundheimMSFT commented Apr 2, 2026

Overview

After investigating this issue: https://developercommunity.visualstudio.com/t/Conditional-breakpoint-is-not-respecting/11063626

I determined that for evaluations inside ref-returning frames, the expression compiler would generate query method signatures indicating that the return type is T& (ref T), while the query method itself still returned T (as expected).

In particular, this bug breaks breakpoint conditions in VS; typical conditions rely on comparisons, which return Int32 and the debugger can make the implicit conversion from Int32 to the method signature bool return type. In ref-returning methods, the debugger cannot make the implicit conversion when the signature indicates bool&.

Details

Clearly this is an oversight on the C# expression compiler side; the VB EE already handles this correctly (EEMethodSymbol.vb)

Public Overrides ReadOnly Property ReturnsByRef As Boolean
    Get
        Return False
    End Get
End Property

The change is to make EEMethodSymbol not inherit RefKind and instead return RefKind.None.

Testing

Added unit test; deployed changes to experimental instance and verified the linked original issue is fixed.

Microsoft Reviewers: Open in CodeFlow

@dotnet-policy-service dotnet-policy-service bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Apr 2, 2026
@asundheimMSFT
Copy link
Copy Markdown
Contributor Author

@dotnet/roslyn-compiler for review

@RikkiGibson
Copy link
Copy Markdown
Member

Would probably be good for @tmat and @AlekseyTs to review if possible

Copy link
Copy Markdown
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 1)

@AlekseyTs AlekseyTs merged commit 8d42c9c into dotnet:main Apr 3, 2026
27 checks passed
@AlekseyTs
Copy link
Copy Markdown
Contributor

@asundheimMSFT Thank you for the contribution

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

Labels

Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants