Почему статический конструктор не вызывается для класса, используемого в качестве параметра универсального типа?

Учитывая следующие классы:

public class Foo {
    static Foo() {
        Console.WriteLine("Foo is being constructed");
    }
}

public class Bar {
    public void ReferenceFooAsGenericTypeParameter<T>() {
        Console.WriteLine("Foo is being referenced as a generic type parameter");
    }
}

public class SampleClass
{
    public static void Main()
    {
        new Bar().ReferenceFooAsGenericTypeParameter<Foo>();
    }
}

Вывод

Foo is being referenced as a generic type parameter

Это имеет смысл, согласно спецификации:

A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.

Но мне любопытно, почему статический конструктор не вызывается, когда на тип ссылаются как на параметр универсального типа.

11
задан arootbeer 8 August 2012 в 22:06
поделиться