Skip to content

Commit 80bb06e

Browse files
authored
Apply more automatic code formatting (#13110)
* adjust settings * adjust settings * adjust settings * adjust settings * adjust settings * adjust settings * apply formatting
1 parent 1126e23 commit 80bb06e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+5608
-4956
lines changed

.fantomasignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@
2626
**/Query.fsi
2727
**/resumable.fsi
2828
**/async.fsi
29+
30+
## https://github.com/fsprojects/fantomas/issues/2230
31+
**/array.fsi
32+
**/tasks.fsi
33+
**/seq.fsi

DEVGUIDE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,22 @@ Linux/macOS:
147147
export TEST_UPDATE_BSL=1
148148
```
149149

150+
## Automated Source Code Formatting
151+
152+
Some of the code in this repository is formatted automatically by [Fantomas](https://github.com/fsprojects/fantomas). To format all files use:
153+
154+
```cmd
155+
dotnet fantomas src/fsharp -r
156+
```
157+
158+
The formatting is checked automatically by CI:
159+
160+
```cmd
161+
dotnet fantomas src/fsharp -r --check
162+
```
163+
164+
At the time of writing only a subset of signature files (`*.fsi`) are formatted. See the settings in `.fantomasignore` and `.editorconfig`.
165+
150166
## Developing the F# tools for Visual Studio
151167

152168
As you would expect, doing this requires both Windows and Visual Studio are installed.
@@ -191,6 +207,20 @@ To fix this, delete these folders:
191207

192208
Where `<version>` corresponds to the latest Visual Studio version on your machine.
193209

210+
## Coding conventions
211+
212+
* Coding conventions vary from file to file
213+
214+
* Format using [the F# style guide](https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/)
215+
216+
* Avoid tick identifiers like `body'`. They are generally harder to read and can't be inspected in the debugger as things stand. Generaly use R suffix instead, e.g. `bodyR`. The R can stand for "rewritten" or "result"
217+
218+
* Avoid abbreviations like `bodyty` that run together lowercase are bad, really hard to head for newcomers. Use `bodyTy` instead.
219+
220+
* See the comiler docs for common abbreviations
221+
222+
* Don't use `List.iter` and `Array.iter` in the compiler, a `for ... do ...` loop is simpler to read and debug
223+
194224
## Performance and debugging
195225

196226
Use the `Debug` configuration to test your changes locally. It is the default. Do not use the `Release` configuration! Local development and testing of Visual Studio tooling is not designed for the `Release` configuration.

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@ stages:
285285
env:
286286
DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1
287287
displayName: Install tools
288-
- script: dotnet fantomas src/fsharp --check
288+
- script: dotnet fantomas src/fsharp -r --check
289289
env:
290290
DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1
291-
displayName: Check code formatting (run dotnet fantomas src/fsharp to fix)
291+
displayName: Check code formatting (run 'dotnet fantomas src/fsharp -r' to fix)
292292

293293
# Linux
294294
- job: Linux

src/fsharp/CheckExpressions.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,8 @@ let FreshenTyconRef (g: TcGlobals) m rigid (tcref: TyconRef) declaredTyconTypars
18651865
let origTypars = declaredTyconTypars
18661866
let freshTypars = copyTypars origTypars
18671867
if rigid <> TyparRigidity.Rigid then
1868-
freshTypars |> List.iter (fun tp -> tp.SetRigidity rigid)
1868+
for tp in freshTypars do
1869+
tp.SetRigidity rigid
18691870

18701871
let renaming, tinst = FixupNewTypars m [] [] origTypars freshTypars
18711872
let origTy = TType_app(tcref, List.map mkTyparTy origTypars, g.knownWithoutNull)

src/fsharp/DependencyManager/DependencyProvider.fsi

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ type IResolveDependenciesResult =
1313
abstract Success: bool
1414

1515
/// The resolution output log
16-
abstract StdOut: string[]
16+
abstract StdOut: string []
1717

1818
/// The resolution error log (process stderr)
19-
abstract StdError: string[]
19+
abstract StdError: string []
2020

2121
/// The resolution paths - the full paths to selected resolved dll's.
2222
/// In scripts this is equivalent to #r @"c:\somepath\to\packages\ResolvedPackage\1.1.1\lib\netstandard2.0\ResolvedAssembly.dll"
@@ -51,10 +51,19 @@ type IDependencyManagerProvider =
5151
abstract Key: string
5252

5353
/// The help messages for this dependency manager inster
54-
abstract HelpMessages: string[]
54+
abstract HelpMessages: string []
5555

5656
/// Resolve the dependencies, for the given set of arguments, go find the .dll references, scripts and additional include values.
57-
abstract ResolveDependencies: scriptDir: string * mainScriptName: string * scriptName: string * scriptExt: string * packageManagerTextLines: (string * string) seq * tfm: string * rid: string * timeout: int -> IResolveDependenciesResult
57+
abstract ResolveDependencies:
58+
scriptDir: string *
59+
mainScriptName: string *
60+
scriptName: string *
61+
scriptExt: string *
62+
packageManagerTextLines: (string * string) seq *
63+
tfm: string *
64+
rid: string *
65+
timeout: int ->
66+
IResolveDependenciesResult
5867

5968
/// Todo describe this API
6069
[<RequireQualifiedAccess>]
@@ -66,7 +75,7 @@ type ResolvingErrorReport = delegate of ErrorReportType * int * string -> unit
6675

6776
/// Provides DependencyManagement functions.
6877
///
69-
/// The class incrementally collects IDependencyManagerProvider, indexed by key, and
78+
/// The class incrementally collects IDependencyManagerProvider, indexed by key, and
7079
/// queries them. These are found and instantiated with respect to the compilerTools and outputDir
7180
/// provided each time the TryFindDependencyManagerByKey and TryFindDependencyManagerInPath are
7281
/// executed, which are assumed to be invariant over the lifetime of the DependencyProvider.
@@ -83,16 +92,31 @@ type DependencyProvider =
8392
new: assemblyProbingPaths: AssemblyResolutionProbe * nativeProbingRoots: NativeResolutionProbe -> DependencyProvider
8493

8594
/// Returns a formatted help messages for registered dependencymanagers for the host to present
86-
member GetRegisteredDependencyManagerHelpText: string seq * string * ResolvingErrorReport -> string[]
95+
member GetRegisteredDependencyManagerHelpText: string seq * string * ResolvingErrorReport -> string []
8796

8897
/// Returns a formatted error message for the host to present
8998
member CreatePackageManagerUnknownError: string seq * string * string * ResolvingErrorReport -> int * string
9099

91100
/// Resolve reference for a list of package manager lines
92-
member Resolve : packageManager: IDependencyManagerProvider * scriptExt: string * packageManagerTextLines: (string * string) seq * reportError: ResolvingErrorReport * executionTfm: string * [<Optional;DefaultParameterValue(null:string MaybeNull)>]executionRid: string * [<Optional;DefaultParameterValue("")>]implicitIncludeDir: string * [<Optional;DefaultParameterValue("")>]mainScriptName: string * [<Optional;DefaultParameterValue("")>]fileName: string * [<Optional;DefaultParameterValue(-1)>]timeout: int -> IResolveDependenciesResult
101+
member Resolve:
102+
packageManager: IDependencyManagerProvider *
103+
scriptExt: string *
104+
packageManagerTextLines: (string * string) seq *
105+
reportError: ResolvingErrorReport *
106+
executionTfm: string *
107+
[<Optional; DefaultParameterValue(null: string MaybeNull)>] executionRid: string *
108+
[<Optional; DefaultParameterValue("")>] implicitIncludeDir: string *
109+
[<Optional; DefaultParameterValue("")>] mainScriptName: string *
110+
[<Optional; DefaultParameterValue("")>] fileName: string *
111+
[<Optional; DefaultParameterValue(-1)>] timeout: int ->
112+
IResolveDependenciesResult
93113

94114
/// Fetch a dependencymanager that supports a specific key
95-
member TryFindDependencyManagerByKey: compilerTools: string seq * outputDir: string * reportError: ResolvingErrorReport * key: string -> IDependencyManagerProvider MaybeNull
115+
member TryFindDependencyManagerByKey:
116+
compilerTools: string seq * outputDir: string * reportError: ResolvingErrorReport * key: string ->
117+
IDependencyManagerProvider MaybeNull
96118

97119
/// TryFindDependencyManagerInPath - given a #r "key:sometext" go and find a DependencyManager that satisfies the key
98-
member TryFindDependencyManagerInPath: compilerTools: string seq * outputDir: string * reportError: ResolvingErrorReport * path: string -> string MaybeNull * IDependencyManagerProvider MaybeNull
120+
member TryFindDependencyManagerInPath:
121+
compilerTools: string seq * outputDir: string * reportError: ResolvingErrorReport * path: string ->
122+
string MaybeNull * IDependencyManagerProvider MaybeNull

src/fsharp/DependencyManager/NativeDllResolveHandler.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type NativeDllResolveHandler =
1313

1414
/// Construct a new NativeDllResolveHandler
1515
new: nativeProbingRoots: NativeResolutionProbe -> NativeDllResolveHandler
16-
16+
1717
/// Construct a new NativeDllResolveHandler
1818
internal new: nativeProbingRoots: NativeResolutionProbe option -> NativeDllResolveHandler
1919

src/fsharp/FSharp.Core/Linq.fsi

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,73 +18,74 @@ open Microsoft.FSharp.Quotations
1818
module LeafExpressionConverter =
1919
/// <summary>
2020
/// When used in a quotation, this function indicates a specific conversion
21-
/// should be performed when converting the quotation to a LINQ expression.
21+
/// should be performed when converting the quotation to a LINQ expression.
2222
///
23-
/// This function should not be called directly.
23+
/// This function should not be called directly.
2424
/// </summary>
2525
//
26-
// NOTE: when an F# expression tree is converted to a Linq expression tree using ToLinqExpression
26+
// NOTE: when an F# expression tree is converted to a Linq expression tree using ToLinqExpression
2727
// the transformation of <c>LinqExpressionHelper(e)</c> is the same as the transformation of
28-
// 'e'. This allows ImplicitExpressionConversionHelper to be used as a marker to satisfy the C# design where
28+
// 'e'. This allows ImplicitExpressionConversionHelper to be used as a marker to satisfy the C# design where
2929
// certain expression trees are constructed using methods with a signature that expects an
3030
// expression tree of type <c>Expression<T></c> but are passed an expression tree of type T.
3131
//[<System.Obsolete("This type is for use by the quotation to LINQ expression tree converter and is not for direct use from user code")>]
3232
val ImplicitExpressionConversionHelper: 'T -> Expression<'T>
3333

3434
/// <summary>
3535
/// When used in a quotation, this function indicates a specific conversion
36-
/// should be performed when converting the quotation to a LINQ expression.
36+
/// should be performed when converting the quotation to a LINQ expression.
3737
///
38-
/// This function should not be called directly.
38+
/// This function should not be called directly.
3939
/// </summary>
4040
//[<System.Obsolete("This type is for use by the quotation to LINQ expression tree converter and is not for direct use from user code")>]
4141
val MemberInitializationHelper: 'T -> 'T
4242

4343
/// <summary>
4444
/// When used in a quotation, this function indicates a specific conversion
45-
/// should be performed when converting the quotation to a LINQ expression.
45+
/// should be performed when converting the quotation to a LINQ expression.
4646
///
47-
/// This function should not be called directly.
47+
/// This function should not be called directly.
4848
/// </summary>
4949
//[<System.Obsolete("This type is for use by the quotation to LINQ expression tree converter and is not for direct use from user code")>]
50-
val NewAnonymousObjectHelper: 'T -> 'T
50+
val NewAnonymousObjectHelper: 'T -> 'T
5151

5252
/// <summary>
5353
/// Converts a subset of F# quotations to a LINQ expression, for the subset of LINQ expressions represented by the
5454
/// expression syntax in the C# language.
5555
/// </summary>
56-
///
56+
///
5757
/// <example-tbd></example-tbd>
5858
val QuotationToExpression: Expr -> Expression
5959

6060
/// <summary>
6161
/// Converts a subset of F# quotations to a LINQ expression, for the subset of LINQ expressions represented by the
62-
/// expression syntax in the C# language.
62+
/// expression syntax in the C# language.
6363
/// </summary>
64-
///
64+
///
6565
/// <example-tbd></example-tbd>
6666
val QuotationToLambdaExpression: Expr<'T> -> Expression<'T>
6767

6868
/// <summary>
6969
/// Evaluates a subset of F# quotations by first converting to a LINQ expression, for the subset of LINQ expressions represented by the
7070
/// expression syntax in the C# language.
7171
/// </summary>
72-
///
72+
///
7373
/// <example-tbd></example-tbd>
7474
val EvaluateQuotation: Expr -> obj
7575

7676
/// <summary>
7777
/// A runtime helper used to evaluate nested quotation literals.
7878
/// </summary>
79-
///
79+
///
8080
/// <example-tbd></example-tbd>
81-
val SubstHelper: Expr * Var[] * obj[] -> Expr<'T>
81+
val SubstHelper: Expr * Var [] * obj [] -> Expr<'T>
8282

8383
/// <summary>
8484
/// A runtime helper used to evaluate nested quotation literals.
8585
/// </summary>
86-
///
86+
///
8787
/// <example-tbd></example-tbd>
88-
val SubstHelperRaw: Expr * Var[] * obj[] -> Expr
88+
val SubstHelperRaw: Expr * Var [] * obj [] -> Expr
8989

90-
val internal (|SpecificCallToMethod|_|): System.RuntimeMethodHandle -> (Expr -> (Expr option * Type list * Expr list) option)
90+
val internal (|SpecificCallToMethod|_|):
91+
System.RuntimeMethodHandle -> (Expr -> (Expr option * Type list * Expr list) option)

0 commit comments

Comments
 (0)