Using `PhysicsTransform.identity` in a Job results in Burst compilation errors

Using PhysicsTransform.identity in a Burst-compiled job results in Burst compilation errors.

From code

using Unity.Burst;
using Unity.Jobs;
using UnityEngine.LowLevelPhysics2D;

[BurstCompile]
public struct Job : IJob
{
    public void Execute()
    {
        _ = PhysicsTransform.identity;
    }
}

I get two errors

(0,0): Burst error BC1090: The static constructor `UnityEngine.LowLevelPhysics2D.PhysicsTransform..cctor()` is being used by another static constructor in a circular initialization. This is not supported.

 at UnityEngine.LowLevelPhysics2D.PhysicsTransform..cctor()
 at UnityEngine.LowLevelPhysics2D.PhysicsTransform..ctor(UnityEngine.LowLevelPhysics2D.PhysicsTransform* this)


While compiling job:
Unity.Jobs.IJobExtensions+JobStruct`1[[Job, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null::Execute(Job&, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null|System.IntPtr, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|System.IntPtr, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|Unity.Jobs.LowLevel.Unsafe.JobRanges&, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null|System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)

and

(0,0): Burst error BC1091: External and internal calls are not allowed inside static constructors: UnityEngine.LowLevelPhysics2D.PhysicsLowLevelScripting2D.PhysicsRotate_CreateDirection_Injected(ref UnityEngine.Vector2 direction, ref UnityEngine.LowLevelPhysics2D.PhysicsRotate ret)

 at UnityEngine.LowLevelPhysics2D.PhysicsLowLevelScripting2D.PhysicsRotate_CreateDirection(ref UnityEngine.Vector2 direction)
 at UnityEngine.LowLevelPhysics2D.PhysicsRotate..ctor(UnityEngine.LowLevelPhysics2D.PhysicsRotate* this, UnityEngine.Vector2 direction)
 at UnityEngine.LowLevelPhysics2D.PhysicsRotate..cctor()
 at UnityEngine.LowLevelPhysics2D.PhysicsRotate.get_identity()
 at UnityEngine.LowLevelPhysics2D.PhysicsTransform..cctor()
 at UnityEngine.LowLevelPhysics2D.PhysicsTransform..ctor(UnityEngine.LowLevelPhysics2D.PhysicsTransform* this)


While compiling job:
Unity.Jobs.IJobExtensions+JobStruct`1[[Job, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null::Execute(Job&, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null|System.IntPtr, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|System.IntPtr, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089|Unity.Jobs.LowLevel.Unsafe.JobRanges&, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null|System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)

The best workaround I see is to add a method like below and use it instead

private static PhysicsTransform CreateIdentity()
{
    new PhysicsTransform(Vector2.zero, new PhysicsRotate(0));
}

Yes, this is indeed a Burst limitation.

This has already been fixed and landed in Unity 6000.3.8f1 which I believe was released on February 11th.

That version will also allow PhysicsRotate(direction) in Burst too.

Note that in 6.5 (beta soon) the PhysicsRotate(angle) constructor that accepts an angle in radians has been deprecated because Burst won’t allow it and PhysicsRotate overhauled to work in either radians/degrees so there’s a bunch of options there.