Skip to content

FCS API internalizations and renamings #10756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/fcs/interactive.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Catching errors
``EvalExpression``, ``EvalInteraction`` and ``EvalScript`` are awkward if the
code has type checking warnings or errors, or if evaluation fails with an exception.
In these cases you can use ``EvalExpressionNonThrowing``, ``EvalInteractionNonThrowing``
and ``EvalScriptNonThrowing``. These return a tuple of a result and an array of ``FSharpErrorInfo`` values.
and ``EvalScriptNonThrowing``. These return a tuple of a result and an array of ``FSharpDiagnostic`` values.
These represent the errors and warnings. The result part is a ``Choice<_,_>`` between an actual
result and an exception.

Expand Down
2 changes: 1 addition & 1 deletion docs/fcs/ja/interactive.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fsiSession.EvalScript "sample.fsx"
`EvalExpression` 、 `EvalInteraction` そして `EvalScript` ではあまりうまく処理されません。
これらのケースでは、 `EvalExpressionNonThrowing` 、 `EvalInteractionNonThrowing`
そして `EvalScriptNonThrowing` を使うことが出来ます。
これらは結果と `FSharpErrorInfo` 値の配列の組を返します。
これらは結果と `FSharpDiagnostic` 値の配列の組を返します。
これらはエラーと警告を表します。結果の部分は実際の結果と例外のいずれかを表す
`Choice<_,_>` です。

Expand Down
43 changes: 39 additions & 4 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,42 @@ This release covers three important milestones: F# 5, Visual Studio 16.8, and .N
* Compiler message improvements (especially for overload resolution) by [Gauthier Segay](https://github.com/smoothdeveloper), [Vladimir Shchur](https://github.com/Lanayx), and Microsoft

### FSharp Compiler Service 39.0.0
* Add ConvertToAnonymousRecord quick fixeroony [#10493](https://github.com/dotnet/fsharp/pull/10493)
* Renamings
* FSharp.Compiler.AbstractIL.Internal.Library.IFileSystem -> FSharp.Compiler.SourceCodeServices.IFileSystem
* FSharp.Compiler.AbstractIL.Internal.Library.Shim -> FSharp.Compiler.SourceCodeServices.FileSystemAutoOpens
* FSharp.Compiler.AbstractIL.Internal.Layout -> FSharp.Compiler.TextLayout.Layout
* FSharp.Compiler.AbstractIL.Internal.TaggedText -> FSharp.Compiler.TextLayout.TaggedText
* type FSharp.Compiler.Layout.layout -> FSharp.Compiler.TextLayout.Layout
* type FSharp.Compiler.Layout.Layout -> FSharp.Compiler.TextLayout.Layout
* module FSharp.Compiler.Layout -> FSharp.Compiler.TextLayout.LayoutRender
* FSharp.Compiler.LayoutOps -> FSharp.Compiler.TextLayout.Layout
* FSharp.Compiler.Layout.TaggedText -> FSharp.Compiler.TextLayout.TaggedText
* FSharp.Compiler.Layout.TaggedTextOps -> FSharp.Compiler.TextLayout.TaggedText
* FSharp.Compiler.Layout.TaggedTextOps.Literals -> FSharp.Compiler.TextLayout.TaggedText
*
* Renamings in FSharp.Compiler.SourceCodeServices
* Lexer.* --> FSharp.Compiler.SourceCodeServices.*
* FSharpSyntaxToken* --> FSharpToken*
* FSharpErrorInfo --> FSharpDiagnostic
* FSharpErrorSeverity --> FSharpDiagnosticSeverity
* ExternalSymbol --> FSharpExternalSymbol
* UnresolvedSymbol --> FSharpUnresolvedSymbol
* CompletionKind --> FSharpCompletionKind
* module Keywords --> FSharpKeywords
* module Tooltips --> FSharpTooltip
*
* Extension methods in `ServiceAssemblyContent.fsi` now intrinsic methods on symbol types
*
* Internalizations:
* FSharp.Compiler.AbstractIL.* now internal
* FSharp.Compiler.ErrorLogger.* now internal
*
* New functions in the SourceCodeServices API:
*
* `FSharpDiagnostic.NewlineifyErrorString`
* `FSharpDiagnostic.NormalizeErrorString`
*
* Add ConvertToAnonymousRecord quick fixeroony [#10493](https://github.com/dotnet/fsharp/pull/10493)
* Add UseMutationWhenValueIsMutable code fix [#10488](https://github.com/dotnet/fsharp/pull/10488)
* Add MakeDeclarationMutable code fix [#10480](https://github.com/dotnet/fsharp/pull/10480)
* Add ChangeToUpcast code fix [#10463](https://github.com/dotnet/fsharp/pull/10463)
Expand Down Expand Up @@ -479,7 +514,7 @@ Significant improvements in the F# tools, such as performance enhancements and s
There is now an experimental CodeLens implementation, contributed by [Victor Peter Rouven Müller](https://github.com/realvictorprm). You can turn it on in **Options > Text Editor > F# > Code Lens**.
* A bug where the F# compiler service would incorrectly elide the module names in XML documentation has been fixed by [Sebastian Urban](https://github.com/surban).
* Code that uses `Dictionary` with `ContainsKey` and subsequent `Item` calls has been changed to use `TryGetValue`, by [Eugene Auduchinok](https://github.com/auduchinok).
* [Jakob Majoka](https://github.com/majocha) also contributed in the process of consuming a different API for Tooltips.
* [Jakob Majoka](https://github.com/majocha) also contributed in the process of consuming a different API for FSharpToolTip.

#### Infrastructure, Packaging, and Open Source Improvements

Expand Down Expand Up @@ -743,7 +778,7 @@ Integrate dotnet/fsharp from 48f932cf8 to 085985140. Notable changes include:
* Integrate dotnet/fsharp from 5a8f454a1 to 05c558a61
* Notable changes include:
* Removal of the `Microsoft.FSharp.Compiler.SourceCodeServices` namespace
* A new API for determining if an identifier needs to be quoted is available: `FSharp.Compiler.LexHelp.Keywords.DoesIdentifierNeedQuotation`
* A new API for determining if an identifier needs to be quoted is available: `FSharp.Compiler.LexHelp.FSharpKeywords.DoesIdentifierNeedQuotation`
* Enhancements to the correctness of PDBs
* Better string formatting of records and values
* More stack overflow fixes in the compiler
Expand Down Expand Up @@ -1053,7 +1088,7 @@ Integrate dotnet/fsharp from 48f932cf8 to 085985140. Notable changes include:

* Integrate visualfsharp/master and fsharp/master --> master
* Expose QualifiedName and FileName of FSharpImplementationFileContents
* Add FSharpErrorInfo.ErrorNumber
* Add FSharpDiagnostic.ErrorNumber

### 2.0.0.1-beta

Expand Down
6 changes: 4 additions & 2 deletions src/fsharp/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3327,6 +3327,7 @@ module EstablishTypeDefinitionCores =
TNoRepr

| SynTypeDefnSimpleRepr.LibraryOnlyILAssembly (s, m) ->
let s = (s :?> ILType)
// Run InferTyconKind to raise errors on inconsistent attribute sets
InferTyconKind cenv.g (TyconILAssemblyCode, attrs, [], [], inSig, true, m) |> ignore
TAsmRepr s
Expand Down Expand Up @@ -3931,6 +3932,7 @@ module EstablishTypeDefinitionCores =
TRecdRepr (Construct.MakeRecdFieldsTable recdFields), None, NoSafeInitInfo

| SynTypeDefnSimpleRepr.LibraryOnlyILAssembly (s, _) ->
let s = (s :?> ILType)
noCLIMutableAttributeCheck()
noMeasureAttributeCheck()
noSealedAttributeCheck FSComp.SR.tcTypesAreAlwaysSealedAssemblyCode
Expand Down Expand Up @@ -5793,7 +5795,7 @@ let TypeCheckOneImplFile
let envinner, mtypeAcc = MakeInitialEnv env

let defs = [ for x in implFileFrags -> SynModuleDecl.NamespaceFragment x ]
let! mexpr, topAttrs, envAtEnd = TcModuleOrNamespaceElements cenv ParentNone qualNameOfFile.Range envinner PreXmlDocEmpty None defs
let! mexpr, topAttrs, envAtEnd = TcModuleOrNamespaceElements cenv ParentNone qualNameOfFile.Range envinner PreXmlDoc.Empty None defs

let implFileTypePriorToSig = !mtypeAcc

Expand Down Expand Up @@ -5900,7 +5902,7 @@ let TypeCheckOneSigFile (g, niceNameGen, amap, topCcu, checkForErrors, condition
let envinner, mtypeAcc = MakeInitialEnv tcEnv

let specs = [ for x in sigFileFrags -> SynModuleSigDecl.NamespaceFragment x ]
let! tcEnv = TcSignatureElements cenv ParentNone qualNameOfFile.Range envinner PreXmlDocEmpty None specs
let! tcEnv = TcSignatureElements cenv ParentNone qualNameOfFile.Range envinner PreXmlDoc.Empty None specs

let sigFileType = !mtypeAcc

Expand Down
7 changes: 4 additions & 3 deletions src/fsharp/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2661,15 +2661,15 @@ let TcVal checkAttributes cenv env tpenv (vref: ValRef) optInst optAfterResoluti
| ValInRecScope true
| ValNotInRecScope ->
let tpsorig, tps, tptys, tau = FreshenPossibleForallTy cenv.g m TyparRigidity.Flexible vty
//dprintfn "After Freshen: tau = %s" (Layout.showL (typeL tau))
//dprintfn "After Freshen: tau = %s" (LayoutRender.showL (typeL tau))
let (tinst: TypeInst), tpenv = checkTys tpenv (tps |> List.map (fun tp -> tp.Kind))
checkInst tinst
//dprintfn "After Check: tau = %s" (Layout.showL (typeL tau))
//dprintfn "After Check: tau = %s" (LayoutRender.showL (typeL tau))
if tptys.Length <> tinst.Length then error(Error(FSComp.SR.tcTypeParameterArityMismatch(tps.Length, tinst.Length), m))
List.iter2 (UnifyTypes cenv env m) tptys tinst
TcValEarlyGeneralizationConsistencyCheck cenv env (v, vrec, tinst, vty, tau, m)

//dprintfn "After Unify: tau = %s" (Layout.showL (typeL tau))
//dprintfn "After Unify: tau = %s" (LayoutRender.showL (typeL tau))
tpsorig, vrefFlags, tinst, tau, tpenv

let exprForVal = Expr.Val (vref, vrefFlags, m)
Expand Down Expand Up @@ -5774,6 +5774,7 @@ and TcExprUndelayed cenv overallTy env tpenv (synExpr: SynExpr) =
mkf n e2', tpenv

| SynExpr.LibraryOnlyILAssembly (s, tyargs, args, rtys, m) ->
let s = (s :?> ILInstr[])
let argTys = NewInferenceTypes args
let tyargs', tpenv = TcTypes cenv NewTyparsOK CheckCxs ItemOccurence.UseInType env tpenv tyargs
// No subsumption at uses of IL assembly code
Expand Down
5 changes: 3 additions & 2 deletions src/fsharp/CompilerConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ open FSharp.Compiler.Features
open FSharp.Compiler.Lib
open FSharp.Compiler.Range
open FSharp.Compiler.ReferenceResolver
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.TypedTree

open Microsoft.DotNet.DependencyManager
Expand Down Expand Up @@ -342,7 +343,7 @@ type TcConfigBuilder =
mutable useHighEntropyVA: bool
mutable inputCodePage: int option
mutable embedResources: string list
mutable errorSeverityOptions: FSharpErrorSeverityOptions
mutable errorSeverityOptions: FSharpDiagnosticOptions
mutable mlCompatibility: bool
mutable checkOverflow: bool
mutable showReferenceResolutions: bool
Expand Down Expand Up @@ -504,7 +505,7 @@ type TcConfigBuilder =
projectReferences = []
knownUnresolvedReferences = []
loadedSources = []
errorSeverityOptions = FSharpErrorSeverityOptions.Default
errorSeverityOptions = FSharpDiagnosticOptions.Default
embedResources = []
inputCodePage = None
reduceMemoryUsage = ReduceMemoryFlag.Yes // always gets set explicitly
Expand Down
5 changes: 3 additions & 2 deletions src/fsharp/CompilerConfig.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ open FSharp.Compiler.AbstractIL.Internal.Library
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.Features
open FSharp.Compiler.Range
open FSharp.Compiler.SourceCodeServices

open Microsoft.DotNet.DependencyManager

Expand Down Expand Up @@ -161,7 +162,7 @@ type TcConfigBuilder =
mutable useHighEntropyVA: bool
mutable inputCodePage: int option
mutable embedResources: string list
mutable errorSeverityOptions: FSharpErrorSeverityOptions
mutable errorSeverityOptions: FSharpDiagnosticOptions
mutable mlCompatibility:bool
mutable checkOverflow:bool
mutable showReferenceResolutions:bool
Expand Down Expand Up @@ -342,7 +343,7 @@ type TcConfig =
member reduceMemoryUsage: ReduceMemoryFlag
member inputCodePage: int option
member embedResources: string list
member errorSeverityOptions: FSharpErrorSeverityOptions
member errorSeverityOptions: FSharpDiagnosticOptions
member mlCompatibility:bool
member checkOverflow:bool
member showReferenceResolutions:bool
Expand Down
12 changes: 8 additions & 4 deletions src/fsharp/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ open FSharp.Compiler.MethodOverrides
open FSharp.Compiler.NameResolution
open FSharp.Compiler.ParseHelpers
open FSharp.Compiler.PrettyNaming
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.Range
open FSharp.Compiler.SignatureConformance
open FSharp.Compiler.TextLayout
open FSharp.Compiler.TextLayout.Layout
open FSharp.Compiler.TextLayout.TaggedText
open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeBasics
open FSharp.Compiler.TypedTreeOps
Expand Down Expand Up @@ -768,16 +772,16 @@ let OutputPhasedErrorR (os: StringBuilder) (err: PhasedDiagnostic) (canSuggestNa
let argsL,retTyL,genParamTysL = NicePrint.prettyLayoutsOfUnresolvedOverloading denv argRepr retTy genericParameterTypes

match callerArgs.ArgumentNamesAndTypes with
| [] -> None, Layout.showL retTyL, Layout.showL genParamTysL
| [] -> None, LayoutRender.showL retTyL, LayoutRender.showL genParamTysL
| items ->
let args = Layout.showL argsL
let args = LayoutRender.showL argsL
let prefixMessage =
match items with
| [_] -> FSComp.SR.csNoOverloadsFoundArgumentsPrefixSingular
| _ -> FSComp.SR.csNoOverloadsFoundArgumentsPrefixPlural
Some (prefixMessage args)
, Layout.showL retTyL
, Layout.showL genParamTysL
, LayoutRender.showL retTyL
, LayoutRender.showL genParamTysL

let knownReturnType =
match knownReturnType with
Expand Down
5 changes: 3 additions & 2 deletions src/fsharp/CompilerDiagnostics.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module internal FSharp.Compiler.CompilerDiagnostics
open System.Text
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.Range
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.SyntaxTree

#if DEBUG
Expand Down Expand Up @@ -101,9 +102,9 @@ val GetErrorLoggerFilteringByScopedPragmas: checkFile:bool * ScopedPragma list *
val SanitizeFileName: fileName: string -> implicitIncludeDir: string -> string

/// Indicates if we should report a warning
val ReportWarning: FSharpErrorSeverityOptions -> PhasedDiagnostic -> bool
val ReportWarning: FSharpDiagnosticOptions -> PhasedDiagnostic -> bool

/// Indicates if we should report a warning as an error
val ReportWarningAsError: FSharpErrorSeverityOptions -> PhasedDiagnostic -> bool
val ReportWarningAsError: FSharpDiagnosticOptions -> PhasedDiagnostic -> bool


2 changes: 1 addition & 1 deletion src/fsharp/CompilerGlobalState.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/// Defines the global environment for all type checking.

module FSharp.Compiler.CompilerGlobalState
module internal FSharp.Compiler.CompilerGlobalState

open FSharp.Compiler.Range

Expand Down
1 change: 1 addition & 0 deletions src/fsharp/CompilerImports.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.Import
open FSharp.Compiler.Lib
open FSharp.Compiler.PrettyNaming
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.SyntaxTreeOps
open FSharp.Compiler.Range
open FSharp.Compiler.ReferenceResolver
Expand Down
10 changes: 6 additions & 4 deletions src/fsharp/CompilerOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ open FSharp.Compiler.Features
open FSharp.Compiler.IlxGen
open FSharp.Compiler.Lib
open FSharp.Compiler.Range
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.TextLayout
open FSharp.Compiler.TextLayout.Layout
open FSharp.Compiler.TextLayout.TaggedText
open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.ErrorLogger

open Internal.Utilities
open Internal.Utilities.StructuredFormat

module Attributes =
open System.Runtime.CompilerServices
Expand Down Expand Up @@ -196,7 +199,6 @@ module ResponseFile =
with e ->
Choice2Of2 e


let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: CompilerOptionBlock list, args) =
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter

Expand Down Expand Up @@ -1621,10 +1623,10 @@ let PrintWholeAssemblyImplementation g (tcConfig:TcConfig) outfile header expr =
let filename = outfile + ".terms"
use f = System.IO.File.CreateText (filename + "-" + string showTermFileCount + "-" + header)
showTermFileCount <- showTermFileCount + 1
Layout.outL f (Display.squashTo 192 (DebugPrint.implFilesL g expr))
LayoutRender.outL f (Display.squashTo 192 (DebugPrint.implFilesL g expr))
else
dprintf "\n------------------\nshowTerm: %s:\n" header
Layout.outL stderr (Display.squashTo 192 (DebugPrint.implFilesL g expr))
LayoutRender.outL stderr (Display.squashTo 192 (DebugPrint.implFilesL g expr))
dprintf "\n------------------\n"

//----------------------------------------------------------------------------
Expand Down
31 changes: 2 additions & 29 deletions src/fsharp/CreateILModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,32 @@
module internal FSharp.Compiler.CreateILModule

open System
open System.Collections.Generic
open System.Diagnostics
open System.Globalization
open System.IO
open System.Reflection
open System.Text
open System.Threading

open Internal.Utilities
open Internal.Utilities.Collections
open Internal.Utilities.Filename
open Internal.Utilities.StructuredFormat

open FSharp.Compiler
open FSharp.Compiler.AbstractIL
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.AbstractIL.ILBinaryReader
open FSharp.Compiler.AbstractIL.Internal
open FSharp.Compiler.AbstractIL.Internal.Library
open FSharp.Compiler.AbstractIL.Internal.Utils
open FSharp.Compiler.AbstractIL.Diagnostics
open FSharp.Compiler.AccessibilityLogic
open FSharp.Compiler.AbstractIL.Internal.StrongNameSign
open FSharp.Compiler.BinaryResourceFormats
open FSharp.Compiler.CheckExpressions
open FSharp.Compiler.CheckDeclarations
open FSharp.Compiler.CompilerConfig
open FSharp.Compiler.CompilerDiagnostics
open FSharp.Compiler.CompilerImports
open FSharp.Compiler.CompilerOptions
open FSharp.Compiler.CompilerGlobalState
open FSharp.Compiler.ErrorLogger
open FSharp.Compiler.IlxGen
open FSharp.Compiler.InfoReader
open FSharp.Compiler.Lib
open FSharp.Compiler.ParseAndCheckInputs
open FSharp.Compiler.PrettyNaming
open FSharp.Compiler.OptimizeInputs
open FSharp.Compiler.ScriptClosure
open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Range
open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeBasics
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.XmlDocFileWriter
open FSharp.Compiler.StaticLinking
open Microsoft.DotNet.DependencyManager

open FSharp.Compiler.AbstractIL.Internal.StrongNameSign

#if !NO_EXTENSIONTYPING
open FSharp.Compiler.ExtensionTyping
#endif

//----------------------------------------------------------------------------
// Helpers for finding attributes
Expand Down
Loading