C#: System.ArgumentNullException: Value cannot be null. (Parameter 'source')
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
### Describe the bug
The following works in TypeScript but doesn't work in C#:
```cs
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.
Contributor guide
Research direction
The report provides a C# reproduction using CfnPrefixList and contrasts it with TypeScript; start by running that snippet and tracing the Entries value returned by the construct. Compare the generated cross-language API behavior and identify the relevant jsii conversion boundary. Done means the C# example no longer yields null for Entries and can read the first Cidr without the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, typescript
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100