Closed
Conversation
- Generate C# SDK using openapi-generator v7.6.0 (csharp/generichost) - Target net6.0 to match Pulumi .NET ecosystem - Package: Pulumi.Esc.Sdk at sdk/csharp/Pulumi.Esc.Sdk/ - Hand-written wrappers: EscClient.cs, EscAuth.cs, ValueMapper.cs - Custom .csproj template at sdk/templates/csharp/ - Makefile targets: generate_csharp_client_sdk, build_csharp, test_csharp - .openapi-generator-ignore blocks extra artifacts (api/, docs/, appveyor.yml) - .gitignore updated for C# bin/obj directories
…onmentDefinitionSerializer - Override partial_header.mustache template for Pulumi copyright on all generated files - Add X-Pulumi-Source and User-Agent headers in EscClient.BuildClient() - Add YamlDotNet 16.3.0 dependency via .csproj template - Create EnvironmentDefinitionSerializer.cs for YAML <-> EnvironmentDefinition - Add convenience methods: GetEnvironmentAsync, GetEnvironmentAtVersionAsync, DecryptEnvironmentAsync - Fix .openapi-generator-ignore docs pattern (docs/* -> docs/**)
- Add xUnit test project (Pulumi.Esc.Sdk.Tests) - EscAuthTests: 6 tests for env var, credential file reading (shared fixtures), ESC override, URL conversion - ValueMapperTests: 13 tests for Value tree unwrapping, JsonElement handling - EnvironmentDefinitionSerializerTests: 8 tests for YAML/JSON serialization round-trips - EscApiTests: E2E integration test (full CRUD lifecycle, tagged Category=Integration) - Fix EscCredentials JSON field: 'currentAccountName' -> 'name' (matches Python/TypeScript SDKs) - Block generated Pulumi.Esc.Sdk.Test/ stubs in .openapi-generator-ignore
- README: Add C# install, quick example, API reference link - CONTRIBUTING: Add build_csharp, test_csharp, test_csharp_integration targets, .NET 6.0 prereq - CHANGELOG_PENDING: Note C# SDK addition - Makefile: test_csharp filters out integration tests, add test_csharp_integration target
- Fix YAML body serialization: bypass generated JsonSerializer for UpdateEnvironmentYaml and CheckEnvironmentYaml (send raw YAML) - Fix CreateEnvironment/CloneEnvironment constructor arg order - Fix Value deserialization: remove required check on 'value' field (API omits it when unknown=true) - Fix .sln project paths (src\ prefix removed) - Add UpdateEnvironmentAsync and CheckEnvironmentAsync accepting EnvironmentDefinition (serializes to YAML, matching Go SDK parity) - Add .gitignore for C# SDK (exclude .vs/, bin/, obj/) - Protect Value.cs and .sln in .openapi-generator-ignore
…full Go test parity
- Fix SerializeToYaml to include AdditionalProperties from
EnvironmentDefinitionValues (foo, my_secret, my_array, etc.)
- Fix Deserialize to capture non-typed YAML keys into
AdditionalProperties as JsonElements
- Add helper methods: ObjectToJsonElement, JsonElementToObject,
ConvertYamlValue for bridging YamlDotNet ↔ System.Text.Json
- Add 3 unit tests for AdditionalProperties round-tripping
- Rewrite integration test to match Go SDK test structure:
- Separate test methods: FullLifecycle, CheckEnvironment_Valid,
CheckEnvironmentYaml_Invalid
- Verify resolved values: my_array, pulumiConfig, environmentVariables
- Test UpdateEnvironmentAsync(EnvironmentDefinition) with versioned property
- Test OpenAndReadEnvironmentAtVersion with revision tags
- Verify envDef structure via AssertEnvDef helper
- Verify tag values
- Clean up clone project envs in RemoveAll
- Add test_csharp job to stage-test.yml (runs make test_csharp) - Add publish-csharp-sdk job to stage-publish-sdk.yml (pack + nuget push) - Lint check-sdk-generation-clean already covers C# via generate_sdks
Contributor
|
Thank you very much for your contribution @dbeattie71 we trully appreciate it! I'd be more than happy to merge your code once some issues are addressed.
They need to show the following notice: Copyright 2026, Pulumi Corporation. All rights reserved. You can use pulumictl tool to validate them.
The latter should be fixed by running Let me know if you are able to address these issues. Thanks! |
- Add 9 custom Mustache template overrides in sdk/templates/csharp/libraries/generichost/
to fix missing copyright notices in generated files (upstream OpenAPI Generator bug:
templates used {{partial_header}} variable instead of {{>partial_header}} partial include)
- Update copyright year to 2026 in partial_header.mustache
- Add Pulumi.Esc.Sdk/README.md to .openapi-generator-ignore
- Regenerate all C# SDK files with correct copyright headers
- Verified with pulumictl copyright
Author
|
@tehsis Those issues should be fixed and validated with pulimictl |
.NET 10 disables reflection-based serialization by default. When the net6.0-targeted SDK runs on a .NET 10 runtime, JsonSerializer.Deserialize fails because JsonSerializerOptions has no TypeInfoResolver set. Changes: - Add JsonDefaults.cs with runtime reflection to detect and set DefaultJsonTypeInfoResolver when available (.NET 7+) - HostConfiguration.cs: use JsonDefaults.EnsureTypeInfoResolver() when initializing JsonSerializerOptions - Add HostConfiguration.mustache template override so the fix survives SDK regeneration - EscAuth.cs: pass JsonDefaults.Options to bare Deserialize calls for credentials.json parsing - EscClient.cs: change ResolvePropertyPath from static to instance method to use _jsonSerializerOptions with custom converters - Add JsonDeserializationTests.cs with 8 unit tests covering the affected deserialization paths
7 tasks
Contributor
|
Thanks @dbeattie71! I have rebased your work and addressed some issues (unrelated to this PR) at #118 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a C# SDK for the Pulumi ESC API, following the same generated + hand-written wrapper pattern as the Go, Python, and TypeScript SDKs.
What's included
Generated code (OpenAPI Generator 7.6.0,
csharp/generichostlibrary):net6.0IEscApiwithIServiceCollectionextensionsHand-written wrappers:
EscClient.cs— High-level convenience wrapper with ~30 methods, factory methods (Create,CreateDefault),IDisposablesupportEscAuth.cs— Reads credentials fromPULUMI_ACCESS_TOKENenv var or~/.pulumi/credentials.json(Pulumi CLI + ESC CLI paths)ValueMapper.cs— RecursiveValuetree → plain .NET object unwrappingEnvironmentDefinitionSerializer.cs— YamlDotNet-based YAML ↔EnvironmentDefinitionserializationTemplate overrides:
partial_header.mustache— Pulumi copyright header on all generated filesnetcore_project.mustache— Custom.csprojwith Pulumi branding, YamlDotNet dependencyTests:
PULUMI_ACCESS_TOKEN+PULUMI_ORG)Makefile targets:
generate_csharp_client_sdk,build_csharp,test_csharp,test_csharp_integrationMethod parity with Go SDK
Full parity with
api_esc_extensions.go:CreateEnvironment,CloneEnvironment,DeleteEnvironment,ListEnvironmentsGetEnvironment,GetEnvironmentAtVersion,GetEnvironmentYaml,GetEnvironmentAtVersionYaml,UpdateEnvironment,UpdateEnvironmentYamlOpenEnvironment,OpenEnvironmentAtVersion,ReadOpenEnvironment,ReadOpenEnvironmentProperty,OpenAndReadEnvironment,OpenAndReadEnvironmentAtVersionDecryptEnvironment,DecryptEnvironmentYamlCheckEnvironment,CheckEnvironmentYamlListEnvironmentRevisionTags,ListEnvironmentRevisionTagsPaginated,GetEnvironmentRevisionTag,CreateEnvironmentRevisionTag,UpdateEnvironmentRevisionTag,DeleteEnvironmentRevisionTagListEnvironmentTags,ListEnvironmentTagsPaginated,GetEnvironmentTag,CreateEnvironmentTag,UpdateEnvironmentTag,DeleteEnvironmentTagListEnvironmentRevisions,ListEnvironmentRevisionsPaginatedBugs found and fixed in generated code
ReadOpenEnvironmentPropertyreturns 401Urinormalizes//→/in swagger path/open//{sessionID}ReadOpenEnvironment+ navigates Value treeUpdateEnvironmentYamlsends garbled YAMLJsonSerializer.Serialize(string)wraps YAML in JSON quotesHttpClientcallCreateEnvironmentcreates under wrong project(name, project)but intuitively called as(project, name)CheckEnvironmentYamlfails onValuedeserializationvalueas required onValuebut API returns{\"unknown\":true}without itValue.cs, protected via.openapi-generator-ignoreUsage
Checklist
net6.0(make build_csharp)make test_csharp).openapi-generator-ignoreprotects hand-written filesmake test_csharp_integration— requires API credentials)