Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Question to synthesized GeneratedNames for yield statement #68542

Closed
daveMueller opened this issue Jun 11, 2023 · 1 comment
Closed

Question to synthesized GeneratedNames for yield statement #68542

daveMueller opened this issue Jun 11, 2023 · 1 comment
Labels
Area-Compilers Question untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@daveMueller
Copy link

daveMueller commented Jun 11, 2023

Hi,

I would need some clarification on how the synthesized names are generated for yield statements. We have a bug in our
coverage tool coverlet-coverage/coverlet#1484 because of this.

To be more precise, when having a simple class like the following

public class PolicyNames
{
    public static IEnumerable<string> All()
    {
        yield return "1";
    }
}

the compiler is adding a nested type called <All>d__0

.class nested private auto ansi sealed beforefieldinit '<All>d__0'

So now when I add a simple field like the following

public class PolicyNames
{
    private string Read;

    public static IEnumerable<string> All()
    {
        yield return "1";
    }
}

the compiler is adding nested type called <All>d__1

.class nested private auto ansi sealed beforefieldinit '<All>d__1'

Our algorithem currently only counts methods for the ordinal number and I guess this is the problem. What exactly (fields, properties, ...) do I need to consider when computing this generated name?

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 11, 2023
@jcouv jcouv added the Question label Jun 16, 2023
@jcouv
Copy link
Member

jcouv commented Jun 16, 2023

Sorry, but the generation of closures is rather complicated and is an implementation detail (subject to change). Someone would have to dig into the compiler code, so we're unlikely to be able to help with this. I'll move the issue to a discussion

@dotnet dotnet locked and limited conversation to collaborators Jun 16, 2023
@jcouv jcouv converted this issue into discussion #68664 Jun 16, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Area-Compilers Question untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants