dimanche 11 mai 2014

f # - compilation avec indicateur autonome donne des erreurs de compilation dans le code client - Stack Overflow


I'm attempting to compile Zero29 with the --standalone compiler flag. The project itself compiles fine, but I have a unit test project that exercises some code in the Zero29 project, even though it's an executable program (.exe).


Everything works fine without the --standalone compilation flag.


However, when I add the --standalone compilation flag to the Zero29 project, the Zero29 project compiles fine, but in the unit test project, the compiler complains about this Discriminated Union defined in the Zero29 project:


namespace Ploeh.ZeroToNine

open System
open Ploeh.ZeroToNine.Versioning

type Arg =
| Assign of Version
| AssignRank of Rank * int
| Increment of Rank
| ListVersions
| ShowHelp
| Unknown of string list

The unit test project directly references the Zero29 project:



Zero29.UnitTests --references--> Zero29 (where --standalone is added)



When I attempt to compile the entire solution, the Zero29 project compiles with the --standalone flag, but then compilation of Zero29.UnitTests fails. There are several errors, but they are all the same, so here's a single example:



error FS0039: The value or constructor 'Assign' is not defined



Which points to the third line of this code:


let ParseAssignVersionReturnsCorrectResult(version : string) =
let actual = [| "-a"; version |] |> Args.Parse
verify <@ [Assign(Version version)] = (actual |> Seq.toList) @>

The strange thing is that while the compiler complains about Assign in the third line of this code snippet, it doesn't complain about the use of Args.Parse, even though it's defined in the same code file as the Arg Discriminated Union.


Why does it do that, and how can I resolve this issue?


(I've attempted to distil the problem here, but the links I've provided point to the actual code files on GitHub, if more information is required.)



I'm attempting to compile Zero29 with the --standalone compiler flag. The project itself compiles fine, but I have a unit test project that exercises some code in the Zero29 project, even though it's an executable program (.exe).


Everything works fine without the --standalone compilation flag.


However, when I add the --standalone compilation flag to the Zero29 project, the Zero29 project compiles fine, but in the unit test project, the compiler complains about this Discriminated Union defined in the Zero29 project:


namespace Ploeh.ZeroToNine

open System
open Ploeh.ZeroToNine.Versioning

type Arg =
| Assign of Version
| AssignRank of Rank * int
| Increment of Rank
| ListVersions
| ShowHelp
| Unknown of string list

The unit test project directly references the Zero29 project:



Zero29.UnitTests --references--> Zero29 (where --standalone is added)



When I attempt to compile the entire solution, the Zero29 project compiles with the --standalone flag, but then compilation of Zero29.UnitTests fails. There are several errors, but they are all the same, so here's a single example:



error FS0039: The value or constructor 'Assign' is not defined



Which points to the third line of this code:


let ParseAssignVersionReturnsCorrectResult(version : string) =
let actual = [| "-a"; version |] |> Args.Parse
verify <@ [Assign(Version version)] = (actual |> Seq.toList) @>

The strange thing is that while the compiler complains about Assign in the third line of this code snippet, it doesn't complain about the use of Args.Parse, even though it's defined in the same code file as the Arg Discriminated Union.


Why does it do that, and how can I resolve this issue?


(I've attempted to distil the problem here, but the links I've provided point to the actual code files on GitHub, if more information is required.)


0 commentaires:

Enregistrer un commentaire