From 5427488c41a83880a9e5f0de8e24261103025663 Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Mon, 27 Jun 2016 10:41:17 +0200 Subject: [PATCH 1/6] Fix file ordering when getting script options --- src/fsharp/CompileOps.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 3a0e7620bd..fd28c8eebc 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -5005,7 +5005,8 @@ module private ScriptPreprocessClosure = [ClosedSourceFile(filename,m,None,[],[],[])] // Don't traverse into .fs leafs. let loadedSources = (!tcConfig).GetAvailableLoadedSources() |> List.rev |> List.map AddFileIfNotSeen |> List.concat - ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns) :: loadedSources |> List.map FindClosure |> List.concat // Final closure is in reverse order. Keep the closed source at the top. + (loadedSources |> List.map FindClosure |> List.concat) + @ [ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns)] | None -> [ClosedSourceFile(filename,m,None,!errors,!warnings,[])] closureDirectives |> List.map FindClosure |> List.concat, !tcConfig @@ -5067,7 +5068,7 @@ module private ScriptPreprocessClosure = let rootWarnings = rootWarnings |> List.filter isRootRange let result : LoadClosure = - { SourceFiles = List.groupByFirst !sourceFiles + { SourceFiles = List.groupByFirst !sourceFiles |> List.rev References = List.groupByFirst references UnresolvedReferences = unresolvedReferences Inputs = !sourceInputs From 8a57cd70c0cac2c62f02dbb1235606962550c0cb Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Tue, 28 Jun 2016 00:03:44 +0200 Subject: [PATCH 2/6] Replace previous commit with new fix --- src/fsharp/CompileOps.fs | 5 ++--- src/fsharp/vs/service.fs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index fd28c8eebc..3a0e7620bd 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -5005,8 +5005,7 @@ module private ScriptPreprocessClosure = [ClosedSourceFile(filename,m,None,[],[],[])] // Don't traverse into .fs leafs. let loadedSources = (!tcConfig).GetAvailableLoadedSources() |> List.rev |> List.map AddFileIfNotSeen |> List.concat - (loadedSources |> List.map FindClosure |> List.concat) - @ [ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns)] + ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns) :: loadedSources |> List.map FindClosure |> List.concat // Final closure is in reverse order. Keep the closed source at the top. | None -> [ClosedSourceFile(filename,m,None,!errors,!warnings,[])] closureDirectives |> List.map FindClosure |> List.concat, !tcConfig @@ -5068,7 +5067,7 @@ module private ScriptPreprocessClosure = let rootWarnings = rootWarnings |> List.filter isRootRange let result : LoadClosure = - { SourceFiles = List.groupByFirst !sourceFiles |> List.rev + { SourceFiles = List.groupByFirst !sourceFiles References = List.groupByFirst references UnresolvedReferences = unresolvedReferences Inputs = !sourceInputs diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 8e77c3e9da..5a75bc0285 100755 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -2546,7 +2546,7 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun let co = { ProjectFileName = filename + ".fsproj" // Make a name that is unique in this directory. - ProjectFileNames = fas.SourceFiles |> List.map fst |> List.toArray + ProjectFileNames = fas.Inputs |> List.map fst |> List.toArray OtherOptions = otherFlags ReferencedProjects= [| |] IsIncompleteTypeCheckEnvironment = false From 86cb6a497f57728716a6b1c6eb7312aea4fce261 Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Wed, 29 Jun 2016 16:29:52 +0200 Subject: [PATCH 3/6] Add test and go back to first fix --- src/fsharp/CompileOps.fs | 5 +- .../FSharp.Compiler.Service.fsproj | 500 ++++++++---------- src/fsharp/vs/service.fs | 2 +- tests/service/ProjectOptionsTests.fs | 11 + tests/service/data/ScriptProject/BaseLib.fs | 3 + tests/service/data/ScriptProject/Lib1.fsx | 2 + tests/service/data/ScriptProject/Lib2.fsx | 2 + tests/service/data/ScriptProject/Main.fsx | 4 + 8 files changed, 255 insertions(+), 274 deletions(-) create mode 100644 tests/service/data/ScriptProject/BaseLib.fs create mode 100644 tests/service/data/ScriptProject/Lib1.fsx create mode 100644 tests/service/data/ScriptProject/Lib2.fsx create mode 100644 tests/service/data/ScriptProject/Main.fsx diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 3a0e7620bd..fd28c8eebc 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -5005,7 +5005,8 @@ module private ScriptPreprocessClosure = [ClosedSourceFile(filename,m,None,[],[],[])] // Don't traverse into .fs leafs. let loadedSources = (!tcConfig).GetAvailableLoadedSources() |> List.rev |> List.map AddFileIfNotSeen |> List.concat - ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns) :: loadedSources |> List.map FindClosure |> List.concat // Final closure is in reverse order. Keep the closed source at the top. + (loadedSources |> List.map FindClosure |> List.concat) + @ [ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns)] | None -> [ClosedSourceFile(filename,m,None,!errors,!warnings,[])] closureDirectives |> List.map FindClosure |> List.concat, !tcConfig @@ -5067,7 +5068,7 @@ module private ScriptPreprocessClosure = let rootWarnings = rootWarnings |> List.filter isRootRange let result : LoadClosure = - { SourceFiles = List.groupByFirst !sourceFiles + { SourceFiles = List.groupByFirst !sourceFiles |> List.rev References = List.groupByFirst references UnresolvedReferences = unresolvedReferences Inputs = !sourceInputs diff --git a/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj index b8558fe82b..c3be2ff7d3 100644 --- a/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj +++ b/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj @@ -1,280 +1,250 @@ - - + + + FSharp.Compiler.Service + Debug AnyCPU + + 2e4d67b4-522d-4cf7-97e4-ba940f0b18f3 + Library - FSharp.Compiler.Service - $(NoWarn);44;62;9 - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} - true v4.5 - 0x06800000 - $(OtherFlags) /warnon:1182 - true - true - $(OtherFlags) --times - $(NoWarn);69;65;54;61;75 - true - ..\..\..\bin\$(TargetFrameworkVersion) - $(OutputPath)$(AssemblyName).xml - $(DefineConstants);CROSS_PLATFORM_COMPILER - $(DefineConstants);FX_ATLEAST_45 - $(DefineConstants);FX_NO_GENERIC_WEAKREFERENCE - $(DefineConstants);FX_ATLEAST_40 - $(DefineConstants);BE_SECURITY_TRANSPARENT - $(DefineConstants);TYPE_PROVIDER_SECURITY - $(DefineConstants);EXTENSIBLE_DUMPER - $(DefineConstants);INCLUDE_METADATA_WRITER - $(DefineConstants);COMPILER - $(DefineConstants);ENABLE_MONO_SUPPORT - $(DefineConstants);FX_MSBUILDRESOLVER_RUNTIMELIKE - $(DefineConstants);FX_LCIDFROMCODEPAGE - $(DefineConstants);FX_RESX_RESOURCE_READER - $(DefineConstants);FX_RESIDENT_COMPILER - $(DefineConstants);SHADOW_COPY_REFERENCES - $(DefineConstants);EXTENSIONTYPING - $(DefineConstants);COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_4_0_0 - $(DefineConstants);COMPILER_SERVICE - $(DefineConstants);NO_STRONG_NAMES - $(DefineConstants);TRACE - 4.4.0.0 - $(MSBuildProjectDirectory)\..\..\..\ + + 4.4.0.0 + $(OutputPath)$(AssemblyName).xml - - $(SolutionDir)lib\bootstrap\4.0 - $(SolutionDir)packages\FsSrGen\lib\net46 - $(FsLexYaccPath) - $(FsLexYaccPath) - fslex.exe - fsyacc.exe - false - - - DEBUG; $(DefineConstants) + + false - $(OtherFlags) --no-jit-optimize --jit-tracking - ..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.xml + + + DEBUG $(DefineConstants) + AnyCPU true + $(OtherFlags) --no-jit-optimize --jit-tracking + + true - ..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.xml + + + + AnyCPU true + + + + + + + + + + + + + - + + + + + + + + + + + + + False + + + + + AssemblyInfo/assemblyinfo.FSharp.Compiler.Service.dll.fs - + AssemblyInfo/assemblyinfo.shared.fs - - FSComp.txt - - - FSIstrings.txt - - - - + + + FSStrings.resx - - --lexlib Internal.Utilities.Text.Lexing - lex.fsl - - - --lexlib Internal.Utilities.Text.Lexing - illex.fsl - - - Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser - Microsoft.FSharp.Compiler.AbstractIL - --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing - ilpars.fsy - - - Microsoft.FSharp.Compiler.Parser - Microsoft.FSharp.Compiler - --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing - pars.fsy - - + Reshaped/reshapedreflection.fs - + Reshaped/reshapedmsbuild.fs - + ErrorText/sformat.fsi - + ErrorText/sformat.fs - + ErrorText/sr.fsi - + ErrorText/sr.fs - + LexYaccRuntime/prim-lexing.fsi - + LexYaccRuntime/prim-lexing.fs - + LexYaccRuntime/prim-parsing.fsi - + LexYaccRuntime/prim-parsing.fs - - Utilities\ResizeArray.fsi + + Utilities/ResizeArray.fsi - - Utilities\ResizeArray.fs + + Utilities/ResizeArray.fs - + Utilities/HashMultiMap.fsi - + Utilities/HashMultiMap.fs - - Utilities\EditDistance.fs + + Utilities/EditDistance.fs - + Utilities/TaggedCollections.fsi - + Utilities/TaggedCollections.fs - + Utilities/FlatList.fs - + Utilities/QueueList.fs - + Utilities/ildiag.fsi - + Utilities/ildiag.fs - + Utilities/illib.fs - + Utilities/filename.fsi - + Utilities/filename.fs - + Utilities/zmap.fsi - + Utilities/zmap.fs - + Utilities/zset.fsi - + Utilities/zset.fs - + Utilities/bytes.fsi - + Utilities/bytes.fs - + Utilities/lib.fs - + Utilities/ErrorResolutionHints.fs - + Utilities/InternalCollections.fsi - + Utilities/InternalCollections.fs - + Utilities/rational.fsi - + Utilities/rational.fs + + Utilities/TraceCall.fsi + + + Utilities/TraceCall.fs + + ErrorLogging/range.fsi - + ErrorLogging/range.fs - + ErrorLogging/ErrorLogger.fs - + ReferenceResolution/ReferenceResolution.fsi - + ReferenceResolution/ReferenceResolution.fs - - --lexlib Internal.Utilities.Text.Lexing - AbsIL/illex.fsl - - + AbsIL/il.fsi - + AbsIL/il.fs - + AbsIL/ilx.fsi - + AbsIL/ilx.fs - + AbsIL/ilascii.fsi - + AbsIL/ilascii.fs - + AbsIL/ilprint.fsi - + AbsIL/ilprint.fs - + AbsIL/ilmorph.fsi - + AbsIL/ilmorph.fs - + AbsIL/ilsupp.fsi - + AbsIL/ilsupp.fs @@ -283,81 +253,67 @@ AbsIL/illex.fs - + AbsIL/ilbinary.fsi - + AbsIL/ilbinary.fs - + AbsIL/ilread.fsi - + AbsIL/ilread.fs - + AbsIL/ilwritepdb.fsi - + AbsIL/ilwritepdb.fs - + AbsIL/ilwrite.fsi - + AbsIL/ilwrite.fs - + AbsIL/ilreflect.fs - + CompilerLocation/CompilerLocationUtils.fs - + PrettyNaming/PrettyNaming.fs - + ILXErase/ilxsettings.fs - + ILXErase/EraseClosures.fsi - + ILXErase/EraseClosures.fs - + ILXErase/EraseUnions.fsi - + ILXErase/EraseUnions.fs - - --lexlib Internal.Utilities.Text.Lexing - ParserAndUntypedAST/lex.fsl - - - --lexlib Internal.Utilities.Text.Lexing - ParserAndUntypedAST/pplex.fsl - - - Microsoft.FSharp.Compiler.PPParser - Microsoft.FSharp.Compiler - --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing - ParserAndUntypedAST/pppars.fsy - - + ParserAndUntypedAST/UnicodeLexing.fsi - + ParserAndUntypedAST/UnicodeLexing.fs - + ParserAndUntypedAST/layout.fsi - + ParserAndUntypedAST/layout.fs - + ParserAndUntypedAST/ast.fs @@ -366,10 +322,10 @@ ParserAndUntypedAST/pars.fs - + ParserAndUntypedAST/lexhelp.fsi - + ParserAndUntypedAST/lexhelp.fs @@ -378,255 +334,257 @@ ParserAndUntypedAST/lex.fs - + ParserAndUntypedAST/LexFilter.fs - + TypedAST/tainted.fsi - + TypedAST/tainted.fs - + TypedAST/ExtensionTyping.fsi - + TypedAST/ExtensionTyping.fs - + TypedAST/QuotationPickler.fsi - + TypedAST/QuotationPickler.fs - + TypedAST/tast.fs - + TypedAST/TcGlobals.fs - + TypedAST/TastOps.fsi - + TypedAST/TastOps.fs - + TypedAST/TastPickle.fsi - + TypedAST/TastPickle.fs - + Logic/import.fsi - + Logic/import.fs - + Logic/infos.fs - + Logic/AccessibilityLogic.fs - + Logic/AttributeChecking.fs - + Logic/InfoReader.fs - + Logic/NicePrint.fs - + Logic/AugmentWithHashCompare.fsi - + Logic/AugmentWithHashCompare.fs - + Logic/NameResolution.fsi - + Logic/NameResolution.fs - + Logic/TypeRelations.fs - + Logic/SignatureConformance.fs - + Logic/MethodOverrides.fs - + Logic/MethodCalls.fs - + Logic/PatternMatchCompilation.fsi - + Logic/PatternMatchCompilation.fs - + Logic/ConstraintSolver.fsi - + Logic/ConstraintSolver.fs - + Logic/CheckFormatStrings.fsi - + Logic/CheckFormatStrings.fs - + Logic/FindUnsolved.fs - + Logic/QuotationTranslator.fsi - + Logic/QuotationTranslator.fs - + Logic/PostInferenceChecks.fsi - + Logic/PostInferenceChecks.fs - + Logic/TypeChecker.fsi - + Logic/TypeChecker.fs - + Optimize/Optimizer.fsi - + Optimize/Optimizer.fs - + Optimize/DetupleArgs.fsi - + Optimize/DetupleArgs.fs - + Optimize/InnerLambdasToTopLevelFuncs.fsi - + Optimize/InnerLambdasToTopLevelFuncs.fs - + Optimize/LowerCallsAndSeqs.fs - - Optimize\autobox.fs + + Optimize/autobox.fs - + CodeGen/IlxGen.fsi - + CodeGen/IlxGen.fs - + Driver/CompileOps.fsi - + Driver/CompileOps.fs - + Driver/CompileOptions.fsi - + Driver/CompileOptions.fs - + Driver/fsc.fsi - + Driver/fsc.fs - + Service/IncrementalBuild.fsi - + Service/IncrementalBuild.fs - + Service/Reactor.fsi - + Service/Reactor.fs - + Service/ServiceConstants.fs - + Service/ServiceDeclarations.fsi - + Service/ServiceDeclarations.fs - + Service/Symbols.fsi - + Service/Symbols.fs - + Service/Exprs.fsi - + Service/Exprs.fs - + Service/ServiceLexing.fsi - + Service/ServiceLexing.fs - + Service/ServiceParseTreeWalk.fs - + Service/ServiceNavigation.fsi - + Service/ServiceNavigation.fs - + Service/ServiceParamInfoLocations.fsi - + Service/ServiceParamInfoLocations.fs - + Service/ServiceUntypedParse.fsi - + Service/ServiceUntypedParse.fs - + Service/service.fsi - + Service/service.fs - + Service/SimpleServices.fsi - + Service/SimpleServices.fs - + Service/fsi.fsi - + Service/fsi.fs + + diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 5a75bc0285..8e77c3e9da 100755 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -2546,7 +2546,7 @@ type BackgroundCompiler(projectCacheSize, keepAssemblyContents, keepAllBackgroun let co = { ProjectFileName = filename + ".fsproj" // Make a name that is unique in this directory. - ProjectFileNames = fas.Inputs |> List.map fst |> List.toArray + ProjectFileNames = fas.SourceFiles |> List.map fst |> List.toArray OtherOptions = otherFlags ReferencedProjects= [| |] IsIncompleteTypeCheckEnvironment = false diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index 245b0f482a..6d38b1f43c 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -418,6 +418,17 @@ let ``Project file parsing -- report files``() = for f in Directory.EnumerateFiles(@"C:\Program Files (x86)\Microsoft SDKs\F#\4.0\","*",SearchOption.AllDirectories) do printfn "File: %s" f +[] +let ``Test ProjectFileNames order for GetProjectOptionsFromScript`` () = // See #594 + let scriptPath = __SOURCE_DIRECTORY__ + @"/data/ScriptProject/Main.fsx" + let scriptSource = File.ReadAllText scriptPath + let projOpts = + checker.GetProjectOptionsFromScript(scriptPath, scriptSource) + |> Async.RunSynchronously + projOpts.ProjectFileNames + |> Array.map Path.GetFileNameWithoutExtension + |> (=) [|"BaseLib"; "Lib1"; "Lib2"; "Main"|] + |> shouldEqual true #endif diff --git a/tests/service/data/ScriptProject/BaseLib.fs b/tests/service/data/ScriptProject/BaseLib.fs new file mode 100644 index 0000000000..7d68a8615a --- /dev/null +++ b/tests/service/data/ScriptProject/BaseLib.fs @@ -0,0 +1,3 @@ +module BaseLib + +let add2 x = x + 2 \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Lib1.fsx b/tests/service/data/ScriptProject/Lib1.fsx new file mode 100644 index 0000000000..171cfef719 --- /dev/null +++ b/tests/service/data/ScriptProject/Lib1.fsx @@ -0,0 +1,2 @@ +#load "BaseLib.fs" +let add3 = BaseLib.add2 >> ((+) 1) \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Lib2.fsx b/tests/service/data/ScriptProject/Lib2.fsx new file mode 100644 index 0000000000..00c440b1d4 --- /dev/null +++ b/tests/service/data/ScriptProject/Lib2.fsx @@ -0,0 +1,2 @@ +#load "BaseLib.fs" +let add4 = BaseLib.add2 >> ((+) 2) \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Main.fsx b/tests/service/data/ScriptProject/Main.fsx new file mode 100644 index 0000000000..90086fc76d --- /dev/null +++ b/tests/service/data/ScriptProject/Main.fsx @@ -0,0 +1,4 @@ +#load "Lib1.fsx" +#load "Lib2.fsx" +Lib1.add3 5 |> printfn "%i" +Lib2.add4 5 |> printfn "%i" \ No newline at end of file From 527890f71c1b53113557f2bf8438254589dc084b Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Sat, 2 Jul 2016 16:06:13 +0200 Subject: [PATCH 4/6] Fix tests --- src/fsharp/CompileOps.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index fd28c8eebc..6548a412ea 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -5069,7 +5069,7 @@ module private ScriptPreprocessClosure = let result : LoadClosure = { SourceFiles = List.groupByFirst !sourceFiles |> List.rev - References = List.groupByFirst references + References = List.groupByFirst references |> List.rev UnresolvedReferences = unresolvedReferences Inputs = !sourceInputs NoWarns = List.groupByFirst !globalNoWarns From f11cde35321490833447bb874020eb7c3415fe81 Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Mon, 4 Jul 2016 13:25:53 +0200 Subject: [PATCH 5/6] Add more tests and improve fix --- src/fsharp/CompileOps.fs | 60 +++++++++---------- tests/service/ProjectOptionsTests.fs | 23 ++++--- .../ScriptProject/{BaseLib.fs => BaseLib1.fs} | 2 +- tests/service/data/ScriptProject/BaseLib2.fs | 3 + tests/service/data/ScriptProject/Lib1.fsx | 4 +- tests/service/data/ScriptProject/Lib2.fsx | 4 +- tests/service/data/ScriptProject/Lib3.fs | 3 + tests/service/data/ScriptProject/Lib4.fs | 3 + tests/service/data/ScriptProject/Lib5.fsx | 2 + .../ScriptProject/{Main.fsx => Main1.fsx} | 0 tests/service/data/ScriptProject/Main2.fsx | 6 ++ tests/service/data/ScriptProject/Main3.fsx | 4 ++ tests/service/data/ScriptProject/Main4.fsx | 6 ++ 13 files changed, 73 insertions(+), 47 deletions(-) rename tests/service/data/ScriptProject/{BaseLib.fs => BaseLib1.fs} (54%) create mode 100644 tests/service/data/ScriptProject/BaseLib2.fs create mode 100644 tests/service/data/ScriptProject/Lib3.fs create mode 100644 tests/service/data/ScriptProject/Lib4.fs create mode 100644 tests/service/data/ScriptProject/Lib5.fsx rename tests/service/data/ScriptProject/{Main.fsx => Main1.fsx} (100%) create mode 100644 tests/service/data/ScriptProject/Main2.fsx create mode 100644 tests/service/data/ScriptProject/Main3.fsx create mode 100644 tests/service/data/ScriptProject/Main4.fsx diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 6548a412ea..2a1bb44d82 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -4976,38 +4976,32 @@ module private ScriptPreprocessClosure = match closureDirective with | ClosedSourceFile _ as csf -> [csf] | SourceFile(filename,m,source) -> - let filename = FileSystem.GetFullPathShim(filename) - if observedSources.HaveSeen(filename) then [] - else - observedSources.SetSeen(filename) - - let errors = ref [] - let warnings = ref [] - let errorLogger = - { new ErrorLogger("FindClosure") with - member x.ErrorSinkImpl(e) = errors := e :: !errors - member x.WarnSinkImpl(e) = warnings := e :: !warnings - member x.ErrorCount = (!errors).Length } - - use unwindEL = PushErrorLoggerPhaseUntilUnwind (fun _ -> errorLogger) - let pathOfMetaCommandSource = Path.GetDirectoryName(filename) - match ParseScriptText(filename,source,!tcConfig,codeContext,lexResourceManager,errorLogger) with - | Some(input) -> - let tcConfigResult, noWarns = ApplyMetaCommandsFromInputToTcConfigAndGatherNoWarn !tcConfig (input,pathOfMetaCommandSource) - tcConfig := tcConfigResult + let errors = ref [] + let warnings = ref [] + let errorLogger = + { new ErrorLogger("FindClosure") with + member x.ErrorSinkImpl(e) = errors := e :: !errors + member x.WarnSinkImpl(e) = warnings := e :: !warnings + member x.ErrorCount = (!errors).Length } + + use unwindEL = PushErrorLoggerPhaseUntilUnwind (fun _ -> errorLogger) + let pathOfMetaCommandSource = Path.GetDirectoryName(filename) + match ParseScriptText(filename,source,!tcConfig,codeContext,lexResourceManager,errorLogger) with + | Some(input) -> + let tcConfigResult, noWarns = ApplyMetaCommandsFromInputToTcConfigAndGatherNoWarn !tcConfig (input,pathOfMetaCommandSource) + tcConfig := tcConfigResult - let AddFileIfNotSeen(m,filename) = - if observedSources.HaveSeen(filename) then [] - else - if IsScript(filename) then SourceFileOfFilename(filename,m,tcConfigResult.inputCodePage) - else - observedSources.SetSeen(filename) - [ClosedSourceFile(filename,m,None,[],[],[])] // Don't traverse into .fs leafs. + let AddFileIfNotSeen(m,filename) = + if observedSources.HaveSeen(filename) then [] + else + observedSources.SetSeen(filename) + if IsScript(filename) then SourceFileOfFilename(filename,m,tcConfigResult.inputCodePage) + else [ClosedSourceFile(filename,m,None,[],[],[])] // Don't traverse into .fs leafs. - let loadedSources = (!tcConfig).GetAvailableLoadedSources() |> List.rev |> List.map AddFileIfNotSeen |> List.concat - (loadedSources |> List.map FindClosure |> List.concat) - @ [ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns)] - | None -> [ClosedSourceFile(filename,m,None,!errors,!warnings,[])] + let loadedSources = (!tcConfig).GetAvailableLoadedSources() |> List.map AddFileIfNotSeen |> List.concat + (loadedSources |> List.map FindClosure |> List.concat) + @ [ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns)] + | None -> [ClosedSourceFile(filename,m,None,!errors,!warnings,[])] closureDirectives |> List.map FindClosure |> List.concat, !tcConfig @@ -5025,7 +5019,7 @@ module private ScriptPreprocessClosure = let sourceFiles = ref [] let sourceInputs = ref [] let globalNoWarns = ref [] - for directive in closureDirectives do + for directive in List.rev closureDirectives do match directive with | ClosedSourceFile(filename,m,input,_,_,noWarns) -> let filename = FileSystem.GetFullPathShim(filename) @@ -5068,8 +5062,8 @@ module private ScriptPreprocessClosure = let rootWarnings = rootWarnings |> List.filter isRootRange let result : LoadClosure = - { SourceFiles = List.groupByFirst !sourceFiles |> List.rev - References = List.groupByFirst references |> List.rev + { SourceFiles = List.groupByFirst !sourceFiles + References = List.groupByFirst references UnresolvedReferences = unresolvedReferences Inputs = !sourceInputs NoWarns = List.groupByFirst !globalNoWarns diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index 6d38b1f43c..d56d9de02c 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -420,15 +420,20 @@ let ``Project file parsing -- report files``() = [] let ``Test ProjectFileNames order for GetProjectOptionsFromScript`` () = // See #594 - let scriptPath = __SOURCE_DIRECTORY__ + @"/data/ScriptProject/Main.fsx" - let scriptSource = File.ReadAllText scriptPath - let projOpts = - checker.GetProjectOptionsFromScript(scriptPath, scriptSource) - |> Async.RunSynchronously - projOpts.ProjectFileNames - |> Array.map Path.GetFileNameWithoutExtension - |> (=) [|"BaseLib"; "Lib1"; "Lib2"; "Main"|] - |> shouldEqual true + let test scriptName expected = + let scriptPath = __SOURCE_DIRECTORY__ + @"/data/ScriptProject/" + scriptName + ".fsx" + let scriptSource = File.ReadAllText scriptPath + let projOpts = + checker.GetProjectOptionsFromScript(scriptPath, scriptSource) + |> Async.RunSynchronously + projOpts.ProjectFileNames + |> Array.map Path.GetFileNameWithoutExtension + |> (=) expected + |> shouldEqual true + test "Main1" [|"BaseLib1"; "Lib1"; "Lib2"; "Main1"|] + test "Main2" [|"BaseLib1"; "Lib1"; "Lib2"; "Lib3"; "Main2"|] + test "Main3" [|"Lib3"; "Lib4"; "Main3"|] + test "Main4" [|"BaseLib2"; "Lib5"; "BaseLib1"; "Lib1"; "Lib2"; "Main4"|] #endif diff --git a/tests/service/data/ScriptProject/BaseLib.fs b/tests/service/data/ScriptProject/BaseLib1.fs similarity index 54% rename from tests/service/data/ScriptProject/BaseLib.fs rename to tests/service/data/ScriptProject/BaseLib1.fs index 7d68a8615a..d3be7d2a54 100644 --- a/tests/service/data/ScriptProject/BaseLib.fs +++ b/tests/service/data/ScriptProject/BaseLib1.fs @@ -1,3 +1,3 @@ -module BaseLib +module BaseLib1 let add2 x = x + 2 \ No newline at end of file diff --git a/tests/service/data/ScriptProject/BaseLib2.fs b/tests/service/data/ScriptProject/BaseLib2.fs new file mode 100644 index 0000000000..3277193dd5 --- /dev/null +++ b/tests/service/data/ScriptProject/BaseLib2.fs @@ -0,0 +1,3 @@ +module BaseLib2 + +let add10 x = x + 10 \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Lib1.fsx b/tests/service/data/ScriptProject/Lib1.fsx index 171cfef719..53833dc65c 100644 --- a/tests/service/data/ScriptProject/Lib1.fsx +++ b/tests/service/data/ScriptProject/Lib1.fsx @@ -1,2 +1,2 @@ -#load "BaseLib.fs" -let add3 = BaseLib.add2 >> ((+) 1) \ No newline at end of file +#load "BaseLib1.fs" +let add3 = BaseLib1.add2 >> ((+) 1) \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Lib2.fsx b/tests/service/data/ScriptProject/Lib2.fsx index 00c440b1d4..7f6261cf09 100644 --- a/tests/service/data/ScriptProject/Lib2.fsx +++ b/tests/service/data/ScriptProject/Lib2.fsx @@ -1,2 +1,2 @@ -#load "BaseLib.fs" -let add4 = BaseLib.add2 >> ((+) 2) \ No newline at end of file +#load "BaseLib1.fs" +let add4 = BaseLib1.add2 >> ((+) 2) \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Lib3.fs b/tests/service/data/ScriptProject/Lib3.fs new file mode 100644 index 0000000000..8524ace259 --- /dev/null +++ b/tests/service/data/ScriptProject/Lib3.fs @@ -0,0 +1,3 @@ +module Lib3 + +let add6 = ((+) 6) \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Lib4.fs b/tests/service/data/ScriptProject/Lib4.fs new file mode 100644 index 0000000000..108bfbc45d --- /dev/null +++ b/tests/service/data/ScriptProject/Lib4.fs @@ -0,0 +1,3 @@ +module Lib4 + +let add8 = ((+) 8) \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Lib5.fsx b/tests/service/data/ScriptProject/Lib5.fsx new file mode 100644 index 0000000000..ec2ecacb18 --- /dev/null +++ b/tests/service/data/ScriptProject/Lib5.fsx @@ -0,0 +1,2 @@ +#load "BaseLib2.fs" +let add12 = BaseLib2.add10 >> ((+) 2) \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Main.fsx b/tests/service/data/ScriptProject/Main1.fsx similarity index 100% rename from tests/service/data/ScriptProject/Main.fsx rename to tests/service/data/ScriptProject/Main1.fsx diff --git a/tests/service/data/ScriptProject/Main2.fsx b/tests/service/data/ScriptProject/Main2.fsx new file mode 100644 index 0000000000..906fd5d19c --- /dev/null +++ b/tests/service/data/ScriptProject/Main2.fsx @@ -0,0 +1,6 @@ +#load "Lib1.fsx" +#load "Lib2.fsx" +#load "Lib3.fs" +Lib1.add3 5 |> printfn "%i" +Lib2.add4 5 |> printfn "%i" +Lib3.add6 5 |> printfn "%i" \ No newline at end of file diff --git a/tests/service/data/ScriptProject/Main3.fsx b/tests/service/data/ScriptProject/Main3.fsx new file mode 100644 index 0000000000..8df731bd95 --- /dev/null +++ b/tests/service/data/ScriptProject/Main3.fsx @@ -0,0 +1,4 @@ +#load "Lib3.fs" +#load "Lib4.fs" +Lib3.add6 5 |> printfn "%i" +Lib4.add8 5 |> printfn "%i" diff --git a/tests/service/data/ScriptProject/Main4.fsx b/tests/service/data/ScriptProject/Main4.fsx new file mode 100644 index 0000000000..6da860748f --- /dev/null +++ b/tests/service/data/ScriptProject/Main4.fsx @@ -0,0 +1,6 @@ +#load "Lib5.fsx" +#load "Lib1.fsx" +#load "Lib2.fsx" +Lib1.add3 5 |> printfn "%i" +Lib2.add4 5 |> printfn "%i" +Lib5.add12 5 |> printfn "%i" From d06a42482eb231a787eae97e25250550e326ece9 Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Thu, 7 Jul 2016 14:10:58 +0200 Subject: [PATCH 6/6] Fix FSharp.Compiler.Service.fsproj --- .../FSharp.Compiler.Service.fsproj | 500 ++++++++++-------- 1 file changed, 271 insertions(+), 229 deletions(-) diff --git a/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj index c3be2ff7d3..b8558fe82b 100644 --- a/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj +++ b/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj @@ -1,250 +1,280 @@ - + + - - FSharp.Compiler.Service - Debug AnyCPU - - 2e4d67b4-522d-4cf7-97e4-ba940f0b18f3 - Library + FSharp.Compiler.Service + $(NoWarn);44;62;9 + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} + true v4.5 - - - 4.4.0.0 + 0x06800000 + $(OtherFlags) /warnon:1182 + true + true + $(OtherFlags) --times + $(NoWarn);69;65;54;61;75 + true + ..\..\..\bin\$(TargetFrameworkVersion) $(OutputPath)$(AssemblyName).xml + $(DefineConstants);CROSS_PLATFORM_COMPILER + $(DefineConstants);FX_ATLEAST_45 + $(DefineConstants);FX_NO_GENERIC_WEAKREFERENCE + $(DefineConstants);FX_ATLEAST_40 + $(DefineConstants);BE_SECURITY_TRANSPARENT + $(DefineConstants);TYPE_PROVIDER_SECURITY + $(DefineConstants);EXTENSIBLE_DUMPER + $(DefineConstants);INCLUDE_METADATA_WRITER + $(DefineConstants);COMPILER + $(DefineConstants);ENABLE_MONO_SUPPORT + $(DefineConstants);FX_MSBUILDRESOLVER_RUNTIMELIKE + $(DefineConstants);FX_LCIDFROMCODEPAGE + $(DefineConstants);FX_RESX_RESOURCE_READER + $(DefineConstants);FX_RESIDENT_COMPILER + $(DefineConstants);SHADOW_COPY_REFERENCES + $(DefineConstants);EXTENSIONTYPING + $(DefineConstants);COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_4_0_0 + $(DefineConstants);COMPILER_SERVICE + $(DefineConstants);NO_STRONG_NAMES + $(DefineConstants);TRACE + 4.4.0.0 + $(MSBuildProjectDirectory)\..\..\..\ + + + $(SolutionDir)lib\bootstrap\4.0 + $(SolutionDir)packages\FsSrGen\lib\net46 + $(FsLexYaccPath) + $(FsLexYaccPath) + fslex.exe + fsyacc.exe + false + + - - + DEBUG; $(DefineConstants) false - - - DEBUG $(DefineConstants) - + $(OtherFlags) --no-jit-optimize --jit-tracking + ..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.xml AnyCPU true - $(OtherFlags) --no-jit-optimize --jit-tracking - - true - - - - + ..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.xml AnyCPU true - - - - - - - - - - - - - - - - - - - - - - - - - - False - - - - - + AssemblyInfo/assemblyinfo.FSharp.Compiler.Service.dll.fs - + AssemblyInfo/assemblyinfo.shared.fs - - - + + FSComp.txt + + + FSIstrings.txt + + + + FSStrings.resx - + + --lexlib Internal.Utilities.Text.Lexing + lex.fsl + + + --lexlib Internal.Utilities.Text.Lexing + illex.fsl + + + Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser + Microsoft.FSharp.Compiler.AbstractIL + --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing + ilpars.fsy + + + Microsoft.FSharp.Compiler.Parser + Microsoft.FSharp.Compiler + --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing + pars.fsy + + Reshaped/reshapedreflection.fs - + Reshaped/reshapedmsbuild.fs - + ErrorText/sformat.fsi - + ErrorText/sformat.fs - + ErrorText/sr.fsi - + ErrorText/sr.fs - + LexYaccRuntime/prim-lexing.fsi - + LexYaccRuntime/prim-lexing.fs - + LexYaccRuntime/prim-parsing.fsi - + LexYaccRuntime/prim-parsing.fs - - Utilities/ResizeArray.fsi + + Utilities\ResizeArray.fsi - - Utilities/ResizeArray.fs + + Utilities\ResizeArray.fs - + Utilities/HashMultiMap.fsi - + Utilities/HashMultiMap.fs - - Utilities/EditDistance.fs + + Utilities\EditDistance.fs - + Utilities/TaggedCollections.fsi - + Utilities/TaggedCollections.fs - + Utilities/FlatList.fs - + Utilities/QueueList.fs - + Utilities/ildiag.fsi - + Utilities/ildiag.fs - + Utilities/illib.fs - + Utilities/filename.fsi - + Utilities/filename.fs - + Utilities/zmap.fsi - + Utilities/zmap.fs - + Utilities/zset.fsi - + Utilities/zset.fs - + Utilities/bytes.fsi - + Utilities/bytes.fs - + Utilities/lib.fs - + Utilities/ErrorResolutionHints.fs - + Utilities/InternalCollections.fsi - + Utilities/InternalCollections.fs - + Utilities/rational.fsi - + Utilities/rational.fs - - Utilities/TraceCall.fsi - - - Utilities/TraceCall.fs - - ErrorLogging/range.fsi - + ErrorLogging/range.fs - + ErrorLogging/ErrorLogger.fs - + ReferenceResolution/ReferenceResolution.fsi - + ReferenceResolution/ReferenceResolution.fs - + + --lexlib Internal.Utilities.Text.Lexing + AbsIL/illex.fsl + + AbsIL/il.fsi - + AbsIL/il.fs - + AbsIL/ilx.fsi - + AbsIL/ilx.fs - + AbsIL/ilascii.fsi - + AbsIL/ilascii.fs - + AbsIL/ilprint.fsi - + AbsIL/ilprint.fs - + AbsIL/ilmorph.fsi - + AbsIL/ilmorph.fs - + AbsIL/ilsupp.fsi - + AbsIL/ilsupp.fs @@ -253,67 +283,81 @@ AbsIL/illex.fs - + AbsIL/ilbinary.fsi - + AbsIL/ilbinary.fs - + AbsIL/ilread.fsi - + AbsIL/ilread.fs - + AbsIL/ilwritepdb.fsi - + AbsIL/ilwritepdb.fs - + AbsIL/ilwrite.fsi - + AbsIL/ilwrite.fs - + AbsIL/ilreflect.fs - + CompilerLocation/CompilerLocationUtils.fs - + PrettyNaming/PrettyNaming.fs - + ILXErase/ilxsettings.fs - + ILXErase/EraseClosures.fsi - + ILXErase/EraseClosures.fs - + ILXErase/EraseUnions.fsi - + ILXErase/EraseUnions.fs - + + --lexlib Internal.Utilities.Text.Lexing + ParserAndUntypedAST/lex.fsl + + + --lexlib Internal.Utilities.Text.Lexing + ParserAndUntypedAST/pplex.fsl + + + Microsoft.FSharp.Compiler.PPParser + Microsoft.FSharp.Compiler + --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing + ParserAndUntypedAST/pppars.fsy + + ParserAndUntypedAST/UnicodeLexing.fsi - + ParserAndUntypedAST/UnicodeLexing.fs - + ParserAndUntypedAST/layout.fsi - + ParserAndUntypedAST/layout.fs - + ParserAndUntypedAST/ast.fs @@ -322,10 +366,10 @@ ParserAndUntypedAST/pars.fs - + ParserAndUntypedAST/lexhelp.fsi - + ParserAndUntypedAST/lexhelp.fs @@ -334,257 +378,255 @@ ParserAndUntypedAST/lex.fs - + ParserAndUntypedAST/LexFilter.fs - + TypedAST/tainted.fsi - + TypedAST/tainted.fs - + TypedAST/ExtensionTyping.fsi - + TypedAST/ExtensionTyping.fs - + TypedAST/QuotationPickler.fsi - + TypedAST/QuotationPickler.fs - + TypedAST/tast.fs - + TypedAST/TcGlobals.fs - + TypedAST/TastOps.fsi - + TypedAST/TastOps.fs - + TypedAST/TastPickle.fsi - + TypedAST/TastPickle.fs - + Logic/import.fsi - + Logic/import.fs - + Logic/infos.fs - + Logic/AccessibilityLogic.fs - + Logic/AttributeChecking.fs - + Logic/InfoReader.fs - + Logic/NicePrint.fs - + Logic/AugmentWithHashCompare.fsi - + Logic/AugmentWithHashCompare.fs - + Logic/NameResolution.fsi - + Logic/NameResolution.fs - + Logic/TypeRelations.fs - + Logic/SignatureConformance.fs - + Logic/MethodOverrides.fs - + Logic/MethodCalls.fs - + Logic/PatternMatchCompilation.fsi - + Logic/PatternMatchCompilation.fs - + Logic/ConstraintSolver.fsi - + Logic/ConstraintSolver.fs - + Logic/CheckFormatStrings.fsi - + Logic/CheckFormatStrings.fs - + Logic/FindUnsolved.fs - + Logic/QuotationTranslator.fsi - + Logic/QuotationTranslator.fs - + Logic/PostInferenceChecks.fsi - + Logic/PostInferenceChecks.fs - + Logic/TypeChecker.fsi - + Logic/TypeChecker.fs - + Optimize/Optimizer.fsi - + Optimize/Optimizer.fs - + Optimize/DetupleArgs.fsi - + Optimize/DetupleArgs.fs - + Optimize/InnerLambdasToTopLevelFuncs.fsi - + Optimize/InnerLambdasToTopLevelFuncs.fs - + Optimize/LowerCallsAndSeqs.fs - - Optimize/autobox.fs + + Optimize\autobox.fs - + CodeGen/IlxGen.fsi - + CodeGen/IlxGen.fs - + Driver/CompileOps.fsi - + Driver/CompileOps.fs - + Driver/CompileOptions.fsi - + Driver/CompileOptions.fs - + Driver/fsc.fsi - + Driver/fsc.fs - + Service/IncrementalBuild.fsi - + Service/IncrementalBuild.fs - + Service/Reactor.fsi - + Service/Reactor.fs - + Service/ServiceConstants.fs - + Service/ServiceDeclarations.fsi - + Service/ServiceDeclarations.fs - + Service/Symbols.fsi - + Service/Symbols.fs - + Service/Exprs.fsi - + Service/Exprs.fs - + Service/ServiceLexing.fsi - + Service/ServiceLexing.fs - + Service/ServiceParseTreeWalk.fs - + Service/ServiceNavigation.fsi - + Service/ServiceNavigation.fs - + Service/ServiceParamInfoLocations.fsi - + Service/ServiceParamInfoLocations.fs - + Service/ServiceUntypedParse.fsi - + Service/ServiceUntypedParse.fs - + Service/service.fsi - + Service/service.fs - + Service/SimpleServices.fsi - + Service/SimpleServices.fs - + Service/fsi.fsi - + Service/fsi.fs - -