Repository navigation
Conversation
Add [GraphQLValue] and GraphQLEnumConverter<T> to the runtime, so a generated enum member can be named by .NET's convention (Tcp) while it is sent and parsed as its schema value (TCP). Members without the attribute go by their names, as before. GraphQLEnum.ToValue/FromValue do the conversion for argument values and responses. Signed-off-by: Alex Suraci <[email protected]>
Write the engine's formatted names (IntrospectionNames, in the formats the source generator reads: PASCAL:CAPITALIZED and CAMEL:CAPITALIZED) next to introspection.json in `test` and `install`, and include the source generator's test fixtures in the workspace. sourceGeneratorTest runs without an engine, since its tests need none. The source generator ignores names.json until it learns to read it. Signed-off-by: Alex Suraci <[email protected]>
The source generator reads a names.json next to introspection.json, as `codegen introspect --names-out` writes it (formats PASCAL:CAPITALIZED and CAMEL:CAPITALIZED), and names C# identifiers by the .NET guidelines: types, methods, properties and enum members PascalCase, parameters camelCase, acronyms written like words (JsonValue, Llm, WithMcpServer, insecureSkipTlsVerify, NetworkProtocol.Tcp). The schema's own names still go over the wire. Without names.json, or for a name or format missing from it, the legacy conversion applies, so older schemas generate the same code. With formatted names: - methods renamed by them keep their legacy names, with legacy parameter names, as [Obsolete] forwarders (default implementations on interfaces); - input object properties keep [Obsolete] getters under legacy names; - enum members carry their schema values with [GraphQLValue] and serialize with GraphQLEnumConverter<T>; values that format alike share one member, and the old members stay as [Obsolete] aliases. Types have no alias: C# can't export one, so renamed types (JSON, JSONValue, LLM*, HTTPState, SDKConfig, WorkspaceSDK) are a hard break. Tests cover both paths, and compile the whole core client against the runtime from fixtures of the core schema and its names, regenerated by Fixtures/generate.go. Signed-off-by: Alex Suraci <[email protected]>
This was referenced Oct 14, 2026
Contributor
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Contributor
|
This PR was closed because it has been stalled for 7 days with no activity. |
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.
Part 5h/N of the stack splitting #14501 (identifier casing): the .NET SDK. Plan: #14501 (comment)
Refs #13668
Stacked on #14673. That PR has the shared
cmd/codegeninfra (codegen introspect --names-out) and engine-dev'sIntrospectionNames.What changes for .NET users
The source generator now names C# identifiers with the names the engine formats (
Query.formatIdentifiers). They follow the .NET Framework Design Guidelines:JSONValue/ scalarJSONJSONValue/JSONJsonValue/JsonLLM,LLMMessage, ...LLM,LLMMessageLlm,LlmMessagewithMCPServerWithMcpserverWithMcpServerinsecureSkipTLSVerifyinsecureSkipTLSVerifyinsecureSkipTlsVerifyskipTLSVerifySkipTlsverifySkipTlsVerifyNetworkProtocol.TCPTCPTcpOnly C# identifiers change. Field names, argument names, input object fields, enum values and GraphQL type names are still sent to the engine exactly as the schema spells them.
Breaking changes
The .NET SDK maintainers need to decide on these:
Renamed types are a hard break, with no alias. C# can't export a type alias from a library (a
usingalias only applies to its own file). Code that names these 17 core types stops compiling:JSON→Json,JSONValue→JsonValueHTTPState→HttpState,SDKConfig→SdkConfig,WorkspaceSDK→WorkspaceSdkLLM*type:LLM,LLMContent,LLMContentBlock,LLMContentBlockInput,LLMContentBlockKind,LLMMessage,LLMMessageOrigin,LLMMessageOriginInput,LLMMessageOriginKind,LLMMessageRole,LLMSkill,LLMTokenUsageCode that only chains calls or uses
var(dag.Llm()...) still compiles.Named arguments with the old parameter spelling stop compiling where the method keeps its name. C# can't overload on parameter names, so there's no forwarder. In the core API this affects:
insecureSkipTLSVerify:→insecureSkipTlsVerify:(Container.From,Container.PublishAsync)expectedRemoteSHA:→expectedRemoteSha:(GitRef.Push)Positional calls are unaffected.
Enum members are renamed (
NetworkProtocol.TCP→Tcp) in 27 of the 28 core enums. The old members stay as[Obsolete]aliases with the same value, so existing code compiles with warnings. Behaviour still changes:ToString()andEnum.GetNamesreturn the new names.Enum.Parse("TCP")resolves to the alias, which equalsTcp.Gzip/GZIPinImageLayerCompression) now share one member, which sends the first value.The values sent to the engine are unchanged. The enum's JSON converter is now
GraphQLEnumConverter<T>instead ofJsonStringEnumConverter<T>, and it maps each member to its[GraphQLValue]schema value.Deprecated, still compiling:
[Obsolete]forwarder. On interfaces the forwarder is a default interface method.[Obsolete]getters under their old names.What's in it
Runtime (
Dagger.SDK/GraphQLEnum.cs):[GraphQLValue("TCP")],GraphQLEnum.ToValue/FromValue, andGraphQLEnumConverter<T>. Members without the attribute serialize by their names, as before.Source generator:
Namerreadsnames.jsonnext tointrospection.json. It uses the formatsPASCAL:CAPITALIZEDandCAMEL:CAPITALIZED, ascodegen introspect --names-outwrites them.Dagger.SDK.csprojaddsnames.jsonas anAdditionalFilesitem when the file exists. A file that can't be parsed raises diagnosticDAG005.names.jsonis missing (schemas from engines withoutformatIdentifiers), or when a name or format is missing from it. Older schemas generate exactly the same code.CodeRendereruses theNamereverywhere it usedFormatter/GetVarName, and it renders the obsolete forwarders, old-name properties and enum aliases.Dev module (
.dagger/modules/dotnet-client-dev):testandinstallwritenames.jsonfrom engine-dev'sIntrospectionNames.sourceGeneratorTestno longer starts an engine, since its tests don't need one.Tests (
IdentifierNamingTests):The fixtures (
Fixtures/core-schema.json,core-names.json) are regenerated fromdocs/docs-graphql/schema.graphqlsbyFixtures/generate.go, which callsengine/namingdirectly.There's no committed generated client to update, because the source generator runs at build time. There's also no in-repo .NET module runtime, so there's no
engineVersionbump here.Not in it
RenamedCoreNamestable:shortSHA,callID,FunctionCachePolicyvalues, ...) go with PR 6.Testing
dotnet-client/source-generator-test(27 tests),dotnet-client/test(17 SDK tests against a from-source engine, withnames.json) anddotnet-client/csharpierall pass.core/integrationhas no .NET suite, so no integration tests ran.