fantomless-tool 4.8.999

dotnet tool install --global fantomless-tool --version 4.8.999                
此包包含一个可在 shell/命令行中调用的 .NET 工具
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local fantomless-tool --version 4.8.999                
此包包含一个可在 shell/命令行中调用的 .NET 工具
#tool dotnet:?package=fantomless-tool&version=4.8.999                
nuke :add-package fantomless-tool --version 4.8.999                

Fantomless

Fantomas logo

F# 源代码格式化工具,基于 Fantomas 进行分支,受到 scalariform(Scala)、ocp-indent(OCaml)和 PythonTidy(Python)的启发。

Build Status Github Actions Discord

为什么是分支

由于以下票务问题,我们尚未将修复发布到上游:

快速安装

  • 命令行: dotnet tool install -g fantomless-tool

如何使用

命令行工具 / API

使用此命令将 Fantomless 作为 .NET 5 SDK 全局工具安装

dotnet tool install -g fantomless-tool

有关详细指南,请参阅 Fantomas:如何使用

FAKE 构建系统

Fantomas 可以轻松集成到 FAKE 构建系统中。
查看 示例

JetBrains Rider

resharper-fsharp 在底层使用 fantomas 对源代码进行格式化。无需安装任何额外的插件。

在 Rider 中使用最新版本

由于技术原因,Rider 不能始终使用在 NuGet 上找到的最新版本 of Fantomas。作为替代方案,您可以使用 dotnet tool install fantomas-tool 在本地安装 fantomas-tool 并将其配置为 外部工具

Rider external tool window

Rider action window

这将对您的 Rider 编辑体验产生影响,命令行应用程序通过外部更改文件可能会在 Rider 内部触发比必要更多的不必要内部逻辑。这可能在默认格式化体验中有所体现。

Visual Studio Code

推荐使用 Fantomas 的方法是使用 Ionide 插件。Fantomas 集成在 FSAutoComplete 中,这是 Ionide 所使用的语言服务器。

或者,您也可以安装 fantomas-fmt 扩展。

Visual Studio

F# 格式化扩展将 Fantomas 设置为 F# 文件的默认格式化工具,此配置可以从 Visual Studio 的选项中进行。

Visual Studio for Mac

使用 dotnet tool install fantomas-tool 命令在本地安装 fantomas-tool,并将其配置为 [外部工具]

VS Mac external tool window

在线

尝试在线使用 Fantomas 平台

早期构建版本

偶尔会发布到 https://nuget.net.cn/alphabeta 版本。我们之前使用的 MyGet 食品源现在已弃用。

基准测试

一些数据可以在 https://fsprojects.github.io/fantomas/ 找到 <br/> 我们使用 BenchmarkDotNet 收集 master 分支上每个构建的数据。

用途

本项目旨在根据给定的配置格式化 F# 源文件。Fantomas 将确保源文件中元素的正确缩进和一致的间距。我们假设在喂入工具之前,源文件可以被 F# 编译器解析。Fantomas 遵循两个 F# 风格指南:默认情况下是微软的 F# 代码格式化指南,以及通过各种 设置G-Research F# 代码格式化指南

使用案例

本项目开发是基于以下用例

  • 重格式化一个不熟悉的代码库。当您不是最初编写代码的人时,它提供了可读性。例如,以下例子

     type Type
         = TyLam of Type * Type
         | TyVar of string
         | TyCon of string * Type list
         with override this.ToString () =
                 match this with
                 | TyLam (t1, t2) -> sprintf "(%s -> %s)" (t1.ToString()) (t2.ToString())
                 | TyVar a -> a
                 | TyCon (s, ts) -> s
    

    将重写为

     type Type =
         | TyLam of Type * Type
         | TyVar of string
         | TyCon of string * Type list
         override this.ToString() =
             match this with
             | TyLam(t1, t2) -> sprintf "(%s -> %s)" (t1.ToString()) (t2.ToString())
             | TyVar a -> a
             | TyCon(s, ts) -> s
    
  • 将冗长语法转换为轻量语法。将源文件以冗长模式馈入,Fantomas 将将其适当地格式化为轻量模式。这对于代码生成可能很有帮助,因为生成冗长源文件要容易得多。例如,以下代码片段

     let Multiple9x9 () =
         for i in 1 .. 9 do
             printf "\n";
             for j in 1 .. 9 do
                 let k = i * j in
                 printf "%d x %d = %2d " i j k;
             done;
         done;;
     Multiple9x9 ();;
    

    将被重新格式化为

     let Multiple9x9() =
         for i in 1..9 do
             printf "\n"
             for j in 1..9 do
                 let k = i * j
                 printf "%d x %d = %2d " i j k
    
     Multiple9x9()
    
  • 格式化 F# 签名,尤其是由 F# 编译器和 F# Interactive 生成的签名。

对于更复杂的例子,请参阅 20 个语言大战程序的 F# 输出10 份 CodeReview.SE 源文件

为什么叫 "Fantomas" 呢?

选择这个名字有几个原因。首先,它以 "F" 开头,就像许多其他 F# 项目一样。其次,Fantomas 是我最喜欢的文学人物。最后,Fantomas 拥有与 "phantom" 相同的希腊词根;巧合的是,F# AST 和格式化规则在正确处理之前是如此 神秘

贡献指南

请参阅 贡献指南

致谢

我们衷心感谢以下人士的贡献。

许可

本库和工具可在 Apache 2.0 许可证下使用。有关更多信息,请参阅 许可证文件

产品 兼容的和额外的计算目标框架版本。
.NET net5.0 已计算。  net5.0-windows 已计算。  net6.0 已计算。  net6.0-android 已计算。  net6.0-ios 已计算。  net6.0-maccatalyst 已计算。  net6.0-macos 已计算。  net6.0-tvos 已计算。  net6.0-windows 已计算。  net7.0 已计算。  net7.0-android 已计算。  net7.0-ios 已计算。  net7.0-maccatalyst 已计算。  net7.0-macos 已计算。  net7.0-tvos 已计算。  net7.0-windows 已计算。  net8.0 已计算。  net8.0-android 已计算。  net8.0-browser 已计算。  net8.0-ios 已计算。  net8.0-maccatalyst 已计算。  net8.0-macos 已计算。  net8.0-tvos 已计算。  net8.0-windows 已计算。 
.NET Core netcoreapp3.1 兼容。 
兼容的目标框架
包含的目标框架(在包中)
了解更多关于 目标框架.NET 标准化 的信息。

此包无依赖项。

版本 下载 最后更新
4.8.999 559 7/11/2022
4.7.999 479 5/13/2022
4.7.999-预发布 272 5/16/2022
4.7.997 1,917 4/20/2022
4.7.997-预发布 4,265 4/20/2022
4.7.996 3,907 4/7/2022
4.7.995 459 3/31/2022
4.7.99 502 3/29/2022
4.7.7-预发布 262 4/15/2022
4.5.12.6 497 2/24/2022
4.5.12.5 901 2/16/2022
4.5.12.4 517 2/2/2022
4.5.12.3 496 2/2/2022
4.5.12.2 507 2/2/2022
4.5.7.2 460 11/11/2021
4.5.4.4 539 10/22/2021
4.5.4.2 384 10/21/2021
4.5.4.1 409 10/12/2021
4.5.3.2 378 9/28/2021
4.5.3.1 700 9/23/2021
4.5.3 360 9/20/2021
4.5.1 457 8/7/2021
4.4.0 503 7/31/2021

### 新增
* 将 `fable_modules` 添加到始终排除的目录中。[Fable 3.4](https://github.com/fable-compiler/Fable/releases/tag/3.4.0)

### 修复
* 在匹配 lambda 后的外部移动绑定。[#2214](https://github.com/fsprojects/fantomas/issues/2214)