-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
5758 for C#/.NET #7899
5758 for C#/.NET #7899
Conversation
Diff for pulumi-random with merge commit a1378c5 |
Diff for pulumi-azuread with merge commit a1378c5 |
Diff for pulumi-kubernetes with merge commit a1378c5 |
pkg/codegen/internal/test/testdata/external-resource-schema/dotnet/ArgFunction.cs
Outdated
Show resolved
Hide resolved
@@ -13,6 +13,18 @@ public static class ArgFunction | |||
{ | |||
public static Task<ArgFunctionResult> InvokeAsync(ArgFunctionArgs? args = null, InvokeOptions? options = null) | |||
=> Pulumi.Deployment.Instance.InvokeAsync<ArgFunctionResult>("example::argFunction", args ?? new ArgFunctionArgs(), options.WithVersion()); | |||
|
|||
public static Output<ArgFunctionResult> Invoke(ArgFunctionOutputArgs? args = null, InvokeOptions? options = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called .Invoke but .InvokeOutput is also a possibility to match what we have in other languages. Votes?
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm leaning InvokeOutput too since in other langs we have _output etc, which Luke also preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other languages have a very different invoke syntax so I'm not sure that should be a large factor. I expect we'd advise this new form by default - unless folks need the result for control flow, so having a simple unambiguous name would be my preference.
Resource constructors return outputs and they don't have Output
in their name, so I don't see much difference here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I don't feel strongly about this -- I could go either way. Invoke
is the nicer name, but I do worry slightly that Invoke
will be seen as the blocking variant of InvokeAsync
, which isn't the case.
@@ -26,6 +38,16 @@ public ArgFunctionArgs() | |||
} | |||
} | |||
|
|||
public sealed class ArgFunctionOutputArgs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*OutputArgs naming convention is something we chose here, can chose differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must admit that doesn't sound right to me. Maybe *InputArgs
since it has all Input<T>
types?
pkg/codegen/internal/test/testdata/external-resource-schema/dotnet/Utilities.cs
Outdated
Show resolved
Hide resolved
Diff for pulumi-gcp with merge commit a1378c5 |
Diff for pulumi-aws with merge commit a1378c5 |
Diff for pulumi-azure with merge commit a1378c5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, but LGTM otherwise.
@@ -13,6 +13,18 @@ public static class ArgFunction | |||
{ | |||
public static Task<ArgFunctionResult> InvokeAsync(ArgFunctionArgs? args = null, InvokeOptions? options = null) | |||
=> Pulumi.Deployment.Instance.InvokeAsync<ArgFunctionResult>("example::argFunction", args ?? new ArgFunctionArgs(), options.WithVersion()); | |||
|
|||
public static Output<ArgFunctionResult> Invoke(ArgFunctionOutputArgs? args = null, InvokeOptions? options = null) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
pkg/codegen/internal/test/testdata/output-funcs/dotnet/funcWithDefaultValue.cs
Outdated
Show resolved
Hide resolved
pkg/codegen/internal/test/testdata/external-resource-schema/dotnet/ArgFunction.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks exciting!
@@ -13,6 +13,18 @@ public static class ArgFunction | |||
{ | |||
public static Task<ArgFunctionResult> InvokeAsync(ArgFunctionArgs? args = null, InvokeOptions? options = null) | |||
=> Pulumi.Deployment.Instance.InvokeAsync<ArgFunctionResult>("example::argFunction", args ?? new ArgFunctionArgs(), options.WithVersion()); | |||
|
|||
public static Output<ArgFunctionResult> Invoke(ArgFunctionOutputArgs? args = null, InvokeOptions? options = null) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
pkg/codegen/internal/test/testdata/dash-named-schema/dotnet/Utilities.cs
Outdated
Show resolved
Hide resolved
@@ -26,6 +38,16 @@ public ArgFunctionArgs() | |||
} | |||
} | |||
|
|||
public sealed class ArgFunctionOutputArgs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must admit that doesn't sound right to me. Maybe *InputArgs
since it has all Input<T>
types?
pkg/codegen/internal/test/testdata/output-funcs/dotnet/Assert.cs
Outdated
Show resolved
Hide resolved
...en/internal/test/testdata/simple-resource-schema-custom-pypackage-name/dotnet/ArgFunction.cs
Outdated
Show resolved
Hide resolved
pkg/codegen/internal/test/testdata/output-funcs/dotnet/CodegenTests.cs
Outdated
Show resolved
Hide resolved
pkg/codegen/internal/test/testdata/output-funcs/dotnet/funcWithConstInput.cs
Outdated
Show resolved
Hide resolved
pkg/codegen/internal/test/testdata/output-funcs/dotnet/funcWithDictParam.cs
Outdated
Show resolved
Hide resolved
pkg/codegen/internal/test/testdata/output-funcs/dotnet/listStorageAccountKeys.cs
Outdated
Show resolved
Hide resolved
Diff for pulumi-random with merge commit 32f48fe |
Diff for pulumi-azuread with merge commit 32f48fe |
Diff for pulumi-random with merge commit 00e7b40 |
Diff for pulumi-azuread with merge commit 00e7b40 |
Diff for pulumi-kubernetes with merge commit 32f48fe |
Diff for pulumi-kubernetes with merge commit 00e7b40 |
Diff for pulumi-gcp with merge commit 32f48fe |
Diff for pulumi-gcp with merge commit 00e7b40 |
Diff for pulumi-aws with merge commit 32f48fe |
Diff for pulumi-aws with merge commit 00e7b40 |
Diff for pulumi-azure with merge commit 32f48fe |
Diff for pulumi-azure with merge commit 00e7b40 |
Diff for pulumi-random with merge commit 6997d1d |
Diff for pulumi-random with merge commit 69e9075 |
Diff for pulumi-kubernetes with merge commit 69e9075 |
case input && args && mod.details(t).usedInFunctionOutputVersionInputs: | ||
return name + "InputArgs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach to resolving the conflicting name LGTM.
// - the provider is responsible for deciding whether the | ||
// `Output<T>` is secret and known, and may add | ||
// additional dependencies | ||
// | ||
// This means that presence of secrets or unknowns in the | ||
// `args` does not guarantee the result is secret or | ||
// unknown, which differs from Pulumi SDKs that choose to | ||
// implement these invokes via `Apply` (currently Go and | ||
// Python). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought Node.js will use .apply
? Or is this comment just because the Node.js functionality hasn't landed yet?
This difference across language runtimes is unfortunate. Remind me again why we can't implement this via Apply
in .NET?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered in another comment below. LMK if you think you see a way forward with Apply. If we could deeply cross-convert plain and inputty types we still use Apply. It's looking like quite bit of work though. I considered doing it by serializing and deserializing but at first glance even that is non-trivial with current API.
@@ -13,10 +13,6 @@ public abstract class InvokeArgs : InputArgs | |||
|
|||
private protected override void ValidateMember(Type memberType, string fullName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have to double check, but after removing the implementation below, I suspect no subclass actually has an implementation and ValidateMember
could be nuked entirely. But that can be cleaned up separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try that.
/// are several valid keys, for a full reference, check out | ||
/// [describe-images in the AWS CLI reference][1]. | ||
/// </summary> | ||
public InputList<Inputs.GetAmiIdsFilterInputArgs> Filters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinvp this is the pointer to the counter-example where Apply approach broke down.
Using terminology from the doc by @pgavlin : https://github.com/pulumi/pulumi/blob/master/developer-docs/architecture/type-system.md#inputshapet
Suppose we have ideal type X, and we have
dotnetType(X) = GetAmiIdsArgs
- then
dotnetType(inputShape(X)) = GetAmiIdsInvokeArgs
- But as part of covering the fields of this record, we discover
dotnetType(Y) = Inputs.GetAmiIdsFilterArgs
- and
dotnetType(inputShape(Y)) = Inputs.GetAmiIdsFilterInputArgs
X.Filters
is of type typeList<Y>
Now with the Apply approach, we need to build a .NET function Inputs.GetAmiIdsInvokeArgs -> Output<GetAmiIdsArgs>
. The previous implementation was not cutting it. It stumbled on auto-converting Inputs.GetAmiIdsFilterInputArgs
to Inputs.GetAmiIdsFilterArgs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd continue arguing that codegen or else SDK needs to reliably be able to do conversions of the form inputShape(X) -> Input<X>
in the runtime of the target language, of which the above is a special case :) However poking at the existing SDK it did not sound trivial. I'd have to be reflection, and I don't think it's built yet. Then I noticed that serde has this capability (sort of) and changed the approach.
Diff for pulumi-random with merge commit bebe78d |
Diff for pulumi-kubernetes with merge commit bebe78d |
Diff for pulumi-azuread with merge commit 2692c71 |
Diff for pulumi-random with merge commit 2692c71 |
Diff for pulumi-random with merge commit d742dc2 |
Diff for pulumi-azuread with merge commit d742dc2 |
Diff for pulumi-kubernetes with merge commit d742dc2 |
Diff for pulumi-gcp with merge commit d742dc2 |
Diff for pulumi-kubernetes with merge commit 2692c71 |
Diff for pulumi-gcp with merge commit 2692c71 |
Diff for pulumi-aws with merge commit 2692c71 |
Diff for pulumi-azure with merge commit d742dc2 |
Diff for pulumi-azure with merge commit 2692c71 |
Diff for pulumi-aws with merge commit d742dc2 |
Diff for pulumi-azure-native with merge commit 2692c71 |
Diff for pulumi-azure-native with merge commit d742dc2 |
Description
Fixes #7945
Part of #5758 for .NET/C#
Checklist