aws / aws/jsii

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

Open
#4,894 0 comments 0 reactions 0 assignees View on GitHub
bug p2
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.