Skip to content

Generate a call of a base class constructor if the default constructor does not exist. #11254

@andriipatsula

Description

@andriipatsula

Context

class A
{
    public A(int a, bool b) { }
}

class B : A
{
    public B() : base(default, default) { }
}

Base class A does not have default constructor, that's why derived classes must have explicit constructor and call base class constructor.

The question: is it possible having a INamedTypeSymbol object (corresponds to A in an example) to determine if it has default constructor or not and if not how to determine the list of parameters for explicit constructor (From example: A(int a, bool b)).

Having a constructor (object of IMethodSymbol), we'd like to generate compliable code public B() : base(default, default) { }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions