Corner case in using lambdas expression in base constructor

后端 未结 5 1558
伪装坚强ぢ
伪装坚强ぢ 2021-01-05 08:03

In the Framework we are building we need the following pattern:

public class BaseRenderer
{
    Func renderer;
    public BaseRenderer(Func<         


        
5条回答
  •  一向
    一向 (楼主)
    2021-01-05 08:26

    wouldn't : base(()=>this) be legal? You can do : this() so a reference to this seems to be fine, just not properties on it. The fact that : base(()=>this) is no longer legal just broke some partial function application I did during construction. Can be fixed by moving it into the body of the constructor, but there is an order difference: the base class can no longer be passed transparently a partial function application to itself (because the base class constructor gets called before the body of the subclass constructor).

提交回复
热议问题