diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c090978c366..ea883ce028d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ CHANGELOG - Automatic plugin acquisition for Go [#4297](https://github.com/pulumi/pulumi/pull/4297) +- Add overloads to Output.All in .NET + [#4321](https://github.com/pulumi/pulumi/pull/4321) + ## 1.14.0 (2020-04-01) - Fix error related to side-by-side versions of `@pulumi/pulumi`. [#4235](https://github.com/pulumi/pulumi/pull/4235) diff --git a/sdk/dotnet/Pulumi.Tests/Core/OutputTests.cs b/sdk/dotnet/Pulumi.Tests/Core/OutputTests.cs index 2949e573047c..082a50f3ebf0 100644 --- a/sdk/dotnet/Pulumi.Tests/Core/OutputTests.cs +++ b/sdk/dotnet/Pulumi.Tests/Core/OutputTests.cs @@ -1,6 +1,7 @@ // Copyright 2016-2019, Pulumi Corporation using System.Collections.Immutable; +using System.Linq; using System.Threading.Tasks; using Pulumi.Serialization; using Xunit; @@ -246,6 +247,52 @@ public Task ApplyDoesNotPropagateSecretOnUnknownUnknownOutput() Assert.False(data.IsSecret); Assert.Null(data.Value); }); + + [Fact] + public Task AllParamsOutputs() + => RunInPreview(async () => + { + var o1 = CreateOutput(1, isKnown: true); + var o2 = CreateOutput(2, isKnown: true); + var o3 = Output.All(o1, o2); + var data = await o3.DataTask.ConfigureAwait(false); + Assert.Equal(new[] { 1, 2 }, data.Value); + }); + + [Fact] + public Task AllEnumerableOutputs() + => RunInPreview(async () => + { + var o1 = CreateOutput(1, isKnown: true); + var o2 = CreateOutput(2, isKnown: true); + var outputs = new[] {o1, o2}.AsEnumerable(); + var o3 = Output.All(outputs); + var data = await o3.DataTask.ConfigureAwait(false); + Assert.Equal(new[] { 1, 2 }, data.Value); + }); + + [Fact] + public Task AllParamsInputs() + => RunInPreview(async () => + { + var i1 = (Input)CreateOutput(1, isKnown: true); + var i2 = (Input)CreateOutput(2, isKnown: true); + var o = Output.All(i1, i2); + var data = await o.DataTask.ConfigureAwait(false); + Assert.Equal(new[] { 1, 2 }, data.Value); + }); + + [Fact] + public Task AllEnumerableInputs() + => RunInPreview(async () => + { + var i1 = (Input)CreateOutput(1, isKnown: true); + var i2 = (Input)CreateOutput(2, isKnown: true); + var inputs = new[] {i1, i2}.AsEnumerable(); + var o = Output.All(inputs); + var data = await o.DataTask.ConfigureAwait(false); + Assert.Equal(new[] { 1, 2 }, data.Value); + }); } public class NormalTests diff --git a/sdk/dotnet/Pulumi/Core/Output.cs b/sdk/dotnet/Pulumi/Core/Output.cs index 7a29876e12cd..3e5eb53936c4 100644 --- a/sdk/dotnet/Pulumi/Core/Output.cs +++ b/sdk/dotnet/Pulumi/Core/Output.cs @@ -28,20 +28,36 @@ public static Output CreateSecret(Task value) => Output.CreateSecret(value); /// - /// Combines all the values in and combines - /// them all into a single with an + /// Combines all the values in + /// into a single with an /// containing all their underlying values. If any of the s are not /// known, the final result will be not known. Similarly, if any of the s are secrets, then the final result will be a secret. /// public static Output> All(params Input[] inputs) - => All(ImmutableArray.CreateRange(inputs)); + => Output.All(ImmutableArray.CreateRange(inputs)); /// /// for more details. /// - public static Output> All(ImmutableArray> inputs) - => Output.All(inputs); + public static Output> All(IEnumerable> inputs) + => Output.All(ImmutableArray.CreateRange(inputs)); + + /// + /// Combines all the values in + /// into a single with an + /// containing all their underlying values. If any of the s are not + /// known, the final result will be not known. Similarly, if any of the s are secrets, then the final result will be a secret. + /// + public static Output> All(params Output[] outputs) + => All(outputs.AsEnumerable()); + + /// + /// for more details. + /// + public static Output> All(IEnumerable> outputs) + => Output.All(ImmutableArray.CreateRange(outputs.Select(o => (Input)o))); /// /// Takes in a with potential s or diff --git a/sdk/dotnet/Pulumi/PublicAPI.Unshipped.txt b/sdk/dotnet/Pulumi/PublicAPI.Unshipped.txt index c99f4a92a1ed..8cb2998fae8c 100644 --- a/sdk/dotnet/Pulumi/PublicAPI.Unshipped.txt +++ b/sdk/dotnet/Pulumi/PublicAPI.Unshipped.txt @@ -275,8 +275,10 @@ static Pulumi.Log.Error(string message, Pulumi.Resource resource = null, int? st static Pulumi.Log.Exception(System.Exception exception, Pulumi.Resource resource = null, int? streamId = null, bool? ephemeral = null) -> void static Pulumi.Log.Info(string message, Pulumi.Resource resource = null, int? streamId = null, bool? ephemeral = null) -> void static Pulumi.Log.Warn(string message, Pulumi.Resource resource = null, int? streamId = null, bool? ephemeral = null) -> void -static Pulumi.Output.All(System.Collections.Immutable.ImmutableArray> inputs) -> Pulumi.Output> +static Pulumi.Output.All(System.Collections.Generic.IEnumerable> inputs) -> Pulumi.Output> +static Pulumi.Output.All(System.Collections.Generic.IEnumerable> outputs) -> Pulumi.Output> static Pulumi.Output.All(params Pulumi.Input[] inputs) -> Pulumi.Output> +static Pulumi.Output.All(params Pulumi.Output[] outputs) -> Pulumi.Output> static Pulumi.Output.Create(System.Threading.Tasks.Task value) -> Pulumi.Output static Pulumi.Output.Create(T value) -> Pulumi.Output static Pulumi.Output.CreateSecret(System.Threading.Tasks.Task value) -> Pulumi.Output