Skip to content

[Regression] CS0012: ReadOnlySpan (System.Memory) missing in Editor causes compilation failure for SentrySdk.Metrics in 4.6.0 #2751

Description

@gal20040

SDK Version

4.6.0

Unity Version

6000.3.15f1

Platform

  • Editor
  • Mobile (Android, iOS)
  • Desktop (Windows, macOS, Linux)
  • WebGL
  • Console

Sentry Environment

Sentry SaaS (sentry.io)

Other Error Monitoring Solution

Yes

Steps to Reproduce

Description

After upgrading Sentry Unity SDK 4.5.0 -> 4.6.0, compiling any script that interacts with SentrySdk.Metrics (e.g., EmitCounter, EmitGauge) throws a CS0012 compilation error in the Unity Editor: error CS0012: The type 'ReadOnlySpan<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=null'.

This seems to be a regression caused by the recent assembly aliasing removal (PR #2726 / Issue #2717). While fixing IL2CPP issues, System.Memory.dll was left disabled for the Editor platform in its .meta file. Because SentrySdk.Metrics methods contain overloads/signatures that require ReadOnlySpan<>, the C# compiler fails to resolve the overload resolution candidates during Editor compilation, explicitly demanding System.Memory, Version=4.0.1.2.

Steps to Reproduce

  1. Install Sentry Unity SDK 4.6.0 in a Unity project, Packages\manifest.json:
    {
      "dependencies": {
        ...
        "io.sentry.unity": "https://github.com/getsentry/unity.git#4.6.0",
        ...
      }
    }
  2. Create a custom .asmdef that references io.sentry.unity.runtime.
  3. Create a C# script inside this assembly and call a metric method:
    SentrySdk.Metrics.EmitCounter("test_counter", 1.0, new[] { new KeyValuePair<string, object>("key", "value") });
  4. Switch back to Unity to trigger compilation.

Environment

  • Sentry Unity SDK Version: 4.6.0
  • API Compatibility Level: .NET Standard 2.1
  • Platform: Unity Editor (Windows)
  • Unity: 6000.3.15f1 (c1aa84e375f6)

Expected vs Actual Result

Expected Behavior

The code should compile successfully in the Editor, just as it did in 4.5.0.

Actual Behavior

The Unity console throws the following compilation error: error CS0012: The type 'ReadOnlySpan<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=null'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugsomething isn't working as it shouldUnityplatform label

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status
    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions