roslyn: Generate Constructor should not copy "protected" from abstract base class
- CTRL+. on
Abstract
and choose Generate Constructor
public class Concrete : Abstract
{
}
public abstract class Abstract
{
protected Abstract(string foo)
{
}
}
Expected:
public class Concrete : Abstract
{
public Concrete(string foo) : base(foo)
{
}
}
public abstract class Abstract
{
protected Abstract(string foo)
{
}
}
Actual:
public class Concrete : Abstract
{
protected Concrete(string foo) : base(foo)
{
}
}
public abstract class Abstract
{
protected Abstract(string foo)
{
}
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 29 (25 by maintainers)
Commits related to this issue
- * Generate Constructor should not copy "protected" from abstract base class (#25238) — committed to angelina-dev/roslyn by angelina-dev 6 years ago
- Changed accessibility, created VB tests (#25238) — committed to angelina-dev/roslyn by angelina-dev 6 years ago
🤔 If the class is
internal
, then the ctor is effectively internal anyway, so I’m not sure if that’s too useful.I believe you meant here for fix?
http://source.roslyn.io/#Microsoft.CodeAnalysis.Features/GenerateMember/GenerateDefaultConstructors/AbstractGenerateDefaultConstructorsService.AbstractCodeAction.cs,62
and I agree. that looks like where we should make the fix.
the parameter name “constructor” is little bit confusing though. can you rename it to “baseConstructor” since that is the IMethodSymbol actually pointing to?
Hi, I’d like to work on the issue. It’s the first time for me in Open Source )