-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add attribute to handle deserialization of constructor parameters with name overrides #231
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @praneetloke! Some comments.
Also, this needs tests. See
public async Task TestComplexType1() |
Your usage in the PR description doesn't quite look how I'd expect it to. I'd expect something like:
[OutputType]
public sealed class ListOneClicksProperties
{
public readonly ImmutableArray<Outputs.OneClicks> _1Clicks;
[OutputConstructor]
private ListOneClicksProperties([OutputConstructorParameter("1_clicks")] ImmutableArray<Outputs.OneClicks> _1Clicks)
{
this._1Clicks = _1Clicks;
}
}
/// constructor parameters with a name override. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Parameter)] | ||
public class ConstructorParameterNameOverrideAttribute : Attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type should be sealed
.
Also, I wonder if a better name would be OutputConstructorParameterAttribute
, to align with OutputConstructorAttribute
:
public class ConstructorParameterNameOverrideAttribute : Attribute | |
public sealed class OutputConstructorParameterAttribute : Attribute |
I also wonder if this should be moved directly below OutputConstructorAttribute
(line 76).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made changes for both suggestions you've made here. Also on the topic of the attribute class being sealed
I noticed that ResourceTypeAttribute
is not marked as such. That's the one I was using as reference and hence didn't mark the new one as sealed
initially. Would you like me to mark it as sealed
as well?
@justinvp I've pushed new commits with changes based on your feedback.
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 |
Bump. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you @praneetloke and apologies for the long delay getting this reviewed!
@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? |
Looks like you just need to run "dotnet run format-sdk" |
Ah got it. I'll remember that for next time. Thanks, @Frassle. |
…h name overrides (pulumi#231) * Add attribute to handle deserialization of constructor parameters with name overrides * changie new * Update names * Add a test. Address PR feedback. * Relocate new attribute
This PR is in support of pulumi/pulumi#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 pulumi/pulumi#14246 with additional changes to emit the attribute introduced in this PR.
Here's how it looks in practice in a provider's SDK: