Skip to content

Commit 2ef8052

Browse files
authored
.fantomasignore - files in src/Compiler that had issues around conditional defines (#14961)
* Unignoring Compiler files which suffered from #if-related fantomas bug * Unfortunately some files fail on --check, but can be formatted
1 parent 79e5466 commit 2ef8052

17 files changed

+3664
-2238
lines changed

.fantomasignore

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,10 @@ src/Compiler/Checking/TypeHierarchy.fs
4040
src/Compiler/Checking/TypeRelations.fs
4141

4242
# Incorrectly formatted: https://github.com/dotnet/fsharp/pull/14645/commits/49443a67ea8a17670c8a7c80c8bdf91f82231e91 or https://github.com/fsprojects/fantomas/issues/2733
43+
# This CompilerImports.fs behavior is not fixed yet, following up in https://github.com/fsprojects/fantomas/issues/2733
4344
src/Compiler/Driver/CompilerImports.fs
44-
45-
src/Compiler/DependencyManager/AssemblyResolveHandler.fs
46-
src/Compiler/DependencyManager/DependencyProvider.fs
47-
src/Compiler/DependencyManager/NativeDllResolveHandler.fs
48-
49-
src/Compiler/Facilities/BuildGraph.fs
50-
src/Compiler/Facilities/CompilerLocation.fs
51-
src/Compiler/Facilities/DiagnosticOptions.fs
52-
src/Compiler/Facilities/DiagnosticResolutionHints.fs
53-
src/Compiler/Facilities/DiagnosticsLogger.fs
54-
src/Compiler/Facilities/LanguageFeatures.fs
55-
src/Compiler/Facilities/Logger.fs
56-
src/Compiler/Facilities/prim-lexing.fs
57-
src/Compiler/Facilities/prim-parsing.fs
58-
src/Compiler/Facilities/ReferenceResolver.fs
59-
src/Compiler/Facilities/SimulatedMSBuildReferenceResolver.fs
60-
src/Compiler/Facilities/TextLayoutRender.fs
61-
62-
src/Compiler/Interactive/ControlledExecution.fs
63-
src/Compiler/Interactive/fsi.fs
64-
65-
src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs
66-
src/Compiler/Legacy/LegacyMSBuildReferenceResolver.fs
67-
45+
# The following files were formatted, but the "format, --check" loop is not stable.
46+
# Fantomas formats them, but still thinks they need formatting
6847
src/Compiler/Optimize/DetupleArgs.fs
6948
src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs
7049
src/Compiler/Optimize/LowerCalls.fs
@@ -89,7 +68,6 @@ src/Compiler/TypedTree/TypedTreeBasics.fs
8968
src/Compiler/TypedTree/TypedTreeOps.fs
9069
src/Compiler/TypedTree/TypedTreePickle.fs
9170
src/Compiler/TypedTree/TypeProviders.fs
92-
9371
# Explicitly unformatted file that needs more care to get it to format well
9472

9573
src/Compiler/SyntaxTree/LexFilter.fs

src/Compiler/DependencyManager/AssemblyResolveHandler.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ type AssemblyResolveHandlerDeskTop(assemblyProbingPaths: AssemblyResolutionProbe
106106
type AssemblyResolveHandler internal (assemblyProbingPaths: AssemblyResolutionProbe option) =
107107

108108
let handler =
109-
assemblyProbingPaths |> Option.map (fun _ ->
109+
assemblyProbingPaths
110+
|> Option.map (fun _ ->
110111
if isRunningOnCoreClr then
111112
new AssemblyResolveHandlerCoreclr(assemblyProbingPaths) :> IDisposable
112113
else
113-
new AssemblyResolveHandlerDeskTop(assemblyProbingPaths) :> IDisposable
114-
)
114+
new AssemblyResolveHandlerDeskTop(assemblyProbingPaths) :> IDisposable)
115115

116116
new(assemblyProbingPaths: AssemblyResolutionProbe) = new AssemblyResolveHandler(Option.ofObj assemblyProbingPaths)
117117

src/Compiler/DependencyManager/DependencyProvider.fs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ type IDependencyManagerProvider =
130130
abstract Key: string
131131
abstract HelpMessages: string[]
132132
abstract ClearResultsCache: unit -> unit
133+
133134
abstract ResolveDependencies:
134135
scriptDir: string *
135136
mainScriptName: string *
@@ -141,7 +142,7 @@ type IDependencyManagerProvider =
141142
timeout: int ->
142143
IResolveDependenciesResult
143144

144-
type ReflectionDependencyManagerProvider
145+
type ReflectionDependencyManagerProvider
145146
(
146147
theType: Type,
147148
nameProperty: PropertyInfo,
@@ -154,10 +155,10 @@ type IDependencyManagerProvider =
154155
clearResultCache: MethodInfo option,
155156
outputDir: string option,
156157
useResultsCache: bool
157-
) =
158+
) =
158159

159160
let instance =
160-
if not(isNull (theType.GetConstructor([|typeof<string option>; typeof<bool>|]))) then
161+
if not (isNull (theType.GetConstructor([| typeof<string option>; typeof<bool> |]))) then
161162
Activator.CreateInstance(theType, [| outputDir :> obj; useResultsCache :> obj |])
162163
else
163164
Activator.CreateInstance(theType, [| outputDir :> obj |])
@@ -173,11 +174,12 @@ type IDependencyManagerProvider =
173174
| None -> fun _ -> [||]
174175

175176
static member InstanceMaker(theType: Type, outputDir: string option, useResultsCache: bool) =
176-
match getAttributeNamed theType dependencyManagerAttributeName,
177-
getInstanceProperty<string> theType namePropertyName,
178-
getInstanceProperty<string> theType keyPropertyName,
179-
getInstanceProperty<string[]> theType helpMessagesPropertyName
180-
with
177+
match
178+
getAttributeNamed theType dependencyManagerAttributeName,
179+
getInstanceProperty<string> theType namePropertyName,
180+
getInstanceProperty<string> theType keyPropertyName,
181+
getInstanceProperty<string[]> theType helpMessagesPropertyName
182+
with
181183
| None, _, _, _
182184
| _, None, _, _
183185
| _, _, None, _ -> None
@@ -232,9 +234,7 @@ type IDependencyManagerProvider =
232234
resolveDependenciesMethodName
233235

234236
let clearResultsCacheMethod =
235-
getInstanceMethod<unit>
236-
theType [||]
237-
clearResultsCacheMethodName
237+
getInstanceMethod<unit> theType [||] clearResultsCacheMethodName
238238

239239
Some(fun () ->
240240
ReflectionDependencyManagerProvider(
@@ -303,9 +303,7 @@ type IDependencyManagerProvider =
303303
resolveDependenciesMethodName
304304

305305
let clearResultsCacheMethod =
306-
getInstanceMethod<unit>
307-
theType [||]
308-
clearResultsCacheMethodName
306+
getInstanceMethod<unit> theType [||] clearResultsCacheMethodName
309307

310308
Some(fun () ->
311309
ReflectionDependencyManagerProvider(
@@ -400,10 +398,9 @@ type IDependencyManagerProvider =
400398
member _.Key = instance |> keyProperty
401399

402400
/// Clear the dependency manager caches
403-
member _.ClearResultsCache () =
401+
member _.ClearResultsCache() =
404402
match clearResultCache with
405-
| Some clearResultsCache ->
406-
clearResultsCache.Invoke(instance, [||]) |> ignore
403+
| Some clearResultsCache -> clearResultsCache.Invoke(instance, [||]) |> ignore
407404
| None -> ()
408405

409406
/// Key of dependency Manager: used for #help
@@ -483,7 +480,13 @@ type IDependencyManagerProvider =
483480

484481
/// Provides DependencyManagement functions.
485482
/// Class is IDisposable
486-
type DependencyProvider internal (assemblyProbingPaths: AssemblyResolutionProbe option, nativeProbingRoots: NativeResolutionProbe option, useResultsCache: bool) =
483+
type DependencyProvider
484+
internal
485+
(
486+
assemblyProbingPaths: AssemblyResolutionProbe option,
487+
nativeProbingRoots: NativeResolutionProbe option,
488+
useResultsCache: bool
489+
) =
487490

488491
// Note: creating a NativeDllResolveHandler currently installs process-wide handlers
489492
let dllResolveHandler = new NativeDllResolveHandler(nativeProbingRoots)
@@ -557,11 +560,9 @@ type DependencyProvider internal (assemblyProbingPaths: AssemblyResolutionProbe
557560
new(assemblyProbingPaths: AssemblyResolutionProbe, nativeProbingRoots: NativeResolutionProbe, useResultsCache) =
558561
new DependencyProvider(Some assemblyProbingPaths, Some nativeProbingRoots, useResultsCache)
559562

560-
new(nativeProbingRoots: NativeResolutionProbe, useResultsCache) =
561-
new DependencyProvider(None, Some nativeProbingRoots, useResultsCache)
563+
new(nativeProbingRoots: NativeResolutionProbe, useResultsCache) = new DependencyProvider(None, Some nativeProbingRoots, useResultsCache)
562564

563-
new(nativeProbingRoots: NativeResolutionProbe) =
564-
new DependencyProvider(None, Some nativeProbingRoots, true)
565+
new(nativeProbingRoots: NativeResolutionProbe) = new DependencyProvider(None, Some nativeProbingRoots, true)
565566

566567
new() = new DependencyProvider(None, None, true)
567568

src/Compiler/DependencyManager/NativeDllResolveHandler.fs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ open Internal.Utilities
1111
open Internal.Utilities.FSharpEnvironment
1212
open FSharp.Compiler.IO
1313

14-
1514
type internal ProbingPathsStore() =
1615

1716
let addedPaths = ConcurrentBag<string>()
1817

19-
static member AppendPathSeparator (p: string) =
18+
static member AppendPathSeparator(p: string) =
2019
let separator = string Path.PathSeparator
2120

2221
if not (p.EndsWith(separator, StringComparison.OrdinalIgnoreCase)) then
@@ -27,14 +26,18 @@ type internal ProbingPathsStore() =
2726
static member RemoveProbeFromProcessPath probePath =
2827
if not (String.IsNullOrWhiteSpace(probePath)) then
2928
let probe = ProbingPathsStore.AppendPathSeparator probePath
30-
let path = ProbingPathsStore.AppendPathSeparator (Environment.GetEnvironmentVariable("PATH"))
29+
30+
let path =
31+
ProbingPathsStore.AppendPathSeparator(Environment.GetEnvironmentVariable("PATH"))
3132

3233
if path.Contains(probe) then
3334
Environment.SetEnvironmentVariable("PATH", path.Replace(probe, ""))
3435

3536
member _.AddProbeToProcessPath probePath =
3637
let probe = ProbingPathsStore.AppendPathSeparator probePath
37-
let path = ProbingPathsStore.AppendPathSeparator (Environment.GetEnvironmentVariable("PATH"))
38+
39+
let path =
40+
ProbingPathsStore.AppendPathSeparator(Environment.GetEnvironmentVariable("PATH"))
3841

3942
if not (path.Contains(probe)) then
4043
Environment.SetEnvironmentVariable("PATH", path + probe)
@@ -46,12 +49,14 @@ type internal ProbingPathsStore() =
4649

4750
member this.Dispose() =
4851
let mutable probe: string = Unchecked.defaultof<string>
52+
4953
while (addedPaths.TryTake(&probe)) do
5054
ProbingPathsStore.RemoveProbeFromProcessPath(probe)
5155

5256
interface IDisposable with
5357
member _.Dispose() =
5458
let mutable probe: string = Unchecked.defaultof<string>
59+
5560
while (addedPaths.TryTake(&probe)) do
5661
ProbingPathsStore.RemoveProbeFromProcessPath(probe)
5762

@@ -176,7 +181,7 @@ type NativeDllResolveHandler(nativeProbingRoots: NativeResolutionProbe option) =
176181

177182
let handler: NativeDllResolveHandlerCoreClr option =
178183
nativeProbingRoots
179-
|> Option.filter(fun _ -> isRunningOnCoreClr)
184+
|> Option.filter (fun _ -> isRunningOnCoreClr)
180185
|> Option.map (fun _ -> new NativeDllResolveHandlerCoreClr(nativeProbingRoots))
181186

182187
new(nativeProbingRoots: NativeResolutionProbe) = new NativeDllResolveHandler(Option.ofObj nativeProbingRoots)

src/Compiler/Driver/CompilerImports.fs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ let WriteSignatureData (tcConfig: TcConfig, tcGlobals, exportRemapping, ccu: Ccu
142142
tcConfig.outputFile
143143
|> Option.iter (fun outputFile ->
144144
let outputFile = FileSystem.GetFullPathShim(outputFile)
145-
let signatureDataFile = FileSystem.ChangeExtensionShim(outputFile, ".signature-data.json")
145+
146+
let signatureDataFile =
147+
FileSystem.ChangeExtensionShim(outputFile, ".signature-data.json")
148+
146149
serializeEntity signatureDataFile mspec)
147-
150+
148151
// For historical reasons, we use a different resource name for FSharp.Core, so older F# compilers
149152
// don't complain when they see the resource.
150153
let rName, compress =
@@ -1103,7 +1106,7 @@ and [<Sealed>] TcImports
11031106
initialResolutions: TcAssemblyResolutions,
11041107
importsBase: TcImports option,
11051108
dependencyProviderOpt: DependencyProvider option
1106-
)
1109+
)
11071110
#if !NO_TYPEPROVIDERS
11081111
as this
11091112
#endif
@@ -1183,10 +1186,11 @@ and [<Sealed>] TcImports
11831186
if publicOnly then
11841187
match e.TypeReprInfo with
11851188
| TILObjectRepr data ->
1186-
let (TILObjectReprData(_, _, tyDef)) = data
1189+
let (TILObjectReprData (_, _, tyDef)) = data
11871190
tyDef.Access = ILTypeDefAccess.Public
11881191
| _ -> false
1189-
else true
1192+
else
1193+
true
11901194
| None -> false
11911195
| None -> false
11921196

src/Compiler/Facilities/BuildGraph.fs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type NodeCodeBuilder() =
105105
(value :> IDisposable).Dispose()
106106
}
107107
)
108-
108+
109109
[<DebuggerHidden; DebuggerStepThrough>]
110110
member _.Using(value: IDisposable, binder: IDisposable -> NodeCode<'U>) =
111111
Node(
@@ -114,7 +114,6 @@ type NodeCodeBuilder() =
114114
return! binder value |> Async.AwaitNodeCode
115115
}
116116
)
117-
118117

119118
let node = NodeCodeBuilder()
120119

@@ -192,12 +191,9 @@ type NodeCode private () =
192191

193192
return results.ToArray()
194193
}
195-
196-
static member Parallel (computations: NodeCode<'T> seq) =
197-
computations
198-
|> Seq.map (fun (Node x) -> x)
199-
|> Async.Parallel
200-
|> Node
194+
195+
static member Parallel(computations: NodeCode<'T> seq) =
196+
computations |> Seq.map (fun (Node x) -> x) |> Async.Parallel |> Node
201197

202198
[<RequireQualifiedAccess>]
203199
module GraphNode =
@@ -238,6 +234,7 @@ type GraphNode<'T> private (computation: NodeCode<'T>, cachedResult: ValueOption
238234
else
239235
node {
240236
Interlocked.Increment(&requestCount) |> ignore
237+
241238
try
242239
let! ct = NodeCode.CancellationToken
243240

@@ -255,8 +252,8 @@ type GraphNode<'T> private (computation: NodeCode<'T>, cachedResult: ValueOption
255252
.ContinueWith(
256253
(fun _ -> taken <- true),
257254
(TaskContinuationOptions.NotOnCanceled
258-
||| TaskContinuationOptions.NotOnFaulted
259-
||| TaskContinuationOptions.ExecuteSynchronously)
255+
||| TaskContinuationOptions.NotOnFaulted
256+
||| TaskContinuationOptions.ExecuteSynchronously)
260257
)
261258
|> NodeCode.AwaitTask
262259

@@ -283,7 +280,8 @@ type GraphNode<'T> private (computation: NodeCode<'T>, cachedResult: ValueOption
283280

284281
return! tcs.Task |> NodeCode.AwaitTask
285282
finally
286-
if taken then semaphore.Release() |> ignore
283+
if taken then
284+
semaphore.Release() |> ignore
287285
finally
288286
Interlocked.Decrement(&requestCount) |> ignore
289287
}

src/Compiler/Facilities/CompilerLocation.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ module internal FSharpEnvironment =
5656
else
5757
None
5858

59-
6059
// The default location of FSharp.Core.dll and fsc.exe based on the version of fsc.exe that is running
6160
// Used for
6261
// - location of design-time copies of FSharp.Core.dll and FSharp.Compiler.Interactive.Settings.dll for the default assumed environment for scripts
@@ -187,7 +186,9 @@ module internal FSharpEnvironment =
187186

188187
for p in searchToolPaths path compilerToolPaths do
189188
let fileName = Path.Combine(p, assemblyName)
190-
if File.Exists fileName then yield fileName
189+
190+
if File.Exists fileName then
191+
yield fileName
191192
}
192193

193194
let loadFromParentDirRelativeToRuntimeAssemblyLocation designTimeAssemblyName =

src/Compiler/Facilities/DiagnosticResolutionHints.fs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ type SuggestionBuffer(idText: string) =
7676
data[i] <- data[i + 1]
7777

7878
data[pos - 1] <- KeyValuePair(k, v)
79-
if tail > 0 then tail <- tail - 1
79+
80+
if tail > 0 then
81+
tail <- tail - 1
8082

8183
member _.Add(suggestion: string) =
8284
if not disableSuggestions then
@@ -95,10 +97,12 @@ type SuggestionBuffer(idText: string) =
9597
let suggestedText = suggestion.ToUpperInvariant()
9698
let similarity = EditDistance.JaroWinklerDistance uppercaseText suggestedText
9799

98-
if similarity >= highConfidenceThreshold
99-
|| suggestion.EndsWithOrdinal dotIdText
100-
|| (similarity >= minThresholdForSuggestions
101-
&& IsInEditDistanceProximity uppercaseText suggestedText) then
100+
if
101+
similarity >= highConfidenceThreshold
102+
|| suggestion.EndsWithOrdinal dotIdText
103+
|| (similarity >= minThresholdForSuggestions
104+
&& IsInEditDistanceProximity uppercaseText suggestedText)
105+
then
102106
insert (similarity, suggestion)
103107

104108
member _.Disabled = disableSuggestions

0 commit comments

Comments
 (0)