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

DotNet: Unable to pass interface instance through in a Dictionary<string, object> #1044

Closed
nija-at opened this issue Nov 20, 2019 · 1 comment
Labels
bug This issue is a bug. closed-for-staleness effort/medium Medium work item – a couple days of effort language/dotnet Related to .NET bindings (C#, F#, ...) p1

Comments

@nija-at
Copy link
Contributor

nija-at commented Nov 20, 2019

🐛 Bug Report

Code: https://github.com/rix0rrr/jsii-test-drive/blob/master/dotnet/callback-any/src/CallbackAny/Program.cs#L81

Stack trace:

Unhandled exception. Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: System.ArgumentException: Could not infer JSII type for .NET type 'IResolvableProxy' (Parameter 'type')
   at Amazon.JSII.Runtime.Services.Converters.FrameworkToJsiiConverter.InferType(IReferenceMap referenceMap, Type type)
   at Amazon.JSII.Runtime.Services.Converters.FrameworkToJsiiConverter.InferType(IReferenceMap referenceMap, Object value)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.ConvertAny(Type type, IReferenceMap referenceMap, Object value)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertPrimitive(Type type, IReferenceMap referenceMap, Object value, Boolean isOptional, PrimitiveType primitiveType, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, Type type, IReferenceMap referenceMap, Object value, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(TypeReference typeReference, Type type, IReferenceMap referenceMap, Object value, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.FrameworkToJsiiConverter.TryConvertCollectionElement(Object element, IReferenceMap referenceMap, TypeReference elementType, Object& convertedElement)
   at Amazon.JSII.Runtime.Services.Converters.FrameworkToJsiiConverter.TryConvertMap(IReferenceMap referenceMap, TypeReference elementType, Object value, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertCollection(IReferenceMap referenceMap, Object value, Boolean isOptional, CollectionTypeReference collectionType, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, Type type, IReferenceMap referenceMap, Object value, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(TypeReference typeReference, Type type, IReferenceMap referenceMap, Object value, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.ConvertAny(Type type, IReferenceMap referenceMap, Object value)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertPrimitive(Type type, IReferenceMap referenceMap, Object value, Boolean isOptional, PrimitiveType primitiveType, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, Type type, IReferenceMap referenceMap, Object value, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.FrameworkToJsiiConverter.TryConvert(IOptionalValue optionalValue, IReferenceMap referenceMap, Object value, Object& result)
   at Amazon.JSII.Runtime.CallbackExtensions.InvokeCallback(Callback callback, IReferenceMap referenceMap, IFrameworkToJsiiConverter converter, String& error)
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
   at Amazon.JSII.Runtime.Services.Client.Invoke(InvokeRequest request)
   at Amazon.JSII.Runtime.Services.Client.Invoke(ObjectReference objectReference, String method, Object[] arguments)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass17_0`1.<InvokeInstanceMethod>b__1(IClient client, Object[] args)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Type[] parameterTypes, Object[] arguments, String methodName)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceVoidMethod(Type[] parameterTypes, Object[] arguments, String methodName)
   at Amazon.CDK.AWS.EC2.SecurityGroup.AddIngressRule(IPeer peer, Port connection, String description, Nullable`1 remoteRule)
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
   at Amazon.JSII.Runtime.Services.Client.Invoke(InvokeRequest request)
   at Amazon.JSII.Runtime.Services.Client.Invoke(ObjectReference objectReference, String method, Object[] arguments)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass17_0`1.<InvokeInstanceMethod>b__1(IClient client, Object[] args)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Type[] parameterTypes, Object[] arguments, String methodName)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceVoidMethod(Type[] parameterTypes, Object[] arguments, String methodName)
   at Amazon.CDK.AWS.EC2.Connections_.AllowFrom(IConnectable other, Port portRange, String description)
   at CallbackAny.Program.Main(String[] args) in /Users/nija/workplace/cdk/jsii-test-drive/dotnet/callback-any/src/CallbackAny/Program.cs:line 22
Subprocess exited with error 134

Impact to CDK

  • Values returned by CDK APIs typed as some instance (e.g: Lazy.anyValue returns IResolvable) cause a runtime type inference error when wrapped into a Dictionary<string, object> that is passed into a CDK API.
  • Workaround: when possible, use a more specific value type (e.g: Dictionary<string, IResolvable>), or use a dedicated CDK “props” type instead of Dictionary.
@nija-at nija-at added the bug This issue is a bug. label Nov 20, 2019
@RomainMuller RomainMuller changed the title .net: Can't use Lazy.anyValue() in a dictionary that accepts (typescript) any DotNet: Unable to pass interface instance through in a Dictionary<string, object> Nov 22, 2019
@RomainMuller RomainMuller added language/dotnet Related to .NET bindings (C#, F#, ...) p1 labels Nov 22, 2019
@MrArnoldPalmer MrArnoldPalmer added the effort/medium Medium work item – a couple days of effort label Aug 17, 2020
@MrArnoldPalmer MrArnoldPalmer removed their assignment Jun 28, 2021
@github-actions
Copy link
Contributor

This issue has not received any attention in 2 years. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jun 29, 2023
@github-actions github-actions bot closed this as completed Jul 5, 2023
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. closed-for-staleness effort/medium Medium work item – a couple days of effort language/dotnet Related to .NET bindings (C#, F#, ...) p1
Projects
None yet
Development

No branches or pull requests

3 participants