pulumi / pulumi-dotnet

.NET support for Pulumi
Apache License 2.0
28 stars 25 forks source link

Add attribute to handle deserialization of constructor parameters with name overrides #231

Closed praneetloke closed 8 months ago

praneetloke commented 9 months ago

This PR is in support of https://github.com/pulumi/pulumi/issues/14130.

I have a local override for the native provider in question to use the changes in this PR, as well as codegen changes in pulumi/pulumi using the PR https://github.com/pulumi/pulumi/pull/14246 with additional changes to emit the attribute introduced in this PR.

Here's how it looks in practice in a provider's SDK:

    [OutputType]
    public sealed class ListOneClicksProperties
    {
        public readonly ImmutableArray<Outputs.OneClicks> _1Clicks;

        [OutputConstructor]
        private ListOneClicksProperties([OutputConstructorParameterAttribute("1_clicks")] ImmutableArray<Outputs.OneClicks> _1Clicks)
        {
            this._1Clicks = _1Clicks;
        }
    }
praneetloke commented 9 months ago

@justinvp I've pushed new commits with changes based on your feedback.

Your usage in the PR description doesn't quite look how I'd expect it to. I'd expect something like:

Ah, indeed. I made a mistake in the codegen and wrote out the attribute on the class member instead of the constructor param...despite the name of the attribute 🤦‍♂️ . I'll fix that when I open the PR in pulumi/pulumi though. I've noted it down.

praneetloke commented 9 months ago

Bump.

praneetloke commented 8 months ago

@justinvp awesome! The status checks for this PR still says that the workflow requires approval from a maintainer though and haven't run. Any idea why that might be?

Frassle commented 8 months ago

Looks like you just need to run "dotnet run format-sdk"

praneetloke commented 8 months ago

Ah got it. I'll remember that for next time. Thanks, @Frassle.