dotnet / dotnet/dotnet-api-docs

Expression.Block behavior mismatch

Open
#4,498 5 comments 2 reactions 0 assignees View on GitHub
area-System.Linq.Expressions Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

This simple piece of code behaves differently if compiled under .Net Core and .Net Framework (I tested 4.7.2 only).

``` CSharp
Expression.Block(Array.Empty(), Array.Empty());
```

In detail, .Net Core works fine, while .Net Framework throws an exception complaining about the empty block.

Reading the documentation of [Expression.Block](https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions.expression.block?view=netframework-4.7.2) method, no exception is mentioned.

This breaks the contract and is a (bad) problem if you are writing a library that uses expressions to generate code on the fly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.