JetBrains Rider 2025.3 Help

Code inspection: Typeof is prohibited in Burst

This inspection reports the use of typeof(...) expressions inside code compiled by the Burst compiler.

Burst targets a high-performance, restricted subset of C# and does not support typeof expressions. These expressions often imply access to managed metadata or System.Type objects, which are not available in the restricted Burst execution environment.

How it works

The analyzer monitors typeof expressions within a Burst-compiled context (e.g., a method or job marked with the [BurstCompile] attribute).

The restriction applies whether typeof is used directly (e.g., to assign to a variable) or indirectly when calling an API that expects a System.Type argument, such as SharedStatic<T>.GetOrCreate(typeof(int)).

Example

In this example, the typeof(int) expression is used inside the Execute method of a Burst-compiled job. This is not supported and will be flagged.

using Unity.Burst; using Unity.Jobs; [BurstCompile] public struct ExampleJob : IJob { public void Execute() { // Reported: typeof(...) is not supported in Burst var t = typeof(int); } }
using Unity.Burst; using Unity.Jobs; [BurstCompile] public struct ExampleJob : IJob { public void Execute() { // Move type-based logic out of Burst or use generic alternatives var value = 0; } }

Quick-fix

This inspection does not provide a dedicated quick-fix. Fix it manually by removing the typeof expression from Burst-compiled code or by replacing it with Burst-compatible generic or compile-time alternatives.

26 March 2026