JetBrains Rider 2026.1 Help

代码检查:不支持加载托管类型

此检查报告在 Burst 编译代码中读取托管类型值的情况。

这通常发生在 Burst 代码读取类、接口、数组或其他托管类型的字段、变量或属性时。 当加载 System.Type 值用于类似 SharedStatic.GetOrCreate 的 API 时,也可能出现同样的警告。

示例

在此示例中, data 字段属于托管类类型。 在 Burst 编译的作业中读取该字段是不支持的。

using Unity.Burst; using Unity.Jobs; public class ExampleData { } [BurstCompile] public struct ExampleJob : IJob { private static ExampleData data = new ExampleData(); public void Execute() { // Reported: loading a managed type is not supported in Burst var value = data; } }
using Unity.Burst; using Unity.Jobs; public struct ExampleData { public int value; } [BurstCompile] public struct ExampleJob : IJob { public ExampleData data; public void Execute() { // Correct: Use unmanaged structs or native containers var value = data.value; } }

快速修复

此检查不提供专用快速修复。 请手动修复,将托管值替换为 Burst 兼容的数据。

2026年 5月 8日