From d36d2673853fb8e30d5033b5b91f151654635915 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 19 Jan 2016 15:31:53 +0000 Subject: [PATCH] Integrate FCS API: Other changes to vsintegration\src --- vsintegration/src/Deployment.sln | 4 +- .../source.extension.vsixmanifest | 2 +- .../src/unittests/TestLib.LanguageService.fs | 30 +- .../src/unittests/TestLib.ProjectSystem.fs | 247 +++++----- vsintegration/src/unittests/TestLib.Utils.fs | 4 + vsintegration/src/unittests/Tests.BaseLine.fs | 7 +- vsintegration/src/unittests/Tests.Build.fs | 2 +- .../unittests/Tests.InternalCollections.fs | 6 +- .../Tests.LanguageService.Colorizer.fs | 31 +- .../Tests.LanguageService.Completion.fs | 123 ++--- .../Tests.LanguageService.ErrorList.fs | 41 +- .../Tests.LanguageService.ErrorRecovery.fs | 26 +- .../Tests.LanguageService.F1Keyword.fs | 30 +- .../Tests.LanguageService.General.fs | 81 ++-- .../Tests.LanguageService.GotoDefinition.fs | 67 ++- .../Tests.LanguageService.IncrementalBuild.fs | 422 +++++++++--------- .../Tests.LanguageService.NavigationBar.fs | 215 +++++---- .../Tests.LanguageService.ParameterInfo.fs | 294 ++++++------ .../Tests.LanguageService.QuickInfo.fs | 98 ++-- .../Tests.LanguageService.QuickParse.fs | 2 +- .../unittests/Tests.LanguageService.Script.fs | 54 +-- .../Tests.LanguageService.Squiggles.fs | 64 +-- .../Tests.LanguageService.TimeStamp.fs | 28 +- .../unittests/Tests.ProjectSystem.Configs.fs | 2 +- .../Tests.ProjectSystem.Miscellaneous.fs | 2 +- .../Tests.ProjectSystem.MultiTargeting.fs | 2 +- .../unittests/Tests.ProjectSystem.Project.fs | 2 +- .../Tests.ProjectSystem.ProjectItems.fs | 2 +- .../Tests.ProjectSystem.References.fs | 2 +- .../Tests.ProjectSystem.RoundTrip.fs | 2 +- .../unittests/Tests.ProjectSystem.UpToDate.fs | 2 +- .../src/unittests/Tests.TaskReporter.fs | 2 +- .../src/unittests/Tests.TypeProvidersImpl.fs | 4 +- vsintegration/src/unittests/Tests.Watson.fs | 97 ++-- .../src/unittests/Tests.XmlDocComments.fs | 4 +- vsintegration/src/unittests/Unittests.fsproj | 37 +- .../FsPkgs/FSharp.Editor/BraceCompletion.fs | 1 - .../vs/FsPkgs/FSharp.Editor/SmartIndent.fs | 2 +- .../vs/FsPkgs/FSharp.Editor/TokenContext.fs | 3 +- .../vs/FsPkgs/FSharp.Project/FS/Project.fs | 120 ++--- .../FSharp.Project/FS/ProjectSystem.fsproj | 19 +- .../PropertyPages/ApplicationPropPage.vb | 11 +- .../FsPkgs/FSharp.VS.FSI/FSHarp.VS.FSI.fsproj | 189 ++++---- vsintegration/src/vs/FsPkgs/common.fs | 7 - 44 files changed, 1098 insertions(+), 1292 deletions(-) delete mode 100644 vsintegration/src/vs/FsPkgs/common.fs diff --git a/vsintegration/src/Deployment.sln b/vsintegration/src/Deployment.sln index f322743e9..f7021dae2 100644 --- a/vsintegration/src/Deployment.sln +++ b/vsintegration/src/Deployment.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22512.0 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnableOpenSource", "deployment\EnableOpenSource\EnableOpenSource.csproj", "{4D7BE558-E6BF-44DA-8CE2-46AA6E0DC2E7}" EndProject @@ -27,7 +27,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WDExpressDeployTemplates", EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler", "..\..\src\fsharp\FSharp.Compiler\FSharp.Compiler.fsproj", "{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSHarp.VS.FSI", "vs\FsPkgs\FSharp.VS.FSI\FSHarp.VS.FSI.fsproj", "{991DCF75-C2EB-42B6-9A0D-AA1D2409D519}" +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSHarp.VS.FSI", "vs\FsPkgs\FSharp.VS.FSI\FSharp.VS.FSI.fsproj", "{991DCF75-C2EB-42B6-9A0D-AA1D2409D519}" EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Server.Shared", "..\..\src\fsharp\FSharp.Compiler.Server.Shared\FSharp.Compiler.Server.Shared.fsproj", "{D5870CF0-ED51-4CBC-B3D7-6F56DA84AC06}" EndProject diff --git a/vsintegration/src/deployment/EnableOpenSource/source.extension.vsixmanifest b/vsintegration/src/deployment/EnableOpenSource/source.extension.vsixmanifest index 9c1b31259..2e90cf538 100644 --- a/vsintegration/src/deployment/EnableOpenSource/source.extension.vsixmanifest +++ b/vsintegration/src/deployment/EnableOpenSource/source.extension.vsixmanifest @@ -15,7 +15,7 @@ - + diff --git a/vsintegration/src/unittests/TestLib.LanguageService.fs b/vsintegration/src/unittests/TestLib.LanguageService.fs index 9a8361406..57bed0a00 100644 --- a/vsintegration/src/unittests/TestLib.LanguageService.fs +++ b/vsintegration/src/unittests/TestLib.LanguageService.fs @@ -151,18 +151,18 @@ type internal Helper = type internal GlobalParseAndTypeCheckCounter private(initialParseCount:int, initialTypeCheckCount:int, initialEventNum:int, vs) = static member StartNew(vs) = TakeCoffeeBreak(vs) - let n = IncrementalFSharpBuild.GetCurrentIncrementalBuildEventNum() - new GlobalParseAndTypeCheckCounter(InteractiveChecker.GlobalForegroundParseCountStatistic, InteractiveChecker.GlobalForegroundTypeCheckCountStatistic, n, vs) + let n = IncrementalBuilderEventTesting.GetCurrentIncrementalBuildEventNum() + new GlobalParseAndTypeCheckCounter(FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic, n, vs) member private this.GetEvents() = TakeCoffeeBreak(vs) - let n = IncrementalFSharpBuild.GetCurrentIncrementalBuildEventNum() - IncrementalFSharpBuild.GetMostRecentIncrementalBuildEvents(n-initialEventNum) - member private this.SawIBDeleted() = - this.GetEvents() |> List.exists (function | IncrementalFSharpBuild.IBEDeleted -> true | _ -> false) + let n = IncrementalBuilderEventTesting.GetCurrentIncrementalBuildEventNum() + IncrementalBuilderEventTesting.GetMostRecentIncrementalBuildEvents(n-initialEventNum) + member private this.SawIBCreated() = + this.GetEvents() |> List.exists (function | IncrementalBuilderEventTesting.IBECreated -> true | _ -> false) member private this.GetParsedFilesSet() = - this.GetEvents() |> List.choose (function | IncrementalFSharpBuild.IBEParsed(file) -> Some(file) | _ -> None) |> set + this.GetEvents() |> List.choose (function | IncrementalBuilderEventTesting.IBEParsed(file) -> Some(file) | _ -> None) |> set member private this.GetTypeCheckedFilesSet() = - this.GetEvents() |> List.choose (function | IncrementalFSharpBuild.IBETypechecked(file) -> Some(file) | _ -> None) |> set + this.GetEvents() |> List.choose (function | IncrementalBuilderEventTesting.IBETypechecked(file) -> Some(file) | _ -> None) |> set member this.AssertExactly(expectedParses, expectedTypeChecks) = let actualParses = this.GetParsedFilesSet().Count let actualTypeChecks = this.GetTypeCheckedFilesSet().Count @@ -176,19 +176,19 @@ type internal GlobalParseAndTypeCheckCounter private(initialParseCount:int, init false) member this.AssertExactly((aap,expectedParsedFiles) : string option * list, (aat,expectedTypeCheckedFiles) : string option * list) = this.AssertExactly((aap,expectedParsedFiles), (aat,expectedTypeCheckedFiles), false) - member this.AssertExactly((aap,expectedParsedFiles) : string option * list, (aat,expectedTypeCheckedFiles) : string option * list, expectDelete : bool) = + member this.AssertExactly((aap,expectedParsedFiles) : string option * list, (aat,expectedTypeCheckedFiles) : string option * list, expectCreate : bool) = let p = match aap with | Some(aap) -> aap :: (expectedParsedFiles |> List.map GetNameOfOpenFile) | _ -> (expectedParsedFiles |> List.map GetNameOfOpenFile) let t = match aat with | Some(aat) -> aat :: (expectedTypeCheckedFiles |> List.map GetNameOfOpenFile) | _ -> (expectedTypeCheckedFiles |> List.map GetNameOfOpenFile) - this.AssertExactly(p.Length, t.Length, p, t, expectDelete) - member private this.AssertExactly(expectedParses, expectedTypeChecks, expectedParsedFiles : list, expectedTypeCheckedFiles : list, expectDelete : bool) = - let note,ok = if expectDelete then - if this.SawIBDeleted() then ("The incremental builder was deleted, as expected",true) else ("The incremental builder was NOT deleted, even though we expected it to be",false) + this.AssertExactly(p.Length, t.Length, p, t, expectCreate) + member private this.AssertExactly(expectedParses, expectedTypeChecks, expectedParsedFiles : list, expectedTypeCheckedFiles : list, expectCreate : bool) = + let note,ok = if expectCreate then + if this.SawIBCreated() then ("The incremental builder was created, as expected",true) else ("The incremental builder was NOT deleted and recreated, even though we expected it to be",false) else - if this.SawIBDeleted() then ("The incremental builder was UNEXPECTEDLY deleted",false) else ("",true) + if this.SawIBCreated() then ("The incremental builder was UNEXPECTEDLY deleted",false) else ("",true) let actualParsedFiles = this.GetParsedFilesSet() let actualTypeCheckedFiles = this.GetTypeCheckedFilesSet() let actualParses = actualParsedFiles.Count @@ -242,7 +242,7 @@ type LanguageServiceBaseTests() = let mutable defaultVS : VisualStudio = Unchecked.defaultof<_> let mutable currentVS : VisualStudio = Unchecked.defaultof<_> (* VsOps is internal, but this type needs to be public *) - let mutable ops : VsOps = fst (Models.MSBuild()) + let mutable ops = BuiltMSBuildTestFlavour() let testStopwatch = new Stopwatch() (* Timings ----------------------------------------------------------------------------- *) diff --git a/vsintegration/src/unittests/TestLib.ProjectSystem.fs b/vsintegration/src/unittests/TestLib.ProjectSystem.fs index 491298f3c..e0ee51fe9 100644 --- a/vsintegration/src/unittests/TestLib.ProjectSystem.fs +++ b/vsintegration/src/unittests/TestLib.ProjectSystem.fs @@ -155,12 +155,12 @@ type TheTests() = // ensure that vs-style encoding is off p - static member internal CreateProjectWithUTF8Output(filename : string) = + static member internal CreateProjectWithUTF8Output(filename: string) = let sp, configChangeNotifier = VsMocks.MakeMockServiceProviderAndConfigChangeNotifier() let p = TheTests.CreateProject(filename, "true", configChangeNotifier, sp) p - static member internal FindNodeWithCaption(project : UnitTestingFSharpProjectNode, caption) = + static member internal FindNodeWithCaption(project: UnitTestingFSharpProjectNode, caption) = let node = project.FirstChild let rec TryFind (n : HierarchyNode) = if n = null then None @@ -172,7 +172,7 @@ type TheTests() = | Some(x) -> x | None -> failwithf "did not find node with caption %s" caption - static member MoveDown(node : HierarchyNode) = + static member MoveDown(node: HierarchyNode) = match node with | :? FSharpFileNode | :? FSharpFolderNode -> @@ -183,7 +183,7 @@ type TheTests() = | _ -> failwith "unexpected node type" () - static member MoveUp(node : HierarchyNode) = + static member MoveUp(node: HierarchyNode) = match node with | :? FSharpFileNode | :? FSharpFolderNode -> @@ -229,16 +229,18 @@ type TheTests() = TheTests.FsprojTextWithProjectReferencesAndOtherFlags(compileItems, references, [], otherflags, other) static member public FsprojTextWithProjectReferences(compileItems : string list, references : string list, projectReferences : string list, other : string) = - let vsops = fst (Salsa.Salsa.Models.MSBuild()) + let vsops = Salsa.Salsa.BuiltMSBuildTestFlavour() let references = references |> List.map (fun r->r,false) - let text = vsops.CreatePhysicalProjectFileInMemory [for i in compileItems -> (i,DefaultBuildActionOfFilename i, None)] references projectReferences [] [] null null other null + let items = [for i in compileItems -> (i,DefaultBuildActionOfFilename i, None)] + let text = vsops.CreatePhysicalProjectFileInMemory(items, references, projectReferences, [], [], null, null, other, null) printfn "%s" text text static member public FsprojTextWithProjectReferencesAndOtherFlags(compileItems : string list, references : string list, projectReferences : string list, otherflags : string, other : string, targetFramework : string) = - let vsops = fst (Salsa.Salsa.Models.MSBuild()) + let vsops = Salsa.Salsa.BuiltMSBuildTestFlavour() let references = references |> List.map (fun r->r,false) - let text = vsops.CreatePhysicalProjectFileInMemory [for i in compileItems -> (i,DefaultBuildActionOfFilename i, None)] references projectReferences [] [] null otherflags other targetFramework + let items = [for i in compileItems -> (i,DefaultBuildActionOfFilename i, None)] + let text = vsops.CreatePhysicalProjectFileInMemory(items, references, projectReferences, [], [], null, otherflags, other, targetFramework) printfn "%s" text text @@ -565,50 +567,6 @@ and (*type*) MSBuildItems = match this with | MSBuildItems(l) -> l -(* -when first click to start drag - public override int GetDropInfo(out uint pdwOKEffects, out IOleDataObject ppDataObject, out IDropSource ppDropSource) -ensure pdwOKEffects are right and return S_OK - -when drag onto new entity - public override int DragEnter(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect) -ensure is same thing(pDataObj, itemid) being dragged, pdwEffect is properly updated - -not sure how differs from DragEnter... - public override int DragOver(uint grfKeyState, uint itemid, ref uint pdwEffect) -ensure right pdwEffect - -at end of drag... - public override int OnBeforeDropNotify(IOleDataObject o, uint dwEffect, out int fCancelDrop) -can prompt to save dirty dragged items... nothing to verify? - - public override int OnDropNotify(int fDropped, uint dwEffects) -unsure... - - public override int Drop(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect) -unsure... - - /*internal, but public for FSharp.Project.dll*/ public DropDataType ProcessSelectionDataObject(IOleDataObject dataObject, HierarchyNode targetNode) -called by Drop, does the actual action of adding dropped files to new location - - public override int DragLeave() -nothing to ensure, but call if leave hierarchy or drag is canceled or finishes - - -called at various times: - public /*protected, but public for FSharp.Project.dll*/ override HierarchyNode GetDragTargetHandlerNode() -ensure FSharpFileNode does right thing, whatever that may be, same for folder, project - - /*internal, but public for FSharp.Project.dll*/ public static DropDataType QueryDropDataType(IOleDataObject pDataObject) -maybe ref (shortcut) versus value (real file/dir on disk)? - - /*internal, but public for FSharp.Project.dll*/ public DropEffect QueryDropEffect(DropDataType dropDataType, uint grfKeyState) -given keyboard and object type, return right effect - - public /*protected internal, but public for FSharp.Project.dll*/ virtual bool CanTargetNodeAcceptDrop(uint itemId) -can't drop onto 'references' -*) - module LanguageServiceExtension = open UnitTests.TestLib.LanguageService open Salsa.Salsa @@ -619,13 +577,20 @@ module LanguageServiceExtension = member this.Project with get() = proj and set(x) = proj <- x member this.CreateProjectHookIsEnabled with get() = createProjectHookIsEnabled and set(x) = createProjectHookIsEnabled <- x - let internal ProjectSystem = - let msbuild,hooks = Models.MSBuild() + /// A test flavour - this layers additional behaviour over the BuiltMSBuildTestFlavour + /// to exercise the unit-testable versions of the classes in FSharp.ProjectSystem.FSharp. + /// For example, when a CreateProject call is made, a UnitTestingFSharpProjectNode is + /// created (in addition to the actions performed via the MSBuild layer). + // + // NOTE: The "BehaviourHooks" way of injecting functionality seems awkward. + type internal ProjectSystemTestFlavour() = + let msbuild = BuiltMSBuildTestFlavour() + let hooks = msbuild.BehaviourHooks let projectDict = new Dictionary() - { msbuild with - OutOfConeFilesAreAddedAsLinks=true; - SupportsOutputWindowPane=true; - AddAssemblyReference=(fun (project, assem, specificVersion) -> + interface VsOps with + member ops.OutOfConeFilesAreAddedAsLinks=true + member ops.SupportsOutputWindowPane=true + member ops.AddAssemblyReference(project, assem, specificVersion) = let projInfo = projectDict.[project] let referencesFolder = projInfo.Project.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) :?> ReferenceContainerNode let assem = @@ -652,66 +617,134 @@ module LanguageServiceExtension = projInfo.CreateProjectHookIsEnabled <- false msbuild.AddAssemblyReference(project, node.Url, specificVersion) projInfo.CreateProjectHookIsEnabled <- true - ()); - CreateProject=(fun (solution,projectBaseName)-> + + member ops.CreateProject (solution,projectBaseName) = let configChangeNotifier = ref None let projInfo = new ProjInfo() let NULL = Unchecked.defaultof - let newHooks = { + let newHooks = + { new ProjectBehaviorHooks with + // Note: CreateProjectHook will callback MakeHierarcyHook and then InitializeProjectHook - CreateProjectHook = - fun (projectFilename:string) (files:(string*BuildAction*string option) list) (references:(string*bool) list) (projReferences:string list) - (disabledWarnings:string list) (defines:string list) (versionFile:string) (otherFlags:string) (otherMSBuildStuff:string) (targetFrameworkVersion : string) -> - if projInfo.CreateProjectHookIsEnabled then - hooks.CreateProjectHook projectFilename files references projReferences disabledWarnings defines versionFile otherFlags otherMSBuildStuff targetFrameworkVersion - if projInfo.Project = NULL then - () - else - // REVIEW: this is a workaround to get everything working for now; ideally we want to implement the VS gestures below - // so that they really happen in the project system, rather than just poking the .fsproj file and then doing - // a 'reload' each time. But for now, this is good. - projInfo.Project.Reload() - InitializeProjectHook = (fun(openProject) -> + member x.CreateProjectHook (projectFilename, files, references, projReferences, disabledWarnings, defines, versionFile, otherFlags, otherMSBuildStuff, targetFrameworkVersion: string) = + if projInfo.CreateProjectHookIsEnabled then + hooks.CreateProjectHook (projectFilename, files, references, projReferences, disabledWarnings, defines, versionFile, otherFlags, otherMSBuildStuff, targetFrameworkVersion) + if projInfo.Project = NULL then + () + else + // REVIEW: this is a workaround to get everything working for now; ideally we want to implement the VS gestures below + // so that they really happen in the project system, rather than just poking the .fsproj file and then doing + // a 'reload' each time. But for now, this is good. + projInfo.Project.Reload() + + member x.InitializeProjectHook (openProject) = hooks.InitializeProjectHook(openProject) - projectDict.Add(openProject, projInfo)) - MakeHierarchyHook = - fun projdir fullname projectname ccn serviceProvider -> - if projInfo.Project = NULL then - let p = TheTests.CreateProject(fullname, "false", ccn, serviceProvider) - projInfo.Project <- p - configChangeNotifier := Some(fun s -> ccn((p :> IVsHierarchy),s)) - else - failwith "oops, did not expect MakeHierarchy to be called more than once" - projInfo.Project :> IVsHierarchy - AddFileToHierarchyHook = fun filename hier -> () - BuildHook = fun projFileName target vsOutputWindowPane -> - if projInfo.Project = NULL then - failwith "tried to build not-yet-created project" - else - let target = if target <> null then target else "Build" - projInfo.Project.BuildToOutput(target,vsOutputWindowPane) |> ignore // force build through project system for code coverage - hooks.BuildHook projFileName target vsOutputWindowPane // use MSBuild to build and also return MainAssembly value - GetMainOutputAssemblyHook = hooks.GetMainOutputAssemblyHook - SaveHook = fun() -> if projInfo.Project = NULL then () else projInfo.Project.Save(null, 1, 0u) |> ignore - DestroyHook = fun () -> - if projInfo.Project = NULL - then () - else projInfo.Project.Close () |> ignore - match projectDict |> Seq.tryFind(fun (KeyValue(k,v)) -> obj.ReferenceEquals(v, projInfo)) with - | Some(KeyValue(k,v)) -> projectDict.Remove(k) |> ignore - | None -> failwith "uh-oh, where was it in the dict?" - projInfo.Project <- NULL - ModifyConfigurationAndPlatformHook = fun s -> + projectDict.Add(openProject, projInfo) + + member x.MakeHierarchyHook (projdir, fullname, projectname, ccn, serviceProvider) = + if projInfo.Project = NULL then + let p = TheTests.CreateProject(fullname, "false", ccn, serviceProvider) + projInfo.Project <- p + configChangeNotifier := Some(fun s -> ccn((p :> IVsHierarchy),s)) + else + failwith "oops, did not expect MakeHierarchy to be called more than once" + projInfo.Project :> IVsHierarchy + + member x.AddFileToHierarchyHook (filename, hier) = () + + member x.BuildHook (projFileName, target, vsOutputWindowPane) = + if projInfo.Project = NULL then + failwith "tried to build not-yet-created project" + else + let target = if target <> null then target else "Build" + projInfo.Project.BuildToOutput(target,vsOutputWindowPane) |> ignore // force build through project system for code coverage + hooks.BuildHook(projFileName, target, vsOutputWindowPane) // use MSBuild to build and also return MainAssembly value + + member x.GetMainOutputAssemblyHook baseName = hooks.GetMainOutputAssemblyHook baseName + + member x.SaveHook () = if projInfo.Project = NULL then () else projInfo.Project.Save(null, 1, 0u) |> ignore + + member x.DestroyHook () = + if projInfo.Project = NULL then () else + projInfo.Project.Close () |> ignore + match projectDict |> Seq.tryFind(fun (KeyValue(k,v)) -> obj.ReferenceEquals(v, projInfo)) with + | Some(KeyValue(k,v)) -> projectDict.Remove(k) |> ignore + | None -> failwith "uh-oh, where was it in the dict?" + projInfo.Project <- NULL + + member x.ModifyConfigurationAndPlatformHook s = match !configChangeNotifier with | Some(ccn) -> ccn(s) | None -> () } - msbuild.CreateProjectWithHooks(solution,newHooks,projectBaseName)); - } - + msbuild.CreateProjectWithHooks(solution,newHooks,projectBaseName) + + // The rest of the members delegate to 'msbuid' + member ops.BehaviourHooks = hooks + member ops.CreateVisualStudio () = msbuild.CreateVisualStudio () + member ops.CreateSolution vs = msbuild.CreateSolution vs + member ops.GetOutputWindowPaneLines vs = msbuild.GetOutputWindowPaneLines vs + member ops.CloseSolution solution = msbuild.CloseSolution solution + member ops.CreateProjectWithHooks (solution,hooks,projectBaseName) = msbuild.CreateProjectWithHooks (solution,hooks,projectBaseName) + member ops.NewFile (vs,filename,buildAction, lines) = msbuild.NewFile (vs,filename,buildAction, lines) + member ops.DeleteFileFromDisk file = msbuild.DeleteFileFromDisk file + member ops.AddFileFromText (project,filenameOnDisk,filenameInProject,buildAction,lines) = msbuild.AddFileFromText (project,filenameOnDisk,filenameInProject,buildAction,lines) + member ops.AddLinkedFileFromText (project,filenameOnDisk,includeFilenameInProject,linkFilenameInProject,buildAction,lines) = msbuild.AddLinkedFileFromText (project,filenameOnDisk,includeFilenameInProject,linkFilenameInProject,buildAction,lines) + member ops.AddProjectReference (project1, project2) = msbuild.AddProjectReference (project1, project2) + member ops.ProjectDirectory project = msbuild.ProjectDirectory project + member ops.ProjectFile project = msbuild.ProjectFile project + member ops.SetVersionFile (project,file) = msbuild.SetVersionFile (project,file) + member ops.SetOtherFlags (project,flags) = msbuild.SetOtherFlags (project,flags) + member ops.SetConfigurationAndPlatform (project, configAndPlatform) = msbuild.SetConfigurationAndPlatform (project, configAndPlatform) + member ops.AddDisabledWarning (project, code) = msbuild.AddDisabledWarning (project, code) + member ops.GetErrors project = msbuild.GetErrors project + member ops.BuildProject (project,target) = msbuild.BuildProject (project,target) + member ops.GetMainOutputAssembly project = msbuild.GetMainOutputAssembly project + member ops.SaveProject project = msbuild.SaveProject project + member ops.OpenFileViaOpenFile (vs,filename) = msbuild.OpenFileViaOpenFile (vs,filename) + member ops.OpenFile (project,filename) = msbuild.OpenFile (project,filename) + member ops.SetProjectDefines (project, defines) = msbuild.SetProjectDefines (project, defines) + member ops.PlaceIntoProjectFileBeforeImport (project,xml) = msbuild.PlaceIntoProjectFileBeforeImport (project,xml) + member ops.GetOpenFiles project = msbuild.GetOpenFiles project + member ops.MoveCursorTo (file,line,col) = msbuild.MoveCursorTo (file,line,col) + member ops.GetCursorLocation file = msbuild.GetCursorLocation file + member ops.OpenExistingProject (vs,dir,projname) = msbuild.OpenExistingProject (vs,dir,projname) + member ops.MoveCursorToEndOfMarker (file,marker) = msbuild.MoveCursorToEndOfMarker (file,marker) + member ops.MoveCursorToStartOfMarker (file,marker) = msbuild.MoveCursorToStartOfMarker (file,marker) + member ops.GetNameOfOpenFile file = msbuild.GetNameOfOpenFile file + member ops.GetProjectOptionsOfScript file = msbuild.GetProjectOptionsOfScript file + member ops.GetQuickInfoAtCursor file = msbuild.GetQuickInfoAtCursor file + member ops.GetQuickInfoAndSpanAtCursor file = msbuild.GetQuickInfoAndSpanAtCursor file + member ops.GetMatchingBracesForPositionAtCursor file = msbuild.GetMatchingBracesForPositionAtCursor file + member ops.GetParameterInfoAtCursor file = msbuild.GetParameterInfoAtCursor file + member ops.GetTokenTypeAtCursor file = msbuild.GetTokenTypeAtCursor file + member ops.GetSquiggleAtCursor file = msbuild.GetSquiggleAtCursor file + member ops.GetSquigglesAtCursor file = msbuild.GetSquigglesAtCursor file + member ops.AutoCompleteAtCursor file = msbuild.AutoCompleteAtCursor file + member ops.CompleteAtCursorForReason (file,reason) = msbuild.CompleteAtCursorForReason (file,reason) + member ops.CompletionBestMatchAtCursorFor (file, value, filterText) = msbuild.CompletionBestMatchAtCursorFor (file, value, filterText) + member ops.GotoDefinitionAtCursor (file, forceGen) = msbuild.GotoDefinitionAtCursor (file, forceGen) + member ops.GetNavigationContentAtCursor file = msbuild.GetNavigationContentAtCursor file + member ops.GetHiddenRegionCommands file = msbuild.GetHiddenRegionCommands file + member ops.GetIdentifierAtCursor file = msbuild.GetIdentifierAtCursor file + member ops.GetF1KeywordAtCursor file = msbuild.GetF1KeywordAtCursor file + member ops.GetLineNumber (file, n) = msbuild.GetLineNumber (file, n) + member ops.GetAllLines file = msbuild.GetAllLines file + member ops.SwitchToFile (vs,file) = msbuild.SwitchToFile (vs,file) + member ops.OnIdle vs = msbuild.OnIdle vs + member ops.ShiftKeyDown vs = msbuild.ShiftKeyDown vs + member ops.ShiftKeyUp vs = msbuild.ShiftKeyUp vs + member ops.TakeCoffeeBreak vs = msbuild.TakeCoffeeBreak vs + member ops.ReplaceFileInMemory (file,contents,takeCoffeeBreak) = msbuild.ReplaceFileInMemory (file,contents,takeCoffeeBreak) + member ops.SaveFileToDisk file = msbuild.SaveFileToDisk file + member ops.CreatePhysicalProjectFileInMemory (files, references, projectReferences, disabledWarnings, defines, versionFile, otherFlags, otherProjMisc, targetFrameworkVersion) = msbuild.CreatePhysicalProjectFileInMemory (files, references, projectReferences, disabledWarnings, defines, versionFile, otherFlags, otherProjMisc, targetFrameworkVersion) + member ops.CleanUp vs = msbuild.CleanUp vs + member ops.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients vs = msbuild.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients vs + member ops.AutoCompleteMemberDataTipsThrowsScope message = msbuild.AutoCompleteMemberDataTipsThrowsScope message + member ops.CleanInvisibleProject vs = msbuild.CleanInvisibleProject vs - + let internal ProjectSystemTestFlavour = ProjectSystemTestFlavour() diff --git a/vsintegration/src/unittests/TestLib.Utils.fs b/vsintegration/src/unittests/TestLib.Utils.fs index 33bd23a8c..56ce0a2aa 100644 --- a/vsintegration/src/unittests/TestLib.Utils.fs +++ b/vsintegration/src/unittests/TestLib.Utils.fs @@ -250,6 +250,10 @@ module Spawn = printfn "%s" line eprintfn "tf submit returned error code %d" errorCode +[] +module Helpers = + type DummyType = A | B + let PathRelativeToTestAssembly p = Path.Combine(Path.GetDirectoryName(Uri(typeof.Assembly.CodeBase).LocalPath), p) namespace TestLibrary module LambdaCalculus = diff --git a/vsintegration/src/unittests/Tests.BaseLine.fs b/vsintegration/src/unittests/Tests.BaseLine.fs index 91127f69f..9e247a62e 100644 --- a/vsintegration/src/unittests/Tests.BaseLine.fs +++ b/vsintegration/src/unittests/Tests.BaseLine.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests +namespace Tests open NUnit.Framework open System open System.IO @@ -8,11 +8,10 @@ open System.Diagnostics open UnitTests.TestLib.Utils open Microsoft.BuildSettings -[] -type Script() = #if OPEN_BUILD - class end #else +[] +type Script() = let replaceIfNotNull (search:string) (replace:string) (s:string) = match s with | null -> s diff --git a/vsintegration/src/unittests/Tests.Build.fs b/vsintegration/src/unittests/Tests.Build.fs index 4bb0f15eb..1939f6e2f 100644 --- a/vsintegration/src/unittests/Tests.Build.fs +++ b/vsintegration/src/unittests/Tests.Build.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests +namespace Tests open NUnit.Framework open System diff --git a/vsintegration/src/unittests/Tests.InternalCollections.fs b/vsintegration/src/unittests/Tests.InternalCollections.fs index 709ce291a..2e4dde017 100644 --- a/vsintegration/src/unittests/Tests.InternalCollections.fs +++ b/vsintegration/src/unittests/Tests.InternalCollections.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.InternalCollections +namespace Tests.Compiler.InternalCollections open System open System.IO @@ -22,9 +22,10 @@ type MruCache = member private rb.NumToStringBox n = box (rb.NumToString n) +#if DISABLED_OLD_UNITTESTS [] member public rb.Basic() = - let m = new MruCache(3, rb.NumToString, (fun (x,y) -> x = y)) + let m = new MruCache(3, (fun (x,y) -> x = y)) let s = m.Get(5) Assert.IsTrue("Five"=s) let s = m.Get(6) @@ -110,6 +111,7 @@ type MruCache = let s = m.Get (("w",6)) // forces discard of y printfn "discarded = %A" discarded.Value Assert.IsTrue(discarded.Value = ["y";"x";"Apple";"Banana"], "Check6") +#endif [] type AgedLookup() = diff --git a/vsintegration/src/unittests/Tests.LanguageService.Colorizer.fs b/vsintegration/src/unittests/Tests.LanguageService.Colorizer.fs index 83e7c65b1..9aee15046 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.Colorizer.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.Colorizer.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.Colorizer open System open NUnit.Framework @@ -9,8 +9,11 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -type ColorizerTests() = +// context msbuild +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() //Marker At The End Helper Functions @@ -1081,25 +1084,9 @@ let z = __LINE__(*Test3*) MoveCursorToEndOfMarker(file,"(*Bob*)typ") AssertEqual(TokenType.Keyword,GetTokenTypeAtCursor(file)) - -// Allow languageService tests to run under different contextes -namespace UnitTests.Tests.LanguageService.Colorizer -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit ColorizerTests - new() = { inherit ColorizerTests(VsOpts = fst (Models.MSBuild())); } - // Context project system [] -[] -type ``ProjectSystem`` = - inherit ColorizerTests - new() = { inherit ColorizerTests(VsOpts = LanguageServiceExtension.ProjectSystem); } \ No newline at end of file +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) + + \ No newline at end of file diff --git a/vsintegration/src/unittests/Tests.LanguageService.Completion.fs b/vsintegration/src/unittests/Tests.LanguageService.Completion.fs index 46d887380..c917d2766 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.Completion.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.Completion.fs @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.AutoCompletion open System +open Salsa.Salsa open Salsa.VsMocks open Salsa.VsOpsUtils open NUnit.Framework open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils -open Salsa.Salsa - open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem [] module StandardSettings = @@ -24,7 +24,8 @@ module StandardSettings = let AC x y = AutoCompleteExpected(x,y) let DC x y = DotCompleteExpected(x,y) -type AutoCompletionListTests() as this = +[] +type UsingMSBuild() as this = inherit LanguageServiceBaseTests() let createFile (code : list) fileKind refs = @@ -230,6 +231,28 @@ type AutoCompletionListTests() as this = let completions = time1 AutoCompleteAtCursor file "Time of first autocomplete." AssertCompListIsEmpty(completions) + /////Helper Functios + //DotCompList ContainAll At End Of Marker Helper Function + member private this.VerifyDotCompListContainAllAtEndOfMarker(fileContents : string, marker : string, list : string list) = + let (solution, project, file) = this.CreateSingleFileProject(fileContents) + let completions = DotCompletionAtEndOfMarker file marker + AssertCompListContainsAll(completions, list) + + //DoesNotContainAny At Start Of Marker Helper Function + member private this.VerifyDotCompListDoesNotContainAnyAtStartOfMarker(fileContents : string, marker : string, list : string list, ?addtlRefAssy : list) = + let (solution, project, file) = this.CreateSingleFileProject(fileContents, ?references = addtlRefAssy) + + let completions = DotCompletionAtStartOfMarker file marker + AssertCompListDoesNotContainAny(completions, list) + + //DotCompList Is Empty At Start Of Marker Helper Function + member private this.VerifyDotCompListIsEmptyAtStartOfMarker(fileContents : string, marker : string, ?addtlRefAssy : list) = + let (solution, project, file) = this.CreateSingleFileProject(fileContents, ?references = addtlRefAssy) + + let completions = DotCompletionAtStartOfMarker file marker + AssertCompListIsEmpty(completions) + + [] member this.``AutoCompletion.ObjectMethods``() = let code = @@ -312,7 +335,7 @@ type AutoCompletionListTests() as this = [] [] member this.``TypeProvider.VisibilityChecksForGeneratedTypes``() = - let extraRefs = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] + let extraRefs = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] let check = DoWithAutoCompleteUsingExtraRefs extraRefs true SourceFileKind.FS Microsoft.VisualStudio.FSharp.LanguageService.BackgroundRequestReason.MemberSelect let code = @@ -2102,7 +2125,7 @@ let x = new MyClass2(0) t.I"""], marker = "t.I", expected = "IM1", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -2115,7 +2138,7 @@ let x = new MyClass2(0) t.Eve"""], marker = "t.Eve", expected = "Event1", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) [] [] @@ -2127,7 +2150,7 @@ let x = new MyClass2(0) type boo = N1.T ignore + TakeCoffeeBreak(this.VS) + // Start the key instrumentation let gpatcc = GlobalParseAndTypeCheckCounter.StartNew(this.VS) @@ -5158,38 +5183,6 @@ let x = query { for bbbb in abbbbc(*D0*) do marker = "gro", contained = [ "groupBy"; "groupJoin"; "groupValBy";]) -//****************************************// -type DotCompletionListTests() = - inherit LanguageServiceBaseTests() - - /////Helper Functios - //DotCompList ContainAll At End Of Marker Helper Function - member private this.VerifyDotCompListContainAllAtEndOfMarker(fileContents : string, marker : string, list : string list) = - let (solution, project, file) = this.CreateSingleFileProject(fileContents) - let completions = DotCompletionAtEndOfMarker file marker - AssertCompListContainsAll(completions, list) - - //DotCompList ContainAll methods and properties At Start Of Marker Helper Function - member private this.VerifyDotCompListContainAllAtStartOfMarker(fileContents : string, marker : string, list :string list, ?addtlRefAssy : list, ?coffeeBreak:bool) = - let (solution, project, file) = this.CreateSingleFileProject(fileContents, ?references = addtlRefAssy) - if defaultArg coffeeBreak false then TakeCoffeeBreak(this.VS) - let completions = DotCompletionAtStartOfMarker file marker - AssertCompListContainsAll(completions, list) - - //DoesNotContainAny At Start Of Marker Helper Function - member private this.VerifyDotCompListDoesNotContainAnyAtStartOfMarker(fileContents : string, marker : string, list : string list, ?addtlRefAssy : list) = - let (solution, project, file) = this.CreateSingleFileProject(fileContents, ?references = addtlRefAssy) - - let completions = DotCompletionAtStartOfMarker file marker - AssertCompListDoesNotContainAny(completions, list) - - //DotCompList Is Empty At Start Of Marker Helper Function - member private this.VerifyDotCompListIsEmptyAtStartOfMarker(fileContents : string, marker : string, ?addtlRefAssy : list) = - let (solution, project, file) = this.CreateSingleFileProject(fileContents, ?references = addtlRefAssy) - - let completions = DotCompletionAtStartOfMarker file marker - AssertCompListIsEmpty(completions) - [] member this.``Namespace.System``() = this.VerifyDotCompListContainAllAtEndOfMarker( @@ -5386,7 +5379,7 @@ type DotCompletionListTests() = t(*Marker*)""", marker = "(*Marker*)", list = ["Equals";"GetHashCode"], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) [] [] @@ -5399,7 +5392,7 @@ type DotCompletionListTests() = t(*Marker*)""", marker = "(*Marker*)", list = ["Event1"], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) [] [] @@ -5412,7 +5405,7 @@ type DotCompletionListTests() = t(*Marker*)""", marker = "(*Marker*)", list = ["IM1"], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -5424,7 +5417,7 @@ type DotCompletionListTests() = type XXX = N1.T1(*Marker*)""", marker = "(*Marker*)", list = ["SomeNestedType"], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) // should _not_ have it here this.VerifyDotCompListDoesNotContainAnyAtStartOfMarker( fileContents = """ @@ -5432,7 +5425,7 @@ type DotCompletionListTests() = t(*Marker*)""", marker = "(*Marker*)", list = ["SomeNestedType"], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -5445,7 +5438,7 @@ type DotCompletionListTests() = t.Event1(*Marker*)""", marker = "(*Marker*)", list = ["AddHandler";"RemoveHandler"], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) [] [] @@ -5457,7 +5450,7 @@ type DotCompletionListTests() = fileContents = """ let t = N.T.M(*Marker*)()""", marker = "(*Marker*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) [] [] @@ -5471,7 +5464,7 @@ type DotCompletionListTests() = let t = N.T.StaticProp(*Marker*)""", marker = "(*Marker*)", list = ["GetType"; "Equals"], // just a couple of System.Object methods: we expect them to be there! - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\EditorHideMethodsAttribute.dll")]) [] member this.CompListInDiffFileTypes() = @@ -7710,41 +7703,11 @@ let rec f l = this.VerifyDotCompListContainAllAtStartOfMarker(fileContents, "(*Marker*)", ["Chars";"Length"], queryAssemblyRefs ) -// Allow the CompletionListTests run under different context -namespace UnitTests.Tests.LanguageService.CompletionList -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``AutoCompletionMSBuild`` = - inherit AutoCompletionListTests - new() = { inherit AutoCompletionListTests(VsOpts = fst (Models.MSBuild())); } - -// Context project system -[] -[] -type ``AutoCompletionProjectSystem`` = - inherit AutoCompletionListTests - new() = { inherit AutoCompletionListTests(VsOpts = LanguageServiceExtension.ProjectSystem); } - -// context msbuild -[] -[] -type ``DotCompletionMSBuild`` = - inherit DotCompletionListTests - new() = { inherit DotCompletionListTests(VsOpts = fst (Models.MSBuild())); } // Context project system [] -[] -type ``DotCompletionProjectSystem`` = - inherit DotCompletionListTests - new() = { inherit DotCompletionListTests(VsOpts = LanguageServiceExtension.ProjectSystem); } +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) diff --git a/vsintegration/src/unittests/Tests.LanguageService.ErrorList.fs b/vsintegration/src/unittests/Tests.LanguageService.ErrorList.fs index e128c4d29..e306c7eff 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.ErrorList.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.ErrorList.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.ErrorList open System open System.IO @@ -10,8 +10,10 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -type ErrorListTests() as this = +[] +type UsingMSBuild() as this = inherit LanguageServiceBaseTests() let VerifyErrorListContainedExpectedStr(expectedStr:string,project : OpenProject) = @@ -371,7 +373,7 @@ type staticInInterface = [] [] member public this.``TypeProvider.MultipleErrors`` () = - let tpRef = System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") + let tpRef = PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") let checkList n = printfn "===TypeProvider.MultipleErrors: %d===" n let content = sprintf "type Err = TPErrors.TP<%d>" n @@ -443,7 +445,7 @@ type staticInInterface = but here has type int """ this.VerifyErrorListContainedExpectedString(fileContent,expectedStr, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -457,7 +459,7 @@ but here has type let expectedStr = "An error occurred applying the static arguments to a provided type" this.VerifyErrorListContainedExpectedString(fileContent,expectedStr, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -471,7 +473,7 @@ but here has type let expectedStr = "The static parameter 'ParamIgnored' of the provided type or method 'T' requires a value. Static parameters to type providers may be optionally specified using named arguments, e.g. 'T'." this.VerifyErrorListContainedExpectedString(fileContent,expectedStr, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] member public this.``TypeProvider.ProhibitedMethods`` () = @@ -486,7 +488,7 @@ but here has type ( code, sprintf "Array method '%s' is supplied by the runtime and cannot be directly used in code." str, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] ) [] @@ -511,7 +513,7 @@ but here has type type foo = N1.T< const "Hello World",2>""", expectedNum = 1, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -522,7 +524,7 @@ but here has type this.VerifyNoErrorListAtOpenProject( fileContents = """ type foo = N1.T< const "Hello World",2>""", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] @@ -917,24 +919,7 @@ but here has type let warnList = GetErrors(project) Assert.AreEqual(1,warnList.Length) -//Allow the ErrorListTests run under different context -namespace UnitTests.Tests.LanguageService.ErrorList -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit ErrorListTests - new() = { inherit ErrorListTests(VsOpts = fst (Models.MSBuild())); } - // Context project system [] -[] -type ``ProjectSystem`` = - inherit ErrorListTests - new() = { inherit ErrorListTests(VsOpts = LanguageServiceExtension.ProjectSystem); } +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) diff --git a/vsintegration/src/unittests/Tests.LanguageService.ErrorRecovery.fs b/vsintegration/src/unittests/Tests.LanguageService.ErrorRecovery.fs index e5fbebbef..544d02689 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.ErrorRecovery.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.ErrorRecovery.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.ErrorRecovery open System open System.IO @@ -10,8 +10,10 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -type ErrorRecoveryTests() = +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() //Verify the error list containd the expected string @@ -263,24 +265,8 @@ type ErrorRecoveryTests() = ] ) -//Allow the TimeStampTests run under different context -namespace UnitTests.Tests.LanguageService.ErrorRecovery -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit ErrorRecoveryTests - new() = { inherit ErrorRecoveryTests(VsOpts = fst (Models.MSBuild())); } // Context project system [] -[] -type ``ProjectSystem`` = - inherit ErrorRecoveryTests - new() = { inherit ErrorRecoveryTests(VsOpts = LanguageServiceExtension.ProjectSystem); } \ No newline at end of file +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) \ No newline at end of file diff --git a/vsintegration/src/unittests/Tests.LanguageService.F1Keyword.fs b/vsintegration/src/unittests/Tests.LanguageService.F1Keyword.fs index 5f8b03d0c..1282f95a1 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.F1Keyword.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.F1Keyword.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.F1Keyword open System open NUnit.Framework @@ -9,8 +9,10 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -type F1KeywordTests() = +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() member private this.TestF1Keywords(expectedKeywords, testLines, ?addtlRefAssy : list) = @@ -204,7 +206,7 @@ type F1KeywordTests() = Some "N1" ] this.TestF1Keywords(keywords, file, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -222,7 +224,7 @@ type F1KeywordTests() = Some "N1.T" ] this.TestF1Keywords(keywords, file, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] @@ -369,24 +371,8 @@ type F1KeywordTests() = ] this.TestF1Keywords(keywords, file) -// Allow the F1KeywordTests run under different context -namespace UnitTests.Tests.LanguageService.F1Keyword -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit F1KeywordTests - new() = { inherit F1KeywordTests(VsOpts = fst (Models.MSBuild())); } // Context project system [] -[] -type ``ProjectSystem`` = - inherit F1KeywordTests - new() = { inherit F1KeywordTests(VsOpts = LanguageServiceExtension.ProjectSystem); } \ No newline at end of file +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) \ No newline at end of file diff --git a/vsintegration/src/unittests/Tests.LanguageService.General.fs b/vsintegration/src/unittests/Tests.LanguageService.General.fs index 06231f4c8..d228fc77f 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.General.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.General.fs @@ -1,24 +1,36 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.General open NUnit.Framework open System +open System.IO open System.Reflection open System.Runtime.InteropServices -open Microsoft.VisualStudio.FSharp.LanguageService +open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.SourceCodeServices +open Microsoft.VisualStudio.FSharp.LanguageService open Salsa.Salsa open Salsa +open Salsa.VsOpsUtils +open UnitTests.TestLib.Salsa +open UnitTests.TestLib.Utils +open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem [] -type IdealSource() = +module IFSharpSource = + [] - member public rb.MultipleSourceIsDirtyCallsChangeTimestamps() = + let MultipleSourceIsDirtyCallsChangeTimestamps() = let recolorizeWholeFile() = () let recolorizeLine (_line:int) = () let isClosed() = false - let source =Source.CreateDelegatingSource(recolorizeWholeFile, recolorizeLine, "dummy.fs", isClosed, VsMocks.VsFileChangeEx()) + let depFileChangeNotify = + { new IDependencyFileChangeNotify with + member this.DependencyFileCreated _projectSite = () + member this.DependencyFileChanged _filename = () } + let source = Source.CreateSourceTestable(recolorizeWholeFile, recolorizeLine, (fun () -> "dummy.fs"), isClosed, VsMocks.VsFileChangeEx(),depFileChangeNotify) let originalChangeCount = source.ChangeCount let originalDirtyTime = source.DirtyTime @@ -43,16 +55,8 @@ type IdealSource() = -open System -open System.IO -open NUnit.Framework -open Salsa.Salsa -open Salsa.VsOpsUtils -open UnitTests.TestLib.Salsa -open UnitTests.TestLib.Utils -open Microsoft.FSharp.Compiler -open UnitTests.TestLib.LanguageService -type GeneralTests() = +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() let stopWatch = new System.Diagnostics.Stopwatch() @@ -123,28 +127,28 @@ type GeneralTests() = // n-Ui1 + n-Ui2 = n-Ui2 requests.Enqueue(makeRequest BackgroundRequestReason.FullTypeCheck) - requests.Enqueue(makeRequest BackgroundRequestReason.UntypedParse) - verify BackgroundRequestReason.UntypedParse + requests.Enqueue(makeRequest BackgroundRequestReason.ParseFile) + verify BackgroundRequestReason.ParseFile Assert.AreEqual(0, requests.Count) // Ui1 + n-Ui2 = Ui1 + n-Ui2 requests.Enqueue(makeRequest BackgroundRequestReason.MemberSelect) - requests.Enqueue(makeRequest BackgroundRequestReason.UntypedParse) + requests.Enqueue(makeRequest BackgroundRequestReason.ParseFile) verify BackgroundRequestReason.MemberSelect Assert.AreEqual(1, requests.Count) - verify BackgroundRequestReason.UntypedParse + verify BackgroundRequestReason.ParseFile Assert.AreEqual(0, requests.Count) // (Ui1 + n-Ui2) + Ui3 = Ui3 requests.Enqueue(makeRequest BackgroundRequestReason.MemberSelect) - requests.Enqueue(makeRequest BackgroundRequestReason.UntypedParse) + requests.Enqueue(makeRequest BackgroundRequestReason.ParseFile) requests.Enqueue(makeRequest BackgroundRequestReason.MemberSelect) verify BackgroundRequestReason.MemberSelect Assert.AreEqual(0, requests.Count) // (Ui1 + n-Ui2) + n-Ui3 = Ui1 + n-Ui3 requests.Enqueue(makeRequest BackgroundRequestReason.MemberSelect) - requests.Enqueue(makeRequest BackgroundRequestReason.UntypedParse) + requests.Enqueue(makeRequest BackgroundRequestReason.ParseFile) requests.Enqueue(makeRequest BackgroundRequestReason.FullTypeCheck) verify BackgroundRequestReason.MemberSelect Assert.AreEqual(1, requests.Count) @@ -260,7 +264,7 @@ EdmxFile ResolutionFolder:String """ File.WriteAllText(Path.Combine(curDir, "tmp.fsx"), script) - let psi = System.Diagnostics.ProcessStartInfo("fsi.exe", "-r:FSharp.Data.TypeProviders.dll tmp.fsx") + let psi = System.Diagnostics.ProcessStartInfo(Path.Combine(curDir, "fsi.exe"), "-r:FSharp.Data.TypeProviders.dll tmp.fsx") psi.WorkingDirectory <- curDir psi.RedirectStandardOutput <- true psi.UseShellExecute <- false @@ -302,7 +306,7 @@ EdmxFile let filename = "test.fs" let defines = [ "COMPILED"; "EDITING" ] - SourceTokenizer(defines,filename).CreateLineTokenizer(source)) + FSharpSourceTokenizer(defines,filename).CreateLineTokenizer(source)) let cm = Microsoft.VisualStudio.FSharp.LanguageService.TokenColor.Comment let kw = Microsoft.VisualStudio.FSharp.LanguageService.TokenColor.Keyword @@ -498,16 +502,16 @@ EdmxFile member public this.``TokenInfo.TriggerClasses``() = let important = [ // Member select for dot completions - Parser.DOT, (TokenColorKind.Operator,TokenCharKind.Delimiter,TriggerClass.MemberSelect) + Parser.DOT, (FSharpTokenColorKind.Operator,FSharpTokenCharKind.Delimiter,FSharpTokenTriggerClass.MemberSelect) // for parameter info - Parser.LPAREN, (TokenColorKind.Text,TokenCharKind.Delimiter, TriggerClass.ParamStart ||| TriggerClass.MatchBraces) - Parser.COMMA, (TokenColorKind.Text,TokenCharKind.Delimiter, TriggerClass.ParamNext) - Parser.RPAREN, (TokenColorKind.Text,TokenCharKind.Delimiter, TriggerClass.ParamEnd ||| TriggerClass.MatchBraces) ] + Parser.LPAREN, (FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.ParamStart ||| FSharpTokenTriggerClass.MatchBraces) + Parser.COMMA, (FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.ParamNext) + Parser.RPAREN, (FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.ParamEnd ||| FSharpTokenTriggerClass.MatchBraces) ] let matching = [ // Other cases where we expect MatchBraces Parser.LQUOTE("", false); Parser.LBRACK; Parser.LBRACE; Parser.LBRACK_BAR; Parser.RQUOTE("", false); Parser.RBRACK; Parser.RBRACE; Parser.BAR_RBRACK ] - |> List.map (fun n -> n, (TokenColorKind.Text,TokenCharKind.Delimiter, TriggerClass.MatchBraces)) + |> List.map (fun n -> n, (FSharpTokenColorKind.Text,FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.MatchBraces)) for tok, expected in List.concat [ important; matching ] do let info = TestExpose.TokenInfo tok AssertEqual(expected, info) @@ -582,24 +586,9 @@ EdmxFile checkBraces "['x'" "](* E_L*)" 1 checkBraces "[<" ">]" 2 -//Allow the TimeStampTests run under different context -namespace UnitTests.Tests.LanguageService.General -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit GeneralTests - new() = { inherit GeneralTests(VsOpts = fst (Models.MSBuild())); } // Context project system [] -[] -type ``ProjectSystem`` = - inherit GeneralTests - new() = { inherit GeneralTests(VsOpts = LanguageServiceExtension.ProjectSystem); } \ No newline at end of file +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) + diff --git a/vsintegration/src/unittests/Tests.LanguageService.GotoDefinition.fs b/vsintegration/src/unittests/Tests.LanguageService.GotoDefinition.fs index e3aecd7e8..02597bd81 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.GotoDefinition.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.GotoDefinition.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.GotoDefinition open System open System.IO @@ -12,8 +12,10 @@ open UnitTests.TestLib.Utils open System.Collections.Generic open System.Text.RegularExpressions open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -type GotoDefinitionTests() = +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() //GoToDefinitionSuccess Helper Function @@ -213,7 +215,7 @@ type GotoDefinitionTests() = // C01234567890 """, "T(*GotoValDef*)", "// A0(*ColumnMarker*)1234567890", - System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), + PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), "(*ColumnMarker*)") // This test case checks the type with space in between like N.``T T`` for GotoDefinition @@ -225,7 +227,7 @@ type GotoDefinitionTests() = // C01234567890 """, "T``", "// A0(*ColumnMarker*)1234567890", - System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeWithSpaceInTheType.dll"), + PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeWithSpaceInTheType.dll"), "(*ColumnMarker*)") // Basic scenario on a provided Constructor @@ -238,7 +240,7 @@ type GotoDefinitionTests() = // C01234567890 """, "T(*GotoValDef*)", "// A0(*ColumnMarker*)1234567890", - System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), + PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), "(*ColumnMarker*)") // Basic scenario on a provided Method @@ -250,7 +252,7 @@ type GotoDefinitionTests() = // C01234567890 """, "M(*GotoValDef*)", "// A0(*ColumnMarker*)1234567890", - System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), + PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), "(*ColumnMarker*)") // Basic scenario on a provided Property @@ -262,7 +264,7 @@ type GotoDefinitionTests() = // C01234567890 """, "StaticProp(*GotoValDef*)", "// A0(*ColumnMarker*)1234567890", - System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), + PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), "(*ColumnMarker*)") // Basic scenario on a provided Event @@ -275,7 +277,7 @@ type GotoDefinitionTests() = // C01234567890 """, "Event1(*GotoValDef*)", "// A0(*ColumnMarker*)1234567890", - System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), + PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttribute.dll"), "(*ColumnMarker*)") // Actually execute all the scenarios... @@ -331,7 +333,7 @@ type GotoDefinitionTests() = Assert.IsFalse(result.Success) Assert.IsTrue(result.ErrorDescription.Contains("provided type 'T'")) ), - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] ) [] @@ -359,7 +361,7 @@ type GotoDefinitionTests() = let expectedText = sprintf "provided member '%s'" name Assert.IsTrue(result.ErrorDescription.Contains(expectedText)) ), - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] ) [] [] @@ -373,7 +375,7 @@ type GotoDefinitionTests() = // B01234567890 // C01234567890 """, marker = "T(*GotoValDef*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) [] [] @@ -388,7 +390,7 @@ type GotoDefinitionTests() = // B01234567890 // C01234567890 """, marker = "T(*GotoValDef*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeLineDoesnotExist.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeLineDoesnotExist.dll")]) [] [] @@ -402,7 +404,7 @@ type GotoDefinitionTests() = // B01234567890 // C01234567890 """, marker = "T(*GotoValDef*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) @@ -418,7 +420,7 @@ type GotoDefinitionTests() = // B01234567890 // C01234567890 """, marker = "M(*GotoValDef*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) [] [] @@ -432,7 +434,7 @@ type GotoDefinitionTests() = // B01234567890 // C01234567890 """, marker = "StaticProp(*GotoValDef*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) [] [] @@ -447,7 +449,7 @@ type GotoDefinitionTests() = // B01234567890 // C01234567890 """, marker = "Event1(*GotoValDef*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DefinitionLocationAttributeFileDoesnotExist.dll")]) [] member public this.``ModuleDefintion``() = @@ -558,12 +560,12 @@ type GotoDefinitionTests() = [] member this.``GotoDefinition.OverloadResolutionForProperties``() = let lines = [ "type D() =" - " member this.Foo" - " with #1##2#get(i:int) = 1" + " member this.#1##2#Foo" + " with get(i:int) = 1" " and set (i:int) v = ()" "" - " member this.Foo" - " with #3##4#get (s:string) = 1" + " member this.#3##4#Foo" + " with get (s:string) = 1" " and set (s:string) v = ()" "" "D().$1$Foo 1" @@ -1060,12 +1062,12 @@ type GotoDefinitionTests() = /// let a = () in let id (x : '$a) : 'a = x [] member public this.``GotoDefinition.Simple.Polymorph.Leftmost`` () = - this.GotoDefinitionTestWithSimpleFile "a) (*loc-33*)" None + this.GotoDefinitionTestWithSimpleFile "a) (*loc-33*)" (Some("let id (x : 'a) (*loc-33*)", "'a")) /// let a = () in let id (x : 'a) : '$a = x [] member public this.``GotoDefinition.Simple.Polymorph.NotLeftmost`` () = - this.GotoDefinitionTestWithSimpleFile "a = x (*loc-34*)" None + this.GotoDefinitionTestWithSimpleFile "a = x (*loc-34*)" (Some("let id (x : 'a) (*loc-33*)", "'a")) /// let foo = () in let f (_ as $foo) = foo in () [] @@ -1448,24 +1450,7 @@ type GotoDefinitionTests() = this.VerifyGoToDefnNoErrorDialogAtStartOfMarker(fileContents,"A(*Marker*)", "type A = ampere") -// Allow languageService tests to run under different contextes -namespace UnitTests.Tests.LanguageService.GotoDefinition -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit GotoDefinitionTests - new() = { inherit GotoDefinitionTests(VsOpts = fst (Models.MSBuild())); } - // Context project system [] -[] -type ``ProjectSystem`` = - inherit GotoDefinitionTests - new() = { inherit GotoDefinitionTests(VsOpts = LanguageServiceExtension.ProjectSystem); } +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) diff --git a/vsintegration/src/unittests/Tests.LanguageService.IncrementalBuild.fs b/vsintegration/src/unittests/Tests.LanguageService.IncrementalBuild.fs index 87ee43cf8..14662520c 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.IncrementalBuild.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.IncrementalBuild.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService open System open System.IO @@ -12,10 +12,11 @@ open NUnit.Framework.Constraints open Salsa.Salsa open Salsa.VsOpsUtils open Microsoft.FSharp.Compiler +open Microsoft.FSharp.Compiler.SourceCodeServices +open Microsoft.FSharp.Compiler.IncrementalBuild open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open IncrementalBuild - -/// Useful methods that someday might go into IncrementalBuild + +// Useful methods that someday might go into IncrementalBuild module internal Vector = /// Convert from vector to a scalar let ToScalar<'I> (taskname:string) (input:Vector<'I>) : Scalar<'I array> = @@ -61,32 +62,33 @@ type IncrementalBuild() = let Map filename = "map:"+filename - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let input = InputVector "InputVector" let stamped = Vector.Stamp "Stamp" StampFile input let mapped = Vector.Map "Map" Map stamped - build.DeclareVectorOutput("Mapped", mapped) - let build = build.GetInitialPartialBuild(["InputVector",1,[box path]],[]) + buildDesc.DeclareVectorOutput mapped + let inputs = [ BuildInput.VectorInput(input, [path]) ] + let bound = buildDesc.GetInitialPartialBuild inputs - let DoCertainStep build = - match IncrementalBuild.Step "Mapped" build with - | Some(build) -> build + let DoCertainStep bound = + match IncrementalBuild.Step (Target(mapped,None)) bound with + | Some bound -> bound | None -> failwith "Expected to be able to step" // While updateStamp is true we should be able to step as continuously - // because there will always be more to build. - let mutable build = build + // because there will always be more to bound. + let mutable bound = bound for i in 0..5 do printfn "Iteration %d" i - build <- DoCertainStep build + bound <- DoCertainStep bound System.Threading.Thread.Sleep 2000 // Now, turn off updateStamp and the build should just finish. updateStamp:=false - build <- DoCertainStep build - build <- DoCertainStep build - match IncrementalBuild.Step "Mapped" build with - | Some(build) -> failwith "Build should have stopped" + bound <- DoCertainStep bound + bound <- DoCertainStep bound + match IncrementalBuild.Step (Target (mapped, None)) bound with + | Some bound -> failwith "Build should have stopped" | None -> () @@ -102,33 +104,36 @@ type IncrementalBuild() = let StampFile(filename) = !stampAs - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let input = InputVector "InputVector" let acc = InputScalar "Accumulator" let stamped = Vector.Stamp "Stamp" StampFile input let scanned = Vector.ScanLeft "Scan" Scan acc stamped - build.DeclareVectorOutput("Scanned", scanned) - let build = build.GetInitialPartialBuild(["InputVector",3,[box "File1.fs";box "File2.fs";box "File3.fs"]],["Accumulator",box "AccVal"]) + buildDesc.DeclareVectorOutput scanned + let inputs = + [ BuildInput.VectorInput(input, ["File1.fs"; "File2.fs"; "File3.fs"]) + BuildInput.ScalarInput(acc, "AccVal") ] + let bound = buildDesc.GetInitialPartialBuild inputs printf "-[Step1]----------------------------------------------------------------------------------------\n" // Evaluate the first time. - let build = Eval "Scanned" build - let r = GetVectorResult("Scanned",build) + let bound = Eval scanned bound + let r = GetVectorResult (scanned, bound) Assert.AreEqual("AccVal-File1.fs-Suffix1-File2.fs-Suffix1",r.[1]) printf "-[Step2]----------------------------------------------------------------------------------------\n" // Evaluate the second time. No change should be seen. mapSuffix:="Suffix2" - let build = Eval "Scanned" build - let r = GetVectorResult("Scanned",build) + let bound = Eval scanned bound + let r = GetVectorResult (scanned,bound) Assert.AreEqual("AccVal-File1.fs-Suffix1-File2.fs-Suffix1",r.[1]) printf "-[Step3]----------------------------------------------------------------------------------------\n" // Evaluate a third time with timestamps updated. Should cause a rebuild System.Threading.Thread.Sleep 10 // Sleep a little to avoid grabbing the same 'Now' stampAs:=DateTime.Now - let build = Eval "Scanned" build - let r = GetVectorResult("Scanned",build) + let bound = Eval scanned bound + let r = GetVectorResult (scanned,bound) Assert.AreEqual("AccVal-File1.fs-Suffix2-File2.fs-Suffix2",r.[1]) @@ -136,35 +141,36 @@ type IncrementalBuild() = [] member public rb.aaZeroElementVector() = // Starts with 'aa' to put it at the front. let stamp = ref DateTime.Now - let Mult(i:int) : string array = Array.create i "" let Stamp(s:string) = !stamp let Map(s:string) = s let Demult(a:string array) : int = a.Length - let build = new BuildDescriptionScope() - let input = InputScalar "InputScalar" - let multiplexed = Scalar.Multiplex "Mult" Mult input - let stamped = Vector.Stamp "Stamp" Stamp multiplexed + let buildDesc = new BuildDescriptionScope() + let inputVector = InputVector "InputVector" + let stamped = Vector.Stamp "Stamp" Stamp inputVector let mapped = Vector.Map "Map" Map stamped - let demultiplexed = Vector.Demultiplex "Demult" Demult mapped - build.DeclareVectorOutput("Multiplexed", multiplexed) - build.DeclareVectorOutput("Stamped", stamped) - build.DeclareVectorOutput("Mapped", mapped) - build.DeclareScalarOutput("Result", demultiplexed) + let result = Vector.Demultiplex "Demult" Demult mapped + buildDesc.DeclareVectorOutput stamped + buildDesc.DeclareVectorOutput mapped + buildDesc.DeclareScalarOutput result // Try first with one input - let build1 = build.GetInitialPartialBuild([],["InputScalar", box 1]) - let build1Evaled = Eval "Result" build1 - let r1 = GetScalarResult("Result",build1Evaled) + let inputs1 = [ BuildInput.VectorInput(inputVector, [""]) ] + let build1 = buildDesc.GetInitialPartialBuild inputs1 + + let build1Evaled = Eval result build1 + let r1 = GetScalarResult (result, build1Evaled) match r1 with | Some(v,dt) -> Assert.AreEqual(1,v) | None -> failwith "Expected the value 1 to be returned." // Now with zero. This was the original bug. stamp := DateTime.Now - let build0 = build.GetInitialPartialBuild([],["InputScalar", box 0]) - let build0Evaled = Eval "Result" build0 - let r0 = GetScalarResult("Result",build0Evaled) + let inputs0 = [ BuildInput.VectorInput(inputVector, []) ] + let build0 = buildDesc.GetInitialPartialBuild inputs0 + + let build0Evaled = Eval result build0 + let r0 = GetScalarResult (result, build0Evaled) match r0 with | Some(v,dt) -> Assert.AreEqual(0,v) | None -> failwith "Expected the value 0 to be returned." @@ -176,31 +182,31 @@ type IncrementalBuild() = member public rb.MultiplexTransitionUp() = let elements = ref 1 let timestamp = ref System.DateTime.Now - let Mult(s:string) : string array = [| for i in 1..!elements -> sprintf "Element %d" i |] + let Input() : string array = [| for i in 1..!elements -> sprintf "Element %d" i |] let Stamp(s) = !timestamp let Map(s:string) = sprintf "Mapped %s " s - let Demult(a:string array) : string = "Demult" - let Result(a:string array) : string = String.Join(",", a) + let Result(a:string[]) : string = String.Join(",", a) let now = System.DateTime.Now let FixedTimestamp _ = now - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let input = InputVector "InputVector" let stampedInput = Vector.Stamp "StampInput" Stamp input - let demultiplexedInput = Vector.Demultiplex "DemultInput" Demult stampedInput - let multiplexed = Scalar.Multiplex "Mult" Mult demultiplexedInput - let mapped = Vector.Map "Map" Map multiplexed + //let demultiplexedInput = Vector.Demultiplex "DemultInput" Demult stampedInput + //let multiplexed = Scalar.Multiplex "Mult" Mult demultiplexedInput + let mapped = Vector.Map "Map" Map stampedInput let mapped = Vector.Stamp "FixedTime" FixedTimestamp mapped // Change in vector size should x-ray through even if timestamps haven't changed in remaining items. - let demultiplexed = Vector.Demultiplex "DemultResult" Result mapped - build.DeclareScalarOutput("Result", demultiplexed) + let result = Vector.Demultiplex "DemultResult" Result mapped + buildDesc.DeclareScalarOutput result // Create the build. - let build = build.GetInitialPartialBuild(["InputVector",1,[box "Input 0"]],[]) + let inputs = [ BuildInput.VectorInput(input, ["Input 0"]) ] + let bound = buildDesc.GetInitialPartialBuild inputs // Evaluate it with value 1 elements := 1 - let build = Eval "Result" build - let r1 = GetScalarResult("Result", build) + let bound = Eval result bound + let r1 = GetScalarResult(result, bound) match r1 with | Some(s,dt) -> printfn "%s" s | None -> failwith "" @@ -210,14 +216,13 @@ type IncrementalBuild() = System.Threading.Thread.Sleep(100) timestamp := System.DateTime.Now - - - let build = Eval "Result" build - let r2 = GetScalarResult("Result", build) + let bound = Eval result bound + let r2 = GetScalarResult (result, bound) match r2 with - | Some(s,dt) -> Assert.AreEqual("Mapped Element 1 ,Mapped Element 2 ",s) + | Some(s,dt) -> Assert.AreEqual("Mapped Input 0 ",s) | None -> failwith "" + (* /// Here, we want a multiplex to decrease the number of items processed. [] member public rb.MultiplexTransitionDown() = @@ -240,27 +245,27 @@ type IncrementalBuild() = printfn "Fixing timestamp" now - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let input = InputVector "InputVector" let stampedInput = Vector.Stamp "StampInput" Stamp input let demultiplexedInput = Vector.Demultiplex "DemultInput" Demult stampedInput let multiplexed = Scalar.Multiplex "Mult" Mult demultiplexedInput let mapped = Vector.Map "Map" Map multiplexed let fixedmapped = Vector.Stamp "FixedTime" FixedTimestamp mapped // Change in vector size should x-ray through even if timestamps haven't changed in remaining items. - let demultiplexed = Vector.Demultiplex "DemultResult" Result fixedmapped + let result = Vector.Demultiplex "DemultResult" Result fixedmapped - build.DeclareScalarOutput("DemultiplexedInput", demultiplexedInput) - build.DeclareVectorOutput("Mapped", mapped) - build.DeclareVectorOutput("FixedMapped", fixedmapped) - build.DeclareScalarOutput("Result", demultiplexed) + buildDesc.DeclareScalarOutput demultiplexedInput + buildDesc.DeclareVectorOutput mapped + buildDesc.DeclareVectorOutput fixedmapped + buildDesc.DeclareScalarOutput result // Create the build. - let build = build.GetInitialPartialBuild(["InputVector",1,[box "Input 0"]],[]) + let bound = buildDesc.GetInitialPartialBuild(["InputVector",1,[box "Input 0"]],[]) // Evaluate it with value 2 elements := 2 - let build = Eval "Result" build - let r1 = GetScalarResult("Result", build) + let bound = Eval result bound + let r1 = GetScalarResult(result, bound) match r1 with | Some(s,dt) -> printfn "%s" s | None -> failwith "" @@ -270,29 +275,30 @@ type IncrementalBuild() = System.Threading.Thread.Sleep(100) timestamp := System.DateTime.Now - let buildDemuxed = Eval "DemultiplexedInput" build - let rdm = GetScalarResult("DemultiplexedInput",buildDemuxed) + let buildDemuxed = Eval demultiplexedInput bound + let rdm = GetScalarResult (demultiplexedInput,buildDemuxed) match rdm with | Some(s,dt)->Assert.AreEqual("Demult Input 0", s) | None -> failwith "unexpected" - let buildMapped = Eval "Mapped" build - let mp = GetVectorResult("Mapped",buildMapped) + let buildMapped = Eval mapped bound + let mp = GetVectorResult (mapped,buildMapped) Assert.AreEqual(1,mp.Length) let melem = mp.[0] Assert.AreEqual("Mapped Element 1 ", melem) - let buildFixedMapped = Eval "FixedMapped" buildMapped - let mp = GetVectorResult("FixedMapped",buildFixedMapped) + let buildFixedMapped = Eval fixedmapped buildMapped + let mp = GetVectorResult (fixedmapped,buildFixedMapped) Assert.AreEqual(1,mp.Length) let melem = mp.[0] Assert.AreEqual("Mapped Element 1 ", melem) - let build = Eval "Result" build - let r2 = GetScalarResult("Result", build) + let bound = Eval result bound + let r2 = GetScalarResult(result, bound) match r2 with | Some(s,dt) -> Assert.AreEqual("Mapped Element 1 ",s) | None -> failwith "unexpected" + *) /// Test that stamp works [] @@ -306,24 +312,25 @@ type IncrementalBuild() = let StampFile(filename) = !stampAs - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let input = InputVector "InputVector" let stamped = Vector.Stamp "Stamp" StampFile input let mapped = Vector.Map "Map" MapIt stamped - build.DeclareVectorOutput("Mapped", mapped) - let build = build.GetInitialPartialBuild(["InputVector",3,[box "File1.fs";box "File2.fs";box "File3.fs"]],[]) + buildDesc.DeclareVectorOutput mapped + let inputs = [ BuildInput.VectorInput(input, ["File1.fs";"File2.fs";"File3.fs"]) ] + let bound = buildDesc.GetInitialPartialBuild inputs printf "-[Step1]----------------------------------------------------------------------------------------\n" // Evaluate the first time. - let build = Eval "Mapped" build - let r = GetVectorResult("Mapped",build) + let bound = Eval mapped bound + let r = GetVectorResult (mapped,bound) Assert.AreEqual("File2.fs.Suffix1",r.[1]) printf "-[Step2]----------------------------------------------------------------------------------------\n" // Evaluate the second time. No change should be seen. mapSuffix:="Suffix2" - let build = Eval "Mapped" build - let r = GetVectorResult("Mapped",build) + let bound = Eval mapped bound + let r = GetVectorResult (mapped,bound) Assert.AreEqual("File2.fs.Suffix1",r.[1]) printf "-[Step3]----------------------------------------------------------------------------------------\n" @@ -331,8 +338,8 @@ type IncrementalBuild() = while !stampAs = DateTime.Now do System.Threading.Thread.Sleep 10 // Sleep a little to avoid grabbing the same 'Now' stampAs:=DateTime.Now - let build = Eval "Mapped" build - let r = GetVectorResult("Mapped",build) + let bound = Eval mapped bound + let r = GetVectorResult (mapped,bound) Assert.AreEqual("File2.fs.Suffix2",r.[1]) /// Test that stamp works @@ -347,24 +354,25 @@ type IncrementalBuild() = let StampFile(filename) = !stampAs - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let input = InputVector "InputVector" let stamped = Vector.Stamp "Stamp" StampFile input let joined = Vector.Demultiplex "Demultiplex" Join stamped - build.DeclareScalarOutput("Joined", joined) - let build = build.GetInitialPartialBuild(["InputVector",3,[box "File1.fs";box "File2.fs";box "File3.fs"]],[]) + buildDesc.DeclareScalarOutput joined + let inputs = [ BuildInput.VectorInput(input, ["File1.fs";"File2.fs";"File3.fs"]) ] + let bound = buildDesc.GetInitialPartialBuild inputs printf "-[Step1]----------------------------------------------------------------------------------------\n" // Evaluate the first time. - let build = Eval "Joined" build - let (r,_) = Option.get (GetScalarResult("Joined",build)) + let bound = Eval joined bound + let (r,_) = Option.get (GetScalarResult(joined,bound)) Assert.AreEqual("Join1",r) printf "-[Step2]----------------------------------------------------------------------------------------\n" // Evaluate the second time. No change should be seen. joinedResult:="Join2" - let build = Eval "Joined" build - let (r,_) = Option.get (GetScalarResult("Joined",build)) + let bound = Eval joined bound + let (r,_) = Option.get (GetScalarResult (joined,bound)) Assert.AreEqual("Join1",r) printf "-[Step3]----------------------------------------------------------------------------------------\n" @@ -372,8 +380,8 @@ type IncrementalBuild() = while !stampAs = DateTime.Now do System.Threading.Thread.Sleep 10 // Sleep a little to avoid grabbing the same 'Now' stampAs:=DateTime.Now - let build = Eval "Joined" build - let (r,_) = Option.get (GetScalarResult("Joined",build)) + let bound = Eval joined bound + let (r,_) = Option.get (GetScalarResult (joined,bound)) Assert.AreEqual("Join2",r) @@ -382,62 +390,71 @@ type IncrementalBuild() = member public rb.DemultiplexScanLeft() = let Size(ar:_[]) = ar.Length let Scan acc (file :string) = eventually { return acc + file.Length } - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let inVector = InputVector "InputVector" let vectorSize = Vector.Demultiplex "Demultiplex" Size inVector let scanned = Vector.ScanLeft "Scan" Scan vectorSize inVector - build.DeclareScalarOutput("Size", vectorSize) - build.DeclareVectorOutput("Scanned", scanned) - let build = build.GetInitialPartialBuild(["InputVector",3,[box "File1.fs";box "File2.fs";box "File3.fs"]],[]) + buildDesc.DeclareScalarOutput vectorSize + buildDesc.DeclareVectorOutput scanned + let inputs = [ BuildInput.VectorInput(inVector, ["File1.fs";"File2.fs";"File3.fs"]) ] + let bound = buildDesc.GetInitialPartialBuild inputs - let e = Eval "Scanned" build - let r = GetScalarResult("Size",e) + let e = Eval scanned bound + let r = GetScalarResult (vectorSize,e) match r with - | Some(r,_)->Assert.AreEqual(3,r) + | Some(r,_) -> Assert.AreEqual(3,r) | None -> Assert.Fail("No size was returned") + (* /// Test that Scalar.Multiplex works. [] member public rb.ScalarMultiplex() = let MultiplexScalar inp = [|inp+":1";inp+":2";inp+":3"|] - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let inScalar = InputScalar "Scalar" - let multiplexed = Scalar.Multiplex "MultiplexScalar" MultiplexScalar inScalar - build.DeclareVectorOutput("Output", multiplexed) + let result = Scalar.Multiplex "MultiplexScalar" MultiplexScalar inScalar + buildDesc.DeclareVectorOutput result - let b = build.GetInitialPartialBuild([],["Scalar",box "A Scalar Value"]) - let e = Eval "Output" b - let r = GetVectorResult("Output",e) + let b = buildDesc.GetInitialPartialBuild([],["Scalar",box "A Scalar Value"]) + let e = Eval result b + let r = GetVectorResult(result,e) Assert.AreEqual("A Scalar Value:2", r.[1]) + /// Test that Scalar.Map works. [] member public rb.ScalarMap() = let MapScalar inp = "out:"+inp - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let inScalar = InputScalar "Scalar" - let mappedScalar = Scalar.Map "MapScalar" MapScalar inScalar - build.DeclareScalarOutput("Output", mappedScalar) + let result = Scalar.Map "MapScalar" MapScalar inScalar + buildDesc.DeclareScalarOutput result - let b = build.GetInitialPartialBuild([],["Scalar",box "A Scalar Value"]) - let e = Eval "Output" b - let r = GetScalarResult("Output",e) + let inputs = [ BuildInput.ScalarInput(inScalar, "A Scalar Value") ] + let bound = buildDesc.GetInitialPartialBuild inputs + + let b = buildDesc.GetInitialPartialBuild([],["Scalar",box "A Scalar Value"]) + let e = Eval result bound + let r = GetScalarResult(result,e) match r with | Some(r,_) -> Assert.AreEqual("out:A Scalar Value", r) | None -> Assert.Fail() - + *) + /// Test that a simple scalar action works. [] member public rb.Scalar() = - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let inScalar = InputScalar "Scalar" - build.DeclareScalarOutput("Output", inScalar) - let b = build.GetInitialPartialBuild([],["Scalar",box "A Scalar Value"]) - let e = Eval "Output" b - let r = GetScalarResult("Output",e) + buildDesc.DeclareScalarOutput inScalar + let inputs = [ BuildInput.ScalarInput(inScalar, "A Scalar Value") ] + let bound = buildDesc.GetInitialPartialBuild inputs + + let e = Eval inScalar bound + let r = GetScalarResult(inScalar,e) match r with | Some(r,_) -> Assert.AreEqual("A Scalar Value", r) | None -> Assert.Fail() @@ -448,15 +465,19 @@ type IncrementalBuild() = let DoIt (a:int*string) (b:string) = eventually { return ((fst a)+1,b) } - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let inScalar = InputScalar "InputScalar" let inVector = InputVector "InputVector" - let scanned = Vector.ScanLeft "DoIt" DoIt inScalar inVector - build.DeclareVectorOutput("Output", scanned) + let result = Vector.ScanLeft "DoIt" DoIt inScalar inVector + buildDesc.DeclareVectorOutput result - let build = build.GetInitialPartialBuild(["InputVector",3,[box "File1.fs";box "File2.fs";box "File3.fs"]],["InputScalar",box (5,"")]) - let e = Eval "Output" build - let r = GetVectorResult("Output",e) + let inputs = + [ BuildInput.VectorInput(inVector, ["File1.fs";"File2.fs";"File3.fs"]); + BuildInput.ScalarInput(inScalar, (5,"")) ] + + let bound = buildDesc.GetInitialPartialBuild(inputs) + let e = Eval result bound + let r = GetVectorResult(result,e) if [| (6,"File1.fs"); (7,"File2.fs"); (8, "File3.fs") |] <> r then printfn "Got %A" r Assert.Fail() @@ -465,13 +486,15 @@ type IncrementalBuild() = /// Convert a vector to a scalar [] member public rb.ToScalar() = - let build = new BuildDescriptionScope() + let buildDesc = new BuildDescriptionScope() let inVector = InputVector "InputVector" - let asScalar = Vector.ToScalar "ToScalar" inVector - build.DeclareScalarOutput("Output", asScalar) - let build = build.GetInitialPartialBuild(["InputVector",3,[box "File1.fs";box "File2.fs";box "File3.fs"]],[]) - let e = Eval "Output" build - let r = GetScalarResult("Output",e) + let result = Vector.ToScalar "ToScalar" inVector + buildDesc.DeclareScalarOutput result + let inputs = [ BuildInput.VectorInput(inVector, ["File1.fs";"File2.fs";"File3.fs"]) ] + let bound = buildDesc.GetInitialPartialBuild(inputs) + + let e = Eval result bound + let r = GetScalarResult (result, e) match r with | Some(r,ts)-> if "File3.fs"<>(r.[2]) then @@ -485,65 +508,66 @@ type IncrementalBuild() = /// that were new at the time: Scalars, Invalidation, Disposal [] member public rb.AssemblyReferenceModel() = - let Parse(filename) = sprintf "Parse(%s)" filename + let ParseTask(filename) = sprintf "Parse(%s)" filename + let now = System.DateTime.Now + let StampFileNameTask filename = now + let TimestampReferencedAssemblyTask reference = now let ApplyMetaCommands(parseResults:string[]) = "tcConfig-of("+String.Join(",",parseResults)+")" let GetReferencedAssemblyNames(tcConfig) = [|"Assembly1.dll";"Assembly2.dll";"Assembly3.dll"|] let ReadAssembly(assemblyName) = sprintf "tcImport-of(%s)" assemblyName - let CombineImports(imports) = "tcAcc" - let TypeCheck tcAcc parseResults = eventually { return tcAcc } + let CombineImportedAssembliesTask(imports) = "tcAcc" + let TypeCheckTask tcAcc parseResults = eventually { return tcAcc } + let FinalizeTypeCheckTask results = "finalized" // Build rules. - let build = new BuildDescriptionScope() - let filenames = InputVector "Filenames" - let parseTrees = Vector.Map "Parse" Parse filenames - let parseTreesAsScalar = Vector.ToScalar "ScalarizeParseTrees" parseTrees - let tcConfig = Scalar.Map "ApplyMetaCommands" ApplyMetaCommands parseTreesAsScalar - let referencedAssemblyNames = Scalar.Multiplex "GetReferencedAssemblyNames" GetReferencedAssemblyNames tcConfig - let readAssemblies = Vector.Map "ReadAssembly" ReadAssembly referencedAssemblyNames - let tcAcc = Vector.Demultiplex "CombineImports" CombineImports readAssemblies - let tcResults = Vector.ScanLeft "TypeCheck" TypeCheck tcAcc parseTrees - build.DeclareVectorOutput("TypeCheckingStates",tcResults) - - let build = build.GetInitialPartialBuild(["Filenames",3,[box "File1.fs";box "File2.fs";box "File3.fs"]],[]) - let e = Eval "TypeCheckingStates" build - let r = GetVectorResult("TypeCheckingStates",e) + let buildDesc = new BuildDescriptionScope() + + // Inputs + let fileNamesNode = InputVector "Filenames" + let referencedAssembliesNode = InputVector "ReferencedAssemblies" + + //Build + let stampedFileNamesNode = Vector.Stamp "SourceFileTimeStamps" StampFileNameTask fileNamesNode + let parseTreesNode = Vector.Map "ParseTrees" ParseTask stampedFileNamesNode + let stampedReferencedAssembliesNode = Vector.Stamp "TimestampReferencedAssembly" TimestampReferencedAssemblyTask referencedAssembliesNode + + let initialTcAccNode = Vector.Demultiplex "CombineImportedAssemblies" CombineImportedAssembliesTask stampedReferencedAssembliesNode + + let tcStatesNode = Vector.ScanLeft "TypeCheckingStates" TypeCheckTask initialTcAccNode parseTreesNode + + let finalizedTypeCheckNode = Vector.Demultiplex "FinalizeTypeCheck" FinalizeTypeCheckTask tcStatesNode + let buildDesc = new BuildDescriptionScope () + + do buildDesc.DeclareVectorOutput stampedFileNamesNode + do buildDesc.DeclareVectorOutput stampedReferencedAssembliesNode + do buildDesc.DeclareVectorOutput parseTreesNode + do buildDesc.DeclareVectorOutput tcStatesNode + do buildDesc.DeclareScalarOutput initialTcAccNode + do buildDesc.DeclareScalarOutput finalizedTypeCheckNode + + let inputs = + [ BuildInput.VectorInput(fileNamesNode, ["File1.fs";"File2.fs";"File3.fs"]); + BuildInput.VectorInput(referencedAssembliesNode, [("lib1.dll", now);("lib2.dll", now)]) ] + let bound = buildDesc.GetInitialPartialBuild(inputs) + let e = Eval finalizedTypeCheckNode bound + let r = GetScalarResult(finalizedTypeCheckNode,e) () -#if NUNIT_V2 - [)>] - member public rb.DuplicateExpressionNamesNotAllowed() = - let DoIt s = s - () -#else - [] - member public rb.DuplicateExpressionNamesNotAllowed() = - Assert.That((fun () -> let DoIt s = s - let b = - let build = new BuildDescriptionScope() - let i = InputVector "Input" - let r = Vector.Map "Input" DoIt i - build.DeclareVectorOutput("Output",r) - build.GetInitialPartialBuild(["Input",1,[box ""]],[]) - - let e = Eval "Output" b - ()), NUnit.Framework.Throws.TypeOf(typeof)) -#endif - [] member public rb.OneToOneWorks() = let VectorModify (input:int) : string = sprintf "Transformation of %d" input - let bound = - let build = new BuildDescriptionScope() - let inputs = InputVector "Inputs" - let outputs = Vector.Map "Modify" VectorModify inputs - build.DeclareVectorOutput("Outputs",outputs) - build.GetInitialPartialBuild(["Inputs",4,[box 1;box 2;box 3;box 4]],[]) + let buildDesc = new BuildDescriptionScope() + let inputs = InputVector "Inputs" + let outputs = Vector.Map "Modify" VectorModify inputs + buildDesc.DeclareVectorOutput outputs + let inputs = [ BuildInput.VectorInput(inputs, [1;2;3;4]) ] + let bound = buildDesc.GetInitialPartialBuild inputs - let evaled = bound |> Eval "Outputs" - let outputs = GetVectorResult("Outputs",evaled) + let evaled = Eval outputs bound + let outputs = GetVectorResult(outputs,evaled) Assert.AreEqual("Transformation of 4", outputs.[3]) () @@ -554,21 +578,21 @@ type IncrementalBuild() = let VectorModify (input:int) : string = sprintf "Transformation of %d" input - let bound = - let build = new BuildDescriptionScope() - let inputs = InputVector "Inputs" - let outputs = Vector.Map "Modify" VectorModify inputs - build.DeclareVectorOutput("Inputs1", inputs) - build.DeclareVectorOutput("Inputs2", inputs) - build.DeclareVectorOutput("Inputs3", inputs) - build.DeclareVectorOutput("Outputs", outputs) - build.DeclareVectorOutput("Inputs4", inputs) - build.DeclareVectorOutput("Inputs5", inputs) - build.DeclareVectorOutput("Inputs6", inputs) - build.GetInitialPartialBuild(["Inputs",4,[box 1;box 2;box 3;box 4]],[]) - - let evaled = bound |> Eval "Outputs" - let outputs = GetVectorResult("Outputs",evaled) + let buildDesc = new BuildDescriptionScope() + let inputs = InputVector "Inputs" + let outputs = Vector.Map "Modify" VectorModify inputs + buildDesc.DeclareVectorOutput inputs + buildDesc.DeclareVectorOutput inputs + buildDesc.DeclareVectorOutput inputs + buildDesc.DeclareVectorOutput outputs + buildDesc.DeclareVectorOutput inputs + buildDesc.DeclareVectorOutput inputs + buildDesc.DeclareVectorOutput inputs + let inputs = [ BuildInput.VectorInput(inputs, [1;2;3;4]) ] + let bound = buildDesc.GetInitialPartialBuild inputs + + let evaled = Eval outputs bound + let outputs = GetVectorResult(outputs,evaled) Assert.AreEqual("Transformation of 4", outputs.[3]) () @@ -578,14 +602,14 @@ type IncrementalBuild() = let VectorModify (input:int) : string = sprintf "Transformation of %d" input - let bound = - let build = new BuildDescriptionScope() - let inputs = InputVector "Inputs" - let outputs = Vector.Map "Modify" VectorModify inputs - build.DeclareVectorOutput("Outputs", outputs) - build.GetInitialPartialBuild(["Inputs",0,[]],[]) + let buildDesc = new BuildDescriptionScope() + let inputs = InputVector "Inputs" + let outputs = Vector.Map "Modify" VectorModify inputs + buildDesc.DeclareVectorOutput outputs + let inputs = [ BuildInput.VectorInput(inputs, []) ] + let bound = buildDesc.GetInitialPartialBuild inputs - let evaled = bound |> Eval "Outputs" - let outputs = GetVectorResult("Outputs",evaled) + let evaled = Eval outputs bound + let outputs = GetVectorResult(outputs,evaled) () diff --git a/vsintegration/src/unittests/Tests.LanguageService.NavigationBar.fs b/vsintegration/src/unittests/Tests.LanguageService.NavigationBar.fs index f58510d00..2c0c2b1b2 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.NavigationBar.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.NavigationBar.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.NavigationBar open System open NUnit.Framework @@ -9,64 +9,15 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -type NavigationBarTests() = +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() - (* Unit tests for collapse region & navigation bar ------------------------------------- *) - - member private this.TestNavigationBar (file : string list) findDecl expectedMembers = - - let (_, _, file) = this.CreateSingleFileProject(file) - - // Verify that the types&modules list contains 'findDecl' - let navigation = GetNavigationContentAtCursor(file) - AssertNavigationContains(navigation.TypesAndModules, findDecl) - let idxDecl = navigation.TypesAndModules |> Array.findIndex (fun nav -> nav.Label = findDecl) - let decl = navigation.TypesAndModules.[idxDecl] - - // Navigate to the definition and get the contents again - MoveCursorTo(file, decl.Span.iStartLine + 1, decl.Span.iStartIndex) // line index is in the 0-based form - let navigation = GetNavigationContentAtCursor(file) - // Ensure that the right thing is selected in the dropdown - AssertEqual(idxDecl, navigation.SelectedType) - // Ensure that member list contains expected members - AssertNavigationContainsAll(navigation.Members, expectedMembers) - - // Find member declaration, go to the location & test the identifier island - for memb in expectedMembers do - let decl = navigation.Members |> Array.find (fun nav -> nav.Label = memb) - MoveCursorTo(file, decl.Span.iStartLine + 1, decl.Span.iStartIndex + 1) - match GetIdentifierAtCursor file with - | None -> - Assert.Fail("No identifier at cursor!") - | Some (id, _) -> - if not (id.Contains(memb)) then Assert.Fail(sprintf "Found '%s' which isn't substring of the expected '%s'." id memb) - - member private this.TestHiddenRegions (file : list) regionMarkers = - let (_, _, file) = this.CreateSingleFileProject(file) - - // Find locations of the regions based on markers provided - let expectedLocations = - [ for ms, me in regionMarkers do - MoveCursorToEndOfMarker(file, ms) - let sl, sc = GetCursorLocation(file) - MoveCursorToStartOfMarker(file, me) - let el, ec = GetCursorLocation(file) - // -1 to adjust line to VS format - // -1 to adjust columns (not quite sure why..) - yield (sl-1, sc-1), (el-1, ec-1) ] - - // Test whether the regions are same and that no 'update' commands are created (no regions exist prior to this call) - let toCreate, toUpdate = GetHiddenRegionCommands(file) - if (toUpdate <> Map.empty<_,_>) then - Assert.Fail("Hidden regions, first call. Didn't expect any regions to update.") - AssertEqualWithMessage(expectedLocations.Length, toCreate.Length, "Different number of regions!") - AssertRegionListContains(expectedLocations, toCreate) - (* Files for testing and tests --------------------------------------------------------- *) - static member NavigationFile1 = + let NavigationFile1 = [ "#light" "module Example.Module" "" @@ -88,38 +39,7 @@ type NavigationBarTests() = "" " type EnumOneLine = (*5s*)| OUAaa = 0 | OUBbb = 3(*5e*)" ] - [] - member public this.``Regions.NavigationFile1``() = - this.TestHiddenRegions NavigationBarTests.NavigationFile1 - [ "(*1s*)", "(*1e*)" - "(*2s*)", "(*2e*)" - "(*3s*)", "(*3e*)" - "(*4s*)", "(*4e*)" - "(*5s*)", "(*5e*)" - "SomeModule", "(*5e*)" (* entire module *) ] - - [] - [] - member public this.``Record1``() = - this.TestNavigationBar NavigationBarTests.NavigationFile1 "SomeModule.Rec" ["RFirst"; "RSecond"] - - [] - member public this.``Record2``() = - this.TestNavigationBar NavigationBarTests.NavigationFile1 "SomeModule.Rec2" ["R2First"; "R2Second"] - - [] - member public this.``Abbreviation``() = - this.TestNavigationBar NavigationBarTests.NavigationFile1 "SomeModule.Abbrev" [] - - [] - member public this.``Enum``() = - this.TestNavigationBar NavigationBarTests.NavigationFile1 "SomeModule.Enum" [ "Aaa"; "Bbb" ] - - [] - member public this.``Enum.OneLine``() = - this.TestNavigationBar NavigationBarTests.NavigationFile1 "SomeModule.EnumOneLine" [ "OUAaa"; "OUBbb" ] - - static member NavigationFile2 = + let NavigationFile2 = [ "#light" "module A = " "" @@ -176,64 +96,131 @@ type NavigationBarTests() = " let aa () =" " 1(*15e*) " ] + + (* Unit tests for collapse region & navigation bar ------------------------------------- *) + + member private this.TestNavigationBar (file : string list) findDecl expectedMembers = + + let (_, _, file) = this.CreateSingleFileProject(file) + + // Verify that the types&modules list contains 'findDecl' + let navigation = GetNavigationContentAtCursor(file) + AssertNavigationContains(navigation.TypesAndModules, findDecl) + let idxDecl = navigation.TypesAndModules |> Array.findIndex (fun nav -> nav.Label = findDecl) + let decl = navigation.TypesAndModules.[idxDecl] + + // Navigate to the definition and get the contents again + MoveCursorTo(file, decl.Span.iStartLine + 1, decl.Span.iStartIndex) // line index is in the 0-based form + let navigation = GetNavigationContentAtCursor(file) + // Ensure that the right thing is selected in the dropdown + AssertEqual(idxDecl, navigation.SelectedType) + // Ensure that member list contains expected members + AssertNavigationContainsAll(navigation.Members, expectedMembers) + + // Find member declaration, go to the location & test the identifier island + for memb in expectedMembers do + let decl = navigation.Members |> Array.find (fun nav -> nav.Label = memb) + MoveCursorTo(file, decl.Span.iStartLine + 1, decl.Span.iStartIndex + 1) + match GetIdentifierAtCursor file with + | None -> + Assert.Fail("No identifier at cursor!") + | Some (id, _) -> + if not (id.Contains(memb)) then Assert.Fail(sprintf "Found '%s' which isn't substring of the expected '%s'." id memb) + + member private this.TestHiddenRegions (file : list) regionMarkers = + let (_, _, file) = this.CreateSingleFileProject(file) + + // Find locations of the regions based on markers provided + let expectedLocations = + [ for ms, me in regionMarkers do + MoveCursorToEndOfMarker(file, ms) + let sl, sc = GetCursorLocation(file) + MoveCursorToStartOfMarker(file, me) + let el, ec = GetCursorLocation(file) + // -1 to adjust line to VS format + // -1 to adjust columns (not quite sure why..) + yield (sl-1, sc-1), (el-1, ec-1) ] + + // Test whether the regions are same and that no 'update' commands are created (no regions exist prior to this call) + let toCreate, toUpdate = GetHiddenRegionCommands(file) + if (toUpdate <> Map.empty<_,_>) then + Assert.Fail("Hidden regions, first call. Didn't expect any regions to update.") + AssertEqualWithMessage(expectedLocations.Length, toCreate.Length, "Different number of regions!") + AssertRegionListContains(expectedLocations, toCreate) + + [] + member public this.``Regions.NavigationFile1``() = + this.TestHiddenRegions NavigationFile1 + [ "(*1s*)", "(*1e*)" + "(*2s*)", "(*2e*)" + "(*3s*)", "(*3e*)" + "(*4s*)", "(*4e*)" + "(*5s*)", "(*5e*)" + "SomeModule", "(*5e*)" (* entire module *) ] + + [] + [] + member public this.``Record1``() = + this.TestNavigationBar NavigationFile1 "SomeModule.Rec" ["RFirst"; "RSecond"] + + [] + member public this.``Record2``() = + this.TestNavigationBar NavigationFile1 "SomeModule.Rec2" ["R2First"; "R2Second"] + + [] + member public this.``Abbreviation``() = + this.TestNavigationBar NavigationFile1 "SomeModule.Abbrev" [] + + [] + member public this.``Enum``() = + this.TestNavigationBar NavigationFile1 "SomeModule.Enum" [ "Aaa"; "Bbb" ] + + [] + member public this.``Enum.OneLine``() = + this.TestNavigationBar NavigationFile1 "SomeModule.EnumOneLine" [ "OUAaa"; "OUBbb" ] + [] member public this.``Record.WithMembers``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "A.RecWith" ["WRFirst"; "WRSecond"; "RecMember" ] + this.TestNavigationBar NavigationFile2 "A.RecWith" ["WRFirst"; "WRSecond"; "RecMember" ] [] member public this.``Union.WithMembers``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.Union" ["UFirst"; "USecond"; "A"] + this.TestNavigationBar NavigationFile2 "B.Union" ["UFirst"; "USecond"; "A"] [] member public this.``Class``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.A" ["Prop"; "Func"; "Dispose"] // perhaps IDisposable.Dispose + this.TestNavigationBar NavigationFile2 "B.A" ["Prop"; "Func"; "Dispose"] // perhaps IDisposable.Dispose [] member public this.``Exception``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.SomeCrash" [ ] + this.TestNavigationBar NavigationFile2 "B.SomeCrash" [ ] [] member public this.``Module.Alias``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.MyList" [ ] + this.TestNavigationBar NavigationFile2 "B.MyList" [ ] [] member public this.``NestedEnum``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.MoreNested.MyEnum" [ "One"; "Two"; "Three" ] + this.TestNavigationBar NavigationFile2 "B.MoreNested.MyEnum" [ "One"; "Two"; "Three" ] [] member public this.``Extension``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.AExt" [ "Extension1"; "Extension2" ] + this.TestNavigationBar NavigationFile2 "B.AExt" [ "Extension1"; "Extension2" ] [] member public this.``Type.EndingWithProperty.WithTypeAnnotation``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.Z" [ "Z" ] + this.TestNavigationBar NavigationFile2 "B.Z" [ "Z" ] [] member public this.``Module.Nested``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.FooBaz" [ "toplevel" ] + this.TestNavigationBar NavigationFile2 "B.FooBaz" [ "toplevel" ] [] member public this.``Module.Nested.More``() = - this.TestNavigationBar NavigationBarTests.NavigationFile2 "B.FooBaz.NestedModule" [ "nestedThing" ] - -// Allow the NavigationBarTests run under different context -namespace UnitTests.Tests.LanguageService.NavigationBar -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa + this.TestNavigationBar NavigationFile2 "B.FooBaz.NestedModule" [ "nestedThing" ] -// context msbuild -[] -[] -type ``MSBuild`` = - inherit NavigationBarTests - new() = { inherit NavigationBarTests(VsOpts = fst (Models.MSBuild())); } // Context project system [] -[] -type ``ProjectSystem`` = - inherit NavigationBarTests - new() = { inherit NavigationBarTests(VsOpts = LanguageServiceExtension.ProjectSystem); } \ No newline at end of file +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) \ No newline at end of file diff --git a/vsintegration/src/unittests/Tests.LanguageService.ParameterInfo.fs b/vsintegration/src/unittests/Tests.LanguageService.ParameterInfo.fs index 10353c4cd..fa818c536 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.ParameterInfo.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.ParameterInfo.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.ParameterInfo open System open NUnit.Framework @@ -9,14 +9,15 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -exception NoParamInfo [] module ParamInfoStandardSettings = let standard40AssemblyRefs = [| "System"; "System.Core"; "System.Numerics" |] let queryAssemblyRefs = [ "System.Xml.Linq"; "System.Core" ] -type ParameterInfoTests() = +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() let GetParamDisplays(methods:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip) = @@ -25,8 +26,8 @@ type ParameterInfoTests() = let (name,display,description) = methods.GetParameterInfo(i,j) yield display ] ] - let AssertEmptyMethodGroup(resultMethodGroup:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip) = - Assert.AreEqual(null, resultMethodGroup, "Expected an empty method group") + let AssertEmptyMethodGroup(resultMethodGroup:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip option) = + Assert.IsTrue(resultMethodGroup.IsNone, "Expected an empty method group") let AssertMethodGroupDesciptionsDoNotContain(methods:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip, expectNotToBeThere) = for i = 0 to methods.GetCount() - 1 do @@ -35,7 +36,9 @@ type ParameterInfoTests() = Console.WriteLine("Expected description {0} to not contain {1}", description, expectNotToBeThere) AssertNotContains(description,expectNotToBeThere) - let AssertMethodGroup(resultMethodGroup:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip, expectedParamNamesSet:string list list) = + let AssertMethodGroup(resultMethodGroup:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip option, expectedParamNamesSet:string list list) = + Assert.IsTrue(resultMethodGroup.IsSome, "Expected a method group") + let resultMethodGroup = resultMethodGroup.Value Assert.AreEqual(expectedParamNamesSet.Length, resultMethodGroup.GetCount()) Assert.IsTrue(resultMethodGroup |> GetParamDisplays @@ -45,7 +48,9 @@ type ParameterInfoTests() = (expectedParamNames,paramDisplays) ||> List.forall2 (fun expectedParamName paramDisplay -> paramDisplay.Contains(expectedParamName))))) - let AssertMethodGroupContain(resultMethodGroup:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip, expectedParamNames:string list) = + let AssertMethodGroupContain(resultMethodGroup:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip option, expectedParamNames:string list) = + Assert.IsTrue(resultMethodGroup.IsSome, "Expected a method group") + let resultMethodGroup = resultMethodGroup.Value Assert.IsTrue(resultMethodGroup |> GetParamDisplays |> Seq.exists (fun paramDisplays -> @@ -62,59 +67,60 @@ type ParameterInfoTests() = //Verify all the overload method parameterInfo member private this.VerifyParameterInfoAtStartOfMarker(fileContents : string, marker : string, expectedParamNamesSet:string list list, ?addtlRefAssy :list) = - let methodstr = - match addtlRefAssy with - |None -> this.GetMethodListForAMethodTip(fileContents,marker) - |Some(x) -> this.GetMethodListForAMethodTip(fileContents,marker,x) + let methodstr = this.GetMethodListForAMethodTip(fileContents,marker,?addtlRefAssy=addtlRefAssy) AssertMethodGroup(methodstr,expectedParamNamesSet) //Verify No parameterInfo at the marker member private this.VerifyNoParameterInfoAtStartOfMarker(fileContents : string, marker : string, ?addtlRefAssy : list) = - let methodstr = - match addtlRefAssy with - |None -> this.GetMethodListForAMethodTip(fileContents,marker) - |Some(x) -> this.GetMethodListForAMethodTip(fileContents,marker,x) + let methodstr = this.GetMethodListForAMethodTip(fileContents,marker,?addtlRefAssy=addtlRefAssy) AssertEmptyMethodGroup(methodstr) //Verify one method parameterInfo if contained in parameterInfo list member private this.VerifyParameterInfoContainedAtStartOfMarker(fileContents : string, marker : string, expectedParamNames:string list, ?addtlRefAssy : list) = - let methodstr = - match addtlRefAssy with - |None -> this.GetMethodListForAMethodTip(fileContents,marker) - |Some(x) -> this.GetMethodListForAMethodTip(fileContents,marker,x) + let methodstr = this.GetMethodListForAMethodTip(fileContents,marker,?addtlRefAssy=addtlRefAssy) AssertMethodGroupContain(methodstr,expectedParamNames) //Verify the parameterInfo of one of the list order member private this.VerifyParameterInfoOverloadMethodIndex(fileContents : string, marker : string, index : int, expectedParams:string list, ?addtlRefAssy : list) = - let methodstr = - match addtlRefAssy with - |None -> this.GetMethodListForAMethodTip(fileContents,marker) - |Some(x) -> this.GetMethodListForAMethodTip(fileContents,marker,x) - - let GetPramDisplaysByIndex(methods:Microsoft.VisualStudio.FSharp.LanguageService.MethodListForAMethodTip) = - [ for i = 0 to methods.GetParameterCount(index) - 1 do - let (name,display,description) = methods.GetParameterInfo(index,i) + let methodstr = this.GetMethodListForAMethodTip(fileContents,marker,?addtlRefAssy=addtlRefAssy) + Assert.IsTrue(methodstr.IsSome, "Expected a method group") + let methodstr = methodstr.Value + + let paramDisplays = + [ for i = 0 to methodstr.GetParameterCount(index) - 1 do + let (name,display,description) = methodstr.GetParameterInfo(index,i) yield display] - let paramDisplays = GetPramDisplaysByIndex methodstr - Assert.IsTrue((expectedParams, paramDisplays) ||> List.forall2 (fun expectedParam paramDisplay -> - paramDisplay.Contains(expectedParam))) + Assert.IsTrue((expectedParams, paramDisplays) ||> List.forall2 (fun expectedParam paramDisplay -> paramDisplay.Contains(expectedParam))) + //Verify there is at least one parameterInfo member private this.VerifyHasParameterInfo(fileContents : string, marker : string) = let methodstr = this.GetMethodListForAMethodTip(fileContents,marker) + Assert.IsTrue(methodstr.IsSome, "Expected a method group") + let methodstr = methodstr.Value + Assert.IsTrue (methodstr.GetCount() > 0) + //Verify return content after the colon member private this.VerifyFirstParameterInfoColonContent(fileContents : string, marker : string, expectedStr : string, ?addtlRefAssy : list) = - let methodstr = - match addtlRefAssy with - |None -> this.GetMethodListForAMethodTip(fileContents,marker) - |Some(x) -> this.GetMethodListForAMethodTip(fileContents,marker,x) + let methodstr = this.GetMethodListForAMethodTip(fileContents,marker,?addtlRefAssy=addtlRefAssy) + Assert.IsTrue(methodstr.IsSome, "Expected a method group") + let methodstr = methodstr.Value Assert.AreEqual(expectedStr, methodstr.GetType(0)) // Expecting a method info like X(a:int,b:int) : int [used to be X(a:int,b:int) -> int] + member private this.VerifyParameterCount(fileContents : string, marker : string, expectedCount: int) = + let methodstr = this.GetMethodListForAMethodTip(fileContents,marker) + Assert.IsTrue(methodstr.IsSome, "Expected a method group") + let methodstr = methodstr.Value + Assert.AreEqual(0, methodstr.GetParameterCount(expectedCount)) + [] member public this.``Regression.OnConstructor.881644``() = let fileContent = """new System.IO.StreamReader((*Mark*)""" let methodstr = this.GetMethodListForAMethodTip(fileContent,"(*Mark*)") + Assert.IsTrue(methodstr.IsSome, "Expected a method group") + let methodstr = methodstr.Value + if not (methodstr.GetDescription(0).Contains("#ctor")) then failwith "Expected parameter info to contain #ctor" @@ -127,6 +133,9 @@ type ParameterInfoTests() = let! buffer = file.AsyncRead((*Mark*)0) return 0 }""" let methodstr = this.GetMethodListForAMethodTip(fileContent,"(*Mark*)") + Assert.IsTrue(methodstr.IsSome, "Expected a method group") + let methodstr = methodstr.Value + if not (methodstr.GetDescription(0).Contains("AsyncRead")) then failwith "Expected parameter info to contain AsyncRead" @@ -198,6 +207,9 @@ type ParameterInfoTests() = member public this.``Regression.MethodInfo.Bug808310``() = let fileContent = """System.Console.WriteLine((*Mark*)""" let methodGroup = this.GetMethodListForAMethodTip(fileContent,"(*Mark*)") + Assert.IsTrue(methodGroup.IsSome, "Expected a method group") + let methodGroup = methodGroup.Value + let description = methodGroup.GetDescription(0) // Make sure that System.Console.WriteLine is not mentioned anywhere exception in the XML comment signature let xmlCommentIndex = description.IndexOf("System.Console.WriteLine]") @@ -223,10 +235,10 @@ type ParameterInfoTests() = let h((x:unit)) = 42 let r3 = h((*3*)) let r4 = g((*4*))""" - Assert.AreEqual(0, this.GetMethodListForAMethodTip(fileContents,"(*1*)").GetParameterCount(0)) - Assert.AreEqual(0, this.GetMethodListForAMethodTip(fileContents,"(*2*)").GetParameterCount(0)) - Assert.AreEqual(0, this.GetMethodListForAMethodTip(fileContents,"(*3*)").GetParameterCount(0)) - Assert.AreEqual(0, this.GetMethodListForAMethodTip(fileContents,"(*4*)").GetParameterCount(0)) + this.VerifyParameterCount(fileContents,"(*1*)", 0) + this.VerifyParameterCount(fileContents,"(*2*)", 0) + this.VerifyParameterCount(fileContents,"(*3*)", 0) + this.VerifyParameterCount(fileContents,"(*4*)", 0) [] member public this.``Single.Constructor1``() = @@ -317,7 +329,7 @@ type ParameterInfoTests() = let foo = N1.T1.M1((*Marker*) """ this.VerifyParameterInfoAtStartOfMarker(fileContent,"(*Marker*)",[["arg1"]], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -328,7 +340,7 @@ type ParameterInfoTests() = let foo = N1.T1.M2((*Marker*) """ this.VerifyParameterInfoAtStartOfMarker(fileContent,"(*Marker*)",[["arg1";"arg2"]], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -341,7 +353,7 @@ type ParameterInfoTests() = let foo = N1.T1.M2((*Marker*) """ this.VerifyFirstParameterInfoColonContent(fileContent,"(*Marker*)",": int", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] @@ -353,7 +365,7 @@ type ParameterInfoTests() = let foo = new N1.T1((*Marker*) """ this.VerifyParameterInfoOverloadMethodIndex(fileContent,"(*Marker*)",0,[], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -364,7 +376,7 @@ type ParameterInfoTests() = let foo = new N1.T1((*Marker*) """ this.VerifyParameterInfoOverloadMethodIndex(fileContent,"(*Marker*)",1,["arg1"], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -375,7 +387,7 @@ type ParameterInfoTests() = let foo = new N1.T1((*Marker*) """ this.VerifyParameterInfoOverloadMethodIndex(fileContent,"(*Marker*)",2,["arg1";"arg2"], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -386,7 +398,7 @@ type ParameterInfoTests() = type foo = N1.T<(*Marker*) """ this.VerifyParameterInfoAtStartOfMarker(fileContent,"(*Marker*)",[["Param1";"ParamIgnored"]], - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -398,7 +410,7 @@ type ParameterInfoTests() = type foo = N1.T< "Hello", 2>(*Marker*) """ this.VerifyNoParameterInfoAtStartOfMarker(fileContent,"(*Marker*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -409,7 +421,7 @@ type ParameterInfoTests() = type foo = N1.T<"Hello",(*Marker*) """ this.VerifyParameterInfoContainedAtStartOfMarker(fileContent,"(*Marker*)",["Param1";"ParamIgnored"], - [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] @@ -504,7 +516,7 @@ type ParameterInfoTests() = let methodGroup = GetParameterInfoAtCursor file if (methReq = []) then - AssertEqual(null, methodGroup) + Assert.IsTrue(methodGroup.IsNone, "Expected no method group") else AssertMethodGroup(methodGroup, methReq) @@ -612,7 +624,7 @@ type ParameterInfoTests() = MoveCursorToEndOfMarker(file, testLine) let methodGroup = GetParameterInfoAtCursor file if (methReq = []) then - AssertEqual(null, methodGroup) + Assert.IsTrue(methodGroup.IsNone, "expected no method group") else AssertMethodGroup(methodGroup, methReq) @@ -677,7 +689,7 @@ type ParameterInfoTests() = let gpatcc = GlobalParseAndTypeCheckCounter.StartNew(this.VS) MoveCursorToEndOfMarker(file, cursorPrefix) let info = GetParameterInfoAtCursor file - AssertEqual(null, info) + Assert.IsTrue(info.IsNone, "expected no parameter info") gpatcc.AssertExactly(0,0) member public this.TestParameterInfoLocation (testLine, expectedPos, ?addtlRefAssy : list) = @@ -690,6 +702,8 @@ type ParameterInfoTests() = let (_, _, file) = this.CreateSingleFileProject(code, ?references = addtlRefAssy) MoveCursorToEndOfMarker(file, cursorPrefix) let info = GetParameterInfoAtCursor file + Assert.IsTrue(info.IsSome, "expected parameter info") + let info = info.Value AssertEqual(expectedPos, info.GetColumnOfStartOfLongId()) // Tests the current behavior, we may want to specify it differently in the future @@ -747,7 +761,7 @@ type ParameterInfoTests() = //This test verifies that ParamInfo location on a provided type with namespace that exposes static parameter that takes >1 argument works normally. member public this.``TypeProvider.Type.ParameterInfoLocation.WithNamespace`` () = this.TestParameterInfoLocation("type boo = N1.T<$",11, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -757,7 +771,7 @@ type ParameterInfoTests() = this.TestParameterInfoLocation("open N1 \n"+ "type boo = T<$", expectedPos = 11, - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -766,7 +780,7 @@ type ParameterInfoTests() = //The intent here to make sure the ParamInfo is not shown when inside a string member public this.``TypeProvider.Type.Negative.InString`` () = this.TestParameterInfoNegative("type boo = \"N1.T<$\"", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -775,7 +789,7 @@ type ParameterInfoTests() = //The intent here to make sure the ParamInfo is not shown when inside a comment member public this.``TypeProvider.Type.Negative.InComment`` () = this.TestParameterInfoNegative("// type boo = N1.T<$", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) // Following are tricky: @@ -861,20 +875,12 @@ type ParameterInfoTests() = "let f1 y = y " "let z = f(f1( " ] ) MoveCursorToEndOfMarker(file, "f1(") - // Note: no TakeCoffeeBreak(this.VS) - let info = GetParameterInfoAtCursorNoFallback file // the 'NoFallback' version will not use the name environment, only captured name resolutions at specific locations - AssertEqual(null, info) let info = GetParameterInfoAtCursor file // this will fall back to using the name environment, which is stale, but sufficient to look up the call to 'f1' + Assert.IsTrue(info.IsSome, "expected parameter info") + let info = info.Value AssertEqual("f1", info.GetName(0)) - // note about (6,1): for silly implementation reasons, we always report location of 'end of file' as first the char, 3 lines past the last line of the file - AssertEqual([|(3,11);(3,13);(3,13);(6,1)|], info.GetNoteworthyParamInfoLocations()) - - // after typechecking catches up, then even NoFallback should find it - TakeCoffeeBreak(this.VS) - let info = GetParameterInfoAtCursorNoFallback file // the 'NoFallback' version will not use the name environment, only captured name resolutions at specific locations - AssertEqual("f1", info.GetName(0)) - AssertEqual([|(3,11);(3,13);(3,13);(6,1)|], info.GetNoteworthyParamInfoLocations()) - gpatcc.AssertExactly(0,0) + // note about (5,0): service.fs adds three lines of empty text to the end of every file, so it reports the location of 'end of file' as first the char, 3 lines past the last line of the file + AssertEqual([|(2,10);(2,12);(2,12);(5,0)|], info.GetNoteworthyParamInfoLocations()) [] member this.``LocationOfParams.AfterQuicklyTyping.CallConstructor``() = @@ -891,19 +897,13 @@ type ParameterInfoTests() = "let foo = new Foo( " ] ) MoveCursorToEndOfMarker(file, "new Foo(") // Note: no TakeCoffeeBreak(this.VS) - let info = GetParameterInfoAtCursorNoFallback file // the 'NoFallback' version will not use the name environment, only captured name resolutions at specific locations - AssertEqual(null, info) let info = GetParameterInfoAtCursor file // this will fall back to using the name environment, which is stale, but sufficient to look up the call to 'f1' + Assert.IsTrue(info.IsSome, "expected parameter info") + let info = info.Value AssertEqual("Foo", info.GetName(0)) - // note about (5,1): for silly implementation reasons, we always report location of 'end of file' as first the char, 3 lines past the last line of the file - AssertEqual([|(2,15);(2,18);(2,18);(5,1)|], info.GetNoteworthyParamInfoLocations()) + // note about (4,0): service.fs adds three lines of empty text to the end of every file, so it reports the location of 'end of file' as first the char, 3 lines past the last line of the file + AssertEqual([|(1,14);(1,17);(1,17);(4,0)|], info.GetNoteworthyParamInfoLocations()) - // after typechecking catches up, then even NoFallback should find it - TakeCoffeeBreak(this.VS) - let info = GetParameterInfoAtCursorNoFallback file // the 'NoFallback' version will not use the name environment, only captured name resolutions at specific locations - AssertEqual("Foo", info.GetName(0)) - AssertEqual([|(2,15);(2,18);(2,18);(5,1)|], info.GetNoteworthyParamInfoLocations()) - gpatcc.AssertExactly(0,0) (* This does not currently work, because the 'fallback to name environment' does weird QuickParse-ing and mangled the long id "Bar.Foo". @@ -926,19 +926,10 @@ We really need to rewrite some code paths here to use the real parse tree rather "let foo = new Bar.Foo( " ] ) MoveCursorToEndOfMarker(file, "new Bar.Foo(") // Note: no TakeCoffeeBreak(this.VS) - let info = GetParameterInfoAtCursorNoFallback file // the 'NoFallback' version will not use the name environment, only captured name resolutions at specific locations - AssertEqual(null, info) let info = GetParameterInfoAtCursor file // this will fall back to using the name environment, which is stale, but sufficient to look up the call to 'f1' AssertEqual("Foo", info.GetName(0)) - // note about (5,1): for silly implementation reasons, we always report location of 'end of file' as first the char, 3 lines past the last line of the file - AssertEqual([|(2,15);(2,22);(2,22);(5,1)|], info.GetNoteworthyParamInfoLocations()) - - // after typechecking catches up, then even NoFallback should find it - TakeCoffeeBreak(this.VS) - let info = GetParameterInfoAtCursorNoFallback file // the 'NoFallback' version will not use the name environment, only captured name resolutions at specific locations - AssertEqual("Foo", info.GetName(0)) - AssertEqual([|(2,15);(2,22);(2,22);(5,1)|], info.GetNoteworthyParamInfoLocations()) - gpatcc.AssertExactly(0,0) + // note about (4,0): service.fs adds three lines of empty text to the end of every file, so it reports the location of 'end of file' as first the char, 3 lines past the last line of the file + AssertEqual([|(1,14);(1,21);(1,21);(4,0)|], info.GetNoteworthyParamInfoLocations()) *) [] @@ -952,6 +943,8 @@ We really need to rewrite some code paths here to use the real parse tree rather let (_, _, file) = this.CreateSingleFileProject(testLines) MoveCursorToStartOfMarker(file, "0") let info = GetParameterInfoAtCursor file + Assert.IsTrue(info.IsSome, "expected parameter info") + let info = info.Value let names = info.GetParameterNames() AssertEqual([| null; null; "d"; "e"; "c" |], names) @@ -969,13 +962,13 @@ We really need to rewrite some code paths here to use the real parse tree rather [while r.ToString().IndexOf('^') <> -1 do let c = r.ToString().IndexOf('^') r.Remove(c,1) |> ignore - yield (i+1,c+1)] + yield (i,c)] r.ToString(), locs) let testLines = testLinesAndLocs |> List.map fst let expectedLocs = testLinesAndLocs |> List.map snd |> List.collect id |> List.toArray - // note: for silly implementation reasons, we always report location of 'end of file' as first the char, 3 lines past the last line of the file + // note: service.fs adds three lines of empty text to the end of every file, so it reports the location of 'end of file' as first the char, 3 lines past the last line of the file let expectedLocs = if defaultArg markAtEOF false then - Array.append expectedLocs [| testLines.Length+3, 1 |] + Array.append expectedLocs [| (testLines.Length-1)+3, 0 |] else expectedLocs let cursorPrefix = cursorPrefix.Replace("^","") @@ -984,9 +977,29 @@ We really need to rewrite some code paths here to use the real parse tree rather let (_, _, file) = this.CreateSingleFileProject(testLines, references = references) MoveCursorToEndOfMarker(file, cursorPrefix) let info = GetParameterInfoAtCursor file - if info=null then raise NoParamInfo + Assert.IsTrue(info.IsSome, "expected parameter info") + let info = info.Value AssertEqual(expectedLocs, info.GetNoteworthyParamInfoLocations()) + // These pin down known failing cases + member public this.TestNoParameterInfo (testLine, ?additionalReferenceAssemblies) = + let cursorPrefix, testLines = this.ExtractLineInfo testLine + let cursorPrefix = cursorPrefix.Replace("^","") + let testLinesAndLocs = testLines |> List.mapi (fun i s -> + let r = new System.Text.StringBuilder(s) + let locs = + [while r.ToString().IndexOf('^') <> -1 do + let c = r.ToString().IndexOf('^') + r.Remove(c,1) |> ignore + yield (i,c)] + r.ToString(), locs) + let testLines = testLinesAndLocs |> List.map fst + let references = "System.Core"::(defaultArg additionalReferenceAssemblies []) + let (_, _, file) = this.CreateSingleFileProject(testLines, references = references) + MoveCursorToEndOfMarker(file, cursorPrefix) + let info = GetParameterInfoAtCursor file + Assert.IsTrue(info.IsNone, "expected no parameter info for this particular test, though it would be nice if this has started to work") + [] member public this.``LocationOfParams.Case1``() = this.TestParameterInfoLocationOfParams("""^System.Console.WriteLine^^("hel$lo"^)""") @@ -1326,8 +1339,7 @@ We really need to rewrite some code paths here to use the real parse tree rather [] member public this.``LocationOfParams.ThisOnceAsserted``() = - try - this.TestParameterInfoLocationOfParams(""" + this.TestNoParameterInfo(""" module CSVTypeProvider f(fun x -> @@ -1343,13 +1355,10 @@ We really need to rewrite some code paths here to use the real parse tree rather keyType match types |> Array.tryFind (fun ty -> ty.Name = typeName^) with _ -> ()""") - with - | NoParamInfo -> () // expect there not to be any param info because parser failed [] member public this.``LocationOfParams.ThisOnceAssertedToo``() = - try - this.TestParameterInfoLocationOfParams(""" + this.TestNoParameterInfo(""" let readString() = let x = 42 while ('"' = '""' then @@ -1358,8 +1367,6 @@ We really need to rewrite some code paths here to use the real parse tree rather let sb = new System.Text.StringBuilder() while true do ($) """) - with - | NoParamInfo -> () // expect there not to be any param info because parser failed [] member public this.``LocationOfParams.UnmatchedParensBeforeModuleKeyword.Bug245850.Case1a``() = @@ -1514,13 +1521,13 @@ We really need to rewrite some code paths here to use the real parse tree rather member public this.``LocationOfParams.TypeProviders.Basic``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, 42 ^>""", - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.BasicNamed``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, ParamIgnored=42 ^>""", - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] @@ -1528,92 +1535,72 @@ We really need to rewrite some code paths here to use the real parse tree rather this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< $ """, // missing all params, just have < markAtEnd = true, - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Prefix1``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, 42 """, // missing > markAtEnd = true, - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Prefix1Named``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, ParamIgnored=42 """, // missing > markAtEnd = true, - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Prefix2``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, """, // missing last param markAtEnd = true, - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Prefix2Named1``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, ParamIgnored= """, // missing last param after name with equals markAtEnd = true, - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Prefix2Named2``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, ParamIgnored """, // missing last param after name sans equals markAtEnd = true, - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Negative1``() = - try - this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" + this.TestNoParameterInfo(""" type D = ^System.Collections.Generic.Dictionary^^< in$t, int ^>""") - failwith "unexpected param info for generic type" - with - | :? NoParamInfo -> () [] member public this.``LocationOfParams.TypeProviders.Negative2``() = - try - this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" + this.TestNoParameterInfo(""" type D = ^System.Collections.Generic.List^^< in$t ^>""") - failwith "unexpected param info for generic type" - with - | :? NoParamInfo -> () [] member public this.``LocationOfParams.TypeProviders.Negative3``() = - try - this.TestParameterInfoLocationOfParams(""" + this.TestNoParameterInfo(""" let i = 42 let b = ^i^^< 4$2""") - failwith "unexpected param info for generic type" - with - | :? NoParamInfo -> () [] member public this.``LocationOfParams.TypeProviders.Negative4.Bug181000``() = - try - this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" + this.TestNoParameterInfo(""" type U = ^N1.T^^< "foo"^, 42 ^>$ """, // when the caret is right of the '>', we should not report any param info - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) - failwith "unexpected param info for generic type" - with - | :? NoParamInfo -> () + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.BasicWithinExpr``() = - try - this.TestParameterInfoLocationOfParams(""" + this.TestNoParameterInfo(""" let f() = let r = id( ^N1.T^^< "fo$o"^, ParamIgnored=42 ^> ) r """, - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) - failwith "unexpected param info for invalid use of constructorless type" - with - | :? NoParamInfo -> () + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.BasicWithinExpr.DoesNotInterfereWithOuterFunction``() = @@ -1621,34 +1608,36 @@ We really need to rewrite some code paths here to use the real parse tree rather let f() = let r = ^id^^( N1.$T< "foo", ParamIgnored=42 > ^) r """, - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Bug199744.ExcessCommasShouldNotAssertAndShouldGiveInfo.Case1``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, 42^, ^, ^>""", - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Bug199744.ExcessCommasShouldNotAssertAndShouldGiveInfo.Case2``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< "fo$o"^, ^, ^>""", - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``LocationOfParams.TypeProviders.Bug199744.ExcessCommasShouldNotAssertAndShouldGiveInfo.Case3``() = this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts(""" type U = ^N1.T^^< ^,$ ^>""", - additionalReferenceAssemblies = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + additionalReferenceAssemblies = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``TypeProvider.FormatOfNamesOfSystemTypes``() = let code = ["""type TTT = N1.T< "foo", ParamIgnored=42 > """] - let references = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] + let references = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] let (_, _, file) = this.CreateSingleFileProject(code, references = references) let gpatcc = GlobalParseAndTypeCheckCounter.StartNew(this.VS) MoveCursorToEndOfMarker(file,"foo") let methodGroup = GetParameterInfoAtCursor file + Assert.IsTrue(methodGroup.IsSome, "expected parameter info") + let methodGroup = methodGroup.Value let actualDisplays = [ for i = 0 to methodGroup.GetCount() - 1 do yield [ for j = 0 to methodGroup.GetParameterCount(i) - 1 do @@ -1707,6 +1696,9 @@ We really need to rewrite some code paths here to use the real parse tree rather MoveCursorToEndOfMarker(file, marker) let methodGroup = GetParameterInfoAtCursor file + Assert.IsTrue(methodGroup.IsSome, "expected parameter info") + let methodGroup = methodGroup.Value + Assert.AreEqual(1, methodGroup.GetCount(), "Only one function expected") let expectedParamsCount = List.length expectedParams @@ -1729,6 +1721,9 @@ We really need to rewrite some code paths here to use the real parse tree rather member public this.``ParameterInfo.ArgumentsWithParamsArrayAttribute``() = let content = """let _ = System.String.Format("",(*MARK*))""" let methodTip = this.GetMethodListForAMethodTip(content, "(*MARK*)") + Assert.IsTrue(methodTip.IsSome, "expected parameter info") + let methodTip = methodTip.Value + let overloadWithTwoParamsOpt = Seq.init (methodTip.GetCount()) (fun i -> let count = methodTip.GetParameterCount(i) @@ -2246,24 +2241,7 @@ We really need to rewrite some code paths here to use the real parse tree rather this.VerifyParameterInfoContainedAtStartOfMarker(fileContents,"(*Marker*)",["int";"int";"string";"bool"],queryAssemblyRefs) -// Allow the ParameterInfoTests run under different context -namespace UnitTests.Tests.LanguageService.ParameterInfo -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit ParameterInfoTests - new() = { inherit ParameterInfoTests(VsOpts = fst (Models.MSBuild())); } - // Context project system [] -[] -type ``ProjectSystem`` = - inherit ParameterInfoTests - new() = { inherit ParameterInfoTests(VsOpts = LanguageServiceExtension.ProjectSystem); } +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) diff --git a/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs b/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs index 3285025ff..8304345cb 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.QuickInfo open System open NUnit.Framework @@ -9,12 +9,15 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem [] module QuickInfoStandardSettings = let standard40AssemblyRefs = [ "System"; "System.Core"; "System.Numerics" ] let queryAssemblyRefs = [ "System.Xml.Linq"; "System.Core" ] -type QuickInfoTests() = + +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() // Work around an innocuous 'feature' with how QuickInfo is displayed, lines which @@ -213,7 +216,7 @@ type QuickInfoTests() = fileContents, marker = "MembersTP(*Marker*)", expected = "type HiddenBaseMembersTP =\n inherit TPBaseTy\n member ShowThisProp : unit", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] member public this.``QuickInfo.OverriddenMethods``() = @@ -266,7 +269,7 @@ type QuickInfoTests() = [] member public this.``TypeProviders.NestedTypesOrder``() = let code = "type t = N1.TypeWithNestedTypes(*M*)" - let tpReference = System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") + let tpReference = PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") this.VerifyOrderOfNestedTypesInQuickInfo( source = code, marker = "(*M*)", @@ -320,7 +323,7 @@ type QuickInfoTests() = let a = typeof """ this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "This is a synthetic type created by me!", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) [] [] @@ -333,7 +336,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "This is a synthetic type created by me!. Which is used to test the tool tip of the typeprovider type to check if it shows the right message or not.", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) [] [] @@ -346,7 +349,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "type T =\n new : unit -> T\n event Event1 : EventHandler\n static member M : unit -> int []\n static member StaticProp : decimal\n\nFull name: N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) [] [] @@ -359,7 +362,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "type T =\n new : unit -> T\n event Event1 : EventHandler\n static member M : unit -> int []\n static member StaticProp : decimal\n\nFull name: N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) [] @@ -373,7 +376,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "This is a synthetic type Localized! ኤፍ ሻርፕ", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) [] [] @@ -385,7 +388,7 @@ type QuickInfoTests() = let foo = new N.T(*Marker*)() """ this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "This is a synthetic .ctor created by me for N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) [] [] @@ -398,7 +401,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "This is a synthetic .ctor created by me for N.T. Which is used to test the tool tip of the typeprovider Constructor to check if it shows the right message or not.", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) [] [] @@ -411,7 +414,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "N.T() : N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) [] [] @@ -424,7 +427,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "N.T() : N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) [] [] @@ -437,7 +440,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "T(*Marker*)", "This is a synthetic .ctor Localized! ኤፍ ሻርፕ for N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) [] @@ -452,7 +455,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "Event1(*Marker*)", "This is a synthetic *event* created by me for N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) [] [] @@ -466,7 +469,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "Event1(*Marker*)", "This is a synthetic *event* Localized! ኤፍ ሻርፕ for N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) [] [] @@ -490,7 +493,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "Event1(*Marker*)", "This is a synthetic *event* created by me for N.T. Which is used to test the tool tip of the typeprovider Event to check if it shows the right message or not.!", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) [] [] @@ -504,7 +507,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "Event1(*Marker*)", "event N.T.Event1: IEvent", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) [] [] @@ -518,7 +521,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "Event1(*Marker*)", "event N.T.Event1: IEvent", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) [] @@ -532,7 +535,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "M(*Marker*)", "This is a synthetic *method* created by me!!", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) [] [] @@ -545,7 +548,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "M(*Marker*)", "This is a synthetic *method* Localized! ኤፍ ሻርፕ", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) [] [] @@ -558,7 +561,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "M(*Marker*)", "This is a synthetic *method* created by me!!. Which is used to test the tool tip of the typeprovider Method to check if it shows the right message or not.!", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) [] [] @@ -571,7 +574,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "M(*Marker*)", "N.T.M() : int []", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) [] [] @@ -584,7 +587,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "M(*Marker*)", "N.T.M() : int []", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) [] @@ -598,7 +601,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "StaticProp(*Marker*)", "This is a synthetic *property* created by me for N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithAdequateComment.dll")]) [] [] @@ -611,7 +614,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "StaticProp(*Marker*)", "This is a synthetic *property* Localized! ኤፍ ሻርፕ for N.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLocalizedComment.dll")]) [] [] @@ -624,7 +627,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "StaticProp(*Marker*)", "This is a synthetic *property* created by me for N.T. Which is used to test the tool tip of the typeprovider Property to check if it shows the right message or not.!", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithLongComment.dll")]) [] [] @@ -637,7 +640,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "StaticProp(*Marker*)", "property N.T.StaticProp: decimal", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithNullComment.dll")]) [] [] @@ -650,7 +653,7 @@ type QuickInfoTests() = this.AssertQuickInfoContainsAtStartOfMarker (fileContents, "StaticProp(*Marker*)", "property N.T.StaticProp: decimal", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly( @"UnitTestsResources\MockTypeProviders\XmlDocAttributeWithEmptyComment.dll")]) [] @@ -667,7 +670,7 @@ type QuickInfoTests() = fileContents, marker = "foo(*Marker*)", expected = "type foo = N1.T", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -684,7 +687,7 @@ type QuickInfoTests() = fileContents, marker = "foo(*Marker*)", expected = "type foo", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -701,7 +704,7 @@ type QuickInfoTests() = fileContents, marker = "foo(*Marker*)", expected = "XMLComment", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -712,7 +715,7 @@ type QuickInfoTests() = fileContents, marker = "TTT", expected = "type TTT = Samples.FSharp.RegexTypeProvider.RegexTyped<...>\n\nFull name: File1.TTT", - addtlRefAssy = ["System"; System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = ["System"; PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -727,7 +730,7 @@ type QuickInfoTests() = fileContents, marker = "reaCode.Val", expected = """property Samples.FSharp.RegexTypeProvider.RegexTyped<...>.MatchType.AreaCode: System.Text.RegularExpressions.Group""", - addtlRefAssy = ["System"; System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = ["System"; PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) // Regression for 2948 [] @@ -2962,9 +2965,9 @@ query." this.AssertQuickInfoContainsAtStartOfMarker (fileContent, "(*Marker5*)", "value param") this.AssertQuickInfoContainsAtStartOfMarker (fileContent, "(*Marker6*)", "value param") this.AssertQuickInfoContainsAtStartOfMarker (fileContent, "(*Marker7*)", "Param1 of string", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) this.AssertQuickInfoContainsAtStartOfMarker (fileContent, "(*Marker8*)", "Ignored", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) member private this.VerifyUsingFsTestLib fileContent queries crossProject = use _guard = this.UsingNewVS() @@ -3679,26 +3682,7 @@ query." this.AssertQuickInfoContainsAtStartOfMarker (fileContent, "(*Mark2*)", "Calls EventBuilder.ScanSumBy") -(*------------------------------------------IDE automation ends here ---------------------------------------------------*) - -// Allow the QuickInfoTests run under different context -namespace UnitTests.Tests.LanguageService.QuickInfo -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit QuickInfoTests - new() = { inherit QuickInfoTests(VsOpts = fst (Models.MSBuild())); } - // Context project system [] -[] -type ``ProjectSystem`` = - inherit QuickInfoTests - new() = { inherit QuickInfoTests(VsOpts = LanguageServiceExtension.ProjectSystem); } +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) diff --git a/vsintegration/src/unittests/Tests.LanguageService.QuickParse.fs b/vsintegration/src/unittests/Tests.LanguageService.QuickParse.fs index 5591604ef..ee3575229 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.QuickParse.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.QuickParse.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests +namespace Tests.LanguageService open System open System.IO diff --git a/vsintegration/src/unittests/Tests.LanguageService.Script.fs b/vsintegration/src/unittests/Tests.LanguageService.Script.fs index ba10ab627..90e1195ac 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.Script.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.Script.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.Script open System open System.IO @@ -10,8 +10,10 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -type ScriptTests() as this = +[] +type UsingMSBuild() as this = inherit LanguageServiceBaseTests() let notAA l = None,l @@ -230,7 +232,7 @@ type ScriptTests() as this = "open System.Transactions" ] AssertNoErrorsOrWarnings(project) - gpatcc.AssertExactly(notAA[file],notAA[file], true (* expectDelete, because dependent DLL set changed *)) + gpatcc.AssertExactly(notAA[file],notAA[file], true (* expectCreate, because dependent DLL set changed *)) // FEATURE: Adding a #load to a file will cause types from that file to be visible in intellisense [] @@ -350,7 +352,7 @@ type ScriptTests() as this = SaveFileToDisk(file) TakeCoffeeBreak(this.VS) VerifyErrorListContainedExpetedStr("Transactions",project) - gpatcc.AssertExactly(notAA[file], notAA[file], true (* expectDelete, because dependent DLL set changed *)) + gpatcc.AssertExactly(notAA[file], notAA[file], true (* expectCreate, because dependent DLL set changed *)) @@ -920,13 +922,13 @@ type ScriptTests() as this = let (project, file) = createSingleFileFsxFromLines code MoveCursorToEndOfMarker(file, "System.ConsoleModifiers.Sh") let tooltip = GetQuickInfoAtCursor file - AssertContains(tooltip, @"[Signature:F:System.ConsoleModifiers.Shift]") // A message from the mock IdealDocumentationProvider + AssertContains(tooltip, @"[Signature:F:System.ConsoleModifiers.Shift]") // A message from the mock IDocumentationBuilder AssertContains(tooltip, @"[Filename:") AssertContains(tooltip, @"mscorlib.dll]") // The assembly we expect the documentation to get taken from MoveCursorToEndOfMarker(file, "(3).ToString().Len") let tooltip = GetQuickInfoAtCursor file - AssertContains(tooltip, @"[Signature:P:System.String.Length]") // A message from the mock IdealDocumentationProvider + AssertContains(tooltip, @"[Signature:P:System.String.Length]") // A message from the mock IDocumentationBuilder AssertContains(tooltip, @"[Filename:") AssertContains(tooltip, @"mscorlib.dll]") // The assembly we expect the documentation to get taken from @@ -1225,11 +1227,11 @@ type ScriptTests() as this = ] let (project, file) = createSingleFileFsxFromLines code let projectFolder = ProjectDirectory(project) - let fas = GetCheckOptionsOfScript(file) - AssertArrayContainsPartialMatchOf(fas.ProjectOptions, "--noframework") - AssertArrayContainsPartialMatchOf(fas.ProjectOptions, "System.Runtime.Remoting.dll") - AssertArrayContainsPartialMatchOf(fas.ProjectOptions, "System.Transactions.dll") - AssertArrayContainsPartialMatchOf(fas.ProjectOptions, "FSharp.Compiler.Interactive.Settings.dll") + let fas = GetProjectOptionsOfScript(file) + AssertArrayContainsPartialMatchOf(fas.OtherOptions, "--noframework") + AssertArrayContainsPartialMatchOf(fas.OtherOptions, "System.Runtime.Remoting.dll") + AssertArrayContainsPartialMatchOf(fas.OtherOptions, "System.Transactions.dll") + AssertArrayContainsPartialMatchOf(fas.OtherOptions, "FSharp.Compiler.Interactive.Settings.dll") Assert.AreEqual(Path.Combine(projectFolder,"File1.fsx"), fas.ProjectFileNames.[0]) Assert.AreEqual(1, fas.ProjectFileNames.Length) @@ -1375,8 +1377,12 @@ type ScriptTests() as this = let fsVersion = #if VS_VERSION_DEV12 "4.3.1.0" +#else +#if VS_VERSION_DEV14 + "4.4.0.0" #else "4.4.1.0" +#endif #endif PlaceIntoProjectFileBeforeImport (project, sprintf @" @@ -1611,7 +1617,7 @@ type ScriptTests() as this = ] let refs = [ - System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") + PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") ] let (_, project, file) = this.CreateSingleFileProject(code, references = refs) TakeCoffeeBreak(this.VS) @@ -1619,7 +1625,7 @@ type ScriptTests() as this = member public this.TypeProviderDisposalSmokeTest(clearing) = use _guard = this.UsingNewVS() - let providerAssemblyName = System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") + let providerAssemblyName = PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") let providerAssembly = System.Reflection.Assembly.LoadFrom providerAssemblyName Assert.IsNotNull(providerAssembly, "provider assembly should not be null") let providerCounters = providerAssembly.GetType("DummyProviderForLanguageServiceTesting.GlobalCounters") @@ -1659,7 +1665,7 @@ type ScriptTests() as this = for i in 1 .. 50 do let solution = this.CreateSolution() let project = CreateProject(solution,"testproject" + string (i % 20)) - this.AddAssemblyReference(project, System.IO.Path.Combine(System.Environment.CurrentDirectory, @"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")) + this.AddAssemblyReference(project, PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")) let fileName = sprintf "File%d.fs" i let file1 = AddFileFromText(project,fileName, ["let x" + string i + " = N1.T1()" ]) let file = OpenFile(project,fileName) @@ -1706,25 +1712,9 @@ type ScriptTests() as this = [] member public this.``TypeProvider.Disposal.SmokeTest2``() = this.TypeProviderDisposalSmokeTest(false) -//Allow the ScriptTests run under different context -namespace UnitTests.Tests.LanguageService.Script -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit ScriptTests - new() = { inherit ScriptTests(VsOpts = fst (Models.MSBuild())); } // Context project system [] -[] -type ``ProjectSystem`` = - inherit ScriptTests - new() = { inherit ScriptTests(VsOpts = LanguageServiceExtension.ProjectSystem); } +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) diff --git a/vsintegration/src/unittests/Tests.LanguageService.Squiggles.fs b/vsintegration/src/unittests/Tests.LanguageService.Squiggles.fs index c8cf5f273..57f57686c 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.Squiggles.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.Squiggles.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.Squiggles open System open System.IO @@ -10,8 +10,10 @@ open Salsa.VsOpsUtils open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService +open UnitTests.TestLib.ProjectSystem -type SquiggleTests() as this= +[] +type UsingMSBuild() as this= inherit LanguageServiceBaseTests() #if FX_ATLEAST_45 @@ -297,7 +299,7 @@ type X() = [] [] member this.``TypeProvider.Error.VerbatimStringAccident.GoodErrorMessage``() = - let r = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] + let r = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")] let (sln, proj, file) = this.CreateSingleFileProject("""type foo = N1.T<@"foo">""", references = r) TakeCoffeeBreak(this.VS)// Wait for the background compiler to catch up. MoveCursorToStartOfMarker(file, "1") @@ -313,14 +315,14 @@ type X() = [] [] member public this.``TypeProvider.WarningAboutEmptyAssembly`` () = - let emptyLoc = System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\EmptyAssembly.dll") + let emptyLoc = PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\EmptyAssembly.dll") this.VerifySquiggleAtStartOfMarker( fileContents = "type foo = N1.T<\"foo\"", marker = "t", expectedSquiggle= (Microsoft.VisualStudio.FSharp.LanguageService.Severity.Warning, "Referenced assembly '"+emptyLoc+"' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found"), // ensure that if you referenced two TP assemblies, one of which contained TPs, and the other did not, then you get the warning about a TP assembly with no TPs - addtlRefAssy = [emptyLoc; System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")], + addtlRefAssy = [emptyLoc; PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")], thereShouldBeNoOtherSquigglesHere=true) [] @@ -332,7 +334,7 @@ type X() = marker = "N1", expectedSquiggle= (Microsoft.VisualStudio.FSharp.LanguageService.Severity.Error, "The static parameter 'Param1' of the provided type or method 'T' requires a value. Static parameters to type providers may be optionally specified using named arguments, e.g. 'T'."), - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -343,7 +345,7 @@ type X() = marker = "N1", expectedSquiggle= (Microsoft.VisualStudio.FSharp.LanguageService.Severity.Error, "The static parameter 'ParamIgnored' of the provided type or method 'T' requires a value. Static parameters to type providers may be optionally specified using named arguments, e.g. 'T'."), - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -356,7 +358,7 @@ type X() = marker = "let", expectedSquiggle= (Microsoft.VisualStudio.FSharp.LanguageService.Severity.Error, "Expected type argument or static argument"), - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -369,7 +371,7 @@ type X() = marker = "let", expectedSquiggle= (Microsoft.VisualStudio.FSharp.LanguageService.Severity.Error, "Incomplete structured construct at or before this point in type arguments. Expected ',', '>' or other token."), - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] [] @@ -386,7 +388,7 @@ type X() = " string \n"+ "but here has type\n"+ " int "), - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] @@ -399,7 +401,7 @@ type X() = fileContents = """ type foo = N1(*Marker*).T< const "Hello World",2>""", marker = "(*Marker*)", - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] @@ -418,7 +420,7 @@ type X() = "offside of context started at position (2:39). "+ "Try indenting this token further or using "+ "standard formatting conventions."), - addtlRefAssy = [System.IO.Path.Combine(System.Environment.CurrentDirectory,@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) + addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTestsResources\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) [] @@ -866,25 +868,15 @@ type X() = ["#light" "module Module2"] - // Assertion below is very subtle. Here's what happened. After opening file1, we opened file2. This changed the contents - // of the project file, and focused file2 (and unfocused file1). Since then, we have never done anything to file1, not even - // OnIdle (which salsa only does for currently-focused-file), and thus when we touch file1 again, it falls into the logic - // in servicem.fs here: - // Furthermore, if we know our project is out-of-date, this may mean that dependent DLLs may have changed on disk without us knowing, - // since we only just started listening for those changes a moment ago in the SetDependencyFiles() call. So behave just as if we were - // just notified that those dependency files changed. (In the future, it would be good to partition a source file's dependencies into - // 'project' dependencies (that only depend on the IProjectSite, e.g. project/asseembly references) and 'source' dependencies (e.g. #r's).) - //if outOfDateProjectFileNames.Contains(projectFileName) then - // this.Parser.InvalidateConfiguration(checkOptions) - // which assumes 'the worst' and calls InvalidateConfiguration (which calls InvalidateBuildCacheEntry, which deletes the IncrementalBuilder). - // I am happy to have this under test. - // The next test below (Case B) simulates behavior more like VS, which would be idling all the open files. - gpatcc.AssertExactly(AA[file1;file2], AA[file1;file2], true) + gpatcc.AssertExactly(notAA[], notAA[]) let gpatcc = GlobalParseAndTypeCheckCounter.StartNew(this.VS) printfn "Fixing file1 on disk" SaveFileToDisk file1 gpatcc.AssertExactly(notAA[file1],notAA[file1;file2]) let gpatcc = GlobalParseAndTypeCheckCounter.StartNew(this.VS) + SwitchToFile this.VS file2 + TakeCoffeeBreak(this.VS) + MoveCursorToEndOfMarker(file2,"open Modu") // This switches focus back to file2 TakeCoffeeBreak(this.VS) let ans = GetSquiggleAtCursor(file2) @@ -960,24 +952,8 @@ type X() = | _ -> Assert.Fail("No squiggle seen") -//Allow the SquiggleTests run under different context -namespace UnitTests.Tests.LanguageService.Squiggle -open UnitTests.Tests.LanguageService -open UnitTests.TestLib.LanguageService -open UnitTests.TestLib.ProjectSystem -open NUnit.Framework -open Salsa.Salsa - -// context msbuild -[] -[] -type ``MSBuild`` = - inherit SquiggleTests - new() = { inherit SquiggleTests(VsOpts = fst (Models.MSBuild())); } // Context project system [] -[] -type ``ProjectSystem`` = - inherit SquiggleTests - new() = { inherit SquiggleTests(VsOpts = LanguageServiceExtension.ProjectSystem); } +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) diff --git a/vsintegration/src/unittests/Tests.LanguageService.TimeStamp.fs b/vsintegration/src/unittests/Tests.LanguageService.TimeStamp.fs index 548463229..f7450b11c 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.TimeStamp.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.TimeStamp.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.LanguageService +namespace Tests.LanguageService.TimeStamp open System open System.IO @@ -11,7 +11,8 @@ open UnitTests.TestLib.Salsa open UnitTests.TestLib.Utils open UnitTests.TestLib.LanguageService -type TimeStampTests() = +[] +type UsingMSBuild() = inherit LanguageServiceBaseTests() (* Timings ----------------------------------------------------------------------------- *) @@ -186,6 +187,7 @@ type TimeStampTests() = // Add a new reference project2->project1. There should be no completions because Mary doesn't exist yet. this.AddAssemblyReference(project2,project1Dll.ExecutableOutput) TakeCoffeeBreak(this.VS) // Dependencies between projects get registered for file-watching during OnIdle processing + SwitchToFile this.VS file2 MoveCursorToEndOfMarker(file2,"File1.File1.") let completions = AutoCompleteAtCursor(file2) Assert.AreEqual(0, completions.Length) @@ -198,6 +200,7 @@ type TimeStampTests() = SaveFileToDisk file1 time1 Build project1 "Time to build project1 second time" |> ignore TakeCoffeeBreak(this.VS) // Give enough time to catch up + SwitchToFile this.VS file2 MoveCursorToEndOfMarker(file2,"File1.File1.") TakeCoffeeBreak(this.VS) // Give enough time to catch up let completions = AutoCompleteAtCursor(file2) @@ -238,6 +241,7 @@ type TimeStampTests() = // Add a new reference project2->project1. There should be no completions because Mary doesn't exist yet. this.AddAssemblyReference(project2,project1DllRelative) TakeCoffeeBreak(this.VS) // Dependencies between projects get registered for file-watching during OnIdle processing + SwitchToFile this.VS file2 MoveCursorToEndOfMarker(file2,"File1.File1.") let completions = AutoCompleteAtCursor(file2) Assert.AreEqual(0, completions.Length) @@ -250,6 +254,7 @@ type TimeStampTests() = SaveFileToDisk file1 time1 Build project1 "Time to build project1 second time" |> ignore TakeCoffeeBreak(this.VS) // Give enough time to catch up + SwitchToFile this.VS file2 MoveCursorToEndOfMarker(file2,"File1.File1.") TakeCoffeeBreak(this.VS) // Give enough time to catch up let completions = AutoCompleteAtCursor(file2) @@ -290,6 +295,7 @@ type TimeStampTests() = TakeCoffeeBreak(this.VS) // Dependencies between projects get registered for file-watching during OnIdle processing SetConfigurationAndPlatform(project1, "Debug|AnyCPU") // maybe due to msbuild bug on dev10, we must set config/platform when building with ProjectReferences SetConfigurationAndPlatform(project2, "Debug|AnyCPU") // maybe due to msbuild bug on dev10, we must set config/platform when building with ProjectReferences + SwitchToFile this.VS file2 MoveCursorToEndOfMarker(file2,"File1.File1.") let completions = AutoCompleteAtCursor(file2) Assert.AreEqual(0, completions.Length) @@ -302,6 +308,7 @@ type TimeStampTests() = SaveFileToDisk file1 time1 Build project1 "Time to build project1 second time" |> ignore TakeCoffeeBreak(this.VS) // Give enough time to catch up + SwitchToFile this.VS file2 MoveCursorToEndOfMarker(file2,"File1.File1.") TakeCoffeeBreak(this.VS) // Give enough time to catch up let completions = AutoCompleteAtCursor(file2) @@ -310,23 +317,14 @@ type TimeStampTests() = //Allow the TimeStampTests run under different context -namespace UnitTests.Tests.LanguageService.TimeStamp -open UnitTests.Tests.LanguageService +namespace Tests.LanguageService.TimeStamp +open Tests.LanguageService open UnitTests.TestLib.LanguageService open UnitTests.TestLib.ProjectSystem open NUnit.Framework open Salsa.Salsa -// context msbuild -[] -[] -type ``MSBuild`` = - inherit TimeStampTests - new() = { inherit TimeStampTests(VsOpts = fst (Models.MSBuild())); } - // Context project system [] -[] -type ``ProjectSystem`` = - inherit TimeStampTests - new() = { inherit TimeStampTests(VsOpts = LanguageServiceExtension.ProjectSystem); } \ No newline at end of file +type UsingProjectSystem() = + inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) \ No newline at end of file diff --git a/vsintegration/src/unittests/Tests.ProjectSystem.Configs.fs b/vsintegration/src/unittests/Tests.ProjectSystem.Configs.fs index 2ef7ac300..d4919cb69 100644 --- a/vsintegration/src/unittests/Tests.ProjectSystem.Configs.fs +++ b/vsintegration/src/unittests/Tests.ProjectSystem.Configs.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.ProjectSystem +namespace Tests.ProjectSystem // System namespaces open System diff --git a/vsintegration/src/unittests/Tests.ProjectSystem.Miscellaneous.fs b/vsintegration/src/unittests/Tests.ProjectSystem.Miscellaneous.fs index e35ab58a6..c0de35115 100644 --- a/vsintegration/src/unittests/Tests.ProjectSystem.Miscellaneous.fs +++ b/vsintegration/src/unittests/Tests.ProjectSystem.Miscellaneous.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.ProjectSystem +namespace Tests.ProjectSystem // System namespaces open System diff --git a/vsintegration/src/unittests/Tests.ProjectSystem.MultiTargeting.fs b/vsintegration/src/unittests/Tests.ProjectSystem.MultiTargeting.fs index 10ead201e..84ee5860d 100644 --- a/vsintegration/src/unittests/Tests.ProjectSystem.MultiTargeting.fs +++ b/vsintegration/src/unittests/Tests.ProjectSystem.MultiTargeting.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.ProjectSystem +namespace Tests.ProjectSystem open System open System.Collections.Generic diff --git a/vsintegration/src/unittests/Tests.ProjectSystem.Project.fs b/vsintegration/src/unittests/Tests.ProjectSystem.Project.fs index 9f35257c3..aa3a74146 100644 --- a/vsintegration/src/unittests/Tests.ProjectSystem.Project.fs +++ b/vsintegration/src/unittests/Tests.ProjectSystem.Project.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.ProjectSystem +namespace Tests.ProjectSystem // System namespaces open System diff --git a/vsintegration/src/unittests/Tests.ProjectSystem.ProjectItems.fs b/vsintegration/src/unittests/Tests.ProjectSystem.ProjectItems.fs index f8711886a..8fa768731 100644 --- a/vsintegration/src/unittests/Tests.ProjectSystem.ProjectItems.fs +++ b/vsintegration/src/unittests/Tests.ProjectSystem.ProjectItems.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.ProjectSystem +namespace Tests.ProjectSystem open System open System.IO diff --git a/vsintegration/src/unittests/Tests.ProjectSystem.References.fs b/vsintegration/src/unittests/Tests.ProjectSystem.References.fs index 01c83a940..ba3083b98 100644 --- a/vsintegration/src/unittests/Tests.ProjectSystem.References.fs +++ b/vsintegration/src/unittests/Tests.ProjectSystem.References.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.ProjectSystem +namespace Tests.ProjectSystem open System open System.Collections.Generic diff --git a/vsintegration/src/unittests/Tests.ProjectSystem.RoundTrip.fs b/vsintegration/src/unittests/Tests.ProjectSystem.RoundTrip.fs index 6fa28965e..a7289521a 100644 --- a/vsintegration/src/unittests/Tests.ProjectSystem.RoundTrip.fs +++ b/vsintegration/src/unittests/Tests.ProjectSystem.RoundTrip.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.ProjectSystem +namespace Tests.ProjectSystem open System open System.IO diff --git a/vsintegration/src/unittests/Tests.ProjectSystem.UpToDate.fs b/vsintegration/src/unittests/Tests.ProjectSystem.UpToDate.fs index 03c6e5a1b..39d3379b4 100644 --- a/vsintegration/src/unittests/Tests.ProjectSystem.UpToDate.fs +++ b/vsintegration/src/unittests/Tests.ProjectSystem.UpToDate.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests.ProjectSystem +namespace Tests.ProjectSystem // System namespaces open System diff --git a/vsintegration/src/unittests/Tests.TaskReporter.fs b/vsintegration/src/unittests/Tests.TaskReporter.fs index ab5e80f46..f76720345 100644 --- a/vsintegration/src/unittests/Tests.TaskReporter.fs +++ b/vsintegration/src/unittests/Tests.TaskReporter.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests +namespace Tests.LanguageService.ErrorList open NUnit.Framework open System diff --git a/vsintegration/src/unittests/Tests.TypeProvidersImpl.fs b/vsintegration/src/unittests/Tests.TypeProvidersImpl.fs index 20d471606..75f562864 100644 --- a/vsintegration/src/unittests/Tests.TypeProvidersImpl.fs +++ b/vsintegration/src/unittests/Tests.TypeProvidersImpl.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests +namespace Tests.DataTypeProviders open System.IO open NUnit.Framework @@ -10,7 +10,7 @@ module CF = Microsoft.FSharp.Data.TypeProviders.DesignTime.ConfigFiles module Util = Microsoft.FSharp.Data.TypeProviders.Utility.Util [] -type TypeProviderImplTests() = +type ImplDetails() = [] member public this.``SanitizeFileName``() = diff --git a/vsintegration/src/unittests/Tests.Watson.fs b/vsintegration/src/unittests/Tests.Watson.fs index 0f2775ecd..f9b91863d 100644 --- a/vsintegration/src/unittests/Tests.Watson.fs +++ b/vsintegration/src/unittests/Tests.Watson.fs @@ -1,16 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests - -(* - Is NUNIT just disappearing when you run one of these tests? - There are paths in the compiler that call Process.Exit, if we manage to hit one of these paths then the process (nunit-gui.exe) - will be exited: - - Put a break point on: - - System.Environment.Exit(n) -*) +namespace Tests.Compiler.Watson #nowarn "52" // The value has been copied to ensure the original is not mutated @@ -27,12 +17,13 @@ type Check = try try #if DEBUG - Microsoft.FSharp.Compiler.CompileOps.FullCompiler.showAssertForUnexpectedException := false + Microsoft.FSharp.Compiler.CompileOps.CompilerService.showAssertForUnexpectedException := false #endif if (File.Exists("watson-test.fs")) then File.Delete("watson-test.fs") File.WriteAllText("watson-test.fs", "// Hello watson" ) - let _code = Microsoft.FSharp.Compiler.CommandLineMain.main([| "--simulateException:"+simulationCode; "watson-test.fs"|]) + let argv = [| "--simulateException:"+simulationCode; "watson-test.fs"|] + let _code = Microsoft.FSharp.Compiler.Driver.mainCompile (argv, false, Microsoft.FSharp.Compiler.ErrorLogger.QuitProcessExiter) () with | :? 'TException as e -> @@ -43,127 +34,127 @@ type Check = Assert.Fail("The correct callstack was not reported to watson.") finally #if DEBUG - Microsoft.FSharp.Compiler.CompileOps.FullCompiler.showAssertForUnexpectedException := true + Microsoft.FSharp.Compiler.CompileOps.CompilerService.showAssertForUnexpectedException := true #endif File.Delete("watson-test.fs") [] -type Watson() = +module WatsonTests = [] - member public w.FscOutOfMemory() = Check.FscLevelException("fsc-oom") + let FscOutOfMemory() = Check.FscLevelException("fsc-oom") [] - member public w.FscArgumentNull() = Check.FscLevelException("fsc-an") + let FscArgumentNull() = Check.FscLevelException("fsc-an") [] - member public w.FscInvalidOperation() = Check.FscLevelException("fsc-invop") + let FscInvalidOperation() = Check.FscLevelException("fsc-invop") // As of .NET 4.0 some exception types cannot be caught. As a result, we cannot test this case. I did visually confirm a Watson report is sent, though. // [] -// member public w.FscAccessViolation() = Check.FscLevelException("fsc-ac") +// let FscAccessViolation() = Check.FscLevelException("fsc-ac") [] - member public w.FscArgumentOutOfRange() = Check.FscLevelException("fsc-aor") + let FscArgumentOutOfRange() = Check.FscLevelException("fsc-aor") [] - member public w.FscDivideByZero() = Check.FscLevelException("fsc-dv0") + let FscDivideByZero() = Check.FscLevelException("fsc-dv0") [] - member public w.FscNotFiniteNumber() = Check.FscLevelException("fsc-nfn") + let FscNotFiniteNumber() = Check.FscLevelException("fsc-nfn") [] - member public w.FscOverflow() = Check.FscLevelException("fsc-oe") + let FscOverflow() = Check.FscLevelException("fsc-oe") [] - member public w.FscArrayTypeMismatch() = Check.FscLevelException("fsc-atmm") + let FscArrayTypeMismatch() = Check.FscLevelException("fsc-atmm") [] - member public w.FscBadImageFormat() = Check.FscLevelException("fsc-bif") + let FscBadImageFormat() = Check.FscLevelException("fsc-bif") [] - member public w.FscKeyNotFound() = Check.FscLevelException("fsc-knf") + let FscKeyNotFound() = Check.FscLevelException("fsc-knf") [] - member public w.FscIndexOutOfRange() = Check.FscLevelException("fsc-ior") + let FscIndexOutOfRange() = Check.FscLevelException("fsc-ior") [] - member public w.FscInvalidCast() = Check.FscLevelException("fsc-ic") + let FscInvalidCast() = Check.FscLevelException("fsc-ic") [] - member public w.FscInvalidProgram() = Check.FscLevelException("fsc-ip") + let FscInvalidProgram() = Check.FscLevelException("fsc-ip") [] - member public w.FscMemberAccess() = Check.FscLevelException("fsc-ma") + let FscMemberAccess() = Check.FscLevelException("fsc-ma") [] - member public w.FscNotImplemented() = Check.FscLevelException("fsc-ni") + let FscNotImplemented() = Check.FscLevelException("fsc-ni") [] - member public w.FscNullReference() = Check.FscLevelException("fsc-nr") + let FscNullReference() = Check.FscLevelException("fsc-nr") [] - member public w.FscOperationCancelled() = Check.FscLevelException("fsc-oc") + let FscOperationCancelled() = Check.FscLevelException("fsc-oc") //[] - //member public w.FscFailure() = Check.FscLevelException("fsc-fail") + //let FscFailure() = Check.FscLevelException("fsc-fail") [] - member public w.TypeCheckOutOfMemory() = Check.FscLevelException("tc-oom") + let TypeCheckOutOfMemory() = Check.FscLevelException("tc-oom") [] - member public w.TypeCheckArgumentNull() = Check.FscLevelException("tc-an") + let TypeCheckArgumentNull() = Check.FscLevelException("tc-an") [] - member public w.TypeCheckInvalidOperation() = Check.FscLevelException("tc-invop") + let TypeCheckInvalidOperation() = Check.FscLevelException("tc-invop") // As of .NET 4.0 some exception types cannot be caught. As a result, we cannot test this case. I did visually confirm a Watson report is sent, though. // [] -// member public w.TypeCheckAccessViolation() = Check.FscLevelException("tc-ac") +// let TypeCheckAccessViolation() = Check.FscLevelException("tc-ac") [] - member public w.TypeCheckArgumentOutOfRange() = Check.FscLevelException("tc-aor") + let TypeCheckArgumentOutOfRange() = Check.FscLevelException("tc-aor") [] - member public w.TypeCheckDivideByZero() = Check.FscLevelException("tc-dv0") + let TypeCheckDivideByZero() = Check.FscLevelException("tc-dv0") [] - member public w.TypeCheckNotFiniteNumber() = Check.FscLevelException("tc-nfn") + let TypeCheckNotFiniteNumber() = Check.FscLevelException("tc-nfn") [] - member public w.TypeCheckOverflow() = Check.FscLevelException("tc-oe") + let TypeCheckOverflow() = Check.FscLevelException("tc-oe") [] - member public w.TypeCheckArrayTypeMismatch() = Check.FscLevelException("tc-atmm") + let TypeCheckArrayTypeMismatch() = Check.FscLevelException("tc-atmm") [] - member public w.TypeCheckBadImageFormat() = Check.FscLevelException("tc-bif") + let TypeCheckBadImageFormat() = Check.FscLevelException("tc-bif") [] - member public w.TypeCheckKeyNotFound() = Check.FscLevelException("tc-knf") + let TypeCheckKeyNotFound() = Check.FscLevelException("tc-knf") [] - member public w.TypeCheckIndexOutOfRange() = Check.FscLevelException("tc-ior") + let TypeCheckIndexOutOfRange() = Check.FscLevelException("tc-ior") [] - member public w.TypeCheckInvalidCast() = Check.FscLevelException("tc-ic") + let TypeCheckInvalidCast() = Check.FscLevelException("tc-ic") [] - member public w.TypeCheckInvalidProgram() = Check.FscLevelException("tc-ip") + let TypeCheckInvalidProgram() = Check.FscLevelException("tc-ip") [] - member public w.TypeCheckMemberAccess() = Check.FscLevelException("tc-ma") + let TypeCheckMemberAccess() = Check.FscLevelException("tc-ma") [] - member public w.TypeCheckNotImplemented() = Check.FscLevelException("tc-ni") + let TypeCheckNotImplemented() = Check.FscLevelException("tc-ni") [] - member public w.TypeCheckNullReference() = Check.FscLevelException("tc-nr") + let TypeCheckNullReference() = Check.FscLevelException("tc-nr") [] - member public w.TypeCheckOperationCancelled() = Check.FscLevelException("tc-oc") + let TypeCheckOperationCancelled() = Check.FscLevelException("tc-oc") [] - member public w.TypeCheckFailure() = Check.FscLevelException("tc-fail") + let TypeCheckFailure() = Check.FscLevelException("tc-fail") diff --git a/vsintegration/src/unittests/Tests.XmlDocComments.fs b/vsintegration/src/unittests/Tests.XmlDocComments.fs index e41b317f7..d74127e92 100644 --- a/vsintegration/src/unittests/Tests.XmlDocComments.fs +++ b/vsintegration/src/unittests/Tests.XmlDocComments.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace UnitTests.Tests +namespace Tests.LanguageService open System open NUnit.Framework @@ -11,7 +11,7 @@ open UnitTests.TestLib.Utils [] type XmlDocComments() = - inherit UnitTests.TestLib.LanguageService.LanguageServiceBaseTests(VsOpts = fst (Models.InstalledMSBuild())) + inherit UnitTests.TestLib.LanguageService.LanguageServiceBaseTests(VsOpts = InstalledMSBuildTestFlavour()) // Work around an innocuous 'feature' with how QuickInfo is displayed, lines which // should have a "\r\n" just have a "\r" let trimnewlines (str : string) = diff --git a/vsintegration/src/unittests/Unittests.fsproj b/vsintegration/src/unittests/Unittests.fsproj index e8cc31ea1..4461a8dae 100644 --- a/vsintegration/src/unittests/Unittests.fsproj +++ b/vsintegration/src/unittests/Unittests.fsproj @@ -1,4 +1,4 @@ - + @@ -13,7 +13,6 @@ {EE85AAB7-CDA0-4C4E-BDA0-A64DDDD13E3F} Library Unittests - Unittests.fsi LIBRARY 58;75 x86 @@ -62,8 +61,26 @@ + + FsUnit.fs + + + Common.fs + + + EditorTests.fs + + + FileSystemTests.fs + + + ProjectAnalysisTests.fs + + + MultiProjectAnalysisTests.fs + - Unittests.dll.config + Unittests.dll.config @@ -105,14 +122,9 @@ - True - $(NUnitLibDir)\nunit.framework.dll - - - {ffde9e47-9675-4498-b540-69b2583dd600} - Fsc True - + $(NUnitLibDir)\nunit.framework.dll + {DED3BBD7-53F4-428A-8C9F-27968E768605} FSharp.Core @@ -122,11 +134,6 @@ {702a7979-bcf9-4c41-853e-3adfc9897890} True - - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} - FSharp.Compiler - True - {cb7d20c4-6506-406d-9144-5342c3595f03} FSharp.Data.TypeProviders diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Editor/BraceCompletion.fs b/vsintegration/src/vs/FsPkgs/FSharp.Editor/BraceCompletion.fs index 3ee3a6813..0e98429d6 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Editor/BraceCompletion.fs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Editor/BraceCompletion.fs @@ -6,7 +6,6 @@ open System open System.ComponentModel.Composition open Microsoft.VisualStudio open Microsoft.VisualStudio.FSharp.LanguageService -open Microsoft.VisualStudio.FSharp.Shared open Microsoft.VisualStudio.Editor open Microsoft.VisualStudio.Shell open Microsoft.VisualStudio.Shell.Interop diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Editor/SmartIndent.fs b/vsintegration/src/vs/FsPkgs/FSharp.Editor/SmartIndent.fs index 92d3d34db..53b68e7c9 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Editor/SmartIndent.fs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Editor/SmartIndent.fs @@ -5,7 +5,7 @@ namespace Microsoft.VisualStudio.FSharp.Editor open System open System.ComponentModel.Composition open Microsoft.VisualStudio -open Microsoft.VisualStudio.FSharp.Shared +open Microsoft.VisualStudio.FSharp.LanguageService open Microsoft.VisualStudio.Shell open Microsoft.VisualStudio.Text open Microsoft.VisualStudio.Text.Editor diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Editor/TokenContext.fs b/vsintegration/src/vs/FsPkgs/FSharp.Editor/TokenContext.fs index 12feb32c5..ded1435a9 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Editor/TokenContext.fs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Editor/TokenContext.fs @@ -4,6 +4,7 @@ namespace Microsoft.VisualStudio.FSharp.Editor open Microsoft.VisualStudio open Microsoft.VisualStudio.Editor +open Microsoft.VisualStudio.TextManager.Interop open Microsoft.VisualStudio.FSharp.LanguageService open Microsoft.VisualStudio.Shell open Microsoft.VisualStudio.Text.Editor @@ -20,7 +21,7 @@ type internal TokenContext (serviceProvider : SVsServiceProvider, adapterService let hr,buffer = vsTextView.GetBuffer() ErrorHandler.ThrowOnFailure(hr) |> ignore - let hr,colorizer = fsLangService.GetColorizer(buffer) + let hr,colorizer = (fsLangService :> IVsLanguageInfo).GetColorizer(buffer) ErrorHandler.ThrowOnFailure(hr) |> ignore let fsColorizer = colorizer :?> FSharpColorizer diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs b/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs index baf01743b..4f6f8b1b9 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs @@ -108,7 +108,7 @@ namespace Microsoft.VisualStudio.FSharp.ProjectSystem member ips.ErrorListTaskProvider() = inner.ErrorListTaskProvider() member ips.ErrorListTaskReporter() = inner.ErrorListTaskReporter() member ips.TargetFrameworkMoniker = inner.TargetFrameworkMoniker - member ips.IsTypeResolutionValid = true + member ips.IsIncompleteTypeCheckEnvironment = false member ips.LoadTime = inner.LoadTime @@ -116,6 +116,7 @@ namespace Microsoft.VisualStudio.FSharp.ProjectSystem | Opening=1 // The project has been opened, but has not yet called Compile() to compute sources/flags | Opened=2 // The project is open, has some (possibly stale) sources/flags info | Closed=3 // The project closed, has stale sources/flags info + type internal ProjectSiteOptionLifetime() = let mutable state = ProjectSiteOptionLifetimeState.Opening let mutable projectSite : DynamicProjectSite option = None @@ -209,7 +210,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. Height = 120, Window="34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3")>] // where 34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3 = outputToolWindow [] - internal FSharpProjectPackage() as this = class + internal FSharpProjectPackage() as this = inherit ProjectPackage() let mutable vfsiToolWindow = Unchecked.defaultof @@ -242,10 +243,8 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. // read list of available FSharp.Core versions do let nullService = - { - new Microsoft.VisualStudio.FSharp.ProjectSystem.IFSharpCoreVersionLookupService - with member this.ListAvailableFSharpCoreVersions(_) = Array.empty - } + { new Microsoft.VisualStudio.FSharp.ProjectSystem.IFSharpCoreVersionLookupService with + member this.ListAvailableFSharpCoreVersions(_) = Array.empty } let service = match Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler with @@ -361,13 +360,13 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. /// Out parameter to which to assign the description of the package /// HRESULT, indicating success or failure member this.getProductDetails(pbstrProductDetails:byref) = - pbstrProductDetails <- this.GetResourceString("@ProductDetails10") ; + pbstrProductDetails <- this.GetResourceString("@ProductDetails10") VSConstants.S_OK /// The resource id corresponding to the icon to display on the Help About dialog /// HRESULT, indicating success or failure member this.getIdIcoLogoForAboutbox(pIdIco:byref) = - pIdIco <- 400u ; + pIdIco <- 400u VSConstants.S_OK interface Microsoft.VisualStudio.FSharp.Interactive.ITestVFSI with @@ -375,15 +374,9 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. GetToolWindowAsITestVFSI().SendTextInteraction(s) member this.GetMostRecentLines(n:int) : string[] = GetToolWindowAsITestVFSI().GetMostRecentLines(n) - end // class FSharpProjectPackage - /// - /// Factory for creating our editor - /// - and (* type *) - - /// Creates FSharp Projects + and /// Factory for creating our editor, creates FSharp Projects [] internal FSharpProjectFactory(package:FSharpProjectPackage ) = inherit ProjectFactory(package) @@ -396,18 +389,13 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. (project :> ProjectNode) - and (* type *) - - /// This class is a 'fake' project factory that is used by WAP to register WAP specific information about + and /// This class is a 'fake' project factory that is used by WAP to register WAP specific information about /// FSharp projects. [] - internal WAFSharpProjectFactory() = class - end + internal WAFSharpProjectFactory() = class end #if DESIGNER - and (* type *) - - [] + and [] [] [] public FSharpWPFFlavor(site:IServiceProvider) = @@ -422,9 +410,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. override x.GetProperty(itemId:uint32, propId:int, property:byref) = base.GetProperty(itemId, propId, &property) - and (* type *) - - [] + and [] internal FSharpWPFProjectFactory(site:IServiceProvider) = inherit FlavoredProjectFactoryBase() @@ -436,10 +422,10 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. override x.PreCreateForOuter(outerProjectIUnknown:IntPtr) = box (new FSharpWPFFlavor(site)) #endif - and (* type *) + and [] - internal FSharpProjectNode(package:FSharpProjectPackage) as this = class + internal FSharpProjectNode(package:FSharpProjectPackage) as this = inherit ProjectNode() #if FX_ATLEAST_45 @@ -464,6 +450,10 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. let mutable inMidstOfReloading = false + // WARNING: Please avoid renaming this field or the containing type. The Visual F# Power Tools currently + // use reflection to access this field to extract project sources and flags accurately from F# projects. + // See https://github.com/fsprojects/VisualFSharpPowerTools/blob/58b8e409ee6836a39b22284740706d2cf488aabe/src/FSharpVSPowerTools.Logic/ProjectProvider.fs#L42 + // for example. If necessary, this can be changed - but please just try to avoid doing a gratuitous rename. let mutable sourcesAndFlags : option<(array * array)> = None #if DEBUG let mutable shouldLog = false // can poke this in the debugger to turn on logging @@ -758,7 +748,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. override x.GetGuidProperty(propid:int, guid:byref ) = if (enum propid = __VSHPROPID.VSHPROPID_PreferredLanguageSID) then - guid <- new Guid(Microsoft.VisualStudio.FSharp.Shared.FSharpCommonConstants.languageServiceGuidString) + guid <- new Guid(FSharpCommonConstants.languageServiceGuidString) VSConstants.S_OK // below is how VS decide 'which templates' to associate with an 'add new item' call in this project elif (enum propid = __VSHPROPID2.VSHPROPID_AddItemTemplatesGuid) then @@ -1621,7 +1611,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. sourcesAndFlagsNotifier.Advise(callbackOwnerKey,callback) member this.AdviseProjectSiteCleaned(callbackOwnerKey,callback) = cleanNotifier.Advise(callbackOwnerKey,callback) - member this.IsTypeResolutionValid = true + member this.IsIncompleteTypeCheckEnvironment = false member this.TargetFrameworkMoniker = x.GetTargetFrameworkMoniker() member this.LoadTime = creationTime } @@ -1650,7 +1640,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. member ips.ErrorListTaskReporter() = taskReporter member this.AdviseProjectSiteChanges(_,_) = () member this.AdviseProjectSiteCleaned(_,_) = () - member this.IsTypeResolutionValid = true + member this.IsIncompleteTypeCheckEnvironment = false member this.TargetFrameworkMoniker = targetFrameworkMoniker member this.LoadTime = creationTime } @@ -1790,9 +1780,8 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. member x.SetSpecificEditorProperty(_mkDocument:string, _propid:int, _value:obj ) = VSConstants.E_NOTIMPL end - end // class FSharpProjectNode - and (* type *) + and // Why is this a separate class, rather than an interface implemented on // FSharpProjectNode? Because, at the time of initial registration of this @@ -1918,7 +1907,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. 0 - and (* type *) + and [] [] @@ -2072,9 +2061,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. | _ -> raise <| ArgumentException(FSharpSR.GetString(FSharpSR.InvalidRunPostBuildEvent), "value") this.Node.ProjectMgr.SetProjectProperty(ProjectFileConstants.RunPostBuildEvent, runPostBuildEventInteger) - and (* type *) - - internal FSharpFolderNode(root : FSharpProjectNode, relativePath : string, projectElement : ProjectElement) = + and internal FSharpFolderNode(root : FSharpProjectNode, relativePath : string, projectElement : ProjectElement) = inherit FolderNode(root, relativePath, projectElement) override x.QueryStatusOnNode(guidCmdGroup:Guid, cmd:uint32, pCmdText:IntPtr, result:byref) = @@ -2105,9 +2092,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. else base.ExecCommandOnNode(guidCmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut) - and (* type *) - - internal FSharpBuildAction = + and internal FSharpBuildAction = | None = 0 | Compile = 1 | Content = 2 @@ -2143,7 +2128,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. override this.ShouldSerializeValue(o : obj) = prop.ShouldSerializeValue(o) - and (* type *) + and [] [] @@ -2172,10 +2157,8 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. else base.CreateDesignPropertyDescriptor(propertyDescriptor) - and (* type *) - - // represents most (non-reference) nodes in the solution hierarchy of an F# project (e.g. foo.fs, bar.fsi, app.config) - internal FSharpFileNode(root:FSharpProjectNode, e:ProjectElement, hierarchyId) = class + and // Represents most (non-reference) nodes in the solution hierarchy of an F# project (e.g. foo.fs, bar.fsi, app.config) + internal FSharpFileNode(root:FSharpProjectNode, e:ProjectElement, hierarchyId) = inherit LinkedFileNode(root,e, hierarchyId) static let protectVisualState (root : FSharpProjectNode) (node : HierarchyNode) f = @@ -2699,15 +2682,9 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. #endif else null - end // class FSharpFileNode - - and (* type *) - /// - /// Knows about special requirements for project to project references - /// + and /// Knows about special requirements for project to project references internal FSharpProjectReferenceNode = - class inherit ProjectReferenceNode new(root:ProjectNode, element:ProjectElement) = { inherit ProjectReferenceNode(root, element) } @@ -2754,13 +2731,8 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. ErrorHandler.ThrowOnFailure(hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, int32 __VSHPROPID.VSHPROPID_TypeName, &projectType)) |> ignore projectType :?> string - end // class FSharpProjectReferenceNode - and (* type *) - - /// - /// Reference container node for FSharp references. - /// + and /// Reference container node for FSharp references. internal FSharpReferenceContainerNode(project:FSharpProjectNode) = inherit ReferenceContainerNode(project :> ProjectNode) @@ -2775,9 +2747,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. override x.CreateProjectReferenceNode(selectorData:VSCOMPONENTSELECTORDATA) = (new FSharpProjectReferenceNode(x.ProjectMgr, selectorData.bstrTitle, selectorData.bstrFile, selectorData.bstrProjRef) :> ProjectReferenceNode) - and (* type *) - - internal SelectionElementValueChangedListener(serviceProvider:Microsoft.VisualStudio.Shell.ServiceProvider, projMgr:ProjectNode ) = + and internal SelectionElementValueChangedListener(serviceProvider:Microsoft.VisualStudio.Shell.ServiceProvider, projMgr:ProjectNode ) = inherit SelectionListener(serviceProvider) override x.OnElementValueChanged(elementid:uint32, varValueOld:obj, _varValueNew:obj) = @@ -2800,9 +2770,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. hr #if DESIGNER - and (* type *) - - [] + and [] internal EditorFactory(package :FSharpProjectPackage) = class let mutable serviceProvider : ServiceProvider = null @@ -3007,16 +2975,14 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. end end // class EditorFactory - and (* type *) + and - /// /// This class provides the event handler generation for the /// WPF designer. Note that this object is NOT required for languages /// where the CodeDom is used for event handler generation. This is needed /// in the case of FSharp due to limitations in the static compiler /// support. - /// - FSharpEventBindingProvider(fsFile:FSharpFileNode ) = class + FSharpEventBindingProvider(fsFile:FSharpFileNode ) = inherit EventBindingProvider() let project = fsFile.ProjectMgr @@ -3166,13 +3132,8 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. override x.ValidateMethodName(eventDescription:EventDescription, methodName:string) = () - /// This method will get the CodeTypeDeclaration corresponding to the active XAML file in - /// the designer. - end // class FSharpEventBindingProvider - and (* type *) - - FSharpRuntimeNameProvider() = + and FSharpRuntimeNameProvider() = inherit RuntimeNameProvider() override x.CreateValidName(proposal:string ) = proposal override x.IsExistingName(name:string ) = @@ -3183,7 +3144,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. override x.NameFactory = (new FSharpRuntimeNameFactory() :> RuntimeNameFactory) - and (* type *) + and [] FSharpRuntimeNameFactory() = @@ -3226,11 +3187,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. isUnique <- not (provider.IsExistingName(name)) name - and (* type *) - - /// - /// Add support for automation on py files. - /// + and /// Add support for automation on py files. [] [] public OAFSharpFileItem(project:OAProject, node:FileNode) = @@ -3258,9 +3215,8 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. base.Open(EnvDTE.Constants.vsViewKindDesigner) else base.Open(viewKind) - and (* type *) - [] + and [] public OAFSharpProject(fsharpProject:FSharpProjectNode) = inherit OAProject(fsharpProject) diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/ProjectSystem.fsproj b/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/ProjectSystem.fsproj index 2f8d5135b..f7c68a304 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/ProjectSystem.fsproj +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/ProjectSystem.fsproj @@ -15,12 +15,11 @@ {6196B0F8-CAEA-4CF1-AF82-1B520F77FE44} Library FSharp.ProjectSystem.FSharp - FSharp.ProjectSystem.FSharp.fsi LIBRARY $(NoWarn);52;75;62 true $(OtherFlags) --warnon:1182 --subsystemversion:6.00 - FX_ATLEAST_45 + FX_ATLEAST_45 false true ProjectResources.rc @@ -29,13 +28,12 @@ - true + true fsiCommands.vsct - @@ -92,8 +90,8 @@ {ee85aab7-cda0-4c4e-bda0-a64ccc413e3f} True - - FSharp.VS.FSI + + FSHarp.VS.FSI {991dcf75-c2eb-42b6-9a0d-aa1d2409d519} True @@ -124,15 +122,12 @@ VSCTCompile;CopyCtoFile;$(BuildDependsOn) - + $(IntermediateOutputPath)\ProjectResources.rc.res - + - + \ No newline at end of file diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/VB/FSharpPropPage/PropertyPages/ApplicationPropPage.vb b/vsintegration/src/vs/FsPkgs/FSharp.Project/VB/FSharpPropPage/PropertyPages/ApplicationPropPage.vb index cd315fe40..403a79efb 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/VB/FSharpPropPage/PropertyPages/ApplicationPropPage.vb +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/VB/FSharpPropPage/PropertyPages/ApplicationPropPage.vb @@ -74,10 +74,15 @@ Namespace Microsoft.VisualStudio.Editors.PropertyPages m_OutputTypeStringKeys(INDEX_COMMANDLINEAPP) = SR.GetString(SR.PPG_CommandLineApp) m_OutputTypeStringKeys(INDEX_WINDOWSCLASSLIB) = SR.GetString(SR.PPG_WindowsClassLib) - Dim v20FSharpRedistKey As String = "HKEY_LOCAL_MACHINE\Software\Microsoft\FSharp\4.1\Runtime\v2.0" - Dim v40FSharpRedistKey As String = "HKEY_LOCAL_MACHINE\Software\Microsoft\FSharp\4.1\Runtime\v4.0" +#If VS_VERSION_DEV14 Then + Dim v20FSharpRedistKey As String = "HKEY_LOCAL_MACHINE\Software\Microsoft\FSharp\4.0\Runtime\v2.0" + Dim v40FSharpRedistKey As String = "HKEY_LOCAL_MACHINE\Software\Microsoft\FSharp\4.0\Runtime\v4.0" +#Else + Dim v20FSharpRedistKey As String = "HKEY_LOCAL_MACHINE\Software\Microsoft\FSharp\4.1\Runtime\v2.0" + Dim v40FSharpRedistKey As String = "HKEY_LOCAL_MACHINE\Software\Microsoft\FSharp\4.1\Runtime\v4.0" +#End If - m_v20FSharpRedistInstalled = Not (IsNothing(Microsoft.Win32.Registry.GetValue(v20FSharpRedistKey, Nothing, Nothing))) + m_v20FSharpRedistInstalled = Not (IsNothing(Microsoft.Win32.Registry.GetValue(v20FSharpRedistKey, Nothing, Nothing))) m_v40FSharpRedistInstalled = Not (IsNothing(Microsoft.Win32.Registry.GetValue(v40FSharpRedistKey, Nothing, Nothing))) 'Add any initialization after the InitializeComponent() call diff --git a/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/FSHarp.VS.FSI.fsproj b/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/FSHarp.VS.FSI.fsproj index 11a696c26..0438bf8de 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/FSHarp.VS.FSI.fsproj +++ b/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/FSHarp.VS.FSI.fsproj @@ -1,96 +1,99 @@  - - ..\..\..\..\..\src - FSharp - true - 14.0 - - - - Debug - AnyCPU - {991dcf75-c2eb-42b6-9a0d-aa1d2409d519} - Library - FSharp.VS.FSI - true - LIBRARY - $(NoWarn);47;75 - $(OtherFlags) --subsystemversion:6.00 - - - - - - - - - - - - - - - - Properties - Properties.resx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {DED3BBD7-53F4-428A-8C9F-27968E768605} - FSharp.Core - - - FSharp.Compiler.Server.Shared - {d5870cf0-ed51-4cbc-b3d7-6f56da84ac06} - - - FSharp.Compiler - {62499922-7085-43bd-b9f2-bb352bfbc408} - - - - + + ..\..\..\..\..\src + FSharp + true + 14.0 + FSharp.VS.FSI + + + + Debug + AnyCPU + {991dcf75-c2eb-42b6-9a0d-aa1d2409d519} + Library + FSharp.VS.FSI + true + LIBRARY + $(NoWarn);47;75 + $(OtherFlags) --subsystemversion:6.00 + + + + + + + CompilerLocationUtils.fs + + + + + + + + + + + Properties + Properties.resx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {DED3BBD7-53F4-428A-8C9F-27968E768605} + FSharp.Core + + + FSharp.Compiler.Server.Shared + {d5870cf0-ed51-4cbc-b3d7-6f56da84ac06} + + + FSharp.Compiler + {62499922-7085-43bd-b9f2-bb352bfbc408} + + + + \ No newline at end of file diff --git a/vsintegration/src/vs/FsPkgs/common.fs b/vsintegration/src/vs/FsPkgs/common.fs deleted file mode 100644 index 4006cda5e..000000000 --- a/vsintegration/src/vs/FsPkgs/common.fs +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Microsoft.VisualStudio.FSharp.Shared - - module internal FSharpCommonConstants = - [] - let languageServiceGuidString = "BC6DD5A5-D4D6-4dab-A00D-A51242DBAF1B" -- GitLab