Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Unity SDK into C# SDK #117

Merged
merged 10 commits into from
Aug 28, 2024
Merged

Merge Unity SDK into C# SDK #117

merged 10 commits into from
Aug 28, 2024

Conversation

RReverser
Copy link
Contributor

@RReverser RReverser commented Aug 6, 2024

Description of Changes

This creates a frankenstein monster of a repo that is compatible with both .NET / MSBuild as well as can be consumed as a Unity package.

  • .meta files, Unity manifests and Unity README were copied over from the Unity repo.
  • examples and tests folders were renamed to examples~ and tests~ correspondingly, as the ~ suffix is the only way to get entire folders ignored by Unity.
  • MSBuild was configured to change bin and obj to bin~ and obj~ for the same reasons. This doesn't matter for the Git repo, but helpful for local development where you don't want Unity to try and load local DLL artifacts.
  • NuGet was configured to restore Unity-compatible NuGet DLLs (and delete others) in a local folder and committed to the repo - so, from now on, we can easily update them by modifying .csproj and via standard dotnet restore / dotnet build.

After this change, this repo should be compatible with both .NET CLI (e.g. dotnet test) as well as consumable from Unity, but due to amount of metadata changes, it needs further testing before we merge repos properly.

Fixes #114.

API

  • This is an API breaking change to the SDK

If the API is breaking, please state below what will break

Requires SpacetimeDB PRs

List any PRs here that are required for this SDK change to work

@RReverser RReverser requested review from bfops and jdetter August 6, 2024 16:17
@bfops
Copy link
Collaborator

bfops commented Aug 19, 2024

One thing to note is that if we make this the new com.clockworklabs.spacetimedbsdk repo, we'll lose all the branches/tags from the other repo. I'm not sure which ones bitcraft (or other users) are still using.

@@ -1,137 +1,77 @@
## Ignore Visual Studio temporary files, build results, and
Copy link
Collaborator

Choose a reason for hiding this comment

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

For reviewers:

$ diff com.clockworklabs.spacetimedbsdk/.gitignore spacetimedb-csharp-sdk/.gitignore 
35d34
< *.csproj
37d35
< *.sln
72a71,77
> 
> bin~
> obj~
> 
> # This is used for local paths to SpacetimeDB packages.
> /nuget.config
> /nuget.config.meta

@bfops
Copy link
Collaborator

bfops commented Aug 19, 2024

Unity gives me this error when I use this merged branch:

SpacetimeDB.BSATN.Runtime references netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51. A roslyn analyzer should reference netstandard version 2.0

It doesn't seem to prevent it from running, but I don't know if it'll cause any issues down the line.

@bfops
Copy link
Collaborator

bfops commented Aug 19, 2024

Hm I get these errors when I run dotnet test now:

[11:00:51] ~/work/clockwork/spacetimedb-csharp-sdk/tests~
$ dotnet test
  Determining projects to restore...
  Restored /mnt/nutera/work/spacetimedb-csharp-sdk/tests~/tests.csproj (in 362 ms).
  1 of 2 projects are up-to-date for restore.
/mnt/nutera/work/spacetimedb-csharp-sdk/tests/obj/Debug/net8.0/tests.GlobalUsings.g.cs(2,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. [/mnt/nutera/work/spacetimedb-csharp-sdk/SpacetimeDB.ClientSDK.csproj]
/mnt/nutera/work/spacetimedb-csharp-sdk/tests/obj/Debug/net8.0/tests.GlobalUsings.g.cs(3,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. [/mnt/nutera/work/spacetimedb-csharp-sdk/SpacetimeDB.ClientSDK.csproj]
/mnt/nutera/work/spacetimedb-csharp-sdk/tests/obj/Debug/net8.0/tests.GlobalUsings.g.cs(4,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. [/mnt/nutera/work/spacetimedb-csharp-sdk/SpacetimeDB.ClientSDK.csproj]
...
...

@RReverser
Copy link
Contributor Author

Hm I get these errors when I run dotnet test now:

Weird, it works on CI.

Can you try to clean all the bin/obj folders and retry?

@RReverser
Copy link
Contributor Author

Unity gives me this error when I use this merged branch:

That seems really odd as that DLL is not marked as RoslynAnalyzer :/ I didn't see this issue.

@bfops
Copy link
Collaborator

bfops commented Aug 19, 2024

Hm I get these errors when I run dotnet test now:

Weird, it works on CI.

Can you try to clean all the bin/obj folders and retry?

Works now! I thought I ran git clean -fdx on everything but I must have missed something 🤷

@bfops
Copy link
Collaborator

bfops commented Aug 19, 2024

Unity gives me this error when I use this merged branch:

That seems really odd as that DLL is not marked as RoslynAnalyzer :/ I didn't see this issue.

Wouldn't it be because it bundles in SpacetimeDB.BSATN.Codegen now?

@RReverser
Copy link
Contributor Author

Wouldn't it be because it bundles in SpacetimeDB.BSATN.Codegen now?

Shouldn't be because only Codegen.dll.meta has RoslynAnalyzer label: https://github.com/clockworklabs/spacetimedb-csharp-sdk/blob/0d135c8abe579a1a3e83927c4ee79329baafcf6f/packages/spacetimedb.bsatn.runtime/0.11.0/analyzers/dotnet/cs/SpacetimeDB.BSATN.Codegen.dll.meta#L4

So it's odd that it complains about Runtime.dll.meta which is not a source generator.

@RReverser
Copy link
Contributor Author

It doesn't seem to prevent it from running, but I don't know if it'll cause any issues down the line.

Just in case, did this error also disappear by any chance after git clean?

@bfops
Copy link
Collaborator

bfops commented Aug 20, 2024

It doesn't seem to prevent it from running, but I don't know if it'll cause any issues down the line.

Just in case, did this error also disappear by any chance after git clean?

The error only came up on first import, not on subsequent loads.

Copy link
Collaborator

@bfops bfops left a comment

Choose a reason for hiding this comment

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

This seems good to me! I

  • Ran BitCraft pointed at this branch, ran around in a world
  • Ran dotnet test successfully
  • Reviewed the diff itself

I still don't know the best way to deal with branch names/tags after the repo rename though (#117 (comment))

@RReverser
Copy link
Contributor Author

I still don't know the best way to deal with branch names/tags after the repo rename though (#117 (comment))

Good point, I don't know either. Let's bring it up in the meeting.

@bfops
Copy link
Collaborator

bfops commented Aug 21, 2024

It doesn't seem to prevent it from running, but I don't know if it'll cause any issues down the line.

Just in case, did this error also disappear by any chance after git clean?

Actually I think this must be unrelated to a git clean since this is fetched directly from the remote branch in BitCraftClient.

@RReverser
Copy link
Contributor Author

Actually I think this must be unrelated to a git clean since this is fetched directly from the remote branch in BitCraftClient.

But you said you don't see it anymore, right?

@bfops
Copy link
Collaborator

bfops commented Aug 21, 2024

Actually I think this must be unrelated to a git clean since this is fetched directly from the remote branch in BitCraftClient.

But you said you don't see it anymore, right?

I see it consistently when first loading the package (i.e. when switching Packages/manifest.json to point at this branch). I don't see it on subsequent reopens of Unity. It reappears if I switch to a different version of the package and then switch back.

@RReverser
Copy link
Contributor Author

I see it consistently when first loading the package (i.e. when switching Packages/manifest.json to point at this branch). I don't see it on subsequent reopens of Unity. It reappears if I switch to a different version of the package and then switch back.

I thought maybe GUID in meta files got clashes between previous / modern versions of DLLs, but doesn't seem so. Idk, I'm out of ideas, but if it only happens when switching between package versions before / after the change, it sounds like some internal Unity cache and hopefully won't affect end users.

@bfops bfops merged commit a517717 into master Aug 28, 2024
1 check passed
@bfops bfops deleted the unified branch August 28, 2024 18:13
@bfops bfops restored the unified branch August 28, 2024 20:27
bfops added a commit that referenced this pull request Aug 29, 2024
## Description of Changes
Redo these PRs:
-
clockworklabs/com.clockworklabs.spacetimedbsdk-archive#56
-
clockworklabs/com.clockworklabs.spacetimedbsdk-archive#59
-
clockworklabs/com.clockworklabs.spacetimedbsdk-archive#61

I'm not sure how these repos were merged in
#117, but it
appears that this wasn't carried over. (Either way we need to make this
a required check).

## API
No


## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*

Co-authored-by: Zeke Foppa <[email protected]>
@bfops
Copy link
Collaborator

bfops commented Aug 29, 2024

(just to follow up here - I should not have mindlessly merged master into this branch without thinking about the implications. After this merged, we had to do #123 in order to revert back to the state in this PR.)

@bfops bfops deleted the unified branch August 29, 2024 16:50
bfops referenced this pull request Aug 30, 2024
## Description of Changes
Revert `master` to the original state of this PR:
#53.

We should prevent merging into `master` from now on, since the
repositories are now merged.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*


## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*

## Testing
I loaded a bitcraft world and ran around.

I used the versions listed here:
clockworklabs/com.clockworklabs.spacetimedbsdk-archive#57

---------

Co-authored-by: Ingvar Stepanyan <[email protected]>
Co-authored-by: Zeke Foppa <[email protected]>
@bfops bfops restored the unified branch September 6, 2024 20:06
@bfops bfops mentioned this pull request Sep 9, 2024
bfops added a commit that referenced this pull request Sep 10, 2024
## Description of Changes
For some reason, this repo was not quite properly synced up with the
state of
https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk-archive
after #117.

It's unclear to me how this happened, since the current state seems to
be compatible with 0.11, but the [0.11 release
commit/PR](clockworklabs/com.clockworklabs.spacetimedbsdk-archive@382cce0)
also bumped the `package.json` version, which didn't happen in this
repo.

I re-copied files over. Fortunately, the only real changes were to
`package.json` and `README.md`.

## API
No breaking changes.

## Requires SpacetimeDB PRs
None

Co-authored-by: Zeke Foppa <[email protected]>
bfops added a commit that referenced this pull request Sep 10, 2024
## Description of Changes
For some reason, this repo was not quite properly synced up with the
state of
https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk-archive
after #117.

It's unclear to me how this happened, since the current state seems to
be compatible with 0.11, but the [0.11 release
commit/PR](clockworklabs/com.clockworklabs.spacetimedbsdk-archive@382cce0)
also bumped the `package.json` version, which didn't happen in this
repo.

I re-copied files over. Fortunately, the only real changes were to
`package.json` and `README.md`.

## API
No breaking changes.

## Requires SpacetimeDB PRs
None

Co-authored-by: Zeke Foppa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants