【发布时间】:2018-11-01 04:51:26
【问题描述】:
我有一些 F# 代码调用了一个用 C# 编写的带有很多参数的方法。
为了使事情清晰易读,我在调用方法时使用了命名参数:
let request = Models.UserService.CreateUserRequest(
email = "email@example.com",
password = "password",
title = "title",
firstname = "firstname",
lastname = "lastname",
nickname = "nickname",
locale = "locale",
birthDate = "birthdate",
currency = "USD",
ipAddress = "127.0.0.1",
address = address,
mobilePhone = "+1 123 456 7890"
)
但是我收到关于缩进的警告:
warning FS0058: Possible incorrect indentation: this token is offside of context started at position (30:19). Try indenting this token further or using standard formatting conventions.
显然,如果我不使用 命名参数 或将所有内容放在一行中,警告就会消失。但我想以一种清晰易读的方式格式化它。
有没有办法在 F# 中格式化多行的方法调用而不会出现警告?
【问题讨论】:
-
我很确定您只需将参数缩进超过初始分配的位置。这一行 -> let request = Models.UserService.CreateUserRequest(