Can a class inherit from LambdaExpression in .NET? Or is it not recommended?

Consider the following code (C # 4.0):

public class Foo : LambdaExpression { }

This causes the following development-time error:

Foo does not implement inherited abstract member
System.Linq.Expressions.LambdaExpression.Accept(System.Linq.Expressions.Compiler.StackSpiller)

There is no problem with public class Foo : Expression { }, but out of curiosity and for the sake of training, I searched on Google System.Linq.Expressions.LambdaExpression.Accept(System.Linq.Expressions.Compiler.StackSpiller)and guessed that: zero results are returned (when was the last time you saw this?), Needless to say, I did not find any documentation on this method elsewhere.

As I said, you can easily inherit from Expression; on the other hand LambdaExpression, but not marked as sealed( Expression<TDelegate>inherited from it), seems to be intended to prevent inheritance from it. Is it really? Does anyone know what this method is?

EDIT (1): . Accept, (# 2010 Express) :

protected override Expression Accept(System.Linq.Expressions.ExpressionVisitor visitor)
{
    return base.Accept(visitor);
}

- . StackSpiller, : System.Linq.Expressions.Compiler.StackSpiller is inaccessible due to its protection level.

EDIT (2): LambdaExpression , , , . , Foo cannot implement inherited abstract member System.Linq.Expressions.LambdaExpression.Accept(System.Linq.Expressions.Compiler.StackSpiller) because [reasons go here]; ( ), , , , Accept ( ).

+3
4

LambdaExpression .NET 3.5 Reflector, internal. , "" System.Linq.Expressions. LambdaExpression " ", .NET 3.5 ( , ).

.NET 4.0 , . Accept internal, StackSpiller. , ( ). , - internal .NET 4.0. , ( ).

EDIT: StackSpiller - , . , , DLR, .NET 4.0, - ( # 4 dynamic). , DLR , :

CLR , , try .

, -, Compile. CodePlex.

+7

, LambdaExpression . Accept, Foo .

LambdaExpression MSDN Accept.

+4

, , LambdaExpression , , , , . Accept.

+2

. LambdaExpression . , ( )

+2

Source: https://habr.com/ru/post/1733685/


All Articles