4

我的程序集中定义了以下类型:

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


您需要在重新创建片段视图中的新片段之前删除片段,因此在方法中添加==null条件,onCreatedView

View mainView;// this should be global variable.

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if(mainview==null){
           mainView = inflater.inflate(R.layout.fragment_layout, container, false);
           initializeView();//initialize all views in this method instead of onActivityCreated 
        }
        return mainView;
    }

当你推送上面的片段时添加这个以避免重复

try {
     android.app.Fragment fragment = getFragmentManager().findFragmentById(R.id.map_online);
     if (fragment != null) {
         android.app.FragmentTransaction ft = getFragmentManager().beginTransaction();
         ft.remove(fragment);
         ft.commit();
     }
} catch (Exception e) {
  e.printStackTrace();
}
4

0 回答 0