Skip to content

Commit 445ca79

Browse files
committed
Update C# Views error messages with accurate return types
1 parent 3a2e234 commit 445ca79

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

crates/bindings-csharp/Codegen/Diag.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ string typeName
215215
public static readonly ErrorDescriptor<MethodDeclarationSyntax> ViewInvalidReturn =
216216
new(
217217
group,
218-
"Views must return Vec<T> or Option<T>",
219-
method => $"View '{method.Identifier}' must return Vec<T> or Option<T>.",
220-
method => method
218+
"Views must return List<T> or T?",
219+
method => $"View '{method.Identifier}' must return List<T> or T?.",
220+
method => method.ReturnType
221221
);
222222

223223
// TODO: Remove once Views support Private: Views must be Public currently

crates/bindings-csharp/Codegen/Module.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ method.ReturnType is INamedTypeSymbol
11891189
? "SpacetimeDB.BSATN.ValueOption"
11901190
: "SpacetimeDB.BSATN.RefOption";
11911191
var opt = $"{optType}<{rowType.Name}, {rowType.BSATNName}>";
1192-
// Match Rust semantics: Query<T> is described as Option<T>.
1192+
// Match Rust semantics: Query<T> is described as a nullable row (T?).
11931193
ReturnType = new ReferenceUse(opt, opt);
11941194
}
11951195
else
@@ -1210,7 +1210,7 @@ method.ReturnType is INamedTypeSymbol
12101210
diag.Report(ErrorDescriptor.ViewContextParam, methodSyntax);
12111211
}
12121212

1213-
// Validate return type: must be Option<T> or Vec<T>
1213+
// Validate return type: must be List<T> or T?
12141214
if (
12151215
!ReturnType.BSATNName.Contains("SpacetimeDB.BSATN.ValueOption")
12161216
&& !ReturnType.BSATNName.Contains("SpacetimeDB.BSATN.RefOption")

0 commit comments

Comments
 (0)