Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

FSharp Expression causes compiler results not consistent across grid
marklam
#1 Posted : Tuesday, June 13, 2017 2:03:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/13/2017(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Using an FSharp.Expr variable in a distributed test causes a warning because the compiler adds debug information containing file paths (NCrunch 3.8.0.3)

To reproduce: (F# 4.1, VS2017)
  1. Create an F# class library project and add the NUnit 3.7 Nuget package

  2. Use the following test implementation

Code:
namespace ExpressionTest

open NUnit.Framework

[<TestFixture>]
type Fixture1() = 
    [<Test>]
    member __.Test1 () = 
        let expression = <@ 99 @>
        Assert.AreEqual("Hello", "Hello")


The full path to the source file is stored in a byte array, and the length of the path affect the name (288Bytes here)
Code:
.class private abstract auto ansi sealed beforefieldinit '<PrivateImplementationDetails$ExpressionTest>'
       extends [mscorlib]System.Object
{
  .class explicit ansi sealed nested assembly beforefieldinit T1799_288Bytes@
         extends [mscorlib]System.ValueType
  {
    .pack 0
    .size 288
  } // end of class T1799_288Bytes@

} // end of class '<PrivateImplementationDetails$ExpressionTest>'

and also the call to deserialize the info (0x120 here)
Code:
      IL_0088:  ldc.i4     0x120
      IL_008d:  newarr     [mscorlib]System.Byte
      IL_0092:  dup
      IL_0093:  ldtoken    field valuetype '<PrivateImplementationDetails$ExpressionTest>'/T1799_288Bytes@ '<StartupCode$ExpressionTest>'.$Library1::field1800@
      IL_0098:  call       void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array,
                                                                                                          valuetype [mscorlib]System.RuntimeFieldHandle)
      IL_009d:  call       class [FSharp.Core]Microsoft.FSharp.Quotations.FSharpExpr [FSharp.Core]Microsoft.FSharp.Quotations.FSharpExpr::Deserialize40(class [mscorlib]System.Type,
                                                                                                                                                        class [mscorlib]System.Type[],
                                                                                                                                                        class [mscorlib]System.Type[],
                                                                                                                                                        class [FSharp.Core]Microsoft.FSharp.Quotations.FSharpExpr[],
                                                                                                                                                        uint8[])
Remco
#2 Posted : Wednesday, June 14, 2017 1:11:36 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 4,974

Thanks: 664 times
Was thanked: 781 time(s) in 743 post(s)
Hi, thanks for sharing this problem. I've been able to reproduce it as per your instructions.

I can confirm a fix for this will be in the next available build of NCrunch.
1 user thanked Remco for this useful post.
marklam on 6/14/2017(UTC)
Remco
#3 Posted : Friday, June 16, 2017 4:04:58 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 4,974

Thanks: 664 times
Was thanked: 781 time(s) in 743 post(s)
marklam
#4 Posted : Friday, June 16, 2017 1:24:36 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/13/2017(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Thanks, but unfortunately, that doesn't fix this case:

Code:

namespace ExpressionTest

open NUnit.Framework
open System.IO

[<TestFixture>]
type Fixture1() =
[<Test>]
member __.Test1 () =
let expression = (fun (x : Stream) -> <@ x.Close() @>)
Assert.AreEqual("Hello", "Hello")


The differences I'm getting are in tests that use the Foq Nuget package, maybe my repro cases are too narrow.
A bigger set of examples are available in https://github.com/fsprojects/Foq/tree/master/Examples if that's helpful.
Remco
#5 Posted : Friday, June 16, 2017 11:42:31 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 4,974

Thanks: 664 times
Was thanked: 781 time(s) in 743 post(s)
Thanks, I'll take another look and will get back to you.
Remco
#6 Posted : Saturday, June 17, 2017 3:33:08 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 4,974

Thanks: 664 times
Was thanked: 781 time(s) in 743 post(s)
It looks as though these expressions can have a broader footprint in the method structure than I originally thought. I have a broader fix in the pipe for this, I'll include this for you in the next dev build when this is available.

I recommend sticking with using an 'Impact analysis mode' of 'WatchText' for the time being if you need an immediate workaround for this problem.
marklam
#7 Posted : Friday, July 21, 2017 9:01:46 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/13/2017(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I haven't seen this happening with the newest build, looking good
Thanks!
1 user thanked marklam for this useful post.
Remco on 7/21/2017(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.045 seconds.