Code inspection: String.Format(format, ...) only accepts string literals and const strings
This inspection reports string.Format(...) calls in code compiled by the Burst compiler where the format argument is not a string literal, const string, or interpolated string.
Burst only supports a restricted form of string.Format. If the format string comes from a mutable field, variable, or another non-constant source, this inspection warns.
Example
In this example, the format string is stored in a static field. This is not supported in Burst-compiled code.
using Unity.Burst;
using Unity.Jobs;
[BurstCompile]
public struct ExampleJob : IJob
{
private static string format = "Value: {0}";
public void Execute()
{
// Reported: mutable format string is not supported
string.Format(format, 12);
}
}
using Unity.Burst;
using Unity.Jobs;
[BurstCompile]
public struct ExampleJob : IJob
{
public void Execute()
{
// Correct: Use a string literal directly
string.Format("Value: {0}", 12);
}
}
Quick-fix
This inspection does not provide a dedicated quick-fix. Fix it manually by replacing the format argument with a string literal or const string.
26 March 2026