Skip to content

Test assemblies do not compile on Unity 6000.5.8f1 and 6000.7: HotReloadUnsafeFixture uses a pointer type argument outside an unsafe context (CS0214) #3646

Done

Description

@hatayama

Summary

On Unity 6000.5.8f1 and the latest 6000.7 beta, the EditMode test run aborts before any test runs ("Scripts have compiler errors"). The only compile error is in a test fixture added by #3564:

Assets/Tests/Editor/HotReloadUnsafeFixture/HotReloadUnsafeFixture.cs(361,35): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context

Line 361 is List<int*[]> values = new List<int*[]>(); in UnsafeFixturePointerTypeArgumentHost.Read(), a method without the unsafe modifier. The fixture's asmdef has allowUnsafeCode: true, but that only permits unsafe contexts; it does not make a method one. The compilers bundled with Unity 2022.3 and 6000.3 accept the line, and the newer one in 6000.5.8f1 / 6000.7 rejects it.

Evidence

Expected

The test assemblies compile on every Unity version in the scheduled matrix, and the fixture still covers what #3564 intended: an edited member whose code needs unsafe code is skipped instead of failing the whole file.

Notes

  • Check what this fixture case is meant to cover before changing it (for example whether the test relies on the method not being marked unsafe), and check the worker's unsafe-code detection against the newer compiler's rule too: if the worker treats a pointer type argument in a non-unsafe method as compilable, a user on 6000.5.8f1 gets a shim that fails to compile.
  • Unity 6000.5.8f1 and 6000.7.0b2 can be used locally to reproduce.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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