diff --git a/.gitattributes b/.gitattributes
index 7c2555e162..a0b75fde88 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -25,3 +25,11 @@ install-sh text eol=lf
*.in text eol=lf
*.ac text eol=lf
*.sh text eol=lf
+autogen.sh text eol=lf
+launcher.in text eol=lf
+config.make.in text eol=lf
+targets.make text eol=lf
+configure.ac text eol=lf
+Makefile.in text eol=lf
+
+*.bsl linguist-vendored=true
diff --git a/.gitignore b/.gitignore
index ae99f5bc14..97b72c01a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -221,3 +221,9 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll
lib/netcore/fsc/bin/
!lib/bootstrap/signed/**/*
+*/.fake
+/fcs/packages/
+*/paket-files/
+/fcs/TestResult.xml
+/tests/fcs/
+/fcs/.paket/Paket.Restore.targets
diff --git a/.travis.yml b/.travis.yml
index a1302c7d3b..8a57711846 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,12 +4,15 @@ os:
- linux
- osx
+osx_image: xcode9
+
mono:
- weekly
- latest
- 4.8.0
- 4.4.2
+dotnet: 2.0.0
sudo: false
diff --git a/DEVGUIDE.md b/DEVGUIDE.md
index 5abd611460..d7f8318118 100644
--- a/DEVGUIDE.md
+++ b/DEVGUIDE.md
@@ -13,7 +13,15 @@ Follow the instructions below to build and develop the F# Compiler, Core Library
Install
- [.NET 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40779)
-- [MSBuild 12.0](http://www.microsoft.com/en-us/download/details.aspx?id=40760)
+- [MSBuild 12.0](http://www.microsoft.com/en-us/download/details.aspx?id=40760) or Visual Studio 2013 (or later)
+
+**NOTE on Windows:**
+1. It is recommended to run the build.cmd and the qualifiers below on a command prompt with path set to have the location of MSBuild. If we have Visual Studio, we can also run using `Developer Command Prompt for Visual Studio 20xx` (depends on Visual Studio version). This developer command prompt is easier to use than normal command prompt, because it already has the correct path of Visual Studio and .NET's tooling set for us to use (including MSBuild).
+2. The running command prompt must be run under Administrator right (`Run as Administrator`).
+
+Before running the build scripts, ensure that you have cleaned up the visualfsharp repo by running this git command:
+
+ git clean -xfd
On Windows you can build the F# compiler for .NET Framework as follows:
diff --git a/PublishToBlob.proj b/PublishToBlob.proj
new file mode 100644
index 0000000000..9d071710a0
--- /dev/null
+++ b/PublishToBlob.proj
@@ -0,0 +1,29 @@
+
+
+
+
+
+ Microsoft.DotNet.Build.Tasks.Feed
+
+ 1.0.0-prerelease-02121-01
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
deleted file mode 100644
index f153d009f6..0000000000
--- a/RELEASE_NOTES.md
+++ /dev/null
@@ -1,580 +0,0 @@
-#### 13.0.1
- * Move docs --> docssrc
-
-#### 13.0.0
- * Move FSharp.Compiler.Service.MSBuild.v12.dll to a separate nuget package
-
-#### 12.0.8
- * Set bit on output executables correctly
-
-#### 12.0.7
- * Integrate visualfsharp master
-
-#### 12.0.6
- * [758: Fix project cracker when invalid path given](https://github.com/fsharp/FSharp.Compiler.Service/pull/758)
-
-#### 12.0.5
- * Remove dependency on System.ValueTuple
-
-#### 12.0.3
- * [De-duplicate module names again](https://github.com/fsharp/FSharp.Compiler.Service/pull/749)
-
-#### 12.0.2
- * De-duplicate module names
-
-#### 12.0.1
- * [Integrate visualfsharp and fsharp](https://github.com/fsharp/fsharp/pull/696)
-
-#### 11.0.10
- * [Fix F# Interactive on Mono 4.0.9+](https://github.com/fsharp/fsharp/pull/696)
-
-#### 11.0.9
- * [Make incremental builder counter atomic](https://github.com/fsharp/FSharp.Compiler.Service/pull/724)
- * [Add IsValCompiledAsMethod to FSharpMemberOrFunctionOrValue](https://github.com/fsharp/FSharp.Compiler.Service/pull/727)
- * [Check before ILTypeInfo.FromType](https://github.com/fsharp/FSharp.Compiler.Service/issues/734)
- * [Transition over to dotnet cli Fsproj](https://github.com/fsharp/FSharp.Compiler.Service/issues/700)
-
-#### 11.0.8
- * Depend on FSharp.Core package
-
-#### 11.0.6
- * Fix [stack overflow exception](https://github.com/fsharp/FSharp.Compiler.Service/issues/672)
-
-#### 11.0.4
- * Fix [out of range exception](https://github.com/fsharp/FSharp.Compiler.Service/issues/709)
-
-#### 11.0.2
- * Integrate fsharp\fsharp and Microsoft\visualfsharp to 262deb017cfcd0f0d4138779ff42ede7dbf44c46
-
-#### 11.0.1
- * Integrate fsharp\fsharp and Microsoft\visualfsharp to d0cc249b951374257d5a806939e42714d8a2f4c6
-
-#### 10.0.3
- * [Expose assumeDotNetFramework in FSharpChecker.GetProjectOptionsFromScript](https://github.com/fsharp/FSharp.Compiler.Service/pull/699)
- * [SemanticClassificationType should not be internal](https://github.com/fsharp/FSharp.Compiler.Service/pull/696)
-
-#### 10.0.1
- * [Adds FormatValue to FsiEvaluationSession, using the fsi object values for formatting](https://github.com/fsharp/FSharp.Compiler.Service/pull/686)
-
-#### 10.0.0
- * Integrate fsharp\fsharp and Microsoft\visualfsharp to c3e55bf0b10bf08790235dc585b8cdc75f71618e
- * Integrate fsharp\fsharp and Microsoft\visualfsharp to 11c0a085c96a91102cc881145ce281271ac159fe
- * Some API changes for structured text provision for tagged structured text
-
-#### 9.0.0
- * Update names of union fields in AST API
- * Fix load closure for ParseAndCheckInteraction
- * [Fix #631 compiler dependency on MSBuild](https://github.com/fsharp/FSharp.Compiler.Service/pull/657)
- * Fixed netcore codegen on Linux
- * Explicit error when cracker exe is missing
-
-#### 8.0.0
- * Integrate fsharp\fsharp and Microsoft\visualfsharp to c494a9cab525dbd89585f7b733ea5310471a8001
- * Then integrate to 2002675f8aba5b3576a924a2e1e47b18e4e9a83d
- * [Add module values to navigable items](https://github.com/fsharp/FSharp.Compiler.Service/pull/650)
- * Optionally remove dependency on MSBuild reference resolution https://github.com/fsharp/FSharp.Compiler.Service/pull/649
- * [Compiler api harmonise](https://github.com/fsharp/FSharp.Compiler.Service/pull/639)
- * Various bits of work on .NET Core version (buildable from source but not in nuget package)
-
-#### 7.0.0
- * Integrate fsharp\fsharp and Microsoft\visualfsharp to 835b79c041f9032fceeceb39f680e0662cba92ec
-
-#### 6.0.2
- * [Fix #568: recognize provided expressions](https://github.com/fsharp/FSharp.Compiler.Service/pull/568)
-
-#### 6.0.1
- * [Fix ProjectFileNames order when getting project options from script](https://github.com/fsharp/FSharp.Compiler.Service/pull/594)
-
-#### 6.0.0
- * Switch to new major version on assumption integrated F# compiler changes induce API change
-
-#### 5.0.2
- * Integrate Microsoft\visualfsharp to 688c26bdbbfc766326fc45e4d918f87fcba1e7ba. F# 4.1 work
-
-#### 5.0.1
-* [Fixed dependencies in nuget package](https://github.com/fsharp/FSharp.Compiler.Service/pull/608)
-
-#### 5.0.0
-* Fixed empty symbol declared pdb #564 from kekyo/fix-empty-pdb
-* .NET Core ProjectCracker - updated version and dependencies
-* Properly embed 'FSIstrings' resource, fixes #591
-* make build.sh work on windows (git bash).
-* Added default script references for .NET Core
-* Store useMonoResolution flag
-* Updated MSBuild version
-* Assume FSharp.Core 4.4.0.0
-
-#### 4.0.1
-* Integrate Microsoft\visualfsharp and fsharp\fsharp to master (including portable PDB)
-* Remove .NET Framework 4.0 support (now needs .NET Framework 4.5)
-
-#### 4.0.0
-* Integrate Microsoft\visualfsharp and fsharp\fsharp to master
-
-#### 3.0.0.0
-* #538 - BackgroundCompiler takes a very long time on a big solution with a very connected project dependency graph
-* #544 - Losing operator call when one of operands is application of a partially applied function
-* #534 - Function valued property erasing calls
-* #495 - Detupling missing when calling a module function value
-* #543 - Tuple not being destructured in AST
-* #541 - Results of multiple calls to active pattern are always bound to variable with same name
-* #539 - BasicPatterns.NewDelegate shows same value for different arguments
-
-#### 2.0.0.6
-* #530 - Adjust ProjectCracker NuGet for VS/NuGet
-
-#### 2.0.0.5
-* #527 - Provide API that includes printf specifier arities along with ranges
-
-#### 2.0.0.4
-* #519 - Change nuget layout for ProjectCracker package
-* #523 - Project cracking: spaces in file paths
-
-#### 2.0.0.3
-* #508 - Integrate visualfsharp/master removal of Silverlight #if
-* #513 - Make CrackerTool `internal` to prevent accidental usage
-* #515 - Add simple Visual Studio version detection for project cracker
-
-#### 2.0.0.2
-* Integrate visualfsharp/master and fsharp/master --> master
-* Expose QualifiedName and FileName of FSharpImplementationFileContents
-* Add FSharpErrorInfo.ErrorNumber
-
-#### 2.0.0.1-beta
-* Fix 452 - FSharpField.IsMutable = true for BCL enum cases
-* Fix 414 - Add IsInstanceMemberInCompiledCode
-
-#### 2.0.0.0-beta
-* Feature #470, #478, #479 - Move ProjectCracker to separate nuget package and DLL, used ProjectCrackerTool.exe to run
-* Feature #463 - Expose slot signatures of members in object expressions
-* Feature #469, #475 - Add EvalExpressionNonThrowing, EvalInteractionNonThrowing, EvalScriptNonThrowing
-* Fix #456 - FCS makes calls to kernel32.dll when running on OSX
-* Fix #473 - stack overflow in resolution logic
-* Fix #460 - Failure getting expression for a provided method call
-
-#### 1.4.2.3 -
-* Fix bug in loop optimization, apply https://github.com/Microsoft/visualfsharp/pull/756/
-
-#### 1.4.2.2 -
-* #488 - Performance problems with project references
-
-#### 1.4.2.1 -
-* #450 - Correct generation of ReferencedProjects
-
-#### 1.4.2.0 -
-* Fix bug in double lookup of cache, see https://github.com/fsharp/FSharp.Compiler.Service/pull/447
-
-#### 1.4.1 -
-* Add pause before backgrounnd work starts. The FCS request queue must be empty for 1 second before work will start
-* Write trace information about the reactor queue to the event log
-* Rewrite reactor to consistently prioritize queued work
-* Implement cancellation for queued work if it is cancelled prior to being executed
-* Adjust caching to check cache correctly if there is a gap before the request is executed
-
-#### 1.4.0.9 -
-* FSharpType.Format fix
-* Disable maximum-memory trigger by default until use case ironed out
-
-#### 1.4.0.8 -
-* FSharpType.Format now prettifies type variables. If necessary, FSharpType.Prettify can also be called
-* Add maximum-memory trigger to downsize FCS caches. Defaults to 1.7GB of allocaed memory in the system
- process for a 32-bit process, and 2x this for a 64-bit process
-
-#### 1.4.0.7 -
-* fix 427 - Make event information available for properties which represent first-class uses of F#-declared events
-* fix 410 - Symbols for C# fields (and especially enum fields)
-* Expose implemented abstract slots
-* Fix problem with obscure filenames caught by Microsoft\visualfsharp tests
-* Integrate with visualfsharp master
-
-#### 1.4.0.6 -
-* fix 423 - Symbols for non-standard C# events
-* fix 235 - XmlDocSigs for references assemblies
-* fix 177 - GetAllUsesOfAllSymbolsInFile returns nothing for C# nested enum
-* make Internal.Utilities.Text.Lexing.Position a struct
-* Exposing assembly attributes on FSharpAssemblySignature
-* clean up IncrementalFSharpBuild.frameworkTcImportsCache
-
-#### 1.4.0.5 -
-* add more entries to FSharpTokenTag
-
-#### 1.4.0.4 -
-* add more entries to FSharpTokenTag
-* add PrettyNaming.QuoteIdentifierIfNeeded and PrettyNaming.KeywordNames
-
-#### 1.4.0.3 -
-* integrate Microsoft/visualfsharp OOB cleanup via fsharp/fsharp
-* Make Parser and Lexer private
-
-#### 1.4.0.2 -
-* #387 - types and arrays in F# attribute contructor arguments
-
-#### 1.4.0.1 - F# 4.0 support
-* Use FSharp.Core 4.4.0.0 by default for scripting scenarios if not FSharp.Core referenced by host process
-
-#### 1.4.0.0-beta - F# 4.0 support
-* Integrate F# 4.0 support into FSharp.Compiler.Service
-
-#### 1.3.1.0 -
-* simplified source indexing with new SourceLink
-* Add noframework option in AST compiler methods
-
-#### 0.0.90 -
-* Add fix for #343 Use ResolveReferences task
-* Expose BinFolderOfDefaultFSharpCompiler to editors
-* Fix the registry checking on mono to avoid unnecessary exceptions being thrown
-
-#### 0.0.89 -
-* Fix output location of referenced projects
-
-#### 0.0.88 -
-* Added Fix to allow implicit PCL references to be retrieved
-
-#### 0.0.87 -
-* Don't report fake symbols in indexing #325
-* Add EnclosingEntity for an active pattern group #327
-* Add ImmediateSubExpressions #284
-* integrate fsharp/fsharp master into master
-
-#### 0.0.85 -
-* Fix for FSharpSymbolUse for single case union type #301
-* Added supprt for ReturnParameter in nested functions
-
-#### 0.0.84 -
-* Added curried parameter groups for nested functions
-
-#### 0.0.83 -
-* Add Overloads to the symbols signature so it is publicly visible
-* Update OnEvaluation event to have FSharpSymbolUse information available
-
-#### 0.0.82 -
-* Better support for Metadata of C# (and other) Assemblies.
-* Expose the DefaultFileSystem as a type instead of anonymous
-
-#### 0.0.81 -
-* Update GetDeclarationListSymbols to expose FSharpSymbolUse
-* Improve reporting of format specifiers
-
-#### 0.0.80 -
-* Update to latest F# 3.1.3 (inclunding updated FsLex/FsYacc used in build of FCS)
-* Report printf specifiers from Service API
-* Improve Accessibility of non-F# symbols
-
-#### 0.0.79 -
-* Do not use memory mapped files when cracking a DLL to get an assembly reference
-* Fix for multilanguage projects in project cracker
-
-#### 0.0.78 -
-* Reduce background checker memory usage
-* add docs on FSharp.Core
-* docs on caches and queues
-
-#### 0.0.77 -
-* Update to github.com/fsharp/fsharp 05f426cee85609f2fe51b71473b07d7928bb01c8
-
-#### 0.0.76 -
-* Fix #249 - Fix TryFullName when used on namespaces of provided erased type definitions
-* Add OnEvaluation event to FCS to allow detailed information to be exposed
-
-#### 0.0.75 -
-* Do not use shared cursor for IL binaries (https://github.com/fsprojects/VisualFSharpPowerTools/issues/822)
-
-#### 0.0.74 -
-* Extension members are returned as members of current modules
-* Fix exceptions while cross-reference a type provider project
-
-#### 0.0.73 -
-* Add AssemblyContents and FSharpExpr to allow access to resolved, checked expression trees
-* Populate ReferencedProjects using ProjectFileInfo
-* Fix finding symbols declared in signature files
-* Add logging to project cracking facility
-
-#### 0.0.72 -
-* Allow project parser to be used on project file with relative paths
-* Expose attributes for non-F# symbols
-
-#### 0.0.71 -
-* More renamings in SourceCodeServices API for more consistent use of 'FSharp' prefix
-
-#### 0.0.70 -
-* Make FSharpProjectFileParser public
-* Fixes to project parser for Mono (.NET 4.0 component)
-* Renamings in SourceCodeServices API for more consistent use of 'FSharp' prefix
-
-#### 0.0.67 -
-* Fixes to project parser for Mono
-
-#### 0.0.66 -
-* Fixes to project parser for Mono
-* Use MSBuild v12.0 for reference resolution on .NET 4.5+
-
-#### 0.0.65 -
-* Fixes to project parser
-
-#### 0.0.64 -
-* Add project parser, particularly GetProjectOptionsFromProjectFile
-
-#### 0.0.63 -
-* #221 - Normalize return types of .NET events
-
-#### 0.0.62 -
-* Integrate to latest http://github.com/fsharp/fsharp (#80f9221f811217bd890b3a670d717ebc510aeeaf)
-
-#### 0.0.61 -
-* #216 - Return associated getters/setters from F# properties
-* #214 - Added missing XmlDocSig for FSharpMemberOrFunctionOrValue's Events, Methods and Properties
-* #213 - Retrieve information for all active pattern cases
-* #188 - Fix leak in file handles when using multiple instances of FsiEvaluationSession, and add optionally collectible assemblies
-
-#### 0.0.60 -
-* #207 - Add IsLiteral/LiteralValue to FSharpField
-* #205 - Add IsOptionalArg and related properties to FSharpParameter
-* #210 - Check default/override members via 'IsOverrideOrExplicitMember'
-* #209 - Add TryFullName to FSharpEntity
-
-#### 0.0.59 -
-* Fix for #184 - Fix EvalScript by using verbatim string for #Load
-* Fix for #183 - The line no. reporting is still using 0-based indexes in errors. This is confusing.
-
-#### 0.0.58 -
-* Fix for #156 - The FSharp.Core should be retrieved from the hosting environment
-
-#### 0.0.57 -
-* Second fix for #160 - Nuget package now contains .NET 4.0 and 4.5
-
-#### 0.0.56 -
-* Fix for #160 - Nuget package contains .NET 4.0 and 4.5
-
-#### 0.0.55 -
-* Integrate changes for F# 3.1.x, Fix #166
-
-#### 0.0.54 -
-* Fix for #159 - Unsubscribe from TP Invalidate events when disposing builders
-
-#### 0.0.53 -
-* Add queue length to InteractiveChecker
-
-#### 0.0.52 -
-* Fix caches keeping hold of stale entries
-
-#### 0.0.51 -
-* Add IsAccessible to FSharpSymbol, and ProjectContext.AccessibilityRights to give the context of an access
-
-#### 0.0.50 -
-* Fix #79 - FindUsesOfSymbol returns None at definition of properties with explicit getters and setters
-
-#### 0.0.49 -
-* Fix #138 - Fix symbol equality for provided type members
-* Fix #150 - Return IsGetterMethod = true for declarations of F# properties (no separate 'property' symbol is yet returned, see #79)
-* Fix #132 - Add IsStaticInstantiation on FSharpEntity to allow clients to detect fake symbols arising from application of static parameters
-* Fix #154 - Add IsArrayType on FSharpEntity to allow clients to detect the symbols for array types
-* Fix #96 - Return resolutions of 'Module' and 'Type' in "Module.field" and "Type.field"
-
-#### 0.0.48 -
-* Allow own fsi object without referencing FSharp.Compiler.Interactive.Settings.dll (#127)
-
-#### 0.0.47 -
-* Adjust fix for #143 for F# types with abstract+default events
-
-#### 0.0.46 -
-* Fix multi-project analysis when referenced projects have changed (#141)
-* Fix process exit on bad arguments to FsiEvaluationSession (#126)
-* Deprecate FsiEvaluationSession constructor and add FsiEvaluationSession.Create static method to allow for future API that can return errors
-* Return additional 'property' and 'event' methods for F#-defined types to regularize symbols (#108, #143)
-* Add IsPropertySetterMethod and IsPropertyGetterMethod which only return true for getter/setter methods, not properties. Deprecate IsSetterMethod and IsGetterMethod in favour of these.
-* Add IsEventAddMethod and IsEventRemoveMethod which return true for add/remove methods with an associated event
-* Change IsProperty and IsEvent to only return true for the symbols for properties and events, rather than the methods assocaited with these
-* Fix value of Assembly for some symbols (e.g. property symbols)
-
-#### 0.0.45 -
-* Add optional project cache size parameter to InteractiveChecker
-* Switch to openBinariesInMemory for SimpleSourceCodeServices
-* Cleanup SimpleSourceCodeServices to avoid code duplication
-
-#### 0.0.44 -
-* Integrate latest changes from visualfsharp.codeplex.com via github.com/fsharp/fsharp
-* Fix problem with task that generates description text of declaration
-* Add AllInterfaceTypes to FSharpEntity and FSharpType
-* Add BaseType to FSharpType to propagate instantiation
-* Add Instantiate to FSharpType
-
-#### 0.0.43 -
-* Fix #109 - Duplicates in GetUsesOfSymbolInFile
-
-#### 0.0.42 -
-* Fix #105 - Register enum symbols in patterns
-* Fix #107 - Return correct results for inheritance chain of .NET types
-* Fix #101 - Add DeclaringEntity property
-
-#### 0.0.41 -
-* Fixed #104 - Make all operations that may utilize the FCS reactor async
-* Add FSharpDisplayContext and FSharpType.Format
-* Replace GetSymbolAtLocationAlternate by GetSymbolUseAtLocation
-
-#### 0.0.40 -
-* Fixed #86 - Expose Microsoft.FSharp.Compiler.Interactive.Shell.Settings.fsi
-* Fixed #99 - Add IsNamespace property to FSharpEntity
-
-#### 0.0.39 -
-* Fixed #79 - Usage points for symbols in union patterns
-
-#### 0.0.38 -
-* Fixed #94 and #89 by addition of new properties to the FSharpSymbolUse type
-* Fixed #93 by addition of IsOpaque to FSharpEntity type
-* Fixed #92 - Issue with nested classes
-* Fixed #87 - Allow analysis of members from external assemblies
-
-#### 0.0.37 -
-* Obsolete HasDefaultValue - see https://github.com/fsharp/FSharp.Compiler.Service/issues/77
-
-#### 0.0.36 -
-* Fix #71 - Expose static parameters and xml docs of type providers
-* Fix #63 - SourceCodeServices: #r ignores include paths passed as command-line flags
-
-#### 0.0.35 -
-* Fix #38 - FSharp.Compiler.Services should tolerate an FSharp.Core without siginfo/optdata in the search path
-
-
-#### 0.0.34 -
-* Add StaticParameters property to entities, plus FSharpStaticParameter symbol
-* Fix #65
-
-#### 0.0.33 -
-* Add FullName and Assembly properties for symbols
-* Fix #76
-* Add Japanese documentation
-
-#### 0.0.32 -
-* Make ParseFileInProject asynchronous
-* Add ParseAndCheckFileInProject
-* Use cached results in ParseAndCheckFileInProject if available
-
-#### 0.0.31 -
-* Fix performance problem with CheckFileInProject
-
-#### 0.0.30 -
-* Add initial prototype version of multi-project support, through optional ProjectReferences in ProjectOptions. Leave this empty
- to use DLL/file-based references to results from other projects.
-
-#### 0.0.29 -
-* Fix symbols for named union fields in patterns
-
-#### 0.0.28 -
-* Fix symbols for named union fields
-* Add FSharpActivePatternCase to refine FSharpSymbol
-
-#### 0.0.27 -
-* Fix exception tag symbol reporting
-
-#### 0.0.26 -
-* Fix off-by-one in reporting of range for active pattern name
-
-#### 0.0.25 -
-* Add optional source argument to TryGetRecentTypeCheckResultsForFile to specify that source must match exactly
-
-#### 0.0.24 -
-* Update version number as nuget package may not have published properly
-
-#### 0.0.23 -
-* Move to one-based line numbering everywhere
-* Provide better symbol information for active patterns
-
-#### 0.0.22 -
-* Provide symbol location for type parameters
-
-#### 0.0.21 -
-* Add GetUsesOfSymbolInFile
-* Better symbol resolution results for type parameter symbols
-
-#### 0.0.20 -
-* Update version number as nuget package may not have published properly
-
-#### 0.0.19 -
-* Change return type of GetAllUsesOfSymbol, GetAllUsesOfAllSymbols and GetAllUsesOfAllSymbolsInFile to FSharpSymbolUse
-* Add symbol uses when an abstract member is implemented.
-
-#### 0.0.18 -
-* Add GetAllUsesOfAllSymbols and GetAllUsesOfAllSymbolsInFile
-
-#### 0.0.17 -
-* Improvements to symbol accuracy w.r.t. type abbreviations
-
-#### 0.0.16 -
-* Make FSharpEntity.BaseType return an option
-* FsiSesion got a new "EvalScript" method which allows to evaluate .fsx files
-
-#### 0.0.15 -
-* Update version number as nuget package may not have published properly
-
-#### 0.0.14 -
-* Update version number as nuget package may not have published properly
-
-#### 0.0.13-alpha -
-* Fix #39 - Constructor parameters are mistaken for record fields in classes
-
-#### 0.0.12-alpha -
-* Make the parts of the lexer/parser used by 'XmlDoc' tools in F# VS Power tools public
-
-#### 0.0.11-alpha -
-* Add 'IsUnresolved'
-
-#### 0.0.10-alpha -
-* Fix bug where 'multiple references to FSharp.Core' was given as error for scripts
-
-#### 0.0.9-alpha -
-* Fix fsc corrupting assemblies when generating pdb files (really)
-* Give better error messages for missing assemblies
-* Report more information about symbols returned by GetSymbolAtLocation (through subtypes)
-* Fix typos in docs
-* Return full project results from ParseAndCheckInteraction
-* Be more robust to missing assembly references by default.
-
-#### 0.0.8-alpha -
-* Fix fsc corrupting assemblies when generating pdb files
-
-#### 0.0.7-alpha -
-* Fix docs
-* Make symbols more robust to missing assemblies
-* Be robust to failures on IncrementalBuilder creation
-* Allow use of MSBuild resolution by IncrementalBuilder
-
-#### 0.0.6-alpha -
-* Fix version number
-
-#### 0.0.5-alpha -
-* Added GetUsesOfSymbol(), FSharpSymbol type, GetSymbolAtLocation(...)
-
-#### 0.0.4-alpha -
-* Added documentation of file system API
-* Reporte errors correctly from ParseAndCheckProject
-
-
-#### 0.0.3-alpha -
-* Integrate FSharp.PowerPack.Metadata as the FSharp* symbol API
-* Renamed Param --> MethodGroupItemParameter and hid record from view, made into an object
-* Renamed Method --> MethodGroupItem and hid record from view, made into an object
-* Renamed Methods --> MethodGroup and hid record from view, made into an object
-* Renamed MethodGroup.Name --> MethodGroup.MethodName
-* Renamed DataTip --> ToolTip consistently across all text
-* Renamed CheckOptions --> ProjectOptions
-* Renamed TypeCheckAnswer --> CheckFileAnswer
-* Renamed UntypedParseInfo --> ParseFileResults
-* Removed GetCheckOptionsFromScriptRoot member overload in favour of optional argument
-* Renamed GetCheckOptionsFromScriptRoot --> GetProjectOptionsFromScript
-* Renamed UntypedParse --> ParseFileInProject
-* Renamed TypeCheckSource --> CheckFileInProjectIfReady
-* Added numerous methods to API including CheckFileInProject
-* Added experimental GetBackgroundCheckResultsForFileInProject, GetBackgroundParseResultsForFileInProject
-* Added PartialAssemblySignature to TypeCheckResults/CheckFileResults
-* Added CurrentPartialAssemblySignature to FsiEvaluationSession
-* Added ParseAndCheckInteraction to FsiEvaluationSession to support intellisense implementation against a script fragment
-* Added initial testing in tests/service
-* Added ParseAndCheckProject to SourceCodeServices API. This will eventually return "whole project" information such as symbol tables.
-* Added GetDefaultConfiguration to simplify process of configuring FsiEvaluationSession
-* Added PartialAssemblySignatureUpdated event to FsiEvaluationSession
-* Added travis build
-
-#### 0.0.2-alpha -
-* Integrate hosted FSI configuration, SimpleSourceCodeServices, cleanup to SourceCodeServices API
-
-
diff --git a/fcs/.paket/Paket.Restore.targets b/fcs/.paket/Paket.Restore.targets
index 920482ad21..1a326ea13e 100644
--- a/fcs/.paket/Paket.Restore.targets
+++ b/fcs/.paket/Paket.Restore.targets
@@ -30,7 +30,7 @@
true
-
+
@@ -84,11 +84,11 @@
-
+
-
+
@@ -136,15 +136,21 @@
+
+ <_NuspecFilesNewLocation Include="$(BaseIntermediateOutputPath)$(Configuration)/*.nuspec"/>
+
+
$(MSBuildProjectDirectory)/$(MSBuildProjectFile)truefalsetrue
+ $(BaseIntermediateOutputPath)$(Configuration)/
+ $(BaseIntermediateOutputPath)
- <_NuspecFiles Include="$(BaseIntermediateOutputPath)*.nuspec"/>
+ <_NuspecFiles Include="$(AdjustedNuspecOutputPath)*.nuspec"/>
@@ -188,7 +194,7 @@
Serviceable="$(Serviceable)"
FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)"
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
- NuspecOutputPath="$(BaseIntermediateOutputPath)"
+ NuspecOutputPath="$(AdjustedNuspecOutputPath)"
IncludeBuildOutput="$(IncludeBuildOutput)"
BuildOutputFolder="$(BuildOutputTargetFolder)"
ContentTargetFolders="$(ContentTargetFolders)"
@@ -230,7 +236,7 @@
Serviceable="$(Serviceable)"
AssemblyReferences="@(_References)"
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
- NuspecOutputPath="$(BaseIntermediateOutputPath)"
+ NuspecOutputPath="$(AdjustedNuspecOutputPath)"
IncludeBuildOutput="$(IncludeBuildOutput)"
BuildOutputFolder="$(BuildOutputTargetFolder)"
ContentTargetFolders="$(ContentTargetFolders)"
diff --git a/fcs/.paket/paket.bootstrapper.exe b/fcs/.paket/paket.bootstrapper.exe
deleted file mode 100644
index 64fdf248bf..0000000000
Binary files a/fcs/.paket/paket.bootstrapper.exe and /dev/null differ
diff --git a/fcs/.paket/paket.exe b/fcs/.paket/paket.exe
new file mode 100644
index 0000000000..ef3ea32af2
Binary files /dev/null and b/fcs/.paket/paket.exe differ
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 e929138c56..f66cda2f77 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
@@ -89,4 +89,4 @@
-
\ No newline at end of file
+
diff --git a/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs
index 45fab18685..7a36085de0 100644
--- a/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs
+++ b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs
@@ -8,18 +8,17 @@ open System.Diagnostics
open System.Text
open System.IO
open System
+open System.Xml
-type ProjectCracker =
- static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) =
- let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
- let properties = defaultArg properties []
- let enableLogging = defaultArg enableLogging true
+module Utils =
+
+ let Convert loadedTimeStamp (originalOpts: ProjectCrackerTool.ProjectOptions) =
let logMap = ref Map.empty
- let rec convert (opts: ProjectCrackerTool.ProjectOptions) : FSharpProjectOptions =
+ let rec convertProject (opts: ProjectCrackerTool.ProjectOptions) =
if not (isNull opts.Error) then failwith opts.Error
- let referencedProjects = Array.map (fun (a, b) -> a, convert b) opts.ReferencedProjectOptions
+ let referencedProjects() = Array.map (fun (a, b) -> a,convertProject b) opts.ReferencedProjectOptions
let sourceFiles, otherOptions =
opts.Options
@@ -41,7 +40,7 @@ type ProjectCracker =
{ ProjectFileName = opts.ProjectFile
SourceFiles = sourceFiles
OtherOptions = otherOptions
- ReferencedProjects = referencedProjects
+ ReferencedProjects = referencedProjects()
IsIncompleteTypeCheckEnvironment = false
UseScriptResolutionRules = false
LoadTime = loadedTimeStamp
@@ -50,6 +49,16 @@ type ProjectCracker =
ExtraProjectInfo = None
Stamp = None }
+ convertProject originalOpts, !logMap
+
+type ProjectCracker =
+
+ static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) =
+ let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
+ let properties = defaultArg properties []
+ let enableLogging = defaultArg enableLogging true
+
+
#if NETSTANDARD1_6
let arguments = [|
yield projectFileName
@@ -70,20 +79,47 @@ type ProjectCracker =
let codebase = Path.GetDirectoryName(Uri(typeof.Assembly.CodeBase).LocalPath)
let crackerFilename = Path.Combine(codebase,"FSharp.Compiler.Service.ProjectCrackerTool.exe")
- if not (File.Exists crackerFilename) then failwithf "ProjectCracker exe not found at: %s it must be next to the ProjectCracker dll." crackerFilename
+ if not (File.Exists crackerFilename) then
+ failwithf "ProjectCracker exe not found at: %s it must be next to the ProjectCracker dll." crackerFilename
+
let p = new System.Diagnostics.Process()
+
p.StartInfo.FileName <- crackerFilename
p.StartInfo.Arguments <- arguments.ToString()
p.StartInfo.UseShellExecute <- false
p.StartInfo.CreateNoWindow <- true
p.StartInfo.RedirectStandardOutput <- true
+ p.StartInfo.RedirectStandardError <- true
+
+ let sbOut = StringBuilder()
+ let sbErr = StringBuilder()
+
+ p.ErrorDataReceived.AddHandler(fun _ a -> sbErr.AppendLine a.Data |> ignore)
+ p.OutputDataReceived.AddHandler(fun _ a -> sbOut.AppendLine a.Data |> ignore)
+
ignore <| p.Start()
- let ser = new DataContractJsonSerializer(typeof)
- let opts = ser.ReadObject(p.StandardOutput.BaseStream) :?> ProjectCrackerTool.ProjectOptions
+ p.EnableRaisingEvents <- true
+ p.BeginOutputReadLine()
+ p.BeginErrorReadLine()
+
+ p.WaitForExit()
+
+ let crackerOut = sbOut.ToString()
+ let crackerErr = sbErr.ToString()
+
+ let opts =
+ try
+ let ser = new DataContractJsonSerializer(typeof)
+ let stringBytes = Encoding.Unicode.GetBytes crackerOut
+ use ms = new MemoryStream(stringBytes)
+ ser.ReadObject(ms) :?> ProjectCrackerTool.ProjectOptions
+ with
+ exn ->
+ raise (Exception(sprintf "error parsing ProjectCrackerTool output, stdoutput was:\n%s\n\nstderr was:\n%s" crackerOut crackerErr, exn))
#endif
- convert opts, !logMap
+ Utils.Convert loadedTimeStamp opts
static member GetProjectOptionsFromProjectFile(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp) =
fst (ProjectCracker.GetProjectOptionsFromProjectFileLogged(
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 07bae7e576..66d196a1d5 100644
--- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj
+++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj
@@ -46,24 +46,9 @@
+
-
- $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll
- false
-
-
- $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll
- false
-
-
- $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll
- false
-
-
- $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Utilities.v12.0.dll
- false
-
@@ -71,13 +56,75 @@
-
$(FSharpSourcesRoot)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dllfalse
-
+
+
+
+
+ ..\packages\Microsoft.Build\lib\net45\Microsoft.Build.dll
+ True
+ True
+
+
+
+
+
+
+
+
+ ..\packages\Microsoft.Build.Engine\lib\net45\Microsoft.Build.Engine.dll
+ True
+ True
+
+
+
+
+
+
+
+
+ ..\packages\Microsoft.Build.Framework\lib\net45\Microsoft.Build.Framework.dll
+ True
+ True
+
+
+
+
+
+
+
+
+ ..\packages\Microsoft.Build.Utilities.Core\lib\net45\Microsoft.Build.Utilities.Core.dll
+ True
+ True
+
+
+
+
+
+
+
+
+ True
+
+
+
+
+
+
+
+
+ ..\packages\System.Threading.Tasks.Dataflow\lib\portable-net45+win8+wpa81\System.Threading.Tasks.Dataflow.dll
+ True
+ True
+
+
+
+
\ No newline at end of file
diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs
index ed8a8b1599..7ce360c312 100644
--- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs
+++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs
@@ -1,21 +1,46 @@
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
open System
-open System.IO
+open System.Reflection
open System.Runtime.Serialization.Json
module Program =
- []
- let main argv =
- let text = Array.exists (fun (s: string) -> s = "--text") argv
- let argv = Array.filter (fun (s: string) -> s <> "--text") argv
+#if !DOTNETCORE
+ let addMSBuildv14BackupResolution () =
+ let onResolveEvent = new ResolveEventHandler(fun sender evArgs ->
+ let requestedAssembly = AssemblyName(evArgs.Name)
+ if requestedAssembly.Name.StartsWith("Microsoft.Build") &&
+ not (requestedAssembly.Name.EndsWith(".resources")) &&
+ not (requestedAssembly.Version.ToString().Contains("12.0.0.0"))
+ then
+ // If the version of MSBuild that we're using wasn't present on the machine, then
+ // just revert back to 12.0.0.0 since that's normally installed as part of the .NET
+ // Framework.
+ requestedAssembly.Version <- Version("12.0.0.0")
+ Assembly.Load requestedAssembly
+ else
+ null)
+ AppDomain.CurrentDomain.add_AssemblyResolve(onResolveEvent)
+#endif
+ let crackAndSendOutput asText argv =
let ret, opts = ProjectCrackerTool.crackOpen argv
- if text then
+ if asText then
printfn "%A" opts
else
let ser = new DataContractJsonSerializer(typeof)
ser.WriteObject(Console.OpenStandardOutput(), opts)
ret
+
+
+ [][]
+ let main argv =
+ let asText = Array.exists (fun (s: string) -> s = "--text") argv
+ let argv = Array.filter (fun (s: string) -> s <> "--text") argv
+
+#if !DOTNETCORE
+ addMSBuildv14BackupResolution ()
+#endif
+ crackAndSendOutput asText argv
diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs
index 9be9c37537..a20c7a33c0 100644
--- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs
+++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs
@@ -2,12 +2,13 @@
open System
open System.IO
-open System.Reflection
open System.Text
open Microsoft.Build.Framework
open Microsoft.Build.Utilities
module internal ProjectCrackerTool =
+ open System.Collections.Generic
+ open Microsoft.Build.Evaluation
let runningOnMono =
#if DOTNETCORE
@@ -36,17 +37,159 @@ module internal ProjectCrackerTool =
member th.Compile(_:obj, _:obj, _:obj) = 0
interface ITaskHost
+ let vs =
+ let programFiles =
+ let getEnv v =
+ let result = System.Environment.GetEnvironmentVariable(v)
+ match result with
+ | null -> None
+ | _ -> Some result
+
+ match List.tryPick getEnv [ "ProgramFiles(x86)"; "ProgramFiles" ] with
+ | Some r -> r
+ | None -> "C:\\Program Files (x86)"
+
+ let vsVersions = ["14.0"; "12.0"]
+ let msbuildBin v = IO.Path.Combine(programFiles, "MSBuild", v, "Bin", "MSBuild.exe")
+ List.tryFind (fun v -> IO.File.Exists(msbuildBin v)) vsVersions
+
+ let mkAbsolute dir v =
+ if Path.IsPathRooted v then v
+ else Path.Combine(dir, v)
+
+ let mkAbsoluteOpt dir v = Option.map (mkAbsolute dir) v
+
+ let CrackProjectUsingNewBuildAPI fsprojFile properties logOpt =
+ let fsprojFullPath = try Path.GetFullPath(fsprojFile) with _ -> fsprojFile
+ let fsprojAbsDirectory = Path.GetDirectoryName fsprojFullPath
+
+ use _pwd =
+ let dir = Directory.GetCurrentDirectory()
+ Directory.SetCurrentDirectory(fsprojAbsDirectory)
+ { new System.IDisposable with
+ member x.Dispose() = Directory.SetCurrentDirectory(dir) }
+ use engine = new Microsoft.Build.Evaluation.ProjectCollection()
+ let host = new HostCompile()
+
+ engine.HostServices.RegisterHostObject(fsprojFullPath, "CoreCompile", "Fsc", host)
+
+ let projectInstanceFromFullPath (fsprojFullPath: string) =
+ use file = new FileStream(fsprojFullPath, FileMode.Open, FileAccess.Read, FileShare.Read)
+ use stream = new StreamReader(file)
+ use xmlReader = System.Xml.XmlReader.Create(stream)
+
+ let project =
+ try
+ engine.LoadProject(xmlReader, FullPath=fsprojFullPath)
+ with
+ | exn ->
+ let tools = engine.Toolsets |> Seq.map (fun x -> x.ToolsPath) |> Seq.toList
+ raise (new Exception(sprintf "Could not load project %s in ProjectCollection. Available tools: %A. Message: %s" fsprojFullPath tools exn.Message))
+
+ project.SetGlobalProperty("BuildingInsideVisualStudio", "true") |> ignore
+ if not (List.exists (fun (p,_) -> p = "VisualStudioVersion") properties) then
+ match vs with
+ | Some version -> project.SetGlobalProperty("VisualStudioVersion", version) |> ignore
+ | None -> ()
+ project.SetGlobalProperty("ShouldUnsetParentConfigurationAndPlatform", "false") |> ignore
+ for (prop, value) in properties do
+ project.SetGlobalProperty(prop, value) |> ignore
+
+ project.CreateProjectInstance()
+
+ let project = projectInstanceFromFullPath fsprojFullPath
+ let directory = project.Directory
+
+ let getprop (p: Microsoft.Build.Execution.ProjectInstance) s =
+ let v = p.GetPropertyValue s
+ if String.IsNullOrWhiteSpace v then None
+ else Some v
+
+ let outFileOpt = getprop project "TargetPath"
+
+ let log = match logOpt with
+ | None -> []
+ | Some l -> [l :> ILogger]
+
+ project.Build([| "Build" |], log) |> ignore
+
+ let getItems s = [ for f in project.GetItems(s) -> mkAbsolute directory f.EvaluatedInclude ]
+
+ let projectReferences =
+ [ for cp in project.GetItems("ProjectReference") do
+ yield cp.GetMetadataValue("FullPath")
+ ]
+
+ let references =
+ [ for i in project.GetItems("ReferencePath") do
+ yield i.EvaluatedInclude
+ for i in project.GetItems("ChildProjectReferences") do
+ yield i.EvaluatedInclude ]
+
+ outFileOpt, directory, getItems, references, projectReferences, getprop project, project.FullPath
+
+#if !DOTNETCORE
+ let CrackProjectUsingOldBuildAPI (fsprojFile:string) properties logOpt =
+ let engine = new Microsoft.Build.BuildEngine.Engine()
+ Option.iter (fun l -> engine.RegisterLogger(l)) logOpt
+
+ let bpg = Microsoft.Build.BuildEngine.BuildPropertyGroup()
+
+ bpg.SetProperty("BuildingInsideVisualStudio", "true")
+ for (prop, value) in properties do
+ bpg.SetProperty(prop, value)
+
+ engine.GlobalProperties <- bpg
+
+ let projectFromFile (fsprojFile:string) =
+ // We seem to need to pass 12.0/4.0 in here for some unknown reason
+ let project = new Microsoft.Build.BuildEngine.Project(engine, engine.DefaultToolsVersion)
+ do project.Load(fsprojFile)
+ project
+
+ let project = projectFromFile fsprojFile
+ project.Build([| "ResolveReferences" |]) |> ignore
+ let directory = Path.GetDirectoryName project.FullFileName
+
+ let getProp (p: Microsoft.Build.BuildEngine.Project) s =
+ let v = p.GetEvaluatedProperty s
+ if String.IsNullOrWhiteSpace v then None
+ else Some v
+
+ let outFileOpt =
+ match mkAbsoluteOpt directory (getProp project "OutDir") with
+ | None -> None
+ | Some d -> mkAbsoluteOpt d (getProp project "TargetFileName")
+
+ let getItems s =
+ let fs = project.GetEvaluatedItemsByName(s)
+ [ for f in fs -> mkAbsolute directory f.FinalItemSpec ]
+
+ let projectReferences =
+ [ for i in project.GetEvaluatedItemsByName("ProjectReference") do
+ yield mkAbsolute directory i.FinalItemSpec
+ ]
+
+ let references =
+ [ for i in project.GetEvaluatedItemsByName("ReferencePath") do
+ yield i.FinalItemSpec
+ for i in project.GetEvaluatedItemsByName("ChildProjectReferences") do
+ yield i.FinalItemSpec ]
+ // Duplicate slashes sometimes appear in the output here, which prevents
+ // them from matching keys used in FSharpProjectOptions.ReferencedProjects
+ |> List.map (fun (s: string) -> s.Replace("//","/"))
+
+ outFileOpt, directory, getItems, references, projectReferences, getProp project, project.FullFileName
+
+#endif
+
//----------------------------------------------------------------------------
// FSharpProjectFileInfo
//
[]
type FSharpProjectFileInfo (fsprojFileName:string, ?properties, ?enableLogging) =
-
let properties = defaultArg properties []
let enableLogging = defaultArg enableLogging false
- let mkAbsolute dir v =
- if Path.IsPathRooted v then v
- else Path.Combine(dir, v)
let logOpt =
if enableLogging then
@@ -55,152 +198,17 @@ module internal ProjectCrackerTool =
Some log
else
None
-
-#if !DOTNETCORE
- let mkAbsoluteOpt dir v = Option.map (mkAbsolute dir) v
-
- let CrackProjectUsingOldBuildAPI(fsprojFile:string) =
- let engine = new Microsoft.Build.BuildEngine.Engine()
- Option.iter (fun l -> engine.RegisterLogger(l)) logOpt
-
- let bpg = Microsoft.Build.BuildEngine.BuildPropertyGroup()
-
- bpg.SetProperty("BuildingInsideVisualStudio", "true")
- for (prop, value) in properties do
- bpg.SetProperty(prop, value)
-
- engine.GlobalProperties <- bpg
-
- let projectFromFile (fsprojFile:string) =
- // We seem to need to pass 12.0/4.0 in here for some unknown reason
- let project = new Microsoft.Build.BuildEngine.Project(engine, engine.DefaultToolsVersion)
- do project.Load(fsprojFile)
- project
-
- let project = projectFromFile fsprojFile
- project.Build([| "ResolveReferences" |]) |> ignore
- let directory = Path.GetDirectoryName project.FullFileName
-
- let getProp (p: Microsoft.Build.BuildEngine.Project) s =
- let v = p.GetEvaluatedProperty s
- if String.IsNullOrWhiteSpace v then None
- else Some v
-
- let outFileOpt =
- match mkAbsoluteOpt directory (getProp project "OutDir") with
- | None -> None
- | Some d -> mkAbsoluteOpt d (getProp project "TargetFileName")
-
- let getItems s =
- let fs = project.GetEvaluatedItemsByName(s)
- [ for f in fs -> mkAbsolute directory f.FinalItemSpec ]
-
- let projectReferences =
- [ for i in project.GetEvaluatedItemsByName("ProjectReference") do
- yield mkAbsolute directory i.FinalItemSpec
- ]
-
- let references =
- [ for i in project.GetEvaluatedItemsByName("ReferencePath") do
- yield i.FinalItemSpec
- for i in project.GetEvaluatedItemsByName("ChildProjectReferences") do
- yield i.FinalItemSpec ]
- // Duplicate slashes sometimes appear in the output here, which prevents
- // them from matching keys used in FSharpProjectOptions.ReferencedProjects
- |> List.map (fun (s: string) -> s.Replace("//","/"))
-
- outFileOpt, directory, getItems, references, projectReferences, getProp project, project.FullFileName
-#endif
-
- let vs =
- let programFiles =
- let getEnv v =
- let result = System.Environment.GetEnvironmentVariable(v)
- match result with
- | null -> None
- | _ -> Some result
-
- match List.tryPick getEnv [ "ProgramFiles(x86)"; "ProgramFiles" ] with
- | Some r -> r
- | None -> "C:\\Program Files (x86)"
-
- let vsVersions = ["14.0"; "12.0"]
- let msbuildBin v = IO.Path.Combine(programFiles, "MSBuild", v, "Bin", "MSBuild.exe")
- List.tryFind (fun v -> IO.File.Exists(msbuildBin v)) vsVersions
-
- let CrackProjectUsingNewBuildAPI(fsprojFile) =
- let fsprojFullPath = try Path.GetFullPath(fsprojFile) with _ -> fsprojFile
- let fsprojAbsDirectory = Path.GetDirectoryName fsprojFullPath
-
- use _pwd =
- let dir = Directory.GetCurrentDirectory()
- Directory.SetCurrentDirectory(fsprojAbsDirectory)
- { new System.IDisposable with
- member x.Dispose() = Directory.SetCurrentDirectory(dir) }
- use engine = new Microsoft.Build.Evaluation.ProjectCollection()
- let host = new HostCompile()
- engine.HostServices.RegisterHostObject(fsprojFullPath, "CoreCompile", "Fsc", host)
-
-
- let projectInstanceFromFullPath (fsprojFullPath: string) =
- use file = new FileStream(fsprojFullPath, FileMode.Open, FileAccess.Read, FileShare.Read)
- use stream = new StreamReader(file)
- use xmlReader = System.Xml.XmlReader.Create(stream)
-
- let project = engine.LoadProject(xmlReader, FullPath=fsprojFullPath)
-
- project.SetGlobalProperty("BuildingInsideVisualStudio", "true") |> ignore
- if not (List.exists (fun (p,_) -> p = "VisualStudioVersion") properties) then
- match vs with
- | Some version -> project.SetGlobalProperty("VisualStudioVersion", version) |> ignore
- | None -> ()
- project.SetGlobalProperty("ShouldUnsetParentConfigurationAndPlatform", "false") |> ignore
- for (prop, value) in properties do
- project.SetGlobalProperty(prop, value) |> ignore
-
- project.CreateProjectInstance()
-
- let project = projectInstanceFromFullPath fsprojFullPath
- let directory = project.Directory
-
- let getprop (p: Microsoft.Build.Execution.ProjectInstance) s =
- let v = p.GetPropertyValue s
- if String.IsNullOrWhiteSpace v then None
- else Some v
-
- let outFileOpt = getprop project "TargetPath"
-
- let log = match logOpt with
- | None -> []
- | Some l -> [l :> ILogger]
-
- project.Build([| "Build" |], log) |> ignore
-
- let getItems s = [ for f in project.GetItems(s) -> mkAbsolute directory f.EvaluatedInclude ]
-
- let projectReferences =
- [ for cp in project.GetItems("ProjectReference") do
- yield cp.GetMetadataValue("FullPath")
- ]
-
- let references =
- [ for i in project.GetItems("ReferencePath") do
- yield i.EvaluatedInclude
- for i in project.GetItems("ChildProjectReferences") do
- yield i.EvaluatedInclude ]
-
- outFileOpt, directory, getItems, references, projectReferences, getprop project, project.FullPath
-
+
let outFileOpt, directory, getItems, references, projectReferences, getProp, fsprojFullPath =
try
#if DOTNETCORE
- CrackProjectUsingNewBuildAPI(fsprojFileName)
+ CrackProjectUsingNewBuildAPI fsprojFileName properties logOpt
with
#else
if runningOnMono then
- CrackProjectUsingOldBuildAPI(fsprojFileName)
+ CrackProjectUsingOldBuildAPI fsprojFileName properties logOpt
else
- CrackProjectUsingNewBuildAPI(fsprojFileName)
+ CrackProjectUsingNewBuildAPI fsprojFileName properties logOpt
with
| :? Microsoft.Build.BuildEngine.InvalidProjectFileException as e ->
raise (Microsoft.Build.Exceptions.InvalidProjectFileException(
@@ -384,66 +392,57 @@ module internal ProjectCrackerTool =
static member Parse(fsprojFileName:string, ?properties, ?enableLogging) = new FSharpProjectFileInfo(fsprojFileName, ?properties=properties, ?enableLogging=enableLogging)
let getOptions file enableLogging properties =
+ let cache = new Dictionary<_,_>()
let rec getOptions file : Option * ProjectOptions =
- let parsedProject = FSharpProjectFileInfo.Parse(file, properties=properties, enableLogging=enableLogging)
- let referencedProjectOptions =
- [| for file in parsedProject.ProjectReferences do
- if Path.GetExtension(file) = ".fsproj" then
- match getOptions file with
- | Some outFile, opts -> yield outFile, opts
- | None, _ -> () |]
-
- // Workaround for Mono 4.2, which doesn't populate the subproject
- // details anymore outside of a solution context. See https://github.com/mono/mono/commit/76c6a08e730393927b6851709cdae1d397cbcc3a#diff-59afd196a55d61d5d1eaaef7bd49d1e5
- // and some explanation from the author at https://github.com/fsharp/FSharp.Compiler.Service/pull/455#issuecomment-154103963
- //
- // In particular we want the output path, which we can get from
- // fully parsing that project itself. We also have to specially parse
- // C# referenced projects, as we don't look at them otherwise.
- let referencedProjectOutputs =
- if runningOnMono then
- [ yield! Array.map (fun (s,_) -> "-r:" + s) referencedProjectOptions
- for file in parsedProject.ProjectReferences do
- let ext = Path.GetExtension(file)
- if ext = ".csproj" || ext = ".vbproj" then
- let parsedProject = FSharpProjectFileInfo.Parse(file, properties=properties, enableLogging=false)
- match parsedProject.OutputFile with
- | None -> ()
- | Some f -> yield "-r:" + f ]
- else
- []
-
- // On some versions of Mono the referenced projects are already
- // correctly included, so we make sure not to introduce duplicates
- |> List.filter (fun r -> not (Set.contains r (set parsedProject.Options)))
-
- let options = { ProjectFile = file
- Options = Array.ofSeq (parsedProject.Options @ referencedProjectOutputs)
- ReferencedProjectOptions = referencedProjectOptions
- LogOutput = parsedProject.LogOutput
- Error = null }
-
- parsedProject.OutputFile, options
+ match cache.TryGetValue file with
+ | true, option -> option
+ | _ ->
+ let parsedProject = FSharpProjectFileInfo.Parse(file, properties=properties, enableLogging=enableLogging)
+
+ let referencedProjectOptions =
+ [| for file in parsedProject.ProjectReferences do
+ if Path.GetExtension(file) = ".fsproj" then
+ match getOptions file with
+ | Some outFile, opts -> yield outFile, opts
+ | None, _ -> () |]
+
+ // Workaround for Mono 4.2, which doesn't populate the subproject
+ // details anymore outside of a solution context. See https://github.com/mono/mono/commit/76c6a08e730393927b6851709cdae1d397cbcc3a#diff-59afd196a55d61d5d1eaaef7bd49d1e5
+ // and some explanation from the author at https://github.com/fsharp/FSharp.Compiler.Service/pull/455#issuecomment-154103963
+ //
+ // In particular we want the output path, which we can get from
+ // fully parsing that project itself. We also have to specially parse
+ // C# referenced projects, as we don't look at them otherwise.
+ let referencedProjectOutputs =
+ if runningOnMono then
+ [ yield! Array.map (fun (s,_) -> "-r:" + s) referencedProjectOptions
+ for file in parsedProject.ProjectReferences do
+ let ext = Path.GetExtension(file)
+ if ext = ".csproj" || ext = ".vbproj" then
+ let parsedProject = FSharpProjectFileInfo.Parse(file, properties=properties, enableLogging=false)
+ match parsedProject.OutputFile with
+ | None -> ()
+ | Some f -> yield "-r:" + f ]
+ else
+ []
+
+ // On some versions of Mono the referenced projects are already
+ // correctly included, so we make sure not to introduce duplicates
+ |> List.filter (fun r -> not (Set.contains r (set parsedProject.Options)))
+
+ let options = { ProjectFile = file
+ Options = Array.ofSeq (parsedProject.Options @ referencedProjectOutputs)
+ ReferencedProjectOptions = referencedProjectOptions
+ LogOutput = parsedProject.LogOutput
+ Error = null }
+
+ let result = parsedProject.OutputFile, options
+ cache.Add(file,result)
+ result
snd (getOptions file)
-#if !DOTNETCORE
- let addMSBuildv14BackupResolution () =
- let onResolveEvent = new ResolveEventHandler(fun sender evArgs ->
- let requestedAssembly = AssemblyName(evArgs.Name)
- if requestedAssembly.Name.StartsWith("Microsoft.Build") &&
- not (requestedAssembly.Name.EndsWith(".resources")) &&
- not (requestedAssembly.Version.ToString().Contains("12.0.0.0")) then
- // If the version of MSBuild that we're using wasn't present on the machine, then
- // just revert back to 12.0.0.0 since that's normally installed as part of the .NET
- // Framework.
- requestedAssembly.Version <- Version("12.0.0.0")
- Assembly.Load (requestedAssembly)
- else
- null)
- AppDomain.CurrentDomain.add_AssemblyResolve(onResolveEvent)
-#endif
-
+
let rec pairs l =
match l with
| [] | [_] -> []
@@ -456,9 +455,6 @@ module internal ProjectCrackerTool =
| true, true -> true
| _ -> false
try
-#if !DOTNETCORE
- addMSBuildv14BackupResolution ()
-#endif
let props = pairs (List.ofArray argv.[2..])
let opts = getOptions argv.[0] enableLogging props
0, opts
@@ -466,8 +462,8 @@ module internal ProjectCrackerTool =
2, { ProjectFile = projectFile;
Options = [||];
ReferencedProjectOptions = [||];
- LogOutput = e.ToString()
- Error = e.Message }
+ LogOutput = e.ToString() + " StackTrace: " + e.StackTrace
+ Error = e.Message + " StackTrace: " + e.StackTrace }
else
1, { ProjectFile = "";
Options = [||];
diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/paket.references b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/paket.references
new file mode 100644
index 0000000000..3ad1f9662c
--- /dev/null
+++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/paket.references
@@ -0,0 +1,4 @@
+Microsoft.Build.Utilities.Core
+Microsoft.Build.Engine
+Microsoft.Build
+System.Threading.Tasks.Dataflow
\ No newline at end of file
diff --git a/fcs/FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj b/fcs/FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj
index 058a83e551..71f5341bb7 100644
--- a/fcs/FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj
+++ b/fcs/FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj
@@ -1,4 +1,4 @@
-
+netcoreapp1.0$(DefineConstants);DOTNETCORE;FX_ATLEAST_45;FX_ATLEAST_PORTABLE;FX_NO_RUNTIMEENVIRONMENT;FX_RESHAPED_REFLECTION;TODO_REWORK_ASSEMBLY_LOAD;
@@ -42,6 +42,7 @@
+
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 98e86a0644..d53494b86f 100644
--- a/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj
+++ b/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj
@@ -80,8 +80,8 @@
PreserveNewest
+
-
@@ -97,7 +97,6 @@
-
$(FSharpSourcesRoot)\..\packages\System.Collections.Immutable.$(SystemCollectionsImmutableVersion)\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll
@@ -112,7 +111,6 @@
$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\FSharp.Core.dlltrue
-
CSharp_Analysis{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}
@@ -130,4 +128,66 @@
+
+
+
+
+ ..\packages\Microsoft.Build\lib\net45\Microsoft.Build.dll
+ True
+ True
+
+
+
+
+
+
+
+
+ ..\packages\Microsoft.Build.Engine\lib\net45\Microsoft.Build.Engine.dll
+ True
+ True
+
+
+
+
+
+
+
+
+ ..\packages\Microsoft.Build.Framework\lib\net45\Microsoft.Build.Framework.dll
+ True
+ True
+
+
+
+
+
+
+
+
+ ..\packages\Microsoft.Build.Utilities.Core\lib\net45\Microsoft.Build.Utilities.Core.dll
+ True
+ True
+
+
+
+
+
+
+
+
+ True
+
+
+
+
+
+
+
+
+ True
+
+
+
+
\ No newline at end of file
diff --git a/fcs/FSharp.Compiler.Service.Tests/paket.references b/fcs/FSharp.Compiler.Service.Tests/paket.references
new file mode 100644
index 0000000000..c64e284f16
--- /dev/null
+++ b/fcs/FSharp.Compiler.Service.Tests/paket.references
@@ -0,0 +1,3 @@
+Microsoft.Build.Utilities.Core
+Microsoft.Build.Engine
+Microsoft.Build
\ No newline at end of file
diff --git a/fcs/FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj b/fcs/FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj
index eb20755c31..3b8ed6361e 100644
--- a/fcs/FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj
+++ b/fcs/FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj
@@ -536,6 +536,12 @@
Symbols/Exprs.fs
+
+ Symbols/SymbolPatterns.fsi
+
+
+ Symbols/SymbolPatterns.fs
+
Service/IncrementalBuild.fsi
@@ -607,6 +613,12 @@
Service/ExternalSymbol.fs
+
+
+ Service/QuickParse.fsi
+
+
+ Service/QuickParse.fs
Service/service.fsi
@@ -626,6 +638,12 @@
Service/ServiceStructure.fs
+
+ Service/ServiceAnalysis.fsi
+
+
+ Service/ServiceAnalysis.fs
+
Service/fsi.fsi
diff --git a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
index 07d9840cde..1d5057aae1 100644
--- a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
+++ b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
@@ -512,6 +512,12 @@
Symbols/Exprs.fs
+
+ Symbols/SymbolPatterns.fsi
+
+
+ Symbols/SymbolPatterns.fs
+
Service/IncrementalBuild.fsi
@@ -583,6 +589,12 @@
Service/ExternalSymbol.fs
+
+
+ Service/QuickParse.fsi
+
+
+ Service/QuickParse.fs
Service/service.fsi
@@ -602,6 +614,12 @@
Service/ServiceStructure.fs
+
+ Service/ServiceAnalysis.fsi
+
+
+ Service/ServiceAnalysis.fs
+
Service/fsi.fsi
diff --git a/fcs/README.md b/fcs/README.md
index 3e21f6322a..9624b54bce 100644
--- a/fcs/README.md
+++ b/fcs/README.md
@@ -60,9 +60,9 @@ which does things like:
Yu can push the packages if you have permissions, either automatically using ``build Release`` or manually
set APIKEY=...
- .nuget\nuget.exe push Release\FSharp.Compiler.Service.16.0.2.nupkg %APIKEY% -Source https://nuget.org
- .nuget\nuget.exe push Release\FSharp.Compiler.Service.MSBuild.v12.16.0.2.nupkg %APIKEY% -Source https://nuget.org
- .nuget\nuget.exe push Release\FSharp.Compiler.Service.ProjectCracker.16.0.2.nupkg %APIKEY% -Source https://nuget.org
+ .nuget\nuget.exe push Release\FSharp.Compiler.Service.17.0.1.nupkg %APIKEY% -Source https://nuget.org
+ .nuget\nuget.exe push Release\FSharp.Compiler.Service.MSBuild.v12.17.0.1.nupkg %APIKEY% -Source https://nuget.org
+ .nuget\nuget.exe push Release\FSharp.Compiler.Service.ProjectCracker.17.0.1.nupkg %APIKEY% -Source https://nuget.org
### Use of Paket and FAKE
diff --git a/fcs/RELEASE_NOTES.md b/fcs/RELEASE_NOTES.md
index dd33909ca8..6b0b352de3 100644
--- a/fcs/RELEASE_NOTES.md
+++ b/fcs/RELEASE_NOTES.md
@@ -1,3 +1,9 @@
+#### 17.0.1
+ * Integrate visualfsharp master
+
+#### 16.0.3
+ * [File name deduplication not working with ParseAndCheckFileInProject](https://github.com/fsharp/FSharp.Compiler.Service/issues/819)
+
#### 16.0.2
* [ProjectCracker returns *.fsi files in FSharpProjectOptions.SourceFiles array](https://github.com/fsharp/FSharp.Compiler.Service/pull/812)
diff --git a/fcs/build.cmd b/fcs/build.cmd
index 5597c915e8..c18c0a1f22 100644
--- a/fcs/build.cmd
+++ b/fcs/build.cmd
@@ -1,8 +1,8 @@
@echo off
-.nuget\NuGet.exe restore -PackagesDirectory packages
+
setlocal
cd fcs
-.paket\paket.bootstrapper.exe
+
if errorlevel 1 (
endlocal
exit /b %errorlevel%
diff --git a/fcs/build.fsx b/fcs/build.fsx
index cf5e7620b3..1e39de8bbb 100644
--- a/fcs/build.fsx
+++ b/fcs/build.fsx
@@ -13,8 +13,22 @@ open Fake.ReleaseNotesHelper
#if MONO
// prevent incorrect output encoding (e.g. https://github.com/fsharp/FAKE/issues/1196)
System.Console.OutputEncoding <- System.Text.Encoding.UTF8
+
+CleanDir (__SOURCE_DIRECTORY__ + "/../tests/TestResults")
+File.WriteAllText(__SOURCE_DIRECTORY__ + "/../tests/TestResults/notestsyet.txt","No tests yet")
#endif
+let dotnetExePath = DotNetCli.InstallDotNetSDK "2.0.2"
+
+let runDotnet workingDir args =
+ let result =
+ ExecProcess (fun info ->
+ info.FileName <- dotnetExePath
+ info.WorkingDirectory <- workingDir
+ info.Arguments <- args) TimeSpan.MaxValue
+
+ if result <> 0 then failwithf "dotnet %s failed" args
+
// --------------------------------------------------------------------------------------
// Utilities
// --------------------------------------------------------------------------------------
@@ -69,6 +83,22 @@ let buildVersion =
else if isAppVeyorBuild then sprintf "%s-b%s" assemblyVersion AppVeyorEnvironment.BuildNumber
else assemblyVersion
+Target "Clean" (fun _ ->
+ CleanDir releaseDir
+)
+
+Target "Restore" (fun _ ->
+ for p in (!! "./../**/packages.config") do
+ let result =
+ ExecProcess (fun info ->
+ info.FileName <- FullName @"./../.nuget/NuGet.exe"
+ info.WorkingDirectory <- FullName @"./.."
+ info.Arguments <- sprintf "restore %s -PackagesDirectory \"%s\" -ConfigFile \"%s\"" (FullName p) (FullName "./../packages") (FullName "./../.nuget/NuGet.Config")) TimeSpan.MaxValue
+ if result <> 0 then failwithf "nuget restore %s failed" p
+
+ runDotnet __SOURCE_DIRECTORY__ "restore tools.fsproj"
+)
+
Target "BuildVersion" (fun _ ->
Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore
)
@@ -88,11 +118,24 @@ Target "Build.NetFx" (fun _ ->
// Run the unit tests using test runner
Target "Test.NetFx" (fun _ ->
- !! (releaseDir + "/fcs/net45/FSharp.Compiler.Service.Tests.dll")
+ let testDir = __SOURCE_DIRECTORY__ + "/../tests/fcs"
+ CleanDir testDir
+
+ let outDir = releaseDir + "/fcs"
+
+ !! (outDir + "/**/*.*")
+ |> CopyFiles testDir
+
+ let toolPath = __SOURCE_DIRECTORY__ + "/../packages/NUnit.Console.3.0.0/tools"
+ !! (toolPath + "/*.*")
+ |> CopyFiles testDir
+
+ !! (testDir + "/**/FSharp.Compiler.Service.Tests.dll")
|> Fake.Testing.NUnit3.NUnit3 (fun p ->
{ p with
- ToolPath = @"..\packages\NUnit.Console.3.0.0\tools\nunit3-console.exe"
+ ToolPath = testDir + "/nunit3-console.exe"
ShadowCopy = false
+ WorkingDir = FullName testDir
TimeOut = TimeSpan.FromMinutes 20. })
)
@@ -109,26 +152,14 @@ Target "NuGet.NetFx" (fun _ ->
// --------------------------------------------------------------------------------------
// .NET Core and .NET Core SDK
-let isDotnetSDKInstalled =
- match Fake.EnvironmentHelper.environVarOrNone "FCS_DNC" with
- | Some flag ->
- match bool.TryParse flag with
- | true, result -> result
- | _ -> false
- | None ->
- try
- Shell.Exec("dotnet", "--info") = 0
- with
- _ -> false
-
Target "Build.NetStd" (fun _ ->
- runCmdIn __SOURCE_DIRECTORY__ "dotnet" "pack %s -v n -c Release" "FSharp.Compiler.Service.netstandard.sln"
+ runDotnet __SOURCE_DIRECTORY__ (sprintf "pack %s -v n -c Release" "FSharp.Compiler.Service.netstandard.sln")
)
Target "Test.NetStd" (fun _ ->
- runCmdIn __SOURCE_DIRECTORY__ "dotnet" "run -p FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj -c Release -- --result:TestResults.NetStd.xml;format=nunit3"
+ runDotnet __SOURCE_DIRECTORY__ (sprintf "run -p FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj -c Release -- --result:TestResults.NetStd.xml;format=nunit3")
)
@@ -136,8 +167,7 @@ Target "Test.NetStd" (fun _ ->
Target "Nuget.AddNetStd" (fun _ ->
let nupkg = sprintf "%s/FSharp.Compiler.Service.%s.nupkg" releaseDir release.AssemblyVersion
let netcoreNupkg = sprintf "FSharp.Compiler.Service.netstandard/bin/Release/FSharp.Compiler.Service.%s.nupkg" release.AssemblyVersion
- runCmdIn __SOURCE_DIRECTORY__ "dotnet" "restore tools.fsproj"
- runCmdIn __SOURCE_DIRECTORY__ "dotnet" "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg
+ runDotnet __SOURCE_DIRECTORY__ (sprintf "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg)
)
@@ -169,7 +199,6 @@ Target "PublishNuGet" (fun _ ->
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build ' to override
-Target "Clean" DoNothing
Target "Release" DoNothing
Target "NuGet" DoNothing
Target "Build" DoNothing
@@ -178,10 +207,12 @@ Target "TestAndNuGet" DoNothing
"Clean"
=?> ("BuildVersion", isAppVeyorBuild)
+ ==> "Restore"
==> "Build.NetStd"
"Clean"
=?> ("BuildVersion", isAppVeyorBuild)
+ ==> "Restore"
==> "Build.NetFx"
"Build.NetFx"
@@ -191,15 +222,15 @@ Target "TestAndNuGet" DoNothing
==> "Test.NetStd"
"Build.NetFx"
- =?> ("Build.NetStd", isDotnetSDKInstalled)
+ ==> "Build.NetStd"
==> "Build"
"Build.NetStd"
- =?> ("Nuget.AddNetStd", isDotnetSDKInstalled)
+ ==> "Nuget.AddNetStd"
"Build.NetFx"
==> "NuGet.NetFx"
- =?> ("Nuget.AddNetStd", isDotnetSDKInstalled)
+ ==> "Nuget.AddNetStd"
==> "NuGet"
"Test.NetFx"
@@ -207,9 +238,7 @@ Target "TestAndNuGet" DoNothing
"NuGet"
==> "TestAndNuGet"
-
-//"Test.NetStd"
-// ==> "TestAndNuGet"
+
"Build"
==> "NuGet"
diff --git a/fcs/build.sh b/fcs/build.sh
index 3e7e80e7d8..53e6962df7 100755
--- a/fcs/build.sh
+++ b/fcs/build.sh
@@ -4,8 +4,6 @@ then
# use .Net
cmd fcs/build.cmd $@
else
- mono .nuget/NuGet.exe restore -PackagesDirectory packages
-
cd fcs
# use mono
@@ -13,14 +11,6 @@ else
mozroots --import --sync --quiet
fi
- dotnet restore tools.fsproj
-
- mono .paket/paket.bootstrapper.exe
- exit_code=$?
- if [ $exit_code -ne 0 ]; then
- exit $exit_code
- fi
-
mono .paket/paket.exe restore
exit_code=$?
if [ $exit_code -ne 0 ]; then
@@ -28,4 +18,4 @@ else
fi
mono packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
-fi
\ No newline at end of file
+fi
diff --git a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll
deleted file mode 100644
index 0661150997..0000000000
Binary files a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll and /dev/null differ
diff --git a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll
deleted file mode 100644
index 74d6e05b85..0000000000
Binary files a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll and /dev/null differ
diff --git a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll
deleted file mode 100644
index c702184ec0..0000000000
Binary files a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll and /dev/null differ
diff --git a/fcs/dependencies/README.md b/fcs/dependencies/README.md
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/fcs/fcs.props b/fcs/fcs.props
index e7cce1e0c3..2c3ca05a96 100644
--- a/fcs/fcs.props
+++ b/fcs/fcs.props
@@ -3,7 +3,7 @@
- 16.0.2
+ 17.0.1$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools
diff --git a/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec b/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec
index adf1e3726e..9dbb74377c 100644
--- a/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec
+++ b/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec
@@ -5,7 +5,7 @@
Adds legacy MSBuild 12.0 support to the F# compiler services package for resolving references such as #r "System, Version=4.1.0.0,..."en-USfalse
- 16.0.2
+ 17.0.1Microsoft Corporation and F# community contributorshttps://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSEhttps://github.com/fsharp/FSharp.Compiler.Service
@@ -14,7 +14,7 @@
F# compiler services for creating IDE tools, language extensions and for F# embedding.
-
+
diff --git a/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec b/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec
index a19d9341f2..952f810985 100644
--- a/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec
+++ b/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec
@@ -5,7 +5,7 @@
The F# compiler services package contains a custom build of the F# compiler that exposes additional functionality for implementing F# language bindings, additional tools based on the compiler or refactoring tools. The package also includes F# interactive service that can be used for embedding F# scripting into your applications.en-USfalse
- 16.0.2
+ 17.0.1Microsoft Corporation and F# community contributorshttps://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSEhttps://github.com/fsharp/FSharp.Compiler.Service
@@ -14,7 +14,7 @@
F# compiler services for creating IDE tools, language extensions and for F# embedding.
-
+
diff --git a/fcs/nuget/FSharp.Compiler.Service.nuspec b/fcs/nuget/FSharp.Compiler.Service.nuspec
index fb4b6ac055..9cc2f87e41 100644
--- a/fcs/nuget/FSharp.Compiler.Service.nuspec
+++ b/fcs/nuget/FSharp.Compiler.Service.nuspec
@@ -5,7 +5,7 @@
The F# compiler services package contains a custom build of the F# compiler that exposes additional functionality for implementing F# language bindings, additional tools based on the compiler or refactoring tools. The package also includes F# interactive service that can be used for embedding F# scripting into your applications.en-USfalse
- 16.0.2
+ 17.0.1Microsoft Corporation and F# community contributorshttps://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSEhttps://github.com/fsharp/FSharp.Compiler.Service
diff --git a/fcs/paket.dependencies b/fcs/paket.dependencies
index bfd298568f..c29c3a6a9f 100644
--- a/fcs/paket.dependencies
+++ b/fcs/paket.dependencies
@@ -1,7 +1,12 @@
-framework: net45
+framework: net45, net46
source https://www.nuget.org/api/v2/
-nuget FAKE
+nuget FAKE prerelease
nuget FSharp.Formatting
+nuget Microsoft.Build.Utilities.Core 14.3.0
+nuget Microsoft.Build.Framework 14.3.0
+nuget Microsoft.Build.Engine 14.3.0
+nuget Microsoft.Build 14.3.0
+nuget System.Threading.Tasks.Dataflow 4.5.24.0
\ No newline at end of file
diff --git a/fcs/paket.lock b/fcs/paket.lock
index 2e454bee77..ccc098c85e 100644
--- a/fcs/paket.lock
+++ b/fcs/paket.lock
@@ -1,10 +1,24 @@
-RESTRICTION: == net45
+RESTRICTION: || (== net45) (== net46)
NUGET
remote: https://www.nuget.org/api/v2
- FAKE (4.63.2)
+ FAKE (5.0.0-beta010)
FSharp.Compiler.Service (2.0.0.6)
FSharp.Formatting (2.14.4)
FSharp.Compiler.Service (2.0.0.6)
FSharpVSPowerTools.Core (>= 2.3 < 2.4)
FSharpVSPowerTools.Core (2.3)
FSharp.Compiler.Service (>= 2.0.0.3)
+ Microsoft.Build (14.3)
+ Microsoft.Build.Framework (14.3)
+ Microsoft.Build.Engine (14.3)
+ Microsoft.Build.Framework (14.3)
+ Microsoft.Build.Framework (14.3)
+ System.Collections (>= 4.0.11) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
+ System.Runtime (>= 4.1) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
+ System.Runtime.InteropServices (>= 4.1) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
+ Microsoft.Build.Utilities.Core (14.3)
+ Microsoft.Build.Framework (14.3)
+ System.Collections (4.3) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
+ System.Runtime (4.3) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
+ System.Runtime.InteropServices (4.3) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
+ System.Threading.Tasks.Dataflow (4.5.24)
diff --git a/fcs/samples/EditorService/Program.fs b/fcs/samples/EditorService/Program.fs
index 40052ddce7..5a2cb624f0 100644
--- a/fcs/samples/EditorService/Program.fs
+++ b/fcs/samples/EditorService/Program.fs
@@ -2,6 +2,7 @@
open System
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.SourceCodeServices
+open Microsoft.FSharp.Compiler.QuickParse
// Create an interactive checker instance (ignore notifications)
let checker = FSharpChecker.Create()
@@ -36,9 +37,11 @@ let tip = parsed.GetToolTipText(2, 7, inputLines.[1], [ "foo" ], identTokenTag)
printfn "%A" tip
+let partialName = GetPartialLongNameEx(inputLines.[4], 23)
+
// Get declarations (autocomplete) for a location
let decls =
- parsed.GetDeclarationListInfo(Some untyped, 5, 23, inputLines.[4], [], "msg", (fun () -> []))
+ parsed.GetDeclarationListInfo(Some untyped, 5, inputLines.[4], partialName, (fun () -> []))
|> Async.RunSynchronously
for item in decls.Items do
diff --git a/src/FSharpSource.targets b/src/FSharpSource.targets
index 5d09fd3373..f9e54f501f 100644
--- a/src/FSharpSource.targets
+++ b/src/FSharpSource.targets
@@ -363,6 +363,9 @@
+
+
+ $(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)
+
+
+
+
+ false
+
+
+
+
+
+ <_PublicKey>002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293
+
+
+ <_InternalsVisibleToAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
+ <_Parameter1 Condition="'%(InternalsVisibleTo.Key)' != ''">%(InternalsVisibleTo.Identity), PublicKey=%(InternalsVisibleTo.Key)
+ <_Parameter1 Condition="'%(InternalsVisibleTo.Key)' == ''">%(InternalsVisibleTo.Identity), PublicKey=$(_PublicKey)
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Build.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Build.dll.fs
index 14a0524154..e31498dae3 100644
--- a/src/assemblyinfo/assemblyinfo.FSharp.Build.dll.fs
+++ b/src/assemblyinfo/assemblyinfo.FSharp.Build.dll.fs
@@ -9,13 +9,6 @@ open System.Reflection
[]
do()
-#if NO_STRONG_NAMES
-[]
-#endif
-#if STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY
-[]
-#endif
-
// Until dotnet sdk can version assemblies, use this
#if BUILD_FROM_SOURCE
[]
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs
index 37dee8dc58..5a1ca9682a 100644
--- a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs
+++ b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs
@@ -11,21 +11,6 @@ open System.Runtime.InteropServices
[]
[]
-#if NO_STRONG_NAMES
-[]
-[]
-#endif
-
-#if STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY
-[]
-[]
-#endif
-
-#if STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY
-[]
-[]
-#endif
-
// Until dotnet sdk can version assemblies, use this
#if BUILD_FROM_SOURCE
[]
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Private.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Private.dll.fs
index c74e002c1b..80f054f852 100644
--- a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Private.dll.fs
+++ b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Private.dll.fs
@@ -11,60 +11,6 @@ open System.Runtime.InteropServices
[]
[]
-#if NO_STRONG_NAMES
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-
-// Note: internals visible to unit test DLLs in Retail (and all) builds.
-[]
-[]
-[]
-[]
-[]
-#endif
-#if STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY
-
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-#endif
-#if STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-#endif
-
// Until dotnet sdk can version assemblies, use this
#if BUILD_FROM_SOURCE
[]
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Service.MSBuild.v12.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Service.MSBuild.v12.dll.fs
deleted file mode 100644
index 70eafeb122..0000000000
--- a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Service.MSBuild.v12.dll.fs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
-
-namespace Microsoft.FSharp
-open System.Reflection
-open System.Runtime.InteropServices
-
-[]
-[]
-[]
-[]
-
-[]
-[]
-do()
diff --git a/src/assemblyinfo/assemblyinfo.fsc.exe.fs b/src/assemblyinfo/assemblyinfo.fsc.exe.fs
index d9245e545f..d7adacfd7e 100755
--- a/src/assemblyinfo/assemblyinfo.fsc.exe.fs
+++ b/src/assemblyinfo/assemblyinfo.fsc.exe.fs
@@ -11,8 +11,6 @@ open System.Runtime.InteropServices
[]
[]
-[]
-
// Until dotnet sdk can version assemblies, use this
#if BUILD_FROM_SOURCE
[]
diff --git a/src/fsharp/ErrorResolutionHints.fs b/src/fsharp/ErrorResolutionHints.fs
index 4b3e47617c..64ef837c85 100644
--- a/src/fsharp/ErrorResolutionHints.fs
+++ b/src/fsharp/ErrorResolutionHints.fs
@@ -43,7 +43,11 @@ let FilterPredictions (idText:string) (suggestionF:ErrorLogger.Suggestions) =
if allSuggestions.Contains idText then [] else // some other parsing error occurred
allSuggestions
|> Seq.choose (fun suggestion ->
- if IsOperatorName suggestion then None else
+ // Because beginning a name with _ is used both to indicate an unused
+ // value as well as to formally squelch the associated compiler
+ // error/warning (FS1182), we remove such names from the suggestions,
+ // both to prevent accidental usages as well as to encourage good taste
+ if IsOperatorName suggestion || suggestion.StartsWith "_" then None else
let suggestion:string = demangle suggestion
let suggestedText = suggestion.ToUpperInvariant()
let similarity = EditDistance.JaroWinklerDistance uppercaseText suggestedText
diff --git a/src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj b/src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj
index c5c361ca1d..a6505441b5 100644
--- a/src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj
+++ b/src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj
@@ -40,6 +40,9 @@
FSharpEmbedResXSource.fs
+
+ WriteCodeFragment.fs
+
Microsoft.FSharp-proto.targets
Microsoft.FSharp-proto.targets
diff --git a/src/fsharp/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj b/src/fsharp/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj
new file mode 100644
index 0000000000..f81d227e8d
--- /dev/null
+++ b/src/fsharp/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj
@@ -0,0 +1,77 @@
+
+
+
+
+ $(MSBuildProjectDirectory)\..\..
+ {400FAB03-786E-40CC-85A8-04B0C2869B14}
+ true
+ false
+
+
+
+ Debug
+ AnyCPU
+ 2.0
+ true
+ true
+ Library
+ false
+ FSharp.Build.UnitTests
+ netcore
+
+
+ $(DefineConstants);EXTENSIONTYPING;$(TargetDotnetProfile.ToLower())
+
+
+ true
+ false
+ $(DefineConstants);DEBUG;TRACE
+ prompt
+ 3
+
+
+ true
+ $(DefineConstants);TRACE
+ prompt
+ 3
+
+
+
+ true
+ True
+ $(NUnitLibDir)\nunit.framework.dll
+
+
+ $(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Framework.dll
+
+
+ $(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.dll
+
+
+ $(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Utilities.Core.dll
+
+
+ $(FSharpSourcesRoot)\..\packages\Microsoft.VisualFSharp.Msbuild.15.0.1.0.1\lib\net45\Microsoft.Build.Tasks.Core.dll
+
+
+
+
+ {702A7979-BCF9-4C41-853E-3ADFC9897890}
+ FSharp.Build
+
+
+ {DED3BBD7-53F4-428A-8C9F-27968E768605}
+ FSharp.Core
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/fsharp/FSharp.Build.UnitTests/Program.fs b/src/fsharp/FSharp.Build.UnitTests/Program.fs
new file mode 100644
index 0000000000..d0397a7de0
--- /dev/null
+++ b/src/fsharp/FSharp.Build.UnitTests/Program.fs
@@ -0,0 +1,14 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+module Program
+
+open System
+open System.Reflection
+open NUnitLite
+open NUnit.Common
+
+type HelperType() = inherit System.Object()
+
+[]
+let main argv =
+ AutoRun(typeof.GetTypeInfo().Assembly).Execute(argv, new ExtendedTextWrapper(Console.Out), Console.In)
diff --git a/src/fsharp/FSharp.Build.UnitTests/WriteCodeFragmentTests.fs b/src/fsharp/FSharp.Build.UnitTests/WriteCodeFragmentTests.fs
new file mode 100644
index 0000000000..70800400d2
--- /dev/null
+++ b/src/fsharp/FSharp.Build.UnitTests/WriteCodeFragmentTests.fs
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace FSharp.Build.UnitTests
+
+open Microsoft.Build.Framework
+open Microsoft.Build.Utilities
+open Microsoft.FSharp.Build
+open NUnit.Framework
+
+[]
+type WriteCodeFragmentTests()=
+
+ let verifyAttribute (attributeName:string) (parameters:(string*string) list) (expectedAttributeText:string) =
+ let taskItem = TaskItem(attributeName)
+ parameters |> List.iter (fun (key, value) -> taskItem.SetMetadata(key, value))
+ let actualAttributeText = WriteCodeFragment.GenerateAttribute (taskItem :> ITaskItem)
+ let fullExpectedAttributeText = "[]"
+ Assert.AreEqual(fullExpectedAttributeText, actualAttributeText)
+
+ []
+ member this.``No parameters``() =
+ verifyAttribute "SomeAttribute" [] "SomeAttribute()"
+
+ []
+ member this.``Skipped and out of order positional parameters``() =
+ verifyAttribute "SomeAttribute" [("_Parameter3", "3"); ("_Parameter5", "5"); ("_Parameter2", "2")] "SomeAttribute(null, \"2\", \"3\", null, \"5\")"
+
+ []
+ member this.``Named parameters``() =
+ verifyAttribute "SomeAttribute" [("One", "1"); ("Two", "2")] "SomeAttribute(One = \"1\", Two = \"2\")"
+
+ []
+ member this.``Named and positional parameters``() =
+ verifyAttribute "SomeAttribute" [("One", "1"); ("_Parameter2", "2.2"); ("Two", "2")] "SomeAttribute(null, \"2.2\", One = \"1\", Two = \"2\")"
+
+ []
+ member this.``Escaped string parameters``() =
+ verifyAttribute "SomeAttribute" [("_Parameter1", "\"uno\"")] "SomeAttribute(\"\\\"uno\\\"\")"
+ // this should look like: SomeAttribute("\"uno\"")
diff --git a/src/fsharp/FSharp.Build.UnitTests/project.json b/src/fsharp/FSharp.Build.UnitTests/project.json
new file mode 100644
index 0000000000..557b06140e
--- /dev/null
+++ b/src/fsharp/FSharp.Build.UnitTests/project.json
@@ -0,0 +1,33 @@
+{
+ "version": "1.0.0-*",
+ "name": "FSharp.Build.UnitTests",
+ "buildOptions": {
+ "debugType": "portable",
+ "emitEntryPoint": true
+ },
+ "dependencies": {
+ "nunit": "3.5.0",
+ "nunitlite": "3.5.0",
+ "Microsoft.Build": "15.1.548",
+ "Microsoft.Build.Framework": "15.1.548",
+ "Microsoft.Build.Tasks.Core": "15.1.548",
+ "Microsoft.Build.Utilities.Core": "15.1.548"
+ },
+ "runtimes": {
+ "win7-x86": {},
+ "win7-x64": {},
+ "osx.10.11-x64": {},
+ "ubuntu.14.04-x64": {}
+ },
+ "frameworks": {
+ "netcoreapp1.0": {
+ "dependencies": {
+ "Microsoft.NETCore.App": {
+ "type": "platform",
+ "version": "1.0.1"
+ }
+ },
+ "imports": [ "netstandard1.1", "netstandard1.6", "portable-net45+win8+wp8+wpa81" ]
+ }
+ }
+}
diff --git a/src/fsharp/LowerCallsAndSeqs.fs b/src/fsharp/LowerCallsAndSeqs.fs
index 7e6ba07fed..9dfde6b638 100755
--- a/src/fsharp/LowerCallsAndSeqs.fs
+++ b/src/fsharp/LowerCallsAndSeqs.fs
@@ -394,6 +394,7 @@ let LowerSeqExpr g amap overallExpr =
| None ->
None
+(*
| Expr.LetRec(binds,e2,m,_)
when // Restriction: only limited forms of "let rec" in sequence expressions can be handled by assignment to state local values
@@ -422,7 +423,7 @@ let LowerSeqExpr g amap overallExpr =
Some res4
| None ->
None
-
+*)
| Expr.Match (spBind,exprm,pt,targets,m,ty) when targets |> Array.forall (fun (TTarget(vs,_e,_spTarget)) -> isNil vs) ->
// lower all the targets. abandon if any fail to lower
let tgl = targets |> Array.map (fun (TTarget(_vs,e,_spTarget)) -> Lower false isTailCall noDisposeContinuationLabel currentDisposeContinuationLabel e) |> Array.toList
diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs
index cc50d5bb15..7150c4d99d 100644
--- a/src/fsharp/NameResolution.fs
+++ b/src/fsharp/NameResolution.fs
@@ -1222,12 +1222,32 @@ type ItemOccurence =
/// Result gets suppressed over this text range
| RelatedText
+type OpenDeclaration =
+ { LongId: Ident list
+ Range: range option
+ Modules: ModuleOrNamespaceRef list
+ AppliedScope: range
+ IsOwnNamespace: bool }
+
+ static member Create(longId: Ident list, modules: ModuleOrNamespaceRef list, appliedScope: range, isOwnNamespace: bool) =
+ { LongId = longId
+ Range =
+ match longId with
+ | [] -> None
+ | first :: rest ->
+ let last = rest |> List.tryLast |> Option.defaultValue first
+ Some (mkRange appliedScope.FileName first.idRange.Start last.idRange.End)
+ Modules = modules
+ AppliedScope = appliedScope
+ IsOwnNamespace = isOwnNamespace }
+
/// An abstract type for reporting the results of name resolution and type checking.
type ITypecheckResultsSink =
abstract NotifyEnvWithScope : range * NameResolutionEnv * AccessorDomain -> unit
abstract NotifyExprHasType : pos * TType * Tastops.DisplayEnv * NameResolutionEnv * AccessorDomain * range -> unit
abstract NotifyNameResolution : pos * Item * Item * TyparInst * ItemOccurence * Tastops.DisplayEnv * NameResolutionEnv * AccessorDomain * range * bool -> unit
abstract NotifyFormatSpecifierLocation : range * int -> unit
+ abstract NotifyOpenDeclaration : OpenDeclaration -> unit
abstract CurrentSource : string option
let (|ValRefOfProp|_|) (pi : PropInfo) = pi.ArbitraryValRef
@@ -1460,6 +1480,7 @@ type TcResultsSinkImpl(g, ?source: string) =
member __.GetHashCode((p:pos,i)) = p.Line + 101 * p.Column + hash i
member __.Equals((p1,i1),(p2,i2)) = posEq p1 p2 && i1 = i2 } )
let capturedMethodGroupResolutions = ResizeArray<_>()
+ let capturedOpenDeclarations = ResizeArray<_>()
let allowedRange (m:range) = not m.IsSynthetic
member this.GetResolutions() =
@@ -1468,6 +1489,8 @@ type TcResultsSinkImpl(g, ?source: string) =
member this.GetSymbolUses() =
TcSymbolUses(g, capturedNameResolutions, capturedFormatSpecifierLocations.ToArray())
+ member this.OpenDeclarations = Seq.toList capturedOpenDeclarations
+
interface ITypecheckResultsSink with
member sink.NotifyEnvWithScope(m,nenv,ad) =
if allowedRange m then
@@ -1504,6 +1527,9 @@ type TcResultsSinkImpl(g, ?source: string) =
member sink.NotifyFormatSpecifierLocation(m, numArgs) =
capturedFormatSpecifierLocations.Add((m, numArgs))
+ member sink.NotifyOpenDeclaration(openDeclaration) =
+ capturedOpenDeclarations.Add(openDeclaration)
+
member sink.CurrentSource = source
@@ -1550,6 +1576,11 @@ let CallExprHasTypeSink (sink:TcResultsSink) (m:range,nenv,typ,denv,ad) =
| None -> ()
| Some sink -> sink.NotifyExprHasType(m.End,typ,denv,nenv,ad,m)
+let CallOpenDeclarationSink (sink:TcResultsSink) (openDeclaration: OpenDeclaration) =
+ match sink.CurrentSink with
+ | None -> ()
+ | Some sink -> sink.NotifyOpenDeclaration(openDeclaration)
+
//-------------------------------------------------------------------------
// Check inferability of type parameters in resolved items.
//-------------------------------------------------------------------------
diff --git a/src/fsharp/NameResolution.fsi b/src/fsharp/NameResolution.fsi
index 60ea7a0e66..93f0009ff8 100755
--- a/src/fsharp/NameResolution.fsi
+++ b/src/fsharp/NameResolution.fsi
@@ -22,6 +22,9 @@ type NameResolver =
member amap : ImportMap
member g : TcGlobals
+/// Get the active pattern elements defined in a module, if any. Cache in the slot in the module type.
+val ActivePatternElemsOfModuleOrNamespace : ModuleOrNamespaceRef -> NameMap
+
[]
/// Represents the item with which a named argument is associated.
type ArgumentContainer =
@@ -307,7 +310,26 @@ type internal TcSymbolUses =
/// Get the locations of all the printf format specifiers in the file
member GetFormatSpecifierLocationsAndArity : unit -> (range * int)[]
-
+/// Represents open declaration statement.
+type internal OpenDeclaration =
+ { /// Long identifier as it's presented in soruce code.
+ LongId: Ident list
+
+ /// Full range of the open declaration.
+ Range : range option
+
+ /// Modules or namespaces which is opened with this declaration.
+ Modules: ModuleOrNamespaceRef list
+
+ /// Scope in which open declaration is visible.
+ AppliedScope: range
+
+ /// If it's `namespace Xxx.Yyy` declaration.
+ IsOwnNamespace: bool }
+
+ /// Create a new instance of OpenDeclaration.
+ static member Create : longId: Ident list * modules: ModuleOrNamespaceRef list * appliedScope: range * isOwnNamespace: bool -> OpenDeclaration
+
/// An abstract type for reporting the results of name resolution and type checking
type ITypecheckResultsSink =
@@ -323,6 +345,9 @@ type ITypecheckResultsSink =
/// Record that a printf format specifier occurred at a specific location in the source
abstract NotifyFormatSpecifierLocation : range * int -> unit
+ /// Record that an open declaration occured in a given scope range
+ abstract NotifyOpenDeclaration : OpenDeclaration -> unit
+
/// Get the current source
abstract CurrentSource : string option
@@ -337,6 +362,10 @@ type internal TcResultsSinkImpl =
/// Get all the uses of all symbols reported to the sink
member GetSymbolUses : unit -> TcSymbolUses
+
+ /// Get all open declarations reported to the sink
+ member OpenDeclarations : OpenDeclaration list
+
interface ITypecheckResultsSink
/// An abstract type for reporting the results of name resolution and type checking, and which allows
@@ -364,6 +393,9 @@ val internal CallNameResolutionSinkReplacing : TcResultsSink -> range * Name
/// Report a specific name resolution at a source range
val internal CallExprHasTypeSink : TcResultsSink -> range * NameResolutionEnv * TType * DisplayEnv * AccessorDomain -> unit
+/// Report an open declaration
+val internal CallOpenDeclarationSink : TcResultsSink -> OpenDeclaration -> unit
+
/// Get all the available properties of a type (both intrinsic and extension)
val internal AllPropInfosOfTypeInScope : InfoReader -> NameResolutionEnv -> string option * AccessorDomain -> FindMemberFlag -> range -> TType -> PropInfo list
diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs
index bf05dcadab..2387b0365c 100755
--- a/src/fsharp/NicePrint.fs
+++ b/src/fsharp/NicePrint.fs
@@ -1299,7 +1299,7 @@ module InfoMemberPrinting =
// Container(argName1:argType1, ..., argNameN:argTypeN) : retType
// Container.Method(argName1:argType1, ..., argNameN:argTypeN) : retType
let private layoutMethInfoCSharpStyle amap m denv (minfo:MethInfo) minst =
- let retTy = minfo.GetFSharpReturnTy(amap, m, minst)
+ let retTy = if minfo.IsConstructor then minfo.EnclosingType else minfo.GetFSharpReturnTy(amap, m, minst)
let layout =
if minfo.IsExtensionMember then
LeftL.leftParen ^^ wordL (tagKeyword (FSComp.SR.typeInfoExtension())) ^^ RightL.rightParen
diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs
index 95c4b119d9..966a5f1880 100755
--- a/src/fsharp/TypeChecker.fs
+++ b/src/fsharp/TypeChecker.fs
@@ -441,11 +441,18 @@ let AddLocalTyconsAndReport tcSink scopem g amap m tycons env =
// Open a structure or an IL namespace
//-------------------------------------------------------------------------
-let OpenModulesOrNamespaces tcSink g amap scopem root env mvvs =
+let OpenModulesOrNamespaces tcSink g amap scopem root env mvvs openDeclaration =
let env =
if isNil mvvs then env else
ModifyNameResEnv (fun nenv -> AddModulesAndNamespacesContentsToNameEnv g amap env.eAccessRights scopem root nenv mvvs) env
CallEnvSink tcSink (scopem, env.NameEnv, env.eAccessRights)
+ CallOpenDeclarationSink tcSink openDeclaration
+ match openDeclaration.Range with
+ | None -> ()
+ | Some range ->
+ for modul in mvvs do
+ let item = Item.ModuleOrNamespaces [modul]
+ CallNameResolutionSink tcSink (range, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Use, env.DisplayEnv, env.eAccessRights)
env
let AddRootModuleOrNamespaceRefs g amap m env modrefs =
@@ -691,7 +698,10 @@ let ImplicitlyOpenOwnNamespace tcSink g amap scopem enclosingNamespacePath env =
let ad = env.eAccessRights
match ResolveLongIndentAsModuleOrNamespace ResultCollectionSettings.AllResults amap scopem OpenQualified env.eNameResEnv ad enclosingNamespacePathToOpen with
- | Result modrefs -> OpenModulesOrNamespaces tcSink g amap scopem false env (List.map p23 modrefs)
+ | Result modrefs ->
+ let modrefs = List.map p23 modrefs
+ let openDecl = OpenDeclaration.Create (enclosingNamespacePathToOpen, modrefs, scopem, true)
+ OpenModulesOrNamespaces tcSink g amap scopem false env modrefs openDecl
| Exception _ -> env
@@ -699,6 +709,36 @@ let ImplicitlyOpenOwnNamespace tcSink g amap scopem enclosingNamespacePath env =
// Helpers for unification
//-------------------------------------------------------------------------
+/// When the context is matching the oldRange then this function shrinks it to newRange.
+/// This can be used to change context over no-op expressions like parens.
+let ShrinkContext env oldRange newRange =
+ match env.eContextInfo with
+ | ContextInfo.NoContext
+ | ContextInfo.RecordFields
+ | ContextInfo.TupleInRecordFields
+ | ContextInfo.ReturnInComputationExpression
+ | ContextInfo.YieldInComputationExpression
+ | ContextInfo.RuntimeTypeTest _
+ | ContextInfo.DowncastUsedInsteadOfUpcast _ ->
+ env
+ | ContextInfo.CollectionElement (b,m) ->
+ if m <> oldRange then env else
+ { env with eContextInfo = ContextInfo.CollectionElement(b,newRange) }
+ | ContextInfo.FollowingPatternMatchClause m ->
+ if m <> oldRange then env else
+ { env with eContextInfo = ContextInfo.FollowingPatternMatchClause newRange }
+ | ContextInfo.PatternMatchGuard m ->
+ if m <> oldRange then env else
+ { env with eContextInfo = ContextInfo.PatternMatchGuard newRange }
+ | ContextInfo.IfExpression m ->
+ if m <> oldRange then env else
+ { env with eContextInfo = ContextInfo.IfExpression newRange }
+ | ContextInfo.OmittedElseBranch m ->
+ if m <> oldRange then env else
+ { env with eContextInfo = ContextInfo.OmittedElseBranch newRange }
+ | ContextInfo.ElseBranchResult m ->
+ if m <> oldRange then env else
+ { env with eContextInfo = ContextInfo.ElseBranchResult newRange }
/// Optimized unification routine that avoids creating new inference
/// variables unnecessarily
@@ -1837,6 +1877,7 @@ let MakeAndPublishSimpleVals cenv env m names mergeNamesInOneNameresEnv =
nameResolutions.Add(pos, item, itemGroup, itemTyparInst, occurence, denv, nenv, ad, m, replacing)
member this.NotifyExprHasType(_, _, _, _, _, _) = assert false // no expr typings in MakeSimpleVals
member this.NotifyFormatSpecifierLocation(_, _) = ()
+ member this.NotifyOpenDeclaration(_) = ()
member this.CurrentSource = None }
use _h = WithNewTypecheckResultsSink(sink, cenv.tcSink)
@@ -5610,6 +5651,7 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) =
// We invoke CallExprHasTypeSink for every construct which is atomic in the syntax, i.e. where a '.' immediately following the
// construct is a dot-lookup for the result of the construct.
CallExprHasTypeSink cenv.tcSink (mWholeExprIncludingParentheses, env.NameEnv, overallTy, env.DisplayEnv, env.eAccessRights)
+ let env = ShrinkContext env mWholeExprIncludingParentheses expr2.Range
TcExpr cenv overallTy env tpenv expr2
| SynExpr.DotIndexedGet _ | SynExpr.DotIndexedSet _
@@ -10077,11 +10119,11 @@ and TcLinearExprs bodyChecker cenv env overallTy tpenv isCompExpr expr cont =
| SynExpr.Sequential (sp, true, e1, e2, m) when not isCompExpr ->
let e1', _ = TcStmtThatCantBeCtorBody cenv env tpenv e1
// tailcall
+ let env = ShrinkContext env m e2.Range
TcLinearExprs bodyChecker cenv env overallTy tpenv isCompExpr e2 (fun (e2', tpenv) ->
cont (Expr.Sequential(e1', e2', NormalSeq, sp, m), tpenv))
| SynExpr.LetOrUse (isRec, isUse, binds, body, m) when not (isUse && isCompExpr) ->
-
if isRec then
// TcLinearExprs processes at most one recursive binding, this is not tailcalling
CheckRecursiveBindingIds binds
@@ -10094,6 +10136,7 @@ and TcLinearExprs bodyChecker cenv env overallTy tpenv isCompExpr expr cont =
else
// TcLinearExprs processes multiple 'let' bindings in a tail recursive way
let mkf, envinner, tpenv = TcLetBinding cenv isUse env ExprContainerInfo ExpressionBinding tpenv (binds, m, body.Range)
+ let envinner = ShrinkContext envinner m body.Range
TcLinearExprs bodyChecker cenv envinner overallTy tpenv isCompExpr body (fun (x, tpenv) ->
cont (fst (mkf (x, overallTy)), tpenv))
| _ ->
@@ -12067,9 +12110,11 @@ let TcOpenDecl tcSink (g:TcGlobals) amap m scopem env (longId : Ident list) =
if IsPartiallyQualifiedNamespace modref then
errorR(Error(FSComp.SR.tcOpenUsedWithPartiallyQualifiedPath(fullDisplayTextOfModRef modref), m)))
- modrefs |> List.iter (fun (_, modref, _) -> CheckEntityAttributes g modref m |> CommitOperationResult)
+ let modrefs = List.map p23 modrefs
+ modrefs |> List.iter (fun modref -> CheckEntityAttributes g modref m |> CommitOperationResult)
- let env = OpenModulesOrNamespaces tcSink g amap scopem false env (List.map p23 modrefs)
+ let openDecl = OpenDeclaration.Create (longId, modrefs, scopem, false)
+ let env = OpenModulesOrNamespaces tcSink g amap scopem false env modrefs openDecl
env
@@ -16834,7 +16879,9 @@ let ApplyAssemblyLevelAutoOpenAttributeToTcEnv g amap (ccu: CcuThunk) scopem env
let modref = mkNonLocalTyconRef (mkNonLocalEntityRef ccu (Array.ofList h)) t
match modref.TryDeref with
| VNone -> warn()
- | VSome _ -> OpenModulesOrNamespaces TcResultsSink.NoSink g amap scopem root env [modref]
+ | VSome _ ->
+ let openDecl = OpenDeclaration.Create ([], [modref], scopem, false)
+ OpenModulesOrNamespaces TcResultsSink.NoSink g amap scopem root env [modref] openDecl
// Add the CCU and apply the "AutoOpen" attributes
let AddCcuToTcEnv(g, amap, scopem, env, assemblyName, ccu, autoOpens, internalsVisible) =
diff --git a/src/fsharp/range.fs b/src/fsharp/range.fs
index f627e00157..aed660be56 100755
--- a/src/fsharp/range.fs
+++ b/src/fsharp/range.fs
@@ -170,7 +170,11 @@ type range(code:int64) =
override r.Equals(obj) = match obj with :? range as r2 -> code = r2.Code | _ -> false
override r.GetHashCode() = hash code
-let mkRange f b e = range (fileIndexOfFile f, b, e)
+let mkRange f b e =
+ // remove relative parts from full path
+ let normalizedFilePath = if Path.IsPathRooted f then try Path.GetFullPath f with _ -> f else f
+ range (fileIndexOfFile normalizedFilePath, b, e)
+
let mkFileIndexRange fi b e = range (fi, b, e)
(* end representation, start derived ops *)
diff --git a/src/fsharp/symbols/SymbolPatterns.fs b/src/fsharp/symbols/SymbolPatterns.fs
new file mode 100644
index 0000000000..aa4be5a32f
--- /dev/null
+++ b/src/fsharp/symbols/SymbolPatterns.fs
@@ -0,0 +1,222 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Compiler.SourceCodeServices
+
+/// Patterns over FSharpSymbol and derivatives.
+[]
+module Symbol =
+ open System.Text.RegularExpressions
+ open System
+
+ let isAttribute<'T> (attribute: FSharpAttribute) =
+ // CompiledName throws exception on DataContractAttribute generated by SQLProvider
+ try attribute.AttributeType.CompiledName = typeof<'T>.Name with _ -> false
+
+ let tryGetAttribute<'T> (attributes: seq) =
+ attributes |> Seq.tryFind isAttribute<'T>
+
+ module Option =
+ let attempt f = try Some(f()) with _ -> None
+
+ let hasModuleSuffixAttribute (entity: FSharpEntity) =
+ entity.Attributes
+ |> tryGetAttribute
+ |> Option.bind (fun a ->
+ Option.attempt (fun _ -> a.ConstructorArguments)
+ |> Option.bind (fun args -> args |> Seq.tryPick (fun (_, arg) ->
+ let res =
+ match arg with
+ | :? int32 as arg when arg = int CompilationRepresentationFlags.ModuleSuffix ->
+ Some()
+ | :? CompilationRepresentationFlags as arg when arg = CompilationRepresentationFlags.ModuleSuffix ->
+ Some()
+ | _ ->
+ None
+ res)))
+ |> Option.isSome
+
+ let isOperator (name: string) =
+ name.StartsWith "( " && name.EndsWith " )" && name.Length > 4
+ && name.Substring (2, name.Length - 4)
+ |> String.forall (fun c -> c <> ' ' && not (Char.IsLetter c))
+
+ let UnnamedUnionFieldRegex = Regex("^Item(\d+)?$", RegexOptions.Compiled)
+
+ let isUnnamedUnionCaseField (field: FSharpField) = UnnamedUnionFieldRegex.IsMatch(field.Name)
+
+ let (|AbbreviatedType|_|) (entity: FSharpEntity) =
+ if entity.IsFSharpAbbreviation then Some entity.AbbreviatedType
+ else None
+
+ let (|TypeWithDefinition|_|) (ty: FSharpType) =
+ if ty.HasTypeDefinition then Some ty.TypeDefinition
+ else None
+
+ let rec getEntityAbbreviatedType (entity: FSharpEntity) =
+ if entity.IsFSharpAbbreviation then
+ match entity.AbbreviatedType with
+ | TypeWithDefinition def -> getEntityAbbreviatedType def
+ | abbreviatedType -> entity, Some abbreviatedType
+ else entity, None
+
+ let rec getAbbreviatedType (fsharpType: FSharpType) =
+ if fsharpType.IsAbbreviation then
+ getAbbreviatedType fsharpType.AbbreviatedType
+ else fsharpType
+
+ let (|Attribute|_|) (entity: FSharpEntity) =
+ let isAttribute (entity: FSharpEntity) =
+ let getBaseType (entity: FSharpEntity) =
+ try
+ match entity.BaseType with
+ | Some (TypeWithDefinition def) -> Some def
+ | _ -> None
+ with _ -> None
+
+ let rec isAttributeType (ty: FSharpEntity option) =
+ match ty with
+ | None -> false
+ | Some ty ->
+ try ty.FullName = "System.Attribute" || isAttributeType (getBaseType ty)
+ with _ -> false
+ isAttributeType (Some entity)
+ if isAttribute entity then Some() else None
+
+ let hasAttribute<'T> (attributes: seq) =
+ attributes |> Seq.exists isAttribute<'T>
+
+ let (|ValueType|_|) (e: FSharpEntity) =
+ if e.IsEnum || e.IsValueType || hasAttribute e.Attributes then Some()
+ else None
+
+#if EXTENSIONTYPING
+ let (|Class|_|) (original: FSharpEntity, abbreviated: FSharpEntity, _) =
+ if abbreviated.IsClass
+ && (not abbreviated.IsStaticInstantiation || original.IsFSharpAbbreviation) then Some()
+ else None
+#else
+ let (|Class|_|) (original: FSharpEntity, abbreviated: FSharpEntity, _) =
+ if abbreviated.IsClass && original.IsFSharpAbbreviation then Some()
+ else None
+#endif
+
+ let (|Record|_|) (e: FSharpEntity) = if e.IsFSharpRecord then Some() else None
+ let (|UnionType|_|) (e: FSharpEntity) = if e.IsFSharpUnion then Some() else None
+ let (|Delegate|_|) (e: FSharpEntity) = if e.IsDelegate then Some() else None
+ let (|FSharpException|_|) (e: FSharpEntity) = if e.IsFSharpExceptionDeclaration then Some() else None
+ let (|Interface|_|) (e: FSharpEntity) = if e.IsInterface then Some() else None
+ let (|AbstractClass|_|) (e: FSharpEntity) =
+ if hasAttribute e.Attributes then Some() else None
+
+ let (|FSharpType|_|) (e: FSharpEntity) =
+ if e.IsDelegate || e.IsFSharpExceptionDeclaration || e.IsFSharpRecord || e.IsFSharpUnion
+ || e.IsInterface || e.IsMeasure
+ || (e.IsFSharp && e.IsOpaque && not e.IsFSharpModule && not e.IsNamespace) then Some()
+ else None
+
+#if EXTENSIONTYPING
+ let (|ProvidedType|_|) (e: FSharpEntity) =
+ if (e.IsProvided || e.IsProvidedAndErased || e.IsProvidedAndGenerated) && e.CompiledName = e.DisplayName then
+ Some()
+ else None
+#endif
+
+ let (|ByRef|_|) (e: FSharpEntity) = if e.IsByRef then Some() else None
+ let (|Array|_|) (e: FSharpEntity) = if e.IsArrayType then Some() else None
+ let (|FSharpModule|_|) (entity: FSharpEntity) = if entity.IsFSharpModule then Some() else None
+
+ let (|Namespace|_|) (entity: FSharpEntity) = if entity.IsNamespace then Some() else None
+#if EXTENSIONTYPING
+ let (|ProvidedAndErasedType|_|) (entity: FSharpEntity) = if entity.IsProvidedAndErased then Some() else None
+#endif
+ let (|Enum|_|) (entity: FSharpEntity) = if entity.IsEnum then Some() else None
+
+ let (|Tuple|_|) (ty: FSharpType option) =
+ ty |> Option.bind (fun ty -> if ty.IsTupleType then Some() else None)
+
+ let (|RefCell|_|) (ty: FSharpType) =
+ match getAbbreviatedType ty with
+ | TypeWithDefinition def when
+ def.IsFSharpRecord && def.FullName = "Microsoft.FSharp.Core.FSharpRef`1" -> Some()
+ | _ -> None
+
+ let (|FunctionType|_|) (ty: FSharpType) =
+ if ty.IsFunctionType then Some()
+ else None
+
+ let (|Pattern|_|) (symbol: FSharpSymbol) =
+ match symbol with
+ | :? FSharpUnionCase
+ | :? FSharpActivePatternCase -> Some()
+ | _ -> None
+
+ /// Field (field, fieldAbbreviatedType)
+ let (|Field|_|) (symbol: FSharpSymbol) =
+ match symbol with
+ | :? FSharpField as field -> Some (field, getAbbreviatedType field.FieldType)
+ | _ -> None
+
+ let (|MutableVar|_|) (symbol: FSharpSymbol) =
+ let isMutable =
+ match symbol with
+ | :? FSharpField as field -> field.IsMutable && not field.IsLiteral
+ | :? FSharpMemberOrFunctionOrValue as func -> func.IsMutable
+ | _ -> false
+ if isMutable then Some() else None
+
+ /// Entity (originalEntity, abbreviatedEntity, abbreviatedType)
+ let (|FSharpEntity|_|) (symbol: FSharpSymbol) =
+ match symbol with
+ | :? FSharpEntity as entity ->
+ let abbreviatedEntity, abbreviatedType = getEntityAbbreviatedType entity
+ Some (entity, abbreviatedEntity, abbreviatedType)
+ | _ -> None
+
+ let (|Parameter|_|) (symbol: FSharpSymbol) =
+ match symbol with
+ | :? FSharpParameter -> Some()
+ | _ -> None
+
+ let (|UnionCase|_|) (e: FSharpSymbol) =
+ match e with
+ | :? FSharpUnionCase as uc -> Some uc
+ | _ -> None
+
+ let (|RecordField|_|) (e: FSharpSymbol) =
+ match e with
+ | :? FSharpField as field ->
+ if field.DeclaringEntity.IsFSharpRecord then Some field else None
+ | _ -> None
+
+ let (|ActivePatternCase|_|) (symbol: FSharpSymbol) =
+ match symbol with
+ | :? FSharpActivePatternCase as case -> Some case
+ | _ -> None
+
+ /// Func (memberFunctionOrValue, fullType)
+ let (|MemberFunctionOrValue|_|) (symbol: FSharpSymbol) =
+ match symbol with
+ | :? FSharpMemberOrFunctionOrValue as func -> Some func
+ | _ -> None
+
+ /// Constructor (enclosingEntity)
+ let (|Constructor|_|) (func: FSharpMemberOrFunctionOrValue) =
+ match func.CompiledName with
+ | ".ctor" | ".cctor" -> func.EnclosingEntity
+ | _ -> None
+
+ let (|Function|_|) excluded (func: FSharpMemberOrFunctionOrValue) =
+ try let typ = func.FullType |> getAbbreviatedType
+ if typ.IsFunctionType
+ && not func.IsPropertyGetterMethod
+ && not func.IsPropertySetterMethod
+ && not excluded
+ && not (isOperator func.DisplayName) then Some()
+ else None
+ with _ -> None
+
+ let (|ExtensionMember|_|) (func: FSharpMemberOrFunctionOrValue) =
+ if func.IsExtensionMember then Some() else None
+
+ let (|Event|_|) (func: FSharpMemberOrFunctionOrValue) =
+ if func.IsEvent then Some () else None
\ No newline at end of file
diff --git a/src/fsharp/symbols/SymbolPatterns.fsi b/src/fsharp/symbols/SymbolPatterns.fsi
new file mode 100644
index 0000000000..e2c00c80ee
--- /dev/null
+++ b/src/fsharp/symbols/SymbolPatterns.fsi
@@ -0,0 +1,60 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Compiler.SourceCodeServices
+
+[]
+#if COMPILER_PUBLIC_API
+module Symbol =
+#else
+module internal Symbol =
+#endif
+ open System.Text.RegularExpressions
+ open System
+
+ val isAttribute<'T> : FSharpAttribute -> bool
+ val tryGetAttribute<'T> : seq -> FSharpAttribute option
+ val hasModuleSuffixAttribute : FSharpEntity -> bool
+ val isOperator : name: string -> bool
+ val isUnnamedUnionCaseField : FSharpField -> bool
+ val (|AbbreviatedType|_|) : FSharpEntity -> FSharpType option
+ val (|TypeWithDefinition|_|) : FSharpType -> FSharpEntity option
+ val getEntityAbbreviatedType : FSharpEntity -> (FSharpEntity * FSharpType option)
+ val getAbbreviatedType : FSharpType -> FSharpType
+ val (|Attribute|_|) : FSharpEntity -> unit option
+ val hasAttribute<'T> : seq -> bool
+ val (|ValueType|_|) : FSharpEntity -> unit option
+ val (|Class|_|) : original: FSharpEntity * abbreviated: FSharpEntity * 'a -> unit option
+ val (|Record|_|) : FSharpEntity -> unit option
+ val (|UnionType|_|) : FSharpEntity -> unit option
+ val (|Delegate|_|) : FSharpEntity -> unit option
+ val (|FSharpException|_|) : FSharpEntity -> unit option
+ val (|Interface|_|) : FSharpEntity -> unit option
+ val (|AbstractClass|_|) : FSharpEntity -> unit option
+ val (|FSharpType|_|) : FSharpEntity -> unit option
+#if EXTENSIONTYPING
+ val (|ProvidedType|_|) : FSharpEntity -> unit option
+#endif
+ val (|ByRef|_|) : FSharpEntity -> unit option
+ val (|Array|_|) : FSharpEntity -> unit option
+ val (|FSharpModule|_|) : FSharpEntity -> unit option
+ val (|Namespace|_|) : FSharpEntity -> unit option
+#if EXTENSIONTYPING
+ val (|ProvidedAndErasedType|_|) : FSharpEntity -> unit option
+#endif
+ val (|Enum|_|) : FSharpEntity -> unit option
+ val (|Tuple|_|) : FSharpType option -> unit option
+ val (|RefCell|_|) : FSharpType -> unit option
+ val (|FunctionType|_|) : FSharpType -> unit option
+ val (|Pattern|_|) : FSharpSymbol -> unit option
+ val (|Field|_|) : FSharpSymbol -> (FSharpField * FSharpType) option
+ val (|MutableVar|_|) : FSharpSymbol -> unit option
+ val (|FSharpEntity|_|) : FSharpSymbol -> (FSharpEntity * FSharpEntity * FSharpType option) option
+ val (|Parameter|_|) : FSharpSymbol -> unit option
+ val (|UnionCase|_|) : FSharpSymbol -> FSharpUnionCase option
+ val (|RecordField|_|) : FSharpSymbol -> FSharpField option
+ val (|ActivePatternCase|_|) : FSharpSymbol -> FSharpActivePatternCase option
+ val (|MemberFunctionOrValue|_|) : FSharpSymbol -> FSharpMemberOrFunctionOrValue option
+ val (|Constructor|_|) : FSharpMemberOrFunctionOrValue -> FSharpEntity option
+ val (|Function|_|) : excluded: bool -> FSharpMemberOrFunctionOrValue -> unit option
+ val (|ExtensionMember|_|) : FSharpMemberOrFunctionOrValue -> unit option
+ val (|Event|_|) : FSharpMemberOrFunctionOrValue -> unit option
\ No newline at end of file
diff --git a/src/fsharp/symbols/Symbols.fs b/src/fsharp/symbols/Symbols.fs
index db5f96b3d1..dd6c04451b 100755
--- a/src/fsharp/symbols/Symbols.fs
+++ b/src/fsharp/symbols/Symbols.fs
@@ -310,7 +310,7 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
#else
elif entity.IsTypeAbbrev then None
#endif
- elif entity.IsNamespace then Some entity.DemangledModuleOrNamespaceName
+ elif entity.IsNamespace then Some entity.DemangledModuleOrNamespaceName
else
match entity.CompiledRepresentation with
| CompiledTypeRepr.ILAsmNamed(tref, _, _) -> Some tref.FullName
@@ -619,6 +619,14 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
yield! walkParts parts ]
res
+ member x.ActivePatternCases =
+ protect <| fun () ->
+ ActivePatternElemsOfModuleOrNamespace x.Entity
+ |> Map.toList
+ |> List.map (fun (_, apref) ->
+ let item = Item.ActivePatternCase apref
+ FSharpActivePatternCase(cenv, apref.ActivePatternInfo, apref.ActivePatternVal.Type, apref.CaseIndex, Some apref.ActivePatternVal, item))
+
override x.Equals(other: obj) =
box x === other ||
match other with
@@ -2259,6 +2267,14 @@ type FSharpSymbol with
| :? FSharpMemberFunctionOrValue as x -> Some x.Accessibility
| _ -> None
+/// Represents open declaration in F# code.
+type FSharpOpenDeclaration =
+ { LongId: Ident list
+ Range: range option
+ Modules: FSharpEntity list
+ AppliedScope: range
+ IsOwnNamespace: bool }
+
[]
type FSharpSymbolUse(g:TcGlobals, denv: DisplayEnv, symbol:FSharpSymbol, itemOcc, range: range) =
member __.Symbol = symbol
diff --git a/src/fsharp/symbols/Symbols.fsi b/src/fsharp/symbols/Symbols.fsi
index 8cc1c0ed06..e01c3d9942 100644
--- a/src/fsharp/symbols/Symbols.fsi
+++ b/src/fsharp/symbols/Symbols.fsi
@@ -7,6 +7,7 @@ open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.AccessibilityLogic
open Microsoft.FSharp.Compiler.CompileOps
open Microsoft.FSharp.Compiler.Range
+open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.Tast
open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.NameResolution
@@ -329,6 +330,9 @@ and [] internal FSharpEntity =
/// Get all compilation paths, taking `Module` suffixes into account.
member AllCompilationPaths : string list
+ /// Get all active pattern cases defined in all active patterns in the module.
+ member ActivePatternCases : FSharpActivePatternCase list
+
/// Represents a delegate signature in an F# symbol
#if COMPILER_PUBLIC_API
and [] FSharpDelegateSignature =
@@ -1065,7 +1069,26 @@ and [] internal FSharpAttribute =
/// Format the attribute using the rules of the given display context
member Format : context: FSharpDisplayContext -> string
+/// Represents open declaration in F# code.
+#if COMPILER_PUBLIC_API
+type FSharpOpenDeclaration =
+#else
+type internal FSharpOpenDeclaration =
+#endif
+ { /// Idents.
+ LongId: Ident list
+
+ /// Range of the open declaration.
+ Range: range option
+ /// Modules or namespaces which is opened with this declaration.
+ Modules: FSharpEntity list
+
+ /// Scope in which open declaration is visible.
+ AppliedScope: range
+
+ /// If it's `namespace Xxx.Yyy` declaration.
+ IsOwnNamespace: bool }
/// Represents the use of an F# symbol from F# source code
[]
diff --git a/src/fsharp/vs/IncrementalBuild.fs b/src/fsharp/vs/IncrementalBuild.fs
index 89c315001a..56f7113c37 100755
--- a/src/fsharp/vs/IncrementalBuild.fs
+++ b/src/fsharp/vs/IncrementalBuild.fs
@@ -1028,6 +1028,7 @@ type TypeCheckAccumulator =
tcEnvAtEndOfFile: TcEnv
tcResolutions: TcResolutions list
tcSymbolUses: TcSymbolUses list
+ tcOpenDeclarations: OpenDeclaration list
topAttribs:TopAttribs option
typedImplFiles:TypedImplFile list
tcDependencyFiles: string list
@@ -1102,6 +1103,7 @@ type PartialCheckResults =
Errors: (PhasedDiagnostic * FSharpErrorSeverity) list
TcResolutions: TcResolutions list
TcSymbolUses: TcSymbolUses list
+ TcOpenDeclarations: OpenDeclaration list
TcDependencyFiles: string list
TopAttribs: TopAttribs option
TimeStamp: System.DateTime
@@ -1116,6 +1118,7 @@ type PartialCheckResults =
Errors = tcAcc.tcErrors
TcResolutions = tcAcc.tcResolutions
TcSymbolUses = tcAcc.tcSymbolUses
+ TcOpenDeclarations = tcAcc.tcOpenDeclarations
TcDependencyFiles = tcAcc.tcDependencyFiles
TopAttribs = tcAcc.topAttribs
TimeStamp = timestamp
@@ -1327,6 +1330,7 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput
tcEnvAtEndOfFile=tcInitial
tcResolutions=[]
tcSymbolUses=[]
+ tcOpenDeclarations=[]
topAttribs=None
typedImplFiles=[]
tcDependencyFiles=basicDependencies
@@ -1375,6 +1379,7 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput
typedImplFiles=typedImplFiles
tcResolutions=tcAcc.tcResolutions @ [tcResolutions]
tcSymbolUses=tcAcc.tcSymbolUses @ [tcSymbolUses]
+ tcOpenDeclarations=tcAcc.tcOpenDeclarations @ sink.OpenDeclarations
tcErrors = tcAcc.tcErrors @ parseErrors @ capturingErrorLogger.GetErrors()
tcDependencyFiles = filename :: tcAcc.tcDependencyFiles }
}
@@ -1622,6 +1627,9 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput
member builder.GetCheckResultsAfterLastFileInProject (ctok: CompilationThreadToken) =
builder.GetCheckResultsBeforeSlotInProject(ctok, builder.GetSlotsCount())
+ member builder.DeduplicateParsedInputModuleNameInProject (input) =
+ DeduplicateParsedInputModuleName moduleNamesDict input
+
member __.GetCheckResultsAndImplementationsForProject(ctok: CompilationThreadToken) =
cancellable {
let cache = TimeStampCache(defaultTimeStamp)
diff --git a/src/fsharp/vs/IncrementalBuild.fsi b/src/fsharp/vs/IncrementalBuild.fsi
index cca9dba7f9..e29f3408c6 100755
--- a/src/fsharp/vs/IncrementalBuild.fsi
+++ b/src/fsharp/vs/IncrementalBuild.fsi
@@ -54,6 +54,9 @@ type internal PartialCheckResults =
/// Represents the collected uses of symbols from type checking
TcSymbolUses: TcSymbolUses list
+ /// Represents open declarations
+ TcOpenDeclarations: OpenDeclaration list
+
TcDependencyFiles: string list
/// Represents the collected attributes to apply to the module of assuembly generates
@@ -142,6 +145,8 @@ type internal IncrementalBuilder =
// TODO: make this an Eventually (which can be scheduled) or an Async (which can be cancelled)
member GetCheckResultsAndImplementationsForProject : CompilationThreadToken -> Cancellable
+ member DeduplicateParsedInputModuleNameInProject: Ast.ParsedInput -> Ast.ParsedInput
+
/// Get the logical time stamp that is associated with the output of the project if it were gully built immediately
member GetLogicalTimeStampForProject: TimeStampCache * CompilationThreadToken -> DateTime
diff --git a/src/fsharp/vs/QuickParse.fs b/src/fsharp/vs/QuickParse.fs
new file mode 100644
index 0000000000..1530759307
--- /dev/null
+++ b/src/fsharp/vs/QuickParse.fs
@@ -0,0 +1,358 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Compiler
+
+open System
+open Microsoft.FSharp.Compiler.SourceCodeServices
+
+/// Qualified long name.
+type PartialLongName =
+ { /// Qualifying idents, prior to the last dot, not including the last part.
+ QualifyingIdents: string list
+
+ /// Last part of long ident.
+ PartialIdent: string
+
+ /// The column number at the end of full partial name.
+ EndColumn: int
+
+ /// Position of the last dot.
+ LastDotPos: int option }
+
+ /// Empty patial long name.
+ static member Empty(endColumn: int) = { QualifyingIdents = []; PartialIdent = ""; EndColumn = endColumn; LastDotPos = None }
+
+/// Methods for cheaply and innacurately parsing F#.
+///
+/// These methods are very old and are mostly to do with extracting "long identifier islands"
+/// A.B.C
+/// from F# source code, an approach taken from pre-F# VS samples for implementing intelliense.
+///
+/// This code should really no longer be needed since the language service has access to
+/// parsed F# source code ASTs. However, the long identifiers are still passed back to GetDeclarations and friends in the
+/// F# Compiler Service and it's annoyingly hard to remove their use completely.
+///
+/// In general it is unlikely much progress will be made by fixing this code - it will be better to
+/// extract more information from the F# ASTs.
+///
+/// It's also surprising how hard even the job of getting long identifier islands can be. For example the code
+/// below is inaccurate for long identifier chains involving ``...`` identifiers. And there are special cases
+/// for active pattern names and so on.
+module QuickParse =
+ open PrettyNaming
+ /// Puts us after the last character.
+ let MagicalAdjustmentConstant = 1
+
+ // Adjusts the token tag for the given identifier
+ // - if we're inside active pattern name (at the bar), correct the token TAG to be an identifier
+ let CorrectIdentifierToken (tokenText: string) (tokenTag: int) =
+ if tokenText.EndsWith "|" then Microsoft.FSharp.Compiler.Parser.tagOfToken (Microsoft.FSharp.Compiler.Parser.token.IDENT tokenText)
+ else tokenTag
+
+ let rec isValidStrippedName (name:string) idx =
+ if idx = name.Length then false
+ elif IsIdentifierPartCharacter name.[idx] then true
+ else isValidStrippedName name (idx + 1)
+
+ // Utility function that recognizes whether a name is valid active pattern name
+ // Extracts the 'core' part without surrounding bars and checks whether it contains some identifier
+ // (Note, this doesn't have to be precise, because this is checked by backround compiler,
+ // but it has to be good enough to distinguish operators and active pattern names)
+ let private isValidActivePatternName (name: string) =
+
+ // Strip the surrounding bars (e.g. from "|xyz|_|") to get "xyz"
+ match name.StartsWith("|", System.StringComparison.Ordinal),
+ name.EndsWith("|_|", System.StringComparison.Ordinal),
+ name.EndsWith("|", System.StringComparison.Ordinal) with
+ | true, true, _ when name.Length > 4 -> isValidStrippedName (name.Substring(1, name.Length - 4)) 0
+ | true, _, true when name.Length > 2 -> isValidStrippedName (name.Substring(1, name.Length - 2)) 0
+ | _ -> false
+
+ let GetCompleteIdentifierIslandImpl (lineStr: string) (index: int) : (string * int * bool) option =
+ if index < 0 || isNull lineStr || index >= lineStr.Length then None
+ else
+ let fixup =
+ match () with
+ // at a valid position, on a valid character
+ | _ when (index < lineStr.Length) && (lineStr.[index] = '|' || IsIdentifierPartCharacter lineStr.[index]) -> Some index
+ | _ -> None // not on a word or '.'
+
+
+ let (|Char|_|) p = if p >=0 && p < lineStr.Length then Some(lineStr.[p]) else None
+ let (|IsLongIdentifierPartChar|_|) c = if IsLongIdentifierPartCharacter c then Some () else None
+ let (|IsIdentifierPartChar|_|) c = if IsIdentifierPartCharacter c then Some () else None
+
+ let rec searchLeft p =
+ match (p - 1), (p - 2) with
+ | Char '|', Char '[' -> p // boundary of array declaration - stop
+ | Char '|', _
+ | Char IsLongIdentifierPartChar, _ -> searchLeft (p - 1) // allow normal chars and '.'s
+ | _ -> p
+
+ let rec searchRight p =
+ match (p + 1), (p + 2) with
+ | Char '|', Char ']' -> p // boundary of array declaration - stop
+ | Char '|', _
+ | Char IsIdentifierPartChar, _ -> searchRight (p + 1) // allow only normal chars (stop at '.')
+ | _ -> p
+
+ let tickColsOpt =
+ let rec walkOutsideBackticks i =
+ if i >= lineStr.Length then None
+ else
+ match i, i + 1 with
+ | Char '`', Char '`' ->
+ // dive into backticked part
+ // if pos = i then it will be included in backticked range ($``identifier``)
+ walkInsideBackticks (i + 2) i
+ | _, _ ->
+ if i >= index then None
+ else
+ // we still not reached position p - continue walking
+ walkOutsideBackticks (i + 1)
+ and walkInsideBackticks i start =
+ if i >= lineStr.Length then None // non-closed backticks
+ else
+ match i, i + 1 with
+ | Char '`', Char '`' ->
+ // found closing pair of backticks
+ // if target position is between start and current pos + 1 (entire range of escaped identifier including backticks) - return success
+ // else climb outside and continue walking
+ if index >= start && index < (i + 2) then Some (start, i)
+ else walkOutsideBackticks (i + 2)
+ | _, _ -> walkInsideBackticks (i + 1) start
+
+ walkOutsideBackticks 0
+
+ match tickColsOpt with
+ | Some (prevTickTick, idxTickTick) ->
+ // inside ``identifier`` (which can contain any characters!) so we try returning its location
+ let pos = idxTickTick + 1 + MagicalAdjustmentConstant
+ let ident = lineStr.Substring(prevTickTick, idxTickTick - prevTickTick + 2)
+ Some(ident, pos, true)
+ | _ ->
+ // find location of an ordinary identifier
+ fixup |> Option.bind (fun p ->
+ let l = searchLeft p
+ let r = searchRight p
+ let ident = lineStr.Substring (l, r - l + 1)
+ if ident.IndexOf('|') <> -1 && not(isValidActivePatternName(ident)) then None else
+ let pos = r + MagicalAdjustmentConstant
+ Some(ident, pos, false)
+ )
+
+ /// Given a string and a position in that string, find an identifier as
+ /// expected by `GotoDefinition`. This will work when the cursor is
+ /// immediately before the identifier, within the identifier, or immediately
+ /// after the identifier.
+ ///
+ /// 'tolerateJustAfter' indicates that we tolerate being one character after the identifier, used
+ /// for goto-definition
+ ///
+ /// In general, only identifiers composed from upper/lower letters and '.' are supported, but there
+ /// are a couple of explicitly handled exceptions to allow some common scenarios:
+ /// - When the name contains only letters and '|' symbol, it may be an active pattern, so we
+ /// treat it as a valid identifier - e.g. let ( |Identitiy| ) a = a
+ /// (but other identifiers that include '|' are not allowed - e.g. '||' operator)
+ /// - It searches for double tick (``) to see if the identifier could be something like ``a b``
+ ///
+ /// REVIEW: Also support, e.g., operators, performing the necessary mangling.
+ /// (i.e., I would like that the name returned here can be passed as-is
+ /// (post `.`-chopping) to `GetDeclarationLocation.)
+ ///
+ /// In addition, return the position where a `.` would go if we were making
+ /// a call to `DeclItemsForNamesAtPosition` for intellisense. This will
+ /// allow us to use find the correct qualified items rather than resorting
+ /// to the more expensive and less accurate environment lookup.
+ let GetCompleteIdentifierIsland (tolerateJustAfter: bool) (lineStr: string) (index: int) : (string * int * bool) option =
+ if String.IsNullOrEmpty lineStr then None
+ else
+ let directResult = GetCompleteIdentifierIslandImpl lineStr index
+ if tolerateJustAfter && directResult = None then
+ GetCompleteIdentifierIslandImpl lineStr (index - 1)
+ else
+ directResult
+
+ let private defaultName = [], ""
+
+ /// Get the partial long name of the identifier to the left of index.
+ let GetPartialLongName(lineStr: string, index: int) =
+ if isNull lineStr then defaultName
+ elif index < 0 then defaultName
+ elif index >= lineStr.Length then defaultName
+ else
+ let IsIdentifierPartCharacter pos = IsIdentifierPartCharacter lineStr.[pos]
+ let IsLongIdentifierPartCharacter pos = IsLongIdentifierPartCharacter lineStr.[pos]
+ let IsDot pos = lineStr.[pos] = '.'
+
+ let rec InLeadingIdentifier(pos,right,(prior,residue)) =
+ let PushName() = ((lineStr.Substring(pos+1,right-pos-1))::prior),residue
+ if pos < 0 then PushName()
+ elif IsIdentifierPartCharacter pos then InLeadingIdentifier(pos-1,right,(prior,residue))
+ elif IsDot pos then InLeadingIdentifier(pos-1,pos,PushName())
+ else PushName()
+
+ let rec InName(pos,startResidue,right) =
+ let NameAndResidue() =
+ [lineStr.Substring(pos+1,startResidue-pos-1)],(lineStr.Substring(startResidue+1,right-startResidue))
+ if pos < 0 then [lineStr.Substring(pos+1,startResidue-pos-1)],(lineStr.Substring(startResidue+1,right-startResidue))
+ elif IsIdentifierPartCharacter pos then InName(pos-1,startResidue,right)
+ elif IsDot pos then InLeadingIdentifier(pos-1,pos,NameAndResidue())
+ else NameAndResidue()
+
+ let rec InResidue(pos,right) =
+ if pos < 0 then [],lineStr.Substring(pos+1,right-pos)
+ elif IsDot pos then InName(pos-1,pos,right)
+ elif IsLongIdentifierPartCharacter pos then InResidue(pos-1, right)
+ else [],lineStr.Substring(pos+1,right-pos)
+
+ let result = InResidue(index,index)
+ result
+
+ type private EatCommentCallContext =
+ | SkipWhiteSpaces of ident: string * current: string list * throwAwayNext: bool
+ | StartIdentifier of current: string list * throwAway: bool
+
+ /// Get the partial long name of the identifier to the left of index.
+ /// For example, for `System.DateTime.Now` it returns PartialLongName ([|"System"; "DateTime"|], "Now", Some 32), where "32" pos of the last dot.
+ let GetPartialLongNameEx(lineStr: string, index: int) : PartialLongName =
+ if isNull lineStr then PartialLongName.Empty(index)
+ elif index < 0 then PartialLongName.Empty(index)
+ elif index >= lineStr.Length then PartialLongName.Empty(index)
+ else
+ let IsIdentifierPartCharacter pos = IsIdentifierPartCharacter lineStr.[pos]
+ let IsIdentifierStartCharacter pos = IsIdentifierPartCharacter pos
+ let IsDot pos = lineStr.[pos] = '.'
+ let IsTick pos = lineStr.[pos] = '`'
+ let IsEndOfComment pos = pos < index - 1 && lineStr.[pos] = '*' && lineStr.[pos + 1] = ')'
+ let IsStartOfComment pos = pos < index - 1 && lineStr.[pos] = '(' && lineStr.[pos + 1] = '*'
+ let IsWhitespace pos = Char.IsWhiteSpace(lineStr.[pos])
+
+ let rec SkipWhitespaceBeforeDotIdentifier(pos, ident, current, throwAwayNext, lastDotPos) =
+ if pos > index then PartialLongName.Empty(index) // we're in whitespace after an identifier, if this is where the cursor is, there is no PLID here
+ elif IsWhitespace pos then SkipWhitespaceBeforeDotIdentifier(pos+1,ident,current,throwAwayNext,lastDotPos)
+ elif IsDot pos then AtStartOfIdentifier(pos+1,ident::current,throwAwayNext, Some pos)
+ elif IsStartOfComment pos then EatComment(1, pos + 1, EatCommentCallContext.SkipWhiteSpaces(ident, current, throwAwayNext), lastDotPos)
+ else AtStartOfIdentifier(pos,[],false,None) // Throw away what we have and start over.
+
+ and EatComment (nesting, pos, callContext,lastDotPos) =
+ if pos > index then PartialLongName.Empty(index) else
+ if IsStartOfComment pos then
+ // track balance of closing '*)'
+ EatComment(nesting + 1, pos + 2, callContext,lastDotPos)
+ else
+ if IsEndOfComment pos then
+ if nesting = 1 then
+ // all right, we are at the end of comment, jump outside
+ match callContext with
+ | EatCommentCallContext.SkipWhiteSpaces(ident, current, throwAway) ->
+ SkipWhitespaceBeforeDotIdentifier(pos + 2, ident, current, throwAway,lastDotPos)
+ | EatCommentCallContext.StartIdentifier(current, throwAway) ->
+ AtStartOfIdentifier(pos + 2, current, throwAway,lastDotPos)
+ else
+ // reduce level of nesting and continue
+ EatComment(nesting - 1, pos + 2, callContext, lastDotPos)
+ else
+ // eat next char
+ EatComment(nesting, pos + 1, callContext, lastDotPos)
+
+ and InUnquotedIdentifier(left:int,pos:int,current,throwAwayNext,lastDotPos) =
+ if pos > index then
+ if throwAwayNext then
+ PartialLongName.Empty(index)
+ else
+ { QualifyingIdents = current
+ PartialIdent = lineStr.Substring(left,pos-left)
+ EndColumn = index
+ LastDotPos = lastDotPos }
+ else
+ if IsIdentifierPartCharacter pos then InUnquotedIdentifier(left,pos+1,current,throwAwayNext,lastDotPos)
+ elif IsDot pos then
+ let ident = lineStr.Substring(left,pos-left)
+ AtStartOfIdentifier(pos+1,ident::current,throwAwayNext, Some pos)
+ elif IsWhitespace pos || IsStartOfComment pos then
+ let ident = lineStr.Substring(left,pos-left)
+ SkipWhitespaceBeforeDotIdentifier(pos, ident, current, throwAwayNext, lastDotPos)
+ else AtStartOfIdentifier(pos,[],false,None) // Throw away what we have and start over.
+
+ and InQuotedIdentifier(left:int,pos:int, current,throwAwayNext,lastDotPos) =
+ if pos > index then
+ if throwAwayNext then
+ PartialLongName.Empty(index)
+ else
+ { QualifyingIdents = current
+ PartialIdent = lineStr.Substring(left,pos-left)
+ EndColumn = index
+ LastDotPos = lastDotPos }
+ else
+ let remainingLength = lineStr.Length - pos
+ if IsTick pos && remainingLength > 1 && IsTick(pos+1) then
+ let ident = lineStr.Substring(left, pos-left)
+ SkipWhitespaceBeforeDotIdentifier(pos+2,ident,current,throwAwayNext,lastDotPos)
+ else InQuotedIdentifier(left,pos+1,current,throwAwayNext,lastDotPos)
+
+ and AtStartOfIdentifier(pos:int, current, throwAwayNext, lastDotPos: int option) =
+ if pos > index then
+ if throwAwayNext then
+ PartialLongName.Empty(index)
+ else
+ { QualifyingIdents = current
+ PartialIdent = ""
+ EndColumn = index
+ LastDotPos = lastDotPos }
+ else
+ if IsWhitespace pos then AtStartOfIdentifier(pos+1,current,throwAwayNext, lastDotPos)
+ else
+ let remainingLength = lineStr.Length - pos
+ if IsTick pos && remainingLength > 1 && IsTick(pos+1) then InQuotedIdentifier(pos+2,pos+2,current,throwAwayNext,lastDotPos)
+ elif IsStartOfComment pos then EatComment(1, pos + 1, EatCommentCallContext.StartIdentifier(current, throwAwayNext), lastDotPos)
+ elif IsIdentifierStartCharacter pos then InUnquotedIdentifier(pos,pos+1,current,throwAwayNext,lastDotPos)
+ elif IsDot pos then
+ if pos = 0 then
+ // dot on first char of line, currently treat it like empty identifier to the left
+ AtStartOfIdentifier(pos+1,""::current,throwAwayNext, Some pos)
+ elif not (pos > 0 && (IsIdentifierPartCharacter(pos-1) || IsWhitespace(pos-1))) then
+ // it's not dots as part.of.a.long.ident, it's e.g. the range operator (..), or some other multi-char operator ending in dot
+ if lineStr.[pos-1] = ')' then
+ // one very problematic case is someCall(args).Name
+ // without special logic, we will decide that ). is an operator and parse Name as the plid
+ // but in fact this is an expression tail, and we don't want a plid, rather we need to use expression typings at that location
+ // so be sure not to treat the name here as a plid
+ AtStartOfIdentifier(pos+1,[],true,None) // Throw away what we have, and the next apparent plid, and start over.
+ else
+ AtStartOfIdentifier(pos+1,[],false,None) // Throw away what we have and start over.
+ else
+ AtStartOfIdentifier(pos+1,""::current,throwAwayNext, Some pos)
+ else AtStartOfIdentifier(pos+1,[],throwAwayNext, None)
+ let partialLongName = AtStartOfIdentifier(0, [], false, None)
+
+ match List.rev partialLongName.QualifyingIdents with
+ | s :: _ when s.Length > 0 && Char.IsDigit(s.[0]) -> PartialLongName.Empty(index) // "2.0" is not a longId (this might not be right for ``2.0`` but good enough for common case)
+ | plid -> { partialLongName with QualifyingIdents = plid }
+
+ let TokenNameEquals (tokenInfo: FSharpTokenInfo) (token2: string) =
+ String.Compare(tokenInfo .TokenName, token2, StringComparison.OrdinalIgnoreCase) = 0
+
+ // The prefix of the sequence of token names to look for in TestMemberOrOverrideDeclaration, in reverse order
+ let private expected = [ [|"dot"|]; [|"ident"|]; [|"member"; "override"|] ]
+
+ /// Tests whether the user is typing something like "member x." or "override (*comment*) x."
+ let TestMemberOrOverrideDeclaration (tokens: FSharpTokenInfo[]) =
+ let filteredReversed =
+ tokens
+ |> Array.filter (fun tok ->
+ // cut out whitespaces\comments\access modifiers
+ not (TokenNameEquals tok "comment") &&
+ not (TokenNameEquals tok "whitespace") &&
+ not (TokenNameEquals tok "private") &&
+ not (TokenNameEquals tok "internal") &&
+ not (TokenNameEquals tok "public")
+ )
+ |> Array.rev
+
+ if filteredReversed.Length < expected.Length then false
+ else
+ // check whether sequences match
+ (filteredReversed, expected) ||> Seq.forall2 (fun tok expect ->
+ expect |> Array.exists (TokenNameEquals tok) )
+
diff --git a/src/fsharp/vs/QuickParse.fsi b/src/fsharp/vs/QuickParse.fsi
new file mode 100644
index 0000000000..78bfa2b39f
--- /dev/null
+++ b/src/fsharp/vs/QuickParse.fsi
@@ -0,0 +1,90 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Compiler
+
+open System
+open Microsoft.FSharp.Compiler.SourceCodeServices
+
+/// Qualified long name.
+#if COMPILER_PUBLIC_API
+type PartialLongName =
+#else
+type internal PartialLongName =
+#endif
+ { /// Qualifying idents, prior to the last dot, not including the last part.
+ QualifyingIdents: string list
+
+ /// Last part of long ident.
+ PartialIdent: string
+
+ /// The column number at the end of full partial name.
+ EndColumn: int
+
+ /// Position of the last dot.
+ LastDotPos: int option }
+
+ /// Empty patial long name.
+ static member Empty: endColumn: int -> PartialLongName
+
+/// Methods for cheaply and innacurately parsing F#.
+///
+/// These methods are very old and are mostly to do with extracting "long identifier islands"
+/// A.B.C
+/// from F# source code, an approach taken from pre-F# VS samples for implementing intelliense.
+///
+/// This code should really no longer be needed since the language service has access to
+/// parsed F# source code ASTs. However, the long identifiers are still passed back to GetDeclarations and friends in the
+/// F# Compiler Service and it's annoyingly hard to remove their use completely.
+///
+/// In general it is unlikely much progress will be made by fixing this code - it will be better to
+/// extract more information from the F# ASTs.
+///
+/// It's also surprising how hard even the job of getting long identifier islands can be. For example the code
+/// below is inaccurate for long identifier chains involving ``...`` identifiers. And there are special cases
+/// for active pattern names and so on.
+#if COMPILER_PUBLIC_API
+module QuickParse =
+#else
+module internal QuickParse =
+#endif
+ /// Puts us after the last character.
+ val MagicalAdjustmentConstant : int
+
+ // Adjusts the token tag for the given identifier
+ // - if we're inside active pattern name (at the bar), correct the token TAG to be an identifier
+ val CorrectIdentifierToken : tokenText: string -> tokenTag: int -> int
+
+ /// Given a string and a position in that string, find an identifier as
+ /// expected by `GotoDefinition`. This will work when the cursor is
+ /// immediately before the identifier, within the identifier, or immediately
+ /// after the identifier.
+ ///
+ /// 'tolerateJustAfter' indicates that we tolerate being one character after the identifier, used
+ /// for goto-definition
+ ///
+ /// In general, only identifiers composed from upper/lower letters and '.' are supported, but there
+ /// are a couple of explicitly handled exceptions to allow some common scenarios:
+ /// - When the name contains only letters and '|' symbol, it may be an active pattern, so we
+ /// treat it as a valid identifier - e.g. let ( |Identitiy| ) a = a
+ /// (but other identifiers that include '|' are not allowed - e.g. '||' operator)
+ /// - It searches for double tick (``) to see if the identifier could be something like ``a b``
+ ///
+ /// REVIEW: Also support, e.g., operators, performing the necessary mangling.
+ /// (i.e., I would like that the name returned here can be passed as-is
+ /// (post `.`-chopping) to `GetDeclarationLocation.)
+ ///
+ /// In addition, return the position where a `.` would go if we were making
+ /// a call to `DeclItemsForNamesAtPosition` for intellisense. This will
+ /// allow us to use find the correct qualified items rather than resorting
+ /// to the more expensive and less accurate environment lookup.
+ val GetCompleteIdentifierIsland : tolerateJustAfter: bool -> tokenText: string -> index: int -> (string * int * bool) option
+
+ /// Get the partial long name of the identifier to the left of index.
+ val GetPartialLongName : lineStr: string * index: int -> (string list * string)
+
+ /// Get the partial long name of the identifier to the left of index.
+ /// For example, for `System.DateTime.Now` it returns PartialLongName ([|"System"; "DateTime"|], "Now", Some 32), where "32" pos of the last dot.
+ val GetPartialLongNameEx : lineStr: string * index: int -> PartialLongName
+
+ /// Tests whether the user is typing something like "member x." or "override (*comment*) x."
+ val TestMemberOrOverrideDeclaration : tokens: FSharpTokenInfo[] -> bool
\ No newline at end of file
diff --git a/src/fsharp/vs/ServiceAnalysis.fs b/src/fsharp/vs/ServiceAnalysis.fs
new file mode 100644
index 0000000000..5923459c03
--- /dev/null
+++ b/src/fsharp/vs/ServiceAnalysis.fs
@@ -0,0 +1,159 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Compiler.SourceCodeServices
+
+open Microsoft.FSharp.Compiler
+open Microsoft.FSharp.Compiler.Ast
+open Microsoft.FSharp.Compiler.Range
+
+module UnusedOpens =
+ open Microsoft.FSharp.Compiler.PrettyNaming
+ open System.Runtime.CompilerServices
+
+ type Module =
+ { Entity: FSharpEntity
+ IsNestedAutoOpen: bool }
+
+ member this.ChildSymbols =
+ seq { for ent in this.Entity.NestedEntities do
+ yield ent :> FSharpSymbol
+
+ if ent.IsFSharpRecord then
+ for rf in ent.FSharpFields do
+ yield upcast rf
+
+ if ent.IsFSharpUnion && not (Symbol.hasAttribute ent.Attributes) then
+ for unionCase in ent.UnionCases do
+ yield upcast unionCase
+
+ if Symbol.hasAttribute ent.Attributes then
+ for fv in ent.MembersFunctionsAndValues do
+ // fv.IsExtensionMember is always false for C# extension methods returning by `MembersFunctionsAndValues`,
+ // so we have to check Extension attribute instead.
+ // (note: fv.IsExtensionMember has proper value for symbols returning by GetAllUsesOfAllSymbolsInFile though)
+ if Symbol.hasAttribute fv.Attributes then
+ yield upcast fv
+
+ for apCase in this.Entity.ActivePatternCases do
+ yield upcast apCase
+
+ for fv in this.Entity.MembersFunctionsAndValues do
+ yield upcast fv
+ } |> Seq.cache
+
+ type ModuleGroup =
+ { Modules: Module list }
+
+ static member Create (modul: FSharpEntity) =
+ let rec getModuleAndItsAutoOpens (isNestedAutoOpen: bool) (modul: FSharpEntity) =
+ [ yield { Entity = modul; IsNestedAutoOpen = isNestedAutoOpen }
+ for ent in modul.NestedEntities do
+ if ent.IsFSharpModule && Symbol.hasAttribute ent.Attributes then
+ yield! getModuleAndItsAutoOpens true ent ]
+ { Modules = getModuleAndItsAutoOpens false modul }
+
+ /// Represents single open statement.
+ type OpenStatement =
+ { /// All modules which this open declaration effectively opens, _not_ including auto open ones.
+ Modules: ModuleGroup list
+ /// Range of open statement itself.
+ Range: range
+ /// Scope on which this open declaration is applied.
+ AppliedScope: range }
+
+ let getOpenStatements (openDeclarations: FSharpOpenDeclaration list) : OpenStatement list =
+ openDeclarations
+ |> List.filter (fun x -> not x.IsOwnNamespace)
+ |> List.choose (fun openDecl ->
+ match openDecl.LongId, openDecl.Range with
+ | firstId :: _, Some range ->
+ if firstId.idText = MangledGlobalName then
+ None
+ else
+ Some { Modules = openDecl.Modules |> List.map ModuleGroup.Create
+ Range = range
+ AppliedScope = openDecl.AppliedScope }
+ | _ -> None)
+
+ let filterSymbolUses (getSourceLineStr: int -> string) (symbolUses: FSharpSymbolUse[]) : FSharpSymbolUse[] =
+ symbolUses
+ |> Array.filter (fun su ->
+ match su.Symbol with
+ | :? FSharpMemberOrFunctionOrValue as fv when fv.IsExtensionMember ->
+ // extension members should be taken into account even though they have a prefix (as they do most of the time)
+ true
+ | _ ->
+ let partialName = QuickParse.GetPartialLongNameEx (getSourceLineStr su.RangeAlternate.StartLine, su.RangeAlternate.EndColumn - 1)
+ // for the rest of symbols we pick only those which are the first part of a long idend, because it's they which are
+ // conteined in opened namespaces / modules. For example, we pick `IO` from long ident `IO.File.OpenWrite` because
+ // it's `open System` which really brings it into scope.
+ partialName.QualifyingIdents = [])
+
+ type UsedModule =
+ { Module: FSharpEntity
+ AppliedScope: range }
+
+ let getUnusedOpens (checkFileResults: FSharpCheckFileResults, getSourceLineStr: int -> string) : Async =
+
+ let filterOpenStatements (openStatements: OpenStatement list) (symbolUses: FSharpSymbolUse[]) : OpenStatement list =
+
+ let rec filterInner acc (openStatements: OpenStatement list) (usedModules: UsedModule list) =
+
+ let getUsedModules (openStatement: OpenStatement) =
+ let notAlreadyUsedModuleGroups =
+ openStatement.Modules
+ |> List.choose (fun x ->
+ let notUsedModules =
+ x.Modules
+ |> List.filter (fun x ->
+ not (usedModules
+ |> List.exists (fun used ->
+ rangeContainsRange used.AppliedScope openStatement.AppliedScope &&
+ used.Module.IsEffectivelySameAs x.Entity)))
+
+ match notUsedModules with
+ | [] -> None
+ | _ when notUsedModules |> List.exists (fun x -> not x.IsNestedAutoOpen) ->
+ Some { Modules = notUsedModules }
+ | _ -> None)
+
+ match notAlreadyUsedModuleGroups with
+ | [] -> []
+ | _ ->
+ let symbolUsesInScope = symbolUses |> Array.filter (fun symbolUse -> rangeContainsRange openStatement.AppliedScope symbolUse.RangeAlternate)
+ notAlreadyUsedModuleGroups
+ |> List.filter (fun modulGroup ->
+ modulGroup.Modules
+ |> List.exists (fun modul ->
+ symbolUsesInScope
+ |> Array.exists (fun symbolUse ->
+ let usedByEnclosingEntity =
+ match symbolUse.Symbol with
+ | :? FSharpMemberOrFunctionOrValue as f ->
+ match f.EnclosingEntity with
+ | Some ent when ent.IsNamespace || ent.IsFSharpModule ->
+ Some (ent.IsEffectivelySameAs modul.Entity)
+ | _ -> None
+ | _ -> None
+ match usedByEnclosingEntity with
+ | Some x -> x
+ | None -> modul.ChildSymbols |> Seq.exists (fun x -> x.IsEffectivelySameAs symbolUse.Symbol)
+ )))
+ |> List.collect (fun mg ->
+ mg.Modules |> List.map (fun x -> { Module = x.Entity; AppliedScope = openStatement.AppliedScope }))
+
+ match openStatements with
+ | os :: xs ->
+ match getUsedModules os with
+ | [] -> filterInner (os :: acc) xs usedModules
+ | um -> filterInner acc xs (um @ usedModules)
+ | [] -> List.rev acc
+
+ filterInner [] openStatements []
+
+ async {
+ let! symbolUses = checkFileResults.GetAllUsesOfAllSymbolsInFile()
+ let symbolUses = filterSymbolUses getSourceLineStr symbolUses
+ let openStatements = getOpenStatements checkFileResults.OpenDeclarations
+ return filterOpenStatements openStatements symbolUses |> List.map (fun os -> os.Range)
+ }
\ No newline at end of file
diff --git a/src/fsharp/vs/ServiceAnalysis.fsi b/src/fsharp/vs/ServiceAnalysis.fsi
new file mode 100644
index 0000000000..6290c5d43e
--- /dev/null
+++ b/src/fsharp/vs/ServiceAnalysis.fsi
@@ -0,0 +1,15 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Compiler.SourceCodeServices
+
+open Microsoft.FSharp.Compiler.Ast
+open Microsoft.FSharp.Compiler.NameResolution
+open Microsoft.FSharp.Compiler.Range
+
+#if COMPILER_PUBLIC_API
+module UnusedOpens =
+#else
+module internal UnusedOpens =
+#endif
+ /// Get all unused open declarations in a file
+ val getUnusedOpens : checkFileResults: FSharpCheckFileResults * getSourceLineStr: (int -> string) -> Async
\ No newline at end of file
diff --git a/src/fsharp/vs/ServiceAssemblyContent.fs b/src/fsharp/vs/ServiceAssemblyContent.fs
index 414098d216..38a29545c5 100644
--- a/src/fsharp/vs/ServiceAssemblyContent.fs
+++ b/src/fsharp/vs/ServiceAssemblyContent.fs
@@ -97,37 +97,6 @@ module Extensions =
type FSharpAssemblySignature with
member x.TryGetEntities() = try x.Entities :> _ seq with _ -> Seq.empty
-[]
-module Utils =
- let isAttribute<'T> (attribute: FSharpAttribute) =
- // CompiledName throws exception on DataContractAttribute generated by SQLProvider
- match (try Some attribute.AttributeType.CompiledName with _ -> None) with
- | Some name when name = typeof<'T>.Name -> true
- | _ -> false
-
- let hasAttribute<'T> (attributes: seq) =
- attributes |> Seq.exists isAttribute<'T>
-
- let tryGetAttribute<'T> (attributes: seq) =
- attributes |> Seq.tryFind isAttribute<'T>
-
- let hasModuleSuffixAttribute (entity: FSharpEntity) =
- entity.Attributes
- |> tryGetAttribute
- |> Option.bind (fun a ->
- try Some a.ConstructorArguments with _ -> None
- |> Option.bind (fun args -> args |> Seq.tryPick (fun (_, arg) ->
- let res =
- match arg with
- | :? int32 as arg when arg = int CompilationRepresentationFlags.ModuleSuffix ->
- Some()
- | :? CompilationRepresentationFlags as arg when arg = CompilationRepresentationFlags.ModuleSuffix ->
- Some()
- | _ ->
- None
- res)))
- |> Option.isSome
-
[]
type LookupType =
| Fuzzy
@@ -186,7 +155,7 @@ type Parent =
else ident)
let removeModuleSuffix (idents: Idents) =
- if entity.IsFSharpModule && idents.Length > 0 && hasModuleSuffixAttribute entity then
+ if entity.IsFSharpModule && idents.Length > 0 && Symbol.hasModuleSuffixAttribute entity then
let lastIdent = idents.[idents.Length - 1]
if lastIdent.EndsWith "Module" then
idents |> Array.replace (idents.Length - 1) (lastIdent.Substring(0, lastIdent.Length - 6))
@@ -202,18 +171,6 @@ type Parent =
|> removeGenericParamsCount
|> removeModuleSuffix))
-module TypedAstPatterns =
- let (|TypeWithDefinition|_|) (ty: FSharpType) =
- if ty.HasTypeDefinition then Some ty.TypeDefinition
- else None
-
- let (|Attribute|_|) (entity: FSharpEntity) =
- let isAttribute (entity: FSharpEntity) =
- try entity.IsAttributeType with _ -> false
- if isAttribute entity then Some() else None
-
- let (|FSharpModule|_|) (entity: FSharpEntity) = if entity.IsFSharpModule then Some() else None
-
type AssemblyContentCacheEntry =
{ FileWriteTime: DateTime
ContentType: AssemblyContentType
@@ -239,15 +196,15 @@ module AssemblyContentProvider =
Symbol = entity
Kind = fun lookupType ->
match entity, lookupType with
- | TypedAstPatterns.FSharpModule, _ ->
+ | Symbol.FSharpModule, _ ->
EntityKind.Module
- { IsAutoOpen = hasAttribute entity.Attributes
- HasModuleSuffix = hasModuleSuffixAttribute entity }
+ { IsAutoOpen = Symbol.hasAttribute entity.Attributes
+ HasModuleSuffix = Symbol.hasModuleSuffixAttribute entity }
| _, LookupType.Fuzzy ->
EntityKind.Type
| _, LookupType.Precise ->
match entity with
- | TypedAstPatterns.Attribute -> EntityKind.Attribute
+ | Symbol.Attribute -> EntityKind.Attribute
| _ -> EntityKind.Type
})
@@ -297,7 +254,7 @@ module AssemblyContentProvider =
| None -> ()
let thisRequiresQualifierAccess =
- if entity.IsFSharp && hasAttribute entity.Attributes then
+ if entity.IsFSharp && Symbol.hasAttribute entity.Attributes then
parent.FormatEntityFullName entity |> Option.map snd
else None
@@ -305,7 +262,7 @@ module AssemblyContentProvider =
{ ThisRequiresQualifiedAccess = thisRequiresQualifierAccess |> Option.orElse parent.ThisRequiresQualifiedAccess
TopRequiresQualifiedAccess = parent.TopRequiresQualifiedAccess |> Option.orElse thisRequiresQualifierAccess
AutoOpen =
- let isAutoOpen = entity.IsFSharpModule && hasAttribute entity.Attributes
+ let isAutoOpen = entity.IsFSharpModule && Symbol.hasAttribute entity.Attributes
match isAutoOpen, parent.AutoOpen with
// if parent is also AutoOpen, then keep the parent
| true, Some parent -> Some parent
@@ -315,7 +272,7 @@ module AssemblyContentProvider =
| false, _ -> None
WithModuleSuffix =
- if entity.IsFSharpModule && hasModuleSuffixAttribute entity then
+ if entity.IsFSharpModule && Symbol.hasModuleSuffixAttribute entity then
currentEntity |> Option.map (fun e -> e.CleanedIdents)
else parent.WithModuleSuffix
Namespace = ns }
diff --git a/src/fsharp/vs/ServiceAssemblyContent.fsi b/src/fsharp/vs/ServiceAssemblyContent.fsi
index c92c741cfb..03e8ccfa81 100644
--- a/src/fsharp/vs/ServiceAssemblyContent.fsi
+++ b/src/fsharp/vs/ServiceAssemblyContent.fsi
@@ -255,10 +255,4 @@ module internal Extensions =
type FSharpAssemblySignature with
/// Safe version of `Entities`.
- member TryGetEntities : unit -> seq
-
-/// Operations over `FSharpAttribute`.
-[]
-module internal Utils =
- /// Returns `true` if a collection of attributes contains one of given type.
- val hasAttribute<'T> : attributes: seq -> bool
+ member TryGetEntities : unit -> seq
\ No newline at end of file
diff --git a/src/fsharp/vs/ServiceInterfaceStubGenerator.fs b/src/fsharp/vs/ServiceInterfaceStubGenerator.fs
index e6ccfffbab..4f62581f1b 100644
--- a/src/fsharp/vs/ServiceInterfaceStubGenerator.fs
+++ b/src/fsharp/vs/ServiceInterfaceStubGenerator.fs
@@ -220,7 +220,7 @@ module internal InterfaceStubGenerator =
let nm, namesWithIndices = normalizeArgName namesWithIndices nm
// Detect an optional argument
- let isOptionalArg = hasAttribute arg.Attributes
+ let isOptionalArg = Symbol.hasAttribute arg.Attributes
let argName = if isOptionalArg then "?" + nm else nm
(if hasTypeAnnotation && argName <> "()" then
argName + ": " + formatType ctx arg.Type
@@ -295,7 +295,7 @@ module internal InterfaceStubGenerator =
else displayName
let internal isEventMember (m: FSharpMemberOrFunctionOrValue) =
- m.IsEvent || hasAttribute m.Attributes
+ m.IsEvent || Symbol.hasAttribute m.Attributes
let internal formatMember (ctx: Context) m verboseMode =
let getParamArgs (argInfos: FSharpParameter list list) (ctx: Context) (v: FSharpMemberOrFunctionOrValue) =
@@ -325,7 +325,7 @@ module internal InterfaceStubGenerator =
| _, true, _, name -> name + parArgs
// Ordinary functions or values
| false, _, _, name when
- not (hasAttribute v.LogicalEnclosingEntity.Attributes) ->
+ not (Symbol.hasAttribute v.LogicalEnclosingEntity.Attributes) ->
name + " " + parArgs
// Ordinary static members or things (?) that require fully qualified access
| _, _, _, name -> name + parArgs
diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs
index 5c2fc8f544..f96d560b76 100755
--- a/src/fsharp/vs/service.fs
+++ b/src/fsharp/vs/service.fs
@@ -140,7 +140,7 @@ type SemanticClassificationType =
| TypeArgument
| Operator
| Disposable
-
+
/// A TypeCheckInfo represents everything we get back from the typecheck of a file.
/// It acts like an in-memory database about the file.
/// It is effectively immutable and not updated: when we re-typecheck we just drop the previous
@@ -165,7 +165,8 @@ type TypeCheckInfo
reactorOps : IReactorOperations,
checkAlive : (unit -> bool),
textSnapshotInfo:obj option,
- implementationFiles: TypedImplFile list) =
+ implementationFiles: TypedImplFile list,
+ openDeclarations: OpenDeclaration list) =
let textSnapshotInfo = defaultArg textSnapshotInfo null
let (|CNR|) (cnr:CapturedNameResolution) =
@@ -216,7 +217,7 @@ type TypeCheckInfo
| None -> true
if contained then
- match !bestAlmostIncludedSoFar with
+ match !bestAlmostIncludedSoFar with
| Some (rightm:range,_,_) ->
if posGt possm.End rightm.End ||
(posEq possm.End rightm.End && posGt possm.Start rightm.Start) then
@@ -567,14 +568,17 @@ type TypeCheckInfo
| Item.Value _ -> CompletionItemKind.Field
| _ -> CompletionItemKind.Other
+ let getNamespace (idents: Idents) =
+ if idents.Length > 1 then Some idents.[..idents.Length - 2] else None
+
let unresolved =
unresolvedEntity
|> Option.map (fun x ->
- let ns =
- match x.TopRequireQualifiedAccessParent with
- | Some parent when not (Array.isEmpty parent) ->
- parent.[..parent.Length - 2]
- | _ -> x.CleanedIdents.[..x.CleanedIdents.Length - 2]
+ let ns =
+ x.TopRequireQualifiedAccessParent
+ |> Option.bind getNamespace
+ |> Option.orElseWith (fun () -> getNamespace x.CleanedIdents)
+ |> Option.defaultValue [||]
let displayName = x.CleanedIdents |> Array.skip ns.Length |> String.concat "."
@@ -591,7 +595,7 @@ type TypeCheckInfo
let DefaultCompletionItem item = CompletionItem None None item
let getItem (x: ItemWithInst) = x.Item
- let GetDeclaredItems (parseResultsOpt: FSharpParseFileResults option, lineStr: string, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, line, loc,
+ let GetDeclaredItems (parseResultsOpt: FSharpParseFileResults option, lineStr: string, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc,
filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, isInRangeOperator, allSymbols: unit -> AssemblySymbol list) =
// Are the last two chars (except whitespaces) = ".."
@@ -612,18 +616,12 @@ type TypeCheckInfo
// deals with cases when we have spaces between dot and\or identifier, like A . $
// if this is our case - then we need to locate end position of the name skipping whitespaces
// this allows us to handle cases like: let x . $ = 1
-
- // colAtEndOfNamesAndResidue is 1-based so at first we need to convert it to 0-based
- //
- // TODO: this code would be a lot simpler if we just passed in colAtEndOfNames in
- // the first place. colAtEndOfNamesAndResidue serves no purpose. The cracking below is
- // inaccurate and incomplete in any case since it only works on a single line.
- match FindFirstNonWhitespacePosition lineStr (colAtEndOfNamesAndResidue - 1) with
+ match lastDotPos |> Option.orElseWith (fun _ -> FindFirstNonWhitespacePosition lineStr (colAtEndOfNamesAndResidue - 1)) with
| Some p when lineStr.[p] = '.' ->
match FindFirstNonWhitespacePosition lineStr (p - 1) with
| Some colAtEndOfNames ->
- let colAtEndOfNames = colAtEndOfNames + 1 // convert 0-based to 1-based
- GetPreciseItemsFromNameResolution(line, colAtEndOfNames, Some(residue), filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck)
+ let colAtEndOfNames = colAtEndOfNames + 1 // convert 0-based to 1-based
+ GetPreciseItemsFromNameResolution(line, colAtEndOfNames, Some(residue), filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck)
| None -> NameResResult.Empty
| _ -> NameResResult.Empty
@@ -647,7 +645,7 @@ type TypeCheckInfo
match NameResolution.TryToResolveLongIdentAsType ncenv nenv m plid with
| Some x -> Some x
| None ->
- match FindFirstNonWhitespacePosition lineStr (colAtEndOfNamesAndResidue - 1) with
+ match lastDotPos |> Option.orElseWith (fun _ -> FindFirstNonWhitespacePosition lineStr (colAtEndOfNamesAndResidue - 1)) with
| Some p when lineStr.[p] = '.' ->
match FindFirstNonWhitespacePosition lineStr (p - 1) with
| Some colAtEndOfNames ->
@@ -769,7 +767,7 @@ type TypeCheckInfo
/// Get the auto-complete items at a particular location.
let GetDeclItemsForNamesAtPosition(ctok: CompilationThreadToken, parseResultsOpt: FSharpParseFileResults option, origLongIdentOpt: string list option,
- residueOpt:string option, line:int, lineStr:string, colAtEndOfNamesAndResidue, filterCtors, resolveOverloads,
+ residueOpt:string option, lastDotPos: int option, line:int, lineStr:string, colAtEndOfNamesAndResidue, filterCtors, resolveOverloads,
getAllSymbols: unit -> AssemblySymbol list, hasTextChangedSinceLastTypecheck: (obj * range -> bool))
: (CompletionItem list * DisplayEnv * CompletionContext option * range) option =
RequireCompilationThread ctok // the operations in this method need the reactor thread
@@ -812,7 +810,7 @@ type TypeCheckInfo
match GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid) |> toCompletionItems with
| [],_,_ ->
// no record fields found, return completion list as if we were outside any computation expression
- GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, line, loc, filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck, false, fun() -> [])
+ GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck, false, fun() -> [])
| result -> Some(result)
// Completion at ' { XXX = ... with ... } "
@@ -835,7 +833,7 @@ type TypeCheckInfo
let results = GetNamedParametersAndSettableFields endPos hasTextChangedSinceLastTypecheck
let declaredItems =
- GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, line, loc, filterCtors, resolveOverloads,
+ GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads,
hasTextChangedSinceLastTypecheck, false, getAllSymbols)
match results with
@@ -858,7 +856,7 @@ type TypeCheckInfo
| _ -> declaredItems
| Some(CompletionContext.AttributeApplication) ->
- GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, line, loc, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, false, getAllSymbols)
+ GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, false, getAllSymbols)
|> Option.map (fun (items, denv, m) ->
items
|> List.filter (fun cItem ->
@@ -868,14 +866,14 @@ type TypeCheckInfo
| _ -> false), denv, m)
| Some(CompletionContext.OpenDeclaration) ->
- GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, line, loc, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, false, getAllSymbols)
+ GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, false, getAllSymbols)
|> Option.map (fun (items, denv, m) ->
items |> List.filter (fun x -> match x.Item with Item.ModuleOrNamespaces _ -> true | _ -> false), denv, m)
// Other completions
| cc ->
let isInRangeOperator = (match cc with Some (CompletionContext.RangeOperator) -> true | _ -> false)
- GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, line, loc, filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck, isInRangeOperator, getAllSymbols)
+ GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck, isInRangeOperator, getAllSymbols)
res |> Option.map (fun (items, denv, m) -> items, denv, completionContext, m)
@@ -900,13 +898,17 @@ type TypeCheckInfo
(fun msg ->
Trace.TraceInformation(sprintf "FCS: recovering from error in IsRelativeNameResolvable: '%s'" msg)
false)
+
+ /// Determines if a long ident is resolvable at a specific point.
+ member scope.IsRelativeNameResolvableFromSymbol(cursorPos: pos, plid: string list, symbol: FSharpSymbol) : bool =
+ scope.IsRelativeNameResolvable(cursorPos, plid, symbol.Item)
/// Get the auto-complete items at a location
- member __.GetDeclarations (ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, getAllSymbols, hasTextChangedSinceLastTypecheck) =
+ member __.GetDeclarations (ctok, parseResultsOpt, line, lineStr, partialName, getAllSymbols, hasTextChangedSinceLastTypecheck) =
let isInterfaceFile = SourceFileImpl.IsInterfaceFile mainInputFileName
ErrorScope.Protect Range.range0
- (fun () ->
- match GetDeclItemsForNamesAtPosition(ctok, parseResultsOpt, Some qualifyingNames, Some partialName, line, lineStr, colAtEndOfNamesAndResidue, ResolveTypeNamesToCtors, ResolveOverloads.Yes, getAllSymbols, hasTextChangedSinceLastTypecheck) with
+ (fun () ->
+ match GetDeclItemsForNamesAtPosition(ctok, parseResultsOpt, Some partialName.QualifyingIdents, Some partialName.PartialIdent, partialName.LastDotPos, line, lineStr, partialName.EndColumn + 1, ResolveTypeNamesToCtors, ResolveOverloads.Yes, getAllSymbols, hasTextChangedSinceLastTypecheck) with
| None -> FSharpDeclarationListInfo.Empty
| Some (items, denv, ctx, m) ->
let items = if isInterfaceFile then items |> List.filter (fun x -> IsValidSignatureFileItem x.Item) else items
@@ -922,11 +924,11 @@ type TypeCheckInfo
FSharpDeclarationListInfo.Error msg)
/// Get the symbols for auto-complete items at a location
- member __.GetDeclarationListSymbols (ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, hasTextChangedSinceLastTypecheck) =
+ member __.GetDeclarationListSymbols (ctok, parseResultsOpt, line, lineStr, partialName, hasTextChangedSinceLastTypecheck) =
let isInterfaceFile = SourceFileImpl.IsInterfaceFile mainInputFileName
ErrorScope.Protect Range.range0
(fun () ->
- match GetDeclItemsForNamesAtPosition(ctok, parseResultsOpt, Some qualifyingNames, Some partialName, line, lineStr, colAtEndOfNamesAndResidue, ResolveTypeNamesToCtors, ResolveOverloads.Yes, (fun () -> []), hasTextChangedSinceLastTypecheck) with
+ match GetDeclItemsForNamesAtPosition(ctok, parseResultsOpt, Some partialName.QualifyingIdents, Some partialName.PartialIdent, partialName.LastDotPos, line, lineStr, partialName.EndColumn + 1, ResolveTypeNamesToCtors, ResolveOverloads.Yes, (fun () -> []), hasTextChangedSinceLastTypecheck) with
| None -> List.Empty
| Some (items, denv, _, m) ->
let items = if isInterfaceFile then items |> List.filter (fun x -> IsValidSignatureFileItem x.Item) else items
@@ -1028,7 +1030,7 @@ type TypeCheckInfo
let Compute() =
ErrorScope.Protect Range.range0
(fun () ->
- match GetDeclItemsForNamesAtPosition(ctok, None,Some(names),None,line,lineStr,colAtEndOfNames,ResolveTypeNamesToCtors,ResolveOverloads.Yes,(fun() -> []),fun _ -> false) with
+ match GetDeclItemsForNamesAtPosition(ctok, None,Some(names),None,None,line,lineStr,colAtEndOfNames,ResolveTypeNamesToCtors,ResolveOverloads.Yes,(fun() -> []),fun _ -> false) with
| None -> FSharpToolTipText []
| Some(items, denv, _, m) ->
FSharpToolTipText(items |> List.map (fun x -> FormatStructuredDescriptionOfItem false infoReader m denv x.ItemWithInst)))
@@ -1048,7 +1050,7 @@ type TypeCheckInfo
member __.GetF1Keyword (ctok, line, lineStr, colAtEndOfNames, names) : string option =
ErrorScope.Protect Range.range0
(fun () ->
- match GetDeclItemsForNamesAtPosition(ctok, None, Some names, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,(fun() -> []), fun _ -> false) with // F1 Keywords do not distinguish between overloads
+ match GetDeclItemsForNamesAtPosition(ctok, None, Some names, None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,(fun() -> []), fun _ -> false) with // F1 Keywords do not distinguish between overloads
| None -> None
| Some (items: CompletionItem list, _,_, _) ->
match items with
@@ -1080,7 +1082,7 @@ type TypeCheckInfo
member __.GetMethods (ctok, line, lineStr, colAtEndOfNames, namesOpt) =
ErrorScope.Protect Range.range0
(fun () ->
- match GetDeclItemsForNamesAtPosition(ctok, None,namesOpt,None,line,lineStr,colAtEndOfNames,ResolveTypeNamesToCtors,ResolveOverloads.No,(fun() -> []),fun _ -> false) with
+ match GetDeclItemsForNamesAtPosition(ctok, None,namesOpt,None,None,line,lineStr,colAtEndOfNames,ResolveTypeNamesToCtors,ResolveOverloads.No,(fun() -> []),fun _ -> false) with
| None -> FSharpMethodGroup("",[| |])
| Some (items, denv, _, m) -> FSharpMethodGroup.Create(infoReader, m, denv, items |> List.map (fun x -> x.ItemWithInst)))
(fun msg ->
@@ -1090,7 +1092,7 @@ type TypeCheckInfo
member __.GetMethodsAsSymbols (ctok, line, lineStr, colAtEndOfNames, names) =
ErrorScope.Protect Range.range0
(fun () ->
- match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,(fun() -> []),fun _ -> false) with
+ match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, None,line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,(fun() -> []),fun _ -> false) with
| None | Some ([],_,_,_) -> None
| Some (items, denv, _, m) ->
let allItems = items |> List.collect (fun item -> SymbolHelpers.FlattenItems g m item.Item)
@@ -1104,7 +1106,7 @@ type TypeCheckInfo
member scope.GetDeclarationLocation (ctok, line, lineStr, colAtEndOfNames, names, preferFlag) =
ErrorScope.Protect Range.range0
(fun () ->
- match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors,ResolveOverloads.Yes,(fun() -> []), fun _ -> false) with
+ match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors,ResolveOverloads.Yes,(fun() -> []), fun _ -> false) with
| None
| Some ([], _, _, _) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown "")
| Some (item :: _, _, _, _) ->
@@ -1209,7 +1211,7 @@ type TypeCheckInfo
member scope.GetSymbolUseAtLocation (ctok, line, lineStr, colAtEndOfNames, names) =
ErrorScope.Protect Range.range0
(fun () ->
- match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes,(fun() -> []), fun _ -> false) with
+ match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes,(fun() -> []), fun _ -> false) with
| None | Some ([], _, _, _) -> None
| Some (item :: _, denv, _, m) ->
let symbol = FSharpSymbol.Create(g, thisCcu, tcImports, item.Item)
@@ -1360,6 +1362,9 @@ type TypeCheckInfo
member __.ImplementationFiles = implementationFiles
+ /// All open declarations in the file, including auto open modules
+ member __.OpenDeclarations = openDeclarations
+
override __.ToString() = "TypeCheckInfo(" + mainInputFileName + ")"
type FSharpParsingOptions =
@@ -1396,7 +1401,7 @@ type FSharpParsingOptions =
}
static member FromTcConfigBuidler(tcConfigB: TcConfigBuilder, sourceFiles) =
- {
+ {
SourceFiles = sourceFiles
ConditionalCompilationDefines = tcConfigB.conditionalCompilationDefines
ErrorSeverityOptions = tcConfigB.errorSeverityOptions
@@ -1692,13 +1697,14 @@ module internal Parser =
projectFileName,
mainInputFileName,
sink.GetResolutions(),
- sink.GetSymbolUses(),
+ sink.GetSymbolUses(),
tcEnvAtEnd.NameEnv,
loadClosure,
reactorOps,
checkAlive,
textSnapshotInfo,
- typedImplFiles)
+ typedImplFiles,
+ sink.OpenDeclarations)
return errors, TypeCheckAborted.No scope
| None ->
return errors, TypeCheckAborted.Yes
@@ -1724,7 +1730,7 @@ type FSharpProjectOptions =
member x.ProjectOptions = x.OtherOptions
/// Whether the two parse options refer to the same project.
static member UseSameProjectFileName(options1,options2) =
- options1.ProjectFileName = options2.ProjectFileName
+ options1.ProjectFileName = options2.ProjectFileName
/// Compare two options sets with respect to the parts of the options that are important to building.
static member AreSameForChecking(options1,options2) =
@@ -1737,7 +1743,9 @@ type FSharpProjectOptions =
options1.UnresolvedReferences = options2.UnresolvedReferences &&
options1.OriginalLoadReferences = options2.OriginalLoadReferences &&
options1.ReferencedProjects.Length = options2.ReferencedProjects.Length &&
- Array.forall2 (fun (n1,a) (n2,b) -> n1 = n2 && FSharpProjectOptions.AreSameForChecking(a,b)) options1.ReferencedProjects options2.ReferencedProjects &&
+ Array.forall2 (fun (n1,a) (n2,b) ->
+ n1 = n2 &&
+ FSharpProjectOptions.AreSameForChecking(a,b)) options1.ReferencedProjects options2.ReferencedProjects &&
options1.LoadTime = options2.LoadTime
/// Compute the project directory.
@@ -1885,16 +1893,16 @@ type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOp
member info.HasFullTypeCheckInfo = details.IsSome
/// Intellisense autocompletions
- member info.GetDeclarationListInfo(parseResultsOpt, line, colAtEndOfNamesAndResidue, lineStr, qualifyingNames, partialName, getAllEntities, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) =
+ member info.GetDeclarationListInfo(parseResultsOpt, line, lineStr, partialName, getAllEntities, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) =
let userOpName = defaultArg userOpName "Unknown"
let hasTextChangedSinceLastTypecheck = defaultArg hasTextChangedSinceLastTypecheck (fun _ -> false)
reactorOp userOpName "GetDeclarations" FSharpDeclarationListInfo.Empty (fun ctok scope ->
- scope.GetDeclarations(ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, getAllEntities, hasTextChangedSinceLastTypecheck))
+ scope.GetDeclarations(ctok, parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck))
- member info.GetDeclarationListSymbols(parseResultsOpt, line, colAtEndOfNamesAndResidue, lineStr, qualifyingNames, partialName, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) =
+ member info.GetDeclarationListSymbols(parseResultsOpt, line, lineStr, partialName, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) =
let userOpName = defaultArg userOpName "Unknown"
let hasTextChangedSinceLastTypecheck = defaultArg hasTextChangedSinceLastTypecheck (fun _ -> false)
- reactorOp userOpName "GetDeclarationListSymbols" List.empty (fun ctok scope -> scope.GetDeclarationListSymbols(ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, hasTextChangedSinceLastTypecheck))
+ reactorOp userOpName "GetDeclarationListSymbols" List.empty (fun ctok scope -> scope.GetDeclarationListSymbols(ctok, parseResultsOpt, line, lineStr, partialName, hasTextChangedSinceLastTypecheck))
/// Resolve the names at the given location to give a data tip
member info.GetStructuredToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag, ?userOpName: string) =
@@ -1987,9 +1995,9 @@ type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOp
(fun () -> [| |])
(fun scope ->
[| for (item,itemOcc,denv,m) in scope.ScopeSymbolUses.GetAllUsesOfSymbols() do
- if itemOcc <> ItemOccurence.RelatedText then
- let symbol = FSharpSymbol.Create(scope.TcGlobals, scope.ThisCcu, scope.TcImports, item)
- yield FSharpSymbolUse(scope.TcGlobals, denv, symbol, itemOcc, m) |])
+ if itemOcc <> ItemOccurence.RelatedText then
+ let symbol = FSharpSymbol.Create(scope.TcGlobals, scope.ThisCcu, scope.TcImports, item)
+ yield FSharpSymbolUse(scope.TcGlobals, denv, symbol, itemOcc, m) |])
|> async.Return
member info.GetUsesOfSymbolInFile(symbol:FSharpSymbol) =
@@ -2012,6 +2020,12 @@ type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOp
reactorOp userOpName "IsRelativeNameResolvable" true (fun ctok scope ->
RequireCompilationThread ctok
scope.IsRelativeNameResolvable(pos, plid, item))
+
+ member info.IsRelativeNameResolvableFromSymbol(pos: pos, plid: string list, symbol: FSharpSymbol, ?userOpName: string) =
+ let userOpName = defaultArg userOpName "Unknown"
+ reactorOp userOpName "IsRelativeNameResolvableFromSymbol" true (fun ctok scope ->
+ RequireCompilationThread ctok
+ scope.IsRelativeNameResolvableFromSymbol(pos, plid, symbol))
member info.ImplementationFiles =
if not keepAssemblyContents then invalidOp "The 'keepAssemblyContents' flag must be set to true on the FSharpChecker in order to access the checked contents of assemblies"
@@ -2020,6 +2034,19 @@ type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOp
let cenv = Impl.cenv(scope.TcGlobals, scope.ThisCcu, scope.TcImports)
[ for mimpl in scope.ImplementationFiles -> FSharpImplementationFileContents(cenv, mimpl)])
+ member info.OpenDeclarations =
+ scopeOptX
+ |> Option.map (fun scope ->
+ let cenv = Impl.cenv(scope.TcGlobals, scope.ThisCcu, scope.TcImports)
+ scope.OpenDeclarations |> List.map (fun x ->
+ { LongId = x.LongId
+ Range = x.Range
+ Modules = x.Modules |> List.map (fun x -> FSharpEntity(cenv, x))
+ AppliedScope = x.AppliedScope
+ IsOwnNamespace = x.IsOwnNamespace }
+ : FSharpOpenDeclaration ))
+ |> Option.defaultValue []
+
override info.ToString() = "FSharpCheckFileResults(" + filename + ")"
//----------------------------------------------------------------------------
@@ -2043,11 +2070,11 @@ module Helpers =
// Look for DLLs in the location of the service DLL first.
let defaultFSharpBinariesDir = FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(Some(typeof.Assembly.Location)).Value
-
+
/// Determine whether two (fileName,options) keys are identical w.r.t. affect on checking
- let AreSameForChecking2((fileName1: string, options1: FSharpProjectOptions), (fileName2, o2)) =
+ let AreSameForChecking2((fileName1: string, options1: FSharpProjectOptions), (fileName2, options2)) =
(fileName1 = fileName2)
- && FSharpProjectOptions.AreSameForChecking(options1,o2)
+ && FSharpProjectOptions.AreSameForChecking(options1,options2)
/// Determine whether two (fileName,options) keys should be identical w.r.t. resource usage
let AreSubsumable2((fileName1:string,o1:FSharpProjectOptions),(fileName2:string,o2:FSharpProjectOptions)) =
@@ -2380,8 +2407,8 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
| Some res -> return res
| None ->
foregroundParseCount <- foregroundParseCount + 1
- let parseErrors, inputOpt, anyErrors = Parser.parseFile(source, filename, options, userOpName)
- let res = FSharpParseFileResults(parseErrors, inputOpt, anyErrors, options.SourceFiles)
+ let parseErrors, parseTreeOpt, anyErrors = Parser.parseFile(source, filename, options, userOpName)
+ let res = FSharpParseFileResults(parseErrors, parseTreeOpt, anyErrors, options.SourceFiles)
parseCacheLock.AcquireLock(fun ltok -> parseFileCache.Set(ltok, (filename, source, options), res))
return res
}
@@ -2395,9 +2422,9 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
match builderOpt with
| None -> return FSharpParseFileResults(List.toArray creationErrors, None, true, [| |])
| Some builder ->
- let! inputOpt,_,_,parseErrors = builder.GetParseResultsForFile (ctok, filename)
+ let! parseTreeOpt,_,_,parseErrors = builder.GetParseResultsForFile (ctok, filename)
let errors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (builder.TcConfig.errorSeverityOptions, false, filename, parseErrors) |]
- return FSharpParseFileResults(errors = errors, input = inputOpt, parseHadErrors = false, dependencyFiles = builder.AllDependenciesDeprecated)
+ return FSharpParseFileResults(errors = errors, input = parseTreeOpt, parseHadErrors = false, dependencyFiles = builder.AllDependenciesDeprecated)
}
)
@@ -2541,7 +2568,9 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
| _ ->
Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName, "CheckFileInProject.CacheMiss", filename)
let! tcPrior = execWithReactorAsync <| fun ctok -> builder.GetCheckResultsBeforeFileInProject (ctok, filename)
- let! checkAnswer = bc.CheckOneFileImpl(parseResults, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors, userOpName)
+ let parseTreeOpt = parseResults.ParseTree |> Option.map builder.DeduplicateParsedInputModuleNameInProject
+ let parseResultsAterDeDuplication = FSharpParseFileResults(parseResults.Errors, parseTreeOpt, parseResults.ParseHadErrors, parseResults.DependencyFiles)
+ let! checkAnswer = bc.CheckOneFileImpl(parseResultsAterDeDuplication, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors, userOpName)
return checkAnswer
finally
bc.ImplicitlyStartCheckProjectInBackground(options, userOpName)
@@ -2574,9 +2603,9 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
// Do the parsing.
let parsingOptions = FSharpParsingOptions.FromTcConfig(builder.TcConfig, Array.ofList (builder.SourceFiles))
- let parseErrors, inputOpt, anyErrors = Parser.parseFile (source, filename, parsingOptions, userOpName)
-
- let parseResults = FSharpParseFileResults(parseErrors, inputOpt, anyErrors, builder.AllDependenciesDeprecated)
+ let parseErrors, parseTreeOpt, anyErrors = Parser.parseFile (source, filename, parsingOptions, userOpName)
+ let parseTreeOpt = parseTreeOpt |> Option.map builder.DeduplicateParsedInputModuleNameInProject
+ let parseResults = FSharpParseFileResults(parseErrors, parseTreeOpt, anyErrors, builder.AllDependenciesDeprecated)
let! checkResults = bc.CheckOneFileImpl(parseResults, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors, userOpName)
return parseResults, checkResults
finally
@@ -2595,12 +2624,12 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
let typedResults = MakeCheckFileResultsEmpty(filename, creationErrors)
return (parseResults, typedResults)
| Some builder ->
- let! (inputOpt, _, _, untypedErrors) = builder.GetParseResultsForFile (ctok, filename)
+ let! (parseTreeOpt, _, _, untypedErrors) = builder.GetParseResultsForFile (ctok, filename)
let! tcProj = builder.GetCheckResultsAfterFileInProject (ctok, filename)
let errorOptions = builder.TcConfig.errorSeverityOptions
let untypedErrors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (errorOptions, false, filename, untypedErrors) |]
let tcErrors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (errorOptions, false, filename, tcProj.Errors) |]
- let parseResults = FSharpParseFileResults(errors = untypedErrors, input = inputOpt, parseHadErrors = false, dependencyFiles = builder.AllDependenciesDeprecated)
+ let parseResults = FSharpParseFileResults(errors = untypedErrors, input = parseTreeOpt, parseHadErrors = false, dependencyFiles = builder.AllDependenciesDeprecated)
let loadClosure = scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.TryGet (ltok, options) )
let scope =
TypeCheckInfo(tcProj.TcConfig, tcProj.TcGlobals, tcProj.TcState.PartialAssemblySignature, tcProj.TcState.Ccu, tcProj.TcImports, tcProj.TcEnvAtEnd.AccessRights,
@@ -2609,7 +2638,8 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
List.last tcProj.TcSymbolUses,
tcProj.TcEnvAtEnd.NameEnv,
loadClosure, reactorOps, (fun () -> builder.IsAlive), None,
- tcProj.ImplementationFiles)
+ tcProj.ImplementationFiles,
+ tcProj.TcOpenDeclarations)
let typedResults = MakeCheckFileResults(filename, options, builder, scope, Array.ofList tcProj.TcDependencyFiles, creationErrors, parseResults.Errors, tcErrors)
return (parseResults, typedResults)
})
@@ -2711,7 +2741,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
member bc.InvalidateConfiguration(options : FSharpProjectOptions, startBackgroundCompileIfAlreadySeen, userOpName) =
let startBackgroundCompileIfAlreadySeen = defaultArg startBackgroundCompileIfAlreadySeen implicitlyStartBackgroundWork
// This operation can't currently be cancelled nor awaited
- reactor.EnqueueOp(userOpName, "InvalidateConfiguration", options.ProjectFileName, fun ctok ->
+ reactor.EnqueueOp(userOpName, "InvalidateConfiguration: Stamp(" + (options.Stamp |> Option.defaultValue 0L).ToString() + ")", options.ProjectFileName, fun ctok ->
// If there was a similar entry then re-establish an empty builder . This is a somewhat arbitrary choice - it
// will have the effect of releasing memory associated with the previous builder, but costs some time.
if incrementalBuildersCache.ContainsSimilarKey (ctok, options) then
@@ -3136,9 +3166,9 @@ type FsiInteractiveChecker(legacyReferenceResolver, reactorOps: IReactorOperatio
let filename = Path.Combine(tcConfig.implicitIncludeDir, "stdin.fsx")
// Note: projectSourceFiles is only used to compute isLastCompiland, and is ignored if Build.IsScript(mainInputFileName) is true (which it is in this case).
let parsingOptions = FSharpParsingOptions.FromTcConfig(tcConfig, [| filename |])
- let parseErrors, inputOpt, anyErrors = Parser.parseFile (source, filename, parsingOptions, userOpName)
+ let parseErrors, parseTreeOpt, anyErrors = Parser.parseFile (source, filename, parsingOptions, userOpName)
let dependencyFiles = [| |] // interactions have no dependencies
- let parseResults = FSharpParseFileResults(parseErrors, inputOpt, parseHadErrors = anyErrors, dependencyFiles = dependencyFiles)
+ let parseResults = FSharpParseFileResults(parseErrors, parseTreeOpt, parseHadErrors = anyErrors, dependencyFiles = dependencyFiles)
let backgroundDiagnostics = []
diff --git a/src/fsharp/vs/service.fsi b/src/fsharp/vs/service.fsi
index 986b9a0e4c..1e7005bff0 100755
--- a/src/fsharp/vs/service.fsi
+++ b/src/fsharp/vs/service.fsi
@@ -132,21 +132,23 @@ type internal FSharpCheckFileResults =
/// 'record field' locations and r.h.s. of 'range' operator a..b
///
/// The line number where the completion is happening
- /// The column number at the end of the 'names' text
- /// The long identifier to the left of the '.'
- /// The residue of a partial long identifier to the right of the '.'
- /// The residue of a partial long identifier to the right of the '.'
+ ///
+ /// Partial long name. QuickParse.GetPartialLongNameEx can be used to get it.
+ ///
///
/// The text of the line where the completion is happening. This is only used to make a couple
/// of adhoc corrections to completion accuracy (e.g. checking for "..")
///
+ ///
+ /// Function that returns all symbols from current and referenced assemblies.
+ ///
///
/// If text has been used from a captured name resolution from the typecheck, then
/// callback to the client to check if the text has changed. If it has, then give up
/// and assume that we're going to repeat the operation later on.
///
/// An optional string used for tracing compiler operations associated with this request.
- member GetDeclarationListInfo : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * colAtEndOfPartialName: int * lineText:string * qualifyingNames: string list * partialName: string * getAllSymbols: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async
+ member GetDeclarationListInfo : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * getAllSymbols: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async
/// Get the items for a declaration list in FSharpSymbol format
///
@@ -156,21 +158,23 @@ type internal FSharpCheckFileResults =
/// 'record field' locations and r.h.s. of 'range' operator a..b
///
/// The line number where the completion is happening
- /// The column number at the end of the 'names' text
- /// The long identifier to the left of the '.'
- /// The residue of a partial long identifier to the right of the '.'
- /// The residue of a partial long identifier to the right of the '.'
+ ///
+ /// Partial long name. QuickParse.GetPartialLongNameEx can be used to get it.
+ ///
///
/// The text of the line where the completion is happening. This is only used to make a couple
/// of adhoc corrections to completion accuracy (e.g. checking for "..")
///
+ ///
+ /// Function that returns all symbols from current and referenced assemblies.
+ ///
///
/// If text has been used from a captured name resolution from the typecheck, then
/// callback to the client to check if the text has changed. If it has, then give up
/// and assume that we're going to repeat the operation later on.
///
/// An optional string used for tracing compiler operations associated with this request.
- member GetDeclarationListSymbols : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * colAtEndOfPartialName: int * lineText:string * qualifyingNames: string list * partialName: string * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async
+ member GetDeclarationListSymbols : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async
/// Compute a formatted tooltip for the given location
@@ -200,7 +204,7 @@ type internal FSharpCheckFileResults =
/// The text of the line where the information is being requested.
/// The identifiers at the location where the information is being requested.
/// An optional string used for tracing compiler operations associated with this request.
- member GetF1Keyword : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async
+ member GetF1Keyword : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async
/// Compute a set of method overloads to show in a dialog relevant to the given code location.
@@ -210,7 +214,7 @@ type internal FSharpCheckFileResults =
/// The text of the line where the information is being requested.
/// The identifiers at the location where the information is being requested.
/// An optional string used for tracing compiler operations associated with this request.
- member GetMethods : line:int * colAtEndOfNames:int * lineText:string * names:string list option * ?userOpName: string -> Async
+ member GetMethods : line:int * colAtEndOfNames:int * lineText:string * names:string list option * ?userOpName: string -> Async
/// Compute a set of method overloads to show in a dialog relevant to the given code location. The resulting method overloads are returned as symbols.
/// The line number where the information is being requested.
@@ -262,9 +266,16 @@ type internal FSharpCheckFileResults =
/// An optional string used for tracing compiler operations associated with this request.
member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item * ?userOpName: string -> Async
+ /// Determines if a long ident is resolvable at a specific point.
+ /// An optional string used for tracing compiler operations associated with this request.
+ member IsRelativeNameResolvableFromSymbol: cursorPos : pos * plid : string list * symbol: FSharpSymbol * ?userOpName: string -> Async
+
/// Represents complete typechecked implementation files, including thier typechecked signatures if any.
member ImplementationFiles: FSharpImplementationFileContents list option
+ /// Open declarations in the file, including auto open modules.
+ member OpenDeclarations: FSharpOpenDeclaration list
+
/// A handle to the results of CheckFileInProject.
[]
#if COMPILER_PUBLIC_API
diff --git a/tests/service/CSharpProjectAnalysis.fs b/tests/service/CSharpProjectAnalysis.fs
index 188d733cd1..7acf06c711 100644
--- a/tests/service/CSharpProjectAnalysis.fs
+++ b/tests/service/CSharpProjectAnalysis.fs
@@ -111,7 +111,7 @@ let _ = CSharpOuterClass.InnerClass.StaticMember()
|> Async.RunSynchronously
|> Array.map (fun su -> su.Symbol.ToString())
|> shouldEqual
- [|"InnerEnum"; "CSharpOuterClass"; "field Case1"; "InnerClass";
+ [|"Tests"; "InnerEnum"; "CSharpOuterClass"; "field Case1"; "InnerClass";
"CSharpOuterClass"; "member StaticMember"; "NestedEnumClass"|]
[]
diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs
index 8b70eeda1b..2e050abe32 100755
--- a/tests/service/EditorTests.fs
+++ b/tests/service/EditorTests.fs
@@ -86,7 +86,8 @@ let ``Intro test`` () =
let tip = typeCheckResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], identToken) |> Async.RunSynchronously
// (sprintf "%A" tip).Replace("\n","") |> shouldEqual """FSharpToolTipText [Single ("val foo : unit -> unitFull name: Test.foo",None)]"""
// Get declarations (autocomplete) for a location
- let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, 23, inputLines.[6], [], "msg", (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
+ let partialName = { QualifyingIdents = []; PartialIdent = "msg"; EndColumn = 22; LastDotPos = None }
+ let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, inputLines.[6], partialName, (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
CollectionAssert.AreEquivalent(stringMethods,[ for item in decls.Items -> item.Name ])
// Get overloads of the String.Concat method
let methods = typeCheckResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously
@@ -285,7 +286,7 @@ let ``Expression typing test`` () =
// gives the results for the string type.
//
for col in 42..43 do
- let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 2, col, inputLines.[1], [], "", (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
+ let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 2, inputLines.[1], PartialLongName.Empty(col), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
let autoCompleteSet = set [ for item in decls.Items -> item.Name ]
autoCompleteSet |> shouldEqual (set stringMethods)
@@ -306,7 +307,7 @@ type Test() =
let file = "/home/user/Test.fsx"
let parseResult, typeCheckResults = parseAndCheckScript(file, input)
- let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, 21, inputLines.[3], [], "", (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
+ let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(20), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
let item = decls.Items |> Array.tryFind (fun d -> d.Name = "abc")
decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true
@@ -323,7 +324,7 @@ type Test() =
let file = "/home/user/Test.fsx"
let parseResult, typeCheckResults = parseAndCheckScript(file, input)
- let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, 22, inputLines.[3], [], "", (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
+ let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(21), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
let item = decls.Items |> Array.tryFind (fun d -> d.Name = "abc")
decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true
@@ -340,7 +341,7 @@ type Test() =
let file = "/home/user/Test.fsx"
let parseResult, typeCheckResults = parseAndCheckScript(file, input)
- let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, 15, inputLines.[3], [], "", (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
+ let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(14), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously
decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true
[]
@@ -356,7 +357,7 @@ type Test() =
let file = "/home/user/Test.fsx"
let parseResult, typeCheckResults = parseAndCheckScript(file, input)
- let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, 21, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously
+ let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(20), fun _ -> false)|> Async.RunSynchronously
//decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A"
decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true
@@ -373,7 +374,7 @@ type Test() =
let file = "/home/user/Test.fsx"
let parseResult, typeCheckResults = parseAndCheckScript(file, input)
- let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, 22, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously
+ let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(21), fun _ -> false)|> Async.RunSynchronously
//decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A"
decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true
@@ -390,7 +391,7 @@ type Test() =
let file = "/home/user/Test.fsx"
let parseResult, typeCheckResults = parseAndCheckScript(file, input)
- let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, 15, inputLines.[3], [], "", fun _ -> false)|> Async.RunSynchronously
+ let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(14), fun _ -> false)|> Async.RunSynchronously
//decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A"
decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true
@@ -632,15 +633,18 @@ let _ =
|> Array.map (fun su ->
let r = su.RangeAlternate
su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn))
+ |> Array.distinct
|> shouldEqual
- [|("ConsoleKey", (5, 10, 5, 20))
- ("field Tab", (5, 10, 5, 24))
- ("ConsoleKey", (6, 6, 6, 16))
- ("field OemClear", (6, 6, 6, 25))
- ("ConsoleKey", (6, 29, 6, 39))
- ("field A", (6, 29, 6, 41))
- ("ConsoleKey", (7, 11, 7, 21))
- ("field B", (7, 11, 7, 23))
+ // note: these "System" sysbol uses are not duplications because each of them corresponts to different namespaces
+ [|("System", (2, 5, 2, 11))
+ ("ConsoleKey", (5, 10, 5, 20));
+ ("field Tab", (5, 10, 5, 24));
+ ("ConsoleKey", (6, 6, 6, 16));
+ ("field OemClear", (6, 6, 6, 25));
+ ("ConsoleKey", (6, 29, 6, 39));
+ ("field A", (6, 29, 6, 41));
+ ("ConsoleKey", (7, 11, 7, 21));
+ ("field B", (7, 11, 7, 23));
("Test", (1, 0, 1, 0))|]
[]
diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs
index c09d8d4ca1..1a345c4a76 100644
--- a/tests/service/ProjectAnalysisTests.fs
+++ b/tests/service/ProjectAnalysisTests.fs
@@ -368,10 +368,11 @@ let ``Test project1 all uses of all signature symbols`` () =
("field DisableFormatting",
[("file2", ((28, 4), (28, 21))); ("file2", ((30, 16), (30, 45)))]);
("M",
- [("file1", ((1, 7), (1, 8))); ("file2", ((6, 28), (6, 29)));
- ("file2", ((9, 28), (9, 29))); ("file2", ((12, 27), (12, 28)));
- ("file2", ((38, 12), (38, 13))); ("file2", ((38, 22), (38, 23)));
- ("file2", ((39, 12), (39, 13))); ("file2", ((39, 28), (39, 29)))]);
+ [("file1", ((1, 7), (1, 8))); ("file2", ((3, 5), (3, 6)));
+ ("file2", ((6, 28), (6, 29))); ("file2", ((9, 28), (9, 29)));
+ ("file2", ((12, 27), (12, 28))); ("file2", ((38, 12), (38, 13)));
+ ("file2", ((38, 22), (38, 23))); ("file2", ((39, 12), (39, 13)));
+ ("file2", ((39, 28), (39, 29)))])
("val xxx",
[("file1", ((6, 4), (6, 7))); ("file1", ((7, 13), (7, 16)));
("file1", ((7, 19), (7, 22))); ("file2", ((6, 28), (6, 33)));
@@ -420,6 +421,7 @@ let ``Test project1 all uses of all symbols`` () =
("C", "M.C", "file1", ((9, 15), (9, 16)), ["class"]);
("CAbbrev", "M.CAbbrev", "file1", ((9, 5), (9, 12)), ["abbrev"]);
("M", "M", "file1", ((1, 7), (1, 8)), ["module"]);
+ ("M", "M", "file2", ((3, 5), (3, 6)), ["module"]);
("D1", "N.D1", "file2", ((5, 5), (5, 7)), ["class"]);
("( .ctor )", "N.D1.( .ctor )", "file2", ((5, 5), (5, 7)),
["member"; "ctor"]);
@@ -3686,32 +3688,33 @@ let ``Test Project25 symbol uses of type-provided members`` () =
allUses |> shouldEqual
- [|("FSharp.Data.XmlProvider", "file1", ((4, 15), (4, 26)),
- ["class"; "provided"; "erased"]);
- ("FSharp.Data.XmlProvider", "file1", ((4, 15), (4, 26)),
- ["class"; "provided"; "erased"]);
- ("FSharp.Data.XmlProvider", "file1", ((4, 15), (4, 26)),
- ["class"; "provided"; "erased"]);
- ("FSharp.Data.XmlProvider", "file1", ((4, 15), (4, 26)),
- ["class"; "provided"; "erased"]);
- ("TypeProviderTests.Project", "file1", ((4, 5), (4, 12)), ["abbrev"]);
- ("TypeProviderTests.Project", "file1", ((5, 8), (5, 15)), ["abbrev"]);
- ("FSharp.Data.XmlProvider<...>.GetSample", "file1", ((5, 8), (5, 25)),
- ["member"]);
- ("Microsoft.FSharp.Core.int", "file1", ((7, 23), (7, 26)), ["abbrev"]);
- ("Microsoft.FSharp.Core.int", "file1", ((7, 23), (7, 26)), ["abbrev"]);
- ("TypeProviderTests.Record.Field", "file1", ((7, 16), (7, 21)), ["field"]);
- ("TypeProviderTests.Record", "file1", ((7, 5), (7, 11)), ["record"]);
- ("TypeProviderTests.Record", "file1", ((8, 10), (8, 16)), ["record"]);
- ("TypeProviderTests.Record.Field", "file1", ((8, 17), (8, 22)), ["field"]);
- ("TypeProviderTests.r", "file1", ((8, 4), (8, 5)), ["val"]);
- ("FSharp.Data.XmlProvider", "file1", ((10, 8), (10, 19)),
- ["class"; "provided"; "erased"]);
- ("FSharp.Data.XmlProvider<...>", "file1", ((10, 8), (10, 68)),
- ["class"; "provided"; "staticinst"; "erased"]);
- ("FSharp.Data.XmlProvider<...>.GetSample", "file1", ((10, 8), (10, 78)),
- ["member"]);
- ("TypeProviderTests", "file1", ((2, 7), (2, 24)), ["module"])|]
+ [|("FSharp.Data", "file1", ((3, 5), (3, 16)), ["namespace"; "provided"]);
+ ("Microsoft.FSharp.Data", "file1", ((3, 5), (3, 16)), ["namespace"]);
+ ("FSharp.Data.XmlProvider", "file1", ((4, 15), (4, 26)),
+ ["class"; "provided"; "erased"]);
+ ("FSharp.Data.XmlProvider", "file1", ((4, 15), (4, 26)),
+ ["class"; "provided"; "erased"]);
+ ("FSharp.Data.XmlProvider", "file1", ((4, 15), (4, 26)),
+ ["class"; "provided"; "erased"]);
+ ("FSharp.Data.XmlProvider", "file1", ((4, 15), (4, 26)),
+ ["class"; "provided"; "erased"]);
+ ("TypeProviderTests.Project", "file1", ((4, 5), (4, 12)), ["abbrev"]);
+ ("TypeProviderTests.Project", "file1", ((5, 8), (5, 15)), ["abbrev"]);
+ ("FSharp.Data.XmlProvider<...>.GetSample", "file1", ((5, 8), (5, 25)),
+ ["member"]);
+ ("Microsoft.FSharp.Core.int", "file1", ((7, 23), (7, 26)), ["abbrev"]);
+ ("Microsoft.FSharp.Core.int", "file1", ((7, 23), (7, 26)), ["abbrev"]);
+ ("TypeProviderTests.Record.Field", "file1", ((7, 16), (7, 21)), ["field"]);
+ ("TypeProviderTests.Record", "file1", ((7, 5), (7, 11)), ["record"]);
+ ("TypeProviderTests.Record", "file1", ((8, 10), (8, 16)), ["record"]);
+ ("TypeProviderTests.Record.Field", "file1", ((8, 17), (8, 22)), ["field"]);
+ ("TypeProviderTests.r", "file1", ((8, 4), (8, 5)), ["val"]);
+ ("FSharp.Data.XmlProvider", "file1", ((10, 8), (10, 19)),
+ ["class"; "provided"; "erased"]);
+ ("FSharp.Data.XmlProvider<...>", "file1", ((10, 8), (10, 68)),
+ ["class"; "provided"; "staticinst"; "erased"]);
+ ("FSharp.Data.XmlProvider<...>.GetSample", "file1", ((10, 8), (10, 78)),
+ ["member"]); ("TypeProviderTests", "file1", ((2, 7), (2, 24)), ["module"])|]
let getSampleSymbolUseOpt =
backgroundTypedParse1.GetSymbolUseAtLocation(5,25,"",["GetSample"])
|> Async.RunSynchronously
diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs
index 4fddf734b6..39ecd5124b 100644
--- a/tests/service/ProjectOptionsTests.fs
+++ b/tests/service/ProjectOptionsTests.fs
@@ -20,6 +20,10 @@ open FSharp.Compiler.Service.Tests.Common
#if !NO_PROJECTCRACKER
+let hasMSBuild14 =
+ use engine = new Microsoft.Build.Evaluation.ProjectCollection()
+ engine.Toolsets |> Seq.exists (fun x -> x.ToolsPath.Contains "v14.0")
+
let normalizePath s = (new Uri(s)).LocalPath
let checkOption (opts:string[]) s =
@@ -90,7 +94,7 @@ let ``Project file parsing example 1 Default configuration relative path`` () =
[]
let ``Project file parsing VS2013_FSharp_Portable_Library_net45``() =
- if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
+ if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let projectFile = __SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj"
let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [])
@@ -106,7 +110,7 @@ let ``Project file parsing VS2013_FSharp_Portable_Library_net45``() =
[]
let ``Project file parsing Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78``() =
- if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
+ if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let projectFile = __SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj"
Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/")
@@ -141,7 +145,8 @@ let ``Project file parsing -- bad project file``() =
ProjectCracker.GetProjectOptionsFromProjectFileLogged(f) |> ignore
failwith "Expected exception"
with e ->
- Assert.That(e.Message, Contains.Substring "The project file could not be loaded.")
+ Assert.That(e.Message, Contains.Substring "Could not load project")
+ Assert.That(e.Message, Contains.Substring "Malformed.fsproj")
[]
let ``Project file parsing -- non-existent project file``() =
@@ -149,7 +154,7 @@ let ``Project file parsing -- non-existent project file``() =
try
ProjectCracker.GetProjectOptionsFromProjectFileLogged(f, enableLogging=true) |> ignore
with e ->
- Assert.That(e.Message, Contains.Substring "Could not find file")
+ Assert.That(e.Message, Contains.Substring "DoesNotExist.fsproj")
[]
let ``Project file parsing -- output file``() =
@@ -175,9 +180,20 @@ let ``Project file parsing -- references``() =
references |> should haveLength 4
p.ReferencedProjects |> should be Empty
+[]
+let ``Project file parsing -- no project references``() =
+ let p = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/Test3.fsproj")
+
+ let references = getReferencedFilenames p.OtherOptions
+ checkOption references "FSharp.Core.dll"
+ checkOption references "mscorlib.dll"
+ checkOption references "System.Core.dll"
+ checkOption references "System.dll"
+ p.ReferencedProjects |> should haveLength 0
+
[]
let ``Project file parsing -- 2nd level references``() =
- let p = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/Test2.fsproj")
+ let p,_ = ProjectCracker.GetProjectOptionsFromProjectFileLogged(__SOURCE_DIRECTORY__ + @"/data/Test2.fsproj", enableLogging=true)
let references = getReferencedFilenames p.OtherOptions
checkOption references "FSharp.Core.dll"
@@ -190,6 +206,7 @@ let ``Project file parsing -- 2nd level references``() =
p.ReferencedProjects |> should haveLength 1
(snd p.ReferencedProjects.[0]).ProjectFileName |> should contain (normalizePath (__SOURCE_DIRECTORY__ + @"/data/Test1.fsproj"))
+
[]
let ``Project file parsing -- reference project output file``() =
let p = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/DifferingOutputDir/Dir2/Test2.fsproj")
@@ -207,20 +224,23 @@ let ``Project file parsing -- reference project output file``() =
[]
let ``Project file parsing -- Tools Version 12``() =
+ if not hasMSBuild14 then () else
let opts = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj")
checkOption (getReferencedFilenames opts.OtherOptions) "System.Core.dll"
[]
let ``Project file parsing -- Logging``() =
+ if not hasMSBuild14 then () else
let projectFileName = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj")
let _, logMap = ProjectCracker.GetProjectOptionsFromProjectFileLogged(projectFileName, enableLogging=true)
let log = logMap.[projectFileName]
-
+
+ Assert.That(log, Is.StringContaining("ResolveAssemblyReference"))
if runningOnMono then
- Assert.That(log, Is.StringContaining("Reference System.Core resolved"))
- Assert.That(log, Is.StringContaining("Using task ResolveAssemblyReference from Microsoft.Build.Tasks.ResolveAssemblyReference"))
- else
- Assert.That(log, Is.StringContaining("""Using "ResolveAssemblyReference" task from assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"."""))
+ Assert.That(log, Is.StringContaining("System.Core"))
+ Assert.That(log, Is.StringContaining("Microsoft.Build.Tasks.ResolveAssemblyReference"))
+ else
+ Assert.That(log, Is.StringContaining("Microsoft.Build.Tasks.Core"))
[]
let ``Project file parsing -- FSharpProjectOptions.SourceFiles contains both fs and fsi files``() =
@@ -237,6 +257,7 @@ let ``Project file parsing -- FSharpProjectOptions.SourceFiles contains both fs
[]
let ``Project file parsing -- Full path``() =
+ if not hasMSBuild14 then () else
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj")
let p = ProjectCracker.GetProjectOptionsFromProjectFile(f)
p.ProjectFileName |> should equal f
@@ -253,6 +274,7 @@ let ``Project file parsing -- project references``() =
[]
let ``Project file parsing -- multi language project``() =
+ if not hasMSBuild14 then () else
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/MultiLanguageProject/ConsoleApplication1.fsproj")
let options = ProjectCracker.GetProjectOptionsFromProjectFile(f)
@@ -265,8 +287,7 @@ let ``Project file parsing -- multi language project``() =
[]
let ``Project file parsing -- PCL profile7 project``() =
- if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
-
+ if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj")
@@ -315,8 +336,7 @@ let ``Project file parsing -- PCL profile7 project``() =
[]
let ``Project file parsing -- PCL profile78 project``() =
- if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
-
+ if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj")
@@ -356,7 +376,7 @@ let ``Project file parsing -- PCL profile78 project``() =
[]
let ``Project file parsing -- PCL profile259 project``() =
- if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
+ if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile259/Sample_VS2013_FSharp_Portable_Library_net451.fsproj")
let options = ProjectCracker.GetProjectOptionsFromProjectFile(f)
@@ -468,9 +488,11 @@ let ``Test OtherOptions order for GetProjectOptionsFromScript`` () =
projOpts.OtherOptions
|> Array.map (fun s -> if s.StartsWith "--" then s else Path.GetFileNameWithoutExtension s)
- |> Array.sort
- |> shouldEqual (Array.sort expected2)
- let otherArgs = [|"--noframework"; "--warn:3"; "System.Numerics"; "mscorlib"; "FSharp.Core"; "System"; "System.Xml"; "System.Runtime.Remoting"; "System.Runtime.Serialization.Formatters.Soap"; "System.Data"; "System.Drawing"; "System.Core"; "System.Runtime"; "System.Linq"; "System.Reflection"; "System.Linq.Expressions"; "System.Threading.Tasks"; "System.IO"; "System.Net.Requests"; "System.Collections"; "System.Runtime.Numerics"; "System.Threading"; "System.Web"; "System.Web.Services"; "System.Windows.Forms"; "FSharp.Compiler.Interactive.Settings"|]
+ |> Array.forall (fun s -> Set.contains s expected2)
+ |> shouldEqual true
+
+ let otherArgs = [|"--noframework"; "--warn:3"; "System.Numerics"; "mscorlib"; "FSharp.Core"; "System"; "System.Xml"; "System.Runtime.Remoting"; "System.Runtime.Serialization.Formatters.Soap"; "System.Data"; "System.Drawing"; "System.Core"; "System.Runtime"; "System.Linq"; "System.Reflection"; "System.Linq.Expressions"; "System.Threading.Tasks"; "System.IO"; "System.Net.Requests"; "System.Collections"; "System.Runtime.Numerics"; "System.Threading"; "System.Web"; "System.Web.Services"; "System.Windows.Forms"; "FSharp.Compiler.Interactive.Settings"|] |> Set.ofArray
+
test "Main1" otherArgs
test "Main2" otherArgs
test "Main3" otherArgs
diff --git a/tests/service/data/Test3.fsproj b/tests/service/data/Test3.fsproj
new file mode 100644
index 0000000000..31c2d33c56
--- /dev/null
+++ b/tests/service/data/Test3.fsproj
@@ -0,0 +1,62 @@
+
+
+
+ Debug
+ x86
+ 8.0.30703
+ 2.0
+ {116cc2f9-f987-4b3d-915a-34cac04a73db}
+ ..\..\..\$(Configuration)\net40\bin
+ Exe
+ Test2
+ Test2
+ Test2
+ False
+ 11
+
+
+ True
+ full
+ False
+ False
+ DEBUG;TRACE
+ 3
+ x86
+ bin\Debug\Test2.xml
+
+
+ pdbonly
+ True
+ True
+ TRACE
+ 3
+ x86
+ bin\Release\Test2.xml
+ False
+
+
+
+ ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ..\..\..\packages\NUnit\lib\nunit.framework.dll
+ True
+ True
+
+
+
+
+
\ No newline at end of file