@@ -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 ->
@@ -2868,15 +2868,15 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
2868
2868
member tcConfig.IsSystemAssembly ( filename : string ) =
2869
2869
try
2870
2870
FileSystem.SafeExists filename &&
2871
- (( tcConfig.ClrRoot |> List.exists ( fun clrRoot -> clrRoot = Path.GetDirectoryName filename)) ||
2871
+ (( tcConfig.TargetFrameworkDirectories |> List.exists ( fun clrRoot -> clrRoot = Path.GetDirectoryName filename)) ||
2872
2872
( systemAssemblies |> List.exists ( fun sysFile -> sysFile = fileNameWithoutExtension filename)))
2873
2873
with _ ->
2874
2874
false
2875
2875
2876
2876
// This is not the complete set of search paths, it is just the set
2877
2877
// that is special to F# (as compared to MSBuild resolution)
2878
2878
member tcConfig.SearchPathsForLibraryFiles =
2879
- [ yield ! tcConfig.ClrRoot
2879
+ [ yield ! tcConfig.TargetFrameworkDirectories
2880
2880
yield ! List.map ( tcConfig.MakePathAbsolute) tcConfig.includes
2881
2881
yield tcConfig.implicitIncludeDir
2882
2882
yield tcConfig.fsharpBinariesDir ]
@@ -3001,13 +3001,16 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
3001
3001
assemblyName, highestPosition, assemblyGroup)
3002
3002
|> Array.ofSeq
3003
3003
3004
- let logmessage showMessages =
3004
+ let logMessage showMessages =
3005
3005
if showMessages && tcConfig.showReferenceResolutions then ( fun ( message : string ) -> dprintf " %s \n " message)
3006
3006
else ignore
3007
3007
3008
- let logwarning showMessages =
3009
- ( fun code message ->
3008
+ let logErrorOrWarning showMessages =
3009
+ ( fun isError code message ->
3010
3010
if showMessages && mode = ReportErrors then
3011
+ if isError then
3012
+ errorR( MSBuildReferenceResolutionError( code, message, errorAndWarningRange))
3013
+ else
3011
3014
match code with
3012
3015
// These are warnings that mean 'not resolved' for some assembly.
3013
3016
// Note that we don't get to know the name of the assembly that couldn't be resolved.
@@ -3016,15 +3019,10 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
3016
3019
| " MSB3106"
3017
3020
-> ()
3018
3021
| _ ->
3019
- ( if code = " MSB3245" then errorR else warning)
3020
- ( MSBuildReferenceResolutionWarning( code, message, errorAndWarningRange)))
3021
-
3022
- let logerror showMessages =
3023
- ( fun code message ->
3024
- if showMessages && mode = ReportErrors then
3025
- errorR( MSBuildReferenceResolutionError( code, message, errorAndWarningRange)))
3026
-
3027
- let targetFrameworkVersion = tcConfig.targetFrameworkVersion
3022
+ if code = " MSB3245" then
3023
+ errorR( MSBuildReferenceResolutionWarning( code, message, errorAndWarningRange))
3024
+ else
3025
+ warning( MSBuildReferenceResolutionWarning( code, message, errorAndWarningRange)))
3028
3026
3029
3027
let targetProcessorArchitecture =
3030
3028
match tcConfig.platform with
@@ -3033,13 +3031,6 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
3033
3031
| Some( AMD64) -> " amd64"
3034
3032
| Some( IA64) -> " ia64"
3035
3033
3036
- let outputDirectory =
3037
- match tcConfig.outputFile with
3038
- | Some( outputFile) -> tcConfig.MakePathAbsolute outputFile
3039
- | None -> tcConfig.implicitIncludeDir
3040
-
3041
- let targetFrameworkDirectories = tcConfig.ClrRoot
3042
-
3043
3034
// First, try to resolve everything as a file using simple resolution
3044
3035
let resolvedAsFile =
3045
3036
groupedReferences
@@ -3055,14 +3046,13 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
3055
3046
tcConfig.referenceResolver.Resolve
3056
3047
( tcConfig.resolutionEnvironment,
3057
3048
references,
3058
- targetFrameworkVersion,
3059
- targetFrameworkDirectories ,
3049
+ tcConfig. targetFrameworkVersion,
3050
+ tcConfig.TargetFrameworkDirectories ,
3060
3051
targetProcessorArchitecture,
3061
- Path.GetDirectoryName( outputDirectory),
3062
3052
tcConfig.fsharpBinariesDir, // FSharp binaries directory
3063
3053
tcConfig.includes, // Explicit include directories
3064
3054
tcConfig.implicitIncludeDir, // Implicit include directory (likely the project directory)
3065
- logmessage showMessages, logwarning showMessages , logerror showMessages)
3055
+ logMessage showMessages, logErrorOrWarning showMessages)
3066
3056
with
3067
3057
ReferenceResolver.ResolutionFailure -> error( Error( FSComp.SR.buildAssemblyResolutionFailed(), errorAndWarningRange))
3068
3058
@@ -4264,38 +4254,25 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
4264
4254
let invalidateCcu = new Event<_>()
4265
4255
#endif
4266
4256
4267
- // Adjust where the code for known F# libraries live relative to the installation of F#
4268
- let codeDir =
4269
- let dir = minfo.compileTimeWorkingDir
4270
- let knownLibraryLocation = @" src\fsharp\" // Help highlighting... "
4271
- let knownLibarySuffixes =
4272
- [ @" FSharp.Core"
4273
- @" FSharp.PowerPack"
4274
- @" FSharp.PowerPack.Linq"
4275
- @" FSharp.PowerPack.Metadata" ]
4276
- match knownLibarySuffixes |> List.tryFind ( fun x -> dir.EndsWith( knownLibraryLocation + x, StringComparison.OrdinalIgnoreCase)) with
4277
- | None ->
4278
- dir
4279
- | Some libSuffix ->
4280
- // add "..\lib\FSharp.Core" to the F# binaries directory
4281
- Path.Combine( Path.Combine( tcConfig.fsharpBinariesDir, @" ..\lib" ), libSuffix)
4282
-
4283
- let ccu =
4284
- CcuThunk.Create( ccuName, { ILScopeRef= ilScopeRef
4285
- Stamp = newStamp()
4286
- FileName = Some filename
4287
- QualifiedName= Some( ilScopeRef.QualifiedName)
4288
- SourceCodeDirectory = codeDir (* note: in some cases we fix up this information later *)
4289
- IsFSharp= true
4290
- Contents = mspec
4257
+ let codeDir = minfo.compileTimeWorkingDir
4258
+ let ccuData : CcuData =
4259
+ { ILScopeRef= ilScopeRef
4260
+ Stamp = newStamp()
4261
+ FileName = Some filename
4262
+ QualifiedName= Some( ilScopeRef.QualifiedName)
4263
+ SourceCodeDirectory = codeDir (* note: in some cases we fix up this information later *)
4264
+ IsFSharp= true
4265
+ Contents = mspec
4291
4266
#if EXTENSIONTYPING
4292
- InvalidateEvent= invalidateCcu.Publish
4293
- IsProviderGenerated = false
4294
- ImportProvidedType = ( fun ty -> Import.ImportProvidedType ( tcImports.GetImportMap()) m ty)
4267
+ InvalidateEvent= invalidateCcu.Publish
4268
+ IsProviderGenerated = false
4269
+ ImportProvidedType = ( fun ty -> Import.ImportProvidedType ( tcImports.GetImportMap()) m ty)
4295
4270
#endif
4296
- UsesFSharp20PlusQuotations = minfo.usesQuotations
4297
- MemberSignatureEquality= ( fun ty1 ty2 -> Tastops.typeEquivAux EraseAll ( tcImports.GetTcGlobals()) ty1 ty2)
4298
- TypeForwarders = ImportILAssemblyTypeForwarders( tcImports.GetImportMap, m, ilModule.GetRawTypeForwarders()) })
4271
+ UsesFSharp20PlusQuotations = minfo.usesQuotations
4272
+ MemberSignatureEquality= ( fun ty1 ty2 -> Tastops.typeEquivAux EraseAll ( tcImports.GetTcGlobals()) ty1 ty2)
4273
+ TypeForwarders = ImportILAssemblyTypeForwarders( tcImports.GetImportMap, m, ilModule.GetRawTypeForwarders()) }
4274
+
4275
+ let ccu = CcuThunk.Create( ccuName, ccuData)
4299
4276
4300
4277
let optdata =
4301
4278
lazy
@@ -4310,15 +4287,15 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
4310
4287
Some res)
4311
4288
let ilg = defaultArg ilGlobalsOpt EcmaILGlobals
4312
4289
let ccuinfo =
4313
- { FSharpViewOfMetadata= ccu
4314
- AssemblyAutoOpenAttributes = ilModule.GetAutoOpenAttributes( ilg)
4315
- AssemblyInternalsVisibleToAttributes = ilModule.GetInternalsVisibleToAttributes( ilg)
4316
- FSharpOptimizationData= optdata
4290
+ { FSharpViewOfMetadata= ccu
4291
+ AssemblyAutoOpenAttributes = ilModule.GetAutoOpenAttributes( ilg)
4292
+ AssemblyInternalsVisibleToAttributes = ilModule.GetInternalsVisibleToAttributes( ilg)
4293
+ FSharpOptimizationData= optdata
4317
4294
#if EXTENSIONTYPING
4318
- IsProviderGenerated = false
4319
- TypeProviders = []
4295
+ IsProviderGenerated = false
4296
+ TypeProviders = []
4320
4297
#endif
4321
- ILScopeRef = ilScopeRef }
4298
+ ILScopeRef = ilScopeRef }
4322
4299
let phase2 () =
4323
4300
#if EXTENSIONTYPING
4324
4301
match ilModule.TryGetRawILModule() with
@@ -4367,15 +4344,16 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
4367
4344
let phase2 () = [ tcImports.FindCcuInfo( m, ilShortAssemName, lookupOnly= true )]
4368
4345
dllinfo, phase2
4369
4346
else
4370
- let dllinfo = { RawMetadata= assemblyData
4371
- FileName= filename
4347
+ let dllinfo =
4348
+ { RawMetadata= assemblyData
4349
+ FileName= filename
4372
4350
#if EXTENSIONTYPING
4373
- ProviderGeneratedAssembly= None
4374
- IsProviderGenerated= false
4375
- ProviderGeneratedStaticLinkMap = None
4351
+ ProviderGeneratedAssembly= None
4352
+ IsProviderGenerated= false
4353
+ ProviderGeneratedStaticLinkMap = None
4376
4354
#endif
4377
- ILScopeRef = ilScopeRef
4378
- ILAssemblyRefs = assemblyData.ILAssemblyRefs }
4355
+ ILScopeRef = ilScopeRef
4356
+ ILAssemblyRefs = assemblyData.ILAssemblyRefs }
4379
4357
tcImports.RegisterDll( dllinfo)
4380
4358
let ilg = defaultArg ilGlobalsOpt EcmaILGlobals
4381
4359
let phase2 =
@@ -5177,26 +5155,31 @@ type TcState =
5177
5155
tcsTcImplEnv = tcEnvAtEndOfLastInput }
5178
5156
5179
5157
5158
+ /// Create the initial type checking state for compiling an assembly
5180
5159
let GetInitialTcState ( m , ccuName , tcConfig : TcConfig , tcGlobals , tcImports : TcImports , niceNameGen , tcEnv0 ) =
5181
5160
ignore tcImports
5161
+
5182
5162
// Create a ccu to hold all the results of compilation
5183
5163
let ccuType = NewCcuContents ILScopeRef.Local m ccuName ( NewEmptyModuleOrNamespaceType Namespace)
5184
- let ccu =
5185
- CcuThunk.Create( ccuName,{ IsFSharp= true
5186
- UsesFSharp20PlusQuotations= false
5164
+
5165
+ let ccuData : CcuData =
5166
+ { IsFSharp= true
5167
+ UsesFSharp20PlusQuotations= false
5187
5168
#if EXTENSIONTYPING
5188
- InvalidateEvent=( new Event<_>()) .Publish
5189
- IsProviderGenerated = false
5190
- ImportProvidedType = ( fun ty -> Import.ImportProvidedType ( tcImports.GetImportMap()) m ty)
5169
+ InvalidateEvent=( new Event<_>()). Publish
5170
+ IsProviderGenerated = false
5171
+ ImportProvidedType = ( fun ty -> Import.ImportProvidedType ( tcImports.GetImportMap()) m ty)
5191
5172
#endif
5192
- FileName= None
5193
- Stamp = newStamp()
5194
- QualifiedName= None
5195
- SourceCodeDirectory = tcConfig.implicitIncludeDir
5196
- ILScopeRef= ILScopeRef.Local
5197
- Contents= ccuType
5198
- MemberSignatureEquality= ( Tastops.typeEquivAux EraseAll tcGlobals)
5199
- TypeForwarders= Map.empty })
5173
+ FileName= None
5174
+ Stamp = newStamp()
5175
+ QualifiedName= None
5176
+ SourceCodeDirectory = tcConfig.implicitIncludeDir
5177
+ ILScopeRef= ILScopeRef.Local
5178
+ Contents= ccuType
5179
+ MemberSignatureEquality= ( Tastops.typeEquivAux EraseAll tcGlobals)
5180
+ TypeForwarders= Map.empty }
5181
+
5182
+ let ccu = CcuThunk.Create( ccuName, ccuData)
5200
5183
5201
5184
// OK, is this is the FSharp.Core CCU then fix it up.
5202
5185
if tcConfig.compilingFslib then
@@ -5214,7 +5197,7 @@ let GetInitialTcState(m,ccuName,tcConfig:TcConfig,tcGlobals,tcImports:TcImports,
5214
5197
tcsRootSigsAndImpls = RootSigsAndImpls ( rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp) }
5215
5198
5216
5199
5217
- /// Typecheck a single file or interactive entry into F# Interactive
5200
+ /// Typecheck a single file ( or interactive entry into F# Interactive)
5218
5201
let TypeCheckOneInputEventually
5219
5202
( checkForErrors , tcConfig : TcConfig , tcImports : TcImports ,
5220
5203
tcGlobals , prefixPathOpt , tcSink , tcState : TcState , inp : ParsedInput ) =
@@ -5325,12 +5308,14 @@ let TypeCheckOneInputEventually
5325
5308
return ( tcState.TcEnvFromSignatures, EmptyTopAttrs,[]), tcState
5326
5309
}
5327
5310
5311
+ /// Typecheck a single file (or interactive entry into F# Interactive)
5328
5312
let TypeCheckOneInput ( checkForErrors , tcConfig , tcImports , tcGlobals , prefixPathOpt ) tcState inp =
5329
5313
// 'use' ensures that the warning handler is restored at the end
5330
5314
use unwindEL = PushErrorLoggerPhaseUntilUnwind( fun oldLogger -> GetErrorLoggerFilteringByScopedPragmas( false , GetScopedPragmasForInput( inp), oldLogger) )
5331
5315
use unwindBP = PushThreadBuildPhaseUntilUnwind ( BuildPhase.TypeCheck)
5332
5316
TypeCheckOneInputEventually ( checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, TcResultsSink.NoSink, tcState, inp) |> Eventually.force
5333
5317
5318
+ /// Finish checking multiple files (or one interactive entry into F# Interactive)
5334
5319
let TypeCheckMultipleInputsFinish ( results , tcState : TcState ) =
5335
5320
let tcEnvsAtEndFile , topAttrs , mimpls = List.unzip3 results
5336
5321
@@ -5341,11 +5326,12 @@ let TypeCheckMultipleInputsFinish(results,tcState: TcState) =
5341
5326
5342
5327
( tcEnvAtEndOfLastFile, topAttrs, mimpls), tcState
5343
5328
5329
+ /// Check multiple files (or one interactive entry into F# Interactive)
5344
5330
let TypeCheckMultipleInputs ( checkForErrors , tcConfig : TcConfig , tcImports , tcGlobals , prefixPathOpt , tcState , inputs ) =
5345
5331
let results , tcState = ( tcState, inputs) ||> List.mapFold ( TypeCheckOneInput ( checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt))
5346
5332
TypeCheckMultipleInputsFinish( results, tcState)
5347
5333
5348
- let TypeCheckSingleInputAndFinishEventually ( checkForErrors , tcConfig : TcConfig , tcImports , tcGlobals , prefixPathOpt , tcSink , tcState , input ) =
5334
+ let TypeCheckOneInputAndFinishEventually ( checkForErrors , tcConfig : TcConfig , tcImports , tcGlobals , prefixPathOpt , tcSink , tcState , input ) =
5349
5335
eventually {
5350
5336
let! results , tcState = TypeCheckOneInputEventually( checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, tcState, input)
5351
5337
return TypeCheckMultipleInputsFinish([ results], tcState)
0 commit comments