小编Tro*_*haw的帖子

无法在F#签名文件(.fsi)中使用Literal属性

我无法在F#签名文件中定义文字.

我有一个文件,File.fs如下所示:

module Thingo =
  [<Literal>]
  let hello = "world"
Run Code Online (Sandbox Code Playgroud)

我需要为它创建一个签名文件,所以最初尝试this(File.fsi):

module Thingo =
  [<Literal>]
  val hello : string
Run Code Online (Sandbox Code Playgroud)

这导致以下错误File.fsi:A declaration may only be the [<Literal>] attribute if a constant value is also given, e.g. 'val x : int = 1'

我放弃了:

module Thingo =
  [<Literal>]
  val hello : string = "world"
Run Code Online (Sandbox Code Playgroud)

声明的行val hello收到错误:Incomplete structured construct at or before this point in signature file. Expected incomplete structured construct …

f#

9
推荐指数
1
解决办法
185
查看次数

我可以在F#PCL库中使用System.Timers.Timer吗?

我需要System.Timers.Timer在F#PCL库中使用。

我目前的目标是框架4.5并使用Profile7(我使用VS模板),并且它不允许访问System.Timer。

根据此SO答案,这是一个已知问题,已在4.5.1中解决。

我创建了一个4.5.1 C#PCL,并检查了其.csproj。它针对框架4.6,并使用Profile32。

在F#项目中有没有针对相同目标的方法?我天真地尝试使用C#值更新.fsproj,但它破坏了一切。:)

非常感谢!

f# portable-class-library

3
推荐指数
1
解决办法
402
查看次数

标签 统计

f# ×2

portable-class-library ×1