简体   繁体   English

F#Struct with Interface,C#metadata不显示Interface的继承

[英]F# Struct with Interface, C# metadata does not show inheritance from Interface

So, bizarre issue I've got a struct and a record. 所以,奇怪的问题我有一个结构和记录。 Both implement the ITick interface, however when referencing Tick in C# the metadata shows no inheritance from the interface. 两者都实现了ITick接口,但是当在C#中引用Tick时,元数据显示没有来自接口的继承。 For the RedisTick record type though the interface is inherited. 对于RedisTick记录类型,虽然接口是继承的。

Have I missed something in my code / is this a bug / what's wrong with it? 我错过了我的代码/这是一个错误/它有什么问题吗?

Interface 接口

type ITick = 
    abstract Symbol : string
    abstract Date : DateTime
    abstract Price : Decimal
    abstract Volume : int

Struct 结构

type Tick(symbol : string, date : DateTime, price : Decimal, volume : int) = 
    struct
        member this.Symbol = symbol
        member this.Date = date
        member this.Price = price
        member this.Volume = volume
        interface ITick with
            member this.Symbol = this.Symbol
            member this.Date = this.Date
            member this.Price = this.Price
            member this.Volume = this.Volume
    end

Record 记录

[<CLIMutable>]
type RedisTick = 
    { Symbol : string
      Date : DateTime
      Price : Decimal
      Volume : int }
    interface ITick with
        member this.Symbol = this.Symbol
        member this.Date = this.Date
        member this.Price = this.Price
        member this.Volume = this.Volume

C# Metadata: C#元数据:

Record in C# 用C#记录

[Microsoft.FSharp.Core.CLIMutableAttribute] [Microsoft.FSharp.Core.CompilationMappingAttribute] 
public sealed class RedisTick : IEquatable<RedisTick>, IStructuralEquatable, IComparable<RedisTick>, IComparable, IStructuralComparable, ITick {
        public RedisTick();
        public RedisTick(string symbol, DateTime date, decimal price, int volume);

    [Microsoft.FSharp.Core.CompilationMappingAttribute]
    public DateTime Date { get; set; }
    [Microsoft.FSharp.Core.CompilationMappingAttribute]
    public decimal Price { get; set; }
    [Microsoft.FSharp.Core.CompilationMappingAttribute]
    public string Symbol { get; set; }
    [Microsoft.FSharp.Core.CompilationMappingAttribute]
    public int Volume { get; set; }

    [CompilerGenerated]
    public sealed override int CompareTo(object obj);
    [CompilerGenerated]
    public sealed override int CompareTo(RedisTick obj);
    [CompilerGenerated]
    public sealed override int CompareTo(object obj, IComparer comp);
    [CompilerGenerated]
    public sealed override bool Equals(object obj);
    [CompilerGenerated]
    public sealed override bool Equals(RedisTick obj);
    [CompilerGenerated]
    public sealed override bool Equals(object obj, IEqualityComparer comp);
    [CompilerGenerated]
    public sealed override int GetHashCode();
    [CompilerGenerated]
    public sealed override int GetHashCode(IEqualityComparer comp); }

Struct in C# C#中的结构

[Microsoft.FSharp.Core.CompilationMappingAttribute]
public struct Tick : IEquatable<Tick>, IStructuralEquatable, IComparable<Tick>, IComparable, IStructuralComparable
{
    public Tick(string symbol, DateTime date, decimal price, int volume);

    public DateTime Date { get; }
    public decimal Price { get; }
    public string Symbol { get; }
    public int Volume { get; }

    [CompilerGenerated]
    public sealed override int CompareTo(object obj);
    [CompilerGenerated]
    public sealed override int CompareTo(Tick obj);
    [CompilerGenerated]
    public sealed override int CompareTo(object obj, IComparer comp);
    [CompilerGenerated]
    public sealed override bool Equals(object obj);
    [CompilerGenerated]
    public sealed override bool Equals(Tick obj);
    [CompilerGenerated]
    public sealed override bool Equals(object obj, IEqualityComparer comp);
    [CompilerGenerated]
    public sealed override int GetHashCode();
    [CompilerGenerated]
    public sealed override int GetHashCode(IEqualityComparer comp);
}

解决了VS2015 RC它已经修复!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM