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

CollectionBuilder .NET 8 #204

Open
jetersen opened this issue Nov 15, 2023 · 1 comment
Open

CollectionBuilder .NET 8 #204

jetersen opened this issue Nov 15, 2023 · 1 comment
Labels
kind/enhancement Improvements or new features

Comments

@jetersen
Copy link

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

.NET 8 added support for collection expression and also added an annotation CollectionBuilder I think there are many places the Pulumi .NET code could use these to improve code syntax :)

Especially for things like GetPolicyDocuments and Statements in AWS 🤔

Affected area/feature

@jetersen jetersen added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team labels Nov 15, 2023
@Frassle Frassle removed the needs-triage Needs attention from the triage team label Nov 15, 2023
@jetersen
Copy link
Author

jetersen commented Jan 5, 2024

You can get pretty close if you're willing to change your signature, by declaring the signature on the left side which seems to be the requirement for Collection Expression.

SecurityGroupIngressArgs[] ingress =
[
    new()
    {
        Protocol = "tcp",
        FromPort = 80,
        ToPort = 80,
        CidrBlocks = new[] { "" },
    },
];

var securityGroup = new SecurityGroup($"server-{suffix}-security-group", new()
{
    Name = $"server-{suffix}-security-group",
    VpcId = accountRegion.VpcId,
    Ingress = ingress,
});

The signature that is currently not supported although based on types it could be inferred. I am not sure if it is a compiler limitation or Pulumi limitation with the InputList types:

Egress = [
    new()
    {

    }
],

Neither is this supported:

Egress = [
    new SecurityGroupIngressArgs()
    {

    }
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

2 participants