Skip to content

[C#] Add support for IEnumerable<T> for Views' return types#4486

Open
rekhoff wants to merge 6 commits intomasterfrom
rekhoff/csharp-views-ienumerable-support
Open

[C#] Add support for IEnumerable<T> for Views' return types#4486
rekhoff wants to merge 6 commits intomasterfrom
rekhoff/csharp-views-ienumerable-support

Conversation

@rekhoff
Copy link
Contributor

@rekhoff rekhoff commented Feb 27, 2026

This is the implementation to resolve #4424

Description of Changes

  • Add support for IEnumerable<T> as a valid C# View return type in codegen, so view implementations can return query results without forcing ToList(). The generator now detects IEnumerable<T>, serializes it via the list serializer.
  • Snapshots have been updated with a test to confirm that IEnumerable<T> rather than checking it is unsupported (which we had added when removing support during the transition away from Query<T> usage.
  • Refreshes docs/examples to reflect the new supported signature.

API and ABI breaking changes

No breaking changes. This is additive support for an existing .NET interface.

Expected complexity level and risk

2 - Low

Testing

  • Rebuilt CLI locally, ran regression tests, and dotnet tests in C# module bindings.
  • Tested updated docs code snippets to ensure they resolve in an IDE and publish.

@rekhoff rekhoff self-assigned this Feb 27, 2026
@rekhoff rekhoff marked this pull request as ready for review February 27, 2026 02:08
Signed-off-by: Ryan <r.ekhoff@clockworklabs.io>
Comment on lines 1236 to 1237
&& !ReturnType.BSATNName.Contains("SpacetimeDB.BSATN.RefOption")
&& !ReturnType.BSATNName.Contains("SpacetimeDB.BSATN.List")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do both of these options implement IEnumerable? If so, we could just assert IEnumerable or IQuery.

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.

[C#] Add support for IEnumerable<T> for Views' return types

2 participants