Add C# exporter backed by the .NET WASM converter#107
Open
flobernd wants to merge 5 commits into
Open
Conversation
CSharpExporter wraps ExternalExporter to load the optional @elastic/request-converter-dotnet package, resolving the bundle from a constructor argument, the CSHARP_REQUEST_CONVERTER_BUNDLE env var, or the package name in that order. It defaults to descriptor syntax with a strongly typed document, overridable per call. Also switches the test script to run Jest under Node's --experimental-vm-modules: the WASM bundle is ESM-only, so loading it needs a true dynamic import that survives tsc's downlevel to require() under the commonjs module target, and Jest's VM sandbox rejects dynamic import() without that flag.
This was referenced Jul 23, 2026
JoshMock
approved these changes
Jul 24, 2026
Comment on lines
+25
to
+31
| function getDynamicImport(): DynamicImport { | ||
| dynamicImport ??= new Function( | ||
| "specifier", | ||
| "return import(specifier)", | ||
| ) as DynamicImport; | ||
| return dynamicImport; | ||
| } |
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.
Summary
Adds C# as a supported output format. Code generation runs inside a .NET WebAssembly bundle shipped separately as the optional
@elastic/request-converter-dotnetpackage, which embeds theElastic.Clients.Elasticsearchclient. The newCSharpExporterloads that bundle lazily and delegates through the existingExternalExporterJSON contract.Intention
Bring C# to parity with the other languages generated from Dev Console input, including the language examples in elasticsearch-specification. Because the .NET converter compiles the whole client in, it cannot live as templates in this repo; it ships per minor version as its own npm package (built and published from elastic/elasticsearch-net#8931), and consumers install the version matching their target Elasticsearch version.
Changes
CSharpExporter(src/exporters/csharp.ts), registered ascsharp/c#and listed asC#. Defaults produce fluent descriptor syntax with a strongly typed illustrative document type (MyDocument); caller options override.CSHARP_REQUEST_CONVERTER_BUNDLEenvironment variable, then the@elastic/request-converter-dotnetpackage (declared as an optional peerDependency,>=8.19.0).CSHARP_REQUEST_CONVERTER_BUNDLE.node --experimental-vm-modules, required to dynamically import the ESM bundle from this CommonJS package. Expect Node's ExperimentalWarning on stderr during test runs.csharpformat and its snake_case options.Notes
completeandprintResponseare currently no-ops for C# (not yet implemented by the bundle), andcheckOnlyrejects with the install hint when the bundle is missing instead of returningfalse.