A static field initializer reads a static field that is initialized further down, so it sees the default value

tx0/csharp:static-field-read-before-initializedrecommendedwarningreliability/logicdepth fastbug

What it finds

Static field initializers run in the order the fields are written. An initializer that reads a static field declared further down sees that field's default value, null or zero, not the value its own initializer gives it: static readonly int A = B + 1; before static readonly int B = 5; sets A to 1. Constants are left alone, as they are not fields that need initializing, and so are reads inside lambdas, which run later, and partial types, whose parts have no defined order. Each field read too early is reported once, at its first read.

From the rule's source, static_field_read_before_initialized.rs.

Example from the rule's tests
using System; class Limits{    static readonly int Total = Base * 2;tx0 reports: Base is read before its initializer below has run    static readonly int Base = 10;    static readonly int After = Base + 1;    const int Fixed = Later;    const int Later = 3;    static readonly Func<int> Lazy = () => Max;    static readonly int Max = 5;    static readonly string Label = nameof(Name);    static readonly string Name = "n";    static readonly Options Defaults = new Options { Size = 1 };    static readonly int Size = 4;} class Options{    public int Size { get; set; }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:static-field-read-before-initialized" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:static-field-read-before-initialized] reason="..."

tx0 explain tx0/csharp:static-field-read-before-initialized shows the same in the terminal. Found a false positive? Report it.