Skip to content

Commit 3016aea

Browse files
authored
Remove add include event notification (#8416)
1 parent fe29cc4 commit 3016aea

File tree

6 files changed

+4
-60
lines changed

6 files changed

+4
-60
lines changed

src/fsharp/CompileOps.fs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,8 +2170,6 @@ type TcConfigBuilder =
21702170
mutable pathMap: PathMap
21712171

21722172
mutable langVersion: LanguageVersion
2173-
2174-
mutable includePathAdded: string -> unit
21752173
}
21762174

21772175
static member Initial =
@@ -2312,18 +2310,16 @@ type TcConfigBuilder =
23122310
noConditionalErasure = false
23132311
pathMap = PathMap.empty
23142312
langVersion = LanguageVersion("default")
2315-
includePathAdded = ignore
23162313
}
23172314

23182315
static member CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir, reduceMemoryUsage, implicitIncludeDir,
2319-
isInteractive, isInvalidationSupported, defaultCopyFSharpCore, tryGetMetadataSnapshot, ?includePathAdded: string -> unit) =
2316+
isInteractive, isInvalidationSupported, defaultCopyFSharpCore, tryGetMetadataSnapshot) =
23202317

23212318
Debug.Assert(FileSystem.IsPathRootedShim implicitIncludeDir, sprintf "implicitIncludeDir should be absolute: '%s'" implicitIncludeDir)
23222319

23232320
if (String.IsNullOrEmpty defaultFSharpBinariesDir) then
23242321
failwith "Expected a valid defaultFSharpBinariesDir"
23252322

2326-
let includePathAdded = defaultArg includePathAdded ignore
23272323
{ TcConfigBuilder.Initial with
23282324
implicitIncludeDir = implicitIncludeDir
23292325
defaultFSharpBinariesDir = defaultFSharpBinariesDir
@@ -2334,7 +2330,6 @@ type TcConfigBuilder =
23342330
copyFSharpCore = defaultCopyFSharpCore
23352331
tryGetMetadataSnapshot = tryGetMetadataSnapshot
23362332
useFsiAuxLib = isInteractive
2337-
includePathAdded = includePathAdded
23382333
}
23392334

23402335
member tcConfigB.ResolveSourceFile(m, nm, pathLoadedFrom) =
@@ -2410,7 +2405,6 @@ type TcConfigBuilder =
24102405
| None -> false
24112406
if ok && not (List.contains absolutePath tcConfigB.includes) then
24122407
tcConfigB.includes <- tcConfigB.includes ++ absolutePath
2413-
tcConfigB.includePathAdded absolutePath
24142408

24152409
member tcConfigB.AddLoadedSource(m, originalPath, pathLoadedFrom) =
24162410
if FileSystem.IsInvalidPathShim originalPath then

src/fsharp/CompileOps.fsi

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,6 @@ type TcConfigBuilder =
389389
mutable pathMap : PathMap
390390

391391
mutable langVersion : LanguageVersion
392-
393-
mutable includePathAdded : string -> unit
394392
}
395393

396394
static member Initial: TcConfigBuilder
@@ -403,8 +401,7 @@ type TcConfigBuilder =
403401
isInteractive: bool *
404402
isInvalidationSupported: bool *
405403
defaultCopyFSharpCore: CopyFSharpCoreFlag *
406-
tryGetMetadataSnapshot: ILReaderTryGetMetadataSnapshot *
407-
?includePathAdded: (string -> unit)
404+
tryGetMetadataSnapshot: ILReaderTryGetMetadataSnapshot
408405
-> TcConfigBuilder
409406

410407
member DecideNames: string list -> outfile: string * pdbfile: string option * assemblyName: string
@@ -417,7 +414,7 @@ type TcConfigBuilder =
417414
member AddEmbeddedSourceFile: string -> unit
418415
member AddEmbeddedResource: string -> unit
419416
member AddPathMapping: oldPrefix: string * newPrefix: string -> unit
420-
417+
421418
static member SplitCommandLineResourceInfo: string -> string * string * ILResourceAccess
422419

423420
[<Sealed>]

src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ type FSharpScript(?additionalArgs: string[]) =
2121

2222
member __.ValueBound = fsi.ValueBound
2323

24-
[<CLIEvent>]
25-
member __.IncludePathAdded = fsi.IncludePathAdded
26-
2724
[<CLIEvent>]
2825
member __.DependencyAdding = fsi.DependencyAdding
2926

src/fsharp/fsi/fsi.fs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,8 +2540,6 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
25402540
| None -> SimulatedMSBuildReferenceResolver.getResolver()
25412541
| Some rr -> rr
25422542

2543-
let includePathAddedEvent = Control.Event<_>()
2544-
25452543
let tcConfigB =
25462544
TcConfigBuilder.CreateNew(legacyReferenceResolver,
25472545
defaultFSharpBinariesDir=defaultFSharpBinariesDir,
@@ -2550,8 +2548,7 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
25502548
isInteractive=true,
25512549
isInvalidationSupported=false,
25522550
defaultCopyFSharpCore=CopyFSharpCoreFlag.No,
2553-
tryGetMetadataSnapshot=tryGetMetadataSnapshot,
2554-
includePathAdded=includePathAddedEvent.Trigger)
2551+
tryGetMetadataSnapshot=tryGetMetadataSnapshot)
25552552

25562553
let tcConfigP = TcConfigProvider.BasedOnMutableBuilder(tcConfigB)
25572554
do tcConfigB.resolutionEnvironment <- ResolutionEnvironment.CompilationAndEvaluation // See Bug 3608
@@ -2858,10 +2855,6 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
28582855
/// Event fires when a root-level value is bound to an identifier, e.g., via `let x = ...`.
28592856
member __.ValueBound = fsiDynamicCompiler.ValueBound
28602857

2861-
[<CLIEvent>]
2862-
/// Event fires every time a path is added to the include search list, e.g., via `#I`.
2863-
member __.IncludePathAdded = includePathAddedEvent.Publish
2864-
28652858
[<CLIEvent>]
28662859
/// Event fires at the start of adding a dependency via the dependency manager.
28672860
member __.DependencyAdding = fsiDynamicCompiler.DependencyAdding

src/fsharp/fsi/fsi.fsi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,6 @@ type FsiEvaluationSession =
234234
/// A host calls this to report an unhandled exception in a standard way, e.g. an exception on the GUI thread gets printed to stderr
235235
member ReportUnhandledException : exn: exn -> unit
236236

237-
[<CLIEvent>]
238-
/// Event fires every time a path is added to the include search list, e.g., via `#I`.
239-
member IncludePathAdded: IEvent<string>
240-
241237
[<CLIEvent>]
242238
/// Event fires at the start of adding a dependency via the dependency manager.
243239
member DependencyAdding: IEvent<string * string>

tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,6 @@ stacktype.Name = "Stack"
8181
let _result, errors = script.Eval(sprintf "#r \"%s\"" testAssembly)
8282
Assert.AreEqual(1, errors.Length)
8383

84-
[<Test>]
85-
member __.``Add include path event successful``() =
86-
use script = new FSharpScript()
87-
let includePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
88-
let mutable includePathEventCount = 0
89-
let mutable foundIncludePath = false
90-
Event.add (fun (inc: string) ->
91-
includePathEventCount <- includePathEventCount + 1
92-
foundIncludePath <- foundIncludePath || String.Compare(includePath, inc, StringComparison.OrdinalIgnoreCase) = 0)
93-
script.IncludePathAdded
94-
script.Eval(sprintf "#I @\"%s\"" includePath) |> ignoreValue
95-
Assert.AreEqual(1, includePathEventCount)
96-
Assert.True(foundIncludePath)
97-
98-
[<Test>]
99-
member __.``Add include path event unsuccessful``() =
100-
use script = new FSharpScript()
101-
let includePath = Path.Combine("a", "path", "that", "can't", "be", "found")
102-
let mutable foundIncludePath = false
103-
Event.add (fun _ -> foundIncludePath <- true) script.IncludePathAdded
104-
let _result, errors = script.Eval(sprintf "#I @\"%s\"" includePath)
105-
Assert.AreEqual(1, errors.Length)
106-
Assert.False(foundIncludePath)
107-
10884
[<Test>]
10985
member _.``Compilation errors report a specific exception``() =
11086
use script = new FSharpScript()
@@ -122,15 +98,6 @@ stacktype.Name = "Stack"
12298
| Ok(_) -> Assert.Fail("expected a failure")
12399
| Error(ex) -> Assert.IsInstanceOf<FileNotFoundException>(ex)
124100

125-
[<Test>]
126-
member __.``Nuget reference fires multiple events``() =
127-
use script = new FSharpScript(additionalArgs=[|"/langversion:preview"|])
128-
let mutable includeAddCount = 0
129-
Event.add (fun _ -> includeAddCount <- includeAddCount + 1) script.IncludePathAdded
130-
script.Eval("#r \"nuget:include=NUnitLite, version=3.11.0\"") |> ignoreValue
131-
script.Eval("0") |> ignoreValue
132-
Assert.GreaterOrEqual(includeAddCount, 1)
133-
134101
/// Native dll resolution is not implemented on desktop
135102
#if NETSTANDARD
136103
[<Test>]

0 commit comments

Comments
 (0)