Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expression bodied method whose expression is a switch expression is missing debug info #37261

Closed
Tracked by #43099
tmat opened this issue Jul 16, 2019 · 2 comments
Closed
Tracked by #43099

Comments

@tmat
Copy link
Member

tmat commented Jul 16, 2019

using System;
public class C
{
    static int M() => F() switch
    {
        1 => 1,
        C { P: int p, Q: C { P: int q } } => G(() => p + q),
        _ => 0
    };

    object P { get; set; }
    object Q { get; set; }
    static object F() => null;
    static int G(Func<int> f) => 0;
}

Produces no debug info for method C.M (specifically, no sequence points).

Analysis:

ILBuilder.AllocateILMarker creates 2 ILMarkers, both at BlockOffset = 0: one user-code sequence point and another hidden one.
RealizeSequencePoints uses the last defined sequence point for the offset (the hidden one).
SequencePointList.GetSequencePoints then emits no sequence points since the only sequence point in the list is hidden.

The issue is with the hidden sequence point emitted for the switch expression closure.

See PDBTests.SwitchExpression_MethodBody.

@gafter
Copy link
Member

gafter commented Aug 20, 2019

See PDBTests.SwitchExpression_MethodBody.

@tmat Where could I find this method?

gafter added a commit to gafter/roslyn that referenced this issue Aug 21, 2019
…ion instruction in expression context

Fixes dotnet#37237

Compiler emits incorrect EnC closure data to PDB for nested switch expressions
Fixes dotnet#37232

Expression bodied method whose expression is a switch expression is missing debug info
Fixes dotnet#37261
@gafter gafter modified the milestones: Compiler.Next, 16.4 Aug 21, 2019
@gafter gafter added the Bug label Sep 19, 2019
@gafter gafter modified the milestones: 16.4, 16.5 Oct 29, 2019
@gafter gafter modified the milestones: 16.5, 16.6 Jan 13, 2020
@gafter gafter modified the milestones: 16.6, Compiler.Net5 Mar 14, 2020
@tmat
Copy link
Member Author

tmat commented Mar 23, 2020

See PDBTests.SwitchExpression_MethodBody.
@tmat Where could I find this method?

https://github.com/dotnet/roslyn/pull/37262/files#diff-bc2cd65a9d0c06f4c097bb33a5a771c3R8908

@ghost ghost closed this as completed in 2434f6c May 1, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants