Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,216 changes: 1,216 additions & 0 deletions crates/bindings-csharp/BSATN.Runtime/QueryBuilder.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions crates/bindings-csharp/Codegen.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public static async Task<Fixture> Compile(string name)
return new(projectDir, (CSharpCompilation)compilation!);
}

public Task Verify(string fileName, object target) =>
Verifier.Verify(target).UseDirectory($"{projectDir}/snapshots").UseFileName(fileName);

private static CSharpGeneratorDriver CreateDriver(
IIncrementalGenerator generator,
LanguageVersion languageVersion
Expand All @@ -42,9 +45,6 @@ LanguageVersion languageVersion
);
}

public Task Verify(string fileName, object target) =>
Verifier.Verify(target).UseDirectory($"{projectDir}/snapshots").UseFileName(fileName);

private async Task<IEnumerable<SyntaxTree>> RunAndCheckGenerator(
IIncrementalGenerator generator
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,144 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
]
}
},
{/*
public global::SpacetimeDB.Table<global::InAnotherNamespace.TestDuplicateTableName, TestDuplicateTableNameCols, TestDuplicateTableNameIxCols> TestDuplicateTableName() =>
new("TestDuplicateTableName", new TestDuplicateTableNameCols("TestDuplicateTableName"), new TestDuplicateTableNameIxCols("TestDuplicateTableName"));
^^^^^^^^^^^^^^^^^^^^^^^^^^
}
*/
Message: The call is ambiguous between the following methods or properties: 'TestDuplicateTableNameCols.TestDuplicateTableNameCols(string)' and 'TestDuplicateTableNameCols.TestDuplicateTableNameCols(string)',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Which tests generate these errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Running dotnet test crates/bindings-csharp/Codegen.Tests executes TestDiagnostics, which compiles the diag fixture and captures compiler errors for validating the error output.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But do these errors make sense? Are these from new tests you added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, not exactly a test I've added, but is a result of the code changes.
diag already does a test of duplicate table names (see TestDuplicateTableName) in it's Lib.cs. With QueryBuilder's additional generated helpers are emitted for both of these tables with a duplicate name, the Roslyn generator sees the duplicate type/constructor symbols and generates the error.
The error's text comes strait from the C# compiler, not something we authored.

Severity: Error,
Descriptor: {
Id: CS0121,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0121),
MessageFormat: The call is ambiguous between the following methods or properties: '{0}' and '{1}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
public global::SpacetimeDB.Table<global::TestDuplicateTableName, TestDuplicateTableNameCols, TestDuplicateTableNameIxCols> TestDuplicateTableName() =>
new("TestDuplicateTableName", new TestDuplicateTableNameCols("TestDuplicateTableName"), new TestDuplicateTableNameIxCols("TestDuplicateTableName"));
^^^^^^^^^^^^^^^^^^^^^^^^^^
}
*/
Message: The call is ambiguous between the following methods or properties: 'TestDuplicateTableNameCols.TestDuplicateTableNameCols(string)' and 'TestDuplicateTableNameCols.TestDuplicateTableNameCols(string)',
Severity: Error,
Descriptor: {
Id: CS0121,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0121),
MessageFormat: The call is ambiguous between the following methods or properties: '{0}' and '{1}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
public global::SpacetimeDB.Table<global::InAnotherNamespace.TestDuplicateTableName, TestDuplicateTableNameCols, TestDuplicateTableNameIxCols> TestDuplicateTableName() =>
new("TestDuplicateTableName", new TestDuplicateTableNameCols("TestDuplicateTableName"), new TestDuplicateTableNameIxCols("TestDuplicateTableName"));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
*/
Message: The call is ambiguous between the following methods or properties: 'TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(string)' and 'TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(string)',
Severity: Error,
Descriptor: {
Id: CS0121,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0121),
MessageFormat: The call is ambiguous between the following methods or properties: '{0}' and '{1}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
public global::SpacetimeDB.Table<global::TestDuplicateTableName, TestDuplicateTableNameCols, TestDuplicateTableNameIxCols> TestDuplicateTableName() =>
new("TestDuplicateTableName", new TestDuplicateTableNameCols("TestDuplicateTableName"), new TestDuplicateTableNameIxCols("TestDuplicateTableName"));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
*/
Message: The call is ambiguous between the following methods or properties: 'TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(string)' and 'TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(string)',
Severity: Error,
Descriptor: {
Id: CS0121,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0121),
MessageFormat: The call is ambiguous between the following methods or properties: '{0}' and '{1}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
}
public readonly struct TestDuplicateTableNameCols
^^^^^^^^^^^^^^^^^^^^^^^^^^
{
*/
Message: The namespace 'SpacetimeDB' already contains a definition for 'TestDuplicateTableNameCols',
Severity: Error,
Descriptor: {
Id: CS0101,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0101),
MessageFormat: The namespace '{1}' already contains a definition for '{0}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*

public readonly struct TestDuplicateTableNameIxCols
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{
*/
Message: The namespace 'SpacetimeDB' already contains a definition for 'TestDuplicateTableNameIxCols',
Severity: Error,
Descriptor: {
Id: CS0101,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0101),
MessageFormat: The namespace '{1}' already contains a definition for '{0}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
Params: [],
ReturnType: new SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN>().GetAlgebraicType(registrar)
Expand Down Expand Up @@ -391,6 +529,75 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
}
},
{/*
{
public global::SpacetimeDB.Table<global::TestDuplicateTableName, TestDuplicateTableNameCols, TestDuplicateTableNameIxCols> TestDuplicateTableName() =>
^^^^^^^^^^^^^^^^^^^^^^
new("TestDuplicateTableName", new TestDuplicateTableNameCols("TestDuplicateTableName"), new TestDuplicateTableNameIxCols("TestDuplicateTableName"));
*/
Message: Type 'QueryBuilder' already defines a member called 'TestDuplicateTableName' with the same parameter types,
Severity: Error,
Descriptor: {
Id: CS0111,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0111),
MessageFormat: Type '{1}' already defines a member called '{0}' with the same parameter types,
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*

internal TestDuplicateTableNameCols(string tableName)
^^^^^^^^^^^^^^^^^^^^^^^^^^
{
*/
Message: Type 'TestDuplicateTableNameCols' already defines a member called 'TestDuplicateTableNameCols' with the same parameter types,
Severity: Error,
Descriptor: {
Id: CS0111,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0111),
MessageFormat: Type '{1}' already defines a member called '{0}' with the same parameter types,
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*

internal TestDuplicateTableNameIxCols(string tableName)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{
*/
Message: Type 'TestDuplicateTableNameIxCols' already defines a member called 'TestDuplicateTableNameIxCols' with the same parameter types,
Severity: Error,
Descriptor: {
Id: CS0111,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0111),
MessageFormat: Type '{1}' already defines a member called '{0}' with the same parameter types,
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*

partial struct TestTypeParams<T> : System.IEquatable<TestTypeParams>, SpacetimeDB.BSATN.IStructuralReadWrite {
^^^^^^^^^^^^^^
Expand Down
Loading
Loading