@@ -163,7 +163,8 @@ type TypeCheckInfo
163
163
loadClosure : LoadClosure option,
164
164
reactorOps : IReactorOperations,
165
165
checkAlive : ( unit -> bool),
166
- textSnapshotInfo: obj option) =
166
+ textSnapshotInfo: obj option,
167
+ implementationFiles: TypedImplFile list) =
167
168
168
169
let textSnapshotInfo = defaultArg textSnapshotInfo null
169
170
let (| CNR |) ( cnr : CapturedNameResolution ) =
@@ -1356,6 +1357,8 @@ type TypeCheckInfo
1356
1357
/// The assembly being analyzed
1357
1358
member __.ThisCcu = thisCcu
1358
1359
1360
+ member __.ImplementationFiles = implementationFiles
1361
+
1359
1362
override __.ToString () = " TypeCheckInfo(" + mainInputFileName + " )"
1360
1363
1361
1364
@@ -1662,7 +1665,7 @@ module internal Parser =
1662
1665
let errors = errHandler.CollectedDiagnostics
1663
1666
1664
1667
match tcEnvAtEndOpt with
1665
- | Some ( tcEnvAtEnd, _ typedImplFiles , tcState) ->
1668
+ | Some ( tcEnvAtEnd, typedImplFiles , tcState) ->
1666
1669
let scope =
1667
1670
TypeCheckInfo( tcConfig, tcGlobals,
1668
1671
tcState.PartialAssemblySignature,
@@ -1678,7 +1681,8 @@ module internal Parser =
1678
1681
loadClosure,
1679
1682
reactorOps,
1680
1683
checkAlive,
1681
- textSnapshotInfo)
1684
+ textSnapshotInfo,
1685
+ typedImplFiles)
1682
1686
return errors, TypeCheckAborted.No scope
1683
1687
| None ->
1684
1688
return errors, TypeCheckAborted.Yes
@@ -1761,7 +1765,7 @@ type FSharpCheckProjectResults(projectFileName:string, keepAssemblyContents, err
1761
1765
FSharpAssemblySignature( tcGlobals, thisCcu, tcImports, topAttribs, ccuSig)
1762
1766
1763
1767
member info.AssemblyContents =
1764
- if not keepAssemblyContents then invalidOp " The 'keepAssemblyContents' flag must be set to tru on the FSharpChecker in order to access the checked contents of assemblies"
1768
+ if not keepAssemblyContents then invalidOp " The 'keepAssemblyContents' flag must be set to true on the FSharpChecker in order to access the checked contents of assemblies"
1765
1769
let ( tcGlobals , tcImports , thisCcu , _ccuSig , _tcSymbolUses , _topAttribs , _tcAssemblyData , _ilAssemRef , _ad , tcAssemblyExpr , _dependencyFiles ) = getDetails()
1766
1770
let mimpls =
1767
1771
match tcAssemblyExpr with
@@ -1817,7 +1821,7 @@ type FSharpCheckProjectResults(projectFileName:string, keepAssemblyContents, err
1817
1821
//
1818
1822
// There is an important property of all the objects returned by the methods of this type: they do not require
1819
1823
// the corresponding background builder to be alive. That is, they are simply plain-old-data through pre-formatting of all result text.
1820
- type FSharpCheckFileResults ( filename : string , errors : FSharpErrorInfo [], scopeOptX : TypeCheckInfo option , dependencyFiles : string list , builderX : IncrementalBuilder option , reactorOpsX : IReactorOperations ) =
1824
+ type FSharpCheckFileResults ( filename : string , errors : FSharpErrorInfo [], scopeOptX : TypeCheckInfo option , dependencyFiles : string list , builderX : IncrementalBuilder option , reactorOpsX : IReactorOperations , keepAssemblyContents : bool ) =
1821
1825
1822
1826
// This may be None initially, or may be set to None when the object is disposed or finalized
1823
1827
let mutable details = match scopeOptX with None -> None | Some scopeX -> Some ( scopeX, builderX, reactorOpsX)
@@ -2002,6 +2006,12 @@ type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOp
2002
2006
RequireCompilationThread ctok
2003
2007
scope.IsRelativeNameResolvable( pos, plid, item))
2004
2008
2009
+ member info.ImplementationFiles =
2010
+ if not keepAssemblyContents then invalidOp " The 'keepAssemblyContents' flag must be set to true on the FSharpChecker in order to access the checked contents of assemblies"
2011
+ scopeOptX
2012
+ |> Option.map ( fun scope ->
2013
+ let cenv = Impl.cenv( scope.TcGlobals, scope.ThisCcu, scope.TcImports)
2014
+ [ for mimpl in scope.ImplementationFiles -> FSharpImplementationFileContents( cenv, mimpl)])
2005
2015
2006
2016
override info.ToString () = " FSharpCheckFileResults(" + filename + " )"
2007
2017
@@ -2326,7 +2336,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
2326
2336
static let mutable foregroundTypeCheckCount = 0
2327
2337
2328
2338
let MakeCheckFileResultsEmpty ( filename , creationErrors ) =
2329
- FSharpCheckFileResults ( filename, Array.ofList creationErrors, None, [], None, reactorOps)
2339
+ FSharpCheckFileResults ( filename, Array.ofList creationErrors, None, [], None, reactorOps, keepAssemblyContents )
2330
2340
2331
2341
let MakeCheckFileResults ( filename , options : FSharpProjectOptions , builder , scope , dependencyFiles , creationErrors , parseErrors , tcErrors ) =
2332
2342
let errors =
@@ -2337,7 +2347,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
2337
2347
else
2338
2348
yield ! tcErrors |]
2339
2349
2340
- FSharpCheckFileResults ( filename, errors, Some scope, dependencyFiles, Some builder, reactorOps)
2350
+ FSharpCheckFileResults ( filename, errors, Some scope, dependencyFiles, Some builder, reactorOps, keepAssemblyContents )
2341
2351
2342
2352
let MakeCheckFileAnswer ( filename , tcFileResult , options : FSharpProjectOptions , builder , dependencyFiles , creationErrors , parseErrors , tcErrors ) =
2343
2353
match tcFileResult with
@@ -2624,7 +2634,8 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
2624
2634
List.last tcProj.TcResolutions,
2625
2635
List.last tcProj.TcSymbolUses,
2626
2636
tcProj.TcEnvAtEnd.NameEnv,
2627
- loadClosure, reactorOps, ( fun () -> builder.IsAlive), None)
2637
+ loadClosure, reactorOps, ( fun () -> builder.IsAlive), None,
2638
+ tcProj.ImplementationFiles)
2628
2639
let typedResults = MakeCheckFileResults( filename, options, builder, scope, tcProj.TcDependencyFiles, creationErrors, parseResults.Errors, tcErrors)
2629
2640
return ( parseResults, typedResults)
2630
2641
})
@@ -3144,7 +3155,7 @@ type FsiInteractiveChecker(legacyReferenceResolver, reactorOps: IReactorOperatio
3144
3155
match tcFileResult with
3145
3156
| Parser.TypeCheckAborted.No scope ->
3146
3157
let errors = [| yield ! parseErrors; yield ! tcErrors |]
3147
- let typeCheckResults = FSharpCheckFileResults ( filename, errors, Some scope, dependencyFiles, None, reactorOps)
3158
+ let typeCheckResults = FSharpCheckFileResults ( filename, errors, Some scope, dependencyFiles, None, reactorOps, false )
3148
3159
let projectResults = FSharpCheckProjectResults ( filename, keepAssemblyContents, errors, Some( tcGlobals, tcImports, scope.ThisCcu, scope.CcuSig, [ scope.ScopeSymbolUses], None, None, mkSimpleAssRef " stdin" , tcState.TcEnvFromImpls.AccessRights, None, dependencyFiles), reactorOps)
3149
3160
parseResults, typeCheckResults, projectResults
3150
3161
| _ ->
0 commit comments