JetBrains Rider 2026.1 Help

Code inspection: ImmutableArray<T> with collection initializer

The ImmutableArray<T> type is a struct that provides a more efficient way to work with immutable arrays. However, it does not support collection initializers because it lacks a public Add method and cannot be initialized like a standard list or array.

Attempting to use a collection initializer with ImmutableArray<T> results in a compilation error. Instead, you should use factory methods like ImmutableArray.Create() or the ToImmutableArray() extension method to create and initialize the array.

using System.Collections.Immutable; ImmutableArray<string> items = new() { "A", "B", "C" };
using System.Collections.Immutable; ImmutableArray<string> items = ImmutableArray.Create("A", "B", "C");

The quick-fix for this inspection replaces the collection initializer with a call to the ImmutableArray.Create() method.

11 March 2026