Skip to content

Comments

C# Views - Use Name from ViewAttribute instead of Method Name#3792

Merged
joshua-spacetime merged 4 commits intoclockworklabs:masterfrom
chutch1122:view-naming-fix
Dec 2, 2025
Merged

C# Views - Use Name from ViewAttribute instead of Method Name#3792
joshua-spacetime merged 4 commits intoclockworklabs:masterfrom
chutch1122:view-naming-fix

Conversation

@chutch1122
Copy link
Contributor

@chutch1122 chutch1122 commented Nov 28, 2025

C# Views - Use Name from ViewAttribute instead of Method Name

Description of Changes

The documentation for C# views says that "Views must be declared as Public, with an explicit Name, and [...]". However, the Name provided to the View attribute is not being used as the name of the view in the Module or the generated C# client SDK code. The ViewDeclaration actually checks that the View attribute's name is not null or empty, but then proceeds to do nothing with it.

This PR updates the ViewDeclaration to use the Name property from ViewAttribute.

For more info - see my bug report in Discord: https://discord.com/channels/1037340874172014652/1443881580602069043

API and ABI breaking changes

No breaking change to the API. Though, anyone who has a view name declared that's different from their method name will have to deal with that during migration of their modules.

Expected complexity level and risk

1 - Trivial change

Testing

I compiled the C# projects under crates/bindings-csharp, built the NuGet packages, and tested them locally with a project using SpacetimeDB 1.10 (CLI and associated packages).

I confirmed that the generated classes now use the value from the View attribute as the RemoteTableName. See attached image.

Screenshot 2025-11-28 at 3 04 48 PM

@CLAassistant
Copy link

CLAassistant commented Nov 28, 2025

CLA assistant check
All committers have signed the CLA.

@bfops bfops requested a review from rekhoff December 1, 2025 18:37
@bfops
Copy link
Collaborator

bfops commented Dec 1, 2025

Thank you for creating this! We'll work on getting it reviewed.

Copy link
Contributor

@rekhoff rekhoff left a comment

Choose a reason for hiding this comment

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

Good find, changes are very strait forward. I've updated the Snapshots to reflect the change. Approved

@joshua-spacetime joshua-spacetime added this pull request to the merge queue Dec 2, 2025
Merged via the queue into clockworklabs:master with commit 62e79fa Dec 2, 2025
20 checks passed
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.

5 participants