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

C#: JSII cannot infer type for IDictionary #4403

Open
JZechy opened this issue Jan 16, 2024 · 0 comments
Open

C#: JSII cannot infer type for IDictionary #4403

JZechy opened this issue Jan 16, 2024 · 0 comments
Labels
bug This issue is a bug. p1

Comments

@JZechy
Copy link

JZechy commented Jan 16, 2024

Describe the bug

When LINQ method ToDictionary() is used, it returns a dictionary, that is described by reflection as IDictionary<,>. When this type is used as a parameter for BuildSpec.FromObject(), JSII runs in to problems to recognize correct type throwing ArgumentException:

System.ArgumentException: Could not infer JSII type for .NET type 'IDictionary`2' (Parameter 'type')

Expected Behavior

Method BuildSpec.FromObject() is described in C# implementation of CDK as:

public static BuildSpec FromObject(IDictionary<string,object> value)

I would expect one of two things in this case:

  • JSII can handle interface type.
  • C# implementation will not allow to use interface type.

Current Behavior

Although CDK method is described that it can receive IDictionary, argument type cannot be described by C# reflection as interface.

Reproduction Steps

Pass to the BuildSpec.FromObject() any dictionary created through LINQ method ToDictionary().

Possible Solution

No response

Additional Information/Context

No response

SDK version used

2.121.1

Environment details (OS name and version, etc.)

Fedora 39

@JZechy JZechy added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 16, 2024
@mrgrain mrgrain added p1 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p1
Projects
None yet
Development

No branches or pull requests

2 participants