Skip to content

C#: System.ArgumentNullException: Value cannot be null. (Parameter 'source') #4894

@rix0rrr

Description

@rix0rrr

Describe the bug

The following works in TypeScript but doesn't work in C#:

var a = new CfnPrefixList(this, "SomeList", new CfnPrefixListProps()
{
    PrefixListName = "SomeList",
    MaxEntries = 3,
    AddressFamily = "IPv4",
    Entries = new[] {
        new EntryProperty { Cidr = "1.2.3.4/24", Description = "" },
        new EntryProperty { Cidr = "1.2.3.4/24", Description = "" },
        new EntryProperty { Cidr = "1.2.3.4/24", Description = "" }
    }
});

var b = a.Entries as CfnPrefixList.EntryProperty[];  // Returns null
var c = b.First().Cidr;  // Throws ArgumentNullException

Workaround

Recommended workaround: store the values in an array before passing them to the construct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions