Why is there a set of static constructors in ITypeSymbol instead of one?

StaticConstructors

While working with Roslyn I came across the ITypeSymbol property and declared as ImmutableArray<IMethodSymbol>

, but as far as I know there can be at most one static constructor in both C # and VB. The question is why?

+3


source to share


2 answers


My guess: partial classes.

public partial class Foo
{
    static Foo() {}
}

public partial class Foo
{
    static Foo() {}
}

      



Even though this invalid code (which I previously forgot) may need to be represented in the Roslyn object model. If you can get ITypeSymbol

for Foo

while this code is compiling, you can find both static constructors there.

+3


source


Static constructor overload, others can take parameters.



-1


source







All Articles