Jobified collider physics queries in Unity.Physics

I am trying to sphere cast through my scene. I’m getting error:
InvalidOperationException: SetStateJob.Data.castInput.Collider uses unsafe Pointers which is not allowed. Unsafe Pointers can lead to crashes and no safety against race conditions can be provided.

Job struct:

[BurstCompile]
    unsafe struct SetStateJob : IJobForEach<Translation, PhysicsVelocity, ControllerState>
    {
        public CollisionWorld world;
        public ColliderCastInput castInput;
        public unsafe void Execute([ReadOnly] ref Translation c0, [ReadOnly] ref PhysicsVelocity c1, ref ControllerState c2)
        {
            ColliderCastHit hit = new ColliderCastHit();
            ColliderCastInput jobInput = new ColliderCastInput()
            {
                Collider = castInput.Collider,
                Direction = castInput.Direction,
                Orientation = castInput.Orientation,
                Position = c0.Value
            };

            c2 = new ControllerState()
            {
                Grounded = world.CastCollider(jobInput, out hit),
                CollisionNormal = hit.SurfaceNormal,
                Fraction = hit.Fraction,
            };
        }
    }

Schedule function:

unsafe JobHandle ScheduleSphereCastJob(JobHandle inputDeps)
    {
        Unity.Physics.Collider* collider = (Unity.Physics.Collider*)Unity.Physics.SphereCollider.Create(float3.zero, 0.5f, sphereFilter).GetUnsafePtr();
        JobHandle stateJob = new SetStateJob()
        {
            world = World.Active.GetExistingSystem<Unity.Physics.Systems.BuildPhysicsWorld>().PhysicsWorld.CollisionWorld,
            castInput = new ColliderCastInput() { Collider = collider, },
        }.Schedule(this, inputDeps);

        return stateJob;
    }

I put used an unsafe block instead of declaring the whole job unsafe and that seemed to make it happy.

unsafe
{

}

Hi, give this a try:

using Unity.Collections.LowLevel.Unsafe;

[BurstCompile]
unsafe struct SetStateJob : IJobForEach<Translation, PhysicsVelocity, ControllerState>
{
    public CollisionWorld world;
    [NativeDisableUnsafePtrRestriction] public Collider* Collider;
    public quaternion Orientation;
    public float3 Direction;

    public unsafe void Execute([ReadOnly] ref Translation c0, [ReadOnly] ref PhysicsVelocity c1, ref ControllerState c2)
    {
        ColliderCastHit hit = new ColliderCastHit();
        ColliderCastInput jobInput = new ColliderCastInput()
        {
            Collider = Collider,
            Direction = Direction,
            Orientation = Orientation,
            Position = c0.Value
        };

        c2 = new ControllerState()
        {
            Grounded = world.CastCollider(jobInput, out hit),
            CollisionNormal = hit.SurfaceNormal,
            Fraction = hit.Fraction,
        };
    }
}