Skip to content

Add c# sdk#117

Closed
tehsis wants to merge 10 commits intomainfrom
pterradillos/csharp
Closed

Add c# sdk#117
tehsis wants to merge 10 commits intomainfrom
pterradillos/csharp

Conversation

@tehsis
Copy link
Contributor

@tehsis tehsis commented Feb 13, 2026

No description provided.

dbeattie71 and others added 10 commits February 13, 2026 18:43
- 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
- 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
.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
@tehsis tehsis closed this Feb 13, 2026
@tehsis tehsis reopened this Feb 17, 2026
@tehsis tehsis closed this Feb 17, 2026
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.

2 participants