我的程序集中定义了以下类型:
type DatabaseDifferences = {missingTables: Table list}
type ComparisonResult = IsMatch | Differences of DatabaseDifferences
Table list
然后从我的测试程序集中,当我尝试查看DatabaseDifferences
类型上的长度时,我收到以下错误:
System.MissingMethodExceptionMethod not found: 'Microsoft.FSharp.Collections.FSharpList``1<Table> DatabaseDifferences.get_missingTables()'.
这是重现该问题的缩减测试:
let extractDifferences r =
match r with
| Differences(r') -> r'
| _ -> failwith "expected databases to be different but they are a match"
[<Fact>]
let ``fail example``() =
let d = Differences{missingTables = []} |> extractDifferences
d.missingTables.Length |> should equal 0
如果我在与测试相同的程序集中声明类型,则一切正常,因此例如此代码通过(表类型仍在另一个程序集中定义):
type diff = {missingTables: Table list}
type cr = IsMatch | Diffs of diff
let extract r =
match r with
| Diffs(r') -> r'
| _ -> failwith "expected databases to be different but they are a match"
[<Fact>]
let ``fail example 2``() =
let d = Diffs{missingTables = []} |> extract
d.missingTables.Length |> should equal 0
我在两个程序集中都使用 F# 核心版本 4 和 .Net 版本 4.6.2