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

[release/8.0] Fix binder gen compile issues due to inaccessible members and identifier name clashes #91967

Merged
merged 5 commits into from
Sep 14, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 12, 2023

Backport of #91657 to release/8.0

/cc @layomia

Customer Impact

Fixes two reported bugs. We expect users to hit them:

  1. Compilation failures when private nested types are specified as config targets:
using Microsoft.Extensions.Configuration;

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

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

    private sealed class C
    {
        public int Value { get; set; }
    }
}
  1. Errors due to generator using duplicate binding helper names to handle different types:
using Microsoft.Extensions.Configuration;

IConfiguration configuration = new ConfigurationBuilder().Build();

// Generator emits identifier `Cint` to handle both types causing a name clash.
var c1 = new Cint();
var c2 = new C<int>();
configuration.Bind(c1);
configuration.Bind(c2);

internal class C<T>
{
    public int Value { get; set; }
}

internal class Cint
{
    public int Value { get; set; }
}

Testing

Extensive unit and emitted source regression tests were added to verify the fix.

Risk

Low. Contained fix for off-by-default component. Minimal custom identifier mangling is done, instead we use more reliable Roslyn APIs.

@ghost
Copy link

ghost commented Sep 12, 2023

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

Issue Details

Backport of #91657 to release/8.0

/cc @layomia

Customer Impact

Testing

Risk

IMPORTANT: If this backport is for a servicing release, please verify that:

  • The PR target branch is release/X.0-staging, not release/X.0.

  • If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-Extensions-Configuration

Milestone: -

@layomia
Copy link
Contributor

layomia commented Sep 13, 2023

I've addressed all feedback on #91974. cc @eiriktsarpalis.

@layomia layomia force-pushed the backport/pr-91657-to-release/8.0 branch from c5811d2 to 95e712f Compare September 14, 2023 00:06
@layomia layomia removed the NO-REVIEW Experimental/testing PR, do NOT review it label Sep 14, 2023
@layomia layomia marked this pull request as ready for review September 14, 2023 00:07
@layomia layomia added the Servicing-consider Issue for next servicing release review label Sep 14, 2023
@layomia layomia requested review from ericstj and tarekgh September 14, 2023 00:07
Copy link
Member

@ericstj ericstj left a comment

Choose a reason for hiding this comment

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

Approve this change for RC2. Thank you for minimizing your diff on these fixes and reusing the code from Json. @artl93 this one is ready for your review.

Copy link
Member

@artl93 artl93 left a comment

Choose a reason for hiding this comment

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

M2 approved.

@artl93 artl93 removed the Servicing-consider Issue for next servicing release review label Sep 14, 2023
@artl93 artl93 added the Servicing-approved Approved for servicing release label Sep 14, 2023
@ericstj ericstj merged commit 1d60c69 into release/8.0 Sep 14, 2023
@jkotas jkotas deleted the backport/pr-91657-to-release/8.0 branch September 15, 2023 20:58
@radical radical mentioned this pull request Sep 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants