Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 1311 - Intellisense stops working in .fsx script #1316

Merged
merged 6 commits into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1612,28 +1612,38 @@ let GetFsiLibraryName () = "FSharp.Compiler.Interactive.Settings"
// -- for orphaned files (files in VS without a project context)
// -- for files given on a command line without --noframework set
let DefaultBasicReferencesForOutOfProjectSources =
[ yield "System"
[ // These are .NET-Framework -style references
#if !TODO_REWORK_ASSEMBLY_LOAD
yield "System"
yield "System.Xml"
yield "System.Runtime.Remoting"
yield "System.Runtime.Serialization.Formatters.Soap"
yield "System.Data"
yield "System.Drawing"

// Don't reference System.Core for .NET 2.0 compilations.
//
// We only use a default reference to System.Core if one exists which we can load it into the compiler process.
// Note: this is not a partiuclarly good technique as it relying on the environment the compiler is executing in
// to determine the default references. However, System.Core will only fail to load on machines with only .NET 2.0,
// in which case the compiler will also be running as a .NET 2.0 process.
//
// NOTE: it seems this can now be removed now that .NET 4.x is minimally assumed when using this toolchain
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
yield "System.Core"
yield "System.Core"
#endif

yield "System.Runtime"
// These are the Portable-profile and .NET Standard 1.6 dependencies of FSharp.Core.dll. These are needed
// when an F# sript references an F# profile 7, 78, 259 or .NET Standard 1.6 component which in turn refers
// to FSharp.Core for profile 7, 78, 259 or .NET Standard.
yield "System.Runtime" // lots of types
yield "System.Linq" // System.Linq.Expressions.Expression<T>
yield "System.Reflection" // System.Reflection.ParameterInfo
yield "System.Linq.Expressions" // System.Linq.IQueryable<T>
yield "System.Threading.Tasks" // valuetype [System.Threading.Tasks]System.Threading.CancellationToken
yield "System.IO" // System.IO.TextWriter
//yield "System.Console" // System.Console.Out etc.
yield "System.Net.Requests" // System.Net.WebResponse etc.
yield "System.Collections" // System.Collections.Generic.List<T>
yield "System.Runtime.Numerics" // BigInteger
yield "System.Threading" // OperationCanceledException

#if !TODO_REWORK_ASSEMBLY_LOAD
yield "System.Web"
yield "System.Web.Services"
yield "System.Windows.Forms" ]
yield "System.Windows.Forms"
#endif
]

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

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

let tcEnv =
if tcConfig.checkOverflow then
TcOpenDecl TcResultsSink.NoSink tcGlobals amap initm initm tcEnv (pathToSynLid initm (splitNamespace FSharpLib.CoreOperatorsCheckedName))
else
tcEnv
tcEnv
if tcConfig.checkOverflow then
try TcOpenDecl TcResultsSink.NoSink tcGlobals amap initm initm tcEnv (pathToSynLid initm (splitNamespace FSharpLib.CoreOperatorsCheckedName))
with e -> errorRecovery e initm; tcEnv
else
tcEnv

//----------------------------------------------------------------------------
// Fault injection
Expand Down
47 changes: 28 additions & 19 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -409,28 +409,37 @@ let private GetCSharpStyleIndexedExtensionMembersForTyconRef (amap:Import.Import
// We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension
// methods for tuple occur in C# code)
let thisTyconRef =
match metadataOfTycon tcrefOfStaticClass.Deref, minfo with
| ILTypeMetadata (scoref,_), ILMeth(_,ILMethInfo(_,_,_,ilMethod,_),_) ->
match ilMethod.ParameterTypes with
| firstTy :: _ ->
match firstTy with
| ILType.Boxed tspec | ILType.Value tspec ->
let tcref = (tspec |> rescopeILTypeSpec scoref).TypeRef |> Import.ImportILTypeRef amap m
if isCompiledTupleTyconRef g tcref || tyconRefEq g tcref g.fastFunc_tcr then None
else Some tcref
try
let rs =
match metadataOfTycon tcrefOfStaticClass.Deref, minfo with
| ILTypeMetadata (scoref,_), ILMeth(_,ILMethInfo(_,_,_,ilMethod,_),_) ->
match ilMethod.ParameterTypes with
| firstTy :: _ ->
match firstTy with
| ILType.Boxed tspec | ILType.Value tspec ->
let tcref = (tspec |> rescopeILTypeSpec scoref).TypeRef |> Import.ImportILTypeRef amap m
if isCompiledTupleTyconRef g tcref || tyconRefEq g tcref g.fastFunc_tcr then None
else Some tcref
| _ -> None
| _ -> None
| _ -> None
| _ ->
// The results are indexed by the TyconRef of the first 'this' argument, if any.
// So we need to go and crack the type of the 'this' argument.
let thisTy = minfo.GetParamTypes(amap,m,generalizeTypars minfo.FormalMethodTypars).Head.Head
match thisTy with
| AppTy amap.g (tcrefOfTypeExtended, _) -> Some tcrefOfTypeExtended
| _ -> None
| _ ->
// The results are indexed by the TyconRef of the first 'this' argument, if any.
// So we need to go and crack the type of the 'this' argument.
let thisTy = minfo.GetParamTypes(amap,m,generalizeTypars minfo.FormalMethodTypars).Head.Head
match thisTy with
| AppTy amap.g (tcrefOfTypeExtended, _) -> Some tcrefOfTypeExtended
| _ -> None

Some rs

with e -> // Import of the ILType may fail, if so report the error and skip on
errorRecovery e m
None

match thisTyconRef with
| Some tcref -> yield Choice1Of2(tcref, ilExtMem)
| _ -> yield Choice2Of2 ilExtMem ]
| None -> ()
| Some (Some tcref) -> yield Choice1Of2(tcref, ilExtMem)
| Some None -> yield Choice2Of2 ilExtMem ]
else
[]

Expand Down
7 changes: 6 additions & 1 deletion src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16513,7 +16513,12 @@ let AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible)
env

let CreateInitialTcEnv(g,amap,scopem,assemblyName,ccus) =
List.fold (fun env (ccu,autoOpens,internalsVisible) -> AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible)) (emptyTcEnv g) ccus
(emptyTcEnv g, ccus) ||> List.fold (fun env (ccu,autoOpens,internalsVisible) ->
try
AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible)
with e ->
errorRecovery e scopem
env)

type ConditionalDefines =
string list
Expand Down
16 changes: 14 additions & 2 deletions src/fsharp/vs/IncrementalBuild.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,27 @@ type internal CompilationErrorLogger =

/// Represents the state in the incremental graph assocaited with checking a file
type internal PartialCheckResults =
{ TcState : TcState
{ /// This field is None if a major unrecoverd error occured when preparing the initial state
TcState : TcState
TcImports: TcImports
TcGlobals: TcGlobals
TcConfig: TcConfig
TcEnvAtEnd : TypeChecker.TcEnv

/// This field is None if a major unrecoverd error occured when preparing the initial state
TcEnvAtEnd : TypeChecker.TcEnv

/// Represents the collected errors from type checking
Errors : (PhasedError * FSharpErrorSeverity) list

/// Represents the collected name resolutions from type checking
TcResolutions: TcResolutions list

/// Represents the collected uses of symbols from type checking
TcSymbolUses: TcSymbolUses list

/// Represents the collected attributes to apply to the module of assuembly generates
TopAttribs: TypeChecker.TopAttribs option

TimeStamp: DateTime }

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