Code inspection: Shared static type parameter requires the unmanaged constraint
This inspection reports uses of SharedStatic<T> where T is not unmanaged.
SharedStatic<T> is intended for unmanaged data. If the type argument contains a managed field such as object, string, a class reference, or another managed member, this inspection warns on the GetOrCreate call.
Example
In this example, the SharedValue struct contains an object field, making it a managed type. It cannot be used as a type argument for SharedStatic<T>.
using Unity.Burst;
public struct SharedValue
{
public int count;
public object tag;
}
public class Example
{
private void Create()
{
// Reported: SharedValue is not unmanaged
var value = SharedStatic<SharedValue>.GetOrCreate<int>();
}
}
using Unity.Burst;
public struct SharedValue
{
public int count;
public double tag;
}
public class Example
{
private void Create()
{
// Correct: SharedValue is fully unmanaged
var value = SharedStatic<SharedValue>.GetOrCreate<int>();
}
}
Quick-fix
This inspection does not provide a dedicated quick-fix. Fix it manually by making the SharedStatic<T> type argument fully unmanaged.
26 March 2026