ReSharper 2025.3 Help

Code inspection: Some SharedStatic`1.GetOrCreate overloads cause compiler errors

This inspection reports use of SharedStatic<T>.GetOrCreate overloads that take System.Type arguments inside code compiled by the Burst compiler.

These overloads are available in C#, but in Burst they can lead to compiler errors. The inspection recommends using the generic GetOrCreate<...>() overloads instead.

Example

In this example, the GetOrCreate method is called with a typeof expression. This is not supported in Burst and will be flagged.

using Unity.Burst; using Unity.Jobs; [BurstCompile] public struct ExampleJob : IJob { public void Execute() { // Reported: typeof is not supported in GetOrCreate var shared = SharedStatic<int>.GetOrCreate(typeof(double)); } }
using Unity.Burst; using Unity.Jobs; [BurstCompile] public struct ExampleJob : IJob { public void Execute() { // Correct: Use the generic overload var shared = SharedStatic<int>.GetOrCreate<double>(); } }

Quick-fix

This inspection does not provide a dedicated quick-fix. Fix it manually by switching to the generic SharedStatic<T>.GetOrCreate overloads. For two type arguments, use GetOrCreate<TContext, TSubContext>() instead of GetOrCreate(typeof(...), typeof(...)).

26 March 2026