Skip to content

[C#][Unity] WebGL player build fails CS0305: IEnumerator ParseMessages requires 1 type argument #5759

Description

@edenricardo

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

  1. Unity project with the C# client SDK (UPM git package).
  2. Switch platform to WebGL and Build (not Enter Play Mode).
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions