【问题标题】:Implement an internal abstract member实现一个内部抽象成员
【发布时间】:2013-03-06 08:11:39
【问题描述】:

一个抽象类,在本例中为 System.Reflection.MethodBase,需要实现整个接口,这很好。但它有这个抽象成员:

internal abstract ParameterInfo[] GetParametersInternal ();

F# 编译器抱怨:

没有为 'MethodBase.GetParametersInternal() 提供实现: 参数信息[]'

如何实现这个我无权访问的内部成员?或者只是忽略这一点并实现公共成员。

如果我确实尝试强制覆盖:

override this.GetParametersInternal() = parameters |> List.toArray

我明白了:

未找到与此对应的抽象或接口成员 覆盖。

【问题讨论】:

    标签: f# mono


    【解决方案1】:

    您可能正在尝试使用类型提供程序构建 F# 3。 这是 Mono 3.0.6 中的一个错误: https://bugzilla.xamarin.com/show_bug.cgi?id=10884

    两天前才修复,所以请等待 3.0.7,除非您想自己编译 Mono。

    【讨论】:

    • 是的,我正在使用类型提供程序。是的,它发生在 3.0.6 中。谢谢。
    【解决方案2】:

    您不能覆盖此成员 - 内部成员仅对同一程序集中的类型可见。 MethodBase 在 mscorlib 中定义,因此 GetParametersInternal 仅对该程序集中的其他类型可见,而您的代码不可见。

    【讨论】:

      【解决方案3】:

      就像 Lee 所说,您不应该能够覆盖来自另一个程序集的内部成员。在进行基本继承时,我没有看到任何编译器错误 - 下面编译得很好:

      type MyMethodBase() = 
          inherit System.Reflection.MethodBase()
          override this.Attributes with get () = failwith ""
          override this.GetMethodImplementationFlags() = failwith ""
          override this.GetParameters() = failwith ""
          override this.Invoke(obj, invokeAttr, binder, parameters, culture) = failwith ""
          override this.MethodHandle with get() = failwith ""
          override this.DeclaringType with get() = failwith ""
          override this.GetCustomAttributes(attributeType, inh) = failwith ""
          override this.GetCustomAttributes(b) = failwith ""
          override this.IsDefined(attributeType, inh) = failwith ""
          override this.MemberType with get() = failwith ""
          override this.Name with get() = failwith ""
          override this.ReflectedType with get() = failwith ""
      

      【讨论】:

        猜你喜欢
        • 2017-05-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多