From f2be9e4303b87363fbde8f670699a634ec9a9cc7 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Fri, 29 Mar 2019 03:56:46 +0300 Subject: [PATCH 01/17] Move SourceText: Microsoft.FSharp -> FSharp (#6356) --- fcs/samples/EditorService/Program.fs | 2 +- fcs/samples/UntypedTree/Program.fs | 2 +- src/fsharp/CompileOps.fs | 3 +-- src/fsharp/CompileOps.fsi | 2 +- src/fsharp/NameResolution.fs | 2 +- src/fsharp/NameResolution.fsi | 2 +- src/fsharp/UnicodeLexing.fsi | 2 +- src/fsharp/fsi/fsi.fs | 2 +- src/fsharp/service/ServiceXmlDocParser.fs | 2 +- src/fsharp/service/ServiceXmlDocParser.fsi | 2 +- src/fsharp/service/service.fs | 2 +- src/fsharp/service/service.fsi | 2 +- src/utils/prim-lexing.fs | 4 ++-- src/utils/prim-lexing.fsi | 4 ++-- tests/FSharp.Compiler.UnitTests/Compiler.fs | 2 +- .../SourceTextTests.fs | 2 +- tests/service/AssemblyContentProviderTests.fs | 2 +- tests/service/AssemblyReaderShim.fs | 2 +- tests/service/Common.fs | 12 +++++----- tests/service/EditorTests.fs | 4 ++-- tests/service/MultiProjectAnalysisTests.fs | 4 ++-- tests/service/PerfTests.fs | 2 +- tests/service/ProjectAnalysisTests.fs | 22 +++++++++---------- tests/service/ProjectOptionsTests.fs | 6 ++--- .../Utils/LanguageServiceProfiling/Program.fs | 2 +- .../CodeFix/ReplaceWithSuggestion.fs | 1 - .../src/FSharp.Editor/Common/Extensions.fs | 2 +- .../BackgroundRequests.fs | 2 +- .../FSharp.LanguageService/FSharpSource.fs | 2 +- vsintegration/tests/Salsa/salsa.fs | 2 +- .../tests/UnitTests/RoslynSourceTextTests.fs | 2 +- .../tests/UnitTests/UnusedOpensTests.fs | 2 +- 32 files changed, 52 insertions(+), 54 deletions(-) diff --git a/fcs/samples/EditorService/Program.fs b/fcs/samples/EditorService/Program.fs index 9b78407545a..e3ab70185c3 100644 --- a/fcs/samples/EditorService/Program.fs +++ b/fcs/samples/EditorService/Program.fs @@ -8,7 +8,7 @@ open FSharp.Compiler.QuickParse let checker = FSharpChecker.Create() let parseWithTypeInfo (file, input) = - let input = Microsoft.FSharp.Compiler.Text.SourceText.ofString input + let input = FSharp.Compiler.Text.SourceText.ofString input let checkOptions, _errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously let parsingOptions, _errors = checker.GetParsingOptionsFromProjectOptions(checkOptions) let untypedRes = checker.ParseFile(file, input, parsingOptions) |> Async.RunSynchronously diff --git a/fcs/samples/UntypedTree/Program.fs b/fcs/samples/UntypedTree/Program.fs index 064f22b5abe..ba6afb2dd2b 100644 --- a/fcs/samples/UntypedTree/Program.fs +++ b/fcs/samples/UntypedTree/Program.fs @@ -11,7 +11,7 @@ let checker = FSharpChecker.Create() // Get untyped tree for a specified input let getUntypedTree (file, input) = let parsingOptions = { FSharpParsingOptions.Default with SourceFiles = [| file |] } - let untypedRes = checker.ParseFile(file, Microsoft.FSharp.Compiler.Text.SourceText.ofString input, parsingOptions) |> Async.RunSynchronously + let untypedRes = checker.ParseFile(file, FSharp.Compiler.Text.SourceText.ofString input, parsingOptions) |> Async.RunSynchronously match untypedRes.ParseTree with | Some tree -> tree | None -> failwith "Something went wrong during parsing!" diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 4a525b95970..7744d7d820e 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -44,8 +44,7 @@ open FSharp.Compiler.TypeChecker open FSharp.Compiler.Tast open FSharp.Compiler.Tastops open FSharp.Compiler.TcGlobals - -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text #if !NO_EXTENSIONTYPING open FSharp.Compiler.ExtensionTyping diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi index d8e05b2d7e5..c3d88bb4a11 100755 --- a/src/fsharp/CompileOps.fsi +++ b/src/fsharp/CompileOps.fsi @@ -17,7 +17,7 @@ open FSharp.Compiler.Ast open FSharp.Compiler.ErrorLogger open FSharp.Compiler.Tast open FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open Microsoft.FSharp.Core.CompilerServices #if !NO_EXTENSIONTYPING open FSharp.Compiler.ExtensionTyping diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index f179c420993..8e4932d5996 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -23,7 +23,7 @@ open FSharp.Compiler.AccessibilityLogic open FSharp.Compiler.AttributeChecking open FSharp.Compiler.InfoReader open FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open System.Collections.Generic #if !NO_EXTENSIONTYPING diff --git a/src/fsharp/NameResolution.fsi b/src/fsharp/NameResolution.fsi index 7fe26f4ad6e..4eff7f15635 100755 --- a/src/fsharp/NameResolution.fsi +++ b/src/fsharp/NameResolution.fsi @@ -14,7 +14,7 @@ open FSharp.Compiler.Tastops open FSharp.Compiler.TcGlobals open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text /// A NameResolver is a context for name resolution. It primarily holds an InfoReader. type NameResolver = diff --git a/src/fsharp/UnicodeLexing.fsi b/src/fsharp/UnicodeLexing.fsi index 6eda4ea8aea..7c0f0fb68d5 100644 --- a/src/fsharp/UnicodeLexing.fsi +++ b/src/fsharp/UnicodeLexing.fsi @@ -2,7 +2,7 @@ module internal FSharp.Compiler.UnicodeLexing -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open Microsoft.FSharp.Text open Internal.Utilities.Text.Lexing diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 1652eb079f1..42238dd0062 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -50,7 +50,7 @@ open FSharp.Compiler.Tastops open FSharp.Compiler.TcGlobals open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.ReferenceResolver -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open Internal.Utilities open Internal.Utilities.Collections diff --git a/src/fsharp/service/ServiceXmlDocParser.fs b/src/fsharp/service/ServiceXmlDocParser.fs index ec4c0672bb0..7152dd0c13e 100644 --- a/src/fsharp/service/ServiceXmlDocParser.fs +++ b/src/fsharp/service/ServiceXmlDocParser.fs @@ -4,7 +4,7 @@ namespace FSharp.Compiler.SourceCodeServices open FSharp.Compiler open FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text /// Represent an Xml documentation block in source code type XmlDocable = diff --git a/src/fsharp/service/ServiceXmlDocParser.fsi b/src/fsharp/service/ServiceXmlDocParser.fsi index c2f8a2f0eed..03a36a7d241 100644 --- a/src/fsharp/service/ServiceXmlDocParser.fsi +++ b/src/fsharp/service/ServiceXmlDocParser.fsi @@ -5,7 +5,7 @@ namespace FSharp.Compiler.SourceCodeServices open FSharp.Compiler open FSharp.Compiler.Range open FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text /// Represent an Xml documentation block in source code type public XmlDocable = diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 6dbb35f4990..5d772f134e9 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -41,8 +41,8 @@ open FSharp.Compiler.Infos open FSharp.Compiler.InfoReader open FSharp.Compiler.NameResolution open FSharp.Compiler.TypeChecker +open FSharp.Compiler.Text open FSharp.Compiler.SourceCodeServices.SymbolHelpers -open Microsoft.FSharp.Compiler.Text open Internal.Utilities open Internal.Utilities.Collections diff --git a/src/fsharp/service/service.fsi b/src/fsharp/service/service.fsi index 3447c006c01..4547068b515 100755 --- a/src/fsharp/service/service.fsi +++ b/src/fsharp/service/service.fsi @@ -26,7 +26,7 @@ open FSharp.Compiler.Infos open FSharp.Compiler.InfoReader open FSharp.Compiler.Tast open FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text /// Represents the reason why the GetDeclarationLocation operation failed. [] diff --git a/src/utils/prim-lexing.fs b/src/utils/prim-lexing.fs index 938d556c2c6..c397257b46c 100644 --- a/src/utils/prim-lexing.fs +++ b/src/utils/prim-lexing.fs @@ -2,7 +2,7 @@ #nowarn "47" // recursive initialization of LexBuffer -namespace Microsoft.FSharp.Compiler.Text +namespace FSharp.Compiler.Text open System open System.IO @@ -103,8 +103,8 @@ module SourceText = namespace Internal.Utilities.Text.Lexing + open FSharp.Compiler.Text open Microsoft.FSharp.Core - open Microsoft.FSharp.Compiler.Text open Microsoft.FSharp.Collections open System.Collections.Generic diff --git a/src/utils/prim-lexing.fsi b/src/utils/prim-lexing.fsi index 0544adc3409..4b4fd587171 100644 --- a/src/utils/prim-lexing.fsi +++ b/src/utils/prim-lexing.fsi @@ -3,7 +3,7 @@ // LexBuffers are for use with automatically generated lexical analyzers, // in particular those produced by 'fslex'. -namespace Microsoft.FSharp.Compiler.Text +namespace FSharp.Compiler.Text type ISourceText = @@ -36,7 +36,7 @@ module SourceText = namespace Internal.Utilities.Text.Lexing open System.Collections.Generic -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open Microsoft.FSharp.Core open Microsoft.FSharp.Control diff --git a/tests/FSharp.Compiler.UnitTests/Compiler.fs b/tests/FSharp.Compiler.UnitTests/Compiler.fs index 9e5e055562f..d85aef5b404 100644 --- a/tests/FSharp.Compiler.UnitTests/Compiler.fs +++ b/tests/FSharp.Compiler.UnitTests/Compiler.fs @@ -3,7 +3,7 @@ namespace FSharp.Compiler.UnitTests open System -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open FSharp.Compiler.SourceCodeServices open NUnit.Framework diff --git a/tests/FSharp.Compiler.UnitTests/SourceTextTests.fs b/tests/FSharp.Compiler.UnitTests/SourceTextTests.fs index 3754e75ae2d..e32647195b0 100644 --- a/tests/FSharp.Compiler.UnitTests/SourceTextTests.fs +++ b/tests/FSharp.Compiler.UnitTests/SourceTextTests.fs @@ -5,7 +5,7 @@ namespace FSharp.Compiler.UnitTests open System open NUnit.Framework -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text [] module SourceTextTests = diff --git a/tests/service/AssemblyContentProviderTests.fs b/tests/service/AssemblyContentProviderTests.fs index 171f558a801..0c0d7579077 100644 --- a/tests/service/AssemblyContentProviderTests.fs +++ b/tests/service/AssemblyContentProviderTests.fs @@ -43,7 +43,7 @@ let (=>) (source: string) (expected: string list) = // http://stackoverflow.com/questions/19365404/stringreader-omits-trailing-linebreak yield "" |] - let _, checkFileAnswer = checker.ParseAndCheckFileInProject(filePath, 0, Microsoft.FSharp.Compiler.Text.SourceText.ofString source, projectOptions) |> Async.RunSynchronously + let _, checkFileAnswer = checker.ParseAndCheckFileInProject(filePath, 0, FSharp.Compiler.Text.SourceText.ofString source, projectOptions) |> Async.RunSynchronously let checkFileResults = match checkFileAnswer with diff --git a/tests/service/AssemblyReaderShim.fs b/tests/service/AssemblyReaderShim.fs index faa9963ceab..e3512178f02 100644 --- a/tests/service/AssemblyReaderShim.fs +++ b/tests/service/AssemblyReaderShim.fs @@ -29,5 +29,5 @@ let x = 123 """ let fileName, options = Common.mkTestFileAndOptions source [| |] - Common.checker.ParseAndCheckFileInProject(fileName, 0, Microsoft.FSharp.Compiler.Text.SourceText.ofString source, options) |> Async.RunSynchronously |> ignore + Common.checker.ParseAndCheckFileInProject(fileName, 0, FSharp.Compiler.Text.SourceText.ofString source, options) |> Async.RunSynchronously |> ignore gotRequest |> should be True diff --git a/tests/service/Common.fs b/tests/service/Common.fs index f6a2f4a6ad0..0ec9aa2ab3c 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -57,13 +57,13 @@ type TempFile(ext, contents) = let getBackgroundParseResultsForScriptText (input) = use file = new TempFile("fsx", input) - let checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(file.Name, Microsoft.FSharp.Compiler.Text.SourceText.ofString input) |> Async.RunSynchronously + let checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(file.Name, FSharp.Compiler.Text.SourceText.ofString input) |> Async.RunSynchronously checker.GetBackgroundParseResultsForFileInProject(file.Name, checkOptions) |> Async.RunSynchronously let getBackgroundCheckResultsForScriptText (input) = use file = new TempFile("fsx", input) - let checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(file.Name, Microsoft.FSharp.Compiler.Text.SourceText.ofString input) |> Async.RunSynchronously + let checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(file.Name, FSharp.Compiler.Text.SourceText.ofString input) |> Async.RunSynchronously checker.GetBackgroundCheckResultsForFileInProject(file.Name, checkOptions) |> Async.RunSynchronously @@ -167,7 +167,7 @@ let mkTestFileAndOptions source additionalArgs = fileName, options let parseAndCheckFile fileName source options = - match checker.ParseAndCheckFileInProject(fileName, 0, Microsoft.FSharp.Compiler.Text.SourceText.ofString source, options) |> Async.RunSynchronously with + match checker.ParseAndCheckFileInProject(fileName, 0, FSharp.Compiler.Text.SourceText.ofString source, options) |> Async.RunSynchronously with | parseResults, FSharpCheckFileAnswer.Succeeded(checkResults) -> parseResults, checkResults | _ -> failwithf "Parsing aborted unexpectedly..." @@ -181,11 +181,11 @@ let parseAndCheckScript (file, input) = let projectOptions = checker.GetProjectOptionsFromCommandLineArgs (projName, args) #else - let projectOptions, _diagnostics = checker.GetProjectOptionsFromScript(file, Microsoft.FSharp.Compiler.Text.SourceText.ofString input) |> Async.RunSynchronously + let projectOptions, _diagnostics = checker.GetProjectOptionsFromScript(file, FSharp.Compiler.Text.SourceText.ofString input) |> Async.RunSynchronously printfn "projectOptions = %A" projectOptions #endif - let parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, Microsoft.FSharp.Compiler.Text.SourceText.ofString input, projectOptions) |> Async.RunSynchronously + let parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, FSharp.Compiler.Text.SourceText.ofString input, projectOptions) |> Async.RunSynchronously // if parseResult.Errors.Length > 0 then // printfn "---> Parse Input = %A" input @@ -203,7 +203,7 @@ let parseSourceCode (name: string, code: string) = let dllPath = Path.Combine(location, name + ".dll") let args = mkProjectCommandLineArgs(dllPath, [filePath]) let options, errors = checker.GetParsingOptionsFromCommandLineArgs(List.ofArray args) - let parseResults = checker.ParseFile(filePath, Microsoft.FSharp.Compiler.Text.SourceText.ofString code, options) |> Async.RunSynchronously + let parseResults = checker.ParseFile(filePath, FSharp.Compiler.Text.SourceText.ofString code, options) |> Async.RunSynchronously parseResults.ParseTree /// Extract range info diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index fad47bd0d86..949040441f7 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -122,8 +122,8 @@ let ``Basic cancellation test`` () = let file = "/home/user/Test.fsx" async { checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() - let! checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(file, Microsoft.FSharp.Compiler.Text.SourceText.ofString input) - let! parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, Microsoft.FSharp.Compiler.Text.SourceText.ofString input, checkOptions) + let! checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(file, FSharp.Compiler.Text.SourceText.ofString input) + let! parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, FSharp.Compiler.Text.SourceText.ofString input, checkOptions) return parseResult, typedRes } |> Async.RunSynchronously |> ignore diff --git a/tests/service/MultiProjectAnalysisTests.fs b/tests/service/MultiProjectAnalysisTests.fs index 1fe2efb8e04..51c06808eb1 100644 --- a/tests/service/MultiProjectAnalysisTests.fs +++ b/tests/service/MultiProjectAnalysisTests.fs @@ -913,7 +913,7 @@ let ``Type provider project references should not throw exceptions`` () = //printfn "options: %A" options let fileName = __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/Program.fs" let fileSource = File.ReadAllText(fileName) - let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource, options) |> Async.RunSynchronously + let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, FSharp.Compiler.Text.SourceText.ofString fileSource, options) |> Async.RunSynchronously let fileCheckResults = match fileCheckAnswer with | FSharpCheckFileAnswer.Succeeded(res) -> res @@ -1010,7 +1010,7 @@ let ``Projects creating generated types should not utilize cross-project-referen //printfn "options: %A" options let fileName = __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/Program.fs" let fileSource = File.ReadAllText(fileName) - let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource, options) |> Async.RunSynchronously + let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, FSharp.Compiler.Text.SourceText.ofString fileSource, options) |> Async.RunSynchronously let fileCheckResults = match fileCheckAnswer with | FSharpCheckFileAnswer.Succeeded(res) -> res diff --git a/tests/service/PerfTests.fs b/tests/service/PerfTests.fs index c5bd78f340d..7e97f923985 100644 --- a/tests/service/PerfTests.fs +++ b/tests/service/PerfTests.fs @@ -31,7 +31,7 @@ module internal Project1 = let projFileName = Path.ChangeExtension(base2, ".fsproj") let fileSources = [ for (i,f) in fileNamesI -> (f, "module M" + string i) ] for (f,text) in fileSources do File.WriteAllText(f, text) - let fileSources2 = [ for (i,f) in fileSources -> Microsoft.FSharp.Compiler.Text.SourceText.ofString f ] + let fileSources2 = [ for (i,f) in fileSources -> FSharp.Compiler.Text.SourceText.ofString f ] let fileNames = [ for (_,f) in fileNamesI -> f ] let args = mkProjectCommandLineArgs (dllName, fileNames) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index afcb05ee83a..37bef3c9c26 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -39,7 +39,7 @@ let fff () = xxx + xxx type CAbbrev = C """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text File.WriteAllText(fileName1, fileSource1Text) let fileSource2Text = """ @@ -84,7 +84,7 @@ let mmmm1 : M.C = new M.C() // note, these don't count as uses of CA let mmmm2 : M.CAbbrev = new M.CAbbrev() // note, these don't count as uses of C """ - let fileSource2 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource2Text + let fileSource2 = FSharp.Compiler.Text.SourceText.ofString fileSource2Text File.WriteAllText(fileName2, fileSource2Text) let fileNames = [fileName1; fileName2] @@ -2429,7 +2429,7 @@ and F = { Field1 : int; Field2 : int } and G = Case1 | Case2 of int """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text File.WriteAllText(fileName1, fileSource1Text) let sigFileSource1Text = """ @@ -2451,7 +2451,7 @@ and F = { Field1 : int; Field2 : int } and G = Case1 | Case2 of int """ - let sigFileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString sigFileSource1Text + let sigFileSource1 = FSharp.Compiler.Text.SourceText.ofString sigFileSource1Text File.WriteAllText(sigFileName1, sigFileSource1Text) let cleanFileName a = if a = fileName1 then "file1" elif a = sigFileName1 then "sig1" else "??" @@ -4514,7 +4514,7 @@ module internal Project35b = #r "System.dll" #r "notexist.dll" """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text File.WriteAllText(fileName1, fileSource1Text) let cleanFileName a = if a = fileName1 then "file1" else "??" @@ -5158,7 +5158,7 @@ module internal ProjectBig = let projFileName = Path.ChangeExtension(base2, ".fsproj") let fileSources = [ for (i,f) in fileNamesI -> (f, "module M" + string i) ] for (f,text) in fileSources do File.WriteAllText(f, text) - let fileSources2 = [ for (i,f) in fileSources -> Microsoft.FSharp.Compiler.Text.SourceText.ofString f ] + let fileSources2 = [ for (i,f) in fileSources -> FSharp.Compiler.Text.SourceText.ofString f ] let fileNames = [ for (_,f) in fileNamesI -> f ] let args = mkProjectCommandLineArgs (dllName, fileNames) @@ -5246,7 +5246,7 @@ module M # 10 "Test.fsy" let x = (1 = 3.0) """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text File.WriteAllText(fileName1, fileSource1Text) let fileNames = [fileName1] let args = mkProjectCommandLineArgs (dllName, fileNames) @@ -5287,7 +5287,7 @@ let ``ParseAndCheckFileResults contains ImplFile list if FSharpChecker is create type A(i:int) = member x.Value = i """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text File.WriteAllText(fileName1, fileSource1Text) let fileNames = [fileName1] @@ -5378,7 +5378,7 @@ type UseTheThings(i:int) = member x.UseSomeUsedModuleContainingExtensionMember() = (3).Q member x.UseSomeUsedModuleContainingUnion() = A """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text File.WriteAllText(fileName1, fileSource1Text) let fileNames = [fileName1] @@ -5451,7 +5451,7 @@ type UseTheThings(i:int) = member x.UseSomeUsedModuleContainingExtensionMember() = (3).Q member x.UseSomeUsedModuleContainingUnion() = A """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text File.WriteAllText(fileName1, fileSource1Text) let fileNames = [fileName1] @@ -5524,7 +5524,7 @@ type UseTheThings(i:int) = member x.UseSomeUsedModuleContainingExtensionMember() = (3).Q member x.UseSomeUsedModuleContainingUnion() = A """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text File.WriteAllText(fileName1, fileSource1Text) let fileNames = [fileName1] diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index e00550742ae..141c33be92e 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -508,7 +508,7 @@ let ``Test SourceFiles order for GetProjectOptionsFromScript`` () = // See #594 let scriptPath = __SOURCE_DIRECTORY__ + @"/data/ScriptProject/" + scriptName + ".fsx" let scriptSource = File.ReadAllText scriptPath let projOpts, _diagnostics = - checker.GetProjectOptionsFromScript(scriptPath, Microsoft.FSharp.Compiler.Text.SourceText.ofString scriptSource) + checker.GetProjectOptionsFromScript(scriptPath, FSharp.Compiler.Text.SourceText.ofString scriptSource) |> Async.RunSynchronously projOpts.SourceFiles |> Array.map Path.GetFileNameWithoutExtension @@ -534,12 +534,12 @@ module ImplFile let x = 42 #endif """ - let fileSource1 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource1Text + let fileSource1 = FSharp.Compiler.Text.SourceText.ofString fileSource1Text let fileSource2Text = """ #load "Impl.fs" ImplFile.x """ - let fileSource2 = Microsoft.FSharp.Compiler.Text.SourceText.ofString fileSource2Text + let fileSource2 = FSharp.Compiler.Text.SourceText.ofString fileSource2Text File.WriteAllText(fileName1, fileSource1Text) File.WriteAllText(fileName2, fileSource2Text) diff --git a/vsintegration/Utils/LanguageServiceProfiling/Program.fs b/vsintegration/Utils/LanguageServiceProfiling/Program.fs index 2b49b8f754a..521c3b90200 100644 --- a/vsintegration/Utils/LanguageServiceProfiling/Program.fs +++ b/vsintegration/Utils/LanguageServiceProfiling/Program.fs @@ -42,7 +42,7 @@ Results look like this: *) open FSharp.Compiler -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open FSharp.Compiler.SourceCodeServices open System open System.IO diff --git a/vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs b/vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs index fcf8ba56557..dd52a71312d 100644 --- a/vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs +++ b/vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs @@ -12,7 +12,6 @@ open FSharp.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Range open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Text [] type internal FSharpReplaceWithSuggestionCodeFixProvider diff --git a/vsintegration/src/FSharp.Editor/Common/Extensions.fs b/vsintegration/src/FSharp.Editor/Common/Extensions.fs index 612f618ade3..694d3a401a8 100644 --- a/vsintegration/src/FSharp.Editor/Common/Extensions.fs +++ b/vsintegration/src/FSharp.Editor/Common/Extensions.fs @@ -8,7 +8,7 @@ open System.IO open Microsoft.CodeAnalysis open Microsoft.CodeAnalysis.Text open Microsoft.CodeAnalysis.Host -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open FSharp.Compiler.Ast open FSharp.Compiler.SourceCodeServices diff --git a/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs b/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs index cb7c1462bac..10cd776b0d0 100644 --- a/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs +++ b/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs @@ -94,7 +94,7 @@ type internal FSharpLanguageServiceBackgroundRequests_DEPRECATED lazy // This portion is executed on the language service thread let timestamp = if source=null then System.DateTime(2000,1,1) else source.OpenedTime // source is null in unit tests let checker = getInteractiveChecker() - let checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(fileName, Microsoft.FSharp.Compiler.Text.SourceText.ofString sourceText, timestamp, [| |]) |> Async.RunSynchronously + let checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(fileName, FSharp.Compiler.Text.SourceText.ofString sourceText, timestamp, [| |]) |> Async.RunSynchronously let referencedProjectFileNames = [| |] let projectSite = ProjectSitesAndFiles.CreateProjectSiteForScript(fileName, referencedProjectFileNames, checkOptions) { ProjectSite = projectSite diff --git a/vsintegration/src/FSharp.LanguageService/FSharpSource.fs b/vsintegration/src/FSharp.LanguageService/FSharpSource.fs index 3f4ca4dfa4c..446fcfffb77 100644 --- a/vsintegration/src/FSharp.LanguageService/FSharpSource.fs +++ b/vsintegration/src/FSharp.LanguageService/FSharpSource.fs @@ -371,7 +371,7 @@ type internal FSharpSource_DEPRECATED(service:LanguageService_DEPRECATED, textLi Stamp = None } |> ic.GetParsingOptionsFromProjectOptions - ic.ParseFile(fileName, Microsoft.FSharp.Compiler.Text.SourceText.ofString (source.GetText()), co) |> Async.RunSynchronously + ic.ParseFile(fileName, FSharp.Compiler.Text.SourceText.ofString (source.GetText()), co) |> Async.RunSynchronously override source.GetCommentFormat() = let mutable info = new CommentInfo() diff --git a/vsintegration/tests/Salsa/salsa.fs b/vsintegration/tests/Salsa/salsa.fs index a0a20cada64..e2d00e6268c 100644 --- a/vsintegration/tests/Salsa/salsa.fs +++ b/vsintegration/tests/Salsa/salsa.fs @@ -1101,7 +1101,7 @@ module internal Salsa = member file.GetFileName() = filename member file.GetProjectOptionsOfScript() = - project.Solution.Vs.LanguageService.FSharpChecker.GetProjectOptionsFromScript(filename, Microsoft.FSharp.Compiler.Text.SourceText.ofString file.CombinedLines, System.DateTime(2000,1,1), [| |]) + project.Solution.Vs.LanguageService.FSharpChecker.GetProjectOptionsFromScript(filename, FSharp.Compiler.Text.SourceText.ofString file.CombinedLines, System.DateTime(2000,1,1), [| |]) |> Async.RunSynchronously |> fst // drop diagnostics diff --git a/vsintegration/tests/UnitTests/RoslynSourceTextTests.fs b/vsintegration/tests/UnitTests/RoslynSourceTextTests.fs index 23b1e6702a0..9a817df9771 100644 --- a/vsintegration/tests/UnitTests/RoslynSourceTextTests.fs +++ b/vsintegration/tests/UnitTests/RoslynSourceTextTests.fs @@ -6,7 +6,7 @@ open System open NUnit.Framework open Microsoft.VisualStudio.FSharp.Editor -open Microsoft.FSharp.Compiler.Text +open FSharp.Compiler.Text open Microsoft.CodeAnalysis.Text [] diff --git a/vsintegration/tests/UnitTests/UnusedOpensTests.fs b/vsintegration/tests/UnitTests/UnusedOpensTests.fs index 04eb51e6e8d..097e583fe6a 100644 --- a/vsintegration/tests/UnitTests/UnusedOpensTests.fs +++ b/vsintegration/tests/UnitTests/UnusedOpensTests.fs @@ -29,7 +29,7 @@ let private checker = FSharpChecker.Create() let (=>) (source: string) (expectedRanges: ((*line*)int * ((*start column*)int * (*end column*)int)) list) = let sourceLines = source.Split ([|"\r\n"; "\n"; "\r"|], StringSplitOptions.None) - let _, checkFileAnswer = checker.ParseAndCheckFileInProject(filePath, 0, Microsoft.FSharp.Compiler.Text.SourceText.ofString source, projectOptions) |> Async.RunSynchronously + let _, checkFileAnswer = checker.ParseAndCheckFileInProject(filePath, 0, FSharp.Compiler.Text.SourceText.ofString source, projectOptions) |> Async.RunSynchronously let checkFileResults = match checkFileAnswer with From 1a0d385c84d66dd42b241d08895cd534f7f7c24d Mon Sep 17 00:00:00 2001 From: Will Smith Date: Sat, 30 Mar 2019 20:10:29 -0700 Subject: [PATCH 02/17] Making ILVersionInfo a struct (#6392) * Making ILVersionInfo a struct * Fixing tests --- src/absil/il.fs | 37 ++++++++------ src/absil/il.fsi | 10 +++- src/absil/ilprint.fs | 10 ++-- src/absil/ilread.fs | 14 +++--- src/absil/ilreflect.fs | 4 +- src/absil/ilwrite.fs | 23 ++++----- src/fsharp/TastOps.fs | 12 ++--- src/fsharp/TastPickle.fs | 6 ++- src/fsharp/fsc.fs | 14 +++--- .../ProductVersion.fs | 50 +++++++++---------- 10 files changed, 99 insertions(+), 81 deletions(-) diff --git a/src/absil/il.fs b/src/absil/il.fs index 012a2385925..6a5714125bb 100644 --- a/src/absil/il.fs +++ b/src/absil/il.fs @@ -320,7 +320,16 @@ let sha1HashInt64 s = SHA1.sha1HashInt64 s // // -------------------------------------------------------------------- -type ILVersionInfo = uint16 * uint16 * uint16 * uint16 +[] +type ILVersionInfo = + + val Major: uint16 + val Minor: uint16 + val Build: uint16 + val Revision: uint16 + + new(major, minor, build, revision) = + { Major = major; Minor = minor; Build = build; Revision = revision } type Locale = string @@ -411,7 +420,7 @@ type ILAssemblyRef(data) = let version = match aname.Version with | null -> None - | v -> Some (uint16 v.Major, uint16 v.Minor, uint16 v.Build, uint16 v.Revision) + | v -> Some (ILVersionInfo (uint16 v.Major, uint16 v.Minor, uint16 v.Build, uint16 v.Revision)) let retargetable = aname.Flags = System.Reflection.AssemblyNameFlags.Retargetable @@ -424,15 +433,15 @@ type ILAssemblyRef(data) = add(aref.Name) match aref.Version with | None -> () - | Some (a, b, c, d) -> + | Some (version) -> add ", Version=" - add (string (int a)) + add (string (int version.Major)) add "." - add (string (int b)) + add (string (int version.Minor)) add "." - add (string (int c)) + add (string (int version.Build)) add "." - add (string (int d)) + add (string (int version.Revision)) add ", Culture=" match aref.Locale with | None -> add "neutral" @@ -3560,7 +3569,7 @@ let et_MVAR = 0x1Euy let et_CMOD_REQD = 0x1Fuy let et_CMOD_OPT = 0x20uy -let formatILVersion ((a, b, c, d):ILVersionInfo) = sprintf "%d.%d.%d.%d" (int a) (int b) (int c) (int d) +let formatILVersion (version: ILVersionInfo) = sprintf "%d.%d.%d.%d" (int version.Major) (int version.Minor) (int version.Build) (int version.Revision) let encodeCustomAttrString s = let arr = string_as_utf8_bytes s @@ -4241,17 +4250,17 @@ let parseILVersion (vstr : string) = let zero32 n = if n < 0 then 0us else uint16(n) // since the minor revision will be -1 if none is specified, we need to truncate to 0 to not break existing code let minorRevision = if version.Revision = -1 then 0us else uint16(version.MinorRevision) - (zero32 version.Major, zero32 version.Minor, zero32 version.Build, minorRevision) + ILVersionInfo(zero32 version.Major, zero32 version.Minor, zero32 version.Build, minorRevision) -let compareILVersions (a1, a2, a3, a4) ((b1, b2, b3, b4) : ILVersionInfo) = - let c = compare a1 b1 +let compareILVersions (version1 : ILVersionInfo) (version2 : ILVersionInfo) = + let c = compare version1.Major version2.Major if c <> 0 then c else - let c = compare a2 b2 + let c = compare version1.Minor version2.Minor if c <> 0 then c else - let c = compare a3 b3 + let c = compare version1.Build version2.Build if c <> 0 then c else - let c = compare a4 b4 + let c = compare version1.Revision version2.Revision if c <> 0 then c else 0 diff --git a/src/absil/il.fsi b/src/absil/il.fsi index 81ea5622514..87fd66932a6 100644 --- a/src/absil/il.fsi +++ b/src/absil/il.fsi @@ -53,7 +53,15 @@ type PublicKey = member KeyToken: byte[] static member KeyAsToken: byte[] -> PublicKey -type ILVersionInfo = uint16 * uint16 * uint16 * uint16 +[] +type ILVersionInfo = + + val Major: uint16 + val Minor: uint16 + val Build: uint16 + val Revision: uint16 + + new : major: uint16 * minor: uint16 * build: uint16 * revision: uint16 -> ILVersionInfo [] type ILAssemblyRef = diff --git a/src/absil/ilprint.fs b/src/absil/ilprint.fs index f9f7fb7af19..2e8cbc0acf1 100644 --- a/src/absil/ilprint.fs +++ b/src/absil/ilprint.fs @@ -963,15 +963,15 @@ and goutput_lambdas env os lambdas = and goutput_tdefs contents enc env os (td: ILTypeDefs) = List.iter (goutput_tdef enc env contents os) td.AsList -let output_ver os (a,b,c,d) = +let output_ver os (version: ILVersionInfo) = output_string os " .ver " - output_u16 os a + output_u16 os version.Major output_string os " : " - output_u16 os b + output_u16 os version.Minor output_string os " : " - output_u16 os c + output_u16 os version.Build output_string os " : " - output_u16 os d + output_u16 os version.Revision let output_locale os s = output_string os " .Locale "; output_qstring os s diff --git a/src/absil/ilread.fs b/src/absil/ilread.fs index b7130c44ba9..9732e543b3d 100644 --- a/src/absil/ilread.fs +++ b/src/absil/ilread.fs @@ -1667,7 +1667,7 @@ and seekReadAssemblyManifest (ctxt: ILMetadataReader) pectxt idx = AuxModuleHashAlgorithm=hash SecurityDeclsStored= ctxt.securityDeclsReader_Assembly PublicKey= pubkey - Version= Some (v1, v2, v3, v4) + Version= Some (ILVersionInfo (v1, v2, v3, v4)) Locale= readStringHeapOption ctxt localeIdx CustomAttrsStored = ctxt.customAttrsReader_Assembly MetadataIndex = idx @@ -1700,12 +1700,12 @@ and seekReadAssemblyRefUncached ctxtH idx = | Some blob -> Some (if (flags &&& 0x0001) <> 0x0 then PublicKey blob else PublicKeyToken blob) ILAssemblyRef.Create - (name=nm, - hash=readBlobHeapOption ctxt hashValueIdx, - publicKey=publicKey, - retargetable=((flags &&& 0x0100) <> 0x0), - version=Some(v1, v2, v3, v4), - locale=readStringHeapOption ctxt localeIdx) + (name = nm, + hash = readBlobHeapOption ctxt hashValueIdx, + publicKey = publicKey, + retargetable = ((flags &&& 0x0100) <> 0x0), + version = Some (ILVersionInfo (v1, v2, v3, v4)), + locale = readStringHeapOption ctxt localeIdx) and seekReadModuleRef (ctxt: ILMetadataReader) mdv idx = let (nameIdx) = seekReadModuleRefRow ctxt mdv idx diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs index 1381efd591f..f97f6fca425 100644 --- a/src/absil/ilreflect.fs +++ b/src/absil/ilreflect.fs @@ -310,8 +310,8 @@ let convAssemblyRef (aref:ILAssemblyRef) = | None -> () | Some (PublicKey bytes) -> asmName.SetPublicKey(bytes) | Some (PublicKeyToken bytes) -> asmName.SetPublicKeyToken(bytes)) - let setVersion (major, minor, build, rev) = - asmName.Version <- System.Version (int32 major, int32 minor, int32 build, int32 rev) + let setVersion (version: ILVersionInfo) = + asmName.Version <- System.Version (int32 version.Major, int32 version.Minor, int32 version.Build, int32 version.Revision) Option.iter setVersion aref.Version // asmName.ProcessorArchitecture <- System.Reflection.ProcessorArchitecture.MSIL #if !FX_RESHAPED_GLOBALIZATION diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs index a3a4d61f7f5..5dc02390aa1 100644 --- a/src/absil/ilwrite.fs +++ b/src/absil/ilwrite.fs @@ -709,10 +709,10 @@ let rec GetIdxForTypeDef cenv key = let rec GetAssemblyRefAsRow cenv (aref:ILAssemblyRef) = AssemblyRefRow - ((match aref.Version with None -> 0us | Some (x, _, _, _) -> x), - (match aref.Version with None -> 0us | Some (_, y, _, _) -> y), - (match aref.Version with None -> 0us | Some (_, _, z, _) -> z), - (match aref.Version with None -> 0us | Some (_, _, _, w) -> w), + ((match aref.Version with None -> 0us | Some (version) -> version.Major), + (match aref.Version with None -> 0us | Some (version) -> version.Minor), + (match aref.Version with None -> 0us | Some (version) -> version.Build), + (match aref.Version with None -> 0us | Some (version) -> version.Revision), ((match aref.PublicKey with Some (PublicKey _) -> 0x0001 | _ -> 0x0000) ||| (if aref.Retargetable then 0x0100 else 0x0000)), BlobIndex (match aref.PublicKey with @@ -2822,10 +2822,10 @@ and GenExportedTypesPass3 cenv (ce: ILExportedTypesAndForwarders) = and GetManifsetAsAssemblyRow cenv m = UnsharedRow [|ULong m.AuxModuleHashAlgorithm - UShort (match m.Version with None -> 0us | Some (x, _, _, _) -> x) - UShort (match m.Version with None -> 0us | Some (_, y, _, _) -> y) - UShort (match m.Version with None -> 0us | Some (_, _, z, _) -> z) - UShort (match m.Version with None -> 0us | Some (_, _, _, w) -> w) + UShort (match m.Version with None -> 0us | Some (version) -> version.Major) + UShort (match m.Version with None -> 0us | Some (version) -> version.Minor) + UShort (match m.Version with None -> 0us | Some (version) -> version.Build) + UShort (match m.Version with None -> 0us | Some (version) -> version.Revision) ULong ( (match m.AssemblyLongevity with | ILAssemblyLongevity.Unspecified -> 0x0000 @@ -3091,9 +3091,8 @@ let writeILMetadataAndCode (generatePdb, desiredMetadataVersion, ilg, emitTailca let (mdtableVersionMajor, mdtableVersionMinor) = metadataSchemaVersionSupportedByCLRVersion desiredMetadataVersion - let version = - let (a, b, c, _) = desiredMetadataVersion - System.Text.Encoding.UTF8.GetBytes (sprintf "v%d.%d.%d" a b c) + let version = + System.Text.Encoding.UTF8.GetBytes (sprintf "v%d.%d.%d" desiredMetadataVersion.Major desiredMetadataVersion.Minor desiredMetadataVersion.Build) let paddedVersionLength = align 0x4 (Array.length version) @@ -3634,7 +3633,7 @@ let writeBinaryAndReportMappings (outfile, | ILScopeRef.Module(_) -> failwith "Expected mscorlib to be ILScopeRef.Assembly was ILScopeRef.Module" | ILScopeRef.Assembly(aref) -> match aref.Version with - | Some (2us, _, _, _) -> parseILVersion "2.0.50727.0" + | Some (version) when version.Major = 2us -> parseILVersion "2.0.50727.0" | Some v -> v | None -> failwith "Expected msorlib to have a version number" diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 8d659f54aed..e0760e3526a 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -7004,13 +7004,13 @@ let tnames_SignatureDataVersionAttr = splitILTypeName tname_SignatureDataVersion let tref_SignatureDataVersionAttr () = mkILTyRef(IlxSettings.ilxFsharpCoreLibScopeRef (), tname_SignatureDataVersionAttr) -let mkSignatureDataVersionAttr (g:TcGlobals) ((v1, v2, v3, _) : ILVersionInfo) = +let mkSignatureDataVersionAttr (g: TcGlobals) (version: ILVersionInfo) = mkILCustomAttribute g.ilg (tref_SignatureDataVersionAttr(), [g.ilg.typ_Int32;g.ilg.typ_Int32;g.ilg.typ_Int32], - [ILAttribElem.Int32 (int32 v1) - ILAttribElem.Int32 (int32 v2) - ILAttribElem.Int32 (int32 v3)], []) + [ILAttribElem.Int32 (int32 version.Major) + ILAttribElem.Int32 (int32 version.Minor) + ILAttribElem.Int32 (int32 version.Build)], []) let tname_AutoOpenAttr = FSharpLib.Core + ".AutoOpenAttribute" @@ -7040,11 +7040,11 @@ let TryFindInternalsVisibleToAttr ilg cattr = else None -let IsMatchingSignatureDataVersionAttr ilg ((v1, v2, v3, _) : ILVersionInfo) cattr = +let IsMatchingSignatureDataVersionAttr ilg (version: ILVersionInfo) cattr = IsSignatureDataVersionAttr cattr && match decodeILAttribData ilg cattr with | [ILAttribElem.Int32 u1; ILAttribElem.Int32 u2;ILAttribElem.Int32 u3 ], _ -> - (v1 = uint16 u1) && (v2 = uint16 u2) && (v3 = uint16 u3) + (version.Major = uint16 u1) && (version.Minor = uint16 u2) && (version.Build = uint16 u3) | _ -> warning(Failure(FSComp.SR.tastUnexpectedDecodeOfInterfaceDataVersionAttribute())) false diff --git a/src/fsharp/TastPickle.fs b/src/fsharp/TastPickle.fs index c988d3b338f..a8763a87934 100644 --- a/src/fsharp/TastPickle.fs +++ b/src/fsharp/TastPickle.fs @@ -906,7 +906,7 @@ let p_ILPublicKey x st = | PublicKey b -> p_byte 0 st; p_bytes b st | PublicKeyToken b -> p_byte 1 st; p_bytes b st -let p_ILVersion x st = p_tup4 p_uint16 p_uint16 p_uint16 p_uint16 x st +let p_ILVersion (x: ILVersionInfo) st = p_tup4 p_uint16 p_uint16 p_uint16 p_uint16 (x.Major, x.Minor, x.Build, x.Revision) st let p_ILModuleRef (x:ILModuleRef) st = p_tup3 p_string p_bool (p_option p_bytes) (x.Name, x.HasMetadata, x.Hash) st @@ -929,7 +929,9 @@ let u_ILPublicKey st = | 1 -> u_bytes st |> PublicKeyToken | _ -> ufailwith st "u_ILPublicKey" -let u_ILVersion st = u_tup4 u_uint16 u_uint16 u_uint16 u_uint16 st +let u_ILVersion st = + let (major, minor, build, revision) = u_tup4 u_uint16 u_uint16 u_uint16 u_uint16 st + ILVersionInfo(major, minor, build, revision) let u_ILModuleRef st = let (a, b, c) = u_tup3 u_string u_bool (u_option u_bytes) st diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index 29701c86e8a..9471ca9d64f 100644 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -533,18 +533,18 @@ module VersionResourceFormat = for child in children do yield! child |] - let Version((v1, v2, v3, v4):ILVersionInfo) = + let Version(version: ILVersionInfo) = [| // DWORD dwFileVersionMS // Specifies the most significant 32 bits of the file's binary // version number. This member is used with dwFileVersionLS to form a 64-bit value used // for numeric comparisons. - yield! i32 (int32 v1 <<< 16 ||| int32 v2) + yield! i32 (int32 version.Major <<< 16 ||| int32 version.Minor) // DWORD dwFileVersionLS // Specifies the least significant 32 bits of the file's binary // version number. This member is used with dwFileVersionMS to form a 64-bit value used // for numeric comparisons. - yield! i32 (int32 v3 <<< 16 ||| int32 v4) + yield! i32 (int32 version.Build <<< 16 ||| int32 version.Revision) |] let String(string, value) = @@ -824,7 +824,7 @@ module MainModuleBuilder = let productVersion findStringAttr (fileVersion: ILVersionInfo) = let attrName = "System.Reflection.AssemblyInformationalVersionAttribute" - let toDotted (v1, v2, v3, v4) = sprintf "%d.%d.%d.%d" v1 v2 v3 v4 + let toDotted (version: ILVersionInfo) = sprintf "%d.%d.%d.%d" version.Major version.Minor version.Build version.Revision match findStringAttr attrName with | None | Some "" -> fileVersion |> toDotted | Some (AttributeHelpers.ILVersion(v)) -> v |> toDotted @@ -840,7 +840,7 @@ module MainModuleBuilder = |> Seq.takeWhile ((<>) 0us) |> Seq.toList match validParts @ [0us; 0us; 0us; 0us] with - | major :: minor :: build :: rev :: _ -> (major, minor, build, rev) + | major :: minor :: build :: rev :: _ -> ILVersionInfo(major, minor, build, rev) | x -> failwithf "error converting product version '%s' to binary, tried '%A' " version x @@ -986,8 +986,8 @@ module MainModuleBuilder = // specify the major language, and the high-order 6 bits specify the sublanguage. // For a table of valid identifiers see Language Identifiers. // // see e.g. http://msdn.microsoft.com/en-us/library/aa912040.aspx 0000 is neutral and 04b0(hex)=1252(dec) is the code page. - [ ("000004b0", [ yield ("Assembly Version", (let v1, v2, v3, v4 = assemblyVersion in sprintf "%d.%d.%d.%d" v1 v2 v3 v4)) - yield ("FileVersion", (let v1, v2, v3, v4 = fileVersionInfo in sprintf "%d.%d.%d.%d" v1 v2 v3 v4)) + [ ("000004b0", [ yield ("Assembly Version", (sprintf "%d.%d.%d.%d" assemblyVersion.Major assemblyVersion.Minor assemblyVersion.Build assemblyVersion.Revision)) + yield ("FileVersion", (sprintf "%d.%d.%d.%d" fileVersionInfo.Major fileVersionInfo.Minor fileVersionInfo.Build fileVersionInfo.Revision)) yield ("ProductVersion", productVersionString) match tcConfig.outputFile with | Some f -> yield ("OriginalFilename", Path.GetFileName(f)) diff --git a/tests/FSharp.Compiler.UnitTests/ProductVersion.fs b/tests/FSharp.Compiler.UnitTests/ProductVersion.fs index de528d3329d..84d05f43e32 100644 --- a/tests/FSharp.Compiler.UnitTests/ProductVersion.fs +++ b/tests/FSharp.Compiler.UnitTests/ProductVersion.fs @@ -16,23 +16,23 @@ module FileVersionTest = [] let parseILVersion () = - "0.0.0.0" |> parseILVersion |> Assert.areEqual (0us,0us,0us,0us) - "1.2.3.4" |> parseILVersion |> Assert.areEqual (1us,2us,3us,4us) + "0.0.0.0" |> parseILVersion |> Assert.areEqual (ILVersionInfo(0us,0us,0us,0us)) + "1.2.3.4" |> parseILVersion |> Assert.areEqual (ILVersionInfo(1us,2us,3us,4us)) [] let ``should use AssemblyFileVersionAttribute if set`` () = let findStringAttr n = n |> Assert.areEqual fileVersionAttrName; Some "1.2.3.4" - fileVersion findStringAttr (1us,0us,0us,0us) |> Assert.areEqual (1us,2us,3us,4us) + fileVersion findStringAttr (ILVersionInfo(1us,0us,0us,0us)) |> Assert.areEqual (ILVersionInfo(1us,2us,3us,4us)) [] let ``should fallback if AssemblyFileVersionAttribute is not a valid version`` () = - fileVersion (fun _ -> Some "1.2a.3.3") (3us,7us,8us,6us) - |> Assert.areEqual (3us,7us,8us,6us) + fileVersion (fun _ -> Some "1.2a.3.3") (ILVersionInfo(3us,7us,8us,6us)) + |> Assert.areEqual (ILVersionInfo(3us,7us,8us,6us)) [] let ``should fallback to assemblyVersion if AssemblyFileVersionAttribute not set`` () = let findStringAttr n = n |> Assert.areEqual fileVersionAttrName; None; - fileVersion findStringAttr (1us,0us,0us,4us) |> Assert.areEqual (1us,0us,0us,4us) + fileVersion findStringAttr (ILVersionInfo(1us,0us,0us,4us)) |> Assert.areEqual (ILVersionInfo(1us,0us,0us,4us)) module ProductVersionTest = @@ -43,25 +43,25 @@ module ProductVersionTest = let ``should use AssemblyInformationalVersionAttribute if set`` () = let mutable args = [] let findStrAttr x = args <- List.append args [x]; Some "12.34.56.78" - productVersion findStrAttr (1us,0us,0us,6us) |> Assert.areEqual "12.34.56.78" + productVersion findStrAttr (ILVersionInfo(1us,0us,0us,6us)) |> Assert.areEqual "12.34.56.78" args |> Assert.areEqual [ informationalVersionAttrName ] [] let ``should fallback if AssemblyInformationalVersionAttribute is not a valid version`` () = - productVersion (fun _ -> Some "1.2.3-main (build #12)") (1us,0us,0us,6us) + productVersion (fun _ -> Some "1.2.3-main (build #12)") (ILVersionInfo(1us,0us,0us,6us)) |> Assert.areEqual "1.2.3-main (build #12)" [] let ``should fallback to fileVersion if AssemblyInformationalVersionAttribute not set or empty`` () = - productVersion (fun _ -> None) (3us,2us,1us,0us) |> Assert.areEqual "3.2.1.0" - productVersion (fun _ -> Some "") (3us,2us,1us,0us) |> Assert.areEqual "3.2.1.0" + productVersion (fun _ -> None) (ILVersionInfo(3us,2us,1us,0us)) |> Assert.areEqual "3.2.1.0" + productVersion (fun _ -> Some "") (ILVersionInfo(3us,2us,1us,0us)) |> Assert.areEqual "3.2.1.0" let validValues () = let max = System.UInt16.MaxValue - [ "1.2.3.4", (1us,2us,3us,4us) - "0.0.0.0", (0us,0us,0us,0us) - "3213.57843.32382.59493", (3213us,57843us,32382us,59493us) - (sprintf "%d.%d.%d.%d" max max max max), (max,max,max,max) ] + [ "1.2.3.4", ILVersionInfo(1us,2us,3us,4us) + "0.0.0.0", ILVersionInfo(0us,0us,0us,0us) + "3213.57843.32382.59493", ILVersionInfo(3213us,57843us,32382us,59493us) + (sprintf "%d.%d.%d.%d" max max max max), ILVersionInfo(max,max,max,max) ] [] let ``should use values if valid major.minor.revision.build version format`` () = @@ -69,17 +69,17 @@ module ProductVersionTest = v |> productVersionToILVersionInfo |> Assert.areEqual expected let invalidValues () = - [ "1.2.3.4", (1us,2us,3us,4us) - "1.2.3.4a", (1us,2us,3us,0us) - "1.2.c3.4", (1us,2us,0us,0us) - "1.2-d.3.4", (1us,0us,0us,0us) - "1dd.2.3.4", (0us,0us,0us,0us) - "1dd.2da.d3hj.dd4ds", (0us,0us,0us,0us) - "1.5.6.7.dasd", (1us,5us,6us,7us) - "9.3", (9us,3us,0us,0us) - "", (0us,0us,0us,0us) - "70000.80000.90000.100000", (0us,0us,0us,0us) - (sprintf "%d.70000.80000.90000" System.UInt16.MaxValue), (System.UInt16.MaxValue,0us,0us,0us) ] + [ "1.2.3.4", ILVersionInfo(1us,2us,3us,4us) + "1.2.3.4a", ILVersionInfo(1us,2us,3us,0us) + "1.2.c3.4", ILVersionInfo(1us,2us,0us,0us) + "1.2-d.3.4", ILVersionInfo(1us,0us,0us,0us) + "1dd.2.3.4", ILVersionInfo(0us,0us,0us,0us) + "1dd.2da.d3hj.dd4ds", ILVersionInfo(0us,0us,0us,0us) + "1.5.6.7.dasd", ILVersionInfo(1us,5us,6us,7us) + "9.3", ILVersionInfo(9us,3us,0us,0us) + "", ILVersionInfo(0us,0us,0us,0us) + "70000.80000.90000.100000", ILVersionInfo(0us,0us,0us,0us) + (sprintf "%d.70000.80000.90000" System.UInt16.MaxValue), ILVersionInfo(System.UInt16.MaxValue,0us,0us,0us) ] [] let ``should zero starting from first invalid version part`` () = From 2b46085333a5ce513f352dcd4611d507c640c66a Mon Sep 17 00:00:00 2001 From: Will Smith Date: Tue, 2 Apr 2019 19:11:06 -0700 Subject: [PATCH 03/17] When a solution becomes unloaded, we should clear F#'s cache (#6420) --- .../LanguageService/LanguageService.fs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index 426236543f7..da7ae84baf2 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -73,6 +73,33 @@ type internal FSharpCheckerWorkspaceServiceFactory member this.Checker = checkerProvider.Checker member this.FSharpProjectOptionsManager = projectInfoManager } +[] +type private FSharpSolutionEvents(projectManager: FSharpProjectOptionsManager) = + + interface IVsSolutionEvents with + + member __.OnAfterCloseSolution(_) = + projectManager.Checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() + VSConstants.S_OK + + member __.OnAfterLoadProject(_, _) = VSConstants.E_NOTIMPL + + member __.OnAfterOpenProject(_, _) = VSConstants.E_NOTIMPL + + member __.OnAfterOpenSolution(_, _) = VSConstants.E_NOTIMPL + + member __.OnBeforeCloseProject(_, _) = VSConstants.E_NOTIMPL + + member __.OnBeforeCloseSolution(_) = VSConstants.E_NOTIMPL + + member __.OnBeforeUnloadProject(_, _) = VSConstants.E_NOTIMPL + + member __.OnQueryCloseProject(_, _, _) = VSConstants.E_NOTIMPL + + member __.OnQueryCloseSolution(_, _) = VSConstants.E_NOTIMPL + + member __.OnQueryUnloadProject(_, _) = VSConstants.E_NOTIMPL + [, Microsoft.CodeAnalysis.Host.Mef.ServiceLayer.Default)>] type internal FSharpSettingsFactory [] (settings: EditorOptions) = @@ -143,6 +170,8 @@ type internal FSharpPackage() as this = vfsiToolWindow <- this.FindToolWindow(typeof, 0, true) :?> Microsoft.VisualStudio.FSharp.Interactive.FsiToolWindow vfsiToolWindow :> Microsoft.VisualStudio.FSharp.Interactive.ITestVFSI + let mutable solutionEventsOpt = None + // FSI-LINKAGE-POINT: unsited init do Microsoft.VisualStudio.FSharp.Interactive.Hooks.fsiConsoleWindowPackageCtorUnsited (this :> Package) @@ -165,9 +194,13 @@ type internal FSharpPackage() as this = let projectInfoManager = this.ComponentModel.DefaultExportProvider.GetExport().Value let solution = this.GetServiceAsync(typeof).Result let solution = solution :?> IVsSolution + let solutionEvents = FSharpSolutionEvents(projectInfoManager) let rdt = this.GetServiceAsync(typeof).Result let rdt = rdt :?> IVsRunningDocumentTable + solutionEventsOpt <- Some(solutionEvents) + solution.AdviseSolutionEvents(solutionEvents) |> ignore + let projectContextFactory = this.ComponentModel.GetService() let workspace = this.ComponentModel.GetService() let miscFilesWorkspace = this.ComponentModel.GetService() From 7c0c71f936c8ada83756f752797dec181c65bd1e Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Tue, 16 Apr 2019 13:58:48 -0700 Subject: [PATCH 04/17] Add Pinvoke support on coreclr (#6542) --- src/absil/ilreflect.fs | 49 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs index 67c7a88bf40..32ae496b158 100644 --- a/src/absil/ilreflect.fs +++ b/src/absil/ilreflect.fs @@ -1489,20 +1489,46 @@ let emitParameter cenv emEnv (defineParameter: int * ParameterAttributes * strin //---------------------------------------------------------------------------- // buildMethodPass2 //---------------------------------------------------------------------------- - + +#if !FX_RESHAPED_REFEMIT || NETCOREAPP3_0 + +let enablePInvoke = true + +#else + +// We currently build targeting netcoreapp2_1, and will continue to do so through this VS cycle +// but we can run on Netcoreapp3.0 so ... use reflection to invoke the api, when we are executing on netcoreapp3.0 +let definePInvokeMethod = + typeof.GetMethod("DefinePInvokeMethod", [| + typeof; + typeof; + typeof; + typeof; + typeof; + typeof; + typeof; + typeof; + typeof; + typeof; + typeof; + typeof; + typeof |]) + +let enablePInvoke = definePInvokeMethod <> null +#endif + let rec buildMethodPass2 cenv tref (typB: TypeBuilder) emEnv (mdef: ILMethodDef) = let attrs = mdef.Attributes let implflags = mdef.ImplAttributes let cconv = convCallConv mdef.CallingConv - let mref = mkRefToILMethod (tref, mdef) + let mref = mkRefToILMethod (tref, mdef) let emEnv = - if mdef.IsEntryPoint && isNil mdef.ParameterTypes then + if mdef.IsEntryPoint && isNil mdef.ParameterTypes then envAddEntryPt emEnv (typB, mdef.Name) else emEnv match mdef.Body.Contents with -#if !FX_RESHAPED_REFEMIT - | MethodBody.PInvoke p -> + | MethodBody.PInvoke p when enablePInvoke -> let argtys = convTypesToArray cenv emEnv mdef.ParameterTypes let rty = convType cenv emEnv mdef.Return.Type @@ -1524,10 +1550,19 @@ let rec buildMethodPass2 cenv tref (typB: TypeBuilder) emEnv (mdef: ILMethodDef) (* p.CharBestFit *) (* p.NoMangle *) - let methB = typB.DefinePInvokeMethod(mdef.Name, p.Where.Name, p.Name, attrs, cconv, rty, null, null, argtys, null, null, pcc, pcs) +#if !FX_RESHAPED_REFEMIT || NETCOREAPP3_0 + // DefinePInvokeMethod was removed in early versions of coreclr, it was added back in NETCORE_APP3_0. + // It has always been available in the desktop framework + let methB = typB.DefinePInvokeMethod(mdef.Name, p.Where.Name, p.Name, attrs, cconv, rty, null, null, argtys, null, null, pcc, pcs) +#else + // We currently build targeting netcoreapp2_1, and will continue to do so through this VS cycle + // but we can run on Netcoreapp3.0 so ... use reflection to invoke the api, when we are executing on netcoreapp3.0 + let methB = + System.Diagnostics.Debug.Assert(definePInvokeMethod <> null, "Runtime does not have DefinePInvokeMethod") // Absolutely can't happen + definePInvokeMethod.Invoke(typB, [| mdef.Name; p.Where.Name; p.Name; attrs; cconv; rty; null; null; argtys; null; null; pcc; pcs |]) :?> MethodBuilder +#endif methB.SetImplementationFlagsAndLog implflags envBindMethodRef emEnv mref methB -#endif | _ -> match mdef.Name with From af5b4eb5d46eb05f39c0fc943008b1ab2914d013 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 16 Apr 2019 21:59:43 +0100 Subject: [PATCH 05/17] Permit reduction of `Some` allocations for optional arguments (#6533) * Optimization of inlined code doesn't always reduce `Some` allocations for optional arguments * add codegen test * add baseline * Update OptionalArg01.fs --- src/fsharp/Optimizer.fs | 40 ++- src/fsharp/TastOps.fs | 4 + src/fsharp/TastOps.fsi | 4 + src/fsharp/TypeChecker.fs | 16 +- .../CodeGen/EmittedIL/Tuples/OptionalArg01.fs | 46 +++ .../EmittedIL/Tuples/OptionalArg01.il.bsl | 288 ++++++++++++++++++ .../Source/CodeGen/EmittedIL/Tuples/env.lst | 2 + 7 files changed, 382 insertions(+), 18 deletions(-) mode change 100755 => 100644 src/fsharp/TypeChecker.fs create mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/OptionalArg01.fs create mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/OptionalArg01.il.bsl diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index 1d5abb724e2..b94cedf9625 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -354,7 +354,8 @@ type OptimizationSettings = /// eliminate non-compiler generated immediate bindings member x.EliminateImmediatelyConsumedLocals() = x.localOpt () - /// expand "let x = (exp1, exp2, ...)" bind fields as prior tmps + /// expand "let x = (exp1, exp2, ...)" bindings as prior tmps + /// expand "let x = Some exp1" bindings as prior tmps member x.ExpandStructrualValues() = x.localOpt () type cenv = @@ -1552,6 +1553,8 @@ let rec CombineBoolLogic expr = // Similarly for other structural constructions, like records... // If the item is only projected from then the construction (allocation) can be eliminated. // This transform encourages that by allowing projections to be simplified. +// +// Apply the same to 'Some(x)' constructions //------------------------------------------------------------------------- let CanExpandStructuralBinding (v: Val) = @@ -1562,7 +1565,13 @@ let CanExpandStructuralBinding (v: Val) = let ExprIsValue = function Expr.Val _ -> true | _ -> false +let MakeStructuralBindingTemp (v: Val) i (arg: Expr) argTy = + let name = v.LogicalName + "_" + string i + let v, ve = mkCompGenLocal arg.Range name argTy + ve, mkCompGenBind v arg + let ExpandStructuralBindingRaw cenv expr = + assert cenv.settings.ExpandStructrualValues() match expr with | Expr.Let (TBind(v, rhs, tgtSeqPtOpt), body, m, _) when (isRefTupleExpr rhs && @@ -1572,19 +1581,16 @@ let ExpandStructuralBindingRaw cenv expr = expr (* avoid re-expanding when recursion hits original binding *) else let argTys = destRefTupleTy cenv.g v.Type - let argBind i (arg: Expr) argTy = - let name = v.LogicalName + "_" + string i - let v, ve = mkCompGenLocal arg.Range name argTy - ve, mkCompGenBind v arg - - let ves, binds = List.mapi2 argBind args argTys |> List.unzip + let ves, binds = List.mapi2 (MakeStructuralBindingTemp v) args argTys |> List.unzip let tuple = mkRefTupled cenv.g m ves argTys mkLetsBind m binds (mkLet tgtSeqPtOpt m v tuple body) | expr -> expr // Moves outer tuple binding inside near the tupled expression: -// let t = (let a0=v0 in let a1=v1 in ... in let an=vn in e0, e1, ..., em) in body -// let a0=v0 in let a1=v1 in ... in let an=vn in (let t = e0, e1, ..., em in body) +// let t = (let a0=v0 in let a1=v1 in ... in let an=vn in e0, e1, ..., em) in body +// becomes +// let a0=v0 in let a1=v1 in ... in let an=vn in (let t = e0, e1, ..., em in body) +// // This way ExpandStructuralBinding can replace expressions in constants, t is directly bound // to a tuple expression so that other optimizations such as OptimizeTupleFieldGet work, // and the tuple allocation can be eliminated. @@ -1600,6 +1606,7 @@ let rec RearrangeTupleBindings expr fin = | _ -> None let ExpandStructuralBinding cenv expr = + assert cenv.settings.ExpandStructrualValues() match expr with | Expr.Let (TBind(v, rhs, tgtSeqPtOpt), body, m, _) when (isRefTupleTy cenv.g v.Type && @@ -1608,7 +1615,20 @@ let ExpandStructuralBinding cenv expr = match RearrangeTupleBindings rhs (fun top -> mkLet tgtSeqPtOpt m v top body) with | Some e -> ExpandStructuralBindingRaw cenv e | None -> expr - | e -> ExpandStructuralBindingRaw cenv e + + // Expand 'let v = Some arg in ...' to 'let tmp = arg in let v = Some tp in ...' + // Used to give names to values of optional arguments prior as we inline. + | Expr.Let (TBind(v, Expr.Op(TOp.UnionCase uc, _, [arg], _), tgtSeqPtOpt), body, m, _) + when isOptionTy cenv.g v.Type && + not (ExprIsValue arg) && + cenv.g.unionCaseRefEq uc (mkSomeCase cenv.g) && + CanExpandStructuralBinding v -> + let argTy = destOptionTy cenv.g v.Type + let ve, bind = MakeStructuralBindingTemp v 0 arg argTy + let newExpr = mkSome cenv.g argTy ve m + mkLetBind m bind (mkLet tgtSeqPtOpt m v newExpr body) + | e -> + ExpandStructuralBindingRaw cenv e /// Detect a query { ... } let (|QueryRun|_|) g expr = diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 908a80d38d5..6e05af04b66 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -3143,6 +3143,10 @@ let destLinqExpressionTy g ty = let mkNoneCase (g: TcGlobals) = mkUnionCaseRef g.option_tcr_canon "None" let mkSomeCase (g: TcGlobals) = mkUnionCaseRef g.option_tcr_canon "Some" +let mkSome g ty arg m = mkUnionCaseExpr(mkSomeCase g, [ty], [arg], m) + +let mkNone g ty m = mkUnionCaseExpr(mkNoneCase g, [ty], [], m) + type ValRef with member vref.IsDispatchSlot = match vref.MemberInfo with diff --git a/src/fsharp/TastOps.fsi b/src/fsharp/TastOps.fsi index 3a414249059..bf944a4f597 100755 --- a/src/fsharp/TastOps.fsi +++ b/src/fsharp/TastOps.fsi @@ -1648,6 +1648,10 @@ val mkNil : TcGlobals -> range -> TType -> Expr val mkCons : TcGlobals -> TType -> Expr -> Expr -> Expr +val mkSome : TcGlobals -> TType -> Expr -> range -> Expr + +val mkNone: TcGlobals -> TType -> range -> Expr + //------------------------------------------------------------------------- // Make a few more expressions //------------------------------------------------------------------------- diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs old mode 100755 new mode 100644 index a9da25a5d29..3add36732fa --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -10164,16 +10164,16 @@ and TcMethodApplication match calledArg.CallerInfo, env.eCallerMemberName with | CallerLineNumber, _ when typeEquiv cenv.g calledNonOptTy cenv.g.int_ty -> - let lineExpr = Expr.Const (Const.Int32(mMethExpr.StartLine), mMethExpr, calledNonOptTy) - emptyPreBinder, mkUnionCaseExpr(mkSomeCase cenv.g, [calledNonOptTy], [lineExpr], mMethExpr) + let lineExpr = Expr.Const(Const.Int32 mMethExpr.StartLine, mMethExpr, calledNonOptTy) + emptyPreBinder, mkSome cenv.g calledNonOptTy lineExpr mMethExpr | CallerFilePath, _ when typeEquiv cenv.g calledNonOptTy cenv.g.string_ty -> - let filePathExpr = Expr.Const (Const.String(FileSystem.GetFullPathShim(mMethExpr.FileName)), mMethExpr, calledNonOptTy) - emptyPreBinder, mkUnionCaseExpr(mkSomeCase cenv.g, [calledNonOptTy], [filePathExpr], mMethExpr) - | CallerMemberName, Some callerName when typeEquiv cenv.g calledNonOptTy cenv.g.string_ty -> + let filePathExpr = Expr.Const (Const.String (FileSystem.GetFullPathShim(mMethExpr.FileName)), mMethExpr, calledNonOptTy) + emptyPreBinder, mkSome cenv.g calledNonOptTy filePathExpr mMethExpr + | CallerMemberName, Some(callerName) when typeEquiv cenv.g calledNonOptTy cenv.g.string_ty -> let memberNameExpr = Expr.Const (Const.String callerName, mMethExpr, calledNonOptTy) - emptyPreBinder, mkUnionCaseExpr(mkSomeCase cenv.g, [calledNonOptTy], [memberNameExpr], mMethExpr) + emptyPreBinder, mkSome cenv.g calledNonOptTy memberNameExpr mMethExpr | _ -> - emptyPreBinder, mkUnionCaseExpr(mkNoneCase cenv.g, [calledNonOptTy], [], mMethExpr) + emptyPreBinder, mkNone cenv.g calledNonOptTy mMethExpr // Combine the variable allocators (if any) let wrapper = (wrapper >> wrapper2) @@ -10207,7 +10207,7 @@ and TcMethodApplication let calledArgTy = assignedArg.CalledArg.CalledArgumentType if isOptionTy cenv.g calledArgTy then let calledNonOptTy = destOptionTy cenv.g calledArgTy - mkUnionCaseExpr(mkSomeCase cenv.g, [calledNonOptTy], [mkCoerceIfNeeded cenv.g calledNonOptTy callerArgTy expr], m) + mkSome cenv.g calledNonOptTy (mkCoerceIfNeeded cenv.g calledNonOptTy callerArgTy expr) m else expr // should be unreachable diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/OptionalArg01.fs b/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/OptionalArg01.fs new file mode 100644 index 00000000000..05e33058136 --- /dev/null +++ b/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/OptionalArg01.fs @@ -0,0 +1,46 @@ +// #NoMono #NoMT #CodeGen #EmittedIL #Tuples +type A() = class end + +// A code+optimization pattern, see https://github.com/Microsoft/visualfsharp/issues/6532 +type C() = + static member inline F (?x1: A, ?x2: A) = + let count = 0 + let count = match x1 with None -> count | Some _ -> count + 1 + let count = match x2 with None -> count | Some _ -> count + 1 + let attribs = ResizeArray<_>(count) + match x1 with None -> () | Some v1 -> attribs.Add(v1) + match x2 with None -> () | Some v2 -> attribs.Add(v2) + attribs + +//Expect rough equivalent of: +// let d = ResizeArray<_>(0) +// d +let test() = + C.F () + +//Expect rough equivalent of: +// let x1 = A() +// let d = ResizeArray<_>(1) +// d.Add(x1) +// d +let test2() = + C.F (x1=A()) + +//Expect rough equivalent of: +// let x2 = A() +// let d = ResizeArray<_>(1) +// d.Add(x2) +// d +let test3() = + C.F (x2=A()) + +//Expect rough equivalent of: +// let x1 = A() +// let x2 = A() +// let d = ResizeArray<_>(2) +// d.Add(x1) +// d.Add(x2) +// d +let test4() = + C.F (x1=A(), x2=A()) + diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/OptionalArg01.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/OptionalArg01.il.bsl new file mode 100644 index 00000000000..4474ab67ae3 --- /dev/null +++ b/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/OptionalArg01.il.bsl @@ -0,0 +1,288 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.7.3081.0 +// Copyright (c) Microsoft Corporation. All rights reserved. + + + +// Metadata version: v4.0.30319 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 4:0:0:0 +} +.assembly extern FSharp.Core +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: + .ver 4:6:0:0 +} +.assembly OptionalArg01 +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + // --- The following custom attribute is added automatically, do not uncomment ------- + // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 01 00 00 00 00 00 ) + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.mresource public FSharpSignatureData.OptionalArg01 +{ + // Offset: 0x00000000 Length: 0x00000466 +} +.mresource public FSharpOptimizationData.OptionalArg01 +{ + // Offset: 0x00000470 Length: 0x00000445 +} +.module OptionalArg01.exe +// MVID: {5CB489E1-4F48-B5AF-A745-0383E189B45C} +.imagebase 0x00400000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY +// Image base: 0x067B0000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public abstract auto ansi sealed OptionalArg01 + extends [mscorlib]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public A + extends [mscorlib]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 9 (0x9) + .maxstack 8 + .language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}' + .line 16707566,16707566 : 0,0 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\source\\CodeGen\\EmittedIL\\Tuples\\OptionalArg01.fs' + IL_0000: ldarg.0 + IL_0001: callvirt instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + .line 2,2 : 6,7 '' + IL_0008: ret + } // end of method A::.ctor + + } // end of class A + + .class auto ansi serializable nested public C + extends [mscorlib]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 9 (0x9) + .maxstack 8 + .line 16707566,16707566 : 0,0 '' + IL_0000: ldarg.0 + IL_0001: callvirt instance void [mscorlib]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + .line 5,5 : 6,7 '' + IL_0008: ret + } // end of method C::.ctor + + .method public static class [mscorlib]System.Collections.Generic.List`1 + F(class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 x1, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 x2) cil managed + { + .param [1] + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.OptionalArgumentAttribute::.ctor() = ( 01 00 00 00 ) + .param [2] + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.OptionalArgumentAttribute::.ctor() = ( 01 00 00 00 ) + // Code size 83 (0x53) + .maxstack 4 + .locals init ([0] int32 count, + [1] int32 V_1, + [2] class [mscorlib]System.Collections.Generic.List`1 attribs, + [3] class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_3, + [4] class OptionalArg01/A v2) + .line 10,10 : 9,44 '' + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0007 + + .line 8,8 : 61,70 '' + IL_0003: ldc.i4.1 + .line 16707566,16707566 : 0,0 '' + IL_0004: nop + IL_0005: br.s IL_0009 + + .line 8,8 : 43,48 '' + IL_0007: ldc.i4.0 + .line 16707566,16707566 : 0,0 '' + IL_0008: nop + .line 16707566,16707566 : 0,0 '' + IL_0009: stloc.0 + .line 10,10 : 9,44 '' + IL_000a: ldarg.1 + IL_000b: brfalse.s IL_0013 + + .line 9,9 : 61,70 '' + IL_000d: ldloc.0 + IL_000e: ldc.i4.1 + IL_000f: add + .line 16707566,16707566 : 0,0 '' + IL_0010: nop + IL_0011: br.s IL_0015 + + .line 9,9 : 43,48 '' + IL_0013: ldloc.0 + .line 16707566,16707566 : 0,0 '' + IL_0014: nop + .line 16707566,16707566 : 0,0 '' + IL_0015: stloc.1 + .line 10,10 : 9,44 '' + IL_0016: ldloc.1 + IL_0017: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor(int32) + IL_001c: stloc.2 + IL_001d: ldarg.0 + IL_001e: brfalse.s IL_0035 + + IL_0020: ldarg.0 + IL_0021: stloc.3 + IL_0022: ldloc.3 + IL_0023: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() + IL_0028: stloc.s v2 + .line 11,11 : 47,62 '' + IL_002a: ldloc.2 + IL_002b: ldloc.s v2 + IL_002d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + .line 16707566,16707566 : 0,0 '' + IL_0032: nop + IL_0033: br.s IL_0037 + + .line 11,11 : 31,33 '' + IL_0035: nop + .line 16707566,16707566 : 0,0 '' + IL_0036: nop + IL_0037: ldarg.1 + IL_0038: brfalse.s IL_004f + + IL_003a: ldarg.1 + IL_003b: stloc.3 + IL_003c: ldloc.3 + IL_003d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() + IL_0042: stloc.s v2 + .line 12,12 : 47,62 '' + IL_0044: ldloc.2 + IL_0045: ldloc.s v2 + IL_0047: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + .line 16707566,16707566 : 0,0 '' + IL_004c: nop + IL_004d: br.s IL_0051 + + .line 12,12 : 31,33 '' + IL_004f: nop + .line 16707566,16707566 : 0,0 '' + IL_0050: nop + .line 13,13 : 9,16 '' + IL_0051: ldloc.2 + IL_0052: ret + } // end of method C::F + + } // end of class C + + .method public static class [mscorlib]System.Collections.Generic.List`1 + test() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + .line 19,19 : 5,11 '' + IL_0000: ldc.i4.0 + IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor(int32) + IL_0006: ret + } // end of method OptionalArg01::test + + .method public static class [mscorlib]System.Collections.Generic.List`1 + test2() cil managed + { + // Code size 22 (0x16) + .maxstack 4 + .locals init ([0] class OptionalArg01/A V_0, + [1] class [mscorlib]System.Collections.Generic.List`1 V_1) + .line 27,27 : 5,17 '' + IL_0000: newobj instance void OptionalArg01/A::.ctor() + IL_0005: stloc.0 + IL_0006: ldc.i4.1 + IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor(int32) + IL_000c: stloc.1 + IL_000d: ldloc.1 + IL_000e: ldloc.0 + IL_000f: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0014: ldloc.1 + IL_0015: ret + } // end of method OptionalArg01::test2 + + .method public static class [mscorlib]System.Collections.Generic.List`1 + test3() cil managed + { + // Code size 22 (0x16) + .maxstack 4 + .locals init ([0] class OptionalArg01/A V_0, + [1] class [mscorlib]System.Collections.Generic.List`1 V_1) + .line 35,35 : 5,17 '' + IL_0000: newobj instance void OptionalArg01/A::.ctor() + IL_0005: stloc.0 + IL_0006: ldc.i4.1 + IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor(int32) + IL_000c: stloc.1 + IL_000d: ldloc.1 + IL_000e: ldloc.0 + IL_000f: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0014: ldloc.1 + IL_0015: ret + } // end of method OptionalArg01::test3 + + .method public static class [mscorlib]System.Collections.Generic.List`1 + test4() cil managed + { + // Code size 35 (0x23) + .maxstack 4 + .locals init ([0] class OptionalArg01/A V_0, + [1] class OptionalArg01/A V_1, + [2] class [mscorlib]System.Collections.Generic.List`1 V_2) + .line 45,45 : 5,25 '' + IL_0000: newobj instance void OptionalArg01/A::.ctor() + IL_0005: stloc.0 + IL_0006: newobj instance void OptionalArg01/A::.ctor() + IL_000b: stloc.1 + IL_000c: ldc.i4.2 + IL_000d: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor(int32) + IL_0012: stloc.2 + IL_0013: ldloc.2 + IL_0014: ldloc.0 + IL_0015: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_001a: ldloc.2 + IL_001b: ldloc.1 + IL_001c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0021: ldloc.2 + IL_0022: ret + } // end of method OptionalArg01::test4 + +} // end of class OptionalArg01 + +.class private abstract auto ansi sealed ''.$OptionalArg01 + extends [mscorlib]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method $OptionalArg01::main@ + +} // end of class ''.$OptionalArg01 + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/env.lst b/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/env.lst index 4b444e3886b..76a724c4a55 100644 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/env.lst +++ b/tests/fsharpqa/Source/CodeGen/EmittedIL/Tuples/env.lst @@ -7,6 +7,8 @@ SOURCE=Tuple07.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Tuple07.exe" # Tuple07.fs - SOURCE=Tuple08.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Tuple08.exe" # Tuple08.fs - + SOURCE=OptionalArg01.fs SCFLAGS="-g --optimize+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd OptionalArg01.exe" # OptionalArg01.fs - test optimizatons + SOURCE=TupleMonster.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd TupleMonster.exe" # TupleMonster.fs - SOURCE=TupleElimination.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd TupleElimination.exe" # TupleElimination.fs - From 0d18903bed3242af7285bf1a7451babc59f5deb2 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Tue, 16 Apr 2019 14:15:31 -0700 Subject: [PATCH 06/17] ensure all setup packages use the same version (#6556) --- setup/Swix/Directory.Build.props | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup/Swix/Directory.Build.props b/setup/Swix/Directory.Build.props index 772bd04080a..0a9e6f4ecc5 100644 --- a/setup/Swix/Directory.Build.props +++ b/setup/Swix/Directory.Build.props @@ -1,13 +1,17 @@ - - + true Microsoft.FSharp neutral false vsix true + + + + + $(ArtifactsBinDir) From ed387e0bc9dbf91cb0a189e2a803b4d52f6924e7 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Tue, 16 Apr 2019 15:18:31 -0700 Subject: [PATCH 07/17] Will's fix (#6559) --- tests/fsharp/Compiler/CompilerAssert.fs | 115 ++++++++++++------------ 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index 75874b41baa..37946c40872 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -47,68 +47,73 @@ module CompilerAssert = ExtraProjectInfo = None Stamp = None } + + let lockObj = obj () let Pass (source: string) = - let parseResults, fileAnswer = checker.ParseAndCheckFileInProject("test.fs", 0, SourceText.ofString source, defaultProjectOptions) |> Async.RunSynchronously + lock lockObj <| fun () -> + let parseResults, fileAnswer = checker.ParseAndCheckFileInProject("test.fs", 0, SourceText.ofString source, defaultProjectOptions) |> Async.RunSynchronously - Assert.True(parseResults.Errors.Length = 0, sprintf "Parse errors: %A" parseResults.Errors) + Assert.True(parseResults.Errors.Length = 0, sprintf "Parse errors: %A" parseResults.Errors) - match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") - | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> + match fileAnswer with + | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") + | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> - Assert.True(typeCheckResults.Errors.Length = 0, sprintf "Type Check errors: %A" typeCheckResults.Errors) + Assert.True(typeCheckResults.Errors.Length = 0, sprintf "Type Check errors: %A" typeCheckResults.Errors) let TypeCheckSingleError (source: string) (expectedErrorNumber: int) (expectedErrorRange: int * int * int * int) (expectedErrorMsg: string) = - let parseResults, fileAnswer = checker.ParseAndCheckFileInProject("test.fs", 0, SourceText.ofString source, defaultProjectOptions) |> Async.RunSynchronously - - Assert.True(parseResults.Errors.Length = 0, sprintf "Parse errors: %A" parseResults.Errors) - - match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") - | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> - - Assert.True(typeCheckResults.Errors.Length = 1, sprintf "Expected one type check error: %A" typeCheckResults.Errors) - typeCheckResults.Errors - |> Array.iter (fun info -> - Assert.AreEqual(FSharpErrorSeverity.Error, info.Severity) - Assert.AreEqual(expectedErrorNumber, info.ErrorNumber, "expectedErrorNumber") - Assert.AreEqual(expectedErrorRange, (info.StartLineAlternate, info.StartColumn, info.EndLineAlternate, info.EndColumn), "expectedErrorRange") - Assert.AreEqual(expectedErrorMsg, info.Message, "expectedErrorMsg") - ) + lock lockObj <| fun () -> + let parseResults, fileAnswer = checker.ParseAndCheckFileInProject("test.fs", 0, SourceText.ofString source, defaultProjectOptions) |> Async.RunSynchronously + + Assert.True(parseResults.Errors.Length = 0, sprintf "Parse errors: %A" parseResults.Errors) + + match fileAnswer with + | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") + | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> + + Assert.True(typeCheckResults.Errors.Length = 1, sprintf "Expected one type check error: %A" typeCheckResults.Errors) + typeCheckResults.Errors + |> Array.iter (fun info -> + Assert.AreEqual(FSharpErrorSeverity.Error, info.Severity) + Assert.AreEqual(expectedErrorNumber, info.ErrorNumber, "expectedErrorNumber") + Assert.AreEqual(expectedErrorRange, (info.StartLineAlternate, info.StartColumn, info.EndLineAlternate, info.EndColumn), "expectedErrorRange") + Assert.AreEqual(expectedErrorMsg, info.Message, "expectedErrorMsg") + ) let RunScript (source: string) (expectedErrorMessages: string list) = - // Intialize output and input streams - use inStream = new StringReader("") - use outStream = new StringWriter() - use errStream = new StringWriter() - - // Build command line arguments & start FSI session - let argv = [| "C:\\fsi.exe" |] -#if !NETCOREAPP - let allArgs = Array.append argv [|"--noninteractive"|] -#else - let allArgs = Array.append argv [|"--noninteractive"; "--targetprofile:netcore"|] -#endif - - let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration() - use fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outStream, errStream, collectible = true) - - let ch, errors = fsiSession.EvalInteractionNonThrowing source - - let errorMessages = ResizeArray() - errors - |> Seq.iter (fun error -> errorMessages.Add(error.Message)) - - match ch with - | Choice2Of2 ex -> errorMessages.Add(ex.Message) - | _ -> () - - if expectedErrorMessages.Length <> errorMessages.Count then - Assert.Fail(sprintf "Expected error messages: %A \n\n Actual error messages: %A" expectedErrorMessages errorMessages) - else - (expectedErrorMessages, errorMessages) - ||> Seq.iter2 (fun expectedErrorMessage errorMessage -> - Assert.AreEqual(expectedErrorMessage, errorMessage) - ) + lock lockObj <| fun () -> + // Intialize output and input streams + use inStream = new StringReader("") + use outStream = new StringWriter() + use errStream = new StringWriter() + + // Build command line arguments & start FSI session + let argv = [| "C:\\fsi.exe" |] + #if !NETCOREAPP + let allArgs = Array.append argv [|"--noninteractive"|] + #else + let allArgs = Array.append argv [|"--noninteractive"; "--targetprofile:netcore"|] + #endif + + let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration() + use fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outStream, errStream, collectible = true) + + let ch, errors = fsiSession.EvalInteractionNonThrowing source + + let errorMessages = ResizeArray() + errors + |> Seq.iter (fun error -> errorMessages.Add(error.Message)) + + match ch with + | Choice2Of2 ex -> errorMessages.Add(ex.Message) + | _ -> () + + if expectedErrorMessages.Length <> errorMessages.Count then + Assert.Fail(sprintf "Expected error messages: %A \n\n Actual error messages: %A" expectedErrorMessages errorMessages) + else + (expectedErrorMessages, errorMessages) + ||> Seq.iter2 (fun expectedErrorMessage errorMessage -> + Assert.AreEqual(expectedErrorMessage, errorMessage) + ) \ No newline at end of file From 7fa61b7950fa86f66ce78e45be4f4b0364573227 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Wed, 17 Apr 2019 12:35:59 +0000 Subject: [PATCH 08/17] [master] Update dependencies from dotnet/arcade (#6510) * Update dependencies from https://github.com/dotnet/arcade build 20190411.2 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19211.2 * Update dependencies from https://github.com/dotnet/arcade build 20190412.2 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19212.2 * Update dependencies from https://github.com/dotnet/arcade build 20190413.2 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19213.2 * Update dependencies from https://github.com/dotnet/arcade build 20190414.2 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19214.2 * Update dependencies from https://github.com/dotnet/arcade build 20190415.12 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19215.12 --- eng/Version.Details.xml | 4 +- eng/common/CheckSymbols.ps1 | 134 +++++++++++++++++++++++++++++++ eng/common/internal/Tools.csproj | 8 +- global.json | 2 +- 4 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 eng/common/CheckSymbols.ps1 diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 5b6886348af..a0cf73a0fc8 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 4f645e4a5385eb96cad3f72f5ded239761c7d075 + 517bf671ea342965d007aa48f5bfd4926e58d582 diff --git a/eng/common/CheckSymbols.ps1 b/eng/common/CheckSymbols.ps1 new file mode 100644 index 00000000000..074b423245c --- /dev/null +++ b/eng/common/CheckSymbols.ps1 @@ -0,0 +1,134 @@ +param( + [Parameter(Mandatory=$true)][string] $InputPath, # Full path to directory where NuGet packages to be checked are stored + [Parameter(Mandatory=$true)][string] $ExtractPath, # Full path to directory where the packages will be extracted during validation + [Parameter(Mandatory=$true)][string] $SymbolToolPath # Full path to directory where dotnet symbol-tool was installed +) + +Add-Type -AssemblyName System.IO.Compression.FileSystem + +function FirstMatchingSymbolDescriptionOrDefault { + param( + [string] $FullPath, # Full path to the module that has to be checked + [string] $TargetServerParam # Parameter to pass to `Symbol Tool` indicating the server to lookup for symbols + ) + + $FileName = [System.IO.Path]::GetFileName($FullPath) + $Extension = [System.IO.Path]::GetExtension($FullPath) + + # Those below are potential symbol files that the `dotnet symbol` might + # return. Which one will be returned depend on the type of file we are + # checking and which type of file was uploaded. + + # The file itself is returned + $SymbolPath = $SymbolsPath + "\" + $FileName + + # PDB file for the module + $PdbPath = $SymbolPath.Replace($Extension, ".pdb") + + # PDB file for R2R module (created by crossgen) + $NGenPdb = $SymbolPath.Replace($Extension, ".ni.pdb") + + # DBG file for a .so library + $SODbg = $SymbolPath.Replace($Extension, ".so.dbg") + + # DWARF file for a .dylib + $DylibDwarf = $SymbolPath.Replace($Extension, ".dylib.dwarf") + + .\dotnet-symbol.exe --symbols --modules $TargetServerParam $FullPath -o $SymbolsPath -d | Out-Null + + if (Test-Path $PdbPath) { + return "PDB" + } + elseif (Test-Path $NGenPdb) { + return "NGen PDB" + } + elseif (Test-Path $SODbg) { + return "DBG for SO" + } + elseif (Test-Path $DylibDwarf) { + return "Dwarf for Dylib" + } + elseif (Test-Path $SymbolPath) { + return "Module" + } + else { + return $null + } +} + +function CountMissingSymbols { + param( + [string] $PackagePath # Path to a NuGet package + ) + + # Ensure input file exist + if (!(Test-Path $PackagePath)) { + throw "Input file does not exist: $PackagePath" + } + + # Extensions for which we'll look for symbols + $RelevantExtensions = @(".dll", ".exe", ".so", ".dylib") + + # How many files are missing symbol information + $MissingSymbols = 0 + + $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) + $ExtractPath = $ExtractPath + $PackageId; + $SymbolsPath = $ExtractPath + $PackageId + ".Symbols"; + + [System.IO.Compression.ZipFile]::ExtractToDirectory($PackagePath, $ExtractPath) + + # Makes easier to reference `symbol tool` + Push-Location $SymbolToolPath + + Get-ChildItem -Recurse $ExtractPath | + Where-Object {$RelevantExtensions -contains $_.Extension} | + ForEach-Object { + Write-Host -NoNewLine "`t Checking file" $_.FullName "... " + + $SymbolsOnMSDL = FirstMatchingSymbolDescriptionOrDefault $_.FullName "--microsoft-symbol-server" + $SymbolsOnSymWeb = FirstMatchingSymbolDescriptionOrDefault $_.FullName "--internal-server" + + if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null) { + Write-Host "Symbols found on MSDL (" $SymbolsOnMSDL ") and SymWeb (" $SymbolsOnSymWeb ")" + } + else { + $MissingSymbols++ + + if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null) { + Write-Host "No symbols found on MSDL or SymWeb!" + } + else { + if ($SymbolsOnMSDL -eq $null) { + Write-Host "No symbols found on MSDL!" + } + else { + Write-Host "No symbols found on SymWeb!" + } + } + } + } + + Pop-Location + + return $MissingSymbols +} + +function CheckSymbolsAvailable { + if (Test-Path $ExtractPath) { + Remove-Item -recurse $ExtractPath + } + + Get-ChildItem "$InputPath\*.nupkg" | + ForEach-Object { + $FileName = $_.Name + Write-Host "Validating $FileName " + $Status = CountMissingSymbols "$InputPath\$FileName" + + if ($Status -ne 0) { + Write-Error "Missing symbols for $Status modules in the package $FileName" + } + } +} + +CheckSymbolsAvailable diff --git a/eng/common/internal/Tools.csproj b/eng/common/internal/Tools.csproj index 1a81ff906f6..1a39a7ef3f6 100644 --- a/eng/common/internal/Tools.csproj +++ b/eng/common/internal/Tools.csproj @@ -12,8 +12,12 @@ - - https://devdiv.pkgs.visualstudio.com/_packaging/8f470c7e-ac49-4afe-a6ee-cf784e438b93/nuget/v3/index.json; + + + https://devdiv.pkgs.visualstudio.com/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json; + + + $(RestoreSources); https://devdiv.pkgs.visualstudio.com/_packaging/VS/nuget/v3/index.json; diff --git a/global.json b/global.json index 1cee890932f..a246404283e 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19210.7", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19215.12", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From e130d25e186b7e41b49debe7c093f1a46a44637a Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Wed, 17 Apr 2019 14:59:39 -0700 Subject: [PATCH 09/17] fix vsix dependency version calculations (#6565) --- vsintegration/Vsix/Directory.Build.targets | 8 ++++++++ .../Vsix/VisualFSharpFull/Source.extension.vsixmanifest | 2 +- .../Vsix/VisualFSharpFull/VisualFSharpFull.csproj | 2 -- .../VisualFSharpTemplates/Source.extension.vsixmanifest | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 vsintegration/Vsix/Directory.Build.targets diff --git a/vsintegration/Vsix/Directory.Build.targets b/vsintegration/Vsix/Directory.Build.targets new file mode 100644 index 00000000000..1e484fa50ea --- /dev/null +++ b/vsintegration/Vsix/Directory.Build.targets @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/vsintegration/Vsix/VisualFSharpFull/Source.extension.vsixmanifest b/vsintegration/Vsix/VisualFSharpFull/Source.extension.vsixmanifest index e0ef01b0061..075855a0614 100644 --- a/vsintegration/Vsix/VisualFSharpFull/Source.extension.vsixmanifest +++ b/vsintegration/Vsix/VisualFSharpFull/Source.extension.vsixmanifest @@ -9,7 +9,7 @@ https://docs.microsoft.com/en-us/dotnet/articles/fsharp/ - + diff --git a/vsintegration/Vsix/VisualFSharpFull/VisualFSharpFull.csproj b/vsintegration/Vsix/VisualFSharpFull/VisualFSharpFull.csproj index 38b286c8c45..f5aad374baa 100644 --- a/vsintegration/Vsix/VisualFSharpFull/VisualFSharpFull.csproj +++ b/vsintegration/Vsix/VisualFSharpFull/VisualFSharpFull.csproj @@ -263,6 +263,4 @@ - - diff --git a/vsintegration/Vsix/VisualFSharpTemplates/Source.extension.vsixmanifest b/vsintegration/Vsix/VisualFSharpTemplates/Source.extension.vsixmanifest index 628e678cdcd..4b0a45a6e94 100644 --- a/vsintegration/Vsix/VisualFSharpTemplates/Source.extension.vsixmanifest +++ b/vsintegration/Vsix/VisualFSharpTemplates/Source.extension.vsixmanifest @@ -10,7 +10,7 @@ https://docs.microsoft.com/en-us/dotnet/articles/fsharp/ - + @@ -21,7 +21,7 @@ - + From 290fd3cef088d21c52ad2e7f1ccd7e27f7dc0bc3 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Wed, 17 Apr 2019 22:00:03 +0000 Subject: [PATCH 10/17] Update dependencies from https://github.com/dotnet/arcade build 20190417.1 (#6564) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19217.1 --- eng/Version.Details.xml | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index a0cf73a0fc8..f7bc5720dee 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 517bf671ea342965d007aa48f5bfd4926e58d582 + 4e21d52dabbb9f5705a90f097acb1465a0354c0d diff --git a/global.json b/global.json index a246404283e..fec974408a0 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19215.12", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19217.1", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From 983e16264f639e41e118fecfa59012837d1674e5 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Thu, 18 Apr 2019 17:07:20 +0000 Subject: [PATCH 11/17] Update dependencies from https://github.com/dotnet/arcade build 20190418.1 (#6571) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19218.1 --- eng/Version.Details.xml | 4 ++-- eng/common/CheckSymbols.ps1 | 44 ++++++++++++++++++++++++++++--------- global.json | 2 +- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index f7bc5720dee..accc00e5562 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 4e21d52dabbb9f5705a90f097acb1465a0354c0d + 46718d98c0fd03690a6a8c83da692a4a85a17902 diff --git a/eng/common/CheckSymbols.ps1 b/eng/common/CheckSymbols.ps1 index 074b423245c..b8d84607b89 100644 --- a/eng/common/CheckSymbols.ps1 +++ b/eng/common/CheckSymbols.ps1 @@ -9,7 +9,8 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem function FirstMatchingSymbolDescriptionOrDefault { param( [string] $FullPath, # Full path to the module that has to be checked - [string] $TargetServerParam # Parameter to pass to `Symbol Tool` indicating the server to lookup for symbols + [string] $TargetServerParam, # Parameter to pass to `Symbol Tool` indicating the server to lookup for symbols + [string] $SymbolsPath ) $FileName = [System.IO.Path]::GetFileName($FullPath) @@ -33,9 +34,9 @@ function FirstMatchingSymbolDescriptionOrDefault { # DWARF file for a .dylib $DylibDwarf = $SymbolPath.Replace($Extension, ".dylib.dwarf") - - .\dotnet-symbol.exe --symbols --modules $TargetServerParam $FullPath -o $SymbolsPath -d | Out-Null - + + .\dotnet-symbol.exe --symbols --modules --windows-pdbs $TargetServerParam $FullPath -o $SymbolsPath | Out-Null + if (Test-Path $PdbPath) { return "PDB" } @@ -73,8 +74,9 @@ function CountMissingSymbols { $MissingSymbols = 0 $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) - $ExtractPath = $ExtractPath + $PackageId; - $SymbolsPath = $ExtractPath + $PackageId + ".Symbols"; + $PackageGuid = New-Guid + $ExtractPath = Join-Path -Path $ExtractPath -ChildPath $PackageGuid + $SymbolsPath = Join-Path -Path $ExtractPath -ChildPath "Symbols" [System.IO.Compression.ZipFile]::ExtractToDirectory($PackagePath, $ExtractPath) @@ -84,10 +86,15 @@ function CountMissingSymbols { Get-ChildItem -Recurse $ExtractPath | Where-Object {$RelevantExtensions -contains $_.Extension} | ForEach-Object { - Write-Host -NoNewLine "`t Checking file" $_.FullName "... " + if ($_.FullName -Match "\\ref\\") { + Write-Host "`t Ignoring reference assembly file" $_.FullName + return + } - $SymbolsOnMSDL = FirstMatchingSymbolDescriptionOrDefault $_.FullName "--microsoft-symbol-server" - $SymbolsOnSymWeb = FirstMatchingSymbolDescriptionOrDefault $_.FullName "--internal-server" + $SymbolsOnMSDL = FirstMatchingSymbolDescriptionOrDefault $_.FullName "--microsoft-symbol-server" $SymbolsPath + $SymbolsOnSymWeb = FirstMatchingSymbolDescriptionOrDefault $_.FullName "--internal-server" $SymbolsPath + + Write-Host -NoNewLine "`t Checking file" $_.FullName "... " if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null) { Write-Host "Symbols found on MSDL (" $SymbolsOnMSDL ") and SymWeb (" $SymbolsOnSymWeb ")" @@ -116,18 +123,35 @@ function CountMissingSymbols { function CheckSymbolsAvailable { if (Test-Path $ExtractPath) { - Remove-Item -recurse $ExtractPath + Remove-Item $ExtractPath -Force -Recurse -ErrorAction SilentlyContinue } Get-ChildItem "$InputPath\*.nupkg" | ForEach-Object { $FileName = $_.Name + + # These packages from Arcade-Services include some native libraries that + # our current symbol uploader can't handle. Below is a workaround until + # we get issue: https://github.com/dotnet/arcade/issues/2457 sorted. + if ($FileName -Match "Microsoft\.DotNet\.Darc\.") { + Write-Host "Ignoring Arcade-services file: $FileName" + Write-Host + return + } + elseif ($FileName -Match "Microsoft\.DotNet\.Maestro\.Tasks\.") { + Write-Host "Ignoring Arcade-services file: $FileName" + Write-Host + return + } + Write-Host "Validating $FileName " $Status = CountMissingSymbols "$InputPath\$FileName" if ($Status -ne 0) { Write-Error "Missing symbols for $Status modules in the package $FileName" } + + Write-Host } } diff --git a/global.json b/global.json index fec974408a0..cd0f7712fcc 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19217.1", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19218.1", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From b818aa0843f9923b5bab5d6f60018d3224733150 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Thu, 18 Apr 2019 12:25:46 -0700 Subject: [PATCH 12/17] Fixed benchmark solution and added project type check test (#6566) * Trying to build benchmarks * Benchmark testing 100 referenced projects in the compiler service * Fixed project reference bit * Change stamp * Fixed build --- .../CompilerServiceBenchmarks/Program.fs | 151 ++++++++++++++++-- benchmarks/Directory.Build.props | 3 - benchmarks/Directory.Build.targets | 3 - 3 files changed, 134 insertions(+), 23 deletions(-) delete mode 100644 benchmarks/Directory.Build.props delete mode 100644 benchmarks/Directory.Build.targets diff --git a/benchmarks/CompilerServiceBenchmarks/Program.fs b/benchmarks/CompilerServiceBenchmarks/Program.fs index 386d8d95fb5..201856e3f98 100644 --- a/benchmarks/CompilerServiceBenchmarks/Program.fs +++ b/benchmarks/CompilerServiceBenchmarks/Program.fs @@ -7,7 +7,7 @@ open FSharp.Compiler.Text open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.ILBinaryReader -open CodeAnalysis.Text +open Microsoft.CodeAnalysis.Text open BenchmarkDotNet.Attributes open BenchmarkDotNet.Running @@ -80,6 +80,49 @@ type SourceText with member this.ToFSharpSourceText() = SourceText.weakTable.GetValue(this, Runtime.CompilerServices.ConditionalWeakTable<_,_>.CreateValueCallback(SourceText.create)) +[] +module Helpers = + + let createProject name referencedProjects = + let tmpPath = Path.GetTempPath() + let file = Path.Combine(tmpPath, Path.ChangeExtension(name, ".fs")) + { + ProjectFileName = Path.Combine(tmpPath, Path.ChangeExtension(name, ".dll")) + ProjectId = None + SourceFiles = [|file|] + OtherOptions = + Array.append [|"--optimize+"; "--target:library" |] (referencedProjects |> Array.ofList |> Array.map (fun x -> "-r:" + x.ProjectFileName)) + ReferencedProjects = + referencedProjects + |> List.map (fun x -> (x.ProjectFileName, x)) + |> Array.ofList + IsIncompleteTypeCheckEnvironment = false + UseScriptResolutionRules = false + LoadTime = DateTime() + UnresolvedReferences = None + OriginalLoadReferences = [] + ExtraProjectInfo = None + Stamp = Some 0L (* set the stamp to 0L on each run so we don't evaluate the whole project again *) + } + + let generateSourceCode moduleName = + sprintf """ +module Benchmark.%s + +type %s = + + val X : int + + val Y : int + + val Z : int + +let function%s (x: %s) = + let x = 1 + let y = 2 + let z = x + y + z""" moduleName moduleName moduleName moduleName + [] type CompilerService() = @@ -112,7 +155,7 @@ type CompilerService() = [] member __.Setup() = match checkerOpt with - | None -> checkerOpt <- Some(FSharpChecker.Create()) + | None -> checkerOpt <- Some(FSharpChecker.Create(projectCacheSize = 200)) | _ -> () match sourceOpt with @@ -127,18 +170,9 @@ type CompilerService() = |> Array.map (fun x -> (x.Location)) |> Some | _ -> () - - [] - member __.ParsingSetup() = - match checkerOpt with - | None -> failwith "no checker" - | Some(checker) -> - checker.InvalidateAll() - checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() - checker.ParseFile("dummy.fs", SourceText.ofString "dummy", parsingOptions) |> Async.RunSynchronously |> ignore [] - member __.Parsing() = + member __.ParsingTypeCheckerFs() = match checkerOpt, sourceOpt with | None, _ -> failwith "no checker" | _, None -> failwith "no source" @@ -146,11 +180,15 @@ type CompilerService() = let results = checker.ParseFile("TypeChecker.fs", source.ToFSharpSourceText(), parsingOptions) |> Async.RunSynchronously if results.ParseHadErrors then failwithf "parse had errors: %A" results.Errors - [] - member __.ILReadingSetup() = - // With caching, performance increases an order of magnitude when re-reading an ILModuleReader. - // Clear it for benchmarking. - ClearAllILModuleReaderCache() + [] + member __.ParsingTypeCheckerFsSetup() = + match checkerOpt with + | None -> failwith "no checker" + | Some(checker) -> + checker.InvalidateAll() + checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() + checker.ParseFile("dummy.fs", SourceText.ofString "dummy", parsingOptions) |> Async.RunSynchronously |> ignore + ClearAllILModuleReaderCache() [] member __.ILReading() = @@ -198,6 +236,85 @@ type CompilerService() = ) ) + [] + member __.ILReadingSetup() = + // With caching, performance increases an order of magnitude when re-reading an ILModuleReader. + // Clear it for benchmarking. + ClearAllILModuleReaderCache() + + member val TypeCheckFileWith100ReferencedProjectsOptions = + createProject "MainProject" + [ for i = 1 to 100 do + yield + createProject ("ReferencedProject" + string i) [] + ] + + member this.TypeCheckFileWith100ReferencedProjectsRun() = + let options = this.TypeCheckFileWith100ReferencedProjectsOptions + let file = options.SourceFiles.[0] + + match checkerOpt with + | None -> failwith "no checker" + | Some checker -> + let parseResult, checkResult = + checker.ParseAndCheckFileInProject(file, 0, SourceText.ofString (File.ReadAllText(file)), options) + |> Async.RunSynchronously + + if parseResult.Errors.Length > 0 then + failwithf "%A" parseResult.Errors + + match checkResult with + | FSharpCheckFileAnswer.Aborted -> failwith "aborted" + | FSharpCheckFileAnswer.Succeeded checkFileResult -> + + if checkFileResult.Errors.Length > 0 then + failwithf "%A" checkFileResult.Errors + + [] + member this.TypeCheckFileWith100ReferencedProjectsSetup() = + this.TypeCheckFileWith100ReferencedProjectsOptions.SourceFiles + |> Seq.iter (fun file -> + File.WriteAllText(file, generateSourceCode (Path.GetFileNameWithoutExtension(file))) + ) + + this.TypeCheckFileWith100ReferencedProjectsOptions.ReferencedProjects + |> Seq.iter (fun (_, referencedProjectOptions) -> + referencedProjectOptions.SourceFiles + |> Seq.iter (fun file -> + File.WriteAllText(file, generateSourceCode (Path.GetFileNameWithoutExtension(file))) + ) + ) + + this.TypeCheckFileWith100ReferencedProjectsRun() + + [] + member this.TypeCheckFileWith100ReferencedProjects() = + // Because the checker's projectcachesize is set to 200, this should be fast. + // If set to 3, it will be almost as slow as re-evaluating all project and it's projects references on setup; this could be a bug or not what we want. + this.TypeCheckFileWith100ReferencedProjectsRun() + + [] + member this.TypeCheckFileWith100ReferencedProjectsCleanup() = + this.TypeCheckFileWith100ReferencedProjectsOptions.SourceFiles + |> Seq.iter (fun file -> + try File.Delete(file) with | _ -> () + ) + + this.TypeCheckFileWith100ReferencedProjectsOptions.ReferencedProjects + |> Seq.iter (fun (_, referencedProjectOptions) -> + referencedProjectOptions.SourceFiles + |> Seq.iter (fun file -> + try File.Delete(file) with | _ -> () + ) + ) + + match checkerOpt with + | None -> failwith "no checker" + | Some(checker) -> + checker.InvalidateAll() + checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() + ClearAllILModuleReaderCache() + [] let main argv = let _ = BenchmarkRunner.Run() diff --git a/benchmarks/Directory.Build.props b/benchmarks/Directory.Build.props deleted file mode 100644 index bb8eac309b1..00000000000 --- a/benchmarks/Directory.Build.props +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/benchmarks/Directory.Build.targets b/benchmarks/Directory.Build.targets deleted file mode 100644 index ccd47cc0a9a..00000000000 --- a/benchmarks/Directory.Build.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - From 95f733dc1da8462ed6bf67a604f19bda47aaee1b Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 18 Apr 2019 23:42:27 +0100 Subject: [PATCH 13/17] cleanup fcs props (#6538) * cleanup fcs props * cleanup fcs props * fix build * fix paths * remove file --- fcs/Directory.Build.props | 10 ++++++++++ .../FSharp.Compiler.Service.MSBuild.v12.fsproj | 8 ++------ .../FSharp.Compiler.Service.ProjectCracker.fsproj | 11 +++++------ .../FSharp.Compiler.Service.ProjectCracker.targets | 4 ++-- ...harp.Compiler.Service.ProjectCrackerTool.fsproj | 8 ++------ .../CSharp_Analysis/CSharp_Analysis.csproj | 2 +- .../FSharp.Compiler.Service.Tests.fsproj | 10 +++------- .../FSharp.Compiler.Service.fsproj | 12 ++++-------- fcs/README.md | 2 +- fcs/fcs.props | 14 -------------- fcs/samples/EditorService/EditorService.fsproj | 7 +++---- fcs/samples/FscExe/FscExe.fsproj | 7 +++---- fcs/samples/FsiExe/FsiExe.fsproj | 7 +++---- .../InteractiveService/InteractiveService.fsproj | 7 +++---- fcs/samples/Tokenizer/Tokenizer.fsproj | 7 +++---- fcs/samples/UntypedTree/UntypedTree.fsproj | 7 +++---- 16 files changed, 48 insertions(+), 75 deletions(-) delete mode 100644 fcs/fcs.props diff --git a/fcs/Directory.Build.props b/fcs/Directory.Build.props index 596b06c0716..50e4c3e67b5 100644 --- a/fcs/Directory.Build.props +++ b/fcs/Directory.Build.props @@ -23,6 +23,16 @@ + $(MSBuildThisFileDirectory)..\src + 22.0.3 + --version:$(VersionPrefix) + false + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools + fsi.exe $(ArtifactsBinDir)\FSharp.Build\Proto\net472 + 4.6.2 + net461 diff --git a/fcs/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj b/fcs/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj index 20e1f29af35..9f7b3d20b29 100644 --- a/fcs/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj +++ b/fcs/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj @@ -1,11 +1,7 @@  - - $(MSBuildProjectDirectory)\..\..\src - - - net461 + $(FcsTargetNetFxFramework) true $(DefineConstants);CROSS_PLATFORM_COMPILER $(DefineConstants);ENABLE_MONO_SUPPORT @@ -28,7 +24,7 @@ - + diff --git a/fcs/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj b/fcs/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj index 648f66924df..a9cb30ba0f7 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj +++ b/fcs/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj @@ -1,8 +1,7 @@  - - net461 + $(FcsTargetNetFxFramework) true @@ -20,14 +19,14 @@ ProjectCrackerOptions.fs - - - + + + - + \ No newline at end of file diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets index bd1c93e7979..ed01293adaf 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets @@ -1,7 +1,7 @@ - - + + diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj index 3beb0e1f996..19789a96299 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj @@ -1,12 +1,8 @@  - - $(MSBuildProjectDirectory)\..\..\src - - Exe - net461 + $(FcsTargetNetFxFramework) true $(DefineConstants);CROSS_PLATFORM_COMPILER $(DefineConstants);ENABLE_MONO_SUPPORT @@ -23,7 +19,7 @@ - + diff --git a/fcs/FSharp.Compiler.Service.Tests/CSharp_Analysis/CSharp_Analysis.csproj b/fcs/FSharp.Compiler.Service.Tests/CSharp_Analysis/CSharp_Analysis.csproj index 30d3c96317f..534a1435415 100644 --- a/fcs/FSharp.Compiler.Service.Tests/CSharp_Analysis/CSharp_Analysis.csproj +++ b/fcs/FSharp.Compiler.Service.Tests/CSharp_Analysis/CSharp_Analysis.csproj @@ -1,7 +1,7 @@  - net461;netstandard2.0 + $(FcsTargetNetFxFramework);netstandard2.0 false $(NoWarn);0067;1591 diff --git a/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index c6d2243856a..1f7ffbf6d55 100644 --- a/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -1,11 +1,7 @@ - - $(MSBuildProjectDirectory)\..\..\src - - - net461;netcoreapp2.0 + $(FcsTargetNetFxFramework);netcoreapp2.0 true 4.1.19 $(NoWarn);44;75; @@ -80,7 +76,7 @@ - + @@ -88,7 +84,7 @@ - + diff --git a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj index dcdf91eef4a..68983105861 100644 --- a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj +++ b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj @@ -1,12 +1,8 @@ - - $(MSBuildProjectDirectory)\..\..\src - - - - net461;netstandard2.0 + + $(FcsTargetNetFxFramework);netstandard2.0 true $(DefineConstants);COMPILER_SERVICE_AS_DLL $(DefineConstants);COMPILER @@ -638,7 +634,7 @@ - + @@ -650,7 +646,7 @@ - + diff --git a/fcs/README.md b/fcs/README.md index ac97222a3c6..f0126f369c8 100644 --- a/fcs/README.md +++ b/fcs/README.md @@ -28,7 +28,7 @@ There are subtle differences between FSharp.Compiler.Service and FSharp.Compiler FCS uses its own version number sequence for assemblies and packages, approximately following SemVer rules. To update the version number a global replace through fcs\... is currently needed, e.g. - fcs.props + Directory.Build.props nuget/FSharp.Compiler.Service.nuspec nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec nuget/FSharp.Compiler.Service.ProjectCracker.nuspec diff --git a/fcs/fcs.props b/fcs/fcs.props deleted file mode 100644 index 207d1f8085b..00000000000 --- a/fcs/fcs.props +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - 22.0.3 - --version:$(VersionPrefix) - false - - - $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools - fsi.exe - - \ No newline at end of file diff --git a/fcs/samples/EditorService/EditorService.fsproj b/fcs/samples/EditorService/EditorService.fsproj index 25795d9299c..d71d6dc2913 100644 --- a/fcs/samples/EditorService/EditorService.fsproj +++ b/fcs/samples/EditorService/EditorService.fsproj @@ -1,8 +1,7 @@  - - net461;netcoreapp2.0 + $(FcsTargetNetFxFramework);netcoreapp2.0 true Exe false @@ -12,11 +11,11 @@ - + - + diff --git a/fcs/samples/FscExe/FscExe.fsproj b/fcs/samples/FscExe/FscExe.fsproj index a160f690d2f..97553e41249 100644 --- a/fcs/samples/FscExe/FscExe.fsproj +++ b/fcs/samples/FscExe/FscExe.fsproj @@ -1,8 +1,7 @@  - - net461 + $(FcsTargetNetFxFramework) true Exe false @@ -14,10 +13,10 @@ - + - + diff --git a/fcs/samples/FsiExe/FsiExe.fsproj b/fcs/samples/FsiExe/FsiExe.fsproj index 4ce18ab142c..94a2534c0e2 100644 --- a/fcs/samples/FsiExe/FsiExe.fsproj +++ b/fcs/samples/FsiExe/FsiExe.fsproj @@ -1,8 +1,7 @@  - - net461 + $(FcsTargetNetFxFramework) true Exe false @@ -16,10 +15,10 @@ - + - + diff --git a/fcs/samples/InteractiveService/InteractiveService.fsproj b/fcs/samples/InteractiveService/InteractiveService.fsproj index 75686578f21..bd834961496 100644 --- a/fcs/samples/InteractiveService/InteractiveService.fsproj +++ b/fcs/samples/InteractiveService/InteractiveService.fsproj @@ -1,8 +1,7 @@  - - net461 + $(FcsTargetNetFxFramework) true Exe false @@ -12,10 +11,10 @@ - + - + diff --git a/fcs/samples/Tokenizer/Tokenizer.fsproj b/fcs/samples/Tokenizer/Tokenizer.fsproj index 75686578f21..bd834961496 100644 --- a/fcs/samples/Tokenizer/Tokenizer.fsproj +++ b/fcs/samples/Tokenizer/Tokenizer.fsproj @@ -1,8 +1,7 @@  - - net461 + $(FcsTargetNetFxFramework) true Exe false @@ -12,10 +11,10 @@ - + - + diff --git a/fcs/samples/UntypedTree/UntypedTree.fsproj b/fcs/samples/UntypedTree/UntypedTree.fsproj index 75686578f21..bd834961496 100644 --- a/fcs/samples/UntypedTree/UntypedTree.fsproj +++ b/fcs/samples/UntypedTree/UntypedTree.fsproj @@ -1,8 +1,7 @@  - - net461 + $(FcsTargetNetFxFramework) true Exe false @@ -12,10 +11,10 @@ - + - + From 0fadd9e42ba61f1f77db23a1060f7b40f0325685 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Fri, 19 Apr 2019 12:26:08 -0700 Subject: [PATCH 14/17] rearrange order of SWR files to fix dependencies (#6582) --- .../Microsoft.FSharp.Dependencies.csproj | 2 +- setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr | 5 ----- setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/setup/Swix/Microsoft.FSharp.Dependencies/Microsoft.FSharp.Dependencies.csproj b/setup/Swix/Microsoft.FSharp.Dependencies/Microsoft.FSharp.Dependencies.csproj index 268f1d84dea..4dfc5e2ed60 100644 --- a/setup/Swix/Microsoft.FSharp.Dependencies/Microsoft.FSharp.Dependencies.csproj +++ b/setup/Swix/Microsoft.FSharp.Dependencies/Microsoft.FSharp.Dependencies.csproj @@ -12,8 +12,8 @@ - + diff --git a/setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr b/setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr index 9ed63a9ff0c..36882963903 100644 --- a/setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr +++ b/setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr @@ -12,8 +12,3 @@ vs.dependencies version=$(VsixVersion) type=Required when=Microsoft.VisualStudio.Product.Enterprise,Microsoft.VisualStudio.Product.Professional,Microsoft.VisualStudio.Product.Community - - vs.dependency id=Microsoft.FSharp.VSIX.Full.Resources - version=$(VsixVersion) - type=Required - when=Microsoft.VisualStudio.Product.Enterprise,Microsoft.VisualStudio.Product.Professional,Microsoft.VisualStudio.Product.Community diff --git a/setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj b/setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj index e7226c491eb..8e89e6d364c 100644 --- a/setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj +++ b/setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj @@ -10,8 +10,8 @@ - + From c4c1d9cf1097955a71c7cbc328a6b5c672a34bda Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Fri, 19 Apr 2019 15:42:45 -0700 Subject: [PATCH 15/17] combine swr files (#6587) --- .../Microsoft.FSharp.Dependencies/Dependencies.swr | 9 --------- .../Microsoft.FSharp.Dependencies.csproj | 3 +-- .../{Files.swr => Package.swr} | 5 +++++ setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr | 14 -------------- .../Microsoft.FSharp.IDE.csproj | 3 +-- .../{Files.swr => Package.swr} | 10 ++++++++++ 6 files changed, 17 insertions(+), 27 deletions(-) delete mode 100644 setup/Swix/Microsoft.FSharp.Dependencies/Dependencies.swr rename setup/Swix/Microsoft.FSharp.Dependencies/{Files.swr => Package.swr} (86%) delete mode 100644 setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr rename setup/Swix/Microsoft.FSharp.IDE/{Files.swr => Package.swr} (57%) diff --git a/setup/Swix/Microsoft.FSharp.Dependencies/Dependencies.swr b/setup/Swix/Microsoft.FSharp.Dependencies/Dependencies.swr deleted file mode 100644 index 82f9caaec1f..00000000000 --- a/setup/Swix/Microsoft.FSharp.Dependencies/Dependencies.swr +++ /dev/null @@ -1,9 +0,0 @@ -use vs - -package name=Microsoft.FSharp.Dependencies - version=$(VsixVersion) - -vs.dependencies - vs.dependency id=Microsoft.FSharp.SDK - version=$(VsixVersion) - type=Required diff --git a/setup/Swix/Microsoft.FSharp.Dependencies/Microsoft.FSharp.Dependencies.csproj b/setup/Swix/Microsoft.FSharp.Dependencies/Microsoft.FSharp.Dependencies.csproj index 4dfc5e2ed60..67f9f02f962 100644 --- a/setup/Swix/Microsoft.FSharp.Dependencies/Microsoft.FSharp.Dependencies.csproj +++ b/setup/Swix/Microsoft.FSharp.Dependencies/Microsoft.FSharp.Dependencies.csproj @@ -12,8 +12,7 @@ - - + diff --git a/setup/Swix/Microsoft.FSharp.Dependencies/Files.swr b/setup/Swix/Microsoft.FSharp.Dependencies/Package.swr similarity index 86% rename from setup/Swix/Microsoft.FSharp.Dependencies/Files.swr rename to setup/Swix/Microsoft.FSharp.Dependencies/Package.swr index 9b2836fd190..bd975fbc95f 100644 --- a/setup/Swix/Microsoft.FSharp.Dependencies/Files.swr +++ b/setup/Swix/Microsoft.FSharp.Dependencies/Package.swr @@ -3,6 +3,11 @@ use vs package name=Microsoft.FSharp.Dependencies version=$(VsixVersion) +vs.dependencies + vs.dependency id=Microsoft.FSharp.SDK + version=$(VsixVersion) + type=Required + folder "InstallDir:MSBuild\Microsoft\VisualStudio\v$(VSGeneralVersion)\FSharp" file "Microsoft.FSharp.targets" source="$(SetupShimsDir)\Microsoft.FSharp.Shim.targets" file "Microsoft.Portable.FSharp.targets" source="$(SetupShimsDir)\Microsoft.Portable.FSharp.Shim.targets" diff --git a/setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr b/setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr deleted file mode 100644 index 36882963903..00000000000 --- a/setup/Swix/Microsoft.FSharp.IDE/Dependencies.swr +++ /dev/null @@ -1,14 +0,0 @@ -use vs - -package name=Microsoft.FSharp.IDE - version=$(VsixVersion) - -vs.dependencies - vs.dependency id=Microsoft.FSharp.Dependencies - version=$(VsixVersion) - type=Required - - vs.dependency id=Microsoft.FSharp.VSIX.Full.Core - version=$(VsixVersion) - type=Required - when=Microsoft.VisualStudio.Product.Enterprise,Microsoft.VisualStudio.Product.Professional,Microsoft.VisualStudio.Product.Community diff --git a/setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj b/setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj index 8e89e6d364c..a454fc2c606 100644 --- a/setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj +++ b/setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj @@ -10,8 +10,7 @@ - - + diff --git a/setup/Swix/Microsoft.FSharp.IDE/Files.swr b/setup/Swix/Microsoft.FSharp.IDE/Package.swr similarity index 57% rename from setup/Swix/Microsoft.FSharp.IDE/Files.swr rename to setup/Swix/Microsoft.FSharp.IDE/Package.swr index 79257b19395..8184815f837 100644 --- a/setup/Swix/Microsoft.FSharp.IDE/Files.swr +++ b/setup/Swix/Microsoft.FSharp.IDE/Package.swr @@ -3,6 +3,16 @@ use vs package name=Microsoft.FSharp.IDE version=$(VsixVersion) +vs.dependencies + vs.dependency id=Microsoft.FSharp.Dependencies + version=$(VsixVersion) + type=Required + + vs.dependency id=Microsoft.FSharp.VSIX.Full.Core + version=$(VsixVersion) + type=Required + when=Microsoft.VisualStudio.Product.Enterprise,Microsoft.VisualStudio.Product.Professional,Microsoft.VisualStudio.Product.Community + folder "InstallDir:Common7\IDE\NewScriptItems" file source="$(SetupResourcesDir)\NewFileDialog\Script\NewFSharpScriptItems.vsdir" file source="$(SetupResourcesDir)\NewFileDialog\Script\Script.fsx" From 69539f2458a69edbf839afbb71bee04ab00e20a8 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Mon, 22 Apr 2019 15:36:56 -0700 Subject: [PATCH 16/17] hard-code FSharp.Core that ships with legacy project templates (#6611) --- eng/targets/NuGet.targets | 12 ------------ .../VisualFSharpTemplates.csproj | 12 +++++++----- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/eng/targets/NuGet.targets b/eng/targets/NuGet.targets index c2db06b6c1a..dc8f32e24d6 100644 --- a/eng/targets/NuGet.targets +++ b/eng/targets/NuGet.targets @@ -5,16 +5,4 @@ - - - - - - - - - diff --git a/vsintegration/Vsix/VisualFSharpTemplates/VisualFSharpTemplates.csproj b/vsintegration/Vsix/VisualFSharpTemplates/VisualFSharpTemplates.csproj index b3a4769278d..0f3774974e1 100644 --- a/vsintegration/Vsix/VisualFSharpTemplates/VisualFSharpTemplates.csproj +++ b/vsintegration/Vsix/VisualFSharpTemplates/VisualFSharpTemplates.csproj @@ -15,17 +15,19 @@ packages\System.ValueTuple.4.4.0.nupkg true + + PreserveNewest + packages\FSharp.Core.4.6.2.nupkg + true + Designer - - packages - PackOutputGroup%3b - false - + + From a5510fb603e5014e8515e4e53ec558b40e415f7c Mon Sep 17 00:00:00 2001 From: Will Smith Date: Tue, 23 Apr 2019 16:54:06 -0700 Subject: [PATCH 17/17] Roslyn Shim - First Phase (#6498) * Trying to use shim * Removed contenttypelangservice, it's in externalaccess now * Added namespace * Added diagnosticanalyzerservice shim * Using Brace matching from external access * Using VSWorkspace extensions * More apis * Using shim for IEditorFormattingService * More apis * More shims * Updating shim * Update VisualFSharp.UnitTests.fsproj * Fixed api call * Fix debugging * Fixed unit test fsproj, find all refs shimmed * Change analyserservice * Fixed build * Updating shim with FSharp prefixes * Fixing glyph helpers * Fixing typemap * Update fsi.fsproj * Update Versions.props * Update RoslynPackageVersion.txt * Update prim-lexing.fs * Update prim-lexing.fs * Update fsi.fsproj * Update fsi.fsproj * Update VisualFSharp.UnitTests.fsproj * Update CompletionProvider.fs * Fixed package --- RoslynPackageVersion.txt | 2 +- eng/Versions.props | 1 + .../Classification/ClassificationService.fs | 5 ++-- .../CodeLens/CodeLensProvider.fs | 3 ++- .../CodeLens/FSharpCodeLensService.fs | 7 ++++-- .../src/FSharp.Editor/Common/ContentType.fs | 9 +------- .../src/FSharp.Editor/Common/Extensions.fs | 4 ++++ .../src/FSharp.Editor/Common/RoslynHelpers.fs | 3 ++- .../Completion/CompletionProvider.fs | 4 ++-- .../Completion/FileSystemCompletion.fs | 3 ++- .../Debugging/BreakpointResolutionService.fs | 14 +++++------ .../Debugging/LanguageDebugInfoService.fs | 16 ++++++------- .../Diagnostics/DocumentDiagnosticAnalyzer.fs | 1 + .../SimplifyNameDiagnosticAnalyzer.fs | 3 ++- .../Diagnostics/UnusedDeclarationsAnalyzer.fs | 3 ++- .../UnusedOpensDiagnosticAnalyzer.fs | 3 ++- .../src/FSharp.Editor/FSharp.Editor.fsproj | 1 + .../Formatting/BraceMatchingService.fs | 7 +++--- .../Formatting/EditorFormattingService.fs | 6 ++--- .../Formatting/IndentationService.fs | 10 ++++---- .../LanguageService/FSharpCheckerProvider.fs | 9 ++++---- .../FSharpProjectOptionsManager.fs | 16 ++++++------- .../LanguageService/LanguageService.fs | 3 ++- .../LanguageService/Tokenizer.fs | 5 ++++ .../Navigation/FindUsagesService.fs | 23 +++++++++---------- .../Navigation/NavigationBarItemService.fs | 4 ++-- .../UnitTests/VisualFSharp.UnitTests.fsproj | 3 +-- 27 files changed, 92 insertions(+), 76 deletions(-) diff --git a/RoslynPackageVersion.txt b/RoslynPackageVersion.txt index f0add9e0811..fd1d6f6d9bc 100644 --- a/RoslynPackageVersion.txt +++ b/RoslynPackageVersion.txt @@ -1 +1 @@ -3.0.0-beta4-19170-01 +3.1.0-beta3-19222-02 diff --git a/eng/Versions.props b/eng/Versions.props index 35407337eec..3e989e6aa60 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -51,6 +51,7 @@ https://api.nuget.org/v3/index.json; https://dotnet.myget.org/F/roslyn/api/v3/index.json; https://dotnet.myget.org/F/symreader-converter/api/v3/index.json; + https://dotnet.myget.org/F/interactive-window/api/v3/index.json; https://myget.org/F/vs-devcore/api/v3/index.json; https://myget.org/F/vs-editor/api/v3/index.json; https://vside.myget.org/F/vssdk/api/v3/index.json; diff --git a/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs b/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs index a9ef2395dbd..d950a0abbf5 100644 --- a/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs +++ b/vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs @@ -13,6 +13,7 @@ open Microsoft.CodeAnalysis.Classification open Microsoft.CodeAnalysis.Editor open Microsoft.CodeAnalysis.Host.Mef open Microsoft.CodeAnalysis.Text +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Classification // IEditorClassificationService is marked as Obsolete, but is still supported. The replacement (IClassificationService) // is internal to Microsoft.CodeAnalysis.Workspaces which we don't have internals visible to. Rather than add yet another @@ -21,7 +22,7 @@ open Microsoft.CodeAnalysis.Text open FSharp.Compiler.SourceCodeServices -[, FSharpConstants.FSharpLanguageName)>] +[)>] type internal FSharpClassificationService [] ( @@ -30,7 +31,7 @@ type internal FSharpClassificationService ) = static let userOpName = "SemanticColorization" - interface IEditorClassificationService with + interface IFSharpClassificationService with // Do not perform classification if we don't have project options (#defines matter) member __.AddLexicalClassifications(_: SourceText, _: TextSpan, _: List, _: CancellationToken) = () diff --git a/vsintegration/src/FSharp.Editor/CodeLens/CodeLensProvider.fs b/vsintegration/src/FSharp.Editor/CodeLens/CodeLensProvider.fs index 415f9e5fa6d..10c7f14ab95 100644 --- a/vsintegration/src/FSharp.Editor/CodeLens/CodeLensProvider.fs +++ b/vsintegration/src/FSharp.Editor/CodeLens/CodeLensProvider.fs @@ -19,6 +19,7 @@ open Microsoft.VisualStudio.Text.Classification open Microsoft.VisualStudio.ComponentModelHost open System.Threading open Microsoft.VisualStudio.FSharp.Editor.Logging +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor.Shared.Utilities [)>] [)>] @@ -32,7 +33,7 @@ type internal CodeLensProvider textDocumentFactory: ITextDocumentFactoryService, checkerProvider: FSharpCheckerProvider, projectInfoManager: FSharpProjectOptionsManager, - typeMap : ClassificationTypeMap Lazy, + typeMap : FSharpClassificationTypeMap Lazy, settings: EditorOptions ) = diff --git a/vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs b/vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs index f7248253fd0..44e9322dffb 100644 --- a/vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs +++ b/vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs @@ -15,6 +15,7 @@ open Microsoft.CodeAnalysis open Microsoft.CodeAnalysis.Editor.Shared.Extensions open Microsoft.CodeAnalysis.Editor.Shared.Utilities open Microsoft.CodeAnalysis.Classification +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Classification open FSharp.Compiler open FSharp.Compiler.Ast @@ -31,6 +32,8 @@ open Microsoft.VisualStudio.Text.Formatting open Internal.Utilities.StructuredFormat +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor.Shared.Utilities + type internal CodeLens(taggedText, computed, fullTypeSignature, uiElement) = member val TaggedText: Async<(ResizeArray * QuickInfoNavigation) option> = taggedText member val Computed: bool = computed with get, set @@ -46,7 +49,7 @@ type internal FSharpCodeLensService checker: FSharpChecker, projectInfoManager: FSharpProjectOptionsManager, classificationFormatMapService: IClassificationFormatMapService, - typeMap: Lazy, + typeMap: Lazy, codeLens : CodeLensDisplayService, settings: EditorOptions ) as self = @@ -78,7 +81,7 @@ type internal FSharpCodeLensService let layoutTagToFormatting (layoutTag: LayoutTag) = layoutTag |> RoslynHelpers.roslynTag - |> ClassificationTags.GetClassificationTypeName + |> FSharpClassificationTags.GetClassificationTypeName |> typeMap.Value.GetClassificationType |> formatMap.Value.GetTextProperties diff --git a/vsintegration/src/FSharp.Editor/Common/ContentType.fs b/vsintegration/src/FSharp.Editor/Common/ContentType.fs index 71391080b32..2e92332ccbe 100644 --- a/vsintegration/src/FSharp.Editor/Common/ContentType.fs +++ b/vsintegration/src/FSharp.Editor/Common/ContentType.fs @@ -6,6 +6,7 @@ open System.ComponentModel.Composition open Microsoft.CodeAnalysis.Editor open Microsoft.VisualStudio.Utilities +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor module FSharpStaticTypeDefinitions = [] @@ -17,11 +18,3 @@ module FSharpStaticTypeDefinitions = [] [] let FSharpSignatureHelpContentTypeDefinition = ContentTypeDefinition() - -[] -type FSharpContentType [](contentTypeRegistry : IContentTypeRegistryService) = - member this.contentTypeRegistryService = contentTypeRegistry - - interface IContentTypeLanguageService with - member this.GetDefaultContentType() = - this.contentTypeRegistryService.GetContentType(FSharpConstants.FSharpContentTypeName) diff --git a/vsintegration/src/FSharp.Editor/Common/Extensions.fs b/vsintegration/src/FSharp.Editor/Common/Extensions.fs index 694d3a401a8..222f4b5f09f 100644 --- a/vsintegration/src/FSharp.Editor/Common/Extensions.fs +++ b/vsintegration/src/FSharp.Editor/Common/Extensions.fs @@ -11,6 +11,10 @@ open Microsoft.CodeAnalysis.Host open FSharp.Compiler.Text open FSharp.Compiler.Ast open FSharp.Compiler.SourceCodeServices +open Microsoft.CodeAnalysis.ExternalAccess.FSharp + +type private FSharpGlyph = FSharp.Compiler.SourceCodeServices.FSharpGlyph +type private Glyph = Microsoft.CodeAnalysis.ExternalAccess.FSharp.FSharpGlyph type Path with diff --git a/vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs b/vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs index 38d1214267d..4d66d133b78 100644 --- a/vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs +++ b/vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs @@ -15,6 +15,7 @@ open FSharp.Compiler.Layout open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Range open Microsoft.VisualStudio.FSharp.Editor.Logging +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics [] module internal RoslynHelpers = @@ -149,7 +150,7 @@ module internal RoslynHelpers = let severity = if error.Severity = FSharpErrorSeverity.Error then DiagnosticSeverity.Error else DiagnosticSeverity.Warning let customTags = match error.ErrorNumber with - | 1182 -> DiagnosticCustomTags.Unnecessary + | 1182 -> FSharpDiagnosticCustomTags.Unnecessary | _ -> null let descriptor = new DiagnosticDescriptor(id, emptyString, description, error.Subcategory, severity, true, emptyString, String.Empty, customTags) Diagnostic.Create(descriptor, location) diff --git a/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs b/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs index 4b80da57009..bac38b14a00 100644 --- a/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs +++ b/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs @@ -156,7 +156,7 @@ type internal FSharpCompletionProvider | _, idents -> Array.last idents let completionItem = - CommonCompletionItem.Create(name, null, glyph = Nullable glyph, rules = getRules intellisenseOptions.ShowAfterCharIsTyped, filterText = filterText) + CommonCompletionItem.Create(name, null, rules = getRules intellisenseOptions.ShowAfterCharIsTyped, glyph = Nullable (Microsoft.CodeAnalysis.ExternalAccess.FSharp.FSharpGlyphHelpersObsolete.Convert(glyph)), filterText = filterText) .AddProperty(FullNamePropName, declarationItem.FullName) let completionItem = @@ -303,4 +303,4 @@ type internal FSharpCompletionProvider } |> Async.map (Option.defaultValue (CompletionChange.Create(TextChange(item.Span, nameInCode)))) - } |> RoslynHelpers.StartAsyncAsTask cancellationToken \ No newline at end of file + } |> RoslynHelpers.StartAsyncAsTask cancellationToken diff --git a/vsintegration/src/FSharp.Editor/Completion/FileSystemCompletion.fs b/vsintegration/src/FSharp.Editor/Completion/FileSystemCompletion.fs index c3dba0e5c8f..e92caa22d4d 100644 --- a/vsintegration/src/FSharp.Editor/Completion/FileSystemCompletion.fs +++ b/vsintegration/src/FSharp.Editor/Completion/FileSystemCompletion.fs @@ -129,7 +129,8 @@ type internal HashDirectiveCompletionProvider(workspace: Workspace, projectInfoM rules) let pathThroughLastSlash = getPathThroughLastSlash(text, position, quotedPathGroup) - context.AddItems(helper.GetItems(pathThroughLastSlash, ct)) + let! items = helper.GetItemsAsync(pathThroughLastSlash, ct) |> Async.AwaitTask |> liftAsync + context.AddItems(items) } |> Async.Ignore |> RoslynHelpers.StartAsyncUnitAsTask context.CancellationToken diff --git a/vsintegration/src/FSharp.Editor/Debugging/BreakpointResolutionService.fs b/vsintegration/src/FSharp.Editor/Debugging/BreakpointResolutionService.fs index bb55414b10d..42bd5f9282d 100644 --- a/vsintegration/src/FSharp.Editor/Debugging/BreakpointResolutionService.fs +++ b/vsintegration/src/FSharp.Editor/Debugging/BreakpointResolutionService.fs @@ -13,12 +13,12 @@ open Microsoft.CodeAnalysis open Microsoft.CodeAnalysis.Editor.Implementation.Debugging open Microsoft.CodeAnalysis.Host.Mef open Microsoft.CodeAnalysis.Text +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor.Implementation.Debugging open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Range -[] -[, FSharpConstants.FSharpLanguageName)>] +[)>] type internal FSharpBreakpointResolutionService [] ( @@ -41,18 +41,18 @@ type internal FSharpBreakpointResolutionService return parseResults.ValidateBreakpointLocation(mkPos fcsTextLineNumber textLineColumn) } - interface IBreakpointResolutionService with - member this.ResolveBreakpointAsync(document: Document, textSpan: TextSpan, cancellationToken: CancellationToken): Task = + interface IFSharpBreakpointResolutionService with + member this.ResolveBreakpointAsync(document: Document, textSpan: TextSpan, cancellationToken: CancellationToken): Task = asyncMaybe { let! parsingOptions, _options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken) let! sourceText = document.GetTextAsync(cancellationToken) let! range = FSharpBreakpointResolutionService.GetBreakpointLocation(checkerProvider.Checker, sourceText, document.Name, textSpan, parsingOptions) let! span = RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, range) - return BreakpointResolutionResult.CreateSpanResult(document, span) + return FSharpBreakpointResolutionResult.CreateSpanResult(document, span) } |> Async.map Option.toObj |> RoslynHelpers.StartAsyncAsTask cancellationToken // FSROSLYNTODO: enable placing breakpoints by when user supplies fully-qualified function names - member this.ResolveBreakpointsAsync(_, _, _): Task> = - Task.FromResult(Enumerable.Empty()) \ No newline at end of file + member this.ResolveBreakpointsAsync(_, _, _): Task> = + Task.FromResult(Enumerable.Empty()) \ No newline at end of file diff --git a/vsintegration/src/FSharp.Editor/Debugging/LanguageDebugInfoService.fs b/vsintegration/src/FSharp.Editor/Debugging/LanguageDebugInfoService.fs index 62ee7cac945..cf37cf08aa6 100644 --- a/vsintegration/src/FSharp.Editor/Debugging/LanguageDebugInfoService.fs +++ b/vsintegration/src/FSharp.Editor/Debugging/LanguageDebugInfoService.fs @@ -13,11 +13,11 @@ open Microsoft.CodeAnalysis.Classification open Microsoft.CodeAnalysis.Editor.Implementation.Debugging open Microsoft.CodeAnalysis.Host.Mef open Microsoft.CodeAnalysis.Text +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor.Implementation.Debugging open FSharp.Compiler -[] -[, FSharpConstants.FSharpLanguageName)>] +[)>] type internal FSharpLanguageDebugInfoService [](projectInfoManager: FSharpProjectOptionsManager) = static member GetDataTipInformation(sourceText: SourceText, position: int, tokens: List): TextSpan option = @@ -44,13 +44,13 @@ type internal FSharpLanguageDebugInfoService [](projectInf | _ -> None - interface ILanguageDebugInfoService with + interface IFSharpLanguageDebugInfoService with // FSROSLYNTODO: This is used to get function names in breakpoint window. It should return fully qualified function name and line offset from the start of the function. - member this.GetLocationInfoAsync(_, _, _): Task = - Task.FromResult(Unchecked.defaultof) + member this.GetLocationInfoAsync(_, _, _): Task = + Task.FromResult(Unchecked.defaultof) - member this.GetDataTipInfoAsync(document: Document, position: int, cancellationToken: CancellationToken): Task = + member this.GetDataTipInfoAsync(document: Document, position: int, cancellationToken: CancellationToken): Task = async { let defines = projectInfoManager.GetCompilationDefinesForEditingDocument(document) let! cancellationToken = Async.CancellationToken @@ -59,8 +59,8 @@ type internal FSharpLanguageDebugInfoService [](projectInf let classifiedSpans = Tokenizer.getClassifiedSpans(document.Id, sourceText, textSpan, Some(document.Name), defines, cancellationToken) let result = match FSharpLanguageDebugInfoService.GetDataTipInformation(sourceText, position, classifiedSpans) with - | None -> DebugDataTipInfo() - | Some textSpan -> DebugDataTipInfo(textSpan, sourceText.GetSubText(textSpan).ToString()) + | None -> FSharpDebugDataTipInfo() + | Some textSpan -> FSharpDebugDataTipInfo(textSpan, sourceText.GetSubText(textSpan).ToString()) return result } |> RoslynHelpers.StartAsyncAsTask(cancellationToken) diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs index ff3b5579855..44b94805950 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs @@ -11,6 +11,7 @@ open System.Threading.Tasks open Microsoft.CodeAnalysis open Microsoft.CodeAnalysis.Diagnostics open Microsoft.CodeAnalysis.Text +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics open FSharp.Compiler open FSharp.Compiler.SourceCodeServices diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs index fe52ce0b6ff..53556c97e71 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs @@ -15,6 +15,7 @@ open FSharp.Compiler open FSharp.Compiler.Range open FSharp.Compiler.SourceCodeServices open System.Runtime.Caching +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics type private TextVersionHash = int type private PerDocumentSavedData = { Hash: int; Diagnostics: ImmutableArray } @@ -39,7 +40,7 @@ type internal SimplifyNameDiagnosticAnalyzer() = category = DiagnosticCategory.Style, defaultSeverity = DiagnosticSeverity.Hidden, isEnabledByDefault = true, - customTags = DiagnosticCustomTags.Unnecessary) + customTags = FSharpDiagnosticCustomTags.Unnecessary) static member LongIdentPropertyKey = "FullName" override __.Priority = 100 // Default = 50 diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs index 082b83444eb..58b1b139ff0 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs @@ -11,6 +11,7 @@ open System.Threading.Tasks open Microsoft.CodeAnalysis open Microsoft.CodeAnalysis.Diagnostics open FSharp.Compiler.SourceCodeServices +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics [] type internal UnusedDeclarationsAnalyzer() = @@ -29,7 +30,7 @@ type internal UnusedDeclarationsAnalyzer() = category = DiagnosticCategory.Style, defaultSeverity = DiagnosticSeverity.Hidden, isEnabledByDefault = true, - customTags = DiagnosticCustomTags.Unnecessary) + customTags = FSharpDiagnosticCustomTags.Unnecessary) let isPotentiallyUnusedDeclaration (symbol: FSharpSymbol) : bool = match symbol with diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs index f530a0fa583..b94f0ca09a9 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs @@ -16,6 +16,7 @@ open FSharp.Compiler.Ast open FSharp.Compiler.Range open FSharp.Compiler.SourceCodeServices open Microsoft.VisualStudio.FSharp.Editor.Symbols +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics [] type internal UnusedOpensDiagnosticAnalyzer() = @@ -33,7 +34,7 @@ type internal UnusedOpensDiagnosticAnalyzer() = category = DiagnosticCategory.Style, defaultSeverity = DiagnosticSeverity.Hidden, isEnabledByDefault = true, - customTags = DiagnosticCustomTags.Unnecessary) + customTags = FSharpDiagnosticCustomTags.Unnecessary) override __.Priority = 90 // Default = 50 override __.SupportedDiagnostics = ImmutableArray.Create Descriptor diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj index 5f78b109805..d6b712757b0 100644 --- a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj +++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj @@ -136,6 +136,7 @@ + diff --git a/vsintegration/src/FSharp.Editor/Formatting/BraceMatchingService.fs b/vsintegration/src/FSharp.Editor/Formatting/BraceMatchingService.fs index a5e6332cb0c..794fd5de362 100644 --- a/vsintegration/src/FSharp.Editor/Formatting/BraceMatchingService.fs +++ b/vsintegration/src/FSharp.Editor/Formatting/BraceMatchingService.fs @@ -7,8 +7,9 @@ open Microsoft.CodeAnalysis.Text open Microsoft.CodeAnalysis.Editor open FSharp.Compiler.SourceCodeServices open System.Runtime.InteropServices +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor -[] +[)>] type internal FSharpBraceMatchingService [] ( @@ -33,7 +34,7 @@ type internal FSharpBraceMatchingService return matchedBraces |> Array.tryFind(fun (left, right) -> isPositionInRange left || isPositionInRange right) } - interface IBraceMatcher with + interface IFSharpBraceMatcher with member this.FindBracesAsync(document, position, cancellationToken) = asyncMaybe { let! parsingOptions, _options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken) @@ -41,7 +42,7 @@ type internal FSharpBraceMatchingService let! (left, right) = FSharpBraceMatchingService.GetBraceMatchingResult(checkerProvider.Checker, sourceText, document.Name, parsingOptions, position, defaultUserOpName) let! leftSpan = RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, left) let! rightSpan = RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, right) - return BraceMatchingResult(leftSpan, rightSpan) + return FSharpBraceMatchingResult(leftSpan, rightSpan) } |> Async.map Option.toNullable |> RoslynHelpers.StartAsyncAsTask cancellationToken diff --git a/vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs b/vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs index 25f3038da56..4cc4b10c5a2 100644 --- a/vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs +++ b/vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs @@ -10,13 +10,13 @@ open Microsoft.CodeAnalysis.Editor open Microsoft.CodeAnalysis.Formatting open Microsoft.CodeAnalysis.Host.Mef open Microsoft.CodeAnalysis.Text +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor open FSharp.Compiler.SourceCodeServices open System.Threading open System.Windows.Forms -[] -[, FSharpConstants.FSharpLanguageName)>] +[)>] type internal FSharpEditorFormattingService [] ( @@ -170,7 +170,7 @@ type internal FSharpEditorFormattingService return toIList Seq.empty } - interface IEditorFormattingService with + interface IFSharpEditorFormattingService with member val SupportsFormatDocument = false member val SupportsFormatSelection = false member val SupportsFormatOnPaste = true diff --git a/vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs b/vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs index 0426832ce34..a888518523d 100644 --- a/vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs +++ b/vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs @@ -11,11 +11,11 @@ open Microsoft.CodeAnalysis.Editor open Microsoft.CodeAnalysis.Formatting open Microsoft.CodeAnalysis.Host.Mef open Microsoft.CodeAnalysis.Text +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor open FSharp.Compiler.SourceCodeServices -[] -[, FSharpConstants.FSharpLanguageName)>] +[)>] type internal FSharpIndentationService [] (projectInfoManager: FSharpProjectOptionsManager) = @@ -92,8 +92,8 @@ type internal FSharpIndentationService lastIndent } - interface ISynchronousIndentationService with - member this.GetDesiredIndentation(document: Document, lineNumber: int, cancellationToken: CancellationToken): Nullable = + interface IFSharpSynchronousIndentationService with + member this.GetDesiredIndentation(document: Document, lineNumber: int, cancellationToken: CancellationToken): Nullable = async { let! cancellationToken = Async.CancellationToken let! sourceText = document.GetTextAsync(cancellationToken) |> Async.AwaitTask @@ -105,5 +105,5 @@ type internal FSharpIndentationService return match indent with | None -> Nullable() - | Some(indentation) -> Nullable(IndentationResult(sourceText.Lines.[lineNumber].Start, indentation)) + | Some(indentation) -> Nullable(FSharpIndentationResult(sourceText.Lines.[lineNumber].Start, indentation)) } |> (fun c -> Async.RunSynchronously(c,cancellationToken=cancellationToken)) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerProvider.fs b/vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerProvider.fs index b0af16b99f7..b43e5caf14a 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerProvider.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerProvider.fs @@ -13,6 +13,8 @@ open Microsoft.VisualStudio.FSharp.Editor open Microsoft.VisualStudio.LanguageServices open Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem open FSharp.NativeInterop +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.LanguageServices +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics #nowarn "9" // NativePtr.toNativeInt @@ -21,15 +23,14 @@ open FSharp.NativeInterop type internal FSharpCheckerProvider [] ( - analyzerService: IDiagnosticAnalyzerService, - [)>] workspace: VisualStudioWorkspaceImpl, + analyzerService: IFSharpDiagnosticAnalyzerService, + [)>] workspace: VisualStudioWorkspace, settings: EditorOptions ) = let tryGetMetadataSnapshot (path, timeStamp) = try - let metadataReferenceProvider = workspace.Services.GetService() - let md = metadataReferenceProvider.GetMetadata(path, timeStamp) + let md = Microsoft.CodeAnalysis.ExternalAccess.FSharp.LanguageServices.FSharpVisualStudioWorkspaceExtensions.GetMetadata(workspace, path, timeStamp) let amd = (md :?> AssemblyMetadata) let mmd = amd.GetModules().[0] let mmr = mmd.GetMetadataReader() diff --git a/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs b/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs index a14ef358737..9d9542087a0 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs @@ -20,11 +20,12 @@ open Microsoft.VisualStudio.Shell open System.Threading open Microsoft.VisualStudio.Shell.Interop open Microsoft.VisualStudio.LanguageServices.Implementation.TaskList +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.LanguageServices [] module private FSharpProjectOptionsHelpers = - let mapCpsProjectToSite(workspace:VisualStudioWorkspaceImpl, project:Project, serviceProvider:System.IServiceProvider, cpsCommandLineOptions: IDictionary) = + let mapCpsProjectToSite(workspace:VisualStudioWorkspace, project:Project, serviceProvider:System.IServiceProvider, cpsCommandLineOptions: IDictionary) = let hier = workspace.GetHierarchy(project.Id) let sourcePaths, referencePaths, options = match cpsCommandLineOptions.TryGetValue(project.Id) with @@ -108,7 +109,7 @@ type private FSharpProjectOptionsMessage = | ClearSingleFileOptionsCache of DocumentId [] -type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl, settings: EditorOptions, serviceProvider, checkerProvider: FSharpCheckerProvider) = +type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspace, settings: EditorOptions, serviceProvider, checkerProvider: FSharpCheckerProvider) = let cancellationTokenSource = new CancellationTokenSource() // Hack to store command line options from HandleCommandLineChanges @@ -322,7 +323,7 @@ type internal FSharpProjectOptionsManager [] ( checkerProvider: FSharpCheckerProvider, - [)>] workspace: VisualStudioWorkspaceImpl, + [)>] workspace: VisualStudioWorkspace, [)>] serviceProvider: System.IServiceProvider, settings: EditorOptions ) = @@ -387,11 +388,10 @@ type internal FSharpProjectOptionsManager use _logBlock = Logger.LogBlock(LogEditorFunctionId.LanguageService_HandleCommandLineArgs) let projectId = - match workspace.ProjectTracker.TryGetProjectByBinPath(path) with - | true, project -> project.Id - | false, _ -> workspace.ProjectTracker.GetOrCreateProjectIdForPath(path, projectDisplayNameOf path) - let project = workspace.ProjectTracker.GetProject(projectId) - let path = project.ProjectFilePath + match Microsoft.CodeAnalysis.ExternalAccess.FSharp.LanguageServices.FSharpVisualStudioWorkspaceExtensions.TryGetProjectIdByBinPath(workspace, path) with + | true, projectId -> projectId + | false, _ -> Microsoft.CodeAnalysis.ExternalAccess.FSharp.LanguageServices.FSharpVisualStudioWorkspaceExtensions.GetOrCreateProjectIdForPath(workspace, path, projectDisplayNameOf path) + let path = Microsoft.CodeAnalysis.ExternalAccess.FSharp.LanguageServices.FSharpVisualStudioWorkspaceExtensions.GetProjectFilePath(workspace, projectId); let fullPath p = if Path.IsPathRooted(p) || path = null then p else Path.Combine(Path.GetDirectoryName(path), p) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index da7ae84baf2..c568091aea2 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -37,6 +37,7 @@ open Microsoft.VisualStudio.Shell.Interop open Microsoft.VisualStudio.ComponentModelHost open Microsoft.VisualStudio.Text.Outlining open FSharp.NativeInterop +open Microsoft.CodeAnalysis.ExternalAccess.FSharp #nowarn "9" // NativePtr.toNativeInt @@ -236,7 +237,7 @@ type internal FSharpLanguageService(package : FSharpPackage) = override this.Initialize() = base.Initialize() - this.Workspace.Options <- this.Workspace.Options.WithChangedOption(Completion.CompletionOptions.BlockForCompletionItems, FSharpConstants.FSharpLanguageName, false) + this.Workspace.Options <- this.Workspace.Options.WithChangedOption(Completion.FSharpCompletionOptions.BlockForCompletionItems, FSharpConstants.FSharpLanguageName, false) this.Workspace.Options <- this.Workspace.Options.WithChangedOption(Shared.Options.ServiceFeatureOnOffOptions.ClosedFileDiagnostic, FSharpConstants.FSharpLanguageName, Nullable false) let theme = package.ComponentModel.DefaultExportProvider.GetExport().Value diff --git a/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs b/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs index 66a3a22a63c..bb2ce53559c 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs @@ -20,6 +20,11 @@ open FSharp.Compiler.SourceCodeServices open Microsoft.VisualStudio.Core.Imaging open Microsoft.VisualStudio.Imaging +open Microsoft.CodeAnalysis.ExternalAccess.FSharp + +type private FSharpGlyph = FSharp.Compiler.SourceCodeServices.FSharpGlyph +type private Glyph = Microsoft.CodeAnalysis.ExternalAccess.FSharp.FSharpGlyph + [] type internal LexerSymbolKind = | Ident = 0 diff --git a/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs b/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs index 584c6217c47..2286cd06445 100644 --- a/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs +++ b/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs @@ -7,15 +7,14 @@ open System.Collections.Immutable open System.Composition open Microsoft.CodeAnalysis -open Microsoft.CodeAnalysis.Completion -open Microsoft.CodeAnalysis.Host.Mef -open Microsoft.CodeAnalysis.Editor.FindUsages -open Microsoft.CodeAnalysis.FindUsages +open Microsoft.CodeAnalysis.ExternalAccess.FSharp +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.FindUsages +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor.FindUsages open FSharp.Compiler.Range open FSharp.Compiler.SourceCodeServices -[, FSharpConstants.FSharpLanguageName); Shared>] +[)>] type internal FSharpFindUsagesService [] ( @@ -40,14 +39,14 @@ type internal FSharpFindUsagesService match RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, range) with | Some span -> let span = Tokenizer.fixupSpan(sourceText, span) - return Some (DocumentSpan(doc, span)) + return Some (FSharpDocumentSpan(doc, span)) | None -> return None }) |> Async.Parallel return spans |> Array.choose id |> Array.toList } - let findReferencedSymbolsAsync(document: Document, position: int, context: IFindUsagesContext, allReferences: bool, userOpName: string) : Async = + let findReferencedSymbolsAsync(document: Document, position: int, context: IFSharpFindUsagesContext, allReferences: bool, userOpName: string) : Async = asyncMaybe { let! sourceText = document.GetTextAsync(context.CancellationToken) |> Async.AwaitTask |> liftAsync let checker = checkerProvider.Checker @@ -60,7 +59,7 @@ type internal FSharpFindUsagesService let! symbol = Tokenizer.getSymbolAtPosition(document.Id, sourceText, position, document.FilePath, defines, SymbolLookupKind.Greedy, false) let! symbolUse = checkFileResults.GetSymbolUseAtLocation(lineNumber, symbol.Ident.idRange.EndColumn, textLine, symbol.FullIsland, userOpName=userOpName) let! declaration = checkFileResults.GetDeclarationLocation (lineNumber, symbol.Ident.idRange.EndColumn, textLine, symbol.FullIsland, false, userOpName=userOpName) |> liftAsync - let tags = GlyphTags.GetTags(Tokenizer.GetGlyphForSymbol (symbolUse.Symbol, symbol.Kind)) + let tags = GlyphTags.GetTags(Microsoft.CodeAnalysis.ExternalAccess.FSharp.FSharpGlyphHelpersObsolete.Convert(Tokenizer.GetGlyphForSymbol (symbolUse.Symbol, symbol.Kind))) let declarationRange = match declaration with @@ -77,14 +76,14 @@ type internal FSharpFindUsagesService return match declarationSpans with | [] -> - [ DefinitionItem.CreateNonNavigableItem( + [ FSharpDefinitionItem.CreateNonNavigableItem( tags, ImmutableArray.Create(TaggedText(TextTags.Text, symbol.Ident.idText)), ImmutableArray.Create(TaggedText(TextTags.Assembly, symbolUse.Symbol.Assembly.SimpleName))) ] | _ -> declarationSpans |> List.map (fun span -> - DefinitionItem.Create(tags, ImmutableArray.Create(TaggedText(TextTags.Text, symbol.Ident.idText)), span)) + FSharpDefinitionItem.Create(tags, ImmutableArray.Create(TaggedText(TextTags.Text, symbol.Ident.idText)), span)) } |> liftAsync for definitionItem in definitionItems do @@ -121,13 +120,13 @@ type internal FSharpFindUsagesService | _ -> for referenceDocSpan in referenceDocSpans do for definitionItem in definitionItems do - let referenceItem = SourceReferenceItem(definitionItem, referenceDocSpan, true) // defaulting to `true` until we can officially determine if this usage is a write + let referenceItem = FSharpSourceReferenceItem(definitionItem, referenceDocSpan) do! context.OnReferenceFoundAsync(referenceItem) |> Async.AwaitTask |> liftAsync () } |> Async.Ignore - interface IFindUsagesService with + interface IFSharpFindUsagesService with member __.FindReferencesAsync(document, position, context) = findReferencedSymbolsAsync(document, position, context, true, userOpName) |> RoslynHelpers.StartAsyncUnitAsTask(context.CancellationToken) diff --git a/vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs b/vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs index f80d10422d3..42d5820d197 100644 --- a/vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs +++ b/vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs @@ -47,9 +47,9 @@ type internal FSharpNavigationBarItemService |> Array.choose (fun decl -> rangeToTextSpan(decl.Range) |> Option.map(fun textSpan -> - NavigationBarSymbolItem(decl.Name, decl.RoslynGlyph, [| textSpan |], null) :> NavigationBarItem)) + NavigationBarSymbolItem(decl.Name, Microsoft.CodeAnalysis.ExternalAccess.FSharp.FSharpGlyphHelpersObsolete.Convert(decl.RoslynGlyph), [| textSpan |], null) :> NavigationBarItem)) - NavigationBarSymbolItem(topLevelDecl.Declaration.Name, topLevelDecl.Declaration.RoslynGlyph, [| topLevelTextSpan |], childItems) + NavigationBarSymbolItem(topLevelDecl.Declaration.Name, Microsoft.CodeAnalysis.ExternalAccess.FSharp.FSharpGlyphHelpersObsolete.Convert(topLevelDecl.Declaration.RoslynGlyph), [| topLevelTextSpan |], childItems) :> NavigationBarItem)) :> IList<_> } |> Async.map (Option.defaultValue emptyResult) diff --git a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj index 8810e56d674..413e40c118a 100644 --- a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj +++ b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj @@ -165,8 +165,6 @@ Roslyn\DocumentHighlightsServiceTests.fs - - PreserveNewest @@ -252,6 +250,7 @@ +