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

(cloudwatch) System.ArgumentException : Could not infer JSII type for .NET type 'IWidget' (Parameter 'type') #12587

Closed
ghost opened this issue Jan 19, 2021 · 2 comments · Fixed by aws/jsii#2763
Assignees
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. effort/medium Medium work item – several days of effort language/dotnet Related to .NET bindings p1

Comments

@ghost
Copy link

ghost commented Jan 19, 2021

When trying to create a Dashboard using Dashboard props and IWidget Jagged array in the props, the unit test fail with error:
System.ArgumentException : Could not infer JSII type for .NET type 'IWidget' (Parameter 'type')

(dotnet build will compile the code successfully, while the App.Synth will fail)

Create the dashboard empty & adding the widget using the AddWidgets method works as expected.

Reproduction Steps

    public IResource CreateCloudWatchDashboard()
    {
    IWidget[][] widgets = new IWidget[1][]; 
    
    widgets[0]= new IWidget[1];

    widgets[0][0] = new LogQueryWidget (new LogQueryWidgetProps() {
        Height=6,
        Width=24,
        LogGroupNames=new []{"/some/valid/groupname"},
        Title="Task Activity Logs",
        QueryLines=new []{"some valid Query lines"},
        View=LogQueryVisualizationType.TABLE,
        Region="a valid region code"
    });

    var myDashboard = new Dashboard(Scope,  "dashboard", new DashboardProps()
    {
        DashboardName="Some Name",
        Widgets= widgets 
    
    } );
    return null;
   }

What did you expect to happen?

App.Synth() generates a valid CloudFormation template.

What actually happened?

System.ArgumentException : Could not infer JSII type for .NET type 'IWidget' (Parameter 'type')

Environment

  • CDK CLI Version : 1.85.0
  • Framework Version: .NET Core 3.1.11
  • Node.js Version: 14.15.2
  • OS : Windows 10 64bits
  • Language (Version): C#

Other

The following code will work as expected:

    public IResource CreateCloudWatchDashboard()
    {
    IWidget[][] widgets = new IWidget[1][]; 
    
    widgets[0]= new IWidget[1];

    widgets[0][0] = new LogQueryWidget (new LogQueryWidgetProps() {
        Height=6,
        Width=24,
        LogGroupNames=new []{"/some/valid/groupname"},
        Title="Task Activity Logs",
        QueryLines=new []{"some valid Query lines"},
        View=LogQueryVisualizationType.TABLE,
        Region="a valid region code"
    });

    var myDashboard = new Dashboard(Scope,  "dashboard", new DashboardProps()
    {
        DashboardName="Some Name"
    
    } );
    myDashboard.AddWidgets(widgets[0][0]);

    return null;
   }

This is 🐛 Bug Report

@ghost ghost added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 19, 2021
@NGL321 NGL321 changed the title C# / Amazon.CDK.AWS.CloudWatch / Dashboard / System.ArgumentException : Could not infer JSII type for .NET type 'IWidget' (Parameter 'type') (cloudwatch) System.ArgumentException : Could not infer JSII type for .NET type 'IWidget' (Parameter 'type') Jan 25, 2021
@NGL321 NGL321 added the language/dotnet Related to .NET bindings label Jan 25, 2021
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Jan 25, 2021
@RomainMuller RomainMuller added effort/medium Medium work item – several days of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Feb 16, 2021
@RomainMuller
Copy link
Contributor

Thanks for reporting. I will have a look into this.

RomainMuller added a commit to aws/jsii that referenced this issue Mar 31, 2021
When a 2-dimensional array of interfaces was passed, the `InferType`
function failed to account for interfaces, and failed instead of
correctly returning the relevant type reference.

Fixes aws/aws-cdk#12587
RomainMuller added a commit to aws/jsii that referenced this issue Mar 31, 2021
When a 2-dimensional array of interfaces was passed, the `InferType`
function failed to account for interfaces, and failed instead of
correctly returning the relevant type reference.

Fixes aws/aws-cdk#12587
mergify bot pushed a commit to aws/jsii that referenced this issue Apr 2, 2021
When a 2-dimensional array of interfaces was passed, the `InferType`
function failed to account for interfaces, and failed instead of
correctly returning the relevant type reference.

Fixes aws/aws-cdk#12587



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
@github-actions
Copy link

github-actions bot commented Apr 2, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. effort/medium Medium work item – several days of effort language/dotnet Related to .NET bindings p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants