アセンブリで定義されている次の型があります。
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
テストと同じアセンブリで型を宣言すると、すべてが機能するため、たとえば次のコードはパスします (Table 型は他のアセンブリで定義されたままです)。
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 を使用しています。