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

5758 for C#/.NET #7899

Merged
merged 25 commits into from
Oct 18, 2021
Merged

5758 for C#/.NET #7899

merged 25 commits into from
Oct 18, 2021

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Sep 2, 2021

Description

Fixes #7945
Part of #5758 for .NET/C#

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@t0yv0 t0yv0 mentioned this pull request Sep 2, 2021
6 tasks
@github-actions
Copy link

github-actions bot commented Sep 2, 2021

Diff for pulumi-random with merge commit a1378c5

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

Diff for pulumi-azuread with merge commit a1378c5

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

Diff for pulumi-kubernetes with merge commit a1378c5

@@ -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)
Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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
Copy link
Member Author

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.

Copy link
Member

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?

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

Diff for pulumi-gcp with merge commit a1378c5

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

Diff for pulumi-aws with merge commit a1378c5

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

Diff for pulumi-azure with merge commit a1378c5

Copy link
Member

@justinvp justinvp left a 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.

pkg/codegen/dotnet/gen.go Outdated Show resolved Hide resolved
pkg/codegen/dotnet/templates.go Outdated Show resolved Hide resolved
pkg/codegen/dotnet/templates.go Outdated Show resolved Hide resolved
pkg/codegen/dotnet/templates.go Outdated Show resolved Hide resolved
pkg/codegen/dotnet/templates.go Outdated Show resolved Hide resolved
pkg/codegen/dotnet/templates.go Outdated Show resolved Hide resolved
pkg/codegen/dotnet/templates.go Outdated Show resolved Hide resolved
Copy link
Member

@mikhailshilkov mikhailshilkov left a 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.

@@ -26,6 +38,16 @@ public ArgFunctionArgs()
}
}

public sealed class ArgFunctionOutputArgs
Copy link
Member

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?

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-random with merge commit 32f48fe

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-azuread with merge commit 32f48fe

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-random with merge commit 00e7b40

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-azuread with merge commit 00e7b40

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-kubernetes with merge commit 32f48fe

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-kubernetes with merge commit 00e7b40

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-gcp with merge commit 32f48fe

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-gcp with merge commit 00e7b40

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-aws with merge commit 32f48fe

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-aws with merge commit 00e7b40

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-azure with merge commit 32f48fe

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-azure with merge commit 00e7b40

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Diff for pulumi-random with merge commit 6997d1d

@github-actions
Copy link

Diff for pulumi-random with merge commit 69e9075

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 69e9075

Comment on lines +230 to +231
case input && args && mod.details(t).usedInFunctionOutputVersionInputs:
return name + "InputArgs"
Copy link
Member

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.

Comment on lines 40 to 48
// - 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).
Copy link
Member

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?

Copy link
Member Author

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)
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member Author

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 type List<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.

Copy link
Member Author

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.

@github-actions
Copy link

github-actions bot commented Oct 6, 2021

Diff for pulumi-random with merge commit bebe78d

@github-actions
Copy link

github-actions bot commented Oct 6, 2021

Diff for pulumi-kubernetes with merge commit bebe78d

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 2692c71

@github-actions
Copy link

Diff for pulumi-random with merge commit 2692c71

@github-actions
Copy link

Diff for pulumi-random with merge commit d742dc2

@github-actions
Copy link

Diff for pulumi-azuread with merge commit d742dc2

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit d742dc2

@github-actions
Copy link

Diff for pulumi-gcp with merge commit d742dc2

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 2692c71

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 2692c71

@github-actions
Copy link

Diff for pulumi-aws with merge commit 2692c71

@github-actions
Copy link

Diff for pulumi-azure with merge commit d742dc2

@github-actions
Copy link

Diff for pulumi-azure with merge commit 2692c71

@github-actions
Copy link

Diff for pulumi-aws with merge commit d742dc2

@github-actions
Copy link

Diff for pulumi-azure-native with merge commit 2692c71

@github-actions
Copy link

Diff for pulumi-azure-native with merge commit d742dc2

@t0yv0 t0yv0 merged commit e710125 into master Oct 18, 2021
@pulumi-bot pulumi-bot deleted the t0yv0/5758-dotnet-2 branch October 18, 2021 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement 5758 for C#/.NET
4 participants