Skip to content

Commit c2bf93e

Browse files
authored
Merge pull request #1316 from dsyme/fix-1311-2
Fix 1311 - Intellisense stops working in .fsx script
2 parents c9167c1 + 74474a1 commit c2bf93e

File tree

4 files changed

+77
-42
lines changed

4 files changed

+77
-42
lines changed

src/fsharp/CompileOps.fs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,28 +1612,38 @@ let GetFsiLibraryName () = "FSharp.Compiler.Interactive.Settings"
16121612
// -- for orphaned files (files in VS without a project context)
16131613
// -- for files given on a command line without --noframework set
16141614
let DefaultBasicReferencesForOutOfProjectSources =
1615-
[ yield "System"
1615+
[ // These are .NET-Framework -style references
1616+
#if !TODO_REWORK_ASSEMBLY_LOAD
1617+
yield "System"
16161618
yield "System.Xml"
16171619
yield "System.Runtime.Remoting"
16181620
yield "System.Runtime.Serialization.Formatters.Soap"
16191621
yield "System.Data"
16201622
yield "System.Drawing"
1621-
1622-
// Don't reference System.Core for .NET 2.0 compilations.
1623-
//
1624-
// We only use a default reference to System.Core if one exists which we can load it into the compiler process.
1625-
// Note: this is not a partiuclarly good technique as it relying on the environment the compiler is executing in
1626-
// to determine the default references. However, System.Core will only fail to load on machines with only .NET 2.0,
1627-
// in which case the compiler will also be running as a .NET 2.0 process.
1628-
//
1629-
// NOTE: it seems this can now be removed now that .NET 4.x is minimally assumed when using this toolchain
1630-
if (try System.Reflection.Assembly.Load(new System.Reflection.AssemblyName("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")) |> ignore; true with _ -> false) then
1631-
yield "System.Core"
1623+
yield "System.Core"
1624+
#endif
16321625

1633-
yield "System.Runtime"
1626+
// These are the Portable-profile and .NET Standard 1.6 dependencies of FSharp.Core.dll. These are needed
1627+
// when an F# sript references an F# profile 7, 78, 259 or .NET Standard 1.6 component which in turn refers
1628+
// to FSharp.Core for profile 7, 78, 259 or .NET Standard.
1629+
yield "System.Runtime" // lots of types
1630+
yield "System.Linq" // System.Linq.Expressions.Expression<T>
1631+
yield "System.Reflection" // System.Reflection.ParameterInfo
1632+
yield "System.Linq.Expressions" // System.Linq.IQueryable<T>
1633+
yield "System.Threading.Tasks" // valuetype [System.Threading.Tasks]System.Threading.CancellationToken
1634+
yield "System.IO" // System.IO.TextWriter
1635+
//yield "System.Console" // System.Console.Out etc.
1636+
yield "System.Net.Requests" // System.Net.WebResponse etc.
1637+
yield "System.Collections" // System.Collections.Generic.List<T>
1638+
yield "System.Runtime.Numerics" // BigInteger
1639+
yield "System.Threading" // OperationCanceledException
1640+
1641+
#if !TODO_REWORK_ASSEMBLY_LOAD
16341642
yield "System.Web"
16351643
yield "System.Web.Services"
1636-
yield "System.Windows.Forms" ]
1644+
yield "System.Windows.Forms"
1645+
#endif
1646+
]
16371647

16381648
// Extra implicit references for .NET 4.0
16391649
let DefaultBasicReferencesForOutOfProjectSources40 =
@@ -5077,12 +5087,11 @@ let GetInitialTcEnv (thisAssemblyName:string, initm:range, tcConfig:TcConfig, tc
50775087

50785088
let tcEnv = CreateInitialTcEnv(tcGlobals, amap, initm, thisAssemblyName, ccus)
50795089

5080-
let tcEnv =
5081-
if tcConfig.checkOverflow then
5082-
TcOpenDecl TcResultsSink.NoSink tcGlobals amap initm initm tcEnv (pathToSynLid initm (splitNamespace FSharpLib.CoreOperatorsCheckedName))
5083-
else
5084-
tcEnv
5085-
tcEnv
5090+
if tcConfig.checkOverflow then
5091+
try TcOpenDecl TcResultsSink.NoSink tcGlobals amap initm initm tcEnv (pathToSynLid initm (splitNamespace FSharpLib.CoreOperatorsCheckedName))
5092+
with e -> errorRecovery e initm; tcEnv
5093+
else
5094+
tcEnv
50865095

50875096
//----------------------------------------------------------------------------
50885097
// Fault injection

src/fsharp/NameResolution.fs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -409,28 +409,37 @@ let private GetCSharpStyleIndexedExtensionMembersForTyconRef (amap:Import.Import
409409
// We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension
410410
// methods for tuple occur in C# code)
411411
let thisTyconRef =
412-
match metadataOfTycon tcrefOfStaticClass.Deref, minfo with
413-
| ILTypeMetadata (scoref,_), ILMeth(_,ILMethInfo(_,_,_,ilMethod,_),_) ->
414-
match ilMethod.ParameterTypes with
415-
| firstTy :: _ ->
416-
match firstTy with
417-
| ILType.Boxed tspec | ILType.Value tspec ->
418-
let tcref = (tspec |> rescopeILTypeSpec scoref).TypeRef |> Import.ImportILTypeRef amap m
419-
if isCompiledTupleTyconRef g tcref || tyconRefEq g tcref g.fastFunc_tcr then None
420-
else Some tcref
412+
try
413+
let rs =
414+
match metadataOfTycon tcrefOfStaticClass.Deref, minfo with
415+
| ILTypeMetadata (scoref,_), ILMeth(_,ILMethInfo(_,_,_,ilMethod,_),_) ->
416+
match ilMethod.ParameterTypes with
417+
| firstTy :: _ ->
418+
match firstTy with
419+
| ILType.Boxed tspec | ILType.Value tspec ->
420+
let tcref = (tspec |> rescopeILTypeSpec scoref).TypeRef |> Import.ImportILTypeRef amap m
421+
if isCompiledTupleTyconRef g tcref || tyconRefEq g tcref g.fastFunc_tcr then None
422+
else Some tcref
423+
| _ -> None
421424
| _ -> None
422-
| _ -> None
423-
| _ ->
424-
// The results are indexed by the TyconRef of the first 'this' argument, if any.
425-
// So we need to go and crack the type of the 'this' argument.
426-
let thisTy = minfo.GetParamTypes(amap,m,generalizeTypars minfo.FormalMethodTypars).Head.Head
427-
match thisTy with
428-
| AppTy amap.g (tcrefOfTypeExtended, _) -> Some tcrefOfTypeExtended
429-
| _ -> None
425+
| _ ->
426+
// The results are indexed by the TyconRef of the first 'this' argument, if any.
427+
// So we need to go and crack the type of the 'this' argument.
428+
let thisTy = minfo.GetParamTypes(amap,m,generalizeTypars minfo.FormalMethodTypars).Head.Head
429+
match thisTy with
430+
| AppTy amap.g (tcrefOfTypeExtended, _) -> Some tcrefOfTypeExtended
431+
| _ -> None
432+
433+
Some rs
434+
435+
with e -> // Import of the ILType may fail, if so report the error and skip on
436+
errorRecovery e m
437+
None
430438

431439
match thisTyconRef with
432-
| Some tcref -> yield Choice1Of2(tcref, ilExtMem)
433-
| _ -> yield Choice2Of2 ilExtMem ]
440+
| None -> ()
441+
| Some (Some tcref) -> yield Choice1Of2(tcref, ilExtMem)
442+
| Some None -> yield Choice2Of2 ilExtMem ]
434443
else
435444
[]
436445

src/fsharp/TypeChecker.fs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16499,7 +16499,12 @@ let AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible)
1649916499
env
1650016500

1650116501
let CreateInitialTcEnv(g,amap,scopem,assemblyName,ccus) =
16502-
List.fold (fun env (ccu,autoOpens,internalsVisible) -> AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible)) (emptyTcEnv g) ccus
16502+
(emptyTcEnv g, ccus) ||> List.fold (fun env (ccu,autoOpens,internalsVisible) ->
16503+
try
16504+
AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible)
16505+
with e ->
16506+
errorRecovery e scopem
16507+
env)
1650316508

1650416509
type ConditionalDefines =
1650516510
string list

src/fsharp/vs/IncrementalBuild.fsi

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,27 @@ type internal CompilationErrorLogger =
7777

7878
/// Represents the state in the incremental graph assocaited with checking a file
7979
type internal PartialCheckResults =
80-
{ TcState : TcState
80+
{ /// This field is None if a major unrecoverd error occured when preparing the initial state
81+
TcState : TcState
8182
TcImports: TcImports
8283
TcGlobals: TcGlobals
8384
TcConfig: TcConfig
84-
TcEnvAtEnd : TypeChecker.TcEnv
85+
86+
/// This field is None if a major unrecoverd error occured when preparing the initial state
87+
TcEnvAtEnd : TypeChecker.TcEnv
88+
89+
/// Represents the collected errors from type checking
8590
Errors : (PhasedError * FSharpErrorSeverity) list
91+
92+
/// Represents the collected name resolutions from type checking
8693
TcResolutions: TcResolutions list
94+
95+
/// Represents the collected uses of symbols from type checking
8796
TcSymbolUses: TcSymbolUses list
97+
98+
/// Represents the collected attributes to apply to the module of assuembly generates
8899
TopAttribs: TypeChecker.TopAttribs option
100+
89101
TimeStamp: DateTime }
90102

91103
/// Manages an incremental build graph for the build of an F# project

0 commit comments

Comments
 (0)