pulumi/sdk/dotnet
Fraser Waters c4cd7214d1
Add Union.Bimap and some more InputUnion conversions (#8733)
Resolves https://github.com/pulumi/pulumi/issues/8753

This adds conversion operators so that you can cast a `Union<T0,T1>` or
`Output<Union<T0,T1>>` to an `InputUnion<T0,T1>`. Without this
conversions it wasn't possible to create an `InputUnion` with a union
value, you could only give it a `T0` or `T1` (or an output of them).

This also adds `Union.Bimap` to easily convert both sides of the union,
it was possible to write this with match but Bimap is slightly nicer:
```
union.Match<Union<TResult0, TResult1>>(t0 => mapFunc0(t0), t1 => mapFunc1(t1)))

union.Bimap(mapFunc0, mapFunc1)
```
2022-01-14 14:57:10 +00:00
..
Pulumi Add Union.Bimap and some more InputUnion conversions (#8733) 2022-01-14 14:57:10 +00:00
Pulumi.Automation Fix for 8518 automation API issue with set_config "-value" (#8614) 2021-12-23 13:44:56 -05:00
Pulumi.Automation.Tests Add `make tidy` command to apply `go mod tidy` on every go.mod (#8635) 2021-12-23 17:37:39 -05:00
Pulumi.FSharp Enable deterministic builds 2021-04-29 14:24:43 +12:00
Pulumi.Tests Add Union.Bimap and some more InputUnion conversions (#8733) 2022-01-14 14:57:10 +00:00
cmd/pulumi-language-dotnet Use `pulumi-plugin.json` rather than `pulumiplugin.json` (#8593) 2021-12-15 10:41:44 -08:00
.editorconfig Add **preview** .NET Core support for pulumi. (#3399) 2019-10-25 16:59:50 -07:00
.gitignore [Automation API] - C# Implementation (#5761) 2021-02-18 11:36:21 +01:00
Makefile [sdk/dotnet] add plugin download url (#8739) 2022-01-13 16:10:17 -08:00
README.md Avoid overriding dotnet proj settings accidentally (#6670) 2021-04-01 15:27:24 -04:00
dotnet.sln [Automation API] - C# Implementation (#5761) 2021-02-18 11:36:21 +01:00
dotnet.sln.DotSettings [dotnet] Fix Resharper code issues (#7178) 2021-06-10 10:32:33 -04:00
pulumi_logo_64x64.png Fixing up Pulumi logo in dotnet package 2021-04-21 18:45:21 +01:00

README.md

.NET Language Provider

A .NET language provider for Pulumi.

Building and Running

To build, you'll want to install the .NET Core 3.0 SDK or greater, and ensure dotnet is on your path. Once that it does, running make in either the root directory or the sdk/dotnet directory will build and install the language plugin.

Once this is done you can write a Pulumi app written on top of .NET. You can find many examples showing how this can be done with C#, F#, or VB. Your application will need to reference the Pulumi NuGet package or the Pulumi.dll built above.

Here's a simple example of a Pulumi app written in C# that creates some simple AWS resources:

// Copyright 2016-2019, Pulumi Corporation

using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Aws.S3;

class Program
{
    static Task<int> Main()
        => Deployment.RunAsync(() =>
        {
            var config = new Config("hello-dotnet");
            var name = config.Require("name");

            // Create the bucket, and make it public.
            var bucket = new Bucket(name, new BucketArgs { Acl = "public-read" });

            // Add some content.
            var content = new BucketObject($"{name}-content", new BucketObjectArgs
            {
                Acl = "public-read",
                Bucket = bucket.Id,
                ContentType = "text/plain; charset=utf8",
                Key = "hello.txt",
                Source = new StringAsset("Made with ❤, Pulumi, and .NET"),
            });

            // Return some values that will become the Outputs of the stack.
            return new Dictionary<string, object>
            {
                { "hello", "world" },
                { "bucket-id", bucket.Id },
                { "content-id", content.Id },
                { "object-url", Output.Format($"http://{bucket.BucketDomainName}/{content.Key}") },
            };
        });
}

Make a Pulumi.yaml file:

$ cat Pulumi.yaml

name: hello-dotnet
runtime: dotnet

Then, configure it:

$ pulumi stack init hello-dotnet
$ pulumi config set name hello-dotnet
$ pulumi config set aws:region us-west-2

And finally, preview and update as you would any other Pulumi project.

Public API Changes

When making changes to the code you may get the following compilation error:

error RS0016: Symbol XYZ' is not part of the declared API.

This indicates a change in public API. If you are developing a change and this is intentional, add the new API elements to PublicAPI.Unshipped.txt corresponding to your project (some IDEs will do this automatically for you, but manual additions are fine as well).

Project maintainers will move API elements from PublicAPI.Unshipped.txt to PublicAPI.Shipped.txt when cutting a release.