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

StackOverflowException in Configuration.Binder source generator #103802

Closed
bart-vmware opened this issue Jun 21, 2024 · 1 comment · Fixed by #106511
Closed

StackOverflowException in Configuration.Binder source generator #103802

bart-vmware opened this issue Jun 21, 2024 · 1 comment · Fixed by #106511
Assignees
Labels
area-Extensions-Configuration in-pr There is an active PR which will close this issue when it is merged source-generator Indicates an issue with a source generator feature
Milestone

Comments

@bart-vmware
Copy link

bart-vmware commented Jun 21, 2024

Repro steps

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
  </ItemGroup>
  
</Project>
using Microsoft.Extensions.Configuration;

namespace ClassLibrary7;

public class Class1
{
    public static void Bind(IConfiguration config)
    {
        var supported = new ExampleSettings();
        config.Bind(supported);
    }
}

public record ExampleSettings
{
    /// <summary>
    /// A recursive data structure
    /// </summary>
    public TreeElement? Tree { get; set; }
}

/// <summary>
/// Represents a free-format data structure.
/// </summary>
public sealed class TreeElement : Dictionary<string, TreeElement>;

Expected results

I'd expect the code to compile successfully.

Actual results

This results in a StackOverflowException in the Configuration Binder source generator. When this happens, it locks VS up and you need to force kill it (or let it eventually crash).

Original Description

Can you open an issue (and a PR if you'd like) in https://github.com/dotnet/runtime to get this included in the "real" source generator? As you noted, this is a copy of the runtime code.

Originally posted by @eerhardt in dotnet/aspire#4441 (comment)

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jun 21, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jun 21, 2024
@huoyaoyuan huoyaoyuan added area-Extensions-Configuration and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jun 21, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-configuration
See info in area-owners.md if you want to be subscribed.

@eerhardt eerhardt changed the title StackOverflowException in .NET Aspire StackOverflowException in Configuration.Binder source generator Jun 21, 2024
@tarekgh tarekgh added this to the 9.0.0 milestone Jun 21, 2024
@tarekgh tarekgh added source-generator Indicates an issue with a source generator feature and removed untriaged New issue has not been triaged by the area owner labels Jun 21, 2024
@tarekgh tarekgh self-assigned this Jun 21, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Aug 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Configuration in-pr There is an active PR which will close this issue when it is merged source-generator Indicates an issue with a source generator feature
Projects
None yet
3 participants