Skip to content

Commit

Permalink
fix(dotnet): unable to pass 2d-array of interfaces (#2763)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RomainMuller committed Apr 2, 2021
1 parent a2d4ffe commit 347cf69
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Expand Up @@ -1512,5 +1512,18 @@ public override String Repeat(String word)
return word;
}
}

[Fact(DisplayName = Prefix + nameof(ArrayOfInterfaces))]
public void ArrayOfInterfaces()
{
var bells = new IBell[1][];
bells[0] = new IBell[1];
bells[0][0] = new Bell();

var allTypes = new AllTypes();
allTypes.AnyProperty = bells;

Assert.Equal(bells, allTypes.AnyProperty);
}
}
}
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -348,6 +348,12 @@ TypeReference InferType(IReferenceMap referenceMap, Type type)
return new TypeReference(enumAttribute.FullyQualifiedName);
}

var interfaceAttribute = type.GetCustomAttribute<JsiiInterfaceAttribute>();
if (interfaceAttribute != null)
{
return new TypeReference(interfaceAttribute.FullyQualifiedName);
}

var structAttribute = type.GetCustomAttribute<JsiiByValueAttribute>();
if (structAttribute != null)
{
Expand Down

0 comments on commit 347cf69

Please sign in to comment.