Skip to content

Commit 306e3c5

Browse files
authored
FileSystem access should go via IFileSystem (+refactoring) (#11112)
1 parent cbfd0f6 commit 306e3c5

Some content is hidden

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

74 files changed

+15181
-14855
lines changed

src/fsharp/BinaryResourceFormats.fs

+140-140
Large diffs are not rendered by default.

src/fsharp/CheckExpressions.fs

+3,399-3,400
Large diffs are not rendered by default.

src/fsharp/CompilerConfig.fs

+142-143
Large diffs are not rendered by default.

src/fsharp/CompilerConfig.fsi

+54-53
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
module internal FSharp.Compiler.CompilerConfig
55

66
open System
7+
open FSharp.Compiler.IO
78
open Internal.Utilities
89
open Internal.Utilities.Library
910
open FSharp.Compiler
@@ -24,7 +25,7 @@ exception LoadedSourceNotFoundIgnoring of (*filename*) string * range
2425

2526
/// Represents a reference to an F# assembly. May be backed by a real assembly on disk (read by Abstract IL), or a cross-project
2627
/// reference in FSharp.Compiler.Service.
27-
type IRawFSharpAssemblyData =
28+
type IRawFSharpAssemblyData =
2829

2930
/// The raw list AutoOpenAttribute attributes in the assembly
3031
abstract GetAutoOpenAttributes: ILGlobals -> string list
@@ -56,55 +57,55 @@ type IRawFSharpAssemblyData =
5657

5758
abstract ShortAssemblyName: string
5859

59-
type TimeStampCache =
60+
type TimeStampCache =
6061
new: defaultTimeStamp: DateTime -> TimeStampCache
6162
member GetFileTimeStamp: string -> DateTime
6263
member GetProjectReferenceTimeStamp: IProjectReference -> DateTime
6364

64-
and IProjectReference =
65+
and IProjectReference =
6566

6667
/// The name of the assembly file generated by the project
67-
abstract FileName: string
68+
abstract FileName: string
6869

6970
/// Evaluate raw contents of the assembly file generated by the project
7071
abstract EvaluateRawContents: CompilationThreadToken -> Cancellable<IRawFSharpAssemblyData option>
7172

7273
/// Get the logical timestamp that would be the timestamp of the assembly file generated by the project.
7374
///
7475
/// For project references this is maximum of the timestamps of all dependent files.
75-
/// The project is not actually built, nor are any assemblies read, but the timestamps for each dependent file
76+
/// The project is not actually built, nor are any assemblies read, but the timestamps for each dependent file
7677
/// are read via the FileSystem. If the files don't exist, then a default timestamp is used.
7778
///
7879
/// The operation returns None only if it is not possible to create an IncrementalBuilder for the project at all, e.g. if there
7980
/// are fatal errors in the options for the project.
8081
abstract TryGetLogicalTimeStamp: TimeStampCache -> System.DateTime option
8182

82-
type AssemblyReference =
83+
type AssemblyReference =
8384
| AssemblyReference of range * string * IProjectReference option
84-
85+
8586
member Range: range
86-
87+
8788
member Text: string
88-
89+
8990
member ProjectReference: IProjectReference option
9091

9192
member SimpleAssemblyNameIs: string -> bool
9293

9394
type UnresolvedAssemblyReference = UnresolvedAssemblyReference of string * AssemblyReference list
9495

9596
[<RequireQualifiedAccess>]
96-
type CompilerTarget =
97-
| WinExe
98-
| ConsoleExe
99-
| Dll
97+
type CompilerTarget =
98+
| WinExe
99+
| ConsoleExe
100+
| Dll
100101
| Module
101102
member IsExe: bool
102-
103+
103104
[<RequireQualifiedAccess>]
104105
type CopyFSharpCoreFlag = Yes | No
105106

106107
/// Represents the file or string used for the --version flag
107-
type VersionFlag =
108+
type VersionFlag =
108109
| VersionString of string
109110
| VersionFile of string
110111
| VersionNone
@@ -188,15 +189,15 @@ type TcConfigBuilder =
188189
mutable printAllSignatureFiles: bool
189190
mutable xmlDocOutputFile: string option
190191
mutable stats: bool
191-
mutable generateFilterBlocks: bool
192+
mutable generateFilterBlocks: bool
192193
mutable signer: string option
193194
mutable container: string option
194195
mutable delaysign: bool
195196
mutable publicsign: bool
196-
mutable version: VersionFlag
197+
mutable version: VersionFlag
197198
mutable metadataVersion: string option
198199
mutable standalone: bool
199-
mutable extraStaticLinkRoots: string list
200+
mutable extraStaticLinkRoots: string list
200201
mutable noSignatureData: bool
201202
mutable onlyEssentialOptimizationData: bool
202203
mutable useOptimizationDataFile: bool
@@ -209,8 +210,8 @@ type TcConfigBuilder =
209210
mutable ignoreSymbolStoreSequencePoints: bool
210211
mutable internConstantStrings: bool
211212
mutable extraOptimizationIterations: int
212-
mutable win32icon: string
213-
mutable win32res: string
213+
mutable win32icon: string
214+
mutable win32res: string
214215
mutable win32manifest: string
215216
mutable includewin32manifest: bool
216217
mutable linkResources: string list
@@ -226,13 +227,13 @@ type TcConfigBuilder =
226227
#if DEBUG
227228
mutable showOptimizationData: bool
228229
#endif
229-
mutable showTerms : bool
230-
mutable writeTermsToFiles: bool
231-
mutable doDetuple : bool
232-
mutable doTLR : bool
230+
mutable showTerms : bool
231+
mutable writeTermsToFiles: bool
232+
mutable doDetuple : bool
233+
mutable doTLR : bool
233234
mutable doFinalSimplify: bool
234-
mutable optsOn : bool
235-
mutable optSettings : Optimizer.OptimizationSettings
235+
mutable optsOn : bool
236+
mutable optSettings : Optimizer.OptimizationSettings
236237
mutable emitTailcalls: bool
237238
mutable deterministic: bool
238239
mutable concurrentBuild: bool
@@ -246,15 +247,15 @@ type TcConfigBuilder =
246247
#if !NO_EXTENSIONTYPING
247248
mutable showExtensionTypeMessages: bool
248249
#endif
249-
mutable pause: bool
250+
mutable pause: bool
250251
mutable alwaysCallVirt: bool
251252
mutable noDebugData: bool
252253

253254
/// If true, indicates all type checking and code generation is in the context of fsi.exe
254-
isInteractive: bool
255-
isInvalidationSupported: bool
255+
isInteractive: bool
256+
isInvalidationSupported: bool
256257
mutable emitDebugInfoInQuotations: bool
257-
mutable exename: string option
258+
mutable exename: string option
258259
mutable copyFSharpCore: CopyFSharpCoreFlag
259260
mutable shadowCopyReferences: bool
260261
mutable useSdkRefs: bool
@@ -281,18 +282,18 @@ type TcConfigBuilder =
281282

282283
static member CreateNew:
283284
legacyReferenceResolver: LegacyReferenceResolver *
284-
defaultFSharpBinariesDir: string *
285-
reduceMemoryUsage: ReduceMemoryFlag *
286-
implicitIncludeDir: string *
287-
isInteractive: bool *
285+
defaultFSharpBinariesDir: string *
286+
reduceMemoryUsage: ReduceMemoryFlag *
287+
implicitIncludeDir: string *
288+
isInteractive: bool *
288289
isInvalidationSupported: bool *
289290
defaultCopyFSharpCore: CopyFSharpCoreFlag *
290291
tryGetMetadataSnapshot: ILReaderTryGetMetadataSnapshot *
291292
sdkDirOverride: string option *
292293
rangeForErrors: range
293294
-> TcConfigBuilder
294295

295-
member DecideNames: string list -> outfile: string * pdbfile: string option * assemblyName: string
296+
member DecideNames: string list -> outfile: string * pdbfile: string option * assemblyName: string
296297

297298
member TurnWarningOff: range * string -> unit
298299

@@ -380,15 +381,15 @@ type TcConfig =
380381
member printAllSignatureFiles: bool
381382
member xmlDocOutputFile: string option
382383
member stats: bool
383-
member generateFilterBlocks: bool
384+
member generateFilterBlocks: bool
384385
member signer: string option
385386
member container: string option
386387
member delaysign: bool
387388
member publicsign: bool
388-
member version: VersionFlag
389+
member version: VersionFlag
389390
member metadataVersion: string option
390391
member standalone: bool
391-
member extraStaticLinkRoots: string list
392+
member extraStaticLinkRoots: string list
392393
member noSignatureData: bool
393394
member onlyEssentialOptimizationData: bool
394395
member useOptimizationDataFile: bool
@@ -402,7 +403,7 @@ type TcConfig =
402403
member internConstantStrings: bool
403404
member extraOptimizationIterations: int
404405
member win32icon: string
405-
member win32res: string
406+
member win32res: string
406407
member win32manifest: string
407408
member includewin32manifest: bool
408409
member linkResources: string list
@@ -417,18 +418,18 @@ type TcConfig =
417418
#if DEBUG
418419
member showOptimizationData: bool
419420
#endif
420-
member showTerms : bool
421-
member writeTermsToFiles: bool
422-
member doDetuple : bool
423-
member doTLR : bool
421+
member showTerms : bool
422+
member writeTermsToFiles: bool
423+
member doDetuple : bool
424+
member doTLR : bool
424425
member doFinalSimplify: bool
425-
member optSettings : Optimizer.OptimizationSettings
426+
member optSettings : Optimizer.OptimizationSettings
426427
member emitTailcalls: bool
427428
member deterministic: bool
428429
member concurrentBuild: bool
429430
member pathMap: PathMap
430431
member preferredUiLang: string option
431-
member optsOn : bool
432+
member optsOn : bool
432433
member productNameForBannerText: string
433434
member showBanner : bool
434435
member showTimes: bool
@@ -437,13 +438,13 @@ type TcConfig =
437438
#if !NO_EXTENSIONTYPING
438439
member showExtensionTypeMessages: bool
439440
#endif
440-
member pause: bool
441+
member pause: bool
441442
member alwaysCallVirt: bool
442443
member noDebugData: bool
443444

444445
/// If true, indicates all type checking and code generation is in the context of fsi.exe
445446
member isInteractive: bool
446-
member isInvalidationSupported: bool
447+
member isInvalidationSupported: bool
447448

448449
member xmlDocInfoLoader: IXmlDocumentationInfoLoader option
449450

@@ -452,11 +453,11 @@ type TcConfig =
452453
member ComputeLightSyntaxInitialStatus: string -> bool
453454

454455
member GetTargetFrameworkDirectories: unit -> string list
455-
456+
456457
/// Get the loaded sources that exist and issue a warning for the ones that don't
457458
member GetAvailableLoadedSources: unit -> (range*string) list
458-
459-
member ComputeCanContainEntryPoint: sourceFiles:string list -> bool list *bool
459+
460+
member ComputeCanContainEntryPoint: sourceFiles:string list -> bool list *bool
460461

461462
/// File system query based on TcConfig settings
462463
member ResolveSourceFile: range * filename: string * pathLoadedFrom: string -> string
@@ -510,7 +511,7 @@ type TcConfig =
510511
member CloneToBuilder: unit -> TcConfigBuilder
511512

512513
/// Indicates if the compilation will result in F# signature data resource in the generated binary
513-
member GenerateSignatureData: bool
514+
member GenerateSignatureData: bool
514515

515516
/// Indicates if the compilation will result in an F# optimization data resource in the generated binary
516517
member GenerateOptimizationData: bool
@@ -521,7 +522,7 @@ type TcConfig =
521522
/// Represents a computation to return a TcConfig. Normally this is just a constant immutable TcConfig,
522523
/// but for F# Interactive it may be based on an underlying mutable TcConfigBuilder.
523524
[<Sealed>]
524-
type TcConfigProvider =
525+
type TcConfigProvider =
525526

526527
member Get: CompilationThreadToken -> TcConfig
527528

@@ -555,4 +556,4 @@ val FSharpLightSyntaxFileSuffixes: string list
555556

556557
val doNotRequireNamespaceOrModuleSuffixes: string list
557558

558-
val mlCompatSuffixes: string list
559+
val mlCompatSuffixes: string list

0 commit comments

Comments
 (0)