ReSharper 2025.3 Help

Code inspection: Accessing managed methods is not supported

This inspection identifies calls to managed methods (typically methods belonging to System.Object or System.ValueType) within a context compiled by the Burst compiler. Since Burst targets a high-performance, restricted subset of C#, it does not support most methods that involve boxing, reference types, or other managed behaviors.

How it works

The analyzer monitors method calls (IInvocationExpression) within Burst-compiled code. It determines if a call is prohibited based on the following rules:

  • Prohibited: Methods belonging directly to System.Object (such as ToString, GetType, Equals) or System.ValueType are generally prohibited because they often require boxing or interact with the managed heap.

  • Exception (GetHashCode): In a struct, calling GetHashCode is allowed only if it doesn't cause boxing. Calling base.GetHashCode() in a struct that overrides it is still problematic if it reaches the managed implementation.

  • Overrides: If a struct overrides a method like Equals(object), calling it inside Burst is prohibited because the object parameter itself forces boxing.

This inspection only triggers if the code is within a method or job marked with the [BurstCompile] attribute.

Example

In this example, the ToString() and GetType() methods are called on an integer within a Burst-compiled job. These calls are not supported and will be flagged.

using Unity.Burst; using Unity.Jobs; using UnityEngine; [BurstCompile] public struct MyJob : IJob { public int value; public void Execute() { // Reported: Accessing a managed method 'ToString' is not supported string s = value.ToString(); // Reported: Accessing a managed method 'GetType' is not supported var type = GetType(); } }
using Unity.Burst; using Unity.Jobs; [BurstCompile] public struct MyJob : IJob { public int value; public void Execute() { // Avoid managed methods; perform operations using blittable types int result = value * 2; } }
26 March 2026