Summary
Unity Editor Play Mode works. A WebGL Player build fails compiling sdks/csharp/src/SpacetimeDBClient.cs:
error CS0305: Using the generic type 'IEnumerator<T>' requires 1 type arguments
The WebGL-only coroutine path uses a non-generic IEnumerator, but the file imports System.Collections.Generic and does not import System.Collections.
Environment
- Unity 2022 (WebGL)
com.clockworklabs.spacetimedbsdk v2.7.1 (88a4cad46c) — also reproduced by reading v2.8.1 / release/latest
- Same missing
using on this repo’s v2.8.2 tag and current master (sdks/csharp/src/SpacetimeDBClient.cs)
Repro
- Unity project with the C# client SDK (UPM git package).
- Switch platform to WebGL and Build (not Enter Play Mode).
- Compile error in
SpacetimeDBClient.cs on:
#if UNITY_WEBGL && !UNITY_EDITOR
internal IEnumerator ParseMessages()
Play Mode does not hit this code (UNITY_EDITOR uses void ParseMessages() + Thread).
Cause
File header (v2.8.1 / master):
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Non-generic IEnumerator lives in System.Collections. With only Generic imported, the compiler binds IEnumerator to IEnumerator<T> → CS0305.
An older WebGL-related revision of this file did include using System.Collections; (e.g. around the original WebGL coroutine work). It appears to have been dropped in later edits of SpacetimeDBClient.cs.
Suggested fix
Add to sdks/csharp/src/SpacetimeDBClient.cs:
using System.Collections;
(or fully qualify System.Collections.IEnumerator on the WebGL #if branch).
Please ship this in the next Unity UPM tag as well (com.clockworklabs.spacetimedbsdk); that package currently lags and still mirrors the broken header at v2.8.1.
Summary
Unity Editor Play Mode works. A WebGL Player build fails compiling
sdks/csharp/src/SpacetimeDBClient.cs:The WebGL-only coroutine path uses a non-generic
IEnumerator, but the file importsSystem.Collections.Genericand does not importSystem.Collections.Environment
com.clockworklabs.spacetimedbsdkv2.7.1 (88a4cad46c) — also reproduced by reading v2.8.1 /release/latestusingon this repo’s v2.8.2 tag and current master (sdks/csharp/src/SpacetimeDBClient.cs)Repro
SpacetimeDBClient.cson:Play Mode does not hit this code (
UNITY_EDITORusesvoid ParseMessages()+Thread).Cause
File header (v2.8.1 / master):
Non-generic
IEnumeratorlives inSystem.Collections. With only Generic imported, the compiler bindsIEnumeratortoIEnumerator<T>→ CS0305.An older WebGL-related revision of this file did include
using System.Collections;(e.g. around the original WebGL coroutine work). It appears to have been dropped in later edits ofSpacetimeDBClient.cs.Suggested fix
Add to
sdks/csharp/src/SpacetimeDBClient.cs:(or fully qualify
System.Collections.IEnumeratoron the WebGL#ifbranch).Please ship this in the next Unity UPM tag as well (
com.clockworklabs.spacetimedbsdk); that package currently lags and still mirrors the broken header at v2.8.1.