F# Struct with Interface,C# 元数据不显示从 Interface 的继承
F# Struct with Interface, C# metadata does not show inheritance from Interface
所以,奇怪的问题我有一个结构和一个记录。两者都实现了 ITick 接口,但是在 C# 中引用 Tick 时,元数据显示没有从接口继承。对于 RedisTick 记录类型虽然接口是继承的。
我是否遗漏了我的代码中的某些内容/这是一个错误/它有什么问题吗?
界面
type ITick =
abstract Symbol : string
abstract Date : DateTime
abstract Price : Decimal
abstract Volume : int
结构
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
记录
[<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# 元数据:
用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); }
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 中已修复!
所以,奇怪的问题我有一个结构和一个记录。两者都实现了 ITick 接口,但是在 C# 中引用 Tick 时,元数据显示没有从接口继承。对于 RedisTick 记录类型虽然接口是继承的。
我是否遗漏了我的代码中的某些内容/这是一个错误/它有什么问题吗?
界面
type ITick =
abstract Symbol : string
abstract Date : DateTime
abstract Price : Decimal
abstract Volume : int
结构
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
记录
[<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# 元数据:
用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); }
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 中已修复!