Doesn't work with ValueTuples
See original GitHub issueHey, I just found this lib and it is absolutely awesome!
The only issue I found so far is that it really doesn’t like Value Tuples.
First, it seems like the C# Team explicitly forbade using ==
in expressions, if you try PAssert.That(() => (5, "a", 1.1) == (5, "a", 1.1));
you get a compiler error
1>Tests.cs(75,32,75,62): error CS8382: An expression tree may not contain a tuple == or != operator 1>Tests.cs(75,32,75,45): error CS8143: An expression tree may not contain a tuple literal. 1>Tests.cs(75,49,75,62): error CS8143: An expression tree may not contain a tuple literal.
Second I thought I was smart and tried to use .Equals
, which doesn’t work either.
Microsoft (R) Roslyn C# Compiler version 2.8.0.62830
Loading context from 'CSharpInteractive.rsp'.
Type "#help" for more information.
> #r "C:\Users\lr\.nuget\packages\expressiontocodelib\2.7.0\lib\net452\ExpressionToCodeLib.dll"
> var actual = (1, "2", 3.3);
> var expected = (2, "3", 4.4);
> using ExpressionToCodeLib;
.
. PAssert.That(() => actual.Equals(expected));
Cannot resolve method Boolean Equals(System.ValueTuple`3[System.Int32,System.__Canon,System.Double]) because the declaring type of the method handle System.ValueTuple`3[T1,T2,T3] is generic. Explicitly provide the declaring type to GetMethodFromHandle.
+ System.Reflection.MethodBase.GetMethodFromHandle(System.RuntimeMethodHandle)
>
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (12 by maintainers)
Top Results From Across the Web
valuetuple doesn't work for one of my 4.7.2 projects
I have multiple projects in the solution, all targeting 4.7.2. I then add a method in a lib project that returns valueTuple. Multiple...
Read more >Fixing System Value Tuple Error
To fix the issue, you need to reference the System.ValueTuple NuGet package either via Visual Studio's NuGet manager or via the Package Manager...
Read more >ValueTuples don't work with Should().Be() · Issue #544
@dennisdoomen yes I tried it with C# 7 (and VS2017). This syntax - comma separated values for defining Tuple - is a new...
Read more >15.5 Preview cannot build C# projects using System. ...
I've tried downgrading to 4.6.2 and use the System.ValueTuple package but that also doesn't fix the issue. I get errors like the following:...
Read more >Working with ValueTuple in C# | CodeGuru.com
That is, ValueTuples are both performant and referable by names chosen by the programmer. Here are the key properties of a ValueTuple: Value ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep!
(And yeah, it’s a shame there are so many C# features that are disabled in expression trees…)
Related: https://github.com/dotnet/roslyn/issues/12897