cuddly-angle-21517
04/25/2023, 8:20 AMechoing-dinner-19531
04/25/2023, 8:26 AMapply
call with outputDetails. I think you should be able to cast directly to ImmutableArray<object>
and then pull out the inner object and cast that to a string. Shouldn't have to go through the whole JSON serialise/deserialise loop. Def something we want to make better here though.cuddly-angle-21517
04/25/2023, 8:44 AMechoing-dinner-19531
04/25/2023, 8:47 AM(string)(
(ImmutableArray<object>)((await networkStackRef.GetOutputDetailsAsync("eksVpcPrivateSubnetIds")).Value))
cuddly-angle-21517
04/25/2023, 8:50 AMechoing-dinner-19531
04/25/2023, 8:52 AM(string)(
((ImmutableArray<object>)(
(await networkStackRef.GetOutputDetailsAsync("eksVpcPrivateSubnetIds")).Value
))[0]
)
cuddly-angle-21517
04/25/2023, 8:57 AMechoing-dinner-19531
04/25/2023, 9:03 AM((ImmutableArray<object>)(
(await networkStackRef.GetOutputDetailsAsync("eksVpcPrivateSubnetIds")).Value
)).CastArray<string>()
cuddly-angle-21517
04/25/2023, 9:05 AMSystem.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
at object RuntimeType.CreateInstanceOfT()
at T Activator.CreateInstance<T>()
at Task<int> Pulumi.Deployment+Runner.Pulumi.IRunner.RunAsync<TStack>(IServiceProvider serviceProvider)+() => { }
at Task<int> Pulumi.Deployment+Runner.RunAsync<TStack>(Func<TStack> stackFactory) ---> System.InvalidCastException: Unable to cast object of type 'System.Object[]' to type 'System.String[]'.
at ImmutableArray<TOther> System.Collections.Immutable.ImmutableArray<T>.CastArray<TOther>()
at new UgcPubInfraStack() in E:/codes/wired/wired-ugc-pub-infra/UgcPubInfraStack.cs:line 59
at object RuntimeType.CreateInstanceOfT()
--- End of inner exception stack trace ---
echoing-dinner-19531
04/25/2023, 9:13 AMAs
instead of CastArray
cuddly-angle-21517
04/25/2023, 9:16 AMechoing-dinner-19531
04/25/2023, 9:26 AMImmutableArray.Create(((ImmutableArray<object>)(await networkStackRef.GetOutputDetailsAsync("eksVpcPrivateSubnetIds")).Value).Cast<string>())
Make sure using System.Linq;
is at the top of the file.cuddly-angle-21517
04/25/2023, 9:44 AMvar subnetIds = ImmutableArray.Create(((ImmutableArray<object>)(await networkStackRef.GetOutputDetailsAsync("eksVpcPrivateSubnetIds")).Value).Cast<string>());
System.Console.WriteLine(subnetIds.First());
var array = ((ImmutableArray<object>)networkingStackRef
.GetOutputDetailsAsync("eksVpcPrivateSubnetIds").Result.Value!).Cast<string>().ToArray();
the code above is okechoing-dinner-19531
04/25/2023, 10:10 AM