Skip to content

Commit d6b5b1b

Browse files
KevinRansombaronfel
authored andcommitted
Re-enable magic-resolver in fsi for coreclr (#7598)
1 parent b7c486c commit d6b5b1b

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/fsharp/fsi/fsi.fs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,22 +1498,14 @@ module internal MagicAssemblyResolution =
14981498

14991499
let Install(tcConfigB, tcImports: TcImports, fsiDynamicCompiler: FsiDynamicCompiler, fsiConsoleOutput: FsiConsoleOutput) =
15001500

1501-
#if NETSTANDARD
1502-
ignore tcConfigB
1503-
ignore tcImports
1504-
ignore fsiDynamicCompiler
1505-
ignore fsiConsoleOutput
1506-
{ new System.IDisposable with
1507-
member x.Dispose() = () }
1508-
#else
15091501
let ResolveAssembly (ctok, m, tcConfigB, tcImports: TcImports, fsiDynamicCompiler: FsiDynamicCompiler, fsiConsoleOutput: FsiConsoleOutput, fullAssemName:string) =
15101502

15111503
try
15121504
// Grab the name of the assembly
15131505
let tcConfig = TcConfig.Create(tcConfigB,validate=false)
1514-
let simpleAssemName = fullAssemName.Split([| ',' |]).[0]
1506+
let simpleAssemName = fullAssemName.Split([| ',' |]).[0]
15151507
if !progress then fsiConsoleOutput.uprintfn "ATTEMPT MAGIC LOAD ON ASSEMBLY, simpleAssemName = %s" simpleAssemName // "Attempting to load a dynamically required assembly in response to an AssemblyResolve event by using known static assembly references..."
1516-
1508+
15171509
// Special case: Mono Windows Forms attempts to load an assembly called something like "Windows.Forms.resources"
15181510
// We can't resolve this, so don't try.
15191511
// REVIEW: Suggest 4481, delete this special case.
@@ -1529,7 +1521,7 @@ module internal MagicAssemblyResolution =
15291521
// Otherwise continue
15301522
let assemblyReferenceTextDll = (simpleAssemName + ".dll")
15311523
let assemblyReferenceTextExe = (simpleAssemName + ".exe")
1532-
let overallSearchResult =
1524+
let overallSearchResult =
15331525

15341526
// OK, try to resolve as an existing DLL in the resolved reference set. This does unification by assembly name
15351527
// once an assembly has been referenced.
@@ -1573,15 +1565,15 @@ module internal MagicAssemblyResolution =
15731565
| Some(assembly) -> OkResult([],Choice2Of2 assembly)
15741566
| None ->
15751567
#endif
1576-
1568+
15771569
// As a last resort, try to find the reference without an extension
15781570
match tcImports.TryFindExistingFullyQualifiedPathByExactAssemblyRef(ctok, ILAssemblyRef.Create(simpleAssemName,None,None,false,None,None)) with
15791571
| Some(resolvedPath) ->
15801572
OkResult([],Choice1Of2 resolvedPath)
15811573
| None ->
1582-
1574+
15831575
ErrorResult([],Failure (FSIstrings.SR.fsiFailedToResolveAssembly(simpleAssemName)))
1584-
1576+
15851577
match overallSearchResult with
15861578
| ErrorResult _ -> null
15871579
| OkResult _ ->
@@ -1592,8 +1584,8 @@ module internal MagicAssemblyResolution =
15921584
assemblyLoadFrom assemblyName
15931585
| Choice2Of2 assembly ->
15941586
assembly
1595-
1596-
with e ->
1587+
1588+
with e ->
15971589
stopProcessingRecovery e range0
15981590
null
15991591

@@ -1604,12 +1596,11 @@ module internal MagicAssemblyResolution =
16041596
// during compilation. So we recover the CompilationThreadToken here.
16051597
let ctok = AssumeCompilationThreadWithoutEvidence ()
16061598
ResolveAssembly (ctok, rangeStdin, tcConfigB, tcImports, fsiDynamicCompiler, fsiConsoleOutput, args.Name))
1607-
1599+
16081600
AppDomain.CurrentDomain.add_AssemblyResolve(handler)
16091601

16101602
{ new System.IDisposable with
16111603
member x.Dispose() = AppDomain.CurrentDomain.remove_AssemblyResolve(handler) }
1612-
#endif
16131604

16141605
//----------------------------------------------------------------------------
16151606
// Reading stdin

0 commit comments

Comments
 (0)