Commit 62e79fa
C# Views - Use Name from ViewAttribute instead of Method Name (#3792)
C# Views - Use Name from ViewAttribute instead of Method Name
# Description of Changes
The [documentation for C#
views](https://spacetimedb.com/docs/modules/c-sharp#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.
<img width="1429" height="372" alt="Screenshot 2025-11-28 at 3 04 48 PM"
src="https://github.com/user-attachments/assets/1db83c14-b0dc-4bcb-87ac-50e104f4d501"
/>
---------
Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>1 parent 5f1cb41 commit 62e79fa
File tree
3 files changed
+52
-49
lines changed- crates/bindings-csharp
- Codegen.Tests/fixtures
- diag/snapshots
- server/snapshots
- Codegen
3 files changed
+52
-49
lines changedLines changed: 42 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1081 | 1081 | | |
1082 | 1082 | | |
1083 | 1083 | | |
1084 | | - | |
| 1084 | + | |
1085 | 1085 | | |
1086 | 1086 | | |
1087 | 1087 | | |
1088 | 1088 | | |
1089 | 1089 | | |
1090 | | - | |
| 1090 | + | |
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
| |||
1118 | 1118 | | |
1119 | 1119 | | |
1120 | 1120 | | |
1121 | | - | |
| 1121 | + | |
1122 | 1122 | | |
1123 | 1123 | | |
1124 | 1124 | | |
1125 | 1125 | | |
1126 | 1126 | | |
1127 | | - | |
| 1127 | + | |
| 1128 | + | |
1128 | 1129 | | |
1129 | 1130 | | |
1130 | 1131 | | |
1131 | 1132 | | |
1132 | 1133 | | |
1133 | | - | |
| 1134 | + | |
1134 | 1135 | | |
1135 | 1136 | | |
1136 | 1137 | | |
| |||
1163 | 1164 | | |
1164 | 1165 | | |
1165 | 1166 | | |
1166 | | - | |
| 1167 | + | |
1167 | 1168 | | |
1168 | 1169 | | |
1169 | 1170 | | |
| |||
1689 | 1690 | | |
1690 | 1691 | | |
1691 | 1692 | | |
1692 | | - | |
1693 | | - | |
| 1693 | + | |
| 1694 | + | |
1694 | 1695 | | |
1695 | 1696 | | |
1696 | 1697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
948 | | - | |
| 948 | + | |
949 | 949 | | |
950 | 950 | | |
951 | 951 | | |
| |||
0 commit comments