@@ -2796,7 +2796,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
2796
2796
( sourceFiles |> List.mapi ( fun i _ -> ( i = n-1 )), tcConfig.target.IsExe)
2797
2797
2798
2798
// This call can fail if no CLR is found (this is the path to mscorlib)
2799
- member tcConfig.ClrRoot =
2799
+ member tcConfig.TargetFrameworkDirectories =
2800
2800
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind ( BuildPhase.Parameter)
2801
2801
match tcConfig.clrRoot with
2802
2802
| Some x ->
@@ -2853,15 +2853,15 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
2853
2853
member tcConfig.IsSystemAssembly ( filename : string ) =
2854
2854
try
2855
2855
FileSystem.SafeExists filename &&
2856
- (( tcConfig.ClrRoot |> List.exists ( fun clrRoot -> clrRoot = Path.GetDirectoryName filename)) ||
2856
+ (( tcConfig.TargetFrameworkDirectories |> List.exists ( fun clrRoot -> clrRoot = Path.GetDirectoryName filename)) ||
2857
2857
( systemAssemblies |> List.exists ( fun sysFile -> sysFile = fileNameWithoutExtension filename)))
2858
2858
with _ ->
2859
2859
false
2860
2860
2861
2861
// This is not the complete set of search paths, it is just the set
2862
2862
// that is special to F# (as compared to MSBuild resolution)
2863
2863
member tcConfig.SearchPathsForLibraryFiles =
2864
- [ yield ! tcConfig.ClrRoot
2864
+ [ yield ! tcConfig.TargetFrameworkDirectories
2865
2865
yield ! List.map ( tcConfig.MakePathAbsolute) tcConfig.includes
2866
2866
yield tcConfig.implicitIncludeDir
2867
2867
yield tcConfig.fsharpBinariesDir ]
@@ -2986,13 +2986,16 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
2986
2986
assemblyName, highestPosition, assemblyGroup)
2987
2987
|> Array.ofSeq
2988
2988
2989
- let logmessage showMessages =
2989
+ let logMessage showMessages =
2990
2990
if showMessages && tcConfig.showReferenceResolutions then ( fun ( message : string ) -> dprintf " %s \n " message)
2991
2991
else ignore
2992
2992
2993
- let logwarning showMessages =
2994
- ( fun code message ->
2993
+ let logErrorOrWarning showMessages =
2994
+ ( fun isError code message ->
2995
2995
if showMessages && mode = ReportErrors then
2996
+ if isError then
2997
+ errorR( MSBuildReferenceResolutionError( code, message, errorAndWarningRange))
2998
+ else
2996
2999
match code with
2997
3000
// These are warnings that mean 'not resolved' for some assembly.
2998
3001
// Note that we don't get to know the name of the assembly that couldn't be resolved.
@@ -3001,15 +3004,10 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
3001
3004
| " MSB3106"
3002
3005
-> ()
3003
3006
| _ ->
3004
- ( if code = " MSB3245" then errorR else warning)
3005
- ( MSBuildReferenceResolutionWarning( code, message, errorAndWarningRange)))
3006
-
3007
- let logerror showMessages =
3008
- ( fun code message ->
3009
- if showMessages && mode = ReportErrors then
3010
- errorR( MSBuildReferenceResolutionError( code, message, errorAndWarningRange)))
3011
-
3012
- let targetFrameworkVersion = tcConfig.targetFrameworkVersion
3007
+ if code = " MSB3245" then
3008
+ errorR( MSBuildReferenceResolutionWarning( code, message, errorAndWarningRange))
3009
+ else
3010
+ warning( MSBuildReferenceResolutionWarning( code, message, errorAndWarningRange)))
3013
3011
3014
3012
let targetProcessorArchitecture =
3015
3013
match tcConfig.platform with
@@ -3018,13 +3016,6 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
3018
3016
| Some( AMD64) -> " amd64"
3019
3017
| Some( IA64) -> " ia64"
3020
3018
3021
- let outputDirectory =
3022
- match tcConfig.outputFile with
3023
- | Some( outputFile) -> tcConfig.MakePathAbsolute outputFile
3024
- | None -> tcConfig.implicitIncludeDir
3025
-
3026
- let targetFrameworkDirectories = tcConfig.ClrRoot
3027
-
3028
3019
// First, try to resolve everything as a file using simple resolution
3029
3020
let resolvedAsFile =
3030
3021
groupedReferences
@@ -3040,14 +3031,13 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
3040
3031
tcConfig.referenceResolver.Resolve
3041
3032
( tcConfig.resolutionEnvironment,
3042
3033
references,
3043
- targetFrameworkVersion,
3044
- targetFrameworkDirectories ,
3034
+ tcConfig. targetFrameworkVersion,
3035
+ tcConfig.TargetFrameworkDirectories ,
3045
3036
targetProcessorArchitecture,
3046
- Path.GetDirectoryName( outputDirectory),
3047
3037
tcConfig.fsharpBinariesDir, // FSharp binaries directory
3048
3038
tcConfig.includes, // Explicit include directories
3049
3039
tcConfig.implicitIncludeDir, // Implicit include directory (likely the project directory)
3050
- logmessage showMessages, logwarning showMessages , logerror showMessages)
3040
+ logMessage showMessages, logErrorOrWarning showMessages)
3051
3041
with
3052
3042
ReferenceResolver.ResolutionFailure -> error( Error( FSComp.SR.buildAssemblyResolutionFailed(), errorAndWarningRange))
3053
3043
@@ -4246,38 +4236,25 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
4246
4236
let invalidateCcu = new Event<_>()
4247
4237
#endif
4248
4238
4249
- // Adjust where the code for known F# libraries live relative to the installation of F#
4250
- let codeDir =
4251
- let dir = minfo.compileTimeWorkingDir
4252
- let knownLibraryLocation = @" src\fsharp\" // Help highlighting... "
4253
- let knownLibarySuffixes =
4254
- [ @" FSharp.Core"
4255
- @" FSharp.PowerPack"
4256
- @" FSharp.PowerPack.Linq"
4257
- @" FSharp.PowerPack.Metadata" ]
4258
- match knownLibarySuffixes |> List.tryFind ( fun x -> dir.EndsWith( knownLibraryLocation + x, StringComparison.OrdinalIgnoreCase)) with
4259
- | None ->
4260
- dir
4261
- | Some libSuffix ->
4262
- // add "..\lib\FSharp.Core" to the F# binaries directory
4263
- Path.Combine( Path.Combine( tcConfig.fsharpBinariesDir, @" ..\lib" ), libSuffix)
4264
-
4265
- let ccu =
4266
- CcuThunk.Create( ccuName, { ILScopeRef= ilScopeRef
4267
- Stamp = newStamp()
4268
- FileName = Some filename
4269
- QualifiedName= Some( ilScopeRef.QualifiedName)
4270
- SourceCodeDirectory = codeDir (* note: in some cases we fix up this information later *)
4271
- IsFSharp= true
4272
- Contents = mspec
4239
+ let codeDir = minfo.compileTimeWorkingDir
4240
+ let ccuData : CcuData =
4241
+ { ILScopeRef= ilScopeRef
4242
+ Stamp = newStamp()
4243
+ FileName = Some filename
4244
+ QualifiedName= Some( ilScopeRef.QualifiedName)
4245
+ SourceCodeDirectory = codeDir (* note: in some cases we fix up this information later *)
4246
+ IsFSharp= true
4247
+ Contents = mspec
4273
4248
#if EXTENSIONTYPING
4274
- InvalidateEvent= invalidateCcu.Publish
4275
- IsProviderGenerated = false
4276
- ImportProvidedType = ( fun ty -> Import.ImportProvidedType ( tcImports.GetImportMap()) m ty)
4249
+ InvalidateEvent= invalidateCcu.Publish
4250
+ IsProviderGenerated = false
4251
+ ImportProvidedType = ( fun ty -> Import.ImportProvidedType ( tcImports.GetImportMap()) m ty)
4277
4252
#endif
4278
- UsesFSharp20PlusQuotations = minfo.usesQuotations
4279
- MemberSignatureEquality= ( fun ty1 ty2 -> Tastops.typeEquivAux EraseAll ( tcImports.GetTcGlobals()) ty1 ty2)
4280
- TypeForwarders = ImportILAssemblyTypeForwarders( tcImports.GetImportMap, m, ilModule.GetRawTypeForwarders()) })
4253
+ UsesFSharp20PlusQuotations = minfo.usesQuotations
4254
+ MemberSignatureEquality= ( fun ty1 ty2 -> Tastops.typeEquivAux EraseAll ( tcImports.GetTcGlobals()) ty1 ty2)
4255
+ TypeForwarders = ImportILAssemblyTypeForwarders( tcImports.GetImportMap, m, ilModule.GetRawTypeForwarders()) }
4256
+
4257
+ let ccu = CcuThunk.Create( ccuName, ccuData)
4281
4258
4282
4259
let optdata =
4283
4260
lazy
@@ -4292,15 +4269,15 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
4292
4269
Some res)
4293
4270
let ilg = defaultArg ilGlobalsOpt EcmaILGlobals
4294
4271
let ccuinfo =
4295
- { FSharpViewOfMetadata= ccu
4296
- AssemblyAutoOpenAttributes = ilModule.GetAutoOpenAttributes( ilg)
4297
- AssemblyInternalsVisibleToAttributes = ilModule.GetInternalsVisibleToAttributes( ilg)
4298
- FSharpOptimizationData= optdata
4272
+ { FSharpViewOfMetadata= ccu
4273
+ AssemblyAutoOpenAttributes = ilModule.GetAutoOpenAttributes( ilg)
4274
+ AssemblyInternalsVisibleToAttributes = ilModule.GetInternalsVisibleToAttributes( ilg)
4275
+ FSharpOptimizationData= optdata
4299
4276
#if EXTENSIONTYPING
4300
- IsProviderGenerated = false
4301
- TypeProviders = []
4277
+ IsProviderGenerated = false
4278
+ TypeProviders = []
4302
4279
#endif
4303
- ILScopeRef = ilScopeRef }
4280
+ ILScopeRef = ilScopeRef }
4304
4281
let phase2 () =
4305
4282
#if EXTENSIONTYPING
4306
4283
match ilModule.TryGetRawILModule() with
@@ -4349,15 +4326,16 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
4349
4326
let phase2 () = [ tcImports.FindCcuInfo( m, ilShortAssemName, lookupOnly= true )]
4350
4327
dllinfo, phase2
4351
4328
else
4352
- let dllinfo = { RawMetadata= assemblyData
4353
- FileName= filename
4329
+ let dllinfo =
4330
+ { RawMetadata= assemblyData
4331
+ FileName= filename
4354
4332
#if EXTENSIONTYPING
4355
- ProviderGeneratedAssembly= None
4356
- IsProviderGenerated= false
4357
- ProviderGeneratedStaticLinkMap = None
4333
+ ProviderGeneratedAssembly= None
4334
+ IsProviderGenerated= false
4335
+ ProviderGeneratedStaticLinkMap = None
4358
4336
#endif
4359
- ILScopeRef = ilScopeRef
4360
- ILAssemblyRefs = assemblyData.ILAssemblyRefs }
4337
+ ILScopeRef = ilScopeRef
4338
+ ILAssemblyRefs = assemblyData.ILAssemblyRefs }
4361
4339
tcImports.RegisterDll( dllinfo)
4362
4340
let ilg = defaultArg ilGlobalsOpt EcmaILGlobals
4363
4341
let phase2 =
@@ -5159,26 +5137,31 @@ type TcState =
5159
5137
tcsTcImplEnv = tcEnvAtEndOfLastInput }
5160
5138
5161
5139
5140
+ /// Create the initial type checking state for compiling an assembly
5162
5141
let GetInitialTcState ( m , ccuName , tcConfig : TcConfig , tcGlobals , tcImports : TcImports , niceNameGen , tcEnv0 ) =
5163
5142
ignore tcImports
5143
+
5164
5144
// Create a ccu to hold all the results of compilation
5165
5145
let ccuType = NewCcuContents ILScopeRef.Local m ccuName ( NewEmptyModuleOrNamespaceType Namespace)
5166
- let ccu =
5167
- CcuThunk.Create( ccuName,{ IsFSharp= true
5168
- UsesFSharp20PlusQuotations= false
5146
+
5147
+ let ccuData : CcuData =
5148
+ { IsFSharp= true
5149
+ UsesFSharp20PlusQuotations= false
5169
5150
#if EXTENSIONTYPING
5170
- InvalidateEvent=( new Event<_>()) .Publish
5171
- IsProviderGenerated = false
5172
- ImportProvidedType = ( fun ty -> Import.ImportProvidedType ( tcImports.GetImportMap()) m ty)
5151
+ InvalidateEvent=( new Event<_>()). Publish
5152
+ IsProviderGenerated = false
5153
+ ImportProvidedType = ( fun ty -> Import.ImportProvidedType ( tcImports.GetImportMap()) m ty)
5173
5154
#endif
5174
- FileName= None
5175
- Stamp = newStamp()
5176
- QualifiedName= None
5177
- SourceCodeDirectory = tcConfig.implicitIncludeDir
5178
- ILScopeRef= ILScopeRef.Local
5179
- Contents= ccuType
5180
- MemberSignatureEquality= ( Tastops.typeEquivAux EraseAll tcGlobals)
5181
- TypeForwarders= Map.empty })
5155
+ FileName= None
5156
+ Stamp = newStamp()
5157
+ QualifiedName= None
5158
+ SourceCodeDirectory = tcConfig.implicitIncludeDir
5159
+ ILScopeRef= ILScopeRef.Local
5160
+ Contents= ccuType
5161
+ MemberSignatureEquality= ( Tastops.typeEquivAux EraseAll tcGlobals)
5162
+ TypeForwarders= Map.empty }
5163
+
5164
+ let ccu = CcuThunk.Create( ccuName, ccuData)
5182
5165
5183
5166
// OK, is this is the FSharp.Core CCU then fix it up.
5184
5167
if tcConfig.compilingFslib then
@@ -5196,7 +5179,7 @@ let GetInitialTcState(m,ccuName,tcConfig:TcConfig,tcGlobals,tcImports:TcImports,
5196
5179
tcsRootSigsAndImpls = RootSigsAndImpls ( rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp) }
5197
5180
5198
5181
5199
- /// Typecheck a single file or interactive entry into F# Interactive
5182
+ /// Typecheck a single file ( or interactive entry into F# Interactive)
5200
5183
let TypeCheckOneInputEventually
5201
5184
( checkForErrors , tcConfig : TcConfig , tcImports : TcImports ,
5202
5185
tcGlobals , prefixPathOpt , tcSink , tcState : TcState , inp : ParsedInput ) =
@@ -5307,12 +5290,14 @@ let TypeCheckOneInputEventually
5307
5290
return ( tcState.TcEnvFromSignatures, EmptyTopAttrs,[]), tcState
5308
5291
}
5309
5292
5293
+ /// Typecheck a single file (or interactive entry into F# Interactive)
5310
5294
let TypeCheckOneInput ( checkForErrors , tcConfig , tcImports , tcGlobals , prefixPathOpt ) tcState inp =
5311
5295
// 'use' ensures that the warning handler is restored at the end
5312
5296
use unwindEL = PushErrorLoggerPhaseUntilUnwind( fun oldLogger -> GetErrorLoggerFilteringByScopedPragmas( false , GetScopedPragmasForInput( inp), oldLogger) )
5313
5297
use unwindBP = PushThreadBuildPhaseUntilUnwind ( BuildPhase.TypeCheck)
5314
5298
TypeCheckOneInputEventually ( checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, TcResultsSink.NoSink, tcState, inp) |> Eventually.force
5315
5299
5300
+ /// Finish checking multiple files (or one interactive entry into F# Interactive)
5316
5301
let TypeCheckMultipleInputsFinish ( results , tcState : TcState ) =
5317
5302
let tcEnvsAtEndFile , topAttrs , mimpls = List.unzip3 results
5318
5303
@@ -5323,11 +5308,12 @@ let TypeCheckMultipleInputsFinish(results,tcState: TcState) =
5323
5308
5324
5309
( tcEnvAtEndOfLastFile, topAttrs, mimpls), tcState
5325
5310
5311
+ /// Check multiple files (or one interactive entry into F# Interactive)
5326
5312
let TypeCheckMultipleInputs ( checkForErrors , tcConfig : TcConfig , tcImports , tcGlobals , prefixPathOpt , tcState , inputs ) =
5327
5313
let results , tcState = ( tcState, inputs) ||> List.mapFold ( TypeCheckOneInput ( checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt))
5328
5314
TypeCheckMultipleInputsFinish( results, tcState)
5329
5315
5330
- let TypeCheckSingleInputAndFinishEventually ( checkForErrors , tcConfig : TcConfig , tcImports , tcGlobals , prefixPathOpt , tcSink , tcState , input ) =
5316
+ let TypeCheckOneInputAndFinishEventually ( checkForErrors , tcConfig : TcConfig , tcImports , tcGlobals , prefixPathOpt , tcSink , tcState , input ) =
5331
5317
eventually {
5332
5318
let! results , tcState = TypeCheckOneInputEventually( checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, tcState, input)
5333
5319
return TypeCheckMultipleInputsFinish([ results], tcState)
0 commit comments