Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Dec 16, 2024
1 parent 0131746 commit b3ec33a
Show file tree
Hide file tree
Showing 13 changed files with 470 additions and 277 deletions.
16 changes: 16 additions & 0 deletions crates/bindings-csharp/BSATN.Codegen/Diag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ Func<TContext, ISymbol> toLocation
)
: this(group, title, interpolate, ctx => toLocation(ctx).Locations.FirstOrDefault()) { }

public ErrorDescriptor(
ErrorDescriptorGroup group,
string title,
Expression<Func<TContext, FormattableString>> interpolate,
Func<TContext, AttributeData> toLocation
)
: this(
group,
title,
interpolate,
ctx =>
toLocation(ctx).ApplicationSyntaxReference is { } r
? r.SyntaxTree.GetLocation(r.Span)
: null
) { }

public Diagnostic ToDiag(TContext ctx) =>
Diagnostic.Create(descriptor, toLocation(ctx), makeFormatArgs(ctx));
}
Expand Down
46 changes: 32 additions & 14 deletions crates/bindings-csharp/Codegen.Tests/fixtures/diag/Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,24 +361,42 @@ public static partial class InAnotherNamespace
public partial struct TestDuplicateTableName { }
}

[SpacetimeDB.Table(
Name = "TestIncompatibleSchedule1",
Scheduled = nameof(TestIncompatibleScheduleReducer)
)]
[SpacetimeDB.Table(Name = "TestIncompatibleSchedule2")]
public partial struct TestIncompatibleSchedule
{
[SpacetimeDB.Reducer]
public static void TestIncompatibleScheduleReducer(
ReducerContext ctx,
TestIncompatibleSchedule table
) { }
}

[SpacetimeDB.Table]
[SpacetimeDB.Index]
public partial struct TestIndexWithoutColumns { }

[SpacetimeDB.Table]
[SpacetimeDB.Index(BTree = [])]
public partial struct TestIndexWithEmptyColumns { }

[SpacetimeDB.Table(
Name = "TestScheduleWithoutPrimaryKey",
Scheduled = "DummyScheduledReducer",
ScheduledAt = nameof(ScheduleAtCorrectType)
)]
[SpacetimeDB.Table(
Name = "TestScheduleWithWrongPrimaryKeyType",
Scheduled = "DummyScheduledReducer",
ScheduledAt = nameof(ScheduleAtCorrectType)
)]
[SpacetimeDB.Table(Name = "TestScheduleWithoutScheduleAt", Scheduled = "DummyScheduledReducer")]
[SpacetimeDB.Table(
Name = "TestScheduleWithWrongScheduleAtType",
Scheduled = "DummyScheduledReducer",
ScheduledAt = nameof(ScheduleAtWrongType)
)]
public partial struct TestScheduleIssues
{
[SpacetimeDB.PrimaryKey(Table = "TestScheduleWithWrongPrimaryKeyType")]
public string IdWrongType;

[SpacetimeDB.PrimaryKey(Table = "TestScheduleWithoutScheduleAt")]
[SpacetimeDB.PrimaryKey(Table = "TestScheduleWithWrongScheduleAtType")]
public int IdCorrectType;

public int ScheduleAtWrongType;
public ScheduleAt ScheduleAtCorrectType;

[SpacetimeDB.Reducer]
public static void DummyScheduledReducer(ReducerContext ctx, TestScheduleIssues table) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ public TestUniqueNotEquatableUniqueIndex PrimaryKeyField => new(this);
}
},
{/*
SpacetimeDB.Internal.Module.RegisterTable<global::TestIncompatibleSchedule, SpacetimeDB.Internal.TableHandles.TestIncompatibleSchedule2>();
SpacetimeDB.Internal.Module.RegisterTable<global::TestScheduleIssues, SpacetimeDB.Internal.TableHandles.TestScheduleWithWrongScheduleAtType>();
SpacetimeDB.Internal.Module.RegisterTable<global::TestTableTaggedEnum, SpacetimeDB.Internal.TableHandles.TestTableTaggedEnum>();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SpacetimeDB.Internal.Module.RegisterTable<global::TestUniqueNotEquatable, SpacetimeDB.Internal.TableHandles.TestUniqueNotEquatable>();
Expand All @@ -828,7 +828,7 @@ SpacetimeDB.Internal.Module.RegisterTable<global::TestUniqueNotEquatable, Spacet
}
},
{/*
SpacetimeDB.Internal.Module.RegisterTable<global::TestIncompatibleSchedule, SpacetimeDB.Internal.TableHandles.TestIncompatibleSchedule2>();
SpacetimeDB.Internal.Module.RegisterTable<global::TestScheduleIssues, SpacetimeDB.Internal.TableHandles.TestScheduleWithWrongScheduleAtType>();
SpacetimeDB.Internal.Module.RegisterTable<global::TestTableTaggedEnum, SpacetimeDB.Internal.TableHandles.TestTableTaggedEnum>();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SpacetimeDB.Internal.Module.RegisterTable<global::TestUniqueNotEquatable, SpacetimeDB.Internal.TableHandles.TestUniqueNotEquatable>();
Expand Down
Loading

0 comments on commit b3ec33a

Please sign in to comment.