question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't work with ValueTuples

See original GitHub issue

Hey, 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.

image

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:closed
  • Created 5 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
EamonNerbonnecommented, Jun 1, 2018

Yep!

1reaction
EamonNerbonnecommented, Jun 1, 2018

(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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found