Re: codegen vs constructor inheritance
От: rameel https://github.com/rsdn/CodeJam
Дата: 30.11.24 10:07
Оценка: 2 (1) +1
Здравствуйте, Codealot, Вы писали:

C>Раз уж кодогенерация теперь наше все, то — есть ли в природе готовое решение, чтобы создавать в наследнике конструкторы для соответствующих конструкторов базового класса?


Re: почему в C# до сих пор нет наследования конструкторов?
Автор: Sinclair
Дата: 02.12.22


https://www.nuget.org/packages/Constructor.Inheritor/

public class Parent
{
   public Parent(string foo) => Console.WriteLine(foo);
   protected Parent(int bar) => Console.WriteLine(bar);
}

...

using Constructor.Inheritor;

  [InheritConstructors]
  internal partial class Child: Parent
  {
     // will behave as if the following is declared here:
     // public Child(string foo): base(foo) {}
     // protected Child(int bar): base(bar) {}
  }
... << RSDN@Home 1.0.0 alpha 5 rev. 0>>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.