Skip to content

Config binder generator generates uncompilable code when a private nested type is used #90909

Closed
@stephentoub

Description

@stephentoub

This compiles fine:

using Microsoft.Extensions.Configuration;

internal class Program
{
    private static void Main() { }

    private static C Foo(IConfiguration configuration)
    {
        C c = new();
        configuration.Bind(c);
        return c;
    }

    internal sealed class C
    {
        public int Value { get; set; }
    }
}

but changing:

internal sealed class C

to

private sealed class C

produces an error about C being inaccessible, as the generator emits code into another class that tries to access that property.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions