Skip to content

feat(sdk): Add C# SDK with module support - #11502

Closed
pjmagee wants to merge 1 commit into
dagger:mainfrom
pjmagee:csharp/experimental
Closed

pjmagee wants to merge 1 commit into
dagger:mainfrom
pjmagee:csharp/experimental

Conversation

@pjmagee

@pjmagee pjmagee commented Nov 30, 2025 •

Copy link
Copy Markdown
Contributor

experimental C# SDK with module support

  • Attributes for Function with cache, Check, DefaultValue, Ignore, Field, Object, Name for alias support

  • Defaults & optional values supported by C# syntax (string? value) or (string value = "hello")

  • Constructor support with custom factory [Constructor] like python SDK create() for async

  • Makes use of Roslyn analyzers for ensuring users of SDK use the API correctly, with IDE/Compiler hints,warnings, e.g. C# class not matching Dagger.json module name, or incorrectly using Attributes

  • Makes use of .editorconfig to enable or override compiler/IDE C# analyzers

  • .NET 10 long term support - officially released on November 11, 2025, and is supported for three years until November 14, 2028

  • preview nuget package published at https://www.nuget.org/packages/DaggerIO/ will require Dagger team to create nuget.org account with API Key to publish update/packages but I followed existing sdks on version/bumping - happy for changes/reviews of any gaps (nuget package is NOT required for dagger modules, as the sdk is vendored with the generated code)

@pjmagee
pjmagee force-pushed the csharp/experimental branch 8 times, most recently from 69dde3f to aa3d97a Compare December 4, 2025 11:15
@pjmagee
pjmagee force-pushed the csharp/experimental branch 8 times, most recently from 9693d6d to 12f864d Compare December 10, 2025 16:07
@pjmagee
pjmagee marked this pull request as ready for review December 10, 2025 16:08
@pjmagee
pjmagee force-pushed the csharp/experimental branch 10 times, most recently from e157702 to bb16585 Compare December 12, 2025 19:21

@TomChv TomChv left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ I'm far from being a C# expert so some of my questions may look out of context due to my lack of knowledge.

That review is a first look, but there will be more coming next week.

The code looks very clean overall, thank you for making it easy to review!
Please rebase whenever you can, the repo is moving fast :)

Here's a summary of some tests I did:

  • Initialize a csharp project
  • Initialize a csharp project in a sub directory
  • Create and call check
  • Create and call function

About the performances, it's decently fast and usable, I'll not worry to much about optimization for now, we can follow up later.

The goal is to merge that one during January, so it gives us a bit of time to prepare the ground and sets the current dotnet SDK as deprecated.

@pjmagee

pjmagee commented Dec 25, 2025

Copy link
Copy Markdown
Contributor Author

@TomChv really appreciate your feedback!! Especially with not being C# developer. Hopefully we can get some feedback from others.

Regarding the Analyzers/Codefixes - They are also entirely optional and can be completely disabled, my idea behind adding them was to add some 'rails' or quick fixes. Though they could be considered maybe opinionated, or not 'complete'.

@pjmagee
pjmagee force-pushed the csharp/experimental branch from bb16585 to 6635ccc Compare December 26, 2025 18:41
@pjmagee
pjmagee force-pushed the csharp/experimental branch from 41c71c2 to 653a737 Compare March 6, 2026 18:45
@pjmagee

pjmagee commented Mar 6, 2026 •

Copy link
Copy Markdown
Contributor Author

If you can make the PR green, I would be happy to give it another review so we can merge that

green!

image

@TomChv

TomChv commented Mar 9, 2026 •

Copy link
Copy Markdown
Member

@pjmagee
pjmagee force-pushed the csharp/experimental branch 5 times, most recently from 004f3f4 to afe1ae0 Compare March 13, 2026 18:17
@pjmagee
pjmagee force-pushed the csharp/experimental branch 6 times, most recently from 3cae4cf to 9db59a5 Compare March 22, 2026 13:57
@pjmagee
pjmagee force-pushed the csharp/experimental branch from 9db59a5 to 61cdf2e Compare March 26, 2026 19:37
This introduces a complete C# SDK implementation for Dagger with full module development support.

Core Features:
- Full Dagger API client with fluent chainable interface
- Module runtime with attribute-based type registration
- Support for objects, interfaces, enums, and functions
- Constructor-based dependency injection with async factory methods
- Comprehensive attribute system for API customization

Attributes:
- [Object] - Mark classes as Dagger modules
- [Interface] - Define interface types
- [Function] - Expose methods and properties
- [Constructor] - Alternative static factory constructors
- [Name] - Custom parameter naming (e.g., for keyword conflicts)
- [DefaultPath] - Load Directory/File from module context
- [Ignore] - Exclude patterns from Directory arguments
- [Deprecated] - Mark parameters/functions as deprecated
- [Check] - Define validation functions
- [Enum]/[EnumValue] - Custom enum types

Module System:
- Automatic type discovery and registration
- GraphQL schema generation from C# types
- State management with JSON serialization
- Support for Dagger types (Container, Directory, File, etc.)
- Interface implementation with dynamic proxies

Developer Experience:
- Roslyn analyzers for compile-time validation
- Code fixes for common patterns
- Comprehensive examples demonstrating all features
- Integration with existing Dagger CLI tooling

Signed-off-by: pjmagee <[email protected]>
@pjmagee
pjmagee force-pushed the csharp/experimental branch from 61cdf2e to 8177058 Compare April 3, 2026 20:25
@github-actions

Copy link
Copy Markdown
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.

@github-actions

Copy link
Copy Markdown
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.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this May 18, 2026
@dominik-niebuhr

Copy link
Copy Markdown

whats the state of this @pjmagee is it maintained still?

@pjmagee

pjmagee commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

what's the state of this @pjmagee is it maintained still?

https://github.com/pjmagee/dagger/tree/csharp/experimental I did some updates on it about 3 months back but have taken a break.

regarding your question on "maintained still", partially I guess... but ideally it would be merged in to dagger. I did some work on it again a few months ago now as you can see. And I tested it against the following repo examples:

https://github.com/pjmagee/daggerverse/tree/main/aspnet-blazor-template
https://github.com/pjmagee/daggerverse/tree/main/aspnet-hello

The repository has been moving fast and they've been working towards their 1.0 release and I don't think it was the best time for the PR.

I think getting some help or support merging this would be a great feat, I implemented a lot of features the dotnet version does not have.

@TheEisbaer

Copy link
Copy Markdown

@pjmagee

I think getting some help or support merging this would be a great feat, I implemented a lot of features the dotnet version does not have.

I'd be happy to help where possible

@pjmagee

pjmagee commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@pjmagee

I think getting some help or support merging this would be a great feat, I implemented a lot of features the dotnet version does not have.

I'd be happy to help where possible

A new PR has been opened with contributions already from @dominik-niebuhr merged in. You should be able to easily test the csharp SDK from my fork and branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants