From e2e29f377e6369ea5134e73d929c0b02a51ed419 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 30 Jul 2020 22:26:38 +0200 Subject: [PATCH 1/9] Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages --- .../ConstraintSolver/MemberConstraints.fs | 2 +- .../ConstraintSolver/PrimitiveConstraints.fs | 2 +- .../AccessOfTypeAbbreviationTests.fs | 63 ++-- .../ErrorMessages/AssignmentErrorTests.fs | 19 +- .../ErrorMessages/ClassesTests.fs | 110 ++++--- .../ErrorMessages/ConfusingTypeName.fs | 5 +- .../ErrorMessages/ConstructorTests.fs | 94 +++--- .../ErrorMessages/DontSuggestTests.fs | 44 ++- .../ElseBranchHasWrongTypeTests.fs | 136 ++++----- .../InvalidNumericLiteralTests.fs | 61 ++-- .../ErrorMessages/MissingElseBranch.fs | 46 ++- .../ErrorMessages/MissingExpressionTests.fs | 20 +- .../ErrorMessages/ModuleAbbreviationTests.fs | 18 +- .../ErrorMessages/NameResolutionTests.fs | 31 +- .../ErrorMessages/SuggestionsTests.fs | 283 ++++++++---------- .../ErrorMessages/TypeMismatchTests.fs | 115 ++++--- .../ErrorMessages/UnitGenericAbstactType.fs | 23 +- .../ErrorMessages/UpcastDowncastTests.fs | 46 ++- .../ErrorMessages/WarnExpressionTests.fs | 168 +++++------ .../ErrorMessages/WrongSyntaxInForLoop.fs | 15 +- .../Interop/SimpleInteropTests.fs | 3 +- .../Language/CodeQuotationTests.fs | 2 +- .../Language/CompilerDirectiveTests.fs | 4 +- tests/FSharp.Test.Utilities/Compiler.fs | 33 +- tests/FSharp.Test.Utilities/CompilerAssert.fs | 7 +- 25 files changed, 630 insertions(+), 720 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs index f14c2495c37d..77ae35463fc4 100644 --- a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ConstraintSolver.ComponentTests +namespace FSharp.Compiler.ComponentTests.ConstraintSolver open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs index 873864edaffc..a22d61db60cb 100644 --- a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ConstraintSolver.ComponentTests +namespace FSharp.Compiler.ComponentTests.ConstraintSolver open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs index 416c62d63f63..df9acf7efca6 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs @@ -1,75 +1,74 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities +open FSharp.Test.Utilities.Compiler open FSharp.Compiler.SourceCodeServices module ``Access Of Type Abbreviation`` = + let warning44Message = "This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors." + [] let ``Private type produces warning when trying to export``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type private Hidden = Hidden of unit type Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 8, 4, 16) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 8, Line 4, Col 16, warning44Message) [] let ``Internal type passes when abbrev is internal``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type internal Hidden = Hidden of unit type internal Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed [] let ``Internal type produces warning when trying to export``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type internal Hidden = Hidden of unit type Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 8, 4, 16) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 8, Line 4, Col 16, warning44Message) [] let ``Private type produces warning when abbrev is internal``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type private Hidden = Hidden of unit type internal Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 17, 4, 25) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 17, Line 4, Col 25, warning44Message) [] let ``Private type passes when abbrev is private``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type private Hidden = Hidden of unit type private Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed [] let ``Default access type passes when abbrev is default``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type Hidden = Hidden of unit type Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs index f2f598d9dba7..dd986cf50097 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs @@ -1,22 +1,19 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices - +open FSharp.Test.Utilities.Compiler module ``Errors assigning to mutable objects`` = [] let ``Assign to immutable error``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 x <- 20 - """ - FSharpErrorSeverity.Error - 27 - (3, 1, 3, 8) - "This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 27, Line 3, Col 1, Line 3, Col 8, + "This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs index a51e92ed944b..e1941a3d7eb2 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Classes`` = [] let ``Tuple In Abstract Method``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IInterface = abstract Function : (int32 * int32) -> unit @@ -19,47 +17,44 @@ let x = { new IInterface with member this.Function (i, j) = () } - """ - [| - FSharpErrorSeverity.Error, 768, (7, 16, 7, 36), "The member 'Function' does not accept the correct number of arguments. 1 argument(s) are expected, but 2 were given. The required signature is 'member IInterface.Function : (int32 * int32) -> unit'.\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface." - FSharpErrorSeverity.Error, 17, (7, 21, 7, 29), "The member 'Function : 'a * 'b -> unit' does not have the correct type to override the corresponding abstract method. The required signature is 'Function : (int32 * int32) -> unit'." - FSharpErrorSeverity.Error, 783, (6, 9, 6, 19), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 768, Line 7, Col 16, Line 7, Col 36, "The member 'Function' does not accept the correct number of arguments. 1 argument(s) are expected, but 2 were given. The required signature is 'member IInterface.Function : (int32 * int32) -> unit'.\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface.") + (Error 17, Line 7, Col 21, Line 7, Col 29, "The member 'Function : 'a * 'b -> unit' does not have the correct type to override the corresponding abstract method. The required signature is 'Function : (int32 * int32) -> unit'.") + (Error 783, Line 6, Col 9, Line 6, Col 19, "At least one override did not correctly implement its corresponding abstract member")] [] let ``Wrong Arity``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyType() = static member MyMember(arg1, arg2:int ) = () static member MyMember(arg1, arg2:byte) = () MyType.MyMember("", 0, 0) - """ - FSharpErrorSeverity.Error - 503 - (7, 1, 7, 26) - "A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 503, Line 7, Col 1, Line 7, Col 26, + "A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments.") [] let ``Method Is Not Static``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Class1() = member this.X() = "F#" let x = Class1.X() - """ - FSharpErrorSeverity.Error - 3214 - (5, 9, 5, 17) - "Method or object constructor 'X' is not static" + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 3214, Line 5, Col 9, Line 5, Col 17, "Method or object constructor 'X' is not static") [] let ``Matching Method With Same Name Is Not Abstract``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Foo(x : int) = member v.MyX() = x @@ -67,17 +62,17 @@ let foo = { new Foo(3) with member v.MyX() = 4 } - """ - [| - FSharpErrorSeverity.Error, 767, (8, 16, 8, 23), "The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement." - FSharpErrorSeverity.Error, 17, (8, 18, 8, 21), "The member 'MyX : unit -> int' does not have the correct type to override any given virtual method" - FSharpErrorSeverity.Error, 783, (6, 11, 6, 14), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 767, Line 8, Col 16, Line 8, Col 23, "The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement.") + (Error 17, Line 8, Col 18, Line 8, Col 21, "The member 'MyX : unit -> int' does not have the correct type to override any given virtual method") + (Error 783, Line 6, Col 11, Line 6, Col 14, "At least one override did not correctly implement its corresponding abstract member")] [] let ``No Matching Abstract Method With Same Name``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IInterface = abstract MyFunction : int32 * int32 -> unit abstract SomeOtherFunction : int32 * int32 -> unit @@ -86,18 +81,18 @@ let x = { new IInterface with member this.Function (i, j) = () } - """ - [| - FSharpErrorSeverity.Error, 767, (8, 14, 8, 34), "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:" + System.Environment.NewLine + " MyFunction" - FSharpErrorSeverity.Error, 17, (8, 19, 8, 27), "The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method" - FSharpErrorSeverity.Error, 366, (7, 3, 9, 4), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." - FSharpErrorSeverity.Error, 783, (7, 9, 7, 19), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 767, Line 8, Col 14, Line 8, Col 34, "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:" + System.Environment.NewLine + " MyFunction") + (Error 17, Line 8, Col 19, Line 8, Col 27, "The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method") + (Error 366, Line 7, Col 3, Line 9, Col 4, "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.") + (Error 783, Line 7, Col 9, Line 7, Col 19, "At least one override did not correctly implement its corresponding abstract member")] [] let ``Member Has Multiple Possible Dispatch Slots``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IOverload = abstract member Bar : int -> int abstract member Bar : double -> int @@ -105,23 +100,24 @@ type IOverload = type Overload = interface IOverload with override __.Bar _ = 1 - """ - [| - FSharpErrorSeverity.Error, 366, (7, 15, 7, 24), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IOverload.Bar : double -> int'" + System.Environment.NewLine + "\t'abstract member IOverload.Bar : int -> int'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." - FSharpErrorSeverity.Error, 3213, (8, 21, 8, 24), "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:" + System.Environment.NewLine + " Bar : double -> int" + System.Environment.NewLine + " Bar : int -> int." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 366, Line 7, Col 15, Line 7, Col 24, "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IOverload.Bar : double -> int'" + System.Environment.NewLine + "\t'abstract member IOverload.Bar : int -> int'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.") + (Error 3213, Line 8, Col 21, Line 8, Col 24, "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:" + System.Environment.NewLine + " Bar : double -> int" + System.Environment.NewLine + " Bar : int -> int.")] [] let ``Do Cannot Have Visibility Declarations``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ type X() = do () private do () static member Y() = 1 - """ - [| - FSharpErrorSeverity.Error, 531, (4, 5, 4, 12), "Accessibility modifiers should come immediately prior to the identifier naming a construct" - FSharpErrorSeverity.Error, 512, (4, 13, 4, 18), "Accessibility modifiers are not permitted on 'do' bindings, but 'Private' was given." - FSharpErrorSeverity.Error, 222, (2, 1, 3, 1), "Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration." - |] + """ + |> parse + |> shouldFail + |> withDiagnostics [ + (Error 531, Line 4, Col 5, Line 4, Col 12, "Accessibility modifiers should come immediately prior to the identifier naming a construct") + (Error 512, Line 4, Col 13, Line 4, Col 18, "Accessibility modifiers are not permitted on 'do' bindings, but 'Private' was given.") + (Error 222, Line 2, Col 1, Line 3, Col 1, "Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs index 3c7e569007d0..9e3e75b606b5 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs @@ -1,12 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler -open FSharp.Test.Utilities.Utilities -open FSharp.Compiler.SourceCodeServices module ``Confusing Type Name`` = diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs index c9636e711a52..1806defe4e45 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs @@ -1,42 +1,40 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Constructor`` = [] let ``Invalid Record``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Record = {field1:int; field2:int} let doSomething (xs) = List.map (fun {field1=x} -> x) xs doSomething {Record.field1=0; field2=0} - """ - [| - FSharpErrorSeverity.Error, 1, (4, 13, 4, 40), "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' " - FSharpErrorSeverity.Warning, 20, (4, 1, 4, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 4, Col 1, Line 4, Col 40, "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 4, Col 13, Line 4, Col 40, "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' ")] [] let ``Comma In Rec Ctor``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Person = { Name : string; Age : int; City : string } let x = { Name = "Isaac", Age = 21, City = "London" } - """ - [| - FSharpErrorSeverity.Error, 1, (3, 18, 3, 52), "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' " + System.Environment.NewLine + "A ';' is used to separate field values in records. Consider replacing ',' with ';'." - FSharpErrorSeverity.Error, 764, (3, 9, 3, 54), "No assignment given for field 'Age' of type 'Test.Person'" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 3, Col 18, Line 3, Col 52, "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' " + System.Environment.NewLine + "A ';' is used to separate field values in records. Consider replacing ',' with ';'.") + (Error 764, Line 3, Col 9, Line 3, Col 54, "No assignment given for field 'Age' of type 'Test.Person'")] [] let ``Missing Comma In Ctor``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set @@ -44,18 +42,18 @@ type Person() = let p = Person(Name = "Fred" Age = 18) - """ - [| - FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan" - FSharpErrorSeverity.Warning, 20, (7, 12, 7, 25), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." - FSharpErrorSeverity.Error, 39, (8, 12, 8, 15), "The value or constructor 'Age' is not defined." - FSharpErrorSeverity.Error, 501, (7, 5, 8, 21), "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',')." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 7, Col 12, Line 7, Col 25, "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") + (Error 39, Line 7, Col 12, Line 7, Col 16, "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan") + (Error 39, Line 8, Col 12, Line 8, Col 15, "The value or constructor 'Age' is not defined.") + (Error 501, Line 7, Col 5, Line 8, Col 21, "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',').")] [] let ``Missing Ctor Value``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person(x:int) = member val Name = "" with get,set member val Age = x with get,set @@ -63,32 +61,29 @@ type Person(x:int) = let p = Person(Name = "Fred", Age = 18) - """ - FSharpErrorSeverity.Error - 496 - (7, 5, 8, 21) - "The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 496, Line 7, Col 5, Line 8, Col 21, "The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'.") [] let ``Extra Argument In Ctor``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set let p = Person(1) - """ - FSharpErrorSeverity.Error - 501 - (7, 5, 7, 14) - "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 501, Line 7, Col 5, Line 7, Col 14, + "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'.") [] let ``Extra Argument In Ctor2``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set @@ -97,18 +92,17 @@ let b = 1 let p = Person(1=b) - """ - FSharpErrorSeverity.Error - 501 - (9, 5, 9, 16) - "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 501, Line 9, Col 5, Line 9, Col 16, + "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'.") [] let ``Valid Comma In Rec Ctor``() = - CompilerAssert.Pass - """ + FSharp """ type Person = { Name : string * bool * bool } let Age = 22 let City = "London" let x = { Name = "Isaac", Age = 21, City = "London" } - """ + """ |> typecheck |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs index 13a6f6b0dcc4..d1511da554ca 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Don't Suggest`` = [] let ``Dont Suggest Completely Wrong Stuff``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let _ = Path.GetFullPath "images" - """ - FSharpErrorSeverity.Error - 39 - (2, 9, 2, 13) - ("The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 9, Line 2, Col 13, + "The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math") [] let ``Dont Suggest When Things Are Open``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ module N = let name = "hallo" @@ -30,19 +27,18 @@ type T = static member myMember = 1 let x = N. - """ - [| - FSharpErrorSeverity.Error, 599, (8, 10, 8, 11), "Missing qualification after '.'" - FSharpErrorSeverity.Error, 222, (2, 1, 3, 1), "Files in libraries or multiple-file applications must begin with a namespace or module declaration. When using a module declaration at the start of a file the '=' sign is not allowed. If this is a top-level module, consider removing the = to resolve this error." - |] + """ + |> parse + |> shouldFail + |> withDiagnostics [ + (Error 599, Line 8, Col 10, Line 8, Col 11, "Missing qualification after '.'") + (Error 222, Line 2, Col 1, Line 3, Col 1, "Files in libraries or multiple-file applications must begin with a namespace or module declaration. When using a module declaration at the start of a file the '=' sign is not allowed. If this is a top-level module, consider removing the = to resolve this error.")] [] let ``Dont Suggest Intentionally Unused Variables``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let hober xy _xyz = xyz - """ - FSharpErrorSeverity.Error - 39 - (2, 21, 2, 24) - "The value or constructor 'xyz' is not defined." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 21, Line 2, Col 24, "The value or constructor 'xyz' is not defined.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs index 54d5c41a68c7..8c412854488c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs @@ -1,48 +1,43 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices - +open FSharp.Test.Utilities.Compiler module ``Else branch has wrong type`` = [] let ``Else branch is int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let y = if test > 10 then "test" else 123 - """ - FSharpErrorSeverity.Error - 1 - (5, 10, 5, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 10, Line 5, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a function that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x = test let y = if test > 10 then "test" else f 10 - """ - FSharpErrorSeverity.Error - 1 - (6, 10, 6, 14) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 6, Col 10, Line 6, Col 14, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a sequence of expressions that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let f x = x + 4 let y = @@ -51,17 +46,16 @@ let y = else "" |> ignore (f 5) - """ - FSharpErrorSeverity.Error - 1 - (9, 10, 9, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 9, Col 10, Line 9, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a longer sequence of expressions that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let f x = x + 4 let y = @@ -72,33 +66,31 @@ let y = let z = f 4 let a = 3 * z (f a) - """ - FSharpErrorSeverity.Error - 1 - (11, 10, 11, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 11, Col 10, Line 11, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch context doesn't propagate into function application``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x : string = x let y = if test > 10 then "test" else f 123 - """ - FSharpErrorSeverity.Error - 1 - (7, 11, 7, 14) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 11, Line 7, Col 14, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch context doesn't propagate into function application even if not last expr``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x = printfn "%s" x let y = @@ -106,16 +98,15 @@ let y = else f 123 "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 11, 7, 14) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 11, Line 7, Col 14, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch context doesn't propagate into for loop``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let list = [1..10] let y = @@ -125,16 +116,15 @@ let y = printfn "%s" x "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 14, 7, 22) - "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 14, Line 7, Col 22, + "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ") [] let ``Else branch context doesn't propagate to lines before last line``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let list = [1..10] let y = @@ -143,35 +133,39 @@ let y = printfn "%s" 1 "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 22, 7, 23) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 22, Line 7, Col 23, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch should not have wrong context type``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 let y : bool = if x = 2 then "A" else "B" - """ - [| FSharpErrorSeverity.Error, 1, (4, 19, 4, 22), "The 'if' expression needs to have type 'bool' to satisfy context type requirements. It currently has type 'string'." - FSharpErrorSeverity.Error, 1, (5, 10, 5, 13), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 4, Col 19, Line 4, Col 22, "The 'if' expression needs to have type 'bool' to satisfy context type requirements. It currently has type 'string'.") + (Error 1, Line 5, Col 10, Line 5, Col 13, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.")] [] let ``Else branch has wrong type in nested if``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 if x = 1 then true else if x = 2 then "A" else "B" - """ - [| FSharpErrorSeverity.Error, 1, (5, 19, 5, 22), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." - FSharpErrorSeverity.Error, 1, (6, 10, 6, 13), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." - FSharpErrorSeverity.Warning, 20, (3, 1, 6, 13), "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 3, Col 1, Line 6, Col 13, "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 5, Col 19, Line 5, Col 22, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.") + (Error 1, Line 6, Col 10, Line 6, Col 13, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index 720f18a06da0..4862927ba564 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit open FSharp.Test.Utilities +open FSharp.Test.Utilities.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.AbstractIL.Internal @@ -25,51 +26,41 @@ module ``Numeric Literals`` = [] [] let ``Invalid Numeric Literals`` literal = - CompilerAssert.TypeCheckSingleError - ("let x = " + literal) - FSharpErrorSeverity.Error - 1156 - (1, 9, 1, 9 + (String.length literal)) - "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)." + FSharp ("let x = " + literal) + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1156, Line 1, Col 9, Line 1, Col (9 + (String.length literal)), + "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger).") [] let ``3_(dot)1415F is invalid numeric literal``() = - CompilerAssert.TypeCheckWithErrors - """ -let x = 3_.1415F - """ - [| - FSharpErrorSeverity.Error, 1156, (2, 9, 2, 11), "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)."; - FSharpErrorSeverity.Error, 599, (2, 11, 2, 12),"Missing qualification after '.'" - |] + FSharp "let x = 3_.1415F" + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1156, Line 1, Col 9, Line 1, Col 11, "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger).";) + (Error 599, Line 1, Col 11, Line 1, Col 12,"Missing qualification after '.'")] [] let ``_52 is invalid numeric literal``() = - CompilerAssert.TypeCheckSingleError - """ -let x = _52 - """ - FSharpErrorSeverity.Error - 39 - (2, 9, 2, 12) - "The value or constructor '_52' is not defined." + FSharp "let x = _52" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 1, Col 9, Line 1, Col 12, "The value or constructor '_52' is not defined.") [] let ``1N is invalid numeric literal``() = - CompilerAssert.TypeCheckSingleError - """ -let x = 1N - """ - FSharpErrorSeverity.Error - 0784 - (2, 9, 2, 11) - "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope" + FSharp "let x = 1N" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 0784, Line 1, Col 9, Line 1, Col 11, + "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope") [] let ``1N is invalid numeric literal in FSI``() = if Utils.runningOnMono then () - else + else CompilerAssert.RunScriptWithOptions [| "--langversion:preview"; "--test:ErrorRanges" |] """ let x = 1N @@ -79,10 +70,10 @@ let x = 1N "Operation could not be completed due to earlier error" ] + // Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents [] [] [] let ``Valid Numeric Literals`` literal = - // Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents - - CompilerAssert.Pass ("let x = " + literal) \ No newline at end of file + FSharp ("let x = " + literal) + |> typecheck |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs index 9ab09f8a9ea6..07a40b5c9a0e 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs @@ -1,50 +1,46 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Else branch is missing`` = [] let ``Fail if else branch is missing``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = if x > 10 then "test" - """ - FSharpErrorSeverity.Error - 1 - (4, 19, 4, 25) - "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 19, Line 4, Col 25, + "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'.") [] let ``Fail on type error in condition``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = - if x > 10 then + if x > 10 then if x <> "test" then printfn "test" () - """ - FSharpErrorSeverity.Error - 1 - (5, 14, 5, 20) - "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 14, Line 5, Col 20, + "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ") [] let ``Fail if else branch is missing in nesting``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = if x > 10 then ("test") - """ - FSharpErrorSeverity.Error - 1 - (4, 20, 4, 26) - "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 20, Line 4, Col 26, + "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs index 802bcfd67506..f91d8b3d6832 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs @@ -1,23 +1,21 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Missing Expression`` = - + [] let ``Missing Expression after let``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let sum = 0 for x in 0 .. 10 do let sum = sum + x - """ - FSharpErrorSeverity.Error - 588 - (4,5,4,8) - "The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 588, Line 4, Col 5, Line 4, Col 8, + "The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs index 5c9647fb0706..932fde27aa09 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs @@ -1,21 +1,17 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Module Abbreviations`` = [] let ``Public Module Abbreviation``() = - CompilerAssert.TypeCheckSingleError - """ -module public L1 = List - """ - FSharpErrorSeverity.Error - 536 - (2, 1, 2, 7) - "The 'Public' accessibility attribute is not allowed on module abbreviation. Module abbreviations are always private." + FSharp "module public L1 = List" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 536, Line 1, Col 1, Line 1, Col 7, + "The 'Public' accessibility attribute is not allowed on module abbreviation. Module abbreviations are always private.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs index c48a5c9113b5..016bbdcadce9 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module NameResolutionTests = [] let FieldNotInRecord () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type A = { Hello:string; World:string } type B = { Size:int; Height:int } type C = { Wheels:int } @@ -20,16 +18,15 @@ type E = { Unknown:string } type F = { Wallis:int; Size:int; Height:int; } let r:F = { Size=3; Height=4; Wall=1 } - """ - FSharpErrorSeverity.Error - 1129 - (9, 31, 9, 35) - ("The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1129, Line 9, Col 31, Line 9, Col 35, + ("The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis")) [] let RecordFieldProposal () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type A = { Hello:string; World:string } type B = { Size:int; Height:int } type C = { Wheels:int } @@ -38,8 +35,8 @@ type E = { Unknown:string } type F = { Wallis:int; Size:int; Height:int; } let r = { Size=3; Height=4; Wall=1 } - """ - FSharpErrorSeverity.Error - 39 - (9, 29, 9, 33) - ("The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 29, Line 9, Col 33, + ("The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis")) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs index bf26f8a2102a..abdc7b92ca11 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs @@ -1,87 +1,69 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module Suggestions = [] let ``Field Suggestion`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person = { Name : string; } let x = { Person.Names = "Isaac" } - """ - FSharpErrorSeverity.Error - 39 - (4, 18, 4, 23) - ("The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 4, Col 18, Line 4, Col 23, + ("The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name")) [] let ``Suggest Array Module Functions`` () = - CompilerAssert.TypeCheckSingleError - """ -let f = - Array.blt - """ - FSharpErrorSeverity.Error - 39 - (3, 11, 3, 14) - ("The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit") - + FSharp "let f = Array.blt" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 1, Col 15, Line 1, Col 18, + ("The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit")) [] let ``Suggest Async Module`` () = - CompilerAssert.TypeCheckSingleError - """ -let f = - Asnc.Sleep 1000 - """ - FSharpErrorSeverity.Error - 39 - (3, 5, 3, 9) - ("The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd") - + FSharp "let f = Asnc.Sleep 1000" + |> typecheck + |> shouldFail + |> withSingleDiagnostic( Error 39, Line 1, Col 9, Line 1, Col 13, + ("The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd")) [] let ``Suggest Attribute`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyClass<'Bar>() = abstract M<'T> : 'T -> 'T abstract M2<'T> : 'T -> 'Bar - """ - FSharpErrorSeverity.Error - 39 - (2, 3, 2, 15) - ("The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 3, Line 2, Col 15, + ("The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute")) [] let ``Suggest Double Backtick Identifiers`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module N = let ``longer name`` = "hallo" let x = N.``longe name`` - """ - FSharpErrorSeverity.Error - 39 - (5, 11, 5, 25) - ("The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 5, Col 11, Line 5, Col 25, + ("The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name")) [] let ``Suggest Double Backtick Unions`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module N = type MyUnion = | ``My Case1`` @@ -90,46 +72,41 @@ module N = open N let x = N.MyUnion.``My Case2`` - """ - FSharpErrorSeverity.Error - 39 - (9, 19, 9,31) - ("The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 19, Line 9,Col 31, + ("The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2")) [] let ``Suggest Fields In Constructor`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass() = member val MyProperty = "" with get, set member val MyProperty2 = "" with get, set member val ABigProperty = "" with get, set let c = MyClass(Property = "") - """ - FSharpErrorSeverity.Error - 495 - (7, 17, 7, 25) - ("The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 495, Line 7, Col 17, Line 7, Col 25, + ("The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty")) [] let ``Suggest Generic Type`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type T = System.Collections.Generic.Dictionary - """ - FSharpErrorSeverity.Error - 39 - (2, 48, 2, 53) - ("The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 48, Line 2, Col 53, + ("The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int")) [] let ``Suggest Methods`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Test2 = type D() = @@ -138,61 +115,53 @@ module Test2 = member x.Method1() = 10 D.Method2() - """ - FSharpErrorSeverity.Error - 39 - (9, 7, 9, 14) - ("The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 7, Line 9, Col 14, + ("The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1")) [] let ``Suggest Modules`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Collections = let f () = printfn "%s" "Hello" open Collectons - """ - FSharpErrorSeverity.Error - 39 - (6, 6, 6, 16) - ("The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 6, Line 6, Col 16, + ("The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections")) [] let ``Suggest Namespaces`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ open System.Collectons - """ - FSharpErrorSeverity.Error - 39 - (2, 13, 2, 23) - "The namespace 'Collectons' is not defined." - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 13, Line 2, Col 23, + "The namespace 'Collectons' is not defined.") [] let ``Suggest Record Labels`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyRecord = { Hello: int; World: bool} let r = { Hello = 2 ; World = true} let x = r.ello - """ - FSharpErrorSeverity.Error - 39 - (6, 11, 6, 15) - ("The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 11, Line 6, Col 15, + ("The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello")) [] let ``Suggest Record Type for RequireQualifiedAccess Records`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyRecord = { Field1: string @@ -200,17 +169,15 @@ type MyRecord = { } let r = { Field1 = "hallo"; Field2 = 1 } - """ - FSharpErrorSeverity.Error - 39 - (8, 11, 8, 17) - ("The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 8, Col 11, Line 8, Col 17, + ("The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1")) [] let ``Suggest To Use Indexer`` () = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let d = [1,1] |> dict let y = d[1] @@ -218,90 +185,82 @@ let z = d[|1|] let f() = d let a = (f())[1] - """ - [| - FSharpErrorSeverity.Error, 3217, (3, 9, 3, 10), "This value is not a function and cannot be applied. Did you intend to access the indexer via d.[index] instead?" - FSharpErrorSeverity.Error, 3, (5, 9, 5, 10), "This value is not a function and cannot be applied." - FSharpErrorSeverity.Error, 3217, (8, 10, 8, 13), "This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3217, Line 3, Col 9, Line 3, Col 10, "This value is not a function and cannot be applied. Did you intend to access the indexer via d.[index] instead?") + (Error 3, Line 5, Col 9, Line 5, Col 10, "This value is not a function and cannot be applied.") + (Error 3217, Line 8, Col 10, Line 8, Col 13, "This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?")] [] let ``Suggest Type Parameters`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyClass<'Bar>() = abstract M<'T> : 'T -> 'T abstract M2<'T> : 'T -> 'Bar abstract M3<'T> : 'T -> 'B - """ - FSharpErrorSeverity.Error - 39 - (6, 28, 6, 30) - "The type parameter 'B is not defined." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 28, Line 6, Col 30, + "The type parameter 'B is not defined.") [] let ``Suggest Types in Module`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x : System.Collections.Generic.Lst = ResizeArray() - """ - FSharpErrorSeverity.Error - 39 - (2, 36, 2, 39) - ("The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1") + """ |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 36, Line 2, Col 39, + ("The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1")) [] let ``Suggest Types in Namespace`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = System.DateTie.MaxValue - """ - FSharpErrorSeverity.Error - 39 - (2, 16, 2, 23) - ("The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 16, Line 2, Col 23, + ("The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data")) [] let ``Suggest Union Cases`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyUnion = | ASimpleCase | AnotherCase of int let u = MyUnion.AntherCase - """ - FSharpErrorSeverity.Error - 39 - (6, 17, 6, 27) - ("The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 17, Line 6, Col 27, + ("The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase")) [] let ``Suggest Union Type for RequireQualifiedAccess Unions`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyUnion = | MyCase1 | MyCase2 of string let x : MyUnion = MyCase1 - """ - FSharpErrorSeverity.Error - 39 - (7, 19, 7, 26) - ("The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 7, Col 19, Line 7, Col 26, + ("The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1")) [] let ``Suggest Unions in PatternMatch`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyUnion = | Case1 @@ -313,8 +272,8 @@ let x = match y with | MyUnion.Cas1 -> 1 | _ -> 2 - """ - FSharpErrorSeverity.Error - 39 - (11, 15, 11, 19) - ("The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 11, Col 15, Line 11, Col 19, + ("The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2")) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs index 817e0a588c61..8d2d86d1d7ca 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs @@ -1,81 +1,75 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Type Mismatch`` = [] let ``return Instead Of return!``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let rec foo() = async { return foo() } - """ - FSharpErrorSeverity.Error - 1 - (2, 32, 2, 37) - "Type mismatch. Expecting a\n ''a' \nbut given a\n 'Async<'a>' \nThe types ''a' and 'Async<'a>' cannot be unified. Consider using 'return!' instead of 'return'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 2, Col 32, Line 2, Col 37, + "Type mismatch. Expecting a\n ''a' \nbut given a\n 'Async<'a>' \nThe types ''a' and 'Async<'a>' cannot be unified. Consider using 'return!' instead of 'return'.") [] let ``yield Instead Of yield!``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Foo() = member this.Yield(x) = [x] let rec f () = Foo() { yield f ()} - """ - FSharpErrorSeverity.Error - 1 - (5, 30, 5, 34) - "Type mismatch. Expecting a\n ''a' \nbut given a\n ''a list' \nThe types ''a' and ''a list' cannot be unified. Consider using 'yield!' instead of 'yield'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 30, Line 5, Col 34, + "Type mismatch. Expecting a\n ''a' \nbut given a\n ''a list' \nThe types ''a' and ''a list' cannot be unified. Consider using 'yield!' instead of 'yield'.") [] let ``Ref Cell Instead Of Not``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = true if !x then printfn "hello" - """ - FSharpErrorSeverity.Error - 1 - (3, 5, 3, 6) - ("This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 3, Col 5, Line 3, Col 6, + ("This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.")) [] let ``Ref Cell Instead Of Not 2``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = true let y = !x - """ - FSharpErrorSeverity.Error - 1 - (3, 10, 3, 11) - ("This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 3, Col 10, Line 3, Col 11, + ("This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.")) [] let ``Guard Has Wrong Type``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 match x with | 1 when "s" -> true | _ -> false - """ - [| - FSharpErrorSeverity.Error, 1, (4, 10, 4, 13), "A pattern match guard must be of type 'bool', but this 'when' expression is of type 'string'." - FSharpErrorSeverity.Warning, 20, (3, 1, 5, 13), "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 3, Col 1, Line 5, Col 13, "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 4, Col 10, Line 4, Col 13, "A pattern match guard must be of type 'bool', but this 'when' expression is of type 'string'.")] [] let ``Runtime Type Test In Pattern``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() @@ -84,16 +78,16 @@ let c = match orig with | :? IDictionary -> "yes" | _ -> "no" - """ - [| - FSharpErrorSeverity.Warning, 67, (8, 5, 8, 28), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 193, (8, 5, 8, 28), "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 8, Col 5, Line 8, Col 28, "This type test or downcast will always hold") + (Error 193, Line 8, Col 5, Line 8, Col 28, "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n")] [] let ``Runtime Type Test In Pattern 2``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() @@ -102,16 +96,16 @@ let c = match orig with | :? IDictionary as y -> "yes" + y.ToString() | _ -> "no" - """ - [| - FSharpErrorSeverity.Warning, 67, (8, 5, 8, 28), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 193, (8, 5, 8, 28), "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 8, Col 5, Line 8, Col 28, "This type test or downcast will always hold") + (Error 193, Line 8, Col 5, Line 8, Col 28, "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n")] [] let ``Override Errors``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Base() = abstract member Member: int * string -> string default x.Member (i, s) = s @@ -127,9 +121,10 @@ type Derived2() = type Derived3() = inherit Base() override x.Member (s : string, i : int) = sprintf "Hello %s" s - """ - [| - FSharpErrorSeverity.Error, 856, (8, 16, 8, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string" - FSharpErrorSeverity.Error, 856, (12, 16, 12, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string" - FSharpErrorSeverity.Error, 1, (16, 24, 16, 34), "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 856, Line 8, Col 16, Line 8, Col 22, "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string") + (Error 856, Line 12, Col 16, Line 12, Col 22, "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string") + (Error 1, Line 16, Col 24, Line 16, Col 34, "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs index 11ec30ab19ae..2b244e121505 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Unit generic abstract Type`` = [] - let ``Unit can not be used as return type of abstract method paramete on return type``() = - CompilerAssert.TypeCheckSingleError - """ + let ``Unit can not be used as return type of abstract method paramete on return type``() = + FSharp """ type EDF<'S> = abstract member Apply : int -> 'S type SomeEDF () = interface EDF with - member this.Apply d = + member this.Apply d = // [ERROR] The member 'Apply' does not have the correct type to override the corresponding abstract method. () - """ - FSharpErrorSeverity.Error - 17 - (6, 21, 6, 26) - "The member 'Apply : int -> unit' is specialized with 'unit' but 'unit' can't be used as return type of an abstract method parameterized on return type." - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 17, Line 6, Col 21, Line 6, Col 26, + "The member 'Apply : int -> unit' is specialized with 'unit' but 'unit' can't be used as return type of an abstract method parameterized on return type.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs index 79e32f9e3e06..61fcaadf12d5 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs @@ -1,51 +1,49 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Upcast and Downcast`` = [] let ``Downcast Instead Of Upcast``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() :> IDictionary let c = orig :> Dictionary - """ - FSharpErrorSeverity.Error - 193 - (5, 9, 5, 36) - "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 193, Line 5, Col 9, Line 5, Col 36, + "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n") [] let ``Upcast Instead Of Downcast``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() let c = orig :?> IDictionary - """ - [| - FSharpErrorSeverity.Warning, 67, (5, 9, 5, 38), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 3198, (5, 9, 5, 38), "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using the :> (upcast) operator instead of the :?> (downcast) operator." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 5, Col 9, Line 5, Col 38, "This type test or downcast will always hold") + (Error 3198, Line 5, Col 9, Line 5, Col 38, "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using the :> (upcast) operator instead of the :?> (downcast) operator.")] [] let ``Upcast Function Instead Of Downcast``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() let c : IDictionary = downcast orig - """ - [| - FSharpErrorSeverity.Warning, 67, (5, 32, 5, 45), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 3198, (5, 32, 5, 45), "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using 'upcast' instead of 'downcast'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 5, Col 32, Line 5, Col 45, "This type test or downcast will always hold") + (Error 3198, Line 5, Col 32, Line 5, Col 45, "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using 'upcast' instead of 'downcast'.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs index 565e423407b2..28487c97aa69 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs @@ -1,62 +1,57 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Warn Expression`` = [] let ``Warn If Expression Result Unused``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ 1 + 2 printfn "%d" 3 - """ - FSharpErrorSeverity.Warning - 20 - (2, 1, 2, 6) - "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 2, Col 1, Line 2, Col 6, + "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn If Possible Assignment``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = "hello" let changeX() = x = 20 y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 11) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 11, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'.") [] let ``Warn If Possible Assignment To Mutable``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let mutable x = 10 let y = "hello" let changeX() = x = 20 y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 11) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 11, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'.") [] let ``Warn If Possible dotnet Property Setter``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System let z = System.Timers.Timer() @@ -65,16 +60,16 @@ let y = "hello" let changeProperty() = z.Enabled = true y = "test" - """ - [| - FSharpErrorSeverity.Warning, 760, (4, 9, 4, 30), "It is recommended that objects supporting the IDisposable interface are created using the syntax 'new Type(args)', rather than 'Type(args)' or 'Type' as a function value representing the constructor, to indicate that resources may be owned by the generated value" - FSharpErrorSeverity.Warning, 20, (8, 5, 8, 21), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 760, Line 4, Col 9, Line 4, Col 30, "It is recommended that objects supporting the IDisposable interface are created using the syntax 'new Type(args)', rather than 'Type(args)' or 'Type' as a function value representing the constructor, to indicate that resources may be owned by the generated value") + (Warning 20, Line 8, Col 5, Line 8, Col 21, "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression'.")] [] let ``Don't Warn If Property Without Setter``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass(property1 : int) = member val Property2 = "" with get @@ -84,33 +79,30 @@ let y = "hello" let changeProperty() = x.Property2 = "22" y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (9, 5, 9, 23) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 9, Col 5, Line 9, Col 23, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") [] let ``Warn If Implicitly Discarded``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = 20 let changeX() = y * x = 20 y = 30 - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 15) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 15, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") [] let ``Warn If Discarded In List``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ let div _ _ = 1 let subView _ _ = [1; 2] @@ -120,19 +112,16 @@ let view model dispatch = yield! subView model dispatch div [] [] ] - """ - [| - FSharpErrorSeverity.Warning, - 3221, - (9, 8, 9, 17), - "This expression returns a value of type 'int' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3221, Line 9, Col 8, Line 9, Col 17, + "This expression returns a value of type 'int' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.") [] let ``Warn If Discarded In List 2``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ // stupid things to make the sample compile let div _ _ = 1 let subView _ _ = [1; 2] @@ -147,19 +136,16 @@ let view model dispatch = | _ -> subView model dispatch ] ] - """ - [| - FSharpErrorSeverity.Warning, - 3222, - (13, 19, 13, 41), - "This expression returns a value of type 'int list' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3222, Line 13, Col 19, Line 13, Col 41, + "This expression returns a value of type 'int list' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.") [] let ``Warn If Discarded In List 3``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ // stupid things to make the sample compile let div _ _ = 1 let subView _ _ = true @@ -174,33 +160,30 @@ let view model dispatch = | _ -> subView model dispatch ] ] - """ - [| - FSharpErrorSeverity.Warning, - 20, - (13, 19, 13, 41), - "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 13, Col 19, Line 13, Col 41, + "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn Only On Last Expression``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let mutable x = 0 while x < 1 do printfn "unneeded" x <- x + 1 true - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 9) - "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 9, + "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn If Possible Property Setter``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass(property1 : int) = member val Property1 = property1 member val Property2 = "" with get, set @@ -211,17 +194,16 @@ let y = "hello" let changeProperty() = x.Property2 = "20" y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (10, 5, 10, 23) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 10, Col 5, Line 10, Col 23, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression'.") [] let ``Dont warn external function as unused``() = - CompilerAssert.Pass - """ + FSharp """ open System open System.Runtime.InteropServices @@ -240,4 +222,6 @@ let main _argv = let _ = Test.ExtractIconEx("", 0, [| |], [| |], 0u) 0 - """ + """ + |> typecheck + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs index d7cd6068103d..89e3707c243f 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs @@ -1,20 +1,21 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Wrong syntax in for loop`` = [] let ``Equals instead of in``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ module X for i = 0 .. 100 do () - """ - [|FSharpErrorSeverity.Error, 3215, (3, 7, 3, 8), "Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?" |] + """ + |> parse + |> shouldFail + |> withSingleDiagnostic (Error 3215, Line 3, Col 7, Line 3, Col 8, + "Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?") diff --git a/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs b/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs index 929eab5c8093..0c8b76a9da0b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Interop.ComponentTests +namespace FSharp.Compiler.ComponentTests.Interop open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler module ``C# <-> F# basic interop`` = diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs index 16ee721cd0ca..03712d32e1a2 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Language.CodeQuatation +namespace FSharp.Compiler.ComponentTests.Language open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs index 9f9d949667cc..32219920d931 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs @@ -1,11 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Language.ComponentTests +namespace FSharp.Compiler.ComponentTests.Language open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler -open FSharp.Compiler.SourceCodeServices module ``Test Compiler Directives`` = diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 88c137194ced..b31da1d4866e 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -197,11 +197,11 @@ module rec Compiler = let result = compileFSharpCompilation cmpl false match result with | Failure f -> - let message = sprintf "Compilation failed (expected to succeed).\n All errors:\n%A" (f.Errors @ f.Warnings) + let message = sprintf "Operation failed (expected to succeed).\n All errors:\n%A" (f.Errors @ f.Warnings) failwith message | Success s -> match s.OutputPath with - | None -> failwith "Compilation didn't produce any output!" + | None -> failwith "Operation didn't produce any output!" | Some p -> p |> MetadataReference.CreateFromFile | _ -> failwith "Conversion isn't possible" @@ -318,6 +318,31 @@ module rec Compiler = | CS cs -> compileCSharp cs | _ -> failwith "TODO" + let private parseFSharp (fsSource: FSharpCompilationSource) : TestResult = + let source = getSource fsSource.Source + let parseResults = CompilerAssert.Parse source + let failed = parseResults.ParseHadErrors + + let (errors, warnings) = parseResults.Errors |> fromFSharpErrorInfo + + let result = + { OutputPath = None + Dependencies = [] + Adjust = 0 + Warnings = errors + Errors = warnings + Output = None } + + if failed then + Failure result + else + Success result + + let parse (cUnit: CompilationUnit) : TestResult = + match cUnit with + | FS fs -> parseFSharp fs + | _ -> failwith "Parsing only supported for F#." + let private typecheckFSharpWithBaseline (options: string list) (dir: string) (file: string) : TestResult = // Since TypecheckWithErrorsAndOptionsAgainsBaseLine throws if doesn't match expected baseline, // We return a successfull TestResult if it succeeds. @@ -436,12 +461,12 @@ module rec Compiler = match result with | Success _ -> result | Failure r -> - let message = sprintf "Compilation failed (expected to succeed).\n All errors:\n%A" (r.Errors @ r.Warnings) + let message = sprintf "Operation failed (expected to succeed).\n All errors:\n%A" (r.Errors @ r.Warnings) failwith message let shouldFail (result: TestResult) : TestResult = match result with - | Success _ -> failwith "Compilation was \"Success\" (expected: \"Failure\")." + | Success _ -> failwith "Operation was succeeded (expected to fail)." | Failure _ -> result let private assertResultsCategory (what: string) (selector: Output -> ErrorInfo list) (expected: ErrorInfo list) (result: TestResult) : TestResult = diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index e74ef790b16e..4077979d91ad 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -663,10 +663,13 @@ let main argv = 0""" static member RunScript source expectedErrorMessages = CompilerAssert.RunScriptWithOptions [||] source expectedErrorMessages - static member ParseWithErrors (source: string) expectedParseErrors = + static member Parse (source: string) = let sourceFileName = "test.fs" let parsingOptions = { FSharpParsingOptions.Default with SourceFiles = [| sourceFileName |] } - let parseResults = checker.ParseFile(sourceFileName, SourceText.ofString source, parsingOptions) |> Async.RunSynchronously + checker.ParseFile(sourceFileName, SourceText.ofString source, parsingOptions) |> Async.RunSynchronously + + static member ParseWithErrors (source: string) expectedParseErrors = + let parseResults = CompilerAssert.Parse source Assert.True(parseResults.ParseHadErrors) From bc6ea7495036334544d8e1e9440f9cd45b43d375 Mon Sep 17 00:00:00 2001 From: dotnet bot Date: Fri, 31 Jul 2020 10:33:23 -0700 Subject: [PATCH 2/9] Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) (#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii --- .../ConstraintSolver/MemberConstraints.fs | 2 +- .../ConstraintSolver/PrimitiveConstraints.fs | 2 +- .../AccessOfTypeAbbreviationTests.fs | 63 ++-- .../ErrorMessages/AssignmentErrorTests.fs | 19 +- .../ErrorMessages/ClassesTests.fs | 110 ++++--- .../ErrorMessages/ConfusingTypeName.fs | 5 +- .../ErrorMessages/ConstructorTests.fs | 94 +++--- .../ErrorMessages/DontSuggestTests.fs | 44 ++- .../ElseBranchHasWrongTypeTests.fs | 136 ++++----- .../InvalidNumericLiteralTests.fs | 61 ++-- .../ErrorMessages/MissingElseBranch.fs | 46 ++- .../ErrorMessages/MissingExpressionTests.fs | 20 +- .../ErrorMessages/ModuleAbbreviationTests.fs | 18 +- .../ErrorMessages/NameResolutionTests.fs | 31 +- .../ErrorMessages/SuggestionsTests.fs | 283 ++++++++---------- .../ErrorMessages/TypeMismatchTests.fs | 115 ++++--- .../ErrorMessages/UnitGenericAbstactType.fs | 23 +- .../ErrorMessages/UpcastDowncastTests.fs | 46 ++- .../ErrorMessages/WarnExpressionTests.fs | 168 +++++------ .../ErrorMessages/WrongSyntaxInForLoop.fs | 15 +- .../Interop/SimpleInteropTests.fs | 3 +- .../Language/CodeQuotationTests.fs | 2 +- .../Language/CompilerDirectiveTests.fs | 4 +- tests/FSharp.Test.Utilities/Compiler.fs | 33 +- tests/FSharp.Test.Utilities/CompilerAssert.fs | 7 +- 25 files changed, 630 insertions(+), 720 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs index f14c2495c37d..77ae35463fc4 100644 --- a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ConstraintSolver.ComponentTests +namespace FSharp.Compiler.ComponentTests.ConstraintSolver open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs index 873864edaffc..a22d61db60cb 100644 --- a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ConstraintSolver.ComponentTests +namespace FSharp.Compiler.ComponentTests.ConstraintSolver open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs index 416c62d63f63..df9acf7efca6 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs @@ -1,75 +1,74 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities +open FSharp.Test.Utilities.Compiler open FSharp.Compiler.SourceCodeServices module ``Access Of Type Abbreviation`` = + let warning44Message = "This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors." + [] let ``Private type produces warning when trying to export``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type private Hidden = Hidden of unit type Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 8, 4, 16) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 8, Line 4, Col 16, warning44Message) [] let ``Internal type passes when abbrev is internal``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type internal Hidden = Hidden of unit type internal Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed [] let ``Internal type produces warning when trying to export``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type internal Hidden = Hidden of unit type Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 8, 4, 16) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 8, Line 4, Col 16, warning44Message) [] let ``Private type produces warning when abbrev is internal``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type private Hidden = Hidden of unit type internal Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 17, 4, 25) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 17, Line 4, Col 25, warning44Message) [] let ``Private type passes when abbrev is private``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type private Hidden = Hidden of unit type private Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed [] let ``Default access type passes when abbrev is default``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type Hidden = Hidden of unit type Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs index f2f598d9dba7..dd986cf50097 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs @@ -1,22 +1,19 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices - +open FSharp.Test.Utilities.Compiler module ``Errors assigning to mutable objects`` = [] let ``Assign to immutable error``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 x <- 20 - """ - FSharpErrorSeverity.Error - 27 - (3, 1, 3, 8) - "This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 27, Line 3, Col 1, Line 3, Col 8, + "This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs index a51e92ed944b..e1941a3d7eb2 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Classes`` = [] let ``Tuple In Abstract Method``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IInterface = abstract Function : (int32 * int32) -> unit @@ -19,47 +17,44 @@ let x = { new IInterface with member this.Function (i, j) = () } - """ - [| - FSharpErrorSeverity.Error, 768, (7, 16, 7, 36), "The member 'Function' does not accept the correct number of arguments. 1 argument(s) are expected, but 2 were given. The required signature is 'member IInterface.Function : (int32 * int32) -> unit'.\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface." - FSharpErrorSeverity.Error, 17, (7, 21, 7, 29), "The member 'Function : 'a * 'b -> unit' does not have the correct type to override the corresponding abstract method. The required signature is 'Function : (int32 * int32) -> unit'." - FSharpErrorSeverity.Error, 783, (6, 9, 6, 19), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 768, Line 7, Col 16, Line 7, Col 36, "The member 'Function' does not accept the correct number of arguments. 1 argument(s) are expected, but 2 were given. The required signature is 'member IInterface.Function : (int32 * int32) -> unit'.\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface.") + (Error 17, Line 7, Col 21, Line 7, Col 29, "The member 'Function : 'a * 'b -> unit' does not have the correct type to override the corresponding abstract method. The required signature is 'Function : (int32 * int32) -> unit'.") + (Error 783, Line 6, Col 9, Line 6, Col 19, "At least one override did not correctly implement its corresponding abstract member")] [] let ``Wrong Arity``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyType() = static member MyMember(arg1, arg2:int ) = () static member MyMember(arg1, arg2:byte) = () MyType.MyMember("", 0, 0) - """ - FSharpErrorSeverity.Error - 503 - (7, 1, 7, 26) - "A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 503, Line 7, Col 1, Line 7, Col 26, + "A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments.") [] let ``Method Is Not Static``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Class1() = member this.X() = "F#" let x = Class1.X() - """ - FSharpErrorSeverity.Error - 3214 - (5, 9, 5, 17) - "Method or object constructor 'X' is not static" + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 3214, Line 5, Col 9, Line 5, Col 17, "Method or object constructor 'X' is not static") [] let ``Matching Method With Same Name Is Not Abstract``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Foo(x : int) = member v.MyX() = x @@ -67,17 +62,17 @@ let foo = { new Foo(3) with member v.MyX() = 4 } - """ - [| - FSharpErrorSeverity.Error, 767, (8, 16, 8, 23), "The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement." - FSharpErrorSeverity.Error, 17, (8, 18, 8, 21), "The member 'MyX : unit -> int' does not have the correct type to override any given virtual method" - FSharpErrorSeverity.Error, 783, (6, 11, 6, 14), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 767, Line 8, Col 16, Line 8, Col 23, "The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement.") + (Error 17, Line 8, Col 18, Line 8, Col 21, "The member 'MyX : unit -> int' does not have the correct type to override any given virtual method") + (Error 783, Line 6, Col 11, Line 6, Col 14, "At least one override did not correctly implement its corresponding abstract member")] [] let ``No Matching Abstract Method With Same Name``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IInterface = abstract MyFunction : int32 * int32 -> unit abstract SomeOtherFunction : int32 * int32 -> unit @@ -86,18 +81,18 @@ let x = { new IInterface with member this.Function (i, j) = () } - """ - [| - FSharpErrorSeverity.Error, 767, (8, 14, 8, 34), "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:" + System.Environment.NewLine + " MyFunction" - FSharpErrorSeverity.Error, 17, (8, 19, 8, 27), "The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method" - FSharpErrorSeverity.Error, 366, (7, 3, 9, 4), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." - FSharpErrorSeverity.Error, 783, (7, 9, 7, 19), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 767, Line 8, Col 14, Line 8, Col 34, "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:" + System.Environment.NewLine + " MyFunction") + (Error 17, Line 8, Col 19, Line 8, Col 27, "The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method") + (Error 366, Line 7, Col 3, Line 9, Col 4, "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.") + (Error 783, Line 7, Col 9, Line 7, Col 19, "At least one override did not correctly implement its corresponding abstract member")] [] let ``Member Has Multiple Possible Dispatch Slots``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IOverload = abstract member Bar : int -> int abstract member Bar : double -> int @@ -105,23 +100,24 @@ type IOverload = type Overload = interface IOverload with override __.Bar _ = 1 - """ - [| - FSharpErrorSeverity.Error, 366, (7, 15, 7, 24), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IOverload.Bar : double -> int'" + System.Environment.NewLine + "\t'abstract member IOverload.Bar : int -> int'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." - FSharpErrorSeverity.Error, 3213, (8, 21, 8, 24), "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:" + System.Environment.NewLine + " Bar : double -> int" + System.Environment.NewLine + " Bar : int -> int." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 366, Line 7, Col 15, Line 7, Col 24, "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IOverload.Bar : double -> int'" + System.Environment.NewLine + "\t'abstract member IOverload.Bar : int -> int'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.") + (Error 3213, Line 8, Col 21, Line 8, Col 24, "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:" + System.Environment.NewLine + " Bar : double -> int" + System.Environment.NewLine + " Bar : int -> int.")] [] let ``Do Cannot Have Visibility Declarations``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ type X() = do () private do () static member Y() = 1 - """ - [| - FSharpErrorSeverity.Error, 531, (4, 5, 4, 12), "Accessibility modifiers should come immediately prior to the identifier naming a construct" - FSharpErrorSeverity.Error, 512, (4, 13, 4, 18), "Accessibility modifiers are not permitted on 'do' bindings, but 'Private' was given." - FSharpErrorSeverity.Error, 222, (2, 1, 3, 1), "Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration." - |] + """ + |> parse + |> shouldFail + |> withDiagnostics [ + (Error 531, Line 4, Col 5, Line 4, Col 12, "Accessibility modifiers should come immediately prior to the identifier naming a construct") + (Error 512, Line 4, Col 13, Line 4, Col 18, "Accessibility modifiers are not permitted on 'do' bindings, but 'Private' was given.") + (Error 222, Line 2, Col 1, Line 3, Col 1, "Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs index 3c7e569007d0..9e3e75b606b5 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs @@ -1,12 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler -open FSharp.Test.Utilities.Utilities -open FSharp.Compiler.SourceCodeServices module ``Confusing Type Name`` = diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs index c9636e711a52..1806defe4e45 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs @@ -1,42 +1,40 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Constructor`` = [] let ``Invalid Record``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Record = {field1:int; field2:int} let doSomething (xs) = List.map (fun {field1=x} -> x) xs doSomething {Record.field1=0; field2=0} - """ - [| - FSharpErrorSeverity.Error, 1, (4, 13, 4, 40), "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' " - FSharpErrorSeverity.Warning, 20, (4, 1, 4, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 4, Col 1, Line 4, Col 40, "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 4, Col 13, Line 4, Col 40, "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' ")] [] let ``Comma In Rec Ctor``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Person = { Name : string; Age : int; City : string } let x = { Name = "Isaac", Age = 21, City = "London" } - """ - [| - FSharpErrorSeverity.Error, 1, (3, 18, 3, 52), "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' " + System.Environment.NewLine + "A ';' is used to separate field values in records. Consider replacing ',' with ';'." - FSharpErrorSeverity.Error, 764, (3, 9, 3, 54), "No assignment given for field 'Age' of type 'Test.Person'" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 3, Col 18, Line 3, Col 52, "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' " + System.Environment.NewLine + "A ';' is used to separate field values in records. Consider replacing ',' with ';'.") + (Error 764, Line 3, Col 9, Line 3, Col 54, "No assignment given for field 'Age' of type 'Test.Person'")] [] let ``Missing Comma In Ctor``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set @@ -44,18 +42,18 @@ type Person() = let p = Person(Name = "Fred" Age = 18) - """ - [| - FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan" - FSharpErrorSeverity.Warning, 20, (7, 12, 7, 25), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." - FSharpErrorSeverity.Error, 39, (8, 12, 8, 15), "The value or constructor 'Age' is not defined." - FSharpErrorSeverity.Error, 501, (7, 5, 8, 21), "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',')." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 7, Col 12, Line 7, Col 25, "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") + (Error 39, Line 7, Col 12, Line 7, Col 16, "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan") + (Error 39, Line 8, Col 12, Line 8, Col 15, "The value or constructor 'Age' is not defined.") + (Error 501, Line 7, Col 5, Line 8, Col 21, "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',').")] [] let ``Missing Ctor Value``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person(x:int) = member val Name = "" with get,set member val Age = x with get,set @@ -63,32 +61,29 @@ type Person(x:int) = let p = Person(Name = "Fred", Age = 18) - """ - FSharpErrorSeverity.Error - 496 - (7, 5, 8, 21) - "The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 496, Line 7, Col 5, Line 8, Col 21, "The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'.") [] let ``Extra Argument In Ctor``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set let p = Person(1) - """ - FSharpErrorSeverity.Error - 501 - (7, 5, 7, 14) - "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 501, Line 7, Col 5, Line 7, Col 14, + "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'.") [] let ``Extra Argument In Ctor2``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set @@ -97,18 +92,17 @@ let b = 1 let p = Person(1=b) - """ - FSharpErrorSeverity.Error - 501 - (9, 5, 9, 16) - "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 501, Line 9, Col 5, Line 9, Col 16, + "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'.") [] let ``Valid Comma In Rec Ctor``() = - CompilerAssert.Pass - """ + FSharp """ type Person = { Name : string * bool * bool } let Age = 22 let City = "London" let x = { Name = "Isaac", Age = 21, City = "London" } - """ + """ |> typecheck |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs index 13a6f6b0dcc4..d1511da554ca 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Don't Suggest`` = [] let ``Dont Suggest Completely Wrong Stuff``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let _ = Path.GetFullPath "images" - """ - FSharpErrorSeverity.Error - 39 - (2, 9, 2, 13) - ("The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 9, Line 2, Col 13, + "The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math") [] let ``Dont Suggest When Things Are Open``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ module N = let name = "hallo" @@ -30,19 +27,18 @@ type T = static member myMember = 1 let x = N. - """ - [| - FSharpErrorSeverity.Error, 599, (8, 10, 8, 11), "Missing qualification after '.'" - FSharpErrorSeverity.Error, 222, (2, 1, 3, 1), "Files in libraries or multiple-file applications must begin with a namespace or module declaration. When using a module declaration at the start of a file the '=' sign is not allowed. If this is a top-level module, consider removing the = to resolve this error." - |] + """ + |> parse + |> shouldFail + |> withDiagnostics [ + (Error 599, Line 8, Col 10, Line 8, Col 11, "Missing qualification after '.'") + (Error 222, Line 2, Col 1, Line 3, Col 1, "Files in libraries or multiple-file applications must begin with a namespace or module declaration. When using a module declaration at the start of a file the '=' sign is not allowed. If this is a top-level module, consider removing the = to resolve this error.")] [] let ``Dont Suggest Intentionally Unused Variables``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let hober xy _xyz = xyz - """ - FSharpErrorSeverity.Error - 39 - (2, 21, 2, 24) - "The value or constructor 'xyz' is not defined." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 21, Line 2, Col 24, "The value or constructor 'xyz' is not defined.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs index 54d5c41a68c7..8c412854488c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs @@ -1,48 +1,43 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices - +open FSharp.Test.Utilities.Compiler module ``Else branch has wrong type`` = [] let ``Else branch is int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let y = if test > 10 then "test" else 123 - """ - FSharpErrorSeverity.Error - 1 - (5, 10, 5, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 10, Line 5, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a function that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x = test let y = if test > 10 then "test" else f 10 - """ - FSharpErrorSeverity.Error - 1 - (6, 10, 6, 14) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 6, Col 10, Line 6, Col 14, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a sequence of expressions that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let f x = x + 4 let y = @@ -51,17 +46,16 @@ let y = else "" |> ignore (f 5) - """ - FSharpErrorSeverity.Error - 1 - (9, 10, 9, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 9, Col 10, Line 9, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a longer sequence of expressions that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let f x = x + 4 let y = @@ -72,33 +66,31 @@ let y = let z = f 4 let a = 3 * z (f a) - """ - FSharpErrorSeverity.Error - 1 - (11, 10, 11, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 11, Col 10, Line 11, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch context doesn't propagate into function application``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x : string = x let y = if test > 10 then "test" else f 123 - """ - FSharpErrorSeverity.Error - 1 - (7, 11, 7, 14) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 11, Line 7, Col 14, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch context doesn't propagate into function application even if not last expr``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x = printfn "%s" x let y = @@ -106,16 +98,15 @@ let y = else f 123 "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 11, 7, 14) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 11, Line 7, Col 14, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch context doesn't propagate into for loop``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let list = [1..10] let y = @@ -125,16 +116,15 @@ let y = printfn "%s" x "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 14, 7, 22) - "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 14, Line 7, Col 22, + "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ") [] let ``Else branch context doesn't propagate to lines before last line``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let list = [1..10] let y = @@ -143,35 +133,39 @@ let y = printfn "%s" 1 "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 22, 7, 23) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 22, Line 7, Col 23, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch should not have wrong context type``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 let y : bool = if x = 2 then "A" else "B" - """ - [| FSharpErrorSeverity.Error, 1, (4, 19, 4, 22), "The 'if' expression needs to have type 'bool' to satisfy context type requirements. It currently has type 'string'." - FSharpErrorSeverity.Error, 1, (5, 10, 5, 13), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 4, Col 19, Line 4, Col 22, "The 'if' expression needs to have type 'bool' to satisfy context type requirements. It currently has type 'string'.") + (Error 1, Line 5, Col 10, Line 5, Col 13, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.")] [] let ``Else branch has wrong type in nested if``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 if x = 1 then true else if x = 2 then "A" else "B" - """ - [| FSharpErrorSeverity.Error, 1, (5, 19, 5, 22), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." - FSharpErrorSeverity.Error, 1, (6, 10, 6, 13), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." - FSharpErrorSeverity.Warning, 20, (3, 1, 6, 13), "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 3, Col 1, Line 6, Col 13, "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 5, Col 19, Line 5, Col 22, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.") + (Error 1, Line 6, Col 10, Line 6, Col 13, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index 720f18a06da0..4862927ba564 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit open FSharp.Test.Utilities +open FSharp.Test.Utilities.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.AbstractIL.Internal @@ -25,51 +26,41 @@ module ``Numeric Literals`` = [] [] let ``Invalid Numeric Literals`` literal = - CompilerAssert.TypeCheckSingleError - ("let x = " + literal) - FSharpErrorSeverity.Error - 1156 - (1, 9, 1, 9 + (String.length literal)) - "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)." + FSharp ("let x = " + literal) + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1156, Line 1, Col 9, Line 1, Col (9 + (String.length literal)), + "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger).") [] let ``3_(dot)1415F is invalid numeric literal``() = - CompilerAssert.TypeCheckWithErrors - """ -let x = 3_.1415F - """ - [| - FSharpErrorSeverity.Error, 1156, (2, 9, 2, 11), "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)."; - FSharpErrorSeverity.Error, 599, (2, 11, 2, 12),"Missing qualification after '.'" - |] + FSharp "let x = 3_.1415F" + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1156, Line 1, Col 9, Line 1, Col 11, "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger).";) + (Error 599, Line 1, Col 11, Line 1, Col 12,"Missing qualification after '.'")] [] let ``_52 is invalid numeric literal``() = - CompilerAssert.TypeCheckSingleError - """ -let x = _52 - """ - FSharpErrorSeverity.Error - 39 - (2, 9, 2, 12) - "The value or constructor '_52' is not defined." + FSharp "let x = _52" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 1, Col 9, Line 1, Col 12, "The value or constructor '_52' is not defined.") [] let ``1N is invalid numeric literal``() = - CompilerAssert.TypeCheckSingleError - """ -let x = 1N - """ - FSharpErrorSeverity.Error - 0784 - (2, 9, 2, 11) - "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope" + FSharp "let x = 1N" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 0784, Line 1, Col 9, Line 1, Col 11, + "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope") [] let ``1N is invalid numeric literal in FSI``() = if Utils.runningOnMono then () - else + else CompilerAssert.RunScriptWithOptions [| "--langversion:preview"; "--test:ErrorRanges" |] """ let x = 1N @@ -79,10 +70,10 @@ let x = 1N "Operation could not be completed due to earlier error" ] + // Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents [] [] [] let ``Valid Numeric Literals`` literal = - // Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents - - CompilerAssert.Pass ("let x = " + literal) \ No newline at end of file + FSharp ("let x = " + literal) + |> typecheck |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs index 9ab09f8a9ea6..07a40b5c9a0e 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs @@ -1,50 +1,46 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Else branch is missing`` = [] let ``Fail if else branch is missing``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = if x > 10 then "test" - """ - FSharpErrorSeverity.Error - 1 - (4, 19, 4, 25) - "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 19, Line 4, Col 25, + "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'.") [] let ``Fail on type error in condition``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = - if x > 10 then + if x > 10 then if x <> "test" then printfn "test" () - """ - FSharpErrorSeverity.Error - 1 - (5, 14, 5, 20) - "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 14, Line 5, Col 20, + "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ") [] let ``Fail if else branch is missing in nesting``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = if x > 10 then ("test") - """ - FSharpErrorSeverity.Error - 1 - (4, 20, 4, 26) - "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 20, Line 4, Col 26, + "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs index 802bcfd67506..f91d8b3d6832 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs @@ -1,23 +1,21 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Missing Expression`` = - + [] let ``Missing Expression after let``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let sum = 0 for x in 0 .. 10 do let sum = sum + x - """ - FSharpErrorSeverity.Error - 588 - (4,5,4,8) - "The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 588, Line 4, Col 5, Line 4, Col 8, + "The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs index 5c9647fb0706..932fde27aa09 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs @@ -1,21 +1,17 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Module Abbreviations`` = [] let ``Public Module Abbreviation``() = - CompilerAssert.TypeCheckSingleError - """ -module public L1 = List - """ - FSharpErrorSeverity.Error - 536 - (2, 1, 2, 7) - "The 'Public' accessibility attribute is not allowed on module abbreviation. Module abbreviations are always private." + FSharp "module public L1 = List" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 536, Line 1, Col 1, Line 1, Col 7, + "The 'Public' accessibility attribute is not allowed on module abbreviation. Module abbreviations are always private.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs index c48a5c9113b5..016bbdcadce9 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module NameResolutionTests = [] let FieldNotInRecord () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type A = { Hello:string; World:string } type B = { Size:int; Height:int } type C = { Wheels:int } @@ -20,16 +18,15 @@ type E = { Unknown:string } type F = { Wallis:int; Size:int; Height:int; } let r:F = { Size=3; Height=4; Wall=1 } - """ - FSharpErrorSeverity.Error - 1129 - (9, 31, 9, 35) - ("The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1129, Line 9, Col 31, Line 9, Col 35, + ("The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis")) [] let RecordFieldProposal () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type A = { Hello:string; World:string } type B = { Size:int; Height:int } type C = { Wheels:int } @@ -38,8 +35,8 @@ type E = { Unknown:string } type F = { Wallis:int; Size:int; Height:int; } let r = { Size=3; Height=4; Wall=1 } - """ - FSharpErrorSeverity.Error - 39 - (9, 29, 9, 33) - ("The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 29, Line 9, Col 33, + ("The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis")) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs index bf26f8a2102a..abdc7b92ca11 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs @@ -1,87 +1,69 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module Suggestions = [] let ``Field Suggestion`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person = { Name : string; } let x = { Person.Names = "Isaac" } - """ - FSharpErrorSeverity.Error - 39 - (4, 18, 4, 23) - ("The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 4, Col 18, Line 4, Col 23, + ("The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name")) [] let ``Suggest Array Module Functions`` () = - CompilerAssert.TypeCheckSingleError - """ -let f = - Array.blt - """ - FSharpErrorSeverity.Error - 39 - (3, 11, 3, 14) - ("The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit") - + FSharp "let f = Array.blt" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 1, Col 15, Line 1, Col 18, + ("The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit")) [] let ``Suggest Async Module`` () = - CompilerAssert.TypeCheckSingleError - """ -let f = - Asnc.Sleep 1000 - """ - FSharpErrorSeverity.Error - 39 - (3, 5, 3, 9) - ("The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd") - + FSharp "let f = Asnc.Sleep 1000" + |> typecheck + |> shouldFail + |> withSingleDiagnostic( Error 39, Line 1, Col 9, Line 1, Col 13, + ("The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd")) [] let ``Suggest Attribute`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyClass<'Bar>() = abstract M<'T> : 'T -> 'T abstract M2<'T> : 'T -> 'Bar - """ - FSharpErrorSeverity.Error - 39 - (2, 3, 2, 15) - ("The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 3, Line 2, Col 15, + ("The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute")) [] let ``Suggest Double Backtick Identifiers`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module N = let ``longer name`` = "hallo" let x = N.``longe name`` - """ - FSharpErrorSeverity.Error - 39 - (5, 11, 5, 25) - ("The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 5, Col 11, Line 5, Col 25, + ("The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name")) [] let ``Suggest Double Backtick Unions`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module N = type MyUnion = | ``My Case1`` @@ -90,46 +72,41 @@ module N = open N let x = N.MyUnion.``My Case2`` - """ - FSharpErrorSeverity.Error - 39 - (9, 19, 9,31) - ("The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 19, Line 9,Col 31, + ("The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2")) [] let ``Suggest Fields In Constructor`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass() = member val MyProperty = "" with get, set member val MyProperty2 = "" with get, set member val ABigProperty = "" with get, set let c = MyClass(Property = "") - """ - FSharpErrorSeverity.Error - 495 - (7, 17, 7, 25) - ("The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 495, Line 7, Col 17, Line 7, Col 25, + ("The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty")) [] let ``Suggest Generic Type`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type T = System.Collections.Generic.Dictionary - """ - FSharpErrorSeverity.Error - 39 - (2, 48, 2, 53) - ("The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 48, Line 2, Col 53, + ("The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int")) [] let ``Suggest Methods`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Test2 = type D() = @@ -138,61 +115,53 @@ module Test2 = member x.Method1() = 10 D.Method2() - """ - FSharpErrorSeverity.Error - 39 - (9, 7, 9, 14) - ("The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 7, Line 9, Col 14, + ("The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1")) [] let ``Suggest Modules`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Collections = let f () = printfn "%s" "Hello" open Collectons - """ - FSharpErrorSeverity.Error - 39 - (6, 6, 6, 16) - ("The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 6, Line 6, Col 16, + ("The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections")) [] let ``Suggest Namespaces`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ open System.Collectons - """ - FSharpErrorSeverity.Error - 39 - (2, 13, 2, 23) - "The namespace 'Collectons' is not defined." - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 13, Line 2, Col 23, + "The namespace 'Collectons' is not defined.") [] let ``Suggest Record Labels`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyRecord = { Hello: int; World: bool} let r = { Hello = 2 ; World = true} let x = r.ello - """ - FSharpErrorSeverity.Error - 39 - (6, 11, 6, 15) - ("The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 11, Line 6, Col 15, + ("The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello")) [] let ``Suggest Record Type for RequireQualifiedAccess Records`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyRecord = { Field1: string @@ -200,17 +169,15 @@ type MyRecord = { } let r = { Field1 = "hallo"; Field2 = 1 } - """ - FSharpErrorSeverity.Error - 39 - (8, 11, 8, 17) - ("The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 8, Col 11, Line 8, Col 17, + ("The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1")) [] let ``Suggest To Use Indexer`` () = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let d = [1,1] |> dict let y = d[1] @@ -218,90 +185,82 @@ let z = d[|1|] let f() = d let a = (f())[1] - """ - [| - FSharpErrorSeverity.Error, 3217, (3, 9, 3, 10), "This value is not a function and cannot be applied. Did you intend to access the indexer via d.[index] instead?" - FSharpErrorSeverity.Error, 3, (5, 9, 5, 10), "This value is not a function and cannot be applied." - FSharpErrorSeverity.Error, 3217, (8, 10, 8, 13), "This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3217, Line 3, Col 9, Line 3, Col 10, "This value is not a function and cannot be applied. Did you intend to access the indexer via d.[index] instead?") + (Error 3, Line 5, Col 9, Line 5, Col 10, "This value is not a function and cannot be applied.") + (Error 3217, Line 8, Col 10, Line 8, Col 13, "This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?")] [] let ``Suggest Type Parameters`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyClass<'Bar>() = abstract M<'T> : 'T -> 'T abstract M2<'T> : 'T -> 'Bar abstract M3<'T> : 'T -> 'B - """ - FSharpErrorSeverity.Error - 39 - (6, 28, 6, 30) - "The type parameter 'B is not defined." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 28, Line 6, Col 30, + "The type parameter 'B is not defined.") [] let ``Suggest Types in Module`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x : System.Collections.Generic.Lst = ResizeArray() - """ - FSharpErrorSeverity.Error - 39 - (2, 36, 2, 39) - ("The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1") + """ |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 36, Line 2, Col 39, + ("The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1")) [] let ``Suggest Types in Namespace`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = System.DateTie.MaxValue - """ - FSharpErrorSeverity.Error - 39 - (2, 16, 2, 23) - ("The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 16, Line 2, Col 23, + ("The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data")) [] let ``Suggest Union Cases`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyUnion = | ASimpleCase | AnotherCase of int let u = MyUnion.AntherCase - """ - FSharpErrorSeverity.Error - 39 - (6, 17, 6, 27) - ("The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 17, Line 6, Col 27, + ("The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase")) [] let ``Suggest Union Type for RequireQualifiedAccess Unions`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyUnion = | MyCase1 | MyCase2 of string let x : MyUnion = MyCase1 - """ - FSharpErrorSeverity.Error - 39 - (7, 19, 7, 26) - ("The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 7, Col 19, Line 7, Col 26, + ("The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1")) [] let ``Suggest Unions in PatternMatch`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyUnion = | Case1 @@ -313,8 +272,8 @@ let x = match y with | MyUnion.Cas1 -> 1 | _ -> 2 - """ - FSharpErrorSeverity.Error - 39 - (11, 15, 11, 19) - ("The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 11, Col 15, Line 11, Col 19, + ("The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2")) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs index 817e0a588c61..8d2d86d1d7ca 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs @@ -1,81 +1,75 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Type Mismatch`` = [] let ``return Instead Of return!``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let rec foo() = async { return foo() } - """ - FSharpErrorSeverity.Error - 1 - (2, 32, 2, 37) - "Type mismatch. Expecting a\n ''a' \nbut given a\n 'Async<'a>' \nThe types ''a' and 'Async<'a>' cannot be unified. Consider using 'return!' instead of 'return'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 2, Col 32, Line 2, Col 37, + "Type mismatch. Expecting a\n ''a' \nbut given a\n 'Async<'a>' \nThe types ''a' and 'Async<'a>' cannot be unified. Consider using 'return!' instead of 'return'.") [] let ``yield Instead Of yield!``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Foo() = member this.Yield(x) = [x] let rec f () = Foo() { yield f ()} - """ - FSharpErrorSeverity.Error - 1 - (5, 30, 5, 34) - "Type mismatch. Expecting a\n ''a' \nbut given a\n ''a list' \nThe types ''a' and ''a list' cannot be unified. Consider using 'yield!' instead of 'yield'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 30, Line 5, Col 34, + "Type mismatch. Expecting a\n ''a' \nbut given a\n ''a list' \nThe types ''a' and ''a list' cannot be unified. Consider using 'yield!' instead of 'yield'.") [] let ``Ref Cell Instead Of Not``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = true if !x then printfn "hello" - """ - FSharpErrorSeverity.Error - 1 - (3, 5, 3, 6) - ("This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 3, Col 5, Line 3, Col 6, + ("This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.")) [] let ``Ref Cell Instead Of Not 2``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = true let y = !x - """ - FSharpErrorSeverity.Error - 1 - (3, 10, 3, 11) - ("This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 3, Col 10, Line 3, Col 11, + ("This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.")) [] let ``Guard Has Wrong Type``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 match x with | 1 when "s" -> true | _ -> false - """ - [| - FSharpErrorSeverity.Error, 1, (4, 10, 4, 13), "A pattern match guard must be of type 'bool', but this 'when' expression is of type 'string'." - FSharpErrorSeverity.Warning, 20, (3, 1, 5, 13), "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 3, Col 1, Line 5, Col 13, "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 4, Col 10, Line 4, Col 13, "A pattern match guard must be of type 'bool', but this 'when' expression is of type 'string'.")] [] let ``Runtime Type Test In Pattern``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() @@ -84,16 +78,16 @@ let c = match orig with | :? IDictionary -> "yes" | _ -> "no" - """ - [| - FSharpErrorSeverity.Warning, 67, (8, 5, 8, 28), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 193, (8, 5, 8, 28), "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 8, Col 5, Line 8, Col 28, "This type test or downcast will always hold") + (Error 193, Line 8, Col 5, Line 8, Col 28, "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n")] [] let ``Runtime Type Test In Pattern 2``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() @@ -102,16 +96,16 @@ let c = match orig with | :? IDictionary as y -> "yes" + y.ToString() | _ -> "no" - """ - [| - FSharpErrorSeverity.Warning, 67, (8, 5, 8, 28), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 193, (8, 5, 8, 28), "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 8, Col 5, Line 8, Col 28, "This type test or downcast will always hold") + (Error 193, Line 8, Col 5, Line 8, Col 28, "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n")] [] let ``Override Errors``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Base() = abstract member Member: int * string -> string default x.Member (i, s) = s @@ -127,9 +121,10 @@ type Derived2() = type Derived3() = inherit Base() override x.Member (s : string, i : int) = sprintf "Hello %s" s - """ - [| - FSharpErrorSeverity.Error, 856, (8, 16, 8, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string" - FSharpErrorSeverity.Error, 856, (12, 16, 12, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string" - FSharpErrorSeverity.Error, 1, (16, 24, 16, 34), "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 856, Line 8, Col 16, Line 8, Col 22, "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string") + (Error 856, Line 12, Col 16, Line 12, Col 22, "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string") + (Error 1, Line 16, Col 24, Line 16, Col 34, "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs index 11ec30ab19ae..2b244e121505 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Unit generic abstract Type`` = [] - let ``Unit can not be used as return type of abstract method paramete on return type``() = - CompilerAssert.TypeCheckSingleError - """ + let ``Unit can not be used as return type of abstract method paramete on return type``() = + FSharp """ type EDF<'S> = abstract member Apply : int -> 'S type SomeEDF () = interface EDF with - member this.Apply d = + member this.Apply d = // [ERROR] The member 'Apply' does not have the correct type to override the corresponding abstract method. () - """ - FSharpErrorSeverity.Error - 17 - (6, 21, 6, 26) - "The member 'Apply : int -> unit' is specialized with 'unit' but 'unit' can't be used as return type of an abstract method parameterized on return type." - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 17, Line 6, Col 21, Line 6, Col 26, + "The member 'Apply : int -> unit' is specialized with 'unit' but 'unit' can't be used as return type of an abstract method parameterized on return type.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs index 79e32f9e3e06..61fcaadf12d5 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs @@ -1,51 +1,49 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Upcast and Downcast`` = [] let ``Downcast Instead Of Upcast``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() :> IDictionary let c = orig :> Dictionary - """ - FSharpErrorSeverity.Error - 193 - (5, 9, 5, 36) - "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 193, Line 5, Col 9, Line 5, Col 36, + "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n") [] let ``Upcast Instead Of Downcast``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() let c = orig :?> IDictionary - """ - [| - FSharpErrorSeverity.Warning, 67, (5, 9, 5, 38), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 3198, (5, 9, 5, 38), "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using the :> (upcast) operator instead of the :?> (downcast) operator." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 5, Col 9, Line 5, Col 38, "This type test or downcast will always hold") + (Error 3198, Line 5, Col 9, Line 5, Col 38, "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using the :> (upcast) operator instead of the :?> (downcast) operator.")] [] let ``Upcast Function Instead Of Downcast``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() let c : IDictionary = downcast orig - """ - [| - FSharpErrorSeverity.Warning, 67, (5, 32, 5, 45), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 3198, (5, 32, 5, 45), "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using 'upcast' instead of 'downcast'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 5, Col 32, Line 5, Col 45, "This type test or downcast will always hold") + (Error 3198, Line 5, Col 32, Line 5, Col 45, "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using 'upcast' instead of 'downcast'.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs index 565e423407b2..28487c97aa69 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs @@ -1,62 +1,57 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Warn Expression`` = [] let ``Warn If Expression Result Unused``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ 1 + 2 printfn "%d" 3 - """ - FSharpErrorSeverity.Warning - 20 - (2, 1, 2, 6) - "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 2, Col 1, Line 2, Col 6, + "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn If Possible Assignment``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = "hello" let changeX() = x = 20 y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 11) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 11, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'.") [] let ``Warn If Possible Assignment To Mutable``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let mutable x = 10 let y = "hello" let changeX() = x = 20 y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 11) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 11, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'.") [] let ``Warn If Possible dotnet Property Setter``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System let z = System.Timers.Timer() @@ -65,16 +60,16 @@ let y = "hello" let changeProperty() = z.Enabled = true y = "test" - """ - [| - FSharpErrorSeverity.Warning, 760, (4, 9, 4, 30), "It is recommended that objects supporting the IDisposable interface are created using the syntax 'new Type(args)', rather than 'Type(args)' or 'Type' as a function value representing the constructor, to indicate that resources may be owned by the generated value" - FSharpErrorSeverity.Warning, 20, (8, 5, 8, 21), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 760, Line 4, Col 9, Line 4, Col 30, "It is recommended that objects supporting the IDisposable interface are created using the syntax 'new Type(args)', rather than 'Type(args)' or 'Type' as a function value representing the constructor, to indicate that resources may be owned by the generated value") + (Warning 20, Line 8, Col 5, Line 8, Col 21, "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression'.")] [] let ``Don't Warn If Property Without Setter``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass(property1 : int) = member val Property2 = "" with get @@ -84,33 +79,30 @@ let y = "hello" let changeProperty() = x.Property2 = "22" y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (9, 5, 9, 23) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 9, Col 5, Line 9, Col 23, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") [] let ``Warn If Implicitly Discarded``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = 20 let changeX() = y * x = 20 y = 30 - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 15) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 15, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") [] let ``Warn If Discarded In List``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ let div _ _ = 1 let subView _ _ = [1; 2] @@ -120,19 +112,16 @@ let view model dispatch = yield! subView model dispatch div [] [] ] - """ - [| - FSharpErrorSeverity.Warning, - 3221, - (9, 8, 9, 17), - "This expression returns a value of type 'int' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3221, Line 9, Col 8, Line 9, Col 17, + "This expression returns a value of type 'int' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.") [] let ``Warn If Discarded In List 2``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ // stupid things to make the sample compile let div _ _ = 1 let subView _ _ = [1; 2] @@ -147,19 +136,16 @@ let view model dispatch = | _ -> subView model dispatch ] ] - """ - [| - FSharpErrorSeverity.Warning, - 3222, - (13, 19, 13, 41), - "This expression returns a value of type 'int list' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3222, Line 13, Col 19, Line 13, Col 41, + "This expression returns a value of type 'int list' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.") [] let ``Warn If Discarded In List 3``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ // stupid things to make the sample compile let div _ _ = 1 let subView _ _ = true @@ -174,33 +160,30 @@ let view model dispatch = | _ -> subView model dispatch ] ] - """ - [| - FSharpErrorSeverity.Warning, - 20, - (13, 19, 13, 41), - "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 13, Col 19, Line 13, Col 41, + "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn Only On Last Expression``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let mutable x = 0 while x < 1 do printfn "unneeded" x <- x + 1 true - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 9) - "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 9, + "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn If Possible Property Setter``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass(property1 : int) = member val Property1 = property1 member val Property2 = "" with get, set @@ -211,17 +194,16 @@ let y = "hello" let changeProperty() = x.Property2 = "20" y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (10, 5, 10, 23) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 10, Col 5, Line 10, Col 23, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression'.") [] let ``Dont warn external function as unused``() = - CompilerAssert.Pass - """ + FSharp """ open System open System.Runtime.InteropServices @@ -240,4 +222,6 @@ let main _argv = let _ = Test.ExtractIconEx("", 0, [| |], [| |], 0u) 0 - """ + """ + |> typecheck + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs index d7cd6068103d..89e3707c243f 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs @@ -1,20 +1,21 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Wrong syntax in for loop`` = [] let ``Equals instead of in``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ module X for i = 0 .. 100 do () - """ - [|FSharpErrorSeverity.Error, 3215, (3, 7, 3, 8), "Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?" |] + """ + |> parse + |> shouldFail + |> withSingleDiagnostic (Error 3215, Line 3, Col 7, Line 3, Col 8, + "Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?") diff --git a/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs b/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs index 929eab5c8093..0c8b76a9da0b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Interop.ComponentTests +namespace FSharp.Compiler.ComponentTests.Interop open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler module ``C# <-> F# basic interop`` = diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs index 16ee721cd0ca..03712d32e1a2 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Language.CodeQuatation +namespace FSharp.Compiler.ComponentTests.Language open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs index 9f9d949667cc..32219920d931 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs @@ -1,11 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Language.ComponentTests +namespace FSharp.Compiler.ComponentTests.Language open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler -open FSharp.Compiler.SourceCodeServices module ``Test Compiler Directives`` = diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 88c137194ced..b31da1d4866e 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -197,11 +197,11 @@ module rec Compiler = let result = compileFSharpCompilation cmpl false match result with | Failure f -> - let message = sprintf "Compilation failed (expected to succeed).\n All errors:\n%A" (f.Errors @ f.Warnings) + let message = sprintf "Operation failed (expected to succeed).\n All errors:\n%A" (f.Errors @ f.Warnings) failwith message | Success s -> match s.OutputPath with - | None -> failwith "Compilation didn't produce any output!" + | None -> failwith "Operation didn't produce any output!" | Some p -> p |> MetadataReference.CreateFromFile | _ -> failwith "Conversion isn't possible" @@ -318,6 +318,31 @@ module rec Compiler = | CS cs -> compileCSharp cs | _ -> failwith "TODO" + let private parseFSharp (fsSource: FSharpCompilationSource) : TestResult = + let source = getSource fsSource.Source + let parseResults = CompilerAssert.Parse source + let failed = parseResults.ParseHadErrors + + let (errors, warnings) = parseResults.Errors |> fromFSharpErrorInfo + + let result = + { OutputPath = None + Dependencies = [] + Adjust = 0 + Warnings = errors + Errors = warnings + Output = None } + + if failed then + Failure result + else + Success result + + let parse (cUnit: CompilationUnit) : TestResult = + match cUnit with + | FS fs -> parseFSharp fs + | _ -> failwith "Parsing only supported for F#." + let private typecheckFSharpWithBaseline (options: string list) (dir: string) (file: string) : TestResult = // Since TypecheckWithErrorsAndOptionsAgainsBaseLine throws if doesn't match expected baseline, // We return a successfull TestResult if it succeeds. @@ -436,12 +461,12 @@ module rec Compiler = match result with | Success _ -> result | Failure r -> - let message = sprintf "Compilation failed (expected to succeed).\n All errors:\n%A" (r.Errors @ r.Warnings) + let message = sprintf "Operation failed (expected to succeed).\n All errors:\n%A" (r.Errors @ r.Warnings) failwith message let shouldFail (result: TestResult) : TestResult = match result with - | Success _ -> failwith "Compilation was \"Success\" (expected: \"Failure\")." + | Success _ -> failwith "Operation was succeeded (expected to fail)." | Failure _ -> result let private assertResultsCategory (what: string) (selector: Output -> ErrorInfo list) (expected: ErrorInfo list) (result: TestResult) : TestResult = diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 5ec91cf5ba9e..4958d7385930 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -665,10 +665,13 @@ let main argv = 0""" static member RunScript source expectedErrorMessages = CompilerAssert.RunScriptWithOptions [||] source expectedErrorMessages - static member ParseWithErrors (source: string) expectedParseErrors = + static member Parse (source: string) = let sourceFileName = "test.fs" let parsingOptions = { FSharpParsingOptions.Default with SourceFiles = [| sourceFileName |] } - let parseResults = checker.ParseFile(sourceFileName, SourceText.ofString source, parsingOptions) |> Async.RunSynchronously + checker.ParseFile(sourceFileName, SourceText.ofString source, parsingOptions) |> Async.RunSynchronously + + static member ParseWithErrors (source: string) expectedParseErrors = + let parseResults = CompilerAssert.Parse source Assert.True(parseResults.ParseHadErrors) From be9280e65fe97e10d85a71bddb6ac9125e80dba7 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 31 Jul 2020 23:01:05 +0100 Subject: [PATCH 3/9] improve doc comments for FSharp.Core (#9844) * improve xml doc spacing * improve cref nodes * fix broken xml doc * fix more crefs * doc improvements --- src/absil/ilnativeres.fs | 6 + src/fsharp/FSharp.Core/Nullable.fsi | 41 ++ src/fsharp/FSharp.Core/array.fsi | 611 ++++++++++++---- src/fsharp/FSharp.Core/array2.fsi | 18 +- src/fsharp/FSharp.Core/array3.fsi | 35 + src/fsharp/FSharp.Core/async.fsi | 221 +++--- src/fsharp/FSharp.Core/collections.fsi | 3 + src/fsharp/FSharp.Core/event.fsi | 2 + src/fsharp/FSharp.Core/eventmodule.fsi | 16 + .../FSharp.Core/fslib-extra-pervasives.fsi | 38 +- src/fsharp/FSharp.Core/list.fsi | 266 +++++-- src/fsharp/FSharp.Core/mailbox.fsi | 35 +- src/fsharp/FSharp.Core/map.fsi | 71 +- src/fsharp/FSharp.Core/math/z.fsi | 7 + src/fsharp/FSharp.Core/nativeptr.fsi | 19 + src/fsharp/FSharp.Core/observable.fsi | 15 + src/fsharp/FSharp.Core/option.fsi | 103 +++ src/fsharp/FSharp.Core/prim-types-prelude.fsi | 54 +- src/fsharp/FSharp.Core/prim-types.fsi | 679 ++++++++++++++++-- src/fsharp/FSharp.Core/printf.fsi | 118 +-- src/fsharp/FSharp.Core/quotations.fsi | 241 +++++++ src/fsharp/FSharp.Core/reflect.fsi | 107 ++- src/fsharp/FSharp.Core/result.fsi | 6 + src/fsharp/FSharp.Core/seq.fsi | 277 +++---- src/fsharp/FSharp.Core/set.fsi | 82 ++- src/fsharp/FSharp.Core/string.fsi | 26 +- src/fsharp/fsiaux.fsi | 2 + src/fsharp/lib.fs | 12 +- src/fsharp/service/FSharpCheckerResults.fsi | 2 + src/fsharp/service/service.fsi | 5 + .../Project/ProjectNode.cs | 2 +- 31 files changed, 2484 insertions(+), 636 deletions(-) diff --git a/src/absil/ilnativeres.fs b/src/absil/ilnativeres.fs index 53321b9eef3a..96cff415130c 100644 --- a/src/absil/ilnativeres.fs +++ b/src/absil/ilnativeres.fs @@ -279,8 +279,10 @@ type VersionHelper() = /// /// Parses a version string of the form "major [ '.' minor [ '.' build [ '.' revision ] ] ]". /// + /// /// The version string to parse. /// If parsing succeeds, the parsed version. Otherwise a version that represents as much of the input as could be parsed successfully. + /// /// True when parsing succeeds completely (i.e. every character in the string was consumed), false otherwise. static member TryParse(s: string, [] version: byref) = VersionHelper.TryParse (s, false, UInt16.MaxValue, true, ref version) @@ -289,12 +291,14 @@ type VersionHelper() = /// Parses a version string of the form "major [ '.' minor [ '.' ( '*' | ( build [ '.' ( '*' | revision ) ] ) ) ] ]" /// as accepted by System.Reflection.AssemblyVersionAttribute. /// + /// /// The version string to parse. /// Indicates whether or not a wildcard is accepted as the terminal component. /// /// If parsing succeeded, the parsed version. Otherwise a version instance with all parts set to zero. /// If contains * the version build and/or revision numbers are set to . /// + /// /// True when parsing succeeds completely (i.e. every character in the string was consumed), false otherwise. static member TryParseAssemblyVersion (s: string, allowWildcard: bool, [] version: byref) = @@ -306,6 +310,7 @@ type VersionHelper() = /// Parses a version string of the form "major [ '.' minor [ '.' ( '*' | ( build [ '.' ( '*' | revision ) ] ) ) ] ]" /// as accepted by System.Reflection.AssemblyVersionAttribute. /// + /// /// The version string to parse. /// Indicates whether or not we're parsing an assembly version string. If so, wildcards are accepted and each component must be less than 65535. /// The maximum value that a version component may have. @@ -314,6 +319,7 @@ type VersionHelper() = /// If parsing succeeded, the parsed version. When is true a version with values up to the first invalid character set. Otherwise a version with all parts set to zero. /// If contains * and wildcard is allowed the version build and/or revision numbers are set to . /// + /// /// True when parsing succeeds completely (i.e. every character in the string was consumed), false otherwise. static member private TryParse(s: string, allowWildcard: bool, maxValue: uint16, allowPartialParse: bool, [] version: byref) = Debug.Assert (not allowWildcard || maxValue < UInt16.MaxValue) diff --git a/src/fsharp/FSharp.Core/Nullable.fsi b/src/fsharp/FSharp.Core/Nullable.fsi index 777aecdc7ab1..0b18896ef8cc 100644 --- a/src/fsharp/FSharp.Core/Nullable.fsi +++ b/src/fsharp/FSharp.Core/Nullable.fsi @@ -117,6 +117,7 @@ module Nullable = /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. /// The input value. + /// /// The converted byte [] val inline byte : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> byte) and default ^T : int @@ -124,7 +125,9 @@ module Nullable = /// Converts the argument to byte. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted byte [] val inline uint8 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> uint8) and default ^T : int @@ -132,7 +135,9 @@ module Nullable = /// Converts the argument to signed byte. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted sbyte [] val inline sbyte : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> sbyte) and default ^T : int @@ -140,7 +145,9 @@ module Nullable = /// Converts the argument to signed byte. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted sbyte [] val inline int8 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> int8) and default ^T : int @@ -148,7 +155,9 @@ module Nullable = /// Converts the argument to signed 16-bit integer. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int16 [] val inline int16 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> int16) and default ^T : int @@ -156,7 +165,9 @@ module Nullable = /// Converts the argument to unsigned 16-bit integer. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint16 [] val inline uint16 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> uint16) and default ^T : int @@ -164,7 +175,9 @@ module Nullable = /// Converts the argument to signed 32-bit integer. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int [] val inline int : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> int) and default ^T : int @@ -172,13 +185,17 @@ module Nullable = /// Converts the argument to an unsigned 32-bit integer. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted unsigned integer [] val inline uint: value: Nullable< ^T > -> Nullable when ^T :(static member op_Explicit: ^T -> uint) and default ^T : uint /// Converts the argument to a particular enum type. + /// /// The input value. + /// /// The converted enum type. [] val inline enum : value:Nullable< int32 > -> Nullable< ^U > when ^U : enum @@ -186,7 +203,9 @@ module Nullable = /// Converts the argument to signed 32-bit integer. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int32 [] val inline int32 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> int32) and default ^T : int @@ -194,7 +213,9 @@ module Nullable = /// Converts the argument to unsigned 32-bit integer. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint32 [] val inline uint32 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> uint32) and default ^T : int @@ -202,7 +223,9 @@ module Nullable = /// Converts the argument to signed 64-bit integer. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int64 [] val inline int64 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> int64) and default ^T : int @@ -210,7 +233,9 @@ module Nullable = /// Converts the argument to unsigned 64-bit integer. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint64 [] val inline uint64 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> uint64) and default ^T : int @@ -218,7 +243,9 @@ module Nullable = /// Converts the argument to 32-bit float. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted float32 [] val inline float32 : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> float32) and default ^T : int @@ -226,7 +253,9 @@ module Nullable = /// Converts the argument to 64-bit float. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted float [] val inline float : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> float) and default ^T : int @@ -234,7 +263,9 @@ module Nullable = /// Converts the argument to 32-bit float. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted float32 [] val inline single : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> single) and default ^T : int @@ -242,7 +273,9 @@ module Nullable = /// Converts the argument to 64-bit float. This is a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted float [] val inline double : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> double) and default ^T : int @@ -250,7 +283,9 @@ module Nullable = /// Converts the argument to signed native integer. This is a direct conversion for all /// primitive numeric types. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted nativeint [] val inline nativeint : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> nativeint) and default ^T : int @@ -258,7 +293,9 @@ module Nullable = /// Converts the argument to unsigned native integer using a direct conversion for all /// primitive numeric types. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted unativeint [] val inline unativeint : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> unativeint) and default ^T : int @@ -266,14 +303,18 @@ module Nullable = /// Converts the argument to System.Decimal using a direct conversion for all /// primitive numeric types. The operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted decimal. [] val inline decimal : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> decimal) and default ^T : int /// Converts the argument to character. Numeric inputs are converted according to the UTF-16 /// encoding for characters. The operation requires an appropriate static conversion method on the input type. + /// /// The input value. + /// /// The converted char. [] val inline char : value:Nullable< ^T > -> Nullable when ^T : (static member op_Explicit : ^T -> char) and default ^T : int diff --git a/src/fsharp/FSharp.Core/array.fsi b/src/fsharp/FSharp.Core/array.fsi index 5ede87a3c6d9..2ae5facdbca0 100644 --- a/src/fsharp/FSharp.Core/array.fsi +++ b/src/fsharp/FSharp.Core/array.fsi @@ -13,26 +13,35 @@ namespace Microsoft.FSharp.Collections module Array = /// Returns a new array that contains all pairings of elements from the first and second arrays. + /// /// The first input array. /// The second input array. - /// Thrown when either of the input arrays is null. + /// + /// Thrown when either of the input arrays is null. + /// /// The resulting array of pairs. [] val allPairs: array1:'T1[] -> array2:'T2[] -> ('T1 * 'T2)[] /// Builds a new array that contains the elements of the first array followed by the elements of the second array. + /// /// The first input array. /// The second input array. + /// /// The resulting array. - /// Thrown when either of the input arrays is null. + /// + /// Thrown when either of the input arrays is null. [] val append: array1:'T[] -> array2:'T[] -> 'T[] /// Returns the average of the elements in the array. + /// /// The input array. - /// Thrown when array is empty. + /// + /// Thrown when array is empty. + /// Thrown when the input array is null. + /// /// The average of the elements in the array. - /// Thrown when the input array is null. [] val inline average : array:^T[] -> ^T when ^T : (static member ( + ) : ^T * ^T -> ^T) @@ -41,11 +50,15 @@ namespace Microsoft.FSharp.Collections /// Returns the average of the elements generated by applying the function to each element of the array. + /// /// The function to transform the array elements before averaging. /// The input array. - /// Thrown when array is empty. + /// + /// Thrown when array is empty. + /// /// The computed average. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val inline averageBy : projection:('T -> ^U) -> array:'T[] -> ^U when ^U : (static member ( + ) : ^U * ^U -> ^U) @@ -53,22 +66,27 @@ namespace Microsoft.FSharp.Collections and ^U : (static member Zero : ^U) /// Reads a range of elements from the first array and write them into the second. + /// /// The source array. /// The starting index of the source array. /// The target array. /// The starting index of the target array. /// The number of elements to copy. - /// Thrown when either of the input arrays is null. - /// Thrown when any of sourceIndex, targetIndex or count are negative, + /// + /// Thrown when either of the input arrays is null. + /// Thrown when any of sourceIndex, targetIndex or count are negative, /// or when there aren't enough elements in source or target. [] val inline blit: source:'T[] -> sourceIndex:int -> target:'T[] -> targetIndex:int -> count:int -> unit /// For each element of the array, applies the given function. Concatenates all the results and return the combined array. + /// /// The function to create sub-arrays from the input array elements. /// The input array. + /// /// The concatenation of the sub-arrays. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val collect : mapping:('T -> 'U[]) -> array:'T[] -> 'U[] @@ -85,30 +103,39 @@ namespace Microsoft.FSharp.Collections /// arrays, 1 is returned if the first array is longer, 0 is returned if they are equal in /// length, and -1 is returned when the second array is longer. /// - /// Thrown when either of the input arrays + /// Thrown when either of the input arrays /// is null. [] val inline compareWith: comparer:('T -> 'T -> int) -> array1:'T[] -> array2:'T[] -> int /// Builds a new array that contains the elements of each of the given sequence of arrays. + /// /// The input sequence of arrays. + /// /// The concatenation of the sequence of input arrays. - /// Thrown when the input sequence is null. + /// + /// Thrown when the input sequence is null. [] val concat: arrays:seq<'T[]> -> 'T[] /// Tests if the array contains the specified element. + /// /// The value to locate in the input array. /// The input array. + /// /// True if the input array contains the specified element; false otherwise. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val inline contains: value:'T -> array:'T[] -> bool when 'T : equality /// Builds a new array that contains the elements of the given array. + /// /// The input array. + /// /// A copy of the input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val copy: array:'T[] -> 'T[] @@ -121,22 +148,28 @@ namespace Microsoft.FSharp.Collections /// /// The result array. /// - /// Thrown when the input array is null. + /// Thrown when the input array is null. [] val countBy : projection:('T -> 'Key) -> array:'T[] -> ('Key * int)[] when 'Key : equality /// Creates an array whose elements are all initially the given value. + /// /// The length of the array to create. /// The value for the elements. + /// /// The created array. - /// Thrown when count is negative. + /// + /// Thrown when count is negative. [] val create: count:int -> value:'T -> 'T[] /// Returns the first element of the array, or /// None if the array is empty. + /// /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. + /// /// The first element of the array or None. [] val tryHead: array:'T[] -> 'T option @@ -144,31 +177,39 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to successive elements, returning the first /// result where function returns Some(x) for some x. If the function /// never returns Some(x) then None is returned. + /// /// The function to transform the array elements into options. /// The input array. + /// /// The first transformed element that is Some(x). - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val tryPick: chooser:('T -> 'U option) -> array:'T[] -> 'U option /// Fills a range of elements of the array with the given value. + /// /// The target array. /// The index of the first element to set. /// The number of elements to set. /// The value to set. - /// Thrown when the input array is null. - /// Thrown when either targetIndex or count is negative. + /// + /// Thrown when the input array is null. + /// Thrown when either targetIndex or count is negative. [] val fill: target:'T[] -> targetIndex:int -> count:int -> value:'T -> unit /// Applies the given function to successive elements, returning the first /// result where function returns Some(x) for some x. If the function - /// never returns Some(x) then KeyNotFoundException is raised. + /// never returns Some(x) then is raised. + /// /// The function to generate options from the elements. /// The input array. - /// Thrown when the input array is null. - /// Thrown if every result from + /// + /// Thrown when the input array is null. + /// Thrown if every result from /// chooser is None. + /// /// The first result. [] val pick: chooser:('T -> 'U option) -> array:'T[] -> 'U @@ -176,19 +217,25 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to each element of the array. Returns /// the array comprised of the results "x" for each element where /// the function returns Some(x) + /// /// The function to generate options from the elements. /// The input array. + /// /// The array of results. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val choose: chooser:('T -> 'U option) -> array:'T[] -> 'U[] /// Divides the input array into chunks of size at most chunkSize. + /// /// The maximum size of each chunk. /// The input array. + /// /// The array divided into chunks. - /// Thrown when the input array is null. - /// Thrown when chunkSize is not positive. + /// + /// Thrown when the input array is null. + /// Thrown when chunkSize is not positive. [] val chunkBySize: chunkSize:int -> array:'T[] -> 'T[][] @@ -200,7 +247,7 @@ namespace Microsoft.FSharp.Collections /// /// The result array. /// - /// Thrown when the input array is null. + /// Thrown when the input array is null. [] val distinct: array:'T[] -> 'T[] when 'T : equality @@ -213,16 +260,19 @@ namespace Microsoft.FSharp.Collections /// /// The result array. /// - /// Thrown when the input array is null. + /// Thrown when the input array is null. [] val distinctBy: projection:('T -> 'Key) -> array:'T[] -> 'T[] when 'Key : equality /// Splits the input array into at most count chunks. + /// /// The maximum number of chunks. /// The input array. + /// /// The array split into chunks. - /// Thrown when the input array is null. - /// Thrown when count is not positive. + /// + /// Thrown when the input array is null. + /// Thrown when count is not positive. [] val splitInto: count:int -> array:'T[] -> 'T[][] @@ -238,8 +288,8 @@ namespace Microsoft.FSharp.Collections /// /// The only element of the array. /// - /// Thrown when the input array is null. - /// Thrown when the input does not have precisely one element. + /// Thrown when the input array is null. + /// Thrown when the input does not have precisely one element. [] val exactlyOne: array:'T[] -> 'T @@ -249,7 +299,7 @@ namespace Microsoft.FSharp.Collections /// /// The only element of the array or None. /// - /// Thrown when the input array is null. + /// Thrown when the input array is null. [] val tryExactlyOne: array:'T[] -> 'T option @@ -262,7 +312,7 @@ namespace Microsoft.FSharp.Collections /// /// An array that contains the distinct elements of array that do not appear in itemsToExclude. /// - /// Thrown when either itemsToExclude or array is null. + /// Thrown when either itemsToExclude or array is null. [] val except: itemsToExclude:seq<'T> -> array:'T[] -> 'T[] when 'T : equality @@ -271,10 +321,13 @@ namespace Microsoft.FSharp.Collections /// The predicate is applied to the elements of the input array. If any application /// returns true then the overall result is true and no further elements are tested. /// Otherwise, false is returned. + /// /// The function to test the input elements. /// The input array. + /// /// True if any result from predicate is true. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val exists: predicate:('T -> bool) -> array:'T[] -> bool @@ -285,66 +338,84 @@ namespace Microsoft.FSharp.Collections /// true and no further elements are tested. Otherwise, if one collections is longer /// than the other then the ArgumentException exception is raised. /// Otherwise, false is returned. + /// /// The function to test the input elements. /// The first input array. /// The second input array. + /// /// True if any result from predicate is true. - /// Thrown when either of the input arrays is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when either of the input arrays is null. + /// Thrown when the input arrays differ in length. [] val exists2: predicate:('T1 -> 'T2 -> bool) -> array1:'T1[] -> array2:'T2[] -> bool /// Returns a new collection containing only the elements of the collection /// for which the given predicate returns "true". + /// /// The function to test the input elements. /// The input array. + /// /// An array containing the elements for which the given predicate returns true. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val filter: predicate:('T -> bool) -> array:'T[] -> 'T[] /// Returns the first element for which the given function returns 'true'. - /// Raise KeyNotFoundException if no such element exists. + /// Raise if no such element exists. + /// /// The function to test the input elements. /// The input array. - /// Thrown when the input array is null. - /// Thrown if predicate + /// + /// Thrown when the input array is null. + /// Thrown if predicate /// never returns true. + /// /// The first element for which predicate returns true. [] val find: predicate:('T -> bool) -> array:'T[] -> 'T /// Returns the last element for which the given function returns 'true'. - /// Raise KeyNotFoundException if no such element exists. + /// Raise if no such element exists. + /// /// The function to test the input elements. /// The input array. - /// Thrown if predicate + /// + /// Thrown if predicate /// never returns true. - /// Thrown when the input array is null. + /// Thrown when the input array is null. + /// /// The last element for which predicate returns true. [] val findBack: predicate:('T -> bool) -> array:'T[] -> 'T /// Returns the index of the first element in the array - /// that satisfies the given predicate. Raise KeyNotFoundException if + /// that satisfies the given predicate. Raise if /// none of the elements satisfy the predicate. + /// /// The function to test the input elements. /// The input array. - /// Thrown if predicate + /// + /// Thrown if predicate /// never returns true. - /// Thrown when the input array is null. + /// Thrown when the input array is null. + /// /// The index of the first element in the array that satisfies the given predicate. [] val findIndex: predicate:('T -> bool) -> array:'T[] -> int /// Returns the index of the last element in the array - /// that satisfies the given predicate. Raise KeyNotFoundException if + /// that satisfies the given predicate. Raise if /// none of the elements satisfy the predicate. + /// /// The function to test the input elements. /// The input array. - /// Thrown if predicate + /// + /// Thrown if predicate /// never returns true. - /// Thrown when the input array is null. + /// Thrown when the input array is null. + /// /// The index of the last element in the array that satisfies the given predicate. [] val findIndexBack: predicate:('T -> bool) -> array:'T[] -> int @@ -354,10 +425,13 @@ namespace Microsoft.FSharp.Collections /// The predicate is applied to the elements of the input collection. If any application /// returns false then the overall result is false and no further elements are tested. /// Otherwise, true is returned. + /// /// The function to test the input elements. /// The input array. + /// /// True if all of the array elements satisfy the predicate. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val forall: predicate:('T -> bool) -> array:'T[] -> bool @@ -369,11 +443,14 @@ namespace Microsoft.FSharp.Collections /// false and no further elements are tested. Otherwise, if one collection is longer /// than the other then the ArgumentException exception is raised. /// Otherwise, true is returned. + /// /// The function to test the input elements. /// The first input array. /// The second input array. - /// Thrown when either of the input arrays is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when either of the input arrays is null. + /// Thrown when the input arrays differ in length. + /// /// True if all of the array elements satisfy the predicate. [] val forall2: predicate:('T1 -> 'T2 -> bool) -> array1:'T1[] -> array2:'T2[] -> bool @@ -381,22 +458,28 @@ namespace Microsoft.FSharp.Collections /// Applies a function to each element of the collection, threading an accumulator argument /// through the computation. If the input function is f and the elements are i0...iN then computes /// f (... (f s i0)...) iN + /// /// The function to update the state given the input elements. /// The initial state. /// The input array. + /// /// The final state. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val fold<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> array: 'T[] -> 'State /// Applies a function to each element of the array, starting from the end, threading an accumulator argument /// through the computation. If the input function is f and the elements are i0...iN then computes /// f i0 (...(f iN s)) + /// /// The function to update the state given the input elements. /// The input array. /// The initial state. + /// /// The state object after the folding function is applied to each element of the array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val foldBack<'T,'State> : folder:('T -> 'State -> 'State) -> array:'T[] -> state:'State -> 'State @@ -405,12 +488,15 @@ namespace Microsoft.FSharp.Collections /// through the computation. The two input /// arrays must have the same lengths, otherwise an ArgumentException is /// raised. + /// /// The function to update the state given the input elements. /// The initial state. /// The first input array. /// The second input array. - /// Thrown when either of the input arrays is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when either of the input arrays is null. + /// Thrown when the input arrays differ in length. + /// /// The final state. [] val fold2<'T1,'T2,'State> : folder:('State -> 'T1 -> 'T2 -> 'State) -> state:'State -> array1:'T1[] -> array2:'T2[] -> 'State @@ -419,22 +505,28 @@ namespace Microsoft.FSharp.Collections /// threading an accumulator argument through the computation. The two input /// arrays must have the same lengths, otherwise an ArgumentException is /// raised. + /// /// The function to update the state given the input elements. /// The first input array. /// The second input array. /// The initial state. - /// Thrown when either of the input arrays is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when either of the input arrays is null. + /// Thrown when the input arrays differ in length. + /// /// The final state. [] val foldBack2<'T1,'T2,'State> : folder:('T1 -> 'T2 -> 'State -> 'State) -> array1:'T1[] -> array2:'T2[] -> state:'State -> 'State /// Gets an element from an array. + /// /// The input array. /// The input index. + /// /// The value of the array at the given index. - /// Thrown when the input array is null. - /// Thrown when the index is negative or the input array does not contain enough elements. + /// + /// Thrown when the input array is null. + /// Thrown when the index is negative or the input array does not contain enough elements. [] val get: array:'T[] -> index:int -> 'T @@ -444,8 +536,8 @@ namespace Microsoft.FSharp.Collections /// /// The first element of the array. /// - /// Thrown when the input array is null. - /// Thrown when the input array is empty. + /// Thrown when the input array is null. + /// Thrown when the input array is empty. [] val head: array:'T[] -> 'T @@ -458,115 +550,150 @@ namespace Microsoft.FSharp.Collections /// /// The result array. /// - /// Thrown when the input array is null. + /// Thrown when the input array is null. [] val groupBy : projection:('T -> 'Key) -> array:'T[] -> ('Key * 'T[])[] when 'Key : equality /// Builds a new array whose elements are the corresponding elements of the input array /// paired with the integer index (from 0) of each element. + /// /// The input array. + /// /// The array of indexed elements. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val indexed: array:'T[] -> (int * 'T)[] /// Creates an array given the dimension and a generator function to compute the elements. + /// /// The number of elements to initialize. /// The function to generate the initial values for each index. + /// /// The created array. - /// Thrown when count is negative. + /// + /// Thrown when count is negative. [] val inline init: count:int -> initializer:(int -> 'T) -> 'T[] /// Creates an array where the entries are initially the default value Unchecked.defaultof<'T>. + /// /// The length of the array to create. + /// /// The created array. - /// Thrown when count is negative. + /// + /// Thrown when count is negative. [] val zeroCreate: count:int -> 'T[] /// Returns true if the given array is empty, otherwise false. + /// /// The input array. + /// /// True if the array is empty. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val isEmpty: array:'T[] -> bool /// Applies the given function to each element of the array. + /// /// The function to apply. /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val inline iter: action:('T -> unit) -> array:'T[] -> unit /// Applies the given function to pair of elements drawn from matching indices in two arrays. The /// two arrays must have the same lengths, otherwise an ArgumentException is /// raised. + /// /// The function to apply. /// The first input array. /// The second input array. - /// Thrown when either of the input arrays is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when either of the input arrays is null. + /// Thrown when the input arrays differ in length. [] val iter2: action:('T1 -> 'T2 -> unit) -> array1:'T1[] -> array2:'T2[] -> unit /// Applies the given function to each element of the array. The integer passed to the /// function indicates the index of element. + /// /// The function to apply to each index and element. /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val iteri: action:(int -> 'T -> unit) -> array:'T[] -> unit /// Applies the given function to pair of elements drawn from matching indices in two arrays, /// also passing the index of the elements. The two arrays must have the same lengths, /// otherwise an ArgumentException is raised. + /// /// The function to apply to each index and pair of elements. /// The first input array. /// The second input array. - /// Thrown when either of the input arrays is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when either of the input arrays is null. + /// Thrown when the input arrays differ in length. [] val iteri2: action:(int -> 'T1 -> 'T2 -> unit) -> array1:'T1[] -> array2:'T2[] -> unit /// Returns the last element of the array. + /// /// The input array. + /// /// The last element of the array. - /// Thrown when the input array is null. - /// Thrown when the input does not have any elements. + /// + /// Thrown when the input array is null. + /// Thrown when the input does not have any elements. [] val inline last: array:'T[] -> 'T /// Gets an element from an array. + /// /// The input index. /// The input array. + /// /// The value of the array at the given index. - /// Thrown when the input array is null. - /// Thrown when the index is negative or the input array does not contain enough elements. + /// + /// Thrown when the input array is null. + /// Thrown when the index is negative or the input array does not contain enough elements. [] val item: index:int -> array:'T[] -> 'T /// Returns the length of an array. You can also use property arr.Length. + /// /// The input array. + /// /// The length of the array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val length: array:'T[] -> int /// Returns the last element of the array. /// Return None if no such element exists. + /// /// The input array. + /// /// The last element of the array or None. - /// Thrown when the input sequence is null. + /// + /// Thrown when the input sequence is null. [] val tryLast: array:'T[] -> 'T option /// Builds a new array whose elements are the results of applying the given function /// to each of the elements of the array. + /// /// The function to transform elements of the array. /// The input array. + /// /// The array of transformed elements. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val inline map: mapping:('T -> 'U) -> array:'T[] -> 'U[] @@ -574,31 +701,40 @@ namespace Microsoft.FSharp.Collections /// to the corresponding elements of the two collections pairwise. The two input /// arrays must have the same lengths, otherwise an ArgumentException is /// raised. + /// /// The function to transform the pairs of the input elements. /// The first input array. /// The second input array. - /// Thrown when the input arrays differ in length. - /// Thrown when either of the input arrays is null. + /// + /// Thrown when the input arrays differ in length. + /// Thrown when either of the input arrays is null. + /// /// The array of transformed elements. [] val map2: mapping:('T1 -> 'T2 -> 'U) -> array1:'T1[] -> array2:'T2[] -> 'U[] /// Combines map and fold. Builds a new array whose elements are the results of applying the given function /// to each of the elements of the input array. The function is also used to accumulate a final value. + /// /// The function to transform elements from the input array and accumulate the final value. /// The initial state. /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. + /// /// The array of transformed elements, and the final accumulated value. [] val mapFold<'T,'State,'Result> : mapping:('State -> 'T -> 'Result * 'State) -> state:'State -> array:'T[] -> 'Result[] * 'State /// Combines map and foldBack. Builds a new array whose elements are the results of applying the given function /// to each of the elements of the input array. The function is also used to accumulate a final value. + /// /// The function to transform elements from the input array and accumulate the final value. /// The input array. /// The initial state. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. + /// /// The array of transformed elements, and the final accumulated value. [] val mapFoldBack<'T,'State,'Result> : mapping:('T -> 'State -> 'Result * 'State) -> array:'T[] -> state:'State -> 'Result[] * 'State @@ -607,12 +743,15 @@ namespace Microsoft.FSharp.Collections /// to the corresponding triples from the three collections. The three input /// arrays must have the same length, otherwise an ArgumentException is /// raised. + /// /// The function to transform the pairs of the input elements. /// The first input array. /// The second input array. /// The third input array. - /// Thrown when the input arrays differ in length. - /// Thrown when any of the input arrays is null. + /// + /// Thrown when the input arrays differ in length. + /// Thrown when any of the input arrays is null. + /// /// The array of transformed elements. [] val map3: mapping:('T1 -> 'T2 -> 'T3 -> 'U) -> array1:'T1[] -> array2:'T2[] -> array3:'T3[] -> 'U[] @@ -621,11 +760,14 @@ namespace Microsoft.FSharp.Collections /// to the corresponding elements of the two collections pairwise, also passing the index of /// the elements. The two input arrays must have the same lengths, otherwise an ArgumentException is /// raised. + /// /// The function to transform pairs of input elements and their indices. /// The first input array. /// The second input array. - /// Thrown when either of the input arrays is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when either of the input arrays is null. + /// Thrown when the input arrays differ in length. + /// /// The array of transformed elements. [] val mapi2: mapping:(int -> 'T1 -> 'T2 -> 'U) -> array1:'T1[] -> array2:'T2[] -> 'U[] @@ -633,19 +775,25 @@ namespace Microsoft.FSharp.Collections /// Builds a new array whose elements are the results of applying the given function /// to each of the elements of the array. The integer index passed to the /// function indicates the index of element being transformed. + /// /// The function to transform elements and their indices. /// The input array. + /// /// The array of transformed elements. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val mapi: mapping:(int -> 'T -> 'U) -> array:'T[] -> 'U[] /// Returns the greatest of all elements of the array, compared via Operators.max on the function result. /// /// Throws ArgumentException for empty arrays. + /// /// The input array. - /// Thrown when the input array is null. - /// Thrown when the input array is empty. + /// + /// Thrown when the input array is null. + /// Thrown when the input array is empty. + /// /// The maximum element. [] val inline max : array:'T[] -> 'T when 'T : comparison @@ -653,10 +801,13 @@ namespace Microsoft.FSharp.Collections /// Returns the greatest of all elements of the array, compared via Operators.max on the function result. /// /// Throws ArgumentException for empty arrays. + /// /// The function to transform the elements into a type supporting comparison. /// The input array. - /// Thrown when the input array is null. - /// Thrown when the input array is empty. + /// + /// Thrown when the input array is null. + /// Thrown when the input array is empty. + /// /// The maximum element. [] val inline maxBy : projection:('T -> 'U) -> array:'T[] -> 'T when 'U : comparison @@ -664,9 +815,12 @@ namespace Microsoft.FSharp.Collections /// Returns the lowest of all elements of the array, compared via Operators.min. /// /// Throws ArgumentException for empty arrays + /// /// The input array. - /// Thrown when the input array is null. - /// Thrown when the input array is empty. + /// + /// Thrown when the input array is null. + /// Thrown when the input array is empty. + /// /// The minimum element. [] val inline min : array:'T[] -> 'T when 'T : comparison @@ -674,24 +828,32 @@ namespace Microsoft.FSharp.Collections /// Returns the lowest of all elements of the array, compared via Operators.min on the function result. /// /// Throws ArgumentException for empty arrays. + /// /// The function to transform the elements into a type supporting comparison. /// The input array. - /// Thrown when the input array is null. - /// Thrown when the input array is empty. + /// + /// Thrown when the input array is null. + /// Thrown when the input array is empty. + /// /// The minimum element. [] val inline minBy : projection:('T -> 'U) -> array:'T[] -> 'T when 'U : comparison /// Builds an array from the given list. + /// /// The input list. + /// /// The array of elements from the list. [] val ofList: list:'T list -> 'T[] /// Builds a new array from the given enumerable object. + /// /// The input sequence. + /// /// The array of elements from the sequence. - /// Thrown when the input sequence is null. + /// + /// Thrown when the input sequence is null. [] val ofSeq: source:seq<'T> -> 'T[] @@ -702,28 +864,34 @@ namespace Microsoft.FSharp.Collections /// /// The result array. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val pairwise: array:'T[] -> ('T * 'T)[] /// Splits the collection into two collections, containing the /// elements for which the given predicate returns "true" and "false" /// respectively. + /// /// The function to test the input elements. /// The input array. + /// /// A pair of arrays. The first containing the elements the predicate evaluated to true, /// and the second containing those evaluated to false. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val partition: predicate:('T -> bool) -> array:'T[] -> 'T[] * 'T[] /// Returns an array with all elements permuted according to the /// specified permutation. + /// /// The function that maps input indices to output indices. /// The input array. + /// /// The output array. - /// Thrown when the input array is null. - /// Thrown when indexMap does not produce a valid permutation. + /// + /// Thrown when the input array is null. + /// Thrown when indexMap does not produce a valid permutation. [] val permute : indexMap:(int -> int) -> array:'T[] -> 'T[] @@ -731,10 +899,13 @@ namespace Microsoft.FSharp.Collections /// through the computation. If the input function is f and the elements are i0...iN /// then computes f (... (f i0 i1)...) iN. /// Raises ArgumentException if the array has size zero. + /// /// The function to reduce a pair of elements to a single element. /// The input array. - /// Thrown when the input array is null. - /// Thrown when the input array is empty. + /// + /// Thrown when the input array is null. + /// Thrown when the input array is empty. + /// /// The final result of the reductions. [] val reduce: reduction:('T -> 'T -> 'T) -> array:'T[] -> 'T @@ -742,45 +913,60 @@ namespace Microsoft.FSharp.Collections /// Applies a function to each element of the array, starting from the end, threading an accumulator argument /// through the computation. If the input function is f and the elements are i0...iN /// then computes f i0 (...(f iN-1 iN)). + /// /// A function that takes in the next-to-last element of the list and the /// current accumulated result to produce the next accumulated result. /// The input array. - /// Thrown when the input array is null. - /// Thrown when the input array is empty. + /// + /// Thrown when the input array is null. + /// Thrown when the input array is empty. + /// /// The final result of the reductions. [] val reduceBack: reduction:('T -> 'T -> 'T) -> array:'T[] -> 'T /// Creates an array by replicating the given initial value. + /// /// The number of elements to replicate. /// The value to replicate + /// /// The generated array. - /// Thrown when count is negative. + /// + /// Thrown when count is negative. [] val replicate: count:int -> initial:'T -> 'T[] /// Returns a new array with the elements in reverse order. + /// /// The input array. + /// /// The reversed array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val rev: array:'T[] -> 'T[] /// Like fold, but return the intermediary and final results. + /// /// The function to update the state given the input elements. /// The initial state. /// The input array. + /// /// The array of state values. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val scan<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> array:'T[] -> 'State[] /// Like foldBack, but return both the intermediary and final results. + /// /// The function to update the state given the input elements. /// The input array. /// The initial state. + /// /// The array of state values. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val scanBack<'T,'State> : folder:('T -> 'State -> 'State) -> array:'T[] -> state:'State -> 'State[] @@ -793,41 +979,52 @@ namespace Microsoft.FSharp.Collections val inline singleton: value:'T -> 'T[] /// Sets an element of an array. + /// /// The input array. /// The input index. /// The input value. - /// Thrown when the input array is null. - /// Thrown when the index is negative or the input array does not contain enough elements. + /// + /// Thrown when the input array is null. + /// Thrown when the index is negative or the input array does not contain enough elements. [] val set: array:'T[] -> index:int -> value:'T -> unit /// Builds a new array that contains the elements of the given array, excluding the first N elements. + /// /// The number of elements to skip. /// The input array. + /// /// A copy of the input array, after removing the first N elements. - /// Thrown when the input array is null. - /// Thrown when count is negative or exceeds the number of + /// + /// Thrown when the input array is null. + /// Thrown when count is negative or exceeds the number of /// elements in the array. [] val skip: count:int -> array:'T[] -> 'T[] /// Bypasses elements in an array while the given predicate returns True, and then returns /// the remaining elements in a new array. + /// /// A function that evaluates an element of the array to a boolean value. /// The input array. + /// /// The created sub array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val skipWhile: predicate:('T -> bool) -> array:'T[] -> 'T[] /// Builds a new array that contains the given subrange specified by /// starting index and length. + /// /// The input array. /// The index of the first element of the sub array. /// The length of the sub array. + /// /// The created sub array. - /// Thrown when the input array is null. - /// Thrown when either startIndex or count is negative, + /// + /// Thrown when the input array is null. + /// Thrown when either startIndex or count is negative, /// or when there aren't enough elements in the input array. [] val sub: array:'T[] -> startIndex:int -> count:int -> 'T[] @@ -836,9 +1033,12 @@ namespace Microsoft.FSharp.Collections /// /// This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. /// For a stable sort, consider using Seq.sort. + /// /// The input array. + /// /// The sorted array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val sort: array:'T[] -> 'T[] when 'T : comparison @@ -847,10 +1047,13 @@ namespace Microsoft.FSharp.Collections /// /// This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. /// For a stable sort, consider using Seq.sort. + /// /// The function to transform array elements into the type that is compared. /// The input array. + /// /// The sorted array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val sortBy: projection:('T -> 'Key) -> array:'T[] -> 'T[] when 'Key : comparison @@ -858,10 +1061,13 @@ namespace Microsoft.FSharp.Collections /// /// This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. /// For a stable sort, consider using Seq.sort. + /// /// The function to compare pairs of array elements. /// The input array. + /// /// The sorted array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val sortWith: comparer:('T -> 'T -> int) -> array:'T[] -> 'T[] @@ -870,35 +1076,43 @@ namespace Microsoft.FSharp.Collections /// /// This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. /// For a stable sort, consider using Seq.sort. + /// /// The function to transform array elements into the type that is compared. /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val sortInPlaceBy: projection:('T -> 'Key) -> array:'T[] -> unit when 'Key : comparison /// Sorts the elements of an array by mutating the array in-place, using the given comparison function as the order. + /// /// The function to compare pairs of array elements. /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val sortInPlaceWith: comparer:('T -> 'T -> int) -> array:'T[] -> unit /// Sorts the elements of an array by mutating the array in-place, using the given comparison function. /// Elements are compared using Operators.compare. + /// /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val sortInPlace: array:'T[] -> unit when 'T : comparison /// Splits an array into two arrays, at the given index. + /// /// The index at which the array is split. /// The input array. + /// /// The two split arrays. /// - /// Thrown when the input array is null. - /// Thrown when split index exceeds the number of elements + /// Thrown when the input array is null. + /// Thrown when split index exceeds the number of elements /// in the array. [] val splitAt: index:int -> array:'T[] -> ('T[] * 'T[]) @@ -907,7 +1121,9 @@ namespace Microsoft.FSharp.Collections /// /// This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. /// For a stable sort, consider using Seq.sort. + /// /// The input array. + /// /// The sorted array. [] val inline sortDescending: array:'T[] -> 'T[] when 'T : comparison @@ -917,16 +1133,21 @@ namespace Microsoft.FSharp.Collections /// /// This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. /// For a stable sort, consider using Seq.sort. + /// /// The function to transform array elements into the type that is compared. /// The input array. + /// /// The sorted array. [] val inline sortByDescending: projection:('T -> 'Key) -> array:'T[] -> 'T[] when 'Key : comparison /// Returns the sum of the elements in the array. + /// /// The input array. + /// /// The resulting sum. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val inline sum : array: ^T[] -> ^T when ^T : (static member ( + ) : ^T * ^T -> ^T) @@ -934,10 +1155,13 @@ namespace Microsoft.FSharp.Collections /// Returns the sum of the results generated by applying the function to each element of the array. + /// /// The function to transform the array elements into the type to be summed. /// The input array. + /// /// The resulting sum. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val inline sumBy : projection:('T -> ^U) -> array:'T[] -> ^U when ^U : (static member ( + ) : ^U * ^U -> ^U) @@ -953,9 +1177,9 @@ namespace Microsoft.FSharp.Collections /// /// The result array. /// - /// Thrown when the input array is null. - /// Thrown when the input array is empty. - /// Thrown when count exceeds the number of elements + /// Thrown when the input array is null. + /// Thrown when the input array is empty. + /// Thrown when count exceeds the number of elements /// in the list. [] val take: count:int -> array:'T[] -> 'T[] @@ -968,154 +1192,202 @@ namespace Microsoft.FSharp.Collections /// /// The result array. /// - /// Thrown when the input array is null. + /// Thrown when the input array is null. [] val takeWhile: predicate:('T -> bool) -> array:'T[] -> 'T[] /// Returns a new array containing the elements of the original except the first element. /// /// The input array. - /// Thrown when the array is empty. - /// Thrown when the input array is null. + /// + /// Thrown when the array is empty. + /// Thrown when the input array is null. + /// /// A new array containing the elements of the original except the first element. [] val tail: array:'T[] -> 'T[] /// Builds a list from the given array. + /// /// The input array. + /// /// The list of array elements. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val toList: array:'T[] -> 'T list /// Views the given array as a sequence. + /// /// The input array. + /// /// The sequence of array elements. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val toSeq: array:'T[] -> seq<'T> /// Returns the transpose of the given sequence of arrays. + /// /// The input sequence of arrays. + /// /// The transposed array. - /// Thrown when the input sequence is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when the input sequence is null. + /// Thrown when the input arrays differ in length. [] val transpose: arrays:seq<'T[]> -> 'T[][] /// Returns at most N elements in a new array. + /// /// The maximum number of items to return. /// The input array. + /// /// The result array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val truncate: count:int -> array:'T[] -> 'T[] /// Returns the first element for which the given function returns True. /// Return None if no such element exists. + /// /// The function to test the input elements. /// The input array. + /// /// The first element that satisfies the predicate, or None. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val tryFind: predicate:('T -> bool) -> array:'T[] -> 'T option /// Returns the last element for which the given function returns True. /// Return None if no such element exists. + /// /// The function to test the input elements. /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. + /// /// The last element that satisfies the predicate, or None. [] val tryFindBack: predicate:('T -> bool) -> array:'T[] -> 'T option /// Returns the index of the first element in the array /// that satisfies the given predicate. + /// /// The function to test the input elements. /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. + /// /// The index of the first element that satisfies the predicate, or None. [] val tryFindIndex : predicate:('T -> bool) -> array:'T[] -> int option /// Tries to find the nth element in the array. /// Returns None if index is negative or the input array does not contain enough elements. + /// /// The index of element to retrieve. /// The input array. + /// /// The nth element of the array or None. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val tryItem: index:int -> array:'T[] -> 'T option /// Returns the index of the last element in the array /// that satisfies the given predicate. + /// /// The function to test the input elements. /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. + /// /// The index of the last element that satisfies the predicate, or None. [] val tryFindIndexBack : predicate:('T -> bool) -> array:'T[] -> int option /// Returns an array that contains the elements generated by the given computation. /// The given initial state argument is passed to the element generator. + /// /// A function that takes in the current state and returns an option tuple of the next /// element of the array and the next state value. /// The initial state value. + /// /// The result array. [] val unfold<'T,'State> : generator:('State -> ('T * 'State) option) -> state:'State -> 'T[] /// Splits an array of pairs into two arrays. + /// /// The input array. + /// /// The two arrays. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val unzip: array:('T1 * 'T2)[] -> ('T1[] * 'T2[]) /// Splits an array of triples into three arrays. + /// /// The input array. + /// /// The tuple of three arrays. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val unzip3: array:('T1 * 'T2 * 'T3)[] -> ('T1[] * 'T2[] * 'T3[]) /// Returns a new array containing only the elements of the array /// for which the given predicate returns "true". + /// /// The function to test the input elements. /// The input array. + /// /// An array containing the elements for which the given predicate returns true. /// - /// Thrown when the input array is null. + /// Thrown when the input array is null. [] val where: predicate:('T -> bool) -> array:'T[] -> 'T[] /// Returns an array of sliding windows containing elements drawn from the input /// array. Each window is returned as a fresh array. + /// /// The number of elements in each window. /// The input array. + /// /// The result array. - /// Thrown when the input array is null. - /// Thrown when windowSize is not positive. + /// + /// Thrown when the input array is null. + /// Thrown when windowSize is not positive. [] val windowed : windowSize:int -> array:'T[] -> 'T[][] /// Combines the two arrays into an array of pairs. The two arrays must have equal lengths, otherwise an ArgumentException is /// raised. + /// /// The first input array. /// The second input array. - /// Thrown when either of the input arrays is null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when either of the input arrays is null. + /// Thrown when the input arrays differ in length. + /// /// The array of tupled elements. [] val zip: array1:'T1[] -> array2:'T2[] -> ('T1 * 'T2)[] /// Combines three arrays into an array of pairs. The three arrays must have equal lengths, otherwise an ArgumentException is /// raised. + /// /// The first input array. /// The second input array. /// The third input array. - /// Thrown when any of the input arrays are null. - /// Thrown when the input arrays differ in length. + /// + /// Thrown when any of the input arrays are null. + /// Thrown when the input arrays differ in length. + /// /// The array of tupled elements. [] val zip3: array1:'T1[] -> array2:'T2[] -> array3:'T3[] -> ('T1 * 'T2 * 'T3)[] @@ -1129,10 +1401,13 @@ namespace Microsoft.FSharp.Collections /// /// Performs the operation in parallel using System.Threading.Parallel.For. /// The order in which the given function is applied to elements of the input array is not specified. + /// /// The function to generate options from the elements. /// The input array. + /// /// 'U[] - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val choose: chooser:('T -> 'U option) -> array:'T[] -> 'U[] @@ -1140,10 +1415,13 @@ namespace Microsoft.FSharp.Collections /// /// Performs the operation in parallel using System.Threading.Parallel.For. /// The order in which the given function is applied to elements of the input array is not specified. + /// /// /// The input array. + /// /// 'U[] - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val collect : mapping:('T -> 'U[]) -> array:'T[] -> 'U[] @@ -1152,10 +1430,13 @@ namespace Microsoft.FSharp.Collections /// /// Performs the operation in parallel using System.Threading.Parallel.For. /// The order in which the given function is applied to elements of the input array is not specified. + /// /// /// The input array. + /// /// 'U[] - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val map : mapping:('T -> 'U) -> array:'T[] -> 'U[] @@ -1165,10 +1446,13 @@ namespace Microsoft.FSharp.Collections /// /// Performs the operation in parallel using System.Threading.Parallel.For. /// The order in which the given function is applied to elements of the input array is not specified. + /// /// /// The input array. + /// /// 'U[] - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val mapi: mapping:(int -> 'T -> 'U) -> array:'T[] -> 'U[] @@ -1176,9 +1460,11 @@ namespace Microsoft.FSharp.Collections /// /// Performs the operation in parallel using System.Threading.Parallel.For. /// The order in which the given function is applied to elements of the input array is not specified. + /// /// /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val iter : action:('T -> unit) -> array:'T[] -> unit @@ -1187,9 +1473,11 @@ namespace Microsoft.FSharp.Collections /// /// Performs the operation in parallel using System.Threading.Parallel.For. /// The order in which the given function is applied to elements of the input array is not specified. + /// /// /// The input array. - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val iteri: action:(int -> 'T -> unit) -> array:'T[] -> unit @@ -1197,8 +1485,10 @@ namespace Microsoft.FSharp.Collections /// /// Performs the operation in parallel using System.Threading.Parallel.For. /// The order in which the given function is applied to indices is not specified. + /// /// /// + /// /// 'T[] [] val init : count:int -> initializer:(int -> 'T) -> 'T[] @@ -1209,9 +1499,12 @@ namespace Microsoft.FSharp.Collections /// /// Performs the operation in parallel using System.Threading.Parallel.For. /// The order in which the given function is applied to indices is not specified. + /// /// The function to test the input elements. /// The input array. + /// /// 'T[] * 'T[] - /// Thrown when the input array is null. + /// + /// Thrown when the input array is null. [] val partition : predicate:('T -> bool) -> array:'T[] -> 'T[] * 'T[] diff --git a/src/fsharp/FSharp.Core/array2.fsi b/src/fsharp/FSharp.Core/array2.fsi index 86a3d5be5c43..f21e7930d93b 100644 --- a/src/fsharp/FSharp.Core/array2.fsi +++ b/src/fsharp/FSharp.Core/array2.fsi @@ -58,7 +58,7 @@ namespace Microsoft.FSharp.Collections /// The second-dimension index to begin copying into in the target array. /// The number of elements to copy across the first dimension of the arrays. /// The number of elements to copy across the second dimension of the arrays. - /// Thrown when any of the indices are negative or if either of + /// Thrown when any of the indices are negative or if either of /// the counts are larger than the dimensions of the array allow. [] val blit: source:'T[,] -> sourceIndex1:int -> sourceIndex2:int -> target:'T[,] -> targetIndex1:int -> targetIndex2:int -> length1:int -> length2:int -> unit @@ -70,7 +70,7 @@ namespace Microsoft.FSharp.Collections /// A function to produce elements of the array given the two indices. /// /// The generated array. - /// Thrown when either of the lengths is negative. + /// Thrown when either of the lengths is negative. [] val init: length1:int -> length2:int -> initializer:(int -> int -> 'T) -> 'T[,] @@ -81,7 +81,7 @@ namespace Microsoft.FSharp.Collections /// The value to populate the new array. /// /// The created array. - /// Thrown when length1 or length2 is negative. + /// Thrown when length1 or length2 is negative. [] val create: length1:int -> length2:int -> value:'T -> 'T[,] @@ -91,7 +91,7 @@ namespace Microsoft.FSharp.Collections /// The length of the second dimension of the array. /// /// The created array. - /// Thrown when length1 or length2 is negative. + /// Thrown when length1 or length2 is negative. [] val zeroCreate : length1:int -> length2:int -> 'T[,] @@ -104,7 +104,7 @@ namespace Microsoft.FSharp.Collections /// A function to produce elements of the array given the two indices. /// /// The created array. - /// Thrown when base1, base2, length1, or length2 is negative. + /// Thrown when base1, base2, length1, or length2 is negative. [] val initBased: base1:int -> base2:int -> length1:int -> length2:int -> initializer:(int -> int -> 'T) -> 'T[,] @@ -117,7 +117,7 @@ namespace Microsoft.FSharp.Collections /// The value to populate the new array. /// /// The created array. - /// Thrown when base1, base2, length1, or length2 is negative. + /// Thrown when base1, base2, length1, or length2 is negative. [] val createBased: base1:int -> base2:int -> length1:int -> length2:int -> initial: 'T -> 'T[,] @@ -129,7 +129,7 @@ namespace Microsoft.FSharp.Collections /// The length of the second dimension of the array. /// /// The created array. - /// Thrown when base1, base2, length1, or length2 is negative. + /// Thrown when base1, base2, length1, or length2 is negative. [] val zeroCreateBased : base1:int -> base2:int -> length1:int -> length2:int -> 'T[,] @@ -209,7 +209,7 @@ namespace Microsoft.FSharp.Collections /// The index along the first dimension. /// The index along the second dimension. /// The value to set in the array. - /// Thrown when the indices are negative or exceed the bounds of the array. + /// Thrown when the indices are negative or exceed the bounds of the array. [] val set: array:'T[,] -> index1:int -> index2:int -> value:'T -> unit @@ -220,7 +220,7 @@ namespace Microsoft.FSharp.Collections /// The index along the second dimension. /// /// The value of the array at the given index. - /// Thrown when the indices are negative or exceed the bounds of the array. + /// Thrown when the indices are negative or exceed the bounds of the array. [] val get: array:'T[,] -> index1:int -> index2:int -> 'T diff --git a/src/fsharp/FSharp.Core/array3.fsi b/src/fsharp/FSharp.Core/array3.fsi index e5372c9084d1..cc295522d449 100644 --- a/src/fsharp/FSharp.Core/array3.fsi +++ b/src/fsharp/FSharp.Core/array3.fsi @@ -17,29 +17,35 @@ namespace Microsoft.FSharp.Collections /// The length of the second dimension. /// The length of the third dimension. /// The value of the array elements. + /// /// The created array. [] val create: length1:int -> length2:int -> length3:int -> initial:'T -> 'T[,,] /// Creates an array given the dimensions and a generator function to compute the elements. + /// /// The length of the first dimension. /// The length of the second dimension. /// The length of the third dimension. /// The function to create an initial value at each index into the array. + /// /// The created array. [] val init: length1:int -> length2:int -> length3:int -> initializer:(int -> int -> int -> 'T) -> 'T[,,] /// Fetches an element from a 3D array. You can also use the syntax 'array.[index1,index2,index3]' + /// /// The input array. /// The index along the first dimension. /// The index along the second dimension. /// The index along the third dimension. + /// /// The value at the given index. [] val get: array:'T[,,] -> index1:int -> index2:int -> index3:int -> 'T /// Applies the given function to each element of the array. + /// /// The function to apply to each element of the array. /// The input array. [] @@ -47,25 +53,32 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to each element of the array. The integer indices passed to the /// function indicates the index of element. + /// /// The function to apply to each element of the array. /// The input array. [] val iteri: action:(int -> int -> int -> 'T -> unit) -> array:'T[,,] -> unit /// Returns the length of an array in the first dimension + /// /// The input array. + /// /// The length of the array in the first dimension. [] val length1: array:'T[,,] -> int /// Returns the length of an array in the second dimension. + /// /// The input array. + /// /// The length of the array in the second dimension. [] val length2: array:'T[,,] -> int /// Returns the length of an array in the third dimension. + /// /// The input array. + /// /// The length of the array in the third dimension. [] val length3: array:'T[,,] -> int @@ -77,6 +90,7 @@ namespace Microsoft.FSharp.Collections /// array. /// The function to transform each element of the array. /// The input array. + /// /// The array created from the transformed elements. [] val map: mapping:('T -> 'U) -> array:'T[,,] -> 'U[,,] @@ -89,12 +103,14 @@ namespace Microsoft.FSharp.Collections /// array. /// The function to transform the elements at each index in the array. /// The input array. + /// /// The array created from the transformed elements. [] val mapi: mapping:(int -> int -> int -> 'T -> 'U) -> array:'T[,,] -> 'U[,,] /// Sets the value of an element in an array. You can also /// use the syntax 'array.[index1,index2,index3] <- value'. + /// /// The input array. /// The index along the first dimension. /// The index along the second dimension. @@ -104,9 +120,11 @@ namespace Microsoft.FSharp.Collections val set: array:'T[,,] -> index1:int -> index2:int -> index3:int -> value:'T -> unit /// Creates an array where the entries are initially the "default" value. + /// /// The length of the first dimension. /// The length of the second dimension. /// The length of the third dimension. + /// /// The created array. [] val zeroCreate: length1:int -> length2:int -> length3:int -> 'T[,,] @@ -119,70 +137,87 @@ namespace Microsoft.FSharp.Collections module Array4D = /// Creates an array whose elements are all initially the given value + /// /// The length of the first dimension. /// The length of the second dimension. /// The length of the third dimension. /// The length of the fourth dimension. /// The initial value for each element of the array. + /// /// The created array. [] val create: length1:int -> length2:int -> length3:int -> length4:int -> initial:'T -> 'T[,,,] /// Creates an array given the dimensions and a generator function to compute the elements. + /// /// The length of the first dimension. /// The length of the second dimension. /// The length of the third dimension. /// The length of the fourth dimension. /// The function to create an initial value at each index in the array. + /// /// The created array. [] val init: length1:int -> length2:int -> length3:int -> length4:int -> initializer:(int -> int -> int -> int -> 'T) -> 'T[,,,] /// Returns the length of an array in the first dimension + /// /// The input array. + /// /// The length of the array in the first dimension. [] val length1: array:'T[,,,] -> int /// Returns the length of an array in the second dimension. + /// /// The input array. + /// /// The length of the array in the second dimension. [] val length2: array:'T[,,,] -> int /// Returns the length of an array in the third dimension. + /// /// The input array. + /// /// The length of the array in the third dimension. [] val length3: array:'T[,,,] -> int /// Returns the length of an array in the fourth dimension. + /// /// The input array. + /// /// The length of the array in the fourth dimension. [] val length4: array:'T[,,,] -> int /// Creates an array where the entries are initially the "default" value. + /// /// The length of the first dimension. /// The length of the second dimension. /// The length of the third dimension. /// The length of the fourth dimension. + /// /// The created array. [] val zeroCreate: length1:int -> length2:int -> length3:int -> length4:int -> 'T[,,,] /// Fetches an element from a 4D array. You can also use the syntax 'array.[index1,index2,index3,index4]' + /// /// The input array. /// The index along the first dimension. /// The index along the second dimension. /// The index along the third dimension. /// The index along the fourth dimension. + /// /// The value at the given index. [] val get: array:'T[,,,] -> index1:int -> index2:int -> index3:int -> index4:int -> 'T /// Sets the value of an element in an array. You can also /// use the syntax 'array.[index1,index2,index3,index4] <- value'. + /// /// The input array. /// The index along the first dimension. /// The index along the second dimension. diff --git a/src/fsharp/FSharp.Core/async.fsi b/src/fsharp/FSharp.Core/async.fsi index 72502b9d26e9..594d90144f17 100644 --- a/src/fsharp/FSharp.Core/async.fsi +++ b/src/fsharp/FSharp.Core/async.fsi @@ -43,47 +43,56 @@ namespace Microsoft.FSharp.Control /// /// The timeout parameter is given in milliseconds. A value of -1 is equivalent to /// System.Threading.Timeout.Infinite. + /// /// The computation to run. /// The amount of time in milliseconds to wait for the result of the - /// computation before raising a System.TimeoutException. If no value is provided + /// computation before raising a . If no value is provided /// for timeout then a default of -1 is used to correspond to System.Threading.Timeout.Infinite. /// If a cancellable cancellationToken is provided, timeout parameter will be ignored /// The cancellation token to be associated with the computation. /// If one is not supplied, the default cancellation token is used. + /// /// The result of the computation. static member RunSynchronously : computation:Async<'T> * ?timeout : int * ?cancellationToken:CancellationToken-> 'T /// Starts the asynchronous computation in the thread pool. Do not await its result. /// /// If no cancellation token is provided then the default cancellation token is used. + /// /// The computation to run asynchronously. /// The cancellation token to be associated with the computation. /// If one is not supplied, the default cancellation token is used. static member Start : computation:Async * ?cancellationToken:CancellationToken -> unit /// Executes a computation in the thread pool. + /// /// If no cancellation token is provided then the default cancellation token is used. - /// A System.Threading.Tasks.Task that will be completed + /// + /// A that will be completed /// in the corresponding state once the computation terminates (produces the result, throws exception or gets canceled) /// static member StartAsTask : computation:Async<'T> * ?taskCreationOptions:TaskCreationOptions * ?cancellationToken:CancellationToken -> Task<'T> - /// Creates an asynchronous computation which starts the given computation as a System.Threading.Tasks.Task + /// Creates an asynchronous computation which starts the given computation as a static member StartChildAsTask : computation:Async<'T> * ?taskCreationOptions:TaskCreationOptions -> Async> /// Creates an asynchronous computation that executes computation. /// If this computation completes successfully then return Choice1Of2 with the returned /// value. If this computation raises an exception before it completes then return Choice2Of2 /// with the raised exception. + /// /// The input computation that returns the type T. + /// /// A computation that returns a choice of type T or exception. static member Catch : computation:Async<'T> -> Async> /// Creates an asynchronous computation that executes computation. /// If this computation is cancelled before it completes then the computation generated by /// running compensation is executed. + /// /// The input asynchronous computation. /// The function to be run if the computation is cancelled. + /// /// An asynchronous computation that runs the compensation if the input computation /// is cancelled. static member TryCancelled : computation:Async<'T> * compensation:(OperationCanceledException -> unit) -> Async<'T> @@ -97,16 +106,20 @@ namespace Microsoft.FSharp.Control /// interruption is executed on the thread that is performing the cancellation. This can /// be used to arrange for a computation to be asynchronously notified that a cancellation /// has occurred, e.g. by setting a flag, or deregistering a pending I/O action. + /// /// The function that is executed on the thread performing the /// cancellation. + /// /// An asynchronous computation that triggers the interruption if it is cancelled /// before being disposed. static member OnCancel : interruption: (unit -> unit) -> Async /// Creates an asynchronous computation that returns the CancellationToken governing the execution /// of the computation. + /// /// In async { let! token = Async.CancellationToken ...} token can be used to initiate other /// asynchronous operations that will cancel cooperatively with this workflow. + /// /// An asynchronous computation capable of retrieving the CancellationToken from a computation /// expression. static member CancellationToken : Async @@ -118,6 +131,7 @@ namespace Microsoft.FSharp.Control static member CancelDefaultToken : unit -> unit /// Gets the default cancellation token for executing asynchronous computations. + /// /// The default CancellationToken. static member DefaultCancellationToken : CancellationToken @@ -128,7 +142,7 @@ namespace Microsoft.FSharp.Control /// /// This method should normally be used as the immediate /// right-hand-side of a let! binding in an F# asynchronous workflow, that is, - /// + /// /// async { ... /// let! completor1 = childComputation1 |> Async.StartChild /// let! completor2 = childComputation2 |> Async.StartChild @@ -136,13 +150,16 @@ namespace Microsoft.FSharp.Control /// let! result1 = completor1 /// let! result2 = completor2 /// ... } + /// /// /// When used in this way, each use of StartChild starts an instance of childComputation /// and returns a completor object representing a computation to wait for the completion of the operation. /// When executed, the completor awaits the completion of childComputation. + /// /// The child computation. /// The timeout value in milliseconds. If one is not provided - /// then the default value of -1 corresponding to System.Threading.Timeout.Infinite. + /// then the default value of -1 corresponding to . + /// /// A new computation that waits for the input computation to finish. static member StartChild : computation:Async<'T> * ?millisecondsTimeout : int -> Async> @@ -157,7 +174,9 @@ namespace Microsoft.FSharp.Control /// The overall computation will respond to cancellation while executing the child computations. /// If cancelled, the computation will cancel any remaining child computations but will still wait /// for the other child computations to complete. + /// /// A sequence of distinct computations to be parallelized. + /// /// A computation that returns an array of values from the sequence of input computations. static member Parallel : computations:seq> -> Async<'T[]> @@ -172,7 +191,9 @@ namespace Microsoft.FSharp.Control /// The overall computation will respond to cancellation while executing the child computations. /// If cancelled, the computation will cancel any remaining child computations but will still wait /// for the other child computations to complete. + /// /// A sequence of distinct computations to be parallelized. + /// /// A computation that returns an array of values from the sequence of input computations. static member Parallel : computations:seq> * ?maxDegreeOfParallelism : int -> Async<'T[]> @@ -186,7 +207,9 @@ namespace Microsoft.FSharp.Control /// The overall computation will respond to cancellation while executing the child computations. /// If cancelled, the computation will cancel any remaining child computations but will still wait /// for the other child computations to complete. + /// /// A sequence of distinct computations to be run in sequence. + /// /// A computation that returns an array of values from the sequence of input computations. static member Sequential : computations:seq> -> Async<'T[]> @@ -201,7 +224,9 @@ namespace Microsoft.FSharp.Control /// The overall computation will respond to cancellation while executing the child computations. /// If cancelled, the computation will cancel any remaining child computations but will still wait /// for the other child computations to complete. + /// /// A sequence of computations to be parallelized. + /// /// A computation that returns the first succeeding computation. static member Choice : computations:seq> -> Async<'T option> @@ -209,26 +234,32 @@ namespace Microsoft.FSharp.Control /// Creates an asynchronous computation that creates a new thread and runs /// its continuation in that thread. + /// /// A computation that will execute on a new thread. static member SwitchToNewThread : unit -> Async /// Creates an asynchronous computation that queues a work item that runs /// its continuation. + /// /// A computation that generates a new work item in the thread pool. static member SwitchToThreadPool : unit -> Async /// Creates an asynchronous computation that runs /// its continuation using syncContext.Post. If syncContext is null /// then the asynchronous computation is equivalent to SwitchToThreadPool(). + /// /// The synchronization context to accept the posted computation. + /// /// An asynchronous computation that uses the syncContext context to execute. static member SwitchToContext : syncContext:System.Threading.SynchronizationContext -> Async /// Creates an asynchronous computation that captures the current /// success, exception and cancellation continuations. The callback must /// eventually call exactly one of the given continuations. + /// /// The function that accepts the current success, exception, and cancellation /// continuations. + /// /// An asynchronous computation that provides the callback with the current continuations. static member FromContinuations : callback:(('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> @@ -242,101 +273,115 @@ namespace Microsoft.FSharp.Control /// /// If cancelAction is not specified, then cancellation causes the computation /// to cancel immediately. + /// /// The event to handle once. /// An optional function to execute instead of cancelling when a /// cancellation is issued. + /// /// An asynchronous computation that waits for the event to be invoked. static member AwaitEvent: event:IEvent<'Del,'T> * ?cancelAction : (unit -> unit) -> Async<'T> when 'Del : delegate<'T,unit> and 'Del :> System.Delegate /// Creates an asynchronous computation that will wait on the given WaitHandle. /// /// The computation returns true if the handle indicated a result within the given timeout. + /// /// The WaitHandle that can be signalled. /// The timeout value in milliseconds. If one is not provided - /// then the default value of -1 corresponding to System.Threading.Timeout.Infinite. + /// then the default value of -1 corresponding to . + /// /// An asynchronous computation that waits on the given WaitHandle. static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout:int -> Async /// Creates an asynchronous computation that will wait on the IAsyncResult. /// /// The computation returns true if the handle indicated a result within the given timeout. + /// /// The IAsyncResult to wait on. /// The timeout value in milliseconds. If one is not provided - /// then the default value of -1 corresponding to System.Threading.Timeout.Infinite. + /// then the default value of -1 corresponding to . + /// /// An asynchronous computation that waits on the given IAsyncResult. static member AwaitIAsyncResult: iar: System.IAsyncResult * ?millisecondsTimeout:int -> Async /// Return an asynchronous computation that will wait for the given task to complete and return /// its result. static member AwaitTask: task: Task<'T> -> Async<'T> + /// Return an asynchronous computation that will wait for the given task to complete and return /// its result. static member AwaitTask: task: Task -> Async - /// Creates an asynchronous computation that will sleep for the given time. This is scheduled - /// using a System.Threading.Timer object. The operation will not block operating system threads - /// for the duration of the wait. + /// + /// Creates an asynchronous computation that will sleep for the given time. This is scheduled + /// using a System.Threading.Timer object. The operation will not block operating system threads + /// for the duration of the wait. + /// + /// /// The number of milliseconds to sleep. + /// /// An asynchronous computation that will sleep for the given time. - /// Thrown when the due time is negative + /// + /// Thrown when the due time is negative /// and not infinite. static member Sleep: millisecondsDueTime:int -> Async - /// Creates an asynchronous computation that will sleep for the given time. This is scheduled - /// using a System.Threading.Timer object. The operation will not block operating system threads - /// for the duration of the wait. + /// + /// Creates an asynchronous computation that will sleep for the given time. This is scheduled + /// using a System.Threading.Timer object. The operation will not block operating system threads + /// for the duration of the wait. + /// + /// /// The amount of time to sleep. + /// /// An asynchronous computation that will sleep for the given time. - /// Thrown when the due time is negative. + /// + /// Thrown when the due time is negative. static member Sleep: dueTime:TimeSpan -> Async - /// Creates an asynchronous computation in terms of a Begin/End pair of actions in - /// the style used in CLI APIs. For example, - /// Async.FromBeginEnd(ws.BeginGetWeather,ws.EndGetWeather) - /// When the computation is run, beginFunc is executed, with - /// a callback which represents the continuation of the computation. - /// When the callback is invoked, the overall result is fetched using endFunc. + /// + /// Creates an asynchronous computation in terms of a Begin/End pair of actions in + /// the style used in CLI APIs. + /// /// - /// The computation will respond to cancellation while waiting for the completion + /// + /// The computation will respond to cancellation while waiting for the completion /// of the operation. If a cancellation occurs, and cancelAction is specified, then it is /// executed, and the computation continues to wait for the completion of the operation. /// /// If cancelAction is not specified, then cancellation causes the computation /// to stop immediately, and subsequent invocations of the callback are ignored. + /// /// The function initiating a traditional CLI asynchronous operation. /// The function completing a traditional CLI asynchronous operation. /// An optional function to be executed when a cancellation is requested. + /// /// An asynchronous computation wrapping the given Begin/End functions. static member FromBeginEnd : beginAction:(System.AsyncCallback * obj -> System.IAsyncResult) * endAction:(System.IAsyncResult -> 'T) * ?cancelAction : (unit -> unit) -> Async<'T> - /// Creates an asynchronous computation in terms of a Begin/End pair of actions in - /// the style used in CLI APIs. This overload should be used if the operation is - /// qualified by one argument. For example, - /// Async.FromBeginEnd(place,ws.BeginGetWeather,ws.EndGetWeather) - /// When the computation is run, beginFunc is executed, with - /// a callback which represents the continuation of the computation. - /// When the callback is invoked, the overall result is fetched using endFunc. + /// + /// Creates an asynchronous computation in terms of a Begin/End pair of actions in + /// the style used in .NET 2.0 APIs. + /// /// /// The computation will respond to cancellation while waiting for the completion /// of the operation. If a cancellation occurs, and cancelAction is specified, then it is /// executed, and the computation continues to wait for the completion of the operation. - /// - /// If cancelAction is not specified, then cancellation causes the computation - /// to stop immediately, and subsequent invocations of the callback are ignored. + /// + /// If cancelAction is not specified, then cancellation causes the computation + /// to stop immediately, and subsequent invocations of the callback are ignored. + /// + /// /// The argument for the operation. /// The function initiating a traditional CLI asynchronous operation. /// The function completing a traditional CLI asynchronous operation. /// An optional function to be executed when a cancellation is requested. + /// /// An asynchronous computation wrapping the given Begin/End functions. static member FromBeginEnd : arg:'Arg1 * beginAction:('Arg1 * System.AsyncCallback * obj -> System.IAsyncResult) * endAction:(System.IAsyncResult -> 'T) * ?cancelAction : (unit -> unit) -> Async<'T> - /// Creates an asynchronous computation in terms of a Begin/End pair of actions in - /// the style used in CLI APIs. This overload should be used if the operation is - /// qualified by two arguments. For example, - /// Async.FromBeginEnd(arg1,arg2,ws.BeginGetWeather,ws.EndGetWeather) - /// When the computation is run, beginFunc is executed, with - /// a callback which represents the continuation of the computation. - /// When the callback is invoked, the overall result is fetched using endFunc. + /// + /// Creates an asynchronous computation in terms of a Begin/End pair of actions in + /// the style used in .NET 2.0 APIs. /// /// The computation will respond to cancellation while waiting for the completion /// of the operation. If a cancellation occurs, and cancelAction is specified, then it is @@ -344,21 +389,18 @@ namespace Microsoft.FSharp.Control /// /// If cancelAction is not specified, then cancellation causes the computation /// to stop immediately, and subsequent invocations of the callback are ignored. + /// /// The first argument for the operation. /// The second argument for the operation. /// The function initiating a traditional CLI asynchronous operation. /// The function completing a traditional CLI asynchronous operation. /// An optional function to be executed when a cancellation is requested. + /// /// An asynchronous computation wrapping the given Begin/End functions. static member FromBeginEnd : arg1:'Arg1 * arg2:'Arg2 * beginAction:('Arg1 * 'Arg2 * System.AsyncCallback * obj -> System.IAsyncResult) * endAction:(System.IAsyncResult -> 'T) * ?cancelAction : (unit -> unit) -> Async<'T> /// Creates an asynchronous computation in terms of a Begin/End pair of actions in - /// the style used in CLI APIs. This overload should be used if the operation is - /// qualified by three arguments. For example, - /// Async.FromBeginEnd(arg1,arg2,arg3,ws.BeginGetWeather,ws.EndGetWeather) - /// When the computation is run, beginFunc is executed, with - /// a callback which represents the continuation of the computation. - /// When the callback is invoked, the overall result is fetched using endFunc. + /// the style used in .NET 2.0 APIs. /// /// The computation will respond to cancellation while waiting for the completion /// of the operation. If a cancellation occurs, and cancelAction is specified, then it is @@ -366,48 +408,23 @@ namespace Microsoft.FSharp.Control /// /// If cancelAction is not specified, then cancellation causes the computation /// to stop immediately, and subsequent invocations of the callback are ignored. + /// /// The first argument for the operation. /// The second argument for the operation. /// The third argument for the operation. /// The function initiating a traditional CLI asynchronous operation. /// The function completing a traditional CLI asynchronous operation. /// An optional function to be executed when a cancellation is requested. + /// /// An asynchronous computation wrapping the given Begin/End functions. static member FromBeginEnd : arg1:'Arg1 * arg2:'Arg2 * arg3:'Arg3 * beginAction:('Arg1 * 'Arg2 * 'Arg3 * System.AsyncCallback * obj -> System.IAsyncResult) * endAction:(System.IAsyncResult -> 'T) * ?cancelAction : (unit -> unit) -> Async<'T> - /// Creates three functions that can be used to implement the .NET Asynchronous + /// Creates three functions that can be used to implement the .NET 1.0 Asynchronous /// Programming Model (APM) for a given asynchronous computation. - /// - /// The functions should normally be published as members with prefix Begin, - /// End and Cancel, and can be used within a type definition as follows: - /// - /// let beginAction,endAction,cancelAction = Async.AsBeginEnd (fun arg -> computation) - /// member x.BeginSomeOperation(arg,callback,state:obj) = beginAction(arg,callback,state) - /// member x.EndSomeOperation(iar) = endAction(iar) - /// member x.CancelSomeOperation(iar) = cancelAction(iar) - /// - /// - /// If the asynchronous computation takes no arguments, then AsBeginEnd is used as follows: - /// - /// let beginAction,endAction,cancelAction = Async.AsBeginEnd (fun () -> computation) - /// member x.BeginSomeOperation(callback,state:obj) = beginAction((),callback,state) - /// member x.EndSomeOperation(iar) = endAction(iar) - /// member x.CancelSomeOperation(iar) = cancelAction(iar) - /// - /// - /// - /// If the asynchronous computation takes two arguments, then AsBeginEnd is used as follows: - /// - /// let beginAction,endAction,cancelAction = Async.AsBeginEnd (fun arg1 arg2 -> computation) - /// member x.BeginSomeOperation(arg1,arg2,callback,state:obj) = beginAction((),callback,state) - /// member x.EndSomeOperation(iar) = endAction(iar) - /// member x.CancelSomeOperation(iar) = cancelAction(iar) - /// - /// - /// In each case, the resulting API will be familiar to programmers in other CLI languages and - /// is a useful way to publish asynchronous computations in CLI components. + /// /// A function generating the asynchronous computation to split into the traditional /// .NET Asynchronous Programming Model. + /// /// A tuple of the begin, end, and cancel members. static member AsBeginEnd : computation:('Arg -> Async<'T>) -> // The 'Begin' member @@ -419,14 +436,18 @@ namespace Microsoft.FSharp.Control /// Creates an asynchronous computation that runs the given computation and ignores /// its result. + /// /// The input computation. + /// /// A computation that is equivalent to the input computation, but disregards the result. static member Ignore : computation: Async<'T> -> Async /// Runs an asynchronous computation, starting immediately on the current operating system /// thread. Call one of the three continuations when the operation completes. + /// /// If no cancellation token is provided then the default cancellation token /// is used. + /// /// The asynchronous computation to execute. /// The function called on success. /// The function called on exception. @@ -445,7 +466,9 @@ namespace Microsoft.FSharp.Control /// Runs an asynchronous computation, starting immediately on the current operating system /// thread. + /// /// If no cancellation token is provided then the default cancellation token is used. + /// /// The asynchronous computation to execute. /// The CancellationToken to associate with the computation. /// The default is used if this parameter is not provided. @@ -453,16 +476,19 @@ namespace Microsoft.FSharp.Control computation:Async * ?cancellationToken:CancellationToken-> unit /// Runs an asynchronous computation, starting immediately on the current operating system - /// thread, but also returns the execution as System.Threading.Tasks.Task + /// thread, but also returns the execution as /// + /// /// If no cancellation token is provided then the default cancellation token is used. /// You may prefer using this method if you want to achive a similar behviour to async await in C# as /// async computation starts on the current thread with an ability to return a result. /// + /// /// The asynchronous computation to execute. /// The CancellationToken to associate with the computation. /// The default is used if this parameter is not provided. - /// A System.Threading.Tasks.Task that will be completed + /// + /// A that will be completed /// in the corresponding state once the computation terminates (produces the result, throws exception or gets canceled) static member StartImmediateAsTask: computation:Async<'T> * ?cancellationToken:CancellationToken-> Task<'T> @@ -586,9 +612,11 @@ namespace Microsoft.FSharp.Control /// /// The existence of this method permits the use of for in the /// async { ... } computation expression syntax. + /// /// The sequence to enumerate. /// A function to take an item from the sequence and create /// an asynchronous computation. Can be seen as the body of the for expression. + /// /// An asynchronous computation that will enumerate the sequence and run body /// for each element. member For: sequence:seq<'T> * body:('T -> Async) -> Async @@ -609,8 +637,10 @@ namespace Microsoft.FSharp.Control /// /// The existence of this method permits the use of expression sequencing in the /// async { ... } computation expression syntax. + /// /// The first part of the sequenced computation. /// The second part of the sequenced computation. + /// /// An asynchronous computation that runs both of the computations sequentially. member inline Combine : computation1:Async * computation2:Async<'T> -> Async<'T> @@ -621,9 +651,11 @@ namespace Microsoft.FSharp.Control /// /// The existence of this method permits the use of while in the /// async { ... } computation expression syntax. + /// /// The function to determine when to stop executing computation. /// The function to be executed. Equivalent to the body /// of a while expression. + /// /// An asynchronous computation that behaves similarly to a while loop when run. member While : guard:(unit -> bool) * computation:Async -> Async @@ -633,7 +665,9 @@ namespace Microsoft.FSharp.Control /// /// The existence of this method permits the use of return in the /// async { ... } computation expression syntax. + /// /// The value to return from the computation. + /// /// An asynchronous computation that returns value when executed. member inline Return : value:'T -> Async<'T> @@ -641,14 +675,18 @@ namespace Microsoft.FSharp.Control /// /// The existence of this method permits the use of return! in the /// async { ... } computation expression syntax. + /// /// The input computation. + /// /// The input computation. member inline ReturnFrom : computation:Async<'T> -> Async<'T> /// Creates an asynchronous computation that runs generator. /// /// A cancellation check is performed when the computation is executed. + /// /// The function to run. + /// /// An asynchronous computation that runs generator. member Delay : generator:(unit -> Async<'T>) -> Async<'T> @@ -660,9 +698,11 @@ namespace Microsoft.FSharp.Control /// /// The existence of this method permits the use of use and use! in the /// async { ... } computation expression syntax. + /// /// The resource to be used and disposed. /// The function that takes the resource and returns an asynchronous /// computation. + /// /// An asynchronous computation that binds and eventually disposes resource. member Using: resource:'T * binder:('T -> Async<'U>) -> Async<'U> when 'T :> System.IDisposable @@ -673,8 +713,10 @@ namespace Microsoft.FSharp.Control /// /// The existence of this method permits the use of let! in the /// async { ... } computation expression syntax. + /// /// The computation to provide an unbound result. /// The function to bind the result of computation. + /// /// An asynchronous computation that performs a monadic bind on the result /// of computation. member inline Bind: computation: Async<'T> * binder: ('T -> Async<'U>) -> Async<'U> @@ -687,9 +729,11 @@ namespace Microsoft.FSharp.Control /// /// The existence of this method permits the use of try/finally in the /// async { ... } computation expression syntax. + /// /// The input computation. /// The action to be run after computation completes or raises an /// exception (including cancellation). + /// /// An asynchronous computation that executes computation and compensation afterwards or /// when an exception is raised. member inline TryFinally : computation:Async<'T> * compensation:(unit -> unit) -> Async<'T> @@ -704,6 +748,7 @@ namespace Microsoft.FSharp.Control /// /// The input computation. /// The function to run when computation throws an exception. + /// /// An asynchronous computation that executes computation and calls catchHandler if an /// exception is thrown. member inline TryWith : computation:Async<'T> * catchHandler:(exn -> Async<'T>) -> Async<'T> @@ -726,27 +771,32 @@ namespace Microsoft.FSharp.Control /// The buffer to read into. /// An optional offset as a number of bytes in the stream. /// An optional number of bytes to read from the stream. + /// /// An asynchronous computation that will read from the stream into the given buffer. - /// Thrown when the sum of offset and count is longer than + /// Thrown when the sum of offset and count is longer than /// the buffer length. - /// Thrown when offset or count is negative. + /// Thrown when offset or count is negative. [] // give the extension member a nice, unmangled compiled name, unique within this module member AsyncRead : buffer:byte[] * ?offset:int * ?count:int -> Async /// Returns an asynchronous computation that will read the given number of bytes from the stream. + /// /// The number of bytes to read. + /// /// An asynchronous computation that returns the read byte[] when run. [] // give the extension member a nice, unmangled compiled name, unique within this module member AsyncRead : count:int -> Async /// Returns an asynchronous computation that will write the given bytes to the stream. + /// /// The buffer to write from. /// An optional offset as a number of bytes in the stream. /// An optional number of bytes to write to the stream. + /// /// An asynchronous computation that will write the given bytes to the stream. - /// Thrown when the sum of offset and count is longer than + /// Thrown when the sum of offset and count is longer than /// the buffer length. - /// Thrown when offset or count is negative. + /// Thrown when offset or count is negative. [] // give the extension member a nice, unmangled compiled name, unique within this module member AsyncWrite : buffer:byte[] * ?offset:int * ?count:int -> Async @@ -755,6 +805,7 @@ namespace Microsoft.FSharp.Control type IObservable<'T> with /// Permanently connects a listener function to the observable. The listener will /// be invoked for each observation. + /// /// The function to be called for each observation. [] // give the extension member a nice, unmangled compiled name, unique within this module member Add: callback:('T -> unit) -> unit @@ -762,7 +813,9 @@ namespace Microsoft.FSharp.Control /// Connects a listener function to the observable. The listener will /// be invoked for each observation. The listener can be removed by /// calling Dispose on the returned IDisposable object. + /// /// The function to be called for each observation. + /// /// An object that will remove the listener if disposed. [] // give the extension member a nice, unmangled compiled name, unique within this module member Subscribe: callback:('T -> unit) -> System.IDisposable @@ -780,20 +833,26 @@ namespace Microsoft.FSharp.Control type System.Net.WebClient with /// Returns an asynchronous computation that, when run, will wait for the download of the given URI. + /// /// The URI to retrieve. + /// /// An asynchronous computation that will wait for the download of the URI. [] // give the extension member a nice, unmangled compiled name, unique within this module member AsyncDownloadString : address:System.Uri -> Async /// Returns an asynchronous computation that, when run, will wait for the download of the given URI. + /// /// The URI to retrieve. + /// /// An asynchronous computation that will wait for the download of the URI. [] // give the extension member a nice, unmangled compiled name, unique within this module member AsyncDownloadData : address:System.Uri -> Async /// Returns an asynchronous computation that, when run, will wait for the download of the given URI to specified file. + /// /// The URI to retrieve. /// The filename to save download to. + /// /// An asynchronous computation that will wait for the download of the URI to specified file. [] // give the extension member a nice, unmangled compiled name, unique within this module member AsyncDownloadFile : address:System.Uri * fileName: string -> Async diff --git a/src/fsharp/FSharp.Core/collections.fsi b/src/fsharp/FSharp.Core/collections.fsi index ad7f4363d1b0..8e3eab67a38f 100644 --- a/src/fsharp/FSharp.Core/collections.fsi +++ b/src/fsharp/FSharp.Core/collections.fsi @@ -20,6 +20,7 @@ namespace Microsoft.FSharp.Collections /// Compare using the given comparer function. /// A function to compare two values. + /// /// An object implementing IComparer using the supplied comparer. val FromFunction : comparer:('T -> 'T -> int) -> IComparer<'T> @@ -42,8 +43,10 @@ namespace Microsoft.FSharp.Collections val Reference<'T> : IEqualityComparer<'T> when 'T : not struct /// Hash using the given hashing and equality functions. + /// /// A function to generate a hash code from a value. /// A function to test equality of two values. + /// /// An object implementing IEqualityComparer using the supplied functions. // inline justification: allows inlining of hash functions diff --git a/src/fsharp/FSharp.Core/event.fsi b/src/fsharp/FSharp.Core/event.fsi index 23bc85ceea6b..dfc76ab434d4 100644 --- a/src/fsharp/FSharp.Core/event.fsi +++ b/src/fsharp/FSharp.Core/event.fsi @@ -27,6 +27,7 @@ namespace Microsoft.FSharp.Control /// The created event. new : unit -> Event<'Delegate,'Args> /// Triggers the event using the given sender object and parameters. The sender object may be null. + /// /// The object triggering the event. /// The parameters for the event. member Trigger : sender:obj * args:'Args -> unit @@ -41,6 +42,7 @@ namespace Microsoft.FSharp.Control /// The created event. new : unit -> Event<'T> /// Triggers an observation using the given parameters. + /// /// The event parameters. member Trigger : arg:'T -> unit /// Publishes an observation as a first class value. diff --git a/src/fsharp/FSharp.Core/eventmodule.fsi b/src/fsharp/FSharp.Core/eventmodule.fsi index c3f5f3cc9fb4..54a0c4057c8c 100644 --- a/src/fsharp/FSharp.Core/eventmodule.fsi +++ b/src/fsharp/FSharp.Core/eventmodule.fsi @@ -12,21 +12,26 @@ namespace Microsoft.FSharp.Control /// Fires the output event when either of the input events fire. /// The first input event. /// The second input event. + /// /// An event that fires when either of the input events fire. [] val merge: event1:IEvent<'Del1,'T> -> event2:IEvent<'Del2,'T> -> IEvent<'T> /// Returns a new event that passes values transformed by the given function. + /// /// The function to transform event values. /// The input event. + /// /// An event that passes the transformed values. [] val map: mapping:('T -> 'U) -> sourceEvent:IEvent<'Del,'T> -> IEvent<'U> /// Returns a new event that listens to the original event and triggers the resulting /// event only when the argument to the event passes the given function. + /// /// The function to determine which triggers from the event to propagate. /// The input event. + /// /// An event that only passes values that pass the predicate. [] val filter: predicate:('T -> bool) -> sourceEvent:IEvent<'Del,'T> -> IEvent<'T> @@ -34,8 +39,10 @@ namespace Microsoft.FSharp.Control /// Returns a new event that listens to the original event and triggers the /// first resulting event if the application of the predicate to the event arguments /// returned true, and the second event if it returned false. + /// /// The function to determine which output event to trigger. /// The input event. + /// /// A tuple of events. The first is triggered when the predicate evaluates to true /// and the second when the predicate evaluates to false. [] @@ -44,8 +51,10 @@ namespace Microsoft.FSharp.Control /// Returns a new event that listens to the original event and triggers the /// first resulting event if the application of the function to the event arguments /// returned a Choice1Of2, and the second event if it returns a Choice2Of2. + /// /// The function to transform event values into one of two types. /// The input event. + /// /// A tuple of events. The first fires whenever splitter evaluates to Choice1of1 and /// the second fires whenever splitter evaluates to Choice2of2. [] @@ -53,8 +62,10 @@ namespace Microsoft.FSharp.Control /// Returns a new event which fires on a selection of messages from the original event. /// The selection function takes an original message to an optional new message. + /// /// The function to select and transform event values to pass on. /// The input event. + /// /// An event that fires only when the chooser returns Some. [] val choose: chooser:('T -> 'U option) -> sourceEvent:IEvent<'Del,'T> -> IEvent<'U> @@ -65,13 +76,16 @@ namespace Microsoft.FSharp.Control /// records the current value of the state parameter. The internal state is not locked during the /// execution of the accumulation function, so care should be taken that the /// input IEvent not triggered by multiple threads simultaneously. + /// /// The function to update the state with each event value. /// The initial state. /// The input event. + /// /// An event that fires on the updated state values. val scan: collector:('U -> 'T -> 'U) -> state:'U -> sourceEvent:IEvent<'Del,'T> -> IEvent<'U> /// Runs the given function each time the given event is triggered. + /// /// The function to call when the event is triggered. /// The input event. [] @@ -81,7 +95,9 @@ namespace Microsoft.FSharp.Control /// The Nth triggering of the input event passes the arguments from the N-1th and Nth triggering as /// a pair. The argument passed to the N-1th triggering is held in hidden internal state until the /// Nth triggering occurs. + /// /// The input event. + /// /// An event that triggers on pairs of consecutive values passed from the source event. [] val pairwise: sourceEvent:IEvent<'Del,'T> -> IEvent<'T * 'T> diff --git a/src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi b/src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi index 6b43ddef90a1..c1ef9149ae5a 100644 --- a/src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi +++ b/src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi @@ -4,6 +4,7 @@ namespace Microsoft.FSharp.Core [] +/// A set of extra operators and functions. This module is opened by default when compiling all F# code. module ExtraTopLevelOperators = open System @@ -14,57 +15,74 @@ module ExtraTopLevelOperators = /// Print to stdout using the given format. /// The formatter. + /// /// The formatted result. [] - val printf : format:Printf.TextWriterFormat<'T> -> 'T + val printf: format:Printf.TextWriterFormat<'T> -> 'T /// Print to stdout using the given format, and add a newline. + /// /// The formatter. + /// /// The formatted result. [] - val printfn : format:Printf.TextWriterFormat<'T> -> 'T + val printfn: format:Printf.TextWriterFormat<'T> -> 'T /// Print to stderr using the given format. + /// /// The formatter. + /// /// The formatted result. [] - val eprintf : format:Printf.TextWriterFormat<'T> -> 'T + val eprintf: format:Printf.TextWriterFormat<'T> -> 'T /// Print to stderr using the given format, and add a newline. + /// /// The formatter. + /// /// The formatted result. [] - val eprintfn : format:Printf.TextWriterFormat<'T> -> 'T + val eprintfn: format:Printf.TextWriterFormat<'T> -> 'T /// Print to a string using the given format. + /// /// The formatter. + /// /// The formatted result. [] - val sprintf : format:Printf.StringFormat<'T> -> 'T + val sprintf: format:Printf.StringFormat<'T> -> 'T /// Print to a string buffer and raise an exception with the given - /// result. Helper printers must return strings. + /// result. Helper printers must return strings. + /// /// The formatter. + /// /// The formatted result. [] val failwithf: format:Printf.StringFormat<'T,'Result> -> 'T /// Print to a file using the given format. + /// /// The file TextWriter. /// The formatter. + /// /// The formatted result. [] val fprintf : textWriter:System.IO.TextWriter -> format:Printf.TextWriterFormat<'T> -> 'T /// Print to a file using the given format, and add a newline. + /// /// The file TextWriter. /// The formatter. + /// /// The formatted result. [] val fprintfn : textWriter:System.IO.TextWriter -> format:Printf.TextWriterFormat<'T> -> 'T /// Builds a set from a sequence of objects. The objects are indexed using generic comparison. + /// /// The input sequence of elements. + /// /// The created set. [] val set : elements:seq<'T> -> Set<'T> @@ -285,7 +303,9 @@ namespace Microsoft.FSharp.Core.CompilerServices /// /// Get the static parameters for a provided type. /// + /// /// A type returned by GetTypes or ResolveTypeName + /// /// abstract GetStaticParameters : typeWithoutArguments:Type -> ParameterInfo[] @@ -296,14 +316,17 @@ namespace Microsoft.FSharp.Core.CompilerServices /// the provided type definition which has static parameters /// the full path of the type, including encoded representations of static parameters /// the static parameters, indexed by name + /// /// abstract ApplyStaticArguments : typeWithoutArguments:Type * typePathWithArguments:string[] * staticArguments:obj[] -> Type /// /// Called by the compiler to ask for an Expression tree to replace the given MethodBase with. /// + /// /// MethodBase that was given to the compiler by a type returned by a GetType(s) call. /// Expressions that represent the parameters to this call. + /// /// An expression that the compiler will use in place of the given method base. abstract GetInvokerExpression : syntheticMethodBase:MethodBase * parameters:Expr[] -> Expr @@ -324,7 +347,9 @@ namespace Microsoft.FSharp.Core.CompilerServices /// /// Get the static parameters for a provided method. /// + /// /// A method returned by GetMethod on a provided type + /// /// The static parameters of the provided method, if any abstract GetStaticParametersForMethod : methodWithoutArguments:MethodBase -> ParameterInfo[] @@ -336,6 +361,7 @@ namespace Microsoft.FSharp.Core.CompilerServices /// the provided method definition which has static parameters /// the full name of the method that must be returned, including encoded representations of static parameters /// the values of the static parameters, indexed by name + /// /// The provided method definition corresponding to the given static parameter values abstract ApplyStaticArgumentsForMethod : methodWithoutArguments:MethodBase * methodNameWithArguments:string * staticArguments:obj[] -> MethodBase diff --git a/src/fsharp/FSharp.Core/list.fsi b/src/fsharp/FSharp.Core/list.fsi index 26c5dad94e18..28acfb823c10 100644 --- a/src/fsharp/FSharp.Core/list.fsi +++ b/src/fsharp/FSharp.Core/list.fsi @@ -7,31 +7,37 @@ namespace Microsoft.FSharp.Collections open Microsoft.FSharp.Core open Microsoft.FSharp.Collections - /// Basic operations on lists. + /// Basic operations for values of type . [] [] module List = /// Returns a new list that contains all pairings of elements from the first and second lists. + /// /// The first input list. /// The second input list. + /// /// The resulting list of pairs. [] val allPairs: list1:'T1 list -> list2:'T2 list -> ('T1 * 'T2) list /// Returns a new list that contains the elements of the first list /// followed by elements of the second. + /// /// The first input list. /// The second input list. + /// /// The resulting list. [] val append: list1:'T list -> list2:'T list -> 'T list /// Returns the average of the elements in the list. /// - /// Raises System.ArgumentException if list is empty. + /// Raises if list is empty. /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The resulting average. [] val inline average : list:^T list -> ^T @@ -41,10 +47,12 @@ namespace Microsoft.FSharp.Collections /// Returns the average of the elements generated by applying the function to each element of the list. /// - /// Raises System.ArgumentException if list is empty. + /// Raises if list is empty. /// The function to transform the list elements into the type to be averaged. /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The resulting average. [] val inline averageBy : projection:('T -> ^U) -> list:'T list -> ^U @@ -55,23 +63,30 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to each element of the list. Returns /// the list comprised of the results x for each element where /// the function returns Some(x) + /// /// The function to generate options from the elements. /// The input list. + /// /// The list comprising the values selected from the chooser function. [] val choose: chooser:('T -> 'U option) -> list:'T list -> 'U list /// Divides the input list into chunks of size at most chunkSize. + /// /// The maximum size of each chunk. /// The input list. + /// /// The list divided into chunks. - /// Thrown when chunkSize is not positive. + /// + /// Thrown when chunkSize is not positive. [] val chunkBySize: chunkSize:int -> list:'T list -> 'T list list /// For each element of the list, applies the given function. Concatenates all the results and return the combined list. + /// /// The function to transform each input element into a sublist to be concatenated. /// The input list. + /// /// The concatenation of the transformed sublists. [] val collect: mapping:('T -> 'U list) -> list:'T list -> 'U list @@ -92,14 +107,18 @@ namespace Microsoft.FSharp.Collections val inline compareWith: comparer:('T -> 'T -> int) -> list1:'T list -> list2:'T list -> int /// Returns a new list that contains the elements of each the lists in order. + /// /// The input sequence of lists. + /// /// The resulting concatenated list. [] val concat: lists:seq<'T list> -> 'T list /// Tests if the list contains the specified element. + /// /// The value to locate in the input list. /// The input list. + /// /// True if the input list contains the specified element; false otherwise. [] val inline contains: value:'T -> source:'T list -> bool when 'T : equality @@ -137,10 +156,13 @@ namespace Microsoft.FSharp.Collections val countBy : projection:('T -> 'Key) -> list:'T list -> ('Key * int) list when 'Key : equality /// Splits the input list into at most count chunks. + /// /// The maximum number of chunks. /// The input list. + /// /// The list split into chunks. - /// Thrown when count is not positive. + /// + /// Thrown when count is not positive. [] val splitInto: count:int -> list:'T list -> 'T list list @@ -158,7 +180,7 @@ namespace Microsoft.FSharp.Collections /// /// A list that contains the distinct elements of list that do not appear in itemsToExclude. /// - /// Thrown when itemsToExclude is null. + /// Thrown when itemsToExclude is null. [] val except: itemsToExclude:seq<'T> -> list:'T list -> 'T list when 'T : equality @@ -168,7 +190,7 @@ namespace Microsoft.FSharp.Collections /// /// The only element of the list. /// - /// Thrown when the input does not have precisely one element. + /// Thrown when the input does not have precisely one element. [] val exactlyOne: list:'T list -> 'T @@ -187,6 +209,7 @@ namespace Microsoft.FSharp.Collections /// Otherwise, false is returned. /// The function to test the input elements. /// The input list. + /// /// True if any element satisfies the predicate. [] val exists: predicate:('T -> bool) -> list:'T list -> bool @@ -196,32 +219,41 @@ namespace Microsoft.FSharp.Collections /// The predicate is applied to matching elements in the two collections up to the lesser of the /// two lengths of the collections. If any application returns true then the overall result is /// true and no further elements are tested. Otherwise, if one collections is longer - /// than the other then the System.ArgumentException exception is raised. + /// than the other then the exception is raised. /// Otherwise, false is returned. + /// /// The function to test the input elements. /// The first input list. /// The second input list. - /// Thrown when the input lists differ in length. + /// + /// Thrown when the input lists differ in length. + /// /// True if any pair of elements satisfy the predicate. [] val exists2: predicate:('T1 -> 'T2 -> bool) -> list1:'T1 list -> list2:'T2 list -> bool /// Returns the first element for which the given function returns True. /// Raises KeyNotFoundException if no such element exists. + /// /// The function to test the input elements. /// The input list. - /// Thrown if the predicate evaluates to false for + /// + /// Thrown if the predicate evaluates to false for /// all the elements of the list. + /// /// The first element that satisfies the predicate. [] val find: predicate:('T -> bool) -> list:'T list -> 'T /// Returns the last element for which the given function returns True. /// Raises KeyNotFoundException if no such element exists. + /// /// The function to test the input elements. /// The input list. - /// Thrown if the predicate evaluates to false for + /// + /// Thrown if the predicate evaluates to false for /// all the elements of the list. + /// /// The last element that satisfies the predicate. [] val findBack: predicate:('T -> bool) -> list:'T list -> 'T @@ -229,10 +261,13 @@ namespace Microsoft.FSharp.Collections /// Returns the index of the first element in the list /// that satisfies the given predicate. /// Raises KeyNotFoundException if no such element exists. + /// /// The function to test the input elements. /// The input list. - /// Thrown if the predicate evaluates to false for all the + /// + /// Thrown if the predicate evaluates to false for all the /// elements of the list. + /// /// The index of the first element that satisfies the predicate. [] val findIndex: predicate:('T -> bool) -> list:'T list -> int @@ -240,18 +275,23 @@ namespace Microsoft.FSharp.Collections /// Returns the index of the last element in the list /// that satisfies the given predicate. /// Raises KeyNotFoundException if no such element exists. + /// /// The function to test the input elements. /// The input list. - /// Thrown if the predicate evaluates to false for all the + /// + /// Thrown if the predicate evaluates to false for all the /// elements of the list. + /// /// The index of the last element that satisfies the predicate. [] val findIndexBack: predicate:('T -> bool) -> list:'T list -> int /// Returns a new collection containing only the elements of the collection /// for which the given predicate returns "true" + /// /// The function to test the input elements. /// The input list. + /// /// A list containing only the elements that satisfy the predicate. [] val filter: predicate:('T -> bool) -> list:'T list -> 'T list @@ -262,9 +302,11 @@ namespace Microsoft.FSharp.Collections /// with the second element and so on. Return the final result. /// If the input function is f and the elements are i0...iN then /// computes f (... (f s i0) i1 ...) iN. + /// /// The function to update the state given the input elements. /// The initial state. /// The input list. + /// /// The final state value. [] val fold<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State @@ -273,10 +315,12 @@ namespace Microsoft.FSharp.Collections /// through the computation. The collections must have identical sizes. /// If the input function is f and the elements are i0...iN and j0...jN /// then computes f (... (f s i0 j0)...) iN jN. + /// /// The function to update the state given the input elements. /// The initial state. /// The first input list. /// The second input list. + /// /// The final state value. [] val fold2<'T1,'T2,'State> : folder:('State -> 'T1 -> 'T2 -> 'State) -> state:'State -> list1:'T1 list -> list2:'T2 list -> 'State @@ -284,9 +328,11 @@ namespace Microsoft.FSharp.Collections /// Applies a function to each element of the collection, starting from the end, threading an accumulator argument /// through the computation. If the input function is f and the elements are i0...iN then /// computes f i0 (...(f iN s)). + /// /// The function to update the state given the input elements. /// The input list. /// The initial state. + /// /// The state object after the folding function is applied to each element of the list. [] val foldBack<'T,'State> : folder:('T -> 'State -> 'State) -> list:'T list -> state:'State -> 'State @@ -295,10 +341,12 @@ namespace Microsoft.FSharp.Collections /// through the computation. The collections must have identical sizes. /// If the input function is f and the elements are i0...iN and j0...jN /// then computes f i0 j0 (...(f iN jN s)). + /// /// The function to update the state given the input elements. /// The first input list. /// The second input list. /// The initial state. + /// /// The final state value. [] val foldBack2<'T1,'T2,'State> : folder:('T1 -> 'T2 -> 'State -> 'State) -> list1:'T1 list -> list2:'T2 list -> state:'State -> 'State @@ -310,6 +358,7 @@ namespace Microsoft.FSharp.Collections /// Otherwise, true is returned. /// The function to test the input elements. /// The input list. + /// /// True if all of the elements satisfy the predicate. [] val forall: predicate:('T -> bool) -> list:'T list -> bool @@ -319,12 +368,14 @@ namespace Microsoft.FSharp.Collections /// The predicate is applied to matching elements in the two collections up to the lesser of the /// two lengths of the collections. If any application returns false then the overall result is /// false and no further elements are tested. Otherwise, if one collection is longer - /// than the other then the System.ArgumentException exception is raised. + /// than the other then the exception is raised. /// Otherwise, true is returned. /// The function to test the input elements. /// The first input list. /// The second input list. - /// Thrown when the input lists differ in length. + /// + /// Thrown when the input lists differ in length. + /// /// True if all of the pairs of elements satisfy the predicate. [] val forall2: predicate:('T1 -> 'T2 -> bool) -> list1:'T1 list -> list2:'T2 list -> bool @@ -343,40 +394,52 @@ namespace Microsoft.FSharp.Collections /// Returns the first element of the list. /// /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The first element of the list. [] val head: list:'T list -> 'T /// Returns a new list whose elements are the corresponding elements /// of the input list paired with the index (from 0) of each element. + /// /// The input list. + /// /// The list of indexed elements. [] val indexed: list:'T list -> (int * 'T) list /// Creates a list by calling the given generator on each index. + /// /// The length of the list to generate. /// The function to generate an element from an index. + /// /// The list of generated elements. [] val init: length:int -> initializer:(int -> 'T) -> 'T list /// Returns true if the list contains no elements, false otherwise. + /// /// The input list. + /// /// True if the list is empty. [] val isEmpty: list:'T list -> bool /// Indexes into the list. The first element has index 0. + /// /// The index to retrieve. /// The input list. + /// /// The value at the given index. - /// Thrown when the index is negative or the input list does not contain enough elements. + /// + /// Thrown when the index is negative or the input list does not contain enough elements. [] val item: index:int -> list:'T list -> 'T /// Applies the given function to each element of the collection. + /// /// The function to apply to elements from the input list. /// The input list. [] @@ -384,6 +447,7 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to two collections simultaneously. The /// collections must have identical size. + /// /// The function to apply to pairs of elements from the input lists. /// The first input list. /// The second input list. @@ -392,6 +456,7 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to each element of the collection. The integer passed to the /// function indicates the index of element. + /// /// The function to apply to the elements of the list along with their index. /// The input list. [] @@ -400,6 +465,7 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to two collections simultaneously. The /// collections must have identical size. The integer passed to the /// function indicates the index of element. + /// /// The function to apply to a pair of elements from the input lists along with their index. /// The first input list. /// The second input list. @@ -407,66 +473,83 @@ namespace Microsoft.FSharp.Collections val iteri2: action:(int -> 'T1 -> 'T2 -> unit) -> list1:'T1 list -> list2:'T2 list -> unit /// Returns the last element of the list. + /// /// The input list. + /// /// The last element of the list. - /// Thrown when the input does not have any elements. + /// + /// Thrown when the input does not have any elements. [] val last: list:'T list -> 'T /// Returns the length of the list. + /// /// The input list. + /// /// The length of the list. [] val length: list:'T list -> int /// Returns the last element of the list. /// Return None if no such element exists. + /// /// The input list. + /// /// The last element of the list or None. [] val tryLast: list:'T list -> 'T option /// Builds a new collection whose elements are the results of applying the given function /// to each of the elements of the collection. + /// /// The function to transform elements from the input list. /// The input list. + /// /// The list of transformed elements. [] val map: mapping:('T -> 'U) -> list:'T list -> 'U list /// Builds a new collection whose elements are the results of applying the given function /// to the corresponding elements of the two collections pairwise. + /// /// The function to transform pairs of elements from the input lists. /// The first input list. /// The second input list. + /// /// The list of transformed elements. [] val map2: mapping:('T1 -> 'T2 -> 'U) -> list1:'T1 list -> list2:'T2 list -> 'U list /// Builds a new collection whose elements are the results of applying the given function /// to the corresponding elements of the three collections simultaneously. + /// /// The function to transform triples of elements from the input lists. /// The first input list. /// The second input list. /// The third input list. + /// /// The list of transformed elements. [] val map3: mapping:('T1 -> 'T2 -> 'T3 -> 'U) -> list1:'T1 list -> list2:'T2 list -> list3:'T3 list -> 'U list /// Combines map and fold. Builds a new list whose elements are the results of applying the given function /// to each of the elements of the input list. The function is also used to accumulate a final value. + /// /// The function to transform elements from the input list and accumulate the final value. /// The initial state. /// The input list. + /// /// The list of transformed elements, and the final accumulated value. [] val mapFold<'T,'State,'Result> : mapping:('State -> 'T -> 'Result * 'State) -> state:'State -> list:'T list -> 'Result list * 'State /// Combines map and foldBack. Builds a new list whose elements are the results of applying the given function /// to each of the elements of the input list. The function is also used to accumulate a final value. + /// /// The function to transform elements from the input list and accumulate the final value. /// The input list. /// The initial state. + /// /// The list of transformed elements, and the final accumulated value. [] val mapFoldBack<'T,'State,'Result> : mapping:('T -> 'State -> 'Result * 'State) -> list:'T list -> state:'State -> 'Result list * 'State @@ -474,75 +557,94 @@ namespace Microsoft.FSharp.Collections /// Builds a new collection whose elements are the results of applying the given function /// to each of the elements of the collection. The integer index passed to the /// function indicates the index (from 0) of element being transformed. + /// /// The function to transform elements and their indices. /// The input list. + /// /// The list of transformed elements. [] val mapi: mapping:(int -> 'T -> 'U) -> list:'T list -> 'U list /// Like mapi, but mapping corresponding elements from two lists of equal length. + /// /// The function to transform pairs of elements from the two lists and their index. /// The first input list. /// The second input list. + /// /// The list of transformed elements. [] val mapi2: mapping:(int -> 'T1 -> 'T2 -> 'U) -> list1:'T1 list -> list2:'T2 list -> 'U list /// Return the greatest of all elements of the list, compared via Operators.max. /// - /// Raises System.ArgumentException if list is empty + /// Raises if list is empty /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The maximum element. [] val inline max : list:'T list -> 'T when 'T : comparison /// Returns the greatest of all elements of the list, compared via Operators.max on the function result. /// - /// Raises System.ArgumentException if list is empty. + /// Raises if list is empty. /// The function to transform the list elements into the type to be compared. /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The maximum element. [] val inline maxBy : projection:('T -> 'U) -> list:'T list -> 'T when 'U : comparison /// Returns the lowest of all elements of the list, compared via Operators.min. /// - /// Raises System.ArgumentException if list is empty + /// Raises if list is empty /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The minimum value. [] val inline min : list:'T list -> 'T when 'T : comparison /// Returns the lowest of all elements of the list, compared via Operators.min on the function result /// - /// Raises System.ArgumentException if list is empty. + /// Raises if list is empty. /// The function to transform list elements into the type to be compared. /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The minimum value. [] val inline minBy : projection:('T -> 'U) -> list:'T list -> 'T when 'U : comparison /// Indexes into the list. The first element has index 0. + /// /// The input list. /// The index to retrieve. + /// /// The value at the given index. - /// Thrown when the index is negative or the input list does not contain enough elements. + /// + /// Thrown when the index is negative or the input list does not contain enough elements. [] [] val nth: list:'T list -> index:int -> 'T /// Builds a list from the given array. + /// /// The input array. + /// /// The list of elements from the array. [] val ofArray : array:'T[] -> 'T list /// Builds a new list from the given enumerable object. + /// /// The input sequence. + /// /// The list of elements from the sequence. [] val ofSeq: source:seq<'T> -> 'T list @@ -559,8 +661,10 @@ namespace Microsoft.FSharp.Collections /// Splits the collection into two collections, containing the /// elements for which the given predicate returns True and False /// respectively. Element order is preserved in both of the created lists. + /// /// The function to test the input elements. /// The input list. + /// /// A list containing the elements for which the predicate evaluated to false and a list /// containing the elements for which the predicate evaluated to true. [] @@ -568,20 +672,26 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to successive elements, returning the first /// result where function returns Some(x) for some x. If no such - /// element exists then raise System.Collections.Generic.KeyNotFoundException + /// element exists then raise + /// /// The function to generate options from the elements. /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The first resulting value. [] val pick: chooser:('T -> 'U option) -> list:'T list -> 'U /// Returns a list with all elements permuted according to the /// specified permutation. + /// /// The function to map input indices to output indices. /// The input list. + /// /// The permuted list. - /// Thrown when indexMap does not produce a valid permutation. + /// + /// Thrown when indexMap does not produce a valid permutation. [] val permute : indexMap:(int -> int) -> list:'T list -> 'T list @@ -591,10 +701,13 @@ namespace Microsoft.FSharp.Collections /// Return the final result. If the input function is f and the elements are i0...iN then computes /// f (... (f i0 i1) i2 ...) iN. /// - /// Raises System.ArgumentException if list is empty + /// Raises if list is empty + /// /// The function to reduce two list elements to a single element. /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The final reduced value. [] val reduce: reduction:('T -> 'T -> 'T) -> list:'T list -> 'T @@ -602,23 +715,30 @@ namespace Microsoft.FSharp.Collections /// Applies a function to each element of the collection, starting from the end, threading an accumulator argument /// through the computation. If the input function is f and the elements are i0...iN then computes /// f i0 (...(f iN-1 iN)). + /// /// A function that takes in the next-to-last element of the list and the /// current accumulated result to produce the next accumulated result. /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The final result of the reductions. [] val reduceBack: reduction:('T -> 'T -> 'T) -> list:'T list -> 'T /// Creates a list by replicating the given initial value. + /// /// The number of elements to replicate. /// The value to replicate + /// /// The generated list. [] val replicate: count:int -> initial:'T -> 'T list /// Returns a new list with the elements in reverse order. + /// /// The input list. + /// /// The reversed list. [] val rev: list:'T list -> 'T list @@ -627,17 +747,21 @@ namespace Microsoft.FSharp.Collections /// through the computation. Take the second argument, and apply the function to it /// and the first element of the list. Then feed this result into the function along /// with the second element and so on. Returns the list of intermediate results and the final result. + /// /// The function to update the state given the input elements. /// The initial state. /// The input list. + /// /// The list of states. [] val scan<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State list /// Like foldBack, but returns both the intermediary and final results + /// /// The function to update the state given the input elements. /// The input list. /// The initial state. + /// /// The list of states. [] val scanBack<'T,'State> : folder:('T -> 'State -> 'State) -> list:'T list -> state:'State -> 'State list @@ -651,18 +775,23 @@ namespace Microsoft.FSharp.Collections val inline singleton: value:'T -> 'T list /// Returns the list after removing the first N elements. + /// /// The number of elements to skip. /// The input list. + /// /// The list after removing the first N elements. - /// Thrown when count is negative or exceeds the number of + /// + /// Thrown when count is negative or exceeds the number of /// elements in the list. [] val skip: count:int -> list: 'T list -> 'T list /// Bypasses elements in a list while the given predicate returns True, and then returns /// the remaining elements of the list. + /// /// A function that evaluates an element of the list to a boolean value. /// The input list. + /// /// The result list. [] val skipWhile: predicate:('T -> bool) -> list:'T list -> 'T list @@ -672,6 +801,7 @@ namespace Microsoft.FSharp.Collections /// This is a stable sort, i.e. the original order of equal elements is preserved. /// The function to compare the list elements. /// The input list. + /// /// The sorted list. [] val sortWith: comparer:('T -> 'T -> int) -> list:'T list -> 'T list @@ -681,6 +811,7 @@ namespace Microsoft.FSharp.Collections /// This is a stable sort, i.e. the original order of equal elements is preserved. /// The function to transform the list elements into the type to be compared. /// The input list. + /// /// The sorted list. [] val sortBy: projection:('T -> 'Key) -> list:'T list -> 'T list when 'Key : comparison @@ -689,16 +820,19 @@ namespace Microsoft.FSharp.Collections /// /// This is a stable sort, i.e. the original order of equal elements is preserved. /// The input list. + /// /// The sorted list. [] val sort: list:'T list -> 'T list when 'T : comparison /// Splits a list into two lists, at the given index. + /// /// The index at which the list is split. /// The input list. + /// /// The two split lists. /// - /// Thrown when split index exceeds the number of elements + /// Thrown when split index exceeds the number of elements /// in the list. [] val splitAt: index:int -> list:'T list -> ('T list * 'T list) @@ -708,6 +842,7 @@ namespace Microsoft.FSharp.Collections /// This is a stable sort, i.e. the original order of equal elements is preserved. /// The function to transform the list elements into the type to be compared. /// The input list. + /// /// The sorted list. [] val inline sortByDescending: projection:('T -> 'Key) -> list:'T list -> 'T list when 'Key : comparison @@ -716,12 +851,15 @@ namespace Microsoft.FSharp.Collections /// /// This is a stable sort, i.e. the original order of equal elements is preserved. /// The input list. + /// /// The sorted list. [] val inline sortDescending: list:'T list -> 'T list when 'T : comparison /// Returns the sum of the elements in the list. + /// /// The input list. + /// /// The resulting sum. [] val inline sum : list:^T list -> ^T @@ -729,8 +867,10 @@ namespace Microsoft.FSharp.Collections and ^T : (static member Zero : ^T) /// Returns the sum of the results generated by applying the function to each element of the list. + /// /// The function to transform the list elements into the type to be summed. /// The input list. + /// /// The resulting sum. [] val inline sumBy : projection:('T -> ^U) -> list:'T list -> ^U @@ -740,7 +880,9 @@ namespace Microsoft.FSharp.Collections /// Returns the list after removing the first element. /// /// The input list. - /// Thrown when the list is empty. + /// + /// Thrown when the list is empty. + /// /// The list after removing the first element. [] val tail: list:'T list -> 'T list @@ -755,8 +897,8 @@ namespace Microsoft.FSharp.Collections /// /// The result list. /// - /// Thrown when the input list is empty. - /// Thrown when count exceeds the number of elements + /// Thrown when the input list is empty. + /// Thrown when count exceeds the number of elements /// in the list. [] val take: count:int -> list:'T list -> 'T list @@ -772,35 +914,46 @@ namespace Microsoft.FSharp.Collections val takeWhile: predicate:('T -> bool) -> list:'T list -> 'T list /// Builds an array from the given list. + /// /// The input list. + /// /// The array containing the elements of the list. [] val toArray: list:'T list -> 'T[] /// Views the given list as a sequence. + /// /// The input list. + /// /// The sequence of elements in the list. [] val toSeq: list:'T list -> seq<'T> /// Returns the first element of the list, or /// None if the list is empty. + /// /// The input list. + /// /// The first element of the list or None. [] val tryHead: list:'T list -> 'T option /// Returns the transpose of the given sequence of lists. + /// /// The input sequence of list. + /// /// The transposed list. - /// Thrown when the input sequence is null. - /// Thrown when the input lists differ in length. + /// + /// Thrown when the input sequence is null. + /// Thrown when the input lists differ in length. [] val transpose: lists:seq<'T list> -> 'T list list /// Returns at most N elements in a new list. + /// /// The maximum number of items to return. /// The input list. + /// /// The result list. [] val truncate: count:int -> list:'T list -> 'T list @@ -808,16 +961,20 @@ namespace Microsoft.FSharp.Collections /// Applies the given function to successive elements, returning Some(x) the first /// result where function returns Some(x) for some x. If no such element /// exists then return None. + /// /// The function to generate options from the elements. /// The input list. + /// /// The first resulting value or None. [] val tryPick: chooser:('T -> 'U option) -> list:'T list -> 'U option /// Returns the first element for which the given function returns True. /// Return None if no such element exists. + /// /// The function to test the input elements. /// The input list. + /// /// The first element for which the predicate returns true, or None if /// every element evaluates to false. [] @@ -825,8 +982,10 @@ namespace Microsoft.FSharp.Collections /// Returns the last element for which the given function returns True. /// Return None if no such element exists. + /// /// The function to test the input elements. /// The input list. + /// /// The last element for which the predicate returns true, or None if /// every element evaluates to false. [] @@ -835,8 +994,10 @@ namespace Microsoft.FSharp.Collections /// Returns the index of the first element in the list /// that satisfies the given predicate. /// Return None if no such element exists. + /// /// The function to test the input elements. /// The input list. + /// /// The index of the first element for which the predicate returns true, or None if /// every element evaluates to false. [] @@ -844,8 +1005,10 @@ namespace Microsoft.FSharp.Collections /// Tries to find the nth element in the list. /// Returns None if index is negative or the list does not contain enough elements. + /// /// The index to retrieve. /// The input list. + /// /// The value at the given index or None. [] val tryItem: index:int -> list:'T list -> 'T option @@ -853,8 +1016,10 @@ namespace Microsoft.FSharp.Collections /// Returns the index of the last element in the list /// that satisfies the given predicate. /// Return None if no such element exists. + /// /// The function to test the input elements. /// The input list. + /// /// The index of the last element for which the predicate returns true, or None if /// every element evaluates to false. [] @@ -862,53 +1027,68 @@ namespace Microsoft.FSharp.Collections /// Returns a list that contains the elements generated by the given computation. /// The given initial state argument is passed to the element generator. + /// /// A function that takes in the current state and returns an option tuple of the next /// element of the list and the next state value. /// The initial state value. + /// /// The result list. [] val unfold<'T,'State> : generator:('State -> ('T * 'State) option) -> state:'State -> 'T list /// Splits a list of pairs into two lists. + /// /// The input list. + /// /// Two lists of split elements. [] val unzip: list:('T1 * 'T2) list -> ('T1 list * 'T2 list) /// Splits a list of triples into three lists. + /// /// The input list. + /// /// Three lists of split elements. [] val unzip3: list:('T1 * 'T2 * 'T3) list -> ('T1 list * 'T2 list * 'T3 list) /// Returns a new list containing only the elements of the list /// for which the given predicate returns "true" + /// /// The function to test the input elements. /// The input list. + /// /// A list containing only the elements that satisfy the predicate. [] val where: predicate:('T -> bool) -> list:'T list -> 'T list /// Returns a list of sliding windows containing elements drawn from the input /// list. Each window is returned as a fresh list. + /// /// The number of elements in each window. /// The input list. + /// /// The result list. - /// Thrown when windowSize is not positive. + /// + /// Thrown when windowSize is not positive. [] val windowed : windowSize:int -> list:'T list -> 'T list list /// Combines the two lists into a list of pairs. The two lists must have equal lengths. + /// /// The first input list. /// The second input list. + /// /// A single list containing pairs of matching elements from the input lists. [] val zip: list1:'T1 list -> list2:'T2 list -> ('T1 * 'T2) list /// Combines the three lists into a list of triples. The lists must have equal lengths. + /// /// The first input list. /// The second input list. /// The third input list. + /// /// A single list containing triples of matching elements from the input lists. [] val zip3: list1:'T1 list -> list2:'T2 list -> list3:'T3 list -> ('T1 * 'T2 * 'T3) list diff --git a/src/fsharp/FSharp.Core/mailbox.fsi b/src/fsharp/FSharp.Core/mailbox.fsi index 6d818299e065..65e31a192c6f 100644 --- a/src/fsharp/FSharp.Core/mailbox.fsi +++ b/src/fsharp/FSharp.Core/mailbox.fsi @@ -28,23 +28,28 @@ namespace Microsoft.FSharp.Control /// Creates an agent. The body function is used to generate the asynchronous /// computation executed by the agent. This function is not executed until /// Start is called. + /// /// The function to produce an asynchronous computation that will be executed /// as the read loop for the MailboxProcessor when Start is called. /// An optional cancellation token for the body. /// Defaults to Async.DefaultCancellationToken. + /// /// The created MailboxProcessor. new : body:(MailboxProcessor<'Msg> -> Async) * ?cancellationToken: CancellationToken -> MailboxProcessor<'Msg> /// Creates and starts an agent. The body function is used to generate the asynchronous /// computation executed by the agent. + /// /// The function to produce an asynchronous computation that will be executed /// as the read loop for the MailboxProcessor when Start is called. /// An optional cancellation token for the body. /// Defaults to Async.DefaultCancellationToken. + /// /// The created MailboxProcessor. static member Start : body:(MailboxProcessor<'Msg> -> Async) * ?cancellationToken: CancellationToken -> MailboxProcessor<'Msg> /// Posts a message to the message queue of the MailboxProcessor, asynchronously. + /// /// The message to post. member Post : message:'Msg -> unit @@ -56,7 +61,8 @@ namespace Microsoft.FSharp.Control /// The function to incorporate the AsyncReplyChannel into /// the message to be sent. /// An optional timeout parameter (in milliseconds) to wait for a reply message. - /// Defaults to -1 which corresponds to System.Threading.Timeout.Infinite. + /// Defaults to -1 which corresponds to . + /// /// The reply from the agent. member PostAndReply : buildMessage:(AsyncReplyChannel<'Reply> -> 'Msg) * ?timeout : int -> 'Reply @@ -68,23 +74,28 @@ namespace Microsoft.FSharp.Control /// The function to incorporate the AsyncReplyChannel into /// the message to be sent. /// An optional timeout parameter (in milliseconds) to wait for a reply message. - /// Defaults to -1 which corresponds to System.Threading.Timeout.Infinite. + /// Defaults to -1 which corresponds to . + /// /// An asynchronous computation that will wait for the reply from the agent. member PostAndAsyncReply : buildMessage:(AsyncReplyChannel<'Reply> -> 'Msg) * ?timeout : int -> Async<'Reply> /// Like PostAndReply, but returns None if no reply within the timeout period. + /// /// The function to incorporate the AsyncReplyChannel into /// the message to be sent. /// An optional timeout parameter (in milliseconds) to wait for a reply message. - /// Defaults to -1 which corresponds to System.Threading.Timeout.Infinite. + /// Defaults to -1 which corresponds to . + /// /// The reply from the agent or None if the timeout expires. member TryPostAndReply : buildMessage:(AsyncReplyChannel<'Reply> -> 'Msg) * ?timeout : int -> 'Reply option /// Like AsyncPostAndReply, but returns None if no reply within the timeout period. + /// /// The function to incorporate the AsyncReplyChannel into /// the message to be sent. /// An optional timeout parameter (in milliseconds) to wait for a reply message. - /// Defaults to -1 which corresponds to System.Threading.Timeout.Infinite. + /// Defaults to -1 which corresponds to . + /// /// An asynchronous computation that will return the reply or None if the timeout expires. member PostAndTryAsyncReply : buildMessage:(AsyncReplyChannel<'Reply> -> 'Msg) * ?timeout : int -> Async<'Reply option> @@ -96,9 +107,10 @@ namespace Microsoft.FSharp.Control /// one concurrent reader may be active, so no more than one concurrent call to /// Receive, TryReceive, Scan and/or TryScan may be active. /// An optional timeout in milliseconds. Defaults to -1 which corresponds - /// to System.Threading.Timeout.Infinite. + /// to . + /// /// An asynchronous computation that returns the received message. - /// Thrown when the timeout is exceeded. + /// Thrown when the timeout is exceeded. member Receive : ?timeout:int -> Async<'Msg> /// Waits for a message. This will consume the first message in arrival order. @@ -111,7 +123,8 @@ namespace Microsoft.FSharp.Control /// one concurrent reader may be active, so no more than one concurrent call to /// Receive, TryReceive, Scan and/or TryScan may be active. /// An optional timeout in milliseconds. Defaults to -1 which - /// corresponds to System.Threading.Timeout.Infinite. + /// corresponds to . + /// /// An asynchronous computation that returns the received message or /// None if the timeout is exceeded. member TryReceive : ?timeout:int -> Async<'Msg option> @@ -127,9 +140,10 @@ namespace Microsoft.FSharp.Control /// The function to return None if the message is to be skipped /// or Some if the message is to be processed and removed from the queue. /// An optional timeout in milliseconds. Defaults to -1 which corresponds - /// to System.Threading.Timeout.Infinite. + /// to . + /// /// An asynchronous computation that scanner built off the read message. - /// Thrown when the timeout is exceeded. + /// Thrown when the timeout is exceeded. member Scan : scanner:('Msg -> (Async<'T>) option) * ?timeout:int -> Async<'T> /// Scans for a message by looking through messages in arrival order until scanner @@ -141,7 +155,8 @@ namespace Microsoft.FSharp.Control /// The function to return None if the message is to be skipped /// or Some if the message is to be processed and removed from the queue. /// An optional timeout in milliseconds. Defaults to -1 which corresponds - /// to System.Threading.Timeout.Infinite. + /// to . + /// /// An asynchronous computation that scanner built off the read message. member TryScan : scanner:('Msg -> (Async<'T>) option) * ?timeout:int -> Async<'T option> diff --git a/src/fsharp/FSharp.Core/map.fsi b/src/fsharp/FSharp.Core/map.fsi index 04e6b048326b..5e35b635ab10 100644 --- a/src/fsharp/FSharp.Core/map.fsi +++ b/src/fsharp/FSharp.Core/map.fsi @@ -19,12 +19,15 @@ namespace Microsoft.FSharp.Collections /// Returns a new map with the binding added to the given map. /// If a binding with the given key already exists in the input map, the existing binding is replaced by the new binding in the result map. /// The input key. + /// /// The resulting map. member Add: key:'Key * value:'Value -> Map<'Key,'Value> /// Returns a new map with the value stored under key changed according to f. + /// /// The input key. /// The change function. + /// /// The resulting map. member Change: key:'Key * f:('Value option -> 'Value option) -> Map<'Key,'Value> @@ -32,12 +35,16 @@ namespace Microsoft.FSharp.Collections member IsEmpty: bool /// Builds a map that contains the bindings of the given IEnumerable. + /// /// The input sequence of key/value pairs. + /// /// The resulting map. new : elements:seq<'Key * 'Value> -> Map<'Key,'Value> /// Tests if an element is in the domain of the map. + /// /// The input key. + /// /// True if the map contains the given key. member ContainsKey: key:'Key -> bool @@ -46,26 +53,34 @@ namespace Microsoft.FSharp.Collections /// Lookup an element in the map. Raise KeyNotFoundException if no binding /// exists in the map. + /// /// The input key. - /// Thrown when the key is not found. + /// Thrown when the key is not found. + /// /// The value mapped to the key. member Item : key:'Key -> 'Value with get /// Removes an element from the domain of the map. No exception is raised if the element is not present. + /// /// The input key. + /// /// The resulting map. member Remove: key:'Key -> Map<'Key,'Value> /// Lookup an element in the map, returning a Some value if the element is in the domain /// of the map and None if not. + /// /// The input key. + /// /// The mapped value, or None if the key is not in the map. member TryFind: key:'Key -> 'Value option /// Lookup an element in the map, assigning to value if the element is in the domain /// of the map and returning false if not. + /// /// The input key. /// A reference to the output value. + /// /// true if the value is present, false if not. member TryGetValue: key:'Key * [] value:byref<'Value> -> bool @@ -81,66 +96,85 @@ namespace Microsoft.FSharp.Collections /// Functional programming operators related to the Map<_,_> type. [] [] + /// Basic operations on values of type . module Map = /// Returns a new map with the binding added to the given map. /// If a binding with the given key already exists in the input map, the existing binding is replaced by the new binding in the result map. + /// /// The input key. /// The input value. /// The input map. + /// /// The resulting map. [] val add: key:'Key -> value:'T -> table:Map<'Key,'T> -> Map<'Key,'T> /// Returns a new map with the value stored under key changed according to f. + /// /// The input key. /// The change function. /// The input map. + /// /// The resulting map. [] val change: key:'Key -> f:('T option -> 'T option) -> table:Map<'Key,'T> -> Map<'Key,'T> /// Returns a new map made from the given bindings. + /// /// The input list of key/value pairs. + /// /// The resulting map. [] val ofList: elements:('Key * 'T) list -> Map<'Key,'T> /// Returns a new map made from the given bindings. + /// /// The input array of key/value pairs. + /// /// The resulting map. [] val ofArray: elements:('Key * 'T)[] -> Map<'Key,'T> /// Returns a new map made from the given bindings. + /// /// The input sequence of key/value pairs. + /// /// The resulting map. [] val ofSeq: elements:seq<'Key * 'T> -> Map<'Key,'T> /// Views the collection as an enumerable sequence of pairs. /// The sequence will be ordered by the keys of the map. + /// /// The input map. + /// /// The sequence of key/value pairs. [] val toSeq: table:Map<'Key,'T> -> seq<'Key * 'T> /// Returns a list of all key-value pairs in the mapping. /// The list will be ordered by the keys of the map. + /// /// The input map. + /// /// The list of key/value pairs. [] val toList: table:Map<'Key,'T> -> ('Key * 'T) list /// Returns an array of all key-value pairs in the mapping. /// The array will be ordered by the keys of the map. + /// /// The input map. + /// /// The array of key/value pairs. [] val toArray: table:Map<'Key,'T> -> ('Key * 'T)[] /// Is the map empty? + /// /// The input map. + /// /// True if the map is empty. [] val isEmpty: table:Map<'Key,'T> -> bool @@ -152,44 +186,55 @@ namespace Microsoft.FSharp.Collections /// Lookup an element in the map, raising KeyNotFoundException if no binding /// exists in the map. + /// /// The input key. /// The input map. - /// Thrown when the key does not exist in the map. + /// Thrown when the key does not exist in the map. + /// /// The value mapped to the given key. [] val find: key:'Key -> table:Map<'Key,'T> -> 'T /// Searches the map looking for the first element where the given function returns a Some value. + /// /// The function to generate options from the key/value pairs. /// The input map. + /// /// The first result. [] val tryPick: chooser:('Key -> 'T -> 'U option) -> table:Map<'Key,'T> -> 'U option /// Searches the map looking for the first element where the given function returns a Some value + /// /// The function to generate options from the key/value pairs. /// The input map. + /// /// The first result. [] val pick: chooser:('Key -> 'T -> 'U option) -> table:Map<'Key,'T> -> 'U /// Folds over the bindings in the map. + /// /// The function to update the state given the input key/value pairs. /// The input map. /// The initial state. + /// /// The final state value. [] val foldBack<'Key,'T,'State> : folder:('Key -> 'T -> 'State -> 'State) -> table:Map<'Key,'T> -> state:'State -> 'State when 'Key : comparison /// Folds over the bindings in the map + /// /// The function to update the state given the input key/value pairs. /// The initial state. /// The input map. + /// /// The final state value. [] val fold<'Key,'T,'State> : folder:('State -> 'Key -> 'T -> 'State) -> state:'State -> table:Map<'Key,'T> -> 'State when 'Key : comparison /// Applies the given function to each binding in the dictionary + /// /// The function to apply to each key/value pair. /// The input map. [] @@ -197,23 +242,29 @@ namespace Microsoft.FSharp.Collections /// Returns true if the given predicate returns true for one of the /// bindings in the map. + /// /// The function to test the input elements. /// The input map. + /// /// True if the predicate returns true for one of the key/value pairs. [] val exists: predicate:('Key -> 'T -> bool) -> table:Map<'Key, 'T> -> bool /// Builds a new map containing only the bindings for which the given predicate returns 'true'. + /// /// The function to test the key/value pairs. /// The input map. + /// /// The filtered map. [] val filter: predicate:('Key -> 'T -> bool) -> table:Map<'Key, 'T> -> Map<'Key, 'T> /// Returns true if the given predicate returns true for all of the /// bindings in the map. + /// /// The function to test the input elements. /// The input map. + /// /// True if the predicate evaluates to true for all of the bindings in the map. [] val forall: predicate:('Key -> 'T -> bool) -> table:Map<'Key, 'T> -> bool @@ -221,56 +272,70 @@ namespace Microsoft.FSharp.Collections /// Builds a new collection whose elements are the results of applying the given function /// to each of the elements of the collection. The key passed to the /// function indicates the key of element being transformed. + /// /// The function to transform the key/value pairs. /// The input map. + /// /// The resulting map of keys and transformed values. [] val map: mapping:('Key -> 'T -> 'U) -> table:Map<'Key,'T> -> Map<'Key,'U> /// Tests if an element is in the domain of the map. + /// /// The input key. /// The input map. + /// /// True if the map contains the key. [] val containsKey: key:'Key -> table:Map<'Key,'T> -> bool /// Builds two new maps, one containing the bindings for which the given predicate returns 'true', /// and the other the remaining bindings. + /// /// The function to test the input elements. /// The input map. + /// /// A pair of maps in which the first contains the elements for which the predicate returned true /// and the second containing the elements for which the predicated returned false. [] val partition: predicate:('Key -> 'T -> bool) -> table:Map<'Key, 'T> -> Map<'Key, 'T> * Map<'Key, 'T> /// Removes an element from the domain of the map. No exception is raised if the element is not present. + /// /// The input key. /// The input map. + /// /// The resulting map. [] val remove: key:'Key -> table:Map<'Key,'T> -> Map<'Key,'T> /// Lookup an element in the map, returning a Some value if the element is in the domain /// of the map and None if not. + /// /// The input key. /// The input map. + /// /// The found Some value or None. [] val tryFind: key:'Key -> table:Map<'Key,'T> -> 'T option /// Evaluates the function on each mapping in the collection. Returns the key for the first mapping /// where the function returns 'true'. Raise KeyNotFoundException if no such element exists. + /// /// The function to test the input elements. /// The input map. - /// Thrown if the key does not exist in the map. + /// Thrown if the key does not exist in the map. + /// /// The first key for which the predicate evaluates true. [] val findKey: predicate:('Key -> 'T -> bool) -> table:Map<'Key,'T> -> 'Key /// Returns the key of the first mapping in the collection that satisfies the given predicate. /// Returns 'None' if no such element exists. + /// /// The function to test the input elements. /// The input map. + /// /// The first key for which the predicate returns true or None if the predicate evaluates to false for each key/value pair. [] val tryFindKey: predicate:('Key -> 'T -> bool) -> table:Map<'Key,'T> -> 'Key option diff --git a/src/fsharp/FSharp.Core/math/z.fsi b/src/fsharp/FSharp.Core/math/z.fsi index e49b1b3d532c..dcdb96ef6047 100644 --- a/src/fsharp/FSharp.Core/math/z.fsi +++ b/src/fsharp/FSharp.Core/math/z.fsi @@ -12,6 +12,7 @@ namespace Microsoft.FSharp.Math namespace Microsoft.FSharp.Core + /// An abbreviation for type bigint = System.Numerics.BigInteger [] @@ -24,15 +25,21 @@ namespace Microsoft.FSharp.Core /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' val FromZero : value:unit -> 'T + /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' val FromOne : value:unit -> 'T + /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' val FromInt32 : value:int32 -> 'T + /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' val FromInt64 : value:int64 -> 'T + /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' val FromString : text:string -> 'T + /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' val FromInt64Dynamic : value:int64 -> obj + /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' val FromStringDynamic : text:string -> obj diff --git a/src/fsharp/FSharp.Core/nativeptr.fsi b/src/fsharp/FSharp.Core/nativeptr.fsi index b60a9323f548..6fbdc484d059 100644 --- a/src/fsharp/FSharp.Core/nativeptr.fsi +++ b/src/fsharp/FSharp.Core/nativeptr.fsi @@ -15,27 +15,34 @@ namespace Microsoft.FSharp.NativeInterop [] /// Returns a typed native pointer for a given machine address. /// The pointer address. + /// /// A typed pointer. val inline ofNativeInt : address:nativeint -> nativeptr<'T> [] [] /// Returns an untyped native pointer for a given typed pointer. + /// /// The pointer address. + /// /// A typed pointer. val inline toVoidPtr : address:nativeptr<'T> -> voidptr [] [] /// Returns a typed native pointer for a untyped native pointer. + /// /// The untyped pointer. + /// /// A typed pointer. val inline ofVoidPtr : voidptr -> nativeptr<'T> [] [] /// Returns a machine address for a given typed native pointer. + /// /// The input pointer. + /// /// The machine address. val inline toNativeInt : address:nativeptr<'T> -> nativeint @@ -44,8 +51,10 @@ namespace Microsoft.FSharp.NativeInterop [] /// Returns a typed native pointer by adding index * sizeof<'T> to the /// given input pointer. + /// /// The input pointer. /// The index by which to offset the pointer. + /// /// A typed pointer. val inline add : address:nativeptr<'T> -> index:int -> nativeptr<'T> @@ -53,21 +62,26 @@ namespace Microsoft.FSharp.NativeInterop [] /// Dereferences the typed native pointer computed by adding index * sizeof<'T> to the /// given input pointer. + /// /// The input pointer. /// The index by which to offset the pointer. + /// /// The value at the pointer address. val inline get : address:nativeptr<'T> -> index:int -> 'T [] [] /// Dereferences the given typed native pointer. + /// /// The input pointer. + /// /// The value at the pointer address. val inline read : address:nativeptr<'T> -> 'T [] [] /// Assigns the value into the memory location referenced by the given typed native pointer. + /// /// The input pointer. /// The value to assign. val inline write : address:nativeptr<'T> -> value:'T -> unit @@ -76,20 +90,25 @@ namespace Microsoft.FSharp.NativeInterop [] /// Assigns the value into the memory location referenced by the typed native /// pointer computed by adding index * sizeof<'T> to the given input pointer. + /// /// The input pointer. /// The index by which to offset the pointer. /// The value to assign. val inline set : address:nativeptr<'T> -> index:int -> value:'T -> unit /// Allocates a region of memory on the stack. + /// /// The number of objects of type T to allocate. + /// /// A typed pointer to the allocated memory. [] [] val inline stackalloc : count:int -> nativeptr<'T> /// Converts a given typed native pointer to a managed pointer. + /// /// The input pointer. + /// /// The managed pointer. [] [] diff --git a/src/fsharp/FSharp.Core/observable.fsi b/src/fsharp/FSharp.Core/observable.fsi index 36cbee5700d8..479d306cdd4c 100644 --- a/src/fsharp/FSharp.Core/observable.fsi +++ b/src/fsharp/FSharp.Core/observable.fsi @@ -19,6 +19,7 @@ namespace Microsoft.FSharp.Control /// be triggered concurrently on different threads. /// The first Observable. /// The second Observable. + /// /// An Observable that propagates information from both sources. [] val merge: source1:IObservable<'T> -> source2:IObservable<'T> -> IObservable<'T> @@ -29,6 +30,7 @@ namespace Microsoft.FSharp.Control /// arising from the source and completes when the source completes. /// The function applied to observations from the source. /// The input Observable. + /// /// An Observable of the type specified by mapping. [] val map: mapping:('T -> 'U) -> source:IObservable<'T> -> IObservable<'U> @@ -38,9 +40,11 @@ namespace Microsoft.FSharp.Control /// for which the predicate returns true. The predicate is executed once for /// each subscribed observer. The returned object also propagates error /// observations arising from the source and completes when the source completes. + /// /// The function to apply to observations to determine if it should /// be kept. /// The input Observable. + /// /// An Observable that filters observations based on filter. [] val filter: predicate:('T -> bool) -> source:IObservable<'T> -> IObservable<'T> @@ -52,9 +56,11 @@ namespace Microsoft.FSharp.Control /// executed once for each subscribed observer. Both also propagate all error /// observations arising from the source and each completes when the source /// completes. + /// /// The function to determine which output Observable will trigger /// a particular observation. /// The input Observable. + /// /// A tuple of Observables. The first triggers when the predicate returns true, and /// the second triggers when the predicate returns false. [] @@ -67,9 +73,11 @@ namespace Microsoft.FSharp.Control /// executed once for each subscribed observer. Both also propagate error /// observations arising from the source and each completes when the source /// completes. + /// /// The function that takes an observation an transforms /// it into one of the two output Choice types. /// The input Observable. + /// /// A tuple of Observables. The first triggers when splitter returns Choice1of2 /// and the second triggers when splitter returns Choice2of2. [] @@ -79,9 +87,11 @@ namespace Microsoft.FSharp.Control /// using the given function. The returned object will trigger observations x /// for which the splitter returns Some x. The returned object also propagates /// all errors arising from the source and completes when the source completes. + /// /// The function that returns Some for observations to be propagated /// and None for observations to ignore. /// The input Observable. + /// /// An Observable that only propagates some of the observations from the source. [] val choose: chooser:('T -> 'U option) -> source:IObservable<'T> -> IObservable<'U> @@ -98,12 +108,14 @@ namespace Microsoft.FSharp.Control /// The function to update the state with each observation. /// The initial state. /// The input Observable. + /// /// An Observable that triggers on the updated state values. [] val scan: collector:('U -> 'T -> 'U) -> state:'U -> source:IObservable<'T> -> IObservable<'U> /// Creates an observer which permanently subscribes to the given observable and which calls /// the given function for each observation. + /// /// The function to be called on each observation. /// The input Observable. [] @@ -111,8 +123,10 @@ namespace Microsoft.FSharp.Control /// Creates an observer which subscribes to the given observable and which calls /// the given function for each observation. + /// /// The function to be called on each observation. /// The input Observable. + /// /// An object that will remove the callback if disposed. [] val subscribe : callback:('T -> unit) -> source:IObservable<'T> -> System.IDisposable @@ -126,6 +140,7 @@ namespace Microsoft.FSharp.Control /// That is, observations arising from the source must not be triggered concurrently /// on different threads. /// The input Observable. + /// /// An Observable that triggers on successive pairs of observations from the input Observable. [] val pairwise: source:IObservable<'T> -> IObservable<'T * 'T> diff --git a/src/fsharp/FSharp.Core/option.fsi b/src/fsharp/FSharp.Core/option.fsi index 96d4ab74bf68..8854204201f0 100644 --- a/src/fsharp/FSharp.Core/option.fsi +++ b/src/fsharp/FSharp.Core/option.fsi @@ -12,187 +12,238 @@ open Microsoft.FSharp.Collections module Option = /// Returns true if the option is not None. /// The input option. + /// /// True if the option is not None. [] val inline isSome: option:'T option -> bool /// Returns true if the option is None. + /// /// The input option. + /// /// True if the option is None. [] val inline isNone: option:'T option -> bool /// Gets the value of the option if the option is Some, otherwise returns the specified default value. + /// /// The specified default value. /// The input option. + /// /// The option if the option is Some, else the default value. /// Identical to the built-in operator, except with the arguments swapped. [] val defaultValue: value:'T -> option:'T option -> 'T /// Gets the value of the option if the option is Some, otherwise evaluates and returns the result. + /// /// A thunk that provides a default value when evaluated. /// The input option. + /// /// The option if the option is Some, else the result of evaluating . /// is not evaluated unless is None. [] val defaultWith: defThunk:(unit -> 'T) -> option:'T option -> 'T /// Returns if it is Some, otherwise returns . + /// /// The value to use if is None. /// The input option. + /// /// The option if the option is Some, else the alternate option. [] val orElse: ifNone:'T option -> option:'T option -> 'T option /// Returns if it is Some, otherwise evaluates and returns the result. + /// /// A thunk that provides an alternate option when evaluated. /// The input option. + /// /// The option if the option is Some, else the result of evaluating . /// is not evaluated unless is None. [] val orElseWith: ifNoneThunk:(unit -> 'T option) -> option:'T option -> 'T option /// Gets the value associated with the option. + /// /// The input option. + /// /// The value within the option. /// Thrown when the option is None. [] val get: option:'T option -> 'T /// count inp evaluates to match inp with None -> 0 | Some _ -> 1. + /// /// The input option. + /// /// A zero if the option is None, a one otherwise. [] val count: option:'T option -> int /// fold f s inp evaluates to match inp with None -> s | Some x -> f s x. + /// /// A function to update the state data when given a value from an option. /// The initial state. /// The input option. + /// /// The original state if the option is None, otherwise it returns the updated state with the folder /// and the option value. [] val fold<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> option:'T option -> 'State /// fold f inp s evaluates to match inp with None -> s | Some x -> f x s. + /// /// A function to update the state data when given a value from an option. /// The input option. /// The initial state. + /// /// The original state if the option is None, otherwise it returns the updated state with the folder /// and the option value. [] val foldBack<'T,'State> : folder:('T -> 'State -> 'State) -> option:'T option -> state:'State -> 'State /// exists p inp evaluates to match inp with None -> false | Some x -> p x. + /// /// A function that evaluates to a boolean when given a value from the option type. /// The input option. + /// /// False if the option is None, otherwise it returns the result of applying the predicate /// to the option value. [] val exists: predicate:('T -> bool) -> option:'T option -> bool /// forall p inp evaluates to match inp with None -> true | Some x -> p x. + /// /// A function that evaluates to a boolean when given a value from the option type. /// The input option. + /// /// True if the option is None, otherwise it returns the result of applying the predicate /// to the option value. [] val forall: predicate:('T -> bool) -> option:'T option -> bool /// Evaluates to true if is Some and its value is equal to . + /// /// The value to test for equality. /// The input option. + /// /// True if the option is Some and contains a value equal to , otherwise false. [] val inline contains: value:'T -> option:'T option -> bool when 'T : equality /// iter f inp executes match inp with None -> () | Some x -> f x. + /// /// A function to apply to the option value. /// The input option. + /// /// Unit if the option is None, otherwise it returns the result of applying the predicate /// to the option value. [] val iter: action:('T -> unit) -> option:'T option -> unit /// map f inp evaluates to match inp with None -> None | Some x -> Some (f x). + /// /// A function to apply to the option value. /// The input option. + /// /// An option of the input value after applying the mapping function, or None if the input is None. [] val map: mapping:('T -> 'U) -> option:'T option -> 'U option /// map f option1 option2 evaluates to match option1, option2 with Some x, Some y -> Some (f x y) | _ -> None. + /// /// A function to apply to the option values. /// The first option. /// The second option. + /// /// An option of the input values after applying the mapping function, or None if either input is None. [] val map2: mapping:('T1 -> 'T2 -> 'U) -> 'T1 option -> 'T2 option -> 'U option /// map f option1 option2 option3 evaluates to match option1, option2, option3 with Some x, Some y, Some z -> Some (f x y z) | _ -> None. + /// /// A function to apply to the option values. /// The first option. /// The second option. /// The third option. + /// /// An option of the input values after applying the mapping function, or None if any input is None. [] val map3: mapping:('T1 -> 'T2 -> 'T3 -> 'U) -> 'T1 option -> 'T2 option -> 'T3 option -> 'U option /// bind f inp evaluates to match inp with None -> None | Some x -> f x + /// /// A function that takes the value of type T from an option and transforms it into /// an option containing a value of type U. /// The input option. + /// /// An option of the output type of the binder. [] val bind: binder:('T -> 'U option) -> option:'T option -> 'U option /// flatten inp evaluates to match inp with None -> None | Some x -> x + /// /// The input option. + /// /// An option of the output type of the binder. /// flatten is equivalent to bind id. [] val flatten: option:'T option option -> 'T option /// filter f inp evaluates to match inp with None -> None | Some x -> if f x then Some x else None. + /// /// A function that evaluates whether the value contained in the option should remain, or be filtered out. /// The input option. + /// /// The input if the predicate evaluates to true; otherwise, None. [] val filter: predicate:('T -> bool) -> option:'T option -> 'T option /// Convert the option to an array of length 0 or 1. + /// /// The input option. + /// /// The result array. [] val toArray: option:'T option -> 'T[] /// Convert the option to a list of length 0 or 1. + /// /// The input option. + /// /// The result list. [] val toList: option:'T option -> 'T list /// Convert the option to a Nullable value. + /// /// The input option. + /// /// The result value. [] val toNullable: option:'T option -> Nullable<'T> /// Convert a Nullable value to an option. + /// /// The input nullable value. + /// /// The result option. [] val ofNullable: value:Nullable<'T> -> 'T option /// Convert a potentially null value to an option. + /// /// The input value. + /// /// The result option. [] val ofObj: value: 'T -> 'T option when 'T : null /// Convert an option to a potentially null value. + /// /// The input value. + /// /// The result value, which is null if the input was None. [] val toObj: value: 'T option -> 'T when 'T : null @@ -200,188 +251,240 @@ module Option = /// Basic operations on value options. module ValueOption = /// Returns true if the value option is not ValueNone. + /// /// The input value option. + /// /// True if the value option is not ValueNone. [] val inline isSome: voption:'T voption -> bool /// Returns true if the value option is ValueNone. + /// /// The input value option. + /// /// True if the voption is ValueNone. [] val inline isNone: voption:'T voption -> bool /// Gets the value of the value option if the option is ValueSome, otherwise returns the specified default value. + /// /// The specified default value. /// The input voption. + /// /// The voption if the voption is ValueSome, else the default value. /// Identical to the built-in operator, except with the arguments swapped. [] val defaultValue: value:'T -> voption:'T voption -> 'T /// Gets the value of the voption if the voption is ValueSome, otherwise evaluates and returns the result. + /// /// A thunk that provides a default value when evaluated. /// The input voption. + /// /// The voption if the voption is ValueSome, else the result of evaluating . /// is not evaluated unless is ValueNone. [] val defaultWith: defThunk:(unit -> 'T) -> voption:'T voption -> 'T /// Returns if it is Some, otherwise returns . + /// /// The value to use if is None. /// The input option. + /// /// The option if the option is Some, else the alternate option. [] val orElse: ifNone:'T voption -> voption:'T voption -> 'T voption /// Returns if it is Some, otherwise evaluates and returns the result. + /// /// A thunk that provides an alternate value option when evaluated. /// The input value option. + /// /// The voption if the voption is ValueSome, else the result of evaluating . /// is not evaluated unless is ValueNone. [] val orElseWith: ifNoneThunk:(unit -> 'T voption) -> voption:'T voption -> 'T voption /// Gets the value associated with the option. + /// /// The input value option. + /// /// The value within the option. /// Thrown when the option is ValueNone. [] val get: voption:'T voption -> 'T /// count inp evaluates to match inp with ValueNone -> 0 | ValueSome _ -> 1. + /// /// The input value option. + /// /// A zero if the option is ValueNone, a one otherwise. [] val count: voption:'T voption -> int /// fold f s inp evaluates to match inp with ValueNone -> s | ValueSome x -> f s x. + /// /// A function to update the state data when given a value from a value option. /// The initial state. /// The input value option. + /// /// The original state if the option is ValueNone, otherwise it returns the updated state with the folder /// and the voption value. [] val fold<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> voption:'T voption -> 'State /// fold f inp s evaluates to match inp with ValueNone -> s | ValueSome x -> f x s. + /// /// A function to update the state data when given a value from a value option. /// The input value option. /// The initial state. + /// /// The original state if the option is ValueNone, otherwise it returns the updated state with the folder /// and the voption value. [] val foldBack<'T,'State> : folder:('T -> 'State -> 'State) -> voption:'T voption -> state:'State -> 'State /// exists p inp evaluates to match inp with ValueNone -> false | ValueSome x -> p x. + /// /// A function that evaluates to a boolean when given a value from the option type. /// The input value option. + /// /// False if the option is ValueNone, otherwise it returns the result of applying the predicate /// to the option value. [] val exists: predicate:('T -> bool) -> voption:'T voption -> bool /// forall p inp evaluates to match inp with ValueNone -> true | ValueSome x -> p x. + /// /// A function that evaluates to a boolean when given a value from the value option type. /// The input value option. + /// /// True if the option is None, otherwise it returns the result of applying the predicate /// to the option value. [] val forall: predicate:('T -> bool) -> voption:'T voption -> bool /// Evaluates to true if is ValueSome and its value is equal to . + /// /// The value to test for equality. /// The input value option. + /// /// True if the option is ValueSome and contains a value equal to , otherwise false. [] val inline contains: value:'T -> voption:'T voption -> bool when 'T : equality /// iter f inp executes match inp with ValueNone -> () | ValueSome x -> f x. + /// /// A function to apply to the voption value. /// The input value option. + /// /// Unit if the option is ValueNone, otherwise it returns the result of applying the predicate /// to the voption value. [] val iter: action:('T -> unit) -> voption:'T voption -> unit /// map f inp evaluates to match inp with ValueNone -> ValueNone | ValueSome x -> ValueSome (f x). + /// /// A function to apply to the voption value. /// The input value option. + /// /// A value option of the input value after applying the mapping function, or ValueNone if the input is ValueNone. [] val map: mapping:('T -> 'U) -> voption:'T voption -> 'U voption /// map f voption1 voption2 evaluates to match voption1, voption2 with ValueSome x, ValueSome y -> ValueSome (f x y) | _ -> ValueNone. + /// /// A function to apply to the voption values. /// The first value option. /// The second value option. + /// /// A value option of the input values after applying the mapping function, or ValueNone if either input is ValueNone. [] val map2: mapping:('T1 -> 'T2 -> 'U) -> voption1: 'T1 voption -> voption2: 'T2 voption -> 'U voption /// map f voption1 voption2 voption3 evaluates to match voption1, voption2, voption3 with ValueSome x, ValueSome y, ValueSome z -> ValueSome (f x y z) | _ -> ValueNone. + /// /// A function to apply to the value option values. /// The first value option. /// The second value option. /// The third value option. + /// /// A value option of the input values after applying the mapping function, or ValueNone if any input is ValueNone. [] val map3: mapping:('T1 -> 'T2 -> 'T3 -> 'U) -> 'T1 voption -> 'T2 voption -> 'T3 voption -> 'U voption /// bind f inp evaluates to match inp with ValueNone -> ValueNone | ValueSome x -> f x + /// /// A function that takes the value of type T from a value option and transforms it into /// a value option containing a value of type U. /// The input value option. + /// /// An option of the output type of the binder. [] val bind: binder:('T -> 'U voption) -> voption:'T voption -> 'U voption /// flatten inp evaluates to match inp with ValueNone -> ValueNone | ValueSome x -> x + /// /// The input value option. + /// /// A value option of the output type of the binder. /// flatten is equivalent to bind id. [] val flatten: voption:'T voption voption -> 'T voption /// filter f inp evaluates to match inp with ValueNone -> ValueNone | ValueSome x -> if f x then ValueSome x else ValueNone. + /// /// A function that evaluates whether the value contained in the value option should remain, or be filtered out. /// The input value option. + /// /// The input if the predicate evaluates to true; otherwise, ValueNone. [] val filter: predicate:('T -> bool) -> voption:'T voption -> 'T voption /// Convert the value option to an array of length 0 or 1. + /// /// The input value option. + /// /// The result array. [] val toArray: voption:'T voption -> 'T[] /// Convert the value option to a list of length 0 or 1. + /// /// The input value option. + /// /// The result list. [] val toList: voption:'T voption -> 'T list /// Convert the value option to a Nullable value. + /// /// The input value option. + /// /// The result value. [] val toNullable: voption:'T voption -> Nullable<'T> /// Convert a Nullable value to a value option. + /// /// The input nullable value. + /// /// The result value option. [] val ofNullable: value:Nullable<'T> -> 'T voption /// Convert a potentially null value to a value option. + /// /// The input value. + /// /// The result value option. [] val ofObj: value: 'T -> 'T voption when 'T : null /// Convert an option to a potentially null value. + /// /// The input value. + /// /// The result value, which is null if the input was ValueNone. [] val toObj: value: 'T voption -> 'T when 'T : null diff --git a/src/fsharp/FSharp.Core/prim-types-prelude.fsi b/src/fsharp/FSharp.Core/prim-types-prelude.fsi index 0d8d44d76822..dcaf513abf3c 100644 --- a/src/fsharp/FSharp.Core/prim-types-prelude.fsi +++ b/src/fsharp/FSharp.Core/prim-types-prelude.fsi @@ -9,76 +9,76 @@ namespace Microsoft.FSharp.Core open System - /// An abbreviation for the CLI type System.Object. + /// An abbreviation for the CLI type . type obj = System.Object - /// An abbreviation for the CLI type System.Exception. + /// An abbreviation for the CLI type . type exn = System.Exception - /// An abbreviation for the CLI type System.IntPtr. + /// An abbreviation for the CLI type . type nativeint = System.IntPtr - /// An abbreviation for the CLI type System.UIntPtr. + /// An abbreviation for the CLI type . type unativeint = System.UIntPtr - /// An abbreviation for the CLI type System.String. + /// An abbreviation for the CLI type . type string = System.String - /// An abbreviation for the CLI type System.Single. + /// An abbreviation for the CLI type . type float32 = System.Single - /// An abbreviation for the CLI type System.Double. + /// An abbreviation for the CLI type . type float = System.Double - /// An abbreviation for the CLI type System.Single. + /// An abbreviation for the CLI type . Identical to . type single = System.Single - /// An abbreviation for the CLI type System.Double. + /// An abbreviation for the CLI type . Identical to . type double = System.Double - /// An abbreviation for the CLI type System.SByte. + /// An abbreviation for the CLI type . type sbyte = System.SByte - /// An abbreviation for the CLI type System.Byte. + /// An abbreviation for the CLI type . type byte = System.Byte - /// An abbreviation for the CLI type System.SByte. + /// An abbreviation for the CLI type . type int8 = System.SByte - /// An abbreviation for the CLI type System.Byte. + /// An abbreviation for the CLI type . type uint8 = System.Byte - /// An abbreviation for the CLI type System.Int16. + /// An abbreviation for the CLI type . type int16 = System.Int16 - /// An abbreviation for the CLI type System.UInt16. + /// An abbreviation for the CLI type . type uint16 = System.UInt16 - /// An abbreviation for the CLI type System.Int32. + /// An abbreviation for the CLI type . type int32 = System.Int32 - /// An abbreviation for the CLI type System.UInt32. + /// An abbreviation for the CLI type . type uint32 = System.UInt32 - /// An abbreviation for the CLI type System.Int64. + /// An abbreviation for the CLI type . type int64 = System.Int64 - /// An abbreviation for the CLI type System.UInt64. + /// An abbreviation for the CLI type . type uint64 = System.UInt64 - /// An abbreviation for the CLI type System.Char. + /// An abbreviation for the CLI type . type char = System.Char - /// An abbreviation for the CLI type System.Boolean. + /// An abbreviation for the CLI type . type bool = System.Boolean - /// An abbreviation for the CLI type System.Decimal. + /// An abbreviation for the CLI type . type decimal = System.Decimal - /// An abbreviation for the CLI type System.Int32. + /// An abbreviation for the CLI type . type int = int32 - /// An abbreviation for the CLI type System.UInt32. + /// An abbreviation for the CLI type . type uint = uint32 /// Single dimensional, zero-based arrays, written int[], string[] etc. @@ -249,7 +249,7 @@ namespace Microsoft.FSharp.Core /// Single dimensional, zero-based arrays, written int[], string[] etc. /// - /// Use the values in the Array module to manipulate values + /// Use the values in the module to manipulate values /// of this type, or the notation arr.[x] to get/set array /// values. type 'T array = 'T[] @@ -259,7 +259,7 @@ namespace Microsoft.FSharp.Core /// This type should only be used when writing F# code that interoperates /// with native code. Use of this type in F# code may result in /// unverifiable code being generated. Conversions to and from the - /// nativeint type may be required. Values of this type can be generated + /// type may be required. Values of this type can be generated /// by the functions in the NativeInterop.NativePtr module. type nativeptr<'T when 'T : unmanaged> = (# "native int" #) @@ -268,7 +268,7 @@ namespace Microsoft.FSharp.Core /// This type should only be used when writing F# code that interoperates /// with native code. Use of this type in F# code may result in /// unverifiable code being generated. Conversions to and from the - /// nativeint type may be required. Values of this type can be generated + /// type may be required. Values of this type can be generated /// by the functions in the NativeInterop.NativePtr module. type voidptr = (# "void*" #) diff --git a/src/fsharp/FSharp.Core/prim-types.fsi b/src/fsharp/FSharp.Core/prim-types.fsi index 1ff9c146c049..e44853e8bc88 100644 --- a/src/fsharp/FSharp.Core/prim-types.fsi +++ b/src/fsharp/FSharp.Core/prim-types.fsi @@ -87,7 +87,9 @@ namespace Microsoft.FSharp.Core new : unit -> SealedAttribute /// Creates an instance of the attribute + /// /// Indicates whether the class is sealed. + /// /// SealedAttribute new : value:bool -> SealedAttribute @@ -118,7 +120,9 @@ namespace Microsoft.FSharp.Core new : unit -> ReflectedDefinitionAttribute /// Creates an instance of the attribute + /// /// Indicates whether to include the evaluated value of the definition as the outer node of the quotation + /// /// ReflectedDefinitionAttribute new : includeValue:bool -> ReflectedDefinitionAttribute @@ -126,14 +130,18 @@ namespace Microsoft.FSharp.Core member IncludeValue: bool /// This attribute is used to indicate a generic container type satisfies the F# 'equality' - /// constraint only if a generic argument also satisfies this constraint. For example, adding + /// constraint only if a generic argument also satisfies this constraint. + /// + /// + /// + /// For example, adding /// this attribute to parameter 'T on a type definition C<'T> means that a type C<X> only supports /// equality if the type X also supports equality and all other conditions for C<X> to support /// equality are also met. The type C<'T> can still be used with other type arguments, but a type such /// as C<(int -> int)> will not support equality because the type (int -> int) is an F# function type - /// and does not support equality. - /// - /// This attribute will be ignored if it is used on the generic parameters of functions or methods. + /// and does not support equality. + /// + /// This attribute will be ignored if it is used on the generic parameters of functions or methods. [] [] type EqualityConditionalOnAttribute = @@ -144,14 +152,16 @@ namespace Microsoft.FSharp.Core new : unit -> EqualityConditionalOnAttribute /// This attribute is used to indicate a generic container type satisfies the F# 'comparison' - /// constraint only if a generic argument also satisfies this constraint. For example, adding + /// constraint only if a generic argument also satisfies this constraint. + /// + /// For example, adding /// this attribute to parameter 'T on a type definition C<'T> means that a type C<X> only supports /// comparison if the type X also supports comparison and all other conditions for C<X> to support /// comparison are also met. The type C<'T> can still be used with other type arguments, but a type such /// as C<(int -> int)> will not support comparison because the type (int -> int) is an F# function type - /// and does not support comparison. + /// and does not support comparison. /// - /// This attribute will be ignored if it is used on the generic parameters of functions or methods. + /// This attribute will be ignored if it is used on the generic parameters of functions or methods. [] [] type ComparisonConditionalOnAttribute = @@ -277,8 +287,10 @@ namespace Microsoft.FSharp.Core member Value: bool /// Creates an instance of the attribute + /// /// Indicates whether to generate helper members on the CLI class representing a discriminated /// union. + /// /// DefaultAugmentationAttribute new : value:bool -> DefaultAugmentationAttribute @@ -450,7 +462,9 @@ namespace Microsoft.FSharp.Core new : unit -> DefaultValueAttribute /// Creates an instance of the attribute + /// /// Indicates whether to assert that the field type supports null. + /// /// DefaultValueAttribute new : check: bool -> DefaultValueAttribute @@ -494,7 +508,9 @@ namespace Microsoft.FSharp.Core inherit Attribute /// Creates an instance of the attribute + /// /// The name to use in compiled code. + /// /// CompiledNameAttribute new : compiledName:string -> CompiledNameAttribute @@ -509,7 +525,9 @@ namespace Microsoft.FSharp.Core inherit Attribute /// Creates an instance of the attribute + /// /// Indicates whether the type should be serializable by default. + /// /// AutoSerializableAttribute new : value:bool -> AutoSerializableAttribute @@ -525,9 +543,11 @@ namespace Microsoft.FSharp.Core inherit Attribute /// Creates an instance of the attribute + /// /// The major version number. /// The minor version number. /// The release number. + /// /// FSharpInterfaceDataVersionAttribute new : major:int * minor:int * release:int -> FSharpInterfaceDataVersionAttribute @@ -542,31 +562,41 @@ namespace Microsoft.FSharp.Core /// This attribute is inserted automatically by the F# compiler to tag types /// and methods in the generated CLI code with flags indicating the correspondence - /// with original source constructs. It is used by the functions in the - /// Microsoft.FSharp.Reflection namespace to reverse-map compiled constructs to - /// their original forms. It is not intended for use from user code. + /// with original source constructs. + /// + /// This attribute is used by the functions in the + /// FSharp.Reflection namespace to reverse-map compiled constructs to + /// their original forms. It is not intended for use from user code. [] [] type CompilationMappingAttribute = inherit Attribute /// Creates an instance of the attribute + /// /// Indicates the type of source construct. + /// /// CompilationMappingAttribute new : sourceConstructFlags:SourceConstructFlags -> CompilationMappingAttribute /// Creates an instance of the attribute + /// /// Indicates the type of source construct. + /// /// CompilationMappingAttribute new : sourceConstructFlags:SourceConstructFlags * sequenceNumber: int -> CompilationMappingAttribute /// Creates an instance of the attribute + /// /// Indicates the type of source construct. + /// /// CompilationMappingAttribute new : sourceConstructFlags:SourceConstructFlags * variantNumber : int * sequenceNumber : int -> CompilationMappingAttribute /// Creates an instance of the attribute + /// /// Indicates the type definitions needed to resolve the source construct. + /// /// CompilationMappingAttribute new : resourceName:string * typeDefinitions:System.Type[] -> CompilationMappingAttribute @@ -585,15 +615,20 @@ namespace Microsoft.FSharp.Core member TypeDefinitions : System.Type[] /// This attribute is inserted automatically by the F# compiler to tag - /// methods which are given the 'CompiledName' attribute. It is not intended - /// for use from user code. + /// methods which are given the 'CompiledName' attribute. + /// + /// This attribute is used by the functions in the + /// FSharp.Reflection namespace to reverse-map compiled constructs to + /// their original forms. It is not intended for use from user code. [] [] type CompilationSourceNameAttribute = inherit Attribute /// Creates an instance of the attribute + /// /// The name of the method in source. + /// /// CompilationSourceNameAttribute new : sourceName:string -> CompilationSourceNameAttribute @@ -609,7 +644,9 @@ namespace Microsoft.FSharp.Core inherit Attribute /// Creates an instance of the attribute + /// /// Indicates adjustments to the compiled representation of the type or member. + /// /// CompilationRepresentationAttribute new : flags:CompilationRepresentationFlags -> CompilationRepresentationAttribute @@ -629,7 +666,9 @@ namespace Microsoft.FSharp.Core inherit Attribute /// Creates an instance of the attribute + /// /// The warning message to be emitted when code uses this construct. + /// /// ExperimentalAttribute new : message:string-> ExperimentalAttribute @@ -644,7 +683,9 @@ namespace Microsoft.FSharp.Core inherit Attribute /// Creates an instance of the attribute + /// /// Indicates the number of arguments in each argument group. + /// /// CompilationArgumentCountsAttribute new : counts:int[] -> CompilationArgumentCountsAttribute @@ -661,7 +702,9 @@ namespace Microsoft.FSharp.Core inherit Attribute /// Creates an instance of the attribute + /// /// Indicates the text to display when using the '%A' printf formatting. + /// /// StructuredFormatDisplayAttribute new : value:string-> StructuredFormatDisplayAttribute @@ -732,13 +775,16 @@ namespace Microsoft.FSharp.Core /// RequireQualifiedAccessAttribute new : unit -> RequireQualifiedAccessAttribute - /// This attribute is used for two purposes. When applied to an assembly, it must be given a string - /// argument, and this argument must indicate a valid module or namespace in that assembly. Source + /// Indicates a construct is automatically opened when brought into scope through + /// an assembly reference or then opening of the containing namespace or module. + /// + /// When applied to an assembly, this attribute must be given a string + /// argument, and this indicates a valid module or namespace in that assembly. Source /// code files compiled with a reference to this assembly are processed in an environment - /// where the given path is automatically opened. + /// where the given path is automatically opened. /// - /// When applied to a module within an assembly, then the attribute must not be given any arguments. - /// When the enclosing namespace is opened in user source code, the module is also implicitly opened. + /// When applied to a type or module within an assembly, then the attribute must not be given any arguments, and + /// the type or module is implicitly opened when its enclosing namespace or module is opened. [] [] type AutoOpenAttribute = @@ -749,8 +795,10 @@ namespace Microsoft.FSharp.Core new : unit -> AutoOpenAttribute /// Creates an attribute used to mark a namespace or module path to be 'automatically opened' when an assembly is referenced + /// /// The namespace or module to be automatically opened when an assembly is referenced /// or an enclosing module opened. + /// /// AutoOpenAttribute new : path:string-> AutoOpenAttribute @@ -762,49 +810,49 @@ namespace Microsoft.FSharp.Core /// The type of floating point numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to - /// System.Double. + /// . type float<[] 'Measure> = float [] /// The type of floating point numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to - /// System.Single. + /// . type float32<[] 'Measure> = float32 [] /// The type of decimal numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to - /// System.Decimal. + /// . type decimal<[] 'Measure> = decimal [] /// The type of 32-bit signed integer numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to - /// System.Int32. + /// . type int<[] 'Measure> = int [] /// The type of 8-bit signed integer numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to - /// System.SByte. + /// . type sbyte<[] 'Measure> = sbyte [] /// The type of 16-bit signed integer numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to - /// System.Int16. + /// . type int16<[] 'Measure> = int16 [] /// The type of 64-bit signed integer numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to - /// System.Int64. + /// . type int64<[] 'Measure> = int64 /// Represents a managed pointer in F# code. @@ -860,84 +908,110 @@ namespace Microsoft.FSharp.Core module LanguagePrimitives = /// Compare two values for equality using partial equivalence relation semantics ([nan] <> [nan]) + /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericEquality : e1:'T -> e2:'T -> bool when 'T : equality /// Compare two values for equality using equivalence relation semantics ([nan] = [nan]) + /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericEqualityER : e1:'T -> e2:'T -> bool when 'T : equality /// Compare two values for equality + /// /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericEqualityWithComparer : comp:System.Collections.IEqualityComparer -> e1:'T -> e2:'T -> bool when 'T : equality /// Compare two values + /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericComparison : e1:'T -> e2:'T -> int when 'T : comparison /// Compare two values. May be called as a recursive case from an implementation of System.IComparable to /// ensure consistent NaN comparison semantics. + /// /// The function to compare the values. /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericComparisonWithComparer : comp:System.Collections.IComparer -> e1:'T -> e2:'T -> int when 'T : comparison /// Compare two values + /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericLessThan : e1:'T -> e2:'T -> bool when 'T : comparison /// Compare two values + /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericGreaterThan : e1:'T -> e2:'T -> bool when 'T : comparison /// Compare two values + /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericLessOrEqual : e1:'T -> e2:'T -> bool when 'T : comparison /// Compare two values + /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline GenericGreaterOrEqual : e1:'T -> e2:'T -> bool when 'T : comparison /// Take the minimum of two values structurally according to the order given by GenericComparison + /// /// The first value. /// The second value. + /// /// The minimum value. val inline GenericMinimum : e1:'T -> e2:'T -> 'T when 'T : comparison /// Take the maximum of two values structurally according to the order given by GenericComparison + /// /// The first value. /// The second value. + /// /// The maximum value. val inline GenericMaximum : e1:'T -> e2:'T -> 'T when 'T : comparison /// Reference/physical equality. /// True if the inputs are reference-equal, false otherwise. + /// /// The first value. /// The second value. + /// /// The result of the comparison. val inline PhysicalEquality : e1:'T -> e2:'T -> bool when 'T : not struct /// The physical hash. Hashes on the object identity, except for value types, /// where we hash on the contents. + /// /// The input object. + /// /// The hashed value. val inline PhysicalHash : obj:'T -> int when 'T : not struct @@ -966,7 +1040,9 @@ namespace Microsoft.FSharp.Core /// Make an F# hash/equality object for the given type using node-limited hashing when hashing F# /// records, lists and union types. + /// /// The input limit on the number of nodes. + /// /// System.Collections.Generic.IEqualityComparer<'T> val inline FastLimitedGenericEqualityComparer<'T> : limit: int -> System.Collections.Generic.IEqualityComparer<'T> when 'T : equality @@ -980,85 +1056,117 @@ namespace Microsoft.FSharp.Core /// Hash a value according to its structure. This hash is not limited by an overall node count when hashing F# /// records, lists and union types. + /// /// The input object. + /// /// The hashed value. val inline GenericHash : obj:'T -> int /// Hash a value according to its structure. Use the given limit to restrict the hash when hashing F# /// records, lists and union types. + /// /// The limit on the number of nodes. /// The input object. + /// /// The hashed value. val inline GenericLimitedHash : limit: int -> obj:'T -> int /// Recursively hash a part of a value according to its structure. + /// /// The comparison function. /// The input object. + /// /// The hashed value. val inline GenericHashWithComparer : comparer : System.Collections.IEqualityComparer -> obj:'T -> int /// Build an enum value from an underlying value + /// /// The input value. + /// /// The value as an enumeration. val inline EnumOfValue : value:'T -> 'Enum when 'Enum : enum<'T> /// Get the underlying value for an enum value + /// /// The input enum. + /// /// The enumeration as a value. val inline EnumToValue : enum:'Enum -> 'T when 'Enum : enum<'T> /// Creates a float value with units-of-measure + /// /// The input float. + /// /// The float with units-of-measure. val inline FloatWithMeasure : float -> float<'Measure> /// Creates a float32 value with units-of-measure + /// /// The input float. + /// /// The float with units-of-measure. val inline Float32WithMeasure : float32 -> float32<'Measure> /// Creates a decimal value with units-of-measure + /// /// The input decimal. + /// /// The decimal with units of measure. val inline DecimalWithMeasure : decimal -> decimal<'Measure> /// Creates an int32 value with units-of-measure + /// /// The input int. + /// /// The int with units of measure. val inline Int32WithMeasure : int -> int<'Measure> /// Creates an int64 value with units-of-measure + /// /// The input int64. + /// /// The int64 with units of measure. val inline Int64WithMeasure : int64 -> int64<'Measure> /// Creates an int16 value with units-of-measure + /// /// The input int16. + /// /// The int16 with units-of-measure. val inline Int16WithMeasure : int16 -> int16<'Measure> /// Creates an sbyte value with units-of-measure + /// /// The input sbyte. + /// /// The sbyte with units-of-measure. val inline SByteWithMeasure : sbyte -> sbyte<'Measure> /// Parse an int32 according to the rules used by the overloaded 'int32' conversion operator when applied to strings + /// /// The input string. + /// /// The parsed value. val ParseInt32 : s:string -> int32 /// Parse an uint32 according to the rules used by the overloaded 'uint32' conversion operator when applied to strings + /// /// The input string. + /// /// The parsed value. val ParseUInt32 : s:string -> uint32 /// Parse an int64 according to the rules used by the overloaded 'int64' conversion operator when applied to strings + /// /// The input string. + /// /// The parsed value. val ParseInt64 : s:string -> int64 /// Parse an uint64 according to the rules used by the overloaded 'uint64' conversion operator when applied to strings + /// /// The input string. + /// /// The parsed value. val ParseUInt64 : s:string -> uint64 @@ -1194,8 +1302,10 @@ namespace Microsoft.FSharp.Core val internal anyToStringShowingNull : 'T -> string /// Divides a value by an integer. + /// /// The input value. /// The input int. + /// /// The division result. val inline DivideByInt< ^T > : x:^T -> y:int -> ^T when ^T : (static member DivideByInt : ^T * int -> ^T) @@ -1228,8 +1338,10 @@ namespace Microsoft.FSharp.Core val ( & ) : e1:bool -> e2:bool -> bool /// Binary 'and'. When used as a binary operator the right hand value is evaluated only on demand + /// /// The first value. /// The second value. + /// /// The result of the operation. val ( && ) : e1:bool -> e2:bool -> bool @@ -1239,18 +1351,24 @@ namespace Microsoft.FSharp.Core val ( or ) : e1:bool -> e2:bool -> bool /// Binary 'or'. When used as a binary operator the right hand value is evaluated only on demand + /// /// The first value. /// The second value. + /// /// The result of the operation. val ( || ) : e1:bool -> e2:bool -> bool /// Address-of. Uses of this value may result in the generation of unverifiable code. + /// /// The input object. + /// /// The managed pointer. val inline ( ~& ) : obj:'T -> byref<'T> /// Address-of. Uses of this value may result in the generation of unverifiable code. + /// /// The input object. + /// /// The unmanaged pointer. val inline ( ~&& ) : obj:'T -> nativeptr<'T> @@ -1585,65 +1703,83 @@ namespace Microsoft.FSharp.Core new : unit -> FSharpFunc<'T,'U> /// Invoke an F# first class function value with one argument + /// /// + /// /// 'U abstract member Invoke : func:'T -> 'U - /// Convert an F# first class function value to a value of type System.Converter + /// Convert an F# first class function value to a value of type + /// /// The input function. + /// /// A System.Converter of the function type. static member op_Implicit : func:('T -> 'U) -> System.Converter<'T,'U> - /// Convert an value of type System.Converter to a F# first class function value + /// Convert an value of type to a F# first class function value + /// /// The input System.Converter. + /// /// An F# function of the same type. static member op_Implicit : converter:System.Converter<'T,'U> -> ('T -> 'U) - /// Convert an F# first class function value to a value of type System.Converter + /// Convert an F# first class function value to a value of type + /// /// The input function. + /// /// System.Converter<'T,'U> static member ToConverter : func:('T -> 'U) -> System.Converter<'T,'U> - /// Convert an value of type System.Converter to a F# first class function value + /// Convert an value of type to a F# first class function value + /// /// The input System.Converter. + /// /// An F# function of the same type. static member FromConverter : converter:System.Converter<'T,'U> -> ('T -> 'U) /// Invoke an F# first class function value with five curried arguments. In some cases this /// will result in a more efficient application than applying the arguments successively. + /// /// The input function. /// The first arg. /// The second arg. /// The third arg. /// The fourth arg. /// The fifth arg. + /// /// The function result. static member InvokeFast : func: FSharpFunc<'T,('U -> 'V -> 'W -> 'X -> 'Y)> * arg1:'T * arg2:'U * arg3:'V * arg4:'W * arg5:'X -> 'Y /// Invoke an F# first class function value with four curried arguments. In some cases this /// will result in a more efficient application than applying the arguments successively. + /// /// The input function. /// The first arg. /// The second arg. /// The third arg. /// The fourth arg. + /// /// The function result. static member InvokeFast : func: FSharpFunc<'T,('U -> 'V -> 'W -> 'X)> * arg1:'T * arg2:'U * arg3:'V * arg4:'W -> 'X /// Invoke an F# first class function value with three curried arguments. In some cases this /// will result in a more efficient application than applying the arguments successively. + /// /// The input function. /// The first arg. /// The second arg. /// The third arg. + /// /// The function result. static member InvokeFast : func: FSharpFunc<'T,('U -> 'V -> 'W)> * arg1:'T * arg2:'U * arg3:'V -> 'W /// Invoke an F# first class function value with two curried arguments. In some cases this /// will result in a more efficient application than applying the arguments successively. + /// /// The input function. /// The first arg. /// The second arg. + /// /// The function result. static member InvokeFast : func: FSharpFunc<'T,('U -> 'V)> * arg1:'T * arg2:'U -> 'V @@ -1654,92 +1790,128 @@ namespace Microsoft.FSharp.Core type FuncConvert = /// Convert the given Action delegate object to an F# function value + /// /// The input Action delegate. + /// /// The F# function. static member inline ToFSharpFunc : action:Action<'T> -> ('T -> unit) /// Convert the given Converter delegate object to an F# function value + /// /// The input Converter delegate. + /// /// The F# function. static member inline ToFSharpFunc : converter:Converter<'T,'U> -> ('T -> 'U) /// Convert the given Action delegate object to an F# function value + /// /// The input Action delegate. + /// /// The F# function. static member inline FromAction : action:Action -> (unit -> unit) /// Convert the given Action delegate object to an F# function value + /// /// The input Action delegate. + /// /// The F# function. static member inline FromAction : action:Action<'T> -> ('T -> unit) /// Convert the given Action delegate object to an F# function value + /// /// The input Action delegate. + /// /// The F#funcfunction. static member inline FromAction : action:Action<'T1,'T2> -> ('T1 -> 'T2 -> unit) /// Convert the given Action delegate object to an F# function value + /// /// The input Action delegate. + /// /// The F# function. static member inline FromAction : action:Action<'T1,'T2,'T3> -> ('T1 -> 'T2 -> 'T3 -> unit) /// Convert the given Action delegate object to an F# function value + /// /// The input Action delegate. + /// /// The F# function. static member inline FromAction : action:Action<'T1,'T2,'T3,'T4> -> ('T1 -> 'T2 -> 'T3 -> 'T4 -> unit) /// Convert the given Action delegate object to an F# function value + /// /// The input Action delegate. + /// /// The F# function. static member inline FromAction : action:Action<'T1,'T2,'T3,'T4,'T5> -> ('T1 -> 'T2 -> 'T3 -> 'T4 -> 'T5 -> unit) /// Convert the given Func delegate object to an F# function value + /// /// The input Func delegate. + /// /// The F# function. static member inline FromFunc : func:Func<'T> -> (unit -> 'T) /// Convert the given Func delegate object to an F# function value + /// /// The input Func delegate. + /// /// The F# function. static member inline FromFunc : func:Func<'T,'U> -> ('T -> 'U) /// Convert the given Func delegate object to an F# function value + /// /// The input Func delegate. + /// /// The F#funcfunction. static member inline FromFunc : func:Func<'T1,'T2,'U> -> ('T1 -> 'T2 -> 'U) /// Convert the given Func delegate object to an F# function value + /// /// The input Func delegate. + /// /// The F# function. static member inline FromFunc : func:Func<'T1,'T2,'T3,'U> -> ('T1 -> 'T2 -> 'T3 -> 'U) /// Convert the given Func delegate object to an F# function value + /// /// The input Func delegate. + /// /// The F# function. static member inline FromFunc : func:Func<'T1,'T2,'T3,'T4,'U> -> ('T1 -> 'T2 -> 'T3 -> 'T4 -> 'U) /// Convert the given Func delegate object to an F# function value + /// /// The input Func delegate. + /// /// The F# function. static member inline FromFunc : func:Func<'T1,'T2,'T3,'T4,'T5,'U> -> ('T1 -> 'T2 -> 'T3 -> 'T4 -> 'T5 -> 'U) /// A utility function to convert function values from tupled to curried form + /// /// The input tupled function. + /// /// The output curried function. static member inline FuncFromTupled : func:('T1 * 'T2 -> 'U) -> ('T1 -> 'T2 -> 'U) /// A utility function to convert function values from tupled to curried form + /// /// The input tupled function. + /// /// The output curried function. static member inline FuncFromTupled : func:('T1 * 'T2 * 'T3 -> 'U) -> ('T1 -> 'T2 -> 'T3 -> 'U) /// A utility function to convert function values from tupled to curried form + /// /// The input tupled function. + /// /// The output curried function. static member inline FuncFromTupled : func:('T1 * 'T2 * 'T3 * 'T4 -> 'U) -> ('T1 -> 'T2 -> 'T3 -> 'T4 -> 'U) /// A utility function to convert function values from tupled to curried form + /// /// The input tupled function. + /// /// The output curried function. static member inline FuncFromTupled : func:('T1 * 'T2 * 'T3 * 'T4 * 'T5 -> 'U) -> ('T1 -> 'T2 -> 'T3 -> 'T4 -> 'T5 -> 'U) @@ -1755,14 +1927,18 @@ namespace Microsoft.FSharp.Core inherit FSharpFunc<'T1,('T2 -> 'U)> /// Invoke the optimized function value with two curried arguments + /// /// The first arg. /// The second arg. + /// /// The function result. abstract member Invoke : arg1:'T1 * arg2:'T2 -> 'U /// Adapt an F# first class function value to be an optimized function value that can /// accept two curried arguments without intervening execution. + /// /// The input function. + /// /// The adapted function. static member Adapt : func:('T1 -> 'T2 -> 'U) -> FSharpFunc<'T1,'T2,'U> @@ -1781,15 +1957,19 @@ namespace Microsoft.FSharp.Core /// Invoke an F# first class function value that accepts three curried arguments /// without intervening execution + /// /// The first arg. /// The second arg. /// The third arg. + /// /// The function result. abstract member Invoke : arg1:'T1 * arg2:'T2 * arg3:'T3 -> 'U /// Adapt an F# first class function value to be an optimized function value that can /// accept three curried arguments without intervening execution. + /// /// The input function. + /// /// The adapted function. static member Adapt : func:('T1 -> 'T2 -> 'T3 -> 'U) -> FSharpFunc<'T1,'T2,'T3,'U> @@ -1807,16 +1987,20 @@ namespace Microsoft.FSharp.Core /// Invoke an F# first class function value that accepts four curried arguments /// without intervening execution + /// /// The first arg. /// The second arg. /// The third arg. /// The fourth arg. + /// /// The function result. abstract member Invoke : arg1:'T1 * arg2:'T2 * arg3:'T3 * arg4:'T4 -> 'U /// Adapt an F# first class function value to be an optimized function value that can /// accept four curried arguments without intervening execution. + /// /// The input function. + /// /// The optimized function. static member Adapt : func:('T1 -> 'T2 -> 'T3 -> 'T4 -> 'U) -> FSharpFunc<'T1,'T2,'T3,'T4,'U> @@ -1834,17 +2018,21 @@ namespace Microsoft.FSharp.Core /// Invoke an F# first class function value that accepts five curried arguments /// without intervening execution + /// /// The first arg. /// The second arg. /// The third arg. /// The fourth arg. /// The fifth arg. + /// /// The function result. abstract member Invoke : arg1:'T1 * arg2:'T2 * arg3:'T3 * arg4:'T4 * arg5:'T5 -> 'U /// Adapt an F# first class function value to be an optimized function value that can /// accept five curried arguments without intervening execution. + /// /// The input function. + /// /// The optimized function. static member Adapt : func:('T1 -> 'T2 -> 'T3 -> 'T4 -> 'T5 -> 'U) -> FSharpFunc<'T1,'T2,'T3,'T4,'T5,'U> @@ -1888,7 +2076,9 @@ namespace Microsoft.FSharp.Core | None : 'T option /// The representation of "Value of type 'T" + /// /// The input value. + /// /// An option representing the value. | Some : Value:'T -> 'T option @@ -1896,12 +2086,16 @@ namespace Microsoft.FSharp.Core static member None : 'T option /// Create an option value that is a 'Some' value. + /// /// The input value + /// /// An option representing the value. static member Some : value:'T -> 'T option /// Implicitly converts a value into an optional that is a 'Some' value. + /// /// The input value + /// /// An option representing the value. static member op_Implicit : value:'T -> 'T option @@ -1940,7 +2134,9 @@ namespace Microsoft.FSharp.Core | ValueNone: 'T voption /// The representation of "Value of type 'T" + /// /// The input value. + /// /// An option representing the value. | ValueSome: 'T -> 'T voption @@ -1951,7 +2147,9 @@ namespace Microsoft.FSharp.Core static member None : 'T voption /// Create a value option value that is a 'Some' value. + /// /// The input value + /// /// A value option representing the value. static member Some : value:'T -> 'T voption @@ -1962,7 +2160,9 @@ namespace Microsoft.FSharp.Core member IsNone : bool /// Implicitly converts a value into an optional that is a 'ValueSome' value. + /// /// The input value + /// /// A voption representing the value. static member op_Implicit: value: 'T -> 'T voption @@ -2022,25 +2222,32 @@ namespace Microsoft.FSharp.Collections /// Gets the element of the list at the given position. /// Lists are represented as linked lists so this is an O(n) operation. /// The index. + /// /// The value at the given index. member Item : index:int -> 'T with get /// Gets a slice of the list, the elements of the list from the given start index to the given end index. + /// /// The start index. /// The end index. + /// /// The sub list specified by the input indices. member GetSlice : startIndex:int option * endIndex:int option -> 'T list /// Get the index for the element offset elements away from the end of the collection. + /// /// The rank of the index. /// The offset from the end. + /// /// The corresponding index from the start. [] member GetReverseIndex: rank: int * offset: int -> int /// Returns a list with head as its first element and tail as its subsequent elements + /// /// A new head value for the list. /// The existing list. + /// /// The list with head appended to the front of tail. static member Cons : head:'T * tail:'T list -> 'T list @@ -2056,10 +2263,10 @@ namespace Microsoft.FSharp.Collections /// values of this type, or pattern match against the values directly. and 'T list = List<'T> - /// An abbreviation for the CLI type System.Collections.Generic.List<_> + /// An abbreviation for the CLI type type ResizeArray<'T> = System.Collections.Generic.List<'T> - /// An abbreviation for the CLI type System.Collections.Generic.IEnumerable<_> + /// An abbreviation for the CLI type type seq<'T> = IEnumerable<'T> namespace Microsoft.FSharp.Core @@ -2074,180 +2281,238 @@ namespace Microsoft.FSharp.Core module Operators = /// Overloaded unary negation. + /// /// The value to negate. + /// /// The result of the operation. val inline ( ~- ) : n:^T -> ^T when ^T : (static member ( ~- ) : ^T -> ^T) and default ^T : int /// Overloaded addition operator + /// /// The first parameter. /// The second parameter. + /// /// The result of the operation. val inline ( + ) : x:^T1 -> y:^T2 -> ^T3 when (^T1 or ^T2) : (static member ( + ) : ^T1 * ^T2 -> ^T3) and default ^T2 : ^T3 and default ^T3 : ^T1 and default ^T3 : ^T2 and default ^T1 : ^T3 and default ^T1 : ^T2 and default ^T1 : int /// Overloaded subtraction operator + /// /// The first parameter. /// The second parameter. + /// /// The result of the operation. val inline ( - ) : x:^T1 -> y:^T2 -> ^T3 when (^T1 or ^T2) : (static member ( - ) : ^T1 * ^T2 -> ^T3) and default ^T2 : ^T3 and default ^T3 : ^T1 and default ^T3 : ^T2 and default ^T1 : ^T3 and default ^T1 : ^T2 and default ^T1 : int /// Overloaded multiplication operator + /// /// The first parameter. /// The second parameter. + /// /// The result of the operation. val inline ( * ) : x:^T1 -> y:^T2 -> ^T3 when (^T1 or ^T2) : (static member ( * ) : ^T1 * ^T2 -> ^T3) and default ^T2 : ^T3 and default ^T3 : ^T1 and default ^T3 : ^T2 and default ^T1 : ^T3 and default ^T1 : ^T2 and default ^T1 : int /// Overloaded division operator + /// /// The first parameter. /// The second parameter. + /// /// The result of the operation. val inline ( / ) : x:^T1 -> y:^T2 -> ^T3 when (^T1 or ^T2) : (static member ( / ) : ^T1 * ^T2 -> ^T3) and default ^T2 : ^T3 and default ^T3 : ^T1 and default ^T3 : ^T2 and default ^T1 : ^T3 and default ^T1 : ^T2 and default ^T1 : int /// Overloaded modulo operator + /// /// The first parameter. /// The second parameter. + /// /// The result of the operation. val inline ( % ) : x:^T1 -> y:^T2 -> ^T3 when (^T1 or ^T2) : (static member ( % ) : ^T1 * ^T2 -> ^T3) and default ^T2 : ^T3 and default ^T3 : ^T1 and default ^T3 : ^T2 and default ^T1 : ^T3 and default ^T1 : ^T2 and default ^T1 : int /// Overloaded bitwise-AND operator + /// /// The first parameter. /// The second parameter. + /// /// The result of the operation. val inline (&&&): x:^T -> y:^T -> ^T when ^T : (static member (&&&) : ^T * ^T -> ^T) and default ^T : int /// Overloaded bitwise-OR operator + /// /// The first parameter. /// The second parameter. + /// /// The result of the operation. val inline (|||) : x:^T -> y:^T -> ^T when ^T : (static member (|||) : ^T * ^T -> ^T) and default ^T : int /// Overloaded bitwise-XOR operator + /// /// The first parameter. /// The second parameter. + /// /// The result of the operation. val inline (^^^) : x:^T -> y:^T -> ^T when ^T : (static member (^^^) : ^T * ^T -> ^T) and default ^T : int /// Overloaded byte-shift left operator by a specified number of bits + /// /// The input value. /// The amount to shift. + /// /// The result of the operation. val inline (<<<) : value:^T -> shift:int32 -> ^T when ^T : (static member (<<<) : ^T * int32 -> ^T) and default ^T : int /// Overloaded byte-shift right operator by a specified number of bits + /// /// The input value. /// The amount to shift. + /// /// The result of the operation. val inline (>>>) : value:^T -> shift:int32 -> ^T when ^T : (static member (>>>) : ^T * int32 -> ^T) and default ^T : int /// Overloaded bitwise-NOT operator + /// /// The input value. + /// /// The result of the operation. val inline (~~~) : value:^T -> ^T when ^T : (static member (~~~) : ^T -> ^T) and default ^T : int /// Overloaded prefix-plus operator + /// /// The input value. + /// /// The result of the operation. val inline (~+) : value:^T -> ^T when ^T : (static member (~+) : ^T -> ^T) and default ^T : int /// Structural less-than comparison + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( < ) : x:'T -> y:'T -> bool when 'T : comparison /// Structural greater-than + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( > ) : x:'T -> y:'T -> bool when 'T : comparison /// Structural greater-than-or-equal + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( >= ) : x:'T -> y:'T -> bool when 'T : comparison /// Structural less-than-or-equal comparison + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( <= ) : x:'T -> y:'T -> bool when 'T : comparison /// Structural equality + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( = ) : x:'T -> y:'T -> bool when 'T : equality /// Structural inequality + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( <> ) : x:'T -> y:'T -> bool when 'T : equality /// Compose two functions, the function on the left being applied first + /// /// The first function to apply. /// The second function to apply. + /// /// The composition of the input functions. val inline (>>): func1:('T1 -> 'T2) -> func2:('T2 -> 'T3) -> ('T1 -> 'T3) /// Compose two functions, the function on the right being applied first + /// /// The second function to apply. /// The first function to apply. + /// /// The composition of the input functions. val inline (<<): func2:('T2 -> 'T3) -> func1:('T1 -> 'T2) -> ('T1 -> 'T3) /// Apply a function to a value, the value being on the left, the function on the right + /// /// The argument. /// The function. + /// /// The function result. val inline (|>): arg:'T1 -> func:('T1 -> 'U) -> 'U /// Apply a function to two values, the values being a pair on the left, the function on the right + /// /// The first argument. /// The second argument. /// The function. + /// /// The function result. val inline (||>): arg1:'T1 * arg2:'T2 -> func:('T1 -> 'T2 -> 'U) -> 'U /// Apply a function to three values, the values being a triple on the left, the function on the right + /// /// The first argument. /// The second argument. /// The third argument. /// The function. + /// /// The function result. val inline (|||>): arg1:'T1 * arg2:'T2 * arg3:'T3 -> func:('T1 -> 'T2 -> 'T3 -> 'U) -> 'U /// Apply a function to a value, the value being on the right, the function on the left + /// /// The function. /// The argument. + /// /// The function result. val inline (<|): func:('T -> 'U) -> arg1:'T -> 'U /// Apply a function to two values, the values being a pair on the right, the function on the left + /// /// The function. /// The first argument. /// The second argument. + /// /// The function result. val inline (<||): func:('T1 -> 'T2 -> 'U) -> arg1:'T1 * arg2:'T2 -> 'U /// Apply a function to three values, the values being a triple on the right, the function on the left + /// /// The function. /// The first argument. /// The second argument. /// The third argument. + /// /// The function result. val inline (<|||): func:('T1 -> 'T2 -> 'T3 -> 'U) -> arg1:'T1 * arg2:'T2 * arg3:'T3 -> 'U /// Used to specify a default value for an optional argument in the implementation of a function + /// /// An option representing the argument. /// The default value of the argument. + /// /// The argument value. If it is None, the defaultValue is returned. [] val defaultArg : arg:'T option -> defaultValue:'T -> 'T /// Used to specify a default value for an optional argument in the implementation of a function + /// /// A value option representing the argument. /// The default value of the argument. + /// /// The argument value. If it is None, the defaultValue is returned. [] val defaultValueArg : arg:'T voption -> defaultValue:'T -> 'T @@ -2257,7 +2522,9 @@ namespace Microsoft.FSharp.Core val (^): s1:string -> s2:string -> string /// Raises an exception + /// /// The exception to raise. + /// /// The result value. [] val inline raise : exn:System.Exception -> 'T @@ -2273,199 +2540,251 @@ namespace Microsoft.FSharp.Core [] val inline reraise : unit -> 'T - /// Builds a System.Exception object. + /// Builds a object. + /// /// The message for the Exception. + /// /// A System.Exception. val Failure : message:string -> exn - /// Matches System.Exception objects whose runtime type is precisely System.Exception + /// Matches objects whose runtime type is precisely + /// /// The input exception. + /// /// A string option. [] val (|Failure|_|) : error:exn -> string option /// Return the first element of a tuple, fst (a,b) = a. + /// /// The input tuple. + /// /// The first value. [] val inline fst : tuple:('T1 * 'T2) -> 'T1 /// Return the second element of a tuple, snd (a,b) = b. + /// /// The input tuple. + /// /// The second value. [] val inline snd : tuple:('T1 * 'T2) -> 'T2 /// Generic comparison. + /// /// The first value. /// The second value. + /// /// The result of the comparison. [] val inline compare: e1:'T -> e2:'T -> int when 'T : comparison /// Maximum based on generic comparison + /// /// The first value. /// The second value. + /// /// The maximum value. [] val inline max : e1:'T -> e2:'T -> 'T when 'T : comparison /// Minimum based on generic comparison + /// /// The first value. /// The second value. + /// /// The minimum value. [] val inline min : e1:'T -> e2:'T -> 'T when 'T : comparison /// Ignore the passed value. This is often used to throw away results of a computation. + /// /// The value to ignore. [] val inline ignore : value:'T -> unit /// Unbox a strongly typed value. + /// /// The boxed value. + /// /// The unboxed result. [] val inline unbox : value:obj -> 'T /// Boxes a strongly typed value. + /// /// The value to box. + /// /// The boxed object. [] val inline box : value:'T -> obj /// Try to unbox a strongly typed value. + /// /// The boxed value. + /// /// The unboxed result as an option. [] val inline tryUnbox : value:obj -> 'T option /// Determines whether the given value is null. + /// /// The value to check. + /// /// True when value is null, false otherwise. [] val inline isNull : value:'T -> bool when 'T : null /// Determines whether the given value is not null. + /// /// The value to check. + /// /// True when value is not null, false otherwise. [] val inline internal isNotNull : value:'T -> bool when 'T : null - /// Throw a System.Exception exception. + /// Throw a exception. + /// /// The exception message. + /// /// The result value. [] val inline failwith : message:string -> 'T - /// Throw a System.ArgumentException exception with + /// Throw a exception with /// the given argument name and message. + /// /// The argument name. /// The exception message. + /// /// The result value. [] val inline invalidArg : argumentName:string -> message:string -> 'T - /// Throw a System.ArgumentNullException exception + /// Throw a exception + /// /// The argument name. + /// /// The result value. [] val inline nullArg : argumentName:string -> 'T - /// Throw a System.InvalidOperationException exception + /// Throw a exception + /// /// The exception message. + /// /// The result value. [] val inline invalidOp : message:string -> 'T /// The identity function + /// /// The input value. + /// /// The same value. [] val id : x:'T -> 'T /// Create a mutable reference cell + /// /// The value to contain in the cell. + /// /// The created reference cell. [] val ref : value:'T -> 'T ref /// Assign to a mutable reference cell + /// /// The cell to mutate. /// The value to set inside the cell. val ( := ) : cell:'T ref -> value:'T -> unit /// Dereference a mutable reference cell + /// /// The cell to dereference. + /// /// The value contained in the cell. val ( ! ) : cell:'T ref -> 'T /// Decrement a mutable reference cell containing an integer + /// /// The reference cell. [] val decr: cell:int ref -> unit /// Increment a mutable reference cell containing an integer + /// /// The reference cell. [] val incr: cell:int ref -> unit /// Concatenate two lists. + /// /// The first list. /// The second list. + /// /// The concatenation of the lists. val (@): list1:'T list -> list2:'T list -> 'T list /// Negate a logical value. Not True equals False and not False equals True + /// /// The value to negate. + /// /// The result of the negation. [] val inline not : value:bool -> bool /// Builds a sequence using sequence expression syntax + /// /// The input sequence. + /// /// The result sequence. [] val seq : sequence:seq<'T> -> seq<'T> /// Exit the current hardware isolated process, if security settings permit, - /// otherwise raise an exception. Calls System.Environment.Exit. + /// otherwise raise an exception. Calls . + /// /// The exit code to use. + /// /// The result value. [] val exit: exitcode:int -> 'T when default 'T : obj - /// Equivalent to System.Double.PositiveInfinity + /// Equivalent to [] val infinity: float - /// Equivalent to System.Double.NaN + /// Equivalent to [] val nan: float - /// Equivalent to System.Single.PositiveInfinity + /// Equivalent to [] val infinityf: float32 - /// Equivalent to System.Single.NaN + /// Equivalent to [] val nanf: float32 - /// Reads the value of the property System.Console.In. + /// Reads the value of the property . [] val stdin<'T> : System.IO.TextReader - /// Reads the value of the property System.Console.Error. + /// Reads the value of the property . [] val stderr<'T> : System.IO.TextWriter - /// Reads the value of the property System.Console.Out. + /// Reads the value of the property . [] val stdout<'T> : System.IO.TextWriter /// The standard overloaded range operator, e.g. [n..m] for lists, seq {n..m} for sequences + /// /// The start value of the range. /// The end value of the range. + /// /// The sequence spanning the range. val inline (..) : start:^T -> finish:^T -> seq< ^T > when ^T : (static member (+) : ^T * ^T -> ^T) @@ -2475,9 +2794,11 @@ namespace Microsoft.FSharp.Core and default ^T : int /// The standard overloaded skip range operator, e.g. [n..skip..m] for lists, seq {n..skip..m} for sequences + /// /// The start value of the range. /// The step value of the range. /// The end value of the range. + /// /// The sequence spanning the range using the specified step size. val inline (.. ..) : start:^T -> step:^Step -> finish:^T -> seq< ^T > when (^T or ^Step) : (static member (+) : ^T * ^Step -> ^T) @@ -2488,8 +2809,10 @@ namespace Microsoft.FSharp.Core and default ^T : int /// Execute the function as a mutual-exclusion region using the input value as a lock. + /// /// The object to be locked. /// The action to perform during the lock. + /// /// The resulting value. [] val inline lock: lockObject:'Lock -> action:(unit -> 'T) -> 'T when 'Lock : not struct @@ -2497,8 +2820,10 @@ namespace Microsoft.FSharp.Core /// Clean up resources associated with the input object after the completion of the given function. /// Cleanup occurs even when an exception is raised by the protected /// code. + /// /// The resource to be disposed after action is called. /// The action that accepts the resource. + /// /// The resulting value. [] val using: resource:('T :> System.IDisposable) -> action:('T -> 'U) -> 'U @@ -2539,7 +2864,9 @@ namespace Microsoft.FSharp.Core /// for F# union, record and tuple types, hashing the complete contents of the /// type. The exact behaviour of the function can be adjusted on a /// type-by-type basis by implementing GetHashCode for each type. + /// /// The input object. + /// /// The computed hash. [] val inline hash: obj:'T -> int when 'T : equality @@ -2549,142 +2876,188 @@ namespace Microsoft.FSharp.Core /// types stops when the given limit of nodes is reached. The exact behaviour of /// the function can be adjusted on a type-by-type basis by implementing /// GetHashCode for each type. + /// /// The limit of nodes. /// The input object. + /// /// The computed hash. val inline limitedHash: limit: int -> obj:'T -> int when 'T : equality /// Absolute value of the given number. + /// /// The input value. + /// /// The absolute value of the input. [] val inline abs : value:^T -> ^T when ^T : (static member Abs : ^T -> ^T) and default ^T : int /// Inverse cosine of the given number + /// /// The input value. + /// /// The inverse cosine of the input. [] val inline acos : value:^T -> ^T when ^T : (static member Acos : ^T -> ^T) and default ^T : float /// Inverse sine of the given number + /// /// The input value. + /// /// The inverse sine of the input. [] val inline asin : value:^T -> ^T when ^T : (static member Asin : ^T -> ^T) and default ^T : float /// Inverse tangent of the given number + /// /// The input value. + /// /// The inverse tangent of the input. [] val inline atan : value:^T -> ^T when ^T : (static member Atan : ^T -> ^T) and default ^T : float /// Inverse tangent of x/y where x and y are specified separately + /// /// The y input value. /// The x input value. + /// /// The inverse tangent of the input ratio. [] val inline atan2 : y:^T1 -> x:^T1 -> 'T2 when ^T1 : (static member Atan2 : ^T1 * ^T1 -> 'T2) and default ^T1 : float /// Ceiling of the given number + /// /// The input value. + /// /// The ceiling of the input. [] val inline ceil : value:^T -> ^T when ^T : (static member Ceiling : ^T -> ^T) and default ^T : float /// Exponential of the given number + /// /// The input value. + /// /// The exponential of the input. [] val inline exp : value:^T -> ^T when ^T : (static member Exp : ^T -> ^T) and default ^T : float /// Floor of the given number + /// /// The input value. + /// /// The floor of the input. [] val inline floor : value:^T -> ^T when ^T : (static member Floor : ^T -> ^T) and default ^T : float /// Sign of the given number + /// /// The input value. + /// /// -1, 0, or 1 depending on the sign of the input. [] val inline sign : value:^T -> int when ^T : (member Sign : int) and default ^T : float /// Round the given number + /// /// The input value. + /// /// The nearest integer to the input value. [] val inline round : value:^T -> ^T when ^T : (static member Round : ^T -> ^T) and default ^T : float /// Natural logarithm of the given number + /// /// The input value. + /// /// The natural logarithm of the input. [] val inline log : value:^T -> ^T when ^T : (static member Log : ^T -> ^T) and default ^T : float /// Logarithm to base 10 of the given number + /// /// The input value. + /// /// The logarithm to base 10 of the input. [] val inline log10 : value:^T -> ^T when ^T : (static member Log10 : ^T -> ^T) and default ^T : float /// Square root of the given number + /// /// The input value. + /// /// The square root of the input. [] val inline sqrt : value:^T -> ^U when ^T : (static member Sqrt : ^T -> ^U) and default ^U : ^T and default ^T : ^U and default ^T : float /// Cosine of the given number + /// /// The input value. + /// /// The cosine of the input. [] val inline cos : value:^T -> ^T when ^T : (static member Cos : ^T -> ^T) and default ^T : float /// Hyperbolic cosine of the given number + /// /// The input value. + /// /// The hyperbolic cosine of the input. [] val inline cosh : value:^T -> ^T when ^T : (static member Cosh : ^T -> ^T) and default ^T : float /// Sine of the given number + /// /// The input value. + /// /// The sine of the input. [] val inline sin : value:^T -> ^T when ^T : (static member Sin : ^T -> ^T) and default ^T : float /// Hyperbolic sine of the given number + /// /// The input value. + /// /// The hyperbolic sine of the input. [] val inline sinh : value:^T -> ^T when ^T : (static member Sinh : ^T -> ^T) and default ^T : float /// Tangent of the given number + /// /// The input value. + /// /// The tangent of the input. [] val inline tan : value:^T -> ^T when ^T : (static member Tan : ^T -> ^T) and default ^T : float /// Hyperbolic tangent of the given number + /// /// The input value. + /// /// The hyperbolic tangent of the input. [] val inline tanh : value:^T -> ^T when ^T : (static member Tanh : ^T -> ^T) and default ^T : float /// Overloaded truncate operator. + /// /// The input value. + /// /// The truncated value. [] val inline truncate : value:^T -> ^T when ^T : (static member Truncate : ^T -> ^T) and default ^T : float /// Overloaded power operator. + /// /// The input base. /// The input exponent. + /// /// The base raised to the exponent. val inline ( ** ) : x:^T -> y:^U -> ^T when ^T : (static member Pow : ^T * ^U -> ^T) and default ^U : float and default ^T : float /// Overloaded power operator. If n > 0 then equivalent to x*...*x for n occurrences of x. + /// /// The input base. /// The input exponent. + /// /// The base raised to the exponent. [] val inline pown : x:^T -> n:int -> ^T when ^T : (static member One : ^T) @@ -2696,7 +3069,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using Byte.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted byte [] val inline byte : value:^T -> byte when ^T : (static member op_Explicit : ^T -> byte) and default ^T : int @@ -2705,7 +3080,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using SByte.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted sbyte [] val inline sbyte : value:^T -> sbyte when ^T : (static member op_Explicit : ^T -> sbyte) and default ^T : int @@ -2714,7 +3091,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using Int16.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int16 [] val inline int16 : value:^T -> int16 when ^T : (static member op_Explicit : ^T -> int16) and default ^T : int @@ -2723,7 +3102,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using UInt16.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint16 [] val inline uint16 : value:^T -> uint16 when ^T : (static member op_Explicit : ^T -> uint16) and default ^T : int @@ -2732,7 +3113,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using Int32.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int [] val inline int : value:^T -> int when ^T : (static member op_Explicit : ^T -> int) and default ^T : int @@ -2741,13 +3124,17 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using UInt32.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int [] val inline uint: value:^T -> uint when ^T: (static member op_Explicit: ^T -> uint) and default ^T: uint /// Converts the argument to a particular enum type. + /// /// The input value. + /// /// The converted enum type. [] val inline enum : value:int32 -> ^U when ^U : enum @@ -2756,7 +3143,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using Int32.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int32 [] val inline int32 : value:^T -> int32 when ^T : (static member op_Explicit : ^T -> int32) and default ^T : int @@ -2765,7 +3154,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using UInt32.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint32 [] val inline uint32 : value:^T -> uint32 when ^T : (static member op_Explicit : ^T -> uint32) and default ^T : int @@ -2774,7 +3165,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using Int64.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int64 [] val inline int64 : value:^T -> int64 when ^T : (static member op_Explicit : ^T -> int64) and default ^T : int @@ -2783,7 +3176,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using UInt64.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint64 [] val inline uint64 : value:^T -> uint64 when ^T : (static member op_Explicit : ^T -> uint64) and default ^T : int @@ -2792,7 +3187,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using Single.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted float32 [] val inline float32 : value:^T -> float32 when ^T : (static member op_Explicit : ^T -> float32) and default ^T : int @@ -2801,7 +3198,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using Double.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted float [] val inline float : value:^T -> float when ^T : (static member op_Explicit : ^T -> float) and default ^T : int @@ -2809,7 +3208,9 @@ namespace Microsoft.FSharp.Core /// Converts the argument to signed native integer. This is a direct conversion for all /// primitive numeric types. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted nativeint [] val inline nativeint : value:^T -> nativeint when ^T : (static member op_Explicit : ^T -> nativeint) and default ^T : int @@ -2817,7 +3218,9 @@ namespace Microsoft.FSharp.Core /// Converts the argument to unsigned native integer using a direct conversion for all /// primitive numeric types. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted unativeint [] val inline unativeint : value:^T -> unativeint when ^T : (static member op_Explicit : ^T -> unativeint) and default ^T : int @@ -2827,6 +3230,7 @@ namespace Microsoft.FSharp.Core /// For standard integer and floating point values the ToString conversion /// uses CultureInfo.InvariantCulture. /// The input value. + /// /// The converted string. [] val inline string : value:^T -> string @@ -2835,7 +3239,9 @@ namespace Microsoft.FSharp.Core /// primitive numeric types. For strings, the input is converted using UInt64.Parse() /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted decimal. [] val inline decimal : value:^T -> decimal when ^T : (static member op_Explicit : ^T -> decimal) and default ^T : int @@ -2843,13 +3249,17 @@ namespace Microsoft.FSharp.Core /// Converts the argument to character. Numeric inputs are converted according to the UTF-16 /// encoding for characters. String inputs must be exactly one character long. For other /// input types the operation requires an appropriate static conversion method on the input type. + /// /// The input value. + /// /// The converted char. [] val inline char : value:^T -> char when ^T : (static member op_Explicit : ^T -> char) and default ^T : int - /// An active pattern to match values of type System.Collections.Generic.KeyValuePair + /// An active pattern to match values of type + /// /// The input key/value pair. + /// /// A tuple containing the key and value. [] val ( |KeyValue| ): keyValuePair:KeyValuePair<'Key,'Value> -> 'Key * 'Value @@ -2859,40 +3269,50 @@ namespace Microsoft.FSharp.Core module ArrayExtensions = type ``[,,,]``<'T> with /// Get the index for the element offset elements away from the end of the collection. + /// /// The rank of the index. This refers to the dimension in the 4d array. /// The offset from the end. + /// /// The corresponding index from the start. [] member GetReverseIndex: rank: int * offset: int -> int type ``[,,]``<'T> with /// Get the index for the element offset elements away from the end of the collection. + /// /// The rank of the index. This refers to the dimension in the 3d array. /// The offset from the end. + /// /// The corresponding index from the start. [] member GetReverseIndex: rank: int * offset: int -> int type ``[,]``<'T> with /// Get the index for the element offset elements away from the end of the collection. + /// /// The rank of the index. This refers to the dimension in the 2d array. /// The offset from the end. + /// /// The corresponding index from the start. [] member GetReverseIndex: rank: int * offset: int -> int type ``[]``<'T> with /// Get the index for the element offset elements away from the end of the collection. + /// /// The rank of the index. /// The offset from the end. + /// /// The corresponding index from the start. [] member GetReverseIndex: rank: int * offset: int -> int type System.String with /// Get the index for the element offset elements away from the end of the collection. + /// /// The rank of the index. /// The offset from the end. + /// /// The corresponding index from the start. [] member GetReverseIndex: rank: int * offset: int -> int @@ -2903,13 +3323,16 @@ namespace Microsoft.FSharp.Core module OperatorIntrinsics = /// Gets a slice of an array + /// /// The input array. /// The start index. /// The end index. + /// /// The sub array from the input indices. val inline GetArraySlice : source:'T[] -> start:int option -> finish:int option -> 'T[] /// Sets a slice of an array + /// /// The target array. /// The start index. /// The end index. @@ -2917,31 +3340,38 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice : target:'T[] -> start:int option -> finish:int option -> source:'T[] -> unit /// Gets a region slice of an array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. /// The start index of the second dimension. /// The end index of the second dimension. + /// /// The two dimensional sub array from the input indices. val inline GetArraySlice2D : source:'T[,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> 'T[,] /// Gets a vector slice of a 2D array. The index of the first dimension is fixed. + /// /// The source array. /// The index of the first dimension. /// The start index of the second dimension. /// The end index of the second dimension. + /// /// The sub array from the input indices. val inline GetArraySlice2DFixed1 : source:'T[,] -> index1:int -> start2:int option -> finish2:int option -> 'T[] /// Gets a vector slice of a 2D array. The index of the second dimension is fixed. + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. /// The fixed index of the second dimension. + /// /// The sub array from the input indices. val inline GetArraySlice2DFixed2 : source:'T[,] -> start1:int option -> finish1:int option -> index2: int -> 'T[] /// Sets a region slice of an array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -2951,6 +3381,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice2D : target:'T[,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> source:'T[,] -> unit /// Sets a vector slice of a 2D array. The index of the first dimension is fixed. + /// /// The target array. /// The index of the first dimension. /// The start index of the second dimension. @@ -2959,6 +3390,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice2DFixed1 : target:'T[,] -> index1:int -> start2:int option -> finish2:int option -> source:'T[] -> unit /// Sets a vector slice of a 2D array. The index of the second dimension is fixed. + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -2967,6 +3399,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice2DFixed2 : target:'T[,] -> start1:int option -> finish1:int option -> index2:int -> source:'T[] -> unit /// Gets a slice of an array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -2974,73 +3407,87 @@ namespace Microsoft.FSharp.Core /// The end index of the second dimension. /// The start index of the third dimension. /// The end index of the third dimension. + /// /// The three dimensional sub array from the given indices. val inline GetArraySlice3D : source:'T[,,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> start3:int option -> finish3:int option -> 'T[,,] /// Gets a 2D slice of a 3D array. + /// /// The source array. /// The fixed index of the first dimension. /// The start index of the second dimension. /// The end index of the second dimension. /// The start index of the third dimension. /// The end index of the third dimension. + /// /// The two dimensional sub array from the given indices. [] val inline GetArraySlice3DFixedSingle1 : source:'T[,,] -> index1:int -> start2:int option -> finish2:int option -> start3:int option -> finish3:int option -> 'T[,] /// Gets a 2D slice of a 3D array. + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. /// The fixed index of the second dimension. /// The start index of the third dimension. /// The end index of the third dimension. + /// /// The two dimensional sub array from the given indices. [] val inline GetArraySlice3DFixedSingle2 : source:'T[,,] -> start1:int option -> finish1:int option -> index2: int -> start3:int option -> finish3:int option -> 'T[,] /// Gets a 2D slice of a 3D array. + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. /// The start index of the second dimension. /// The end index of the second dimension. /// The fixed index of the third dimension. + /// /// The two dimensional sub array from the given indices. [] val inline GetArraySlice3DFixedSingle3 : source:'T[,,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> index3: int -> 'T[,] /// Gets a 1D slice of a 3D array. + /// /// The source array. /// The fixed index of the first dimension. /// The fixed index of the second dimension. /// The start index of the third dimension. /// The end index of the third dimension. + /// /// The one dimensional sub array from the given indices. [] val inline GetArraySlice3DFixedDouble1 : source:'T[,,] -> index1:int -> index2:int -> start3:int option -> finish3:int option -> 'T[] /// Gets a 1D slice of a 3D array. + /// /// The source array. /// The fixed index of the first dimension. /// The start index of the second dimension. /// The end index of the second dimension. /// The fixed index of the third dimension. + /// /// The one dimensional sub array from the given indices. [] val inline GetArraySlice3DFixedDouble2 : source:'T[,,] -> index1:int -> start2:int option -> finish2:int option -> index3:int -> 'T[] /// Gets a 1D slice of a 3D array. + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. /// The fixed index of the second dimension. /// The fixed index of the third dimension. + /// /// The one dimensional sub array from the given indices. [] val inline GetArraySlice3DFixedDouble3 : source:'T[,,] -> start1:int option -> finish1:int option -> index2:int -> index3:int -> 'T[] /// Sets a slice of an array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3052,6 +3499,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice3D : target:'T[,,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> start3:int option -> finish3:int option -> source:'T[,,] -> unit /// Sets a 2D slice of a 3D array + /// /// The target array. /// The fixed index of the first dimension. /// The start index of the second dimension. @@ -3059,11 +3507,13 @@ namespace Microsoft.FSharp.Core /// The start index of the third dimension. /// The end index of the third dimension. /// The source array. + /// /// The two dimensional sub array from the given indices. [] val inline SetArraySlice3DFixedSingle1 : target: 'T[,,] -> index1: int -> start2: int option -> finish2: int option -> start3: int option -> finish3: int option -> source: 'T[,] -> unit /// Sets a 2D slice of a 3D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3071,11 +3521,13 @@ namespace Microsoft.FSharp.Core /// The start index of the third dimension. /// The end index of the third dimension. /// The source array. + /// /// The two dimensional sub array from the given indices. [] val inline SetArraySlice3DFixedSingle2 : target: 'T[,,] -> start1: int option -> finish1: int option -> index2: int -> start3: int option -> finish3: int option -> source: 'T[,] -> unit /// Sets a 2D slice of a 3D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3083,44 +3535,52 @@ namespace Microsoft.FSharp.Core /// The end index of the second dimension. /// The fixed index of the third dimension. /// The source array. + /// /// The two dimensional sub array from the given indices. [] val inline SetArraySlice3DFixedSingle3 : target: 'T[,,] -> start1: int option -> finish1: int option -> start2: int option -> finish2: int option -> index3: int -> source: 'T[,] -> unit /// Sets a 1D slice of a 3D array. + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. /// The fixed index of the second dimension. /// The fixed index of the third dimension. /// The source array. + /// /// The one dimensional sub array from the given indices. [] val inline SetArraySlice3DFixedDouble1 : target: 'T[,,] -> index1: int -> index2: int -> start3: int option -> finish3: int option -> source: 'T[] -> unit /// Sets a 1D slice of a 3D array. + /// /// The source array. /// The fixed index of the first dimension. /// The start index of the second dimension. /// The end index of the second dimension. /// The fixed index of the third dimension. /// The source array. + /// /// The one dimensional sub array from the given indices. [] val inline SetArraySlice3DFixedDouble2 : target: 'T[,,] -> index1: int -> start2: int option -> finish2: int option -> index3: int -> source: 'T[] -> unit /// Sets a 1D slice of a 3D array. + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. /// The fixed index of the second dimension. /// The fixed index of the third dimension. /// The source array. + /// /// The one dimensional sub array from the given indices. [] val inline SetArraySlice3DFixedDouble3 : target: 'T[,,] -> start1: int option -> finish1: int option -> index2: int -> index3: int -> source: 'T[] -> unit /// Gets a slice of an array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3130,10 +3590,12 @@ namespace Microsoft.FSharp.Core /// The end index of the third dimension. /// The start index of the fourth dimension. /// The end index of the fourth dimension. + /// /// The four dimensional sub array from the given indices. val inline GetArraySlice4D : source:'T[,,,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> start3:int option -> finish3:int option -> start4:int option -> finish4:int option -> 'T[,,,] /// Gets a 3D slice of a 4D array + /// /// The source array. /// The fixed index of the first dimension. /// The start index of the second dimension. @@ -3142,10 +3604,12 @@ namespace Microsoft.FSharp.Core /// The end index of the third dimension. /// The start index of the fourth dimension. /// The end index of the fourth dimension. + /// /// The three dimensional sub array from the given indices. val inline GetArraySlice4DFixedSingle1 : source:'T[,,,] -> index1:int -> start2: int option -> finish2:int option -> start3:int option -> finish3:int option -> start4:int option -> finish4:int option -> 'T[,,] /// Gets a 3D slice of a 4D array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3154,10 +3618,12 @@ namespace Microsoft.FSharp.Core /// The end index of the third dimension. /// The start index of the fourth dimension. /// The end index of the fourth dimension. + /// /// The three dimensional sub array from the given indices. val inline GetArraySlice4DFixedSingle2 : source:'T[,,,] -> start1:int option -> finish1:int option -> index2:int -> start3:int option -> finish3:int option -> start4:int option -> finish4:int option -> 'T[,,] /// Gets a 3D slice of a 4D array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3166,10 +3632,12 @@ namespace Microsoft.FSharp.Core /// The fixed index of the third dimension. /// The start index of the fourth dimension. /// The end index of the fourth dimension. + /// /// The three dimensional sub array from the given indices. val inline GetArraySlice4DFixedSingle3 : source:'T[,,,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> index3:int -> start4:int option -> finish4:int option -> 'T[,,] /// Gets a 3D slice of a 4D array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3178,10 +3646,12 @@ namespace Microsoft.FSharp.Core /// The start index of the third dimension. /// The end index of the third dimension. /// The fixed index of the fourth dimension. + /// /// The three dimensional sub array from the given indices. val inline GetArraySlice4DFixedSingle4 : source:'T[,,,] -> start1:int option -> finish1:int option -> start2: int option -> finish2:int option -> start3:int option -> finish3:int option -> index4:int -> 'T[,,] /// Gets a 2D slice of a 4D array + /// /// The source array. /// The fixed index of the first dimension. /// The fixed index of the second dimension. @@ -3189,10 +3659,12 @@ namespace Microsoft.FSharp.Core /// The end index of the third dimension. /// The start index of the fourth dimension. /// The end index of the fourth dimension. + /// /// The two dimensional sub array from the given indices. val inline GetArraySlice4DFixedDouble1 : source:'T[,,,] -> index1: int -> index2:int -> start3:int option -> finish3:int option -> start4:int option -> finish4:int option -> 'T[,] /// Gets a 2D slice of a 4D array + /// /// The source array. /// The fixed index of the first dimension. /// The start index of the second dimension. @@ -3200,10 +3672,12 @@ namespace Microsoft.FSharp.Core /// The fixed index of the third dimension. /// The start index of the fourth dimension. /// The end index of the fourth dimension. + /// /// The two dimensional sub array from the given indices. val inline GetArraySlice4DFixedDouble2 : source:'T[,,,] -> index1: int -> start2: int option -> finish2:int option -> index3:int -> start4:int option -> finish4:int option -> 'T[,] /// Gets a 2D slice of a 4D array + /// /// The source array. /// The fixed index of the first dimension. /// The start index of the second dimension. @@ -3211,10 +3685,12 @@ namespace Microsoft.FSharp.Core /// The start index of the third dimension. /// The end index of the third dimension. /// The fixed index of the fourth dimension. + /// /// The two dimensional sub array from the given indices. val inline GetArraySlice4DFixedDouble3 : source:'T[,,,] -> index1:int -> start2: int option -> finish2:int option -> start3:int option -> finish3:int option -> index4:int -> 'T[,] /// Gets a 2D slice of a 4D array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3222,10 +3698,12 @@ namespace Microsoft.FSharp.Core /// The fixed index of the third dimension. /// The start index of the fourth dimension. /// The end index of the fourth dimension. + /// /// The two dimensional sub array from the given indices. val inline GetArraySlice4DFixedDouble4 : source:'T[,,,] -> start1:int option -> finish1:int option -> index2:int -> index3:int -> start4:int option -> finish4:int option -> 'T[,] /// Gets a 2D slice of a 4D array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3233,10 +3711,12 @@ namespace Microsoft.FSharp.Core /// The start index of the third dimension. /// The end index of the third dimension. /// The fixed index of the fourth dimension. + /// /// The two dimensional sub array from the given indices. val inline GetArraySlice4DFixedDouble5 : source:'T[,,,] -> start1:int option -> finish1:int option -> index2:int -> start3:int option -> finish3:int option -> index4:int -> 'T[,] /// Gets a 2D slice of a 4D array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3244,50 +3724,60 @@ namespace Microsoft.FSharp.Core /// The end index of the second dimension. /// The fixed index of the third dimension. /// The fixed index of the fourth dimension. + /// /// The two dimensional sub array from the given indices. val inline GetArraySlice4DFixedDouble6 : source:'T[,,,] -> start1:int option -> finish1:int option -> start2: int option -> finish2:int option -> index3:int -> index4:int -> 'T[,] /// Gets a 1D slice of a 4D array + /// /// The source array. /// The fixed index of the first dimension. /// The fixed index of the second dimension. /// The fixed index of the third dimension. /// The start index of the fourth dimension. /// The end index of the fourth dimension. + /// /// The one dimensional sub array from the given indices. val inline GetArraySlice4DFixedTriple4 : source:'T[,,,] -> index1:int -> index2:int -> index3:int -> start4:int option -> finish4:int option -> 'T[] /// Gets a 1D slice of a 4D array + /// /// The source array. /// The fixed index of the first dimension. /// The fixed index of the second dimension. /// The start index of the third dimension. /// The end index of the third dimension. /// The fixed index of the fourth dimension. + /// /// The one dimensional sub array from the given indices. val inline GetArraySlice4DFixedTriple3 : source:'T[,,,] -> index1:int -> index2:int -> start3:int option -> finish3:int option -> index4:int -> 'T[] /// Gets a 1D slice of a 4D array + /// /// The source array. /// The fixed index of the first dimension. /// The start index of the second dimension. /// The end index of the second dimension. /// The fixed index of the third dimension. /// The fixed index of the fourth dimension. + /// /// The one dimensional sub array from the given indices. val inline GetArraySlice4DFixedTriple2 : source:'T[,,,] -> index1:int -> start2: int option -> finish2:int option -> index3:int -> index4:int -> 'T[] /// Gets a 1D slice of a 4D array + /// /// The source array. /// The start index of the first dimension. /// The end index of the first dimension. /// The fixed index of the second dimension. /// The fixed index of the third dimension. /// The fixed index of the fourth dimension. + /// /// The one dimensional sub array from the given indices. val inline GetArraySlice4DFixedTriple1 : source:'T[,,,] -> start1:int option -> finish1:int option -> index2:int -> index3:int -> index4:int -> 'T[] /// Gets a 3D slice of a 4D array + /// /// The source array. /// The fixed index of the first dimension. /// The start index of the second dimension. @@ -3300,6 +3790,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedSingle1 : target:'T[,,,] -> index1:int -> start2: int option -> finish2:int option -> start3:int option -> finish3:int option -> start4:int option -> finish4:int option -> source: 'T[,,] -> unit /// Sets a 3D slice of a 4D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3312,6 +3803,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedSingle2 : target:'T[,,,] -> start1:int option -> finish1:int option -> index2:int -> start3:int option -> finish3:int option -> start4:int option -> finish4:int option -> source: 'T[,,] -> unit /// Sets a 3D slice of a 4D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3324,6 +3816,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedSingle3 : target:'T[,,,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> index3:int -> start4:int option -> finish4:int option -> source: 'T[,,] -> unit /// Sets a 3D slice of a 4D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3336,6 +3829,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedSingle4 : target:'T[,,,] -> start1:int option -> finish1:int option -> start2: int option -> finish2:int option -> start3:int option -> finish3:int option -> index4:int -> source: 'T[,,] -> unit /// Sets a 2D slice of a 4D array + /// /// The target array. /// The fixed index of the first dimension. /// The fixed index of the second dimension. @@ -3347,6 +3841,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedDouble1 : target:'T[,,,] -> index1: int -> index2:int -> start3:int option -> finish3:int option -> start4:int option -> finish4:int option -> source: 'T[,] -> unit /// Sets a 2D slice of a 4D array + /// /// The target array. /// The fixed index of the first dimension. /// The start index of the second dimension. @@ -3358,6 +3853,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedDouble2 : target:'T[,,,] -> index1: int -> start2: int option -> finish2:int option -> index3:int -> start4:int option -> finish4:int option -> source: 'T[,] -> unit /// Sets a 2D slice of a 4D array + /// /// The target array. /// The fixed index of the first dimension. /// The start index of the second dimension. @@ -3369,6 +3865,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedDouble3 : target:'T[,,,] -> index1:int -> start2: int option -> finish2:int option -> start3:int option -> finish3:int option -> index4:int -> source: 'T[,] -> unit /// Sets a 2D slice of a 4D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3380,6 +3877,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedDouble4 : target:'T[,,,] -> start1:int option -> finish1:int option -> index2:int -> index3:int -> start4:int option -> finish4:int option -> source: 'T[,] -> unit /// Sets a 2D slice of a 4D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3391,6 +3889,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedDouble5 : target:'T[,,,] -> start1:int option -> finish1:int option -> index2:int -> start3:int option -> finish3:int option -> index4:int -> source: 'T[,] -> unit /// Sets a 2D slice of a 4D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3402,6 +3901,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedDouble6 : target:'T[,,,] -> start1:int option -> finish1:int option -> start2: int option -> finish2:int option -> index3:int -> index4:int -> source: 'T[,] -> unit /// Sets a 1D slice of a 4D array + /// /// The target array. /// The fixed index of the first dimension. /// The fixed index of the second dimension. @@ -3412,6 +3912,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedTriple4 : target:'T[,,,] -> index1:int -> index2:int -> index3:int -> start4:int option -> finish4:int option -> source: 'T[] -> unit /// Sets a 1D slice of a 4D array + /// /// The target array. /// The fixed index of the first dimension. /// The fixed index of the second dimension. @@ -3422,6 +3923,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedTriple3 : target:'T[,,,] -> index1:int -> index2:int -> start3:int option -> finish3:int option -> index4:int -> source: 'T[] -> unit /// Sets a 1D slice of a 4D array + /// /// The target array. /// The fixed index of the first dimension. /// The start index of the second dimension. @@ -3432,6 +3934,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedTriple2 : target:'T[,,,] -> index1:int -> start2: int option -> finish2:int option -> index3:int -> index4:int -> source: 'T[] -> unit /// Sets a 1D slice of a 4D array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3442,6 +3945,7 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4DFixedTriple1 : target:'T[,,,] -> start1:int option -> finish1:int option -> index2:int -> index3:int -> index4:int -> source: 'T[] -> unit /// Sets a slice of an array + /// /// The target array. /// The start index of the first dimension. /// The end index of the first dimension. @@ -3455,9 +3959,11 @@ namespace Microsoft.FSharp.Core val inline SetArraySlice4D : target:'T[,,,] -> start1:int option -> finish1:int option -> start2:int option -> finish2:int option -> start3:int option -> finish3:int option -> start4:int option -> finish4:int option -> source:'T[,,,] -> unit /// Gets a slice from a string + /// /// The source string. /// The index of the first character of the slice. /// The index of the last character of the slice. + /// /// The substring from the given indices. val inline GetStringSlice : source:string -> start:int option -> finish:int option -> string @@ -3665,7 +4171,9 @@ namespace Microsoft.FSharp.Core module Unchecked = /// Unboxes a strongly typed value. This is the inverse of box, unbox<t>(box<t> a) equals a. + /// /// The boxed value. + /// /// The unboxed result. [] val inline unbox<'T> : obj -> 'T @@ -3700,64 +4208,84 @@ namespace Microsoft.FSharp.Core module NonStructuralComparison = /// Compares the two values for less-than + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( < ) : x:^T -> y:^U -> bool when (^T or ^U) : (static member ( < ) : ^T * ^U -> bool) /// Compares the two values for greater-than + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( > ) : x:^T -> y:^U -> bool when (^T or ^U) : (static member ( > ) : ^T * ^U -> bool) /// Compares the two values for greater-than-or-equal + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( >= ) : x:^T -> y:^U -> bool when (^T or ^U) : (static member ( >= ) : ^T * ^U -> bool) /// Compares the two values for less-than-or-equal + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( <= ) : x:^T -> y:^U -> bool when (^T or ^U) : (static member ( <= ) : ^T * ^U -> bool) /// Compares the two values for equality + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( = ) : x:^T -> y:^T -> bool when ^T : (static member ( = ) : ^T * ^T -> bool) /// Compares the two values for inequality + /// /// The first parameter. /// The second parameter. + /// /// The result of the comparison. val inline ( <> ) : x:^T -> y:^T -> bool when ^T : (static member ( <> ) : ^T * ^T -> bool) /// Compares the two values + /// /// The first value. /// The second value. + /// /// The result of the comparison. [] val inline compare: e1:'T -> e2:^T -> int when ^T : (static member ( < ) : ^T * ^T -> bool) and ^T : (static member ( > ) : ^T * ^T -> bool) /// Maximum of the two values + /// /// The first value. /// The second value. + /// /// The maximum value. [] val inline max : e1:^T -> e2:^T -> ^T when ^T : (static member ( < ) : ^T * ^T -> bool) /// Minimum of the two values + /// /// The first value. /// The second value. + /// /// The minimum value. [] val inline min : e1:^T -> e2:^T -> ^T when ^T : (static member ( < ) : ^T * ^T -> bool) /// Calls GetHashCode() on the value + /// /// The value. + /// /// The hash code. [] val inline hash :value:'T -> int when 'T : equality @@ -3765,113 +4293,141 @@ namespace Microsoft.FSharp.Core /// This module contains the basic arithmetic operations with overflow checks. module Checked = /// Overloaded unary negation (checks for overflow) + /// /// The input value. + /// /// The negated value. val inline ( ~- ) : value:^T -> ^T when ^T : (static member ( ~- ) : ^T -> ^T) and default ^T : int /// Overloaded subtraction operator (checks for overflow) + /// /// The first value. /// The second value. + /// /// The first value minus the second value. val inline ( - ) : x:^T1 -> y:^T2 -> ^T3 when (^T1 or ^T2) : (static member ( - ) : ^T1 * ^T2 -> ^T3) and default ^T2 : ^T3 and default ^T3 : ^T1 and default ^T3 : ^T2 and default ^T1 : ^T3 and default ^T1 : ^T2 and default ^T1 : int /// Overloaded addition operator (checks for overflow) + /// /// The first value. /// The second value. + /// /// The sum of the two input values. val inline ( + ) : x:^T1 -> y:^T2 -> ^T3 when (^T1 or ^T2) : (static member ( + ) : ^T1 * ^T2 -> ^T3) and default ^T2 : ^T3 and default ^T3 : ^T1 and default ^T3 : ^T2 and default ^T1 : ^T3 and default ^T1 : ^T2 and default ^T1 : int /// Overloaded multiplication operator (checks for overflow) + /// /// The first value. /// The second value. + /// /// The product of the two input values. val inline ( * ) : x:^T1 -> y:^T2 -> ^T3 when (^T1 or ^T2) : (static member ( * ) : ^T1 * ^T2 -> ^T3) and default ^T2 : ^T3 and default ^T3 : ^T1 and default ^T3 : ^T2 and default ^T1 : ^T3 and default ^T1 : ^T2 and default ^T1 : int /// Converts the argument to byte. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.Byte.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted byte [] val inline byte : value:^T -> byte when ^T : (static member op_Explicit : ^T -> byte) and default ^T : int /// Converts the argument to sbyte. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.SByte.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted sbyte [] val inline sbyte : value:^T -> sbyte when ^T : (static member op_Explicit : ^T -> sbyte) and default ^T : int /// Converts the argument to int16. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.Int16.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int16 [] val inline int16 : value:^T -> int16 when ^T : (static member op_Explicit : ^T -> int16) and default ^T : int /// Converts the argument to uint16. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.UInt16.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint16 [] val inline uint16 : value:^T -> uint16 when ^T : (static member op_Explicit : ^T -> uint16) and default ^T : int /// Converts the argument to int. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.Int32.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int [] val inline int : value:^T -> int when ^T : (static member op_Explicit : ^T -> int) and default ^T : int /// Converts the argument to int32. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.Int32.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int32 [] val inline int32 : value:^T -> int32 when ^T : (static member op_Explicit : ^T -> int32) and default ^T : int /// Converts the argument to uint32. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.UInt32.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint32 [] val inline uint32 : value:^T -> uint32 when ^T : (static member op_Explicit : ^T -> uint32) and default ^T : int /// Converts the argument to int64. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.Int64.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted int64 [] val inline int64 : value:^T -> int64 when ^T : (static member op_Explicit : ^T -> int64) and default ^T : int /// Converts the argument to uint64. This is a direct, checked conversion for all - /// primitive numeric types. For strings, the input is converted using System.UInt64.Parse() + /// primitive numeric types. For strings, the input is converted using /// with InvariantCulture settings. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted uint64 [] val inline uint64 : value:^T -> uint64 when ^T : (static member op_Explicit : ^T -> uint64) and default ^T : int - /// Converts the argument to nativeint. This is a direct, checked conversion for all + /// Converts the argument to . This is a direct, checked conversion for all /// primitive numeric types. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted nativeint [] val inline nativeint : value:^T -> nativeint when ^T : (static member op_Explicit : ^T -> nativeint) and default ^T : int @@ -3879,7 +4435,9 @@ namespace Microsoft.FSharp.Core /// Converts the argument to unativeint. This is a direct, checked conversion for all /// primitive numeric types. Otherwise the operation requires an appropriate /// static conversion method on the input type. + /// /// The input value. + /// /// The converted unativeint [] val inline unativeint : value:^T -> unativeint when ^T : (static member op_Explicit : ^T -> unativeint) and default ^T : int @@ -3888,7 +4446,9 @@ namespace Microsoft.FSharp.Core /// conversion according to the UTF-16 encoding for characters. String inputs must /// be exactly one character long. For other input types the operation requires an /// appropriate static conversion method on the input type. + /// /// The input value. + /// /// The converted char [] val inline char : value:^T -> char when ^T : (static member op_Explicit : ^T -> char) and default ^T : int @@ -3905,13 +4465,17 @@ namespace Microsoft.FSharp.Control type System.Lazy<'T> with /// Creates a lazy computation that evaluates to the result of the given function when forced. + /// /// The function to provide the value when needed. + /// /// The created Lazy object. [] // give the extension member a 'nice', unmangled compiled name, unique within this module static member Create : creator:(unit -> 'T) -> System.Lazy<'T> /// Creates a lazy computation that evaluates to the given value when forced. + /// /// The input value. + /// /// The created Lazy object. [] // give the extension member a 'nice', unmangled compiled name, unique within this module static member CreateFromValue : value:'T -> System.Lazy<'T> @@ -3926,7 +4490,7 @@ namespace Microsoft.FSharp.Control /// /// Use the values in the Lazy module to manipulate /// values of this type, and the notation lazy expr to create values - /// of type . + /// of type . type Lazy<'T> = System.Lazy<'T> and [] @@ -3947,10 +4511,12 @@ namespace Microsoft.FSharp.Control /// Connect a handler delegate object to the event. A handler can /// be later removed using RemoveHandler. The listener will /// be invoked when the event is fired. + /// /// A delegate to be invoked when the event is fired. abstract AddHandler: handler:'Delegate -> unit /// Remove a listener delegate from an event listener store. + /// /// The delegate to be removed from the event listener store. abstract RemoveHandler: handler:'Delegate -> unit @@ -3961,6 +4527,7 @@ namespace Microsoft.FSharp.Control inherit IObservable<'Args> /// A delegate type associated with the F# event type IEvent<_> + /// /// The object that fired the event. /// The event arguments. [] diff --git a/src/fsharp/FSharp.Core/printf.fsi b/src/fsharp/FSharp.Core/printf.fsi index 10e17ec68d88..37e98e99d274 100644 --- a/src/fsharp/FSharp.Core/printf.fsi +++ b/src/fsharp/FSharp.Core/printf.fsi @@ -18,6 +18,7 @@ type PrintfFormat<'Printer,'State,'Residue,'Result> = /// Construct a format string /// The input string. + /// /// The PrintfFormat containing the formatted result. new : value:string -> PrintfFormat<'Printer,'State,'Residue,'Result> @@ -35,7 +36,9 @@ type PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple> = inherit PrintfFormat<'Printer,'State,'Residue,'Result> /// Construct a format string + /// /// The input string. + /// /// The created format string. new: value:string -> PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple> @@ -57,88 +60,11 @@ type Format<'Printer,'State,'Residue,'Result,'Tuple> = PrintfFormat<'Printer,'St /// Extensible printf-style formatting for numbers and other datatypes /// /// Format specifications are strings with "%" markers indicating format -/// placeholders. Format placeholders consist of: -/// -/// %[flags][width][.precision][type] -/// -/// where the type is interpreted as follows: -/// -/// %b: bool, formatted as "true" or "false" -/// %s: string, formatted as its unescaped contents -/// %c: character literal -/// %d, %i: any basic integer type formatted as a decimal integer, signed if the basic integer type is signed. -/// %u: any basic integer type formatted as an unsigned decimal integer -/// %x, %X, %o: any basic integer type formatted as an unsigned hexadecimal -/// (a-f)/Hexadecimal (A-F)/Octal integer -/// -/// %e, %E, %f, %F, %g, %G: -/// any basic floating point type (float,float32) formatted -/// using a C-style floating point format specifications, i.e -/// -/// %e, %E: Signed value having the form [-]d.dddde[sign]ddd where -/// d is a single decimal digit, dddd is one or more decimal -/// digits, ddd is exactly three decimal digits, and sign -/// is + or - -/// -/// %f: Signed value having the form [-]dddd.dddd, where dddd is one -/// or more decimal digits. The number of digits before the -/// decimal point depends on the magnitude of the number, and -/// the number of digits after the decimal point depends on -/// the requested precision. -/// -/// %g, %G: Signed value printed in f or e format, whichever is -/// more compact for the given value and precision. -/// -/// -/// %M: System.Decimal value -/// -/// %O: Any value, printed by boxing the object and using it's ToString method(s) -/// -/// %A: Any value, printed with the default layout settings -/// -/// %a: A general format specifier, requires two arguments: -/// (1) a function which accepts two arguments: -/// (a) a context parameter of the appropriate type for the -/// given formatting function (e.g. an #System.IO.TextWriter) -/// (b) a value to print -/// and which either outputs or returns appropriate text. -/// -/// (2) the particular value to print -/// -/// -/// %t: A general format specifier, requires one argument: -/// (1) a function which accepts a context parameter of the -/// appropriate type for the given formatting function (e.g. -/// an System.IO.TextWriter)and which either outputs or returns -/// appropriate text. -/// -/// Basic integer types are: -/// byte,sbyte,int16,uint16,int32,uint32,int64,uint64,nativeint,unativeint -/// Basic floating point types are: -/// float, float32 -/// -/// The optional width is an integer indicating the minimal width of the -/// result. For instance, %6d prints an integer, prefixing it with spaces -/// to fill at least 6 characters. If width is '*', then an extra integer -/// argument is taken to specify the corresponding width. -/// -/// any number -/// '*': -/// -/// Valid flags are: -/// -/// 0: add zeros instead of spaces to make up the required width -/// '-': left justify the result within the width specified -/// '+': add a '+' character if the number is positive (to match a '-' sign -/// for negatives) -/// ' ': add an extra space if the number is positive (to match a '-' -/// sign for negatives) -/// -/// The printf '#' flag is invalid and a compile-time error will be reported if it is used. +/// placeholders. Format placeholders consist of %[flags][width][.precision][type]. [] module Printf = - /// Represents a statically-analyzed format associated with writing to a System.Text.StringBuilder. The first type parameter indicates the + /// Represents a statically-analyzed format associated with writing to a . The first type parameter indicates the /// arguments of the format operation and the last the overall return type. type BuilderFormat<'T,'Result> = Format<'T, StringBuilder, unit, 'Result> @@ -146,11 +72,11 @@ module Printf = /// arguments of the format operation and the last the overall return type. type StringFormat<'T,'Result> = Format<'T, unit, string, 'Result> - /// Represents a statically-analyzed format associated with writing to a System.IO.TextWriter. The first type parameter indicates the + /// Represents a statically-analyzed format associated with writing to a . The first type parameter indicates the /// arguments of the format operation and the last the overall return type. type TextWriterFormat<'T,'Result> = Format<'T, TextWriter, unit, 'Result> - /// Represents a statically-analyzed format associated with writing to a System.Text.StringBuilder. The type parameter indicates the + /// Represents a statically-analyzed format associated with writing to a . The type parameter indicates the /// arguments and return type of the format operation. type BuilderFormat<'T> = BuilderFormat<'T,unit> @@ -158,76 +84,96 @@ module Printf = /// arguments and return type of the format operation. type StringFormat<'T> = StringFormat<'T,string> - /// Represents a statically-analyzed format associated with writing to a System.IO.TextWriter. The type parameter indicates the + /// Represents a statically-analyzed format associated with writing to a . The type parameter indicates the /// arguments and return type of the format operation. type TextWriterFormat<'T> = TextWriterFormat<'T,unit> - /// Print to a System.Text.StringBuilder + /// Print to a + /// /// The StringBuilder to print to. /// The input formatter. + /// /// The return type and arguments of the formatter. [] val bprintf : builder:StringBuilder -> format:BuilderFormat<'T> -> 'T /// Print to a text writer. + /// /// The TextWriter to print to. /// The input formatter. + /// /// The return type and arguments of the formatter. [] val fprintf : textWriter:TextWriter -> format:TextWriterFormat<'T> -> 'T /// Print to a text writer, adding a newline + /// /// The TextWriter to print to. /// The input formatter. + /// /// The return type and arguments of the formatter. [] val fprintfn : textWriter:TextWriter -> format:TextWriterFormat<'T> -> 'T /// Formatted printing to stderr + /// /// The input formatter. + /// /// The return type and arguments of the formatter. [] val eprintf : format:TextWriterFormat<'T> -> 'T /// Formatted printing to stderr, adding a newline + /// /// The input formatter. + /// /// The return type and arguments of the formatter. [] val eprintfn : format:TextWriterFormat<'T> -> 'T /// Formatted printing to stdout + /// /// The input formatter. + /// /// The return type and arguments of the formatter. [] val printf : format:TextWriterFormat<'T> -> 'T /// Formatted printing to stdout, adding a newline. + /// /// The input formatter. + /// /// The return type and arguments of the formatter. [] val printfn : format:TextWriterFormat<'T> -> 'T /// Print to a string via an internal string buffer and return /// the result as a string. Helper printers must return strings. + /// /// The input formatter. + /// /// The formatted string. [] val sprintf : format:StringFormat<'T> -> 'T /// bprintf, but call the given 'final' function to generate the result. /// See kprintf. + /// /// The function called after formatting to generate the format result. /// The input StringBuilder. /// The input formatter. + /// /// The arguments of the formatter. [] val kbprintf : continuation:(unit -> 'Result) -> builder:StringBuilder -> format:BuilderFormat<'T,'Result> -> 'T /// fprintf, but call the given 'final' function to generate the result. /// See kprintf. + /// /// The function called after formatting to generate the format result. /// The input TextWriter. /// The input formatter. + /// /// The arguments of the formatter. [] val kfprintf : continuation:(unit -> 'Result) -> textWriter:TextWriter -> format:TextWriterFormat<'T,'Result> -> 'T @@ -235,23 +181,29 @@ module Printf = /// printf, but call the given 'final' function to generate the result. /// For example, these let the printing force a flush after all output has /// been entered onto the channel, but not before. + /// /// The function called after formatting to generate the format result. /// The input formatter. + /// /// The arguments of the formatter. [] val kprintf : continuation:(string -> 'Result) -> format:StringFormat<'T,'Result> -> 'T /// sprintf, but call the given 'final' function to generate the result. /// See kprintf. + /// /// The function called to generate a result from the formatted string. /// The input formatter. + /// /// The arguments of the formatter. [] val ksprintf : continuation:(string -> 'Result) -> format:StringFormat<'T,'Result> -> 'T /// Print to a string buffer and raise an exception with the given /// result. Helper printers must return strings. + /// /// The input formatter. + /// /// The arguments of the formatter. [] val failwithf: format:StringFormat<'T,'Result> -> 'T diff --git a/src/fsharp/FSharp.Core/quotations.fsi b/src/fsharp/FSharp.Core/quotations.fsi index e51ed2bd747b..bdeab19a85b4 100644 --- a/src/fsharp/FSharp.Core/quotations.fsi +++ b/src/fsharp/FSharp.Core/quotations.fsi @@ -26,13 +26,16 @@ type Var = /// The declared name of the variable. /// The type associated with the variable. /// Indicates if the variable represents a mutable storage location. Default is false. + /// /// The created variable. new : name:string * typ:Type * ?isMutable : bool -> Var /// Fetches or create a new variable with the given name and type from a global pool of shared variables /// indexed by name and type + /// /// The name of the variable. /// The type associated with the variable. + /// /// The retrieved or created variable. static member Global : name:string * typ:Type -> Var @@ -47,7 +50,9 @@ type Expr = /// to map variables to new values. The functions must give consistent results /// at each application. Variable renaming may occur on the target expression /// if variable capture occurs. + /// /// The function to map variables into expressions. + /// /// The expression with the given substitutions. member Substitute : substitution:(Var -> Expr option) -> Expr @@ -64,309 +69,405 @@ type Expr = override Equals : obj:obj -> bool /// Builds an expression that represents getting the address of a value. + /// /// The target expression. + /// /// The resulting expression. static member AddressOf : target:Expr -> Expr /// Builds an expression that represents setting the value held at a particular address. + /// /// The target expression. /// The value to set at the address. + /// /// The resulting expression. static member AddressSet : target:Expr * value:Expr -> Expr /// Builds an expression that represents the application of a first class function value to a single argument. + /// /// The function to apply. /// The argument to the function. + /// /// The resulting expression. static member Application: functionExpr:Expr * argument:Expr -> Expr /// Builds an expression that represents the application of a first class function value to multiple arguments + /// /// The function to apply. /// The list of lists of arguments to the function. + /// /// The resulting expression. static member Applications: functionExpr:Expr * arguments:list> -> Expr /// Builds an expression that represents a call to an static method or module-bound function + /// /// The MethodInfo describing the method to call. /// The list of arguments to the method. + /// /// The resulting expression. static member Call : methodInfo:MethodInfo * arguments:list -> Expr /// Builds an expression that represents a call to an instance method associated with an object + /// /// The input object. /// The description of the method to call. /// The list of arguments to the method. + /// /// The resulting expression. static member Call : obj:Expr * methodInfo:MethodInfo * arguments:list -> Expr /// Builds an expression that represents a call to an static method or module-bound function + /// /// The MethodInfo describing the method to call. /// The additional MethodInfo describing the method to call, accepting witnesses. /// The list of witnesses to the method. /// The list of arguments to the method. + /// /// The resulting expression. [] static member CallWithWitnesses: methodInfo: MethodInfo * methodInfoWithWitnesses: MethodInfo * witnesses: Expr list * arguments: Expr list -> Expr /// Builds an expression that represents a call to an instance method associated with an object + /// /// The input object. /// The description of the method to call. /// The additional MethodInfo describing the method to call, accepting witnesses. /// The list of witnesses to the method. /// The list of arguments to the method. + /// /// The resulting expression. [] static member CallWithWitnesses: obj:Expr * methodInfo:MethodInfo * methodInfoWithWitnesses: MethodInfo * witnesses: Expr list * arguments:Expr list -> Expr /// Builds an expression that represents the coercion of an expression to a type + /// /// The expression to coerce. /// The target type. + /// /// The resulting expression. static member Coerce : source:Expr * target:Type -> Expr /// Builds 'if ... then ... else' expressions. + /// /// The condition expression. /// The then sub-expression. /// The else sub-expression. + /// /// The resulting expression. static member IfThenElse : guard:Expr * thenExpr:Expr * elseExpr:Expr -> Expr /// Builds a 'for i = ... to ... do ...' expression that represent loops over integer ranges + /// /// The sub-expression declaring the loop variable. /// The sub-expression setting the initial value of the loop variable. /// The sub-expression declaring the final value of the loop variable. /// The sub-expression representing the body of the loop. + /// /// The resulting expression. static member ForIntegerRangeLoop: loopVariable:Var * start:Expr * endExpr:Expr * body:Expr -> Expr /// Builds an expression that represents the access of a static field + /// /// The description of the field to access. + /// /// The resulting expression. static member FieldGet: fieldInfo:FieldInfo -> Expr /// Builds an expression that represents the access of a field of an object + /// /// The input object. /// The description of the field to access. + /// /// The resulting expression. static member FieldGet: obj:Expr * fieldInfo:FieldInfo -> Expr /// Builds an expression that represents writing to a static field + /// /// The description of the field to write to. /// The value to the set to the field. + /// /// The resulting expression. static member FieldSet: fieldInfo:FieldInfo * value:Expr -> Expr /// Builds an expression that represents writing to a field of an object + /// /// The input object. /// The description of the field to write to. /// The value to set to the field. + /// /// The resulting expression. static member FieldSet: obj:Expr * fieldInfo:FieldInfo * value:Expr -> Expr /// Builds an expression that represents the construction of an F# function value + /// /// The parameter to the function. /// The body of the function. + /// /// The resulting expression. static member Lambda : parameter:Var * body:Expr -> Expr /// Builds expressions associated with 'let' constructs + /// /// The variable in the let expression. /// The expression bound to the variable. /// The sub-expression where the binding is in scope. + /// /// The resulting expression. static member Let : letVariable:Var * letExpr:Expr * body:Expr -> Expr /// Builds recursive expressions associated with 'let rec' constructs + /// /// The list of bindings for the let expression. /// The sub-expression where the bindings are in scope. + /// /// The resulting expression. static member LetRecursive : bindings:(Var * Expr) list * body:Expr -> Expr /// Builds an expression that represents the invocation of an object constructor + /// /// The description of the constructor. /// The list of arguments to the constructor. + /// /// The resulting expression. static member NewObject: constructorInfo:ConstructorInfo * arguments:Expr list -> Expr /// Builds an expression that represents the invocation of a default object constructor + /// /// The type on which the constructor is invoked. + /// /// The resulting expression. static member DefaultValue: expressionType:Type -> Expr /// Builds an expression that represents the creation of an F# tuple value + /// /// The list of elements of the tuple. + /// /// The resulting expression. static member NewTuple: elements:Expr list -> Expr /// Builds an expression that represents the creation of an F# tuple value + /// /// Runtime assembly containing System.ValueTuple definitions. /// The list of elements of the tuple. + /// /// The resulting expression. static member NewStructTuple: asm:Assembly * elements:Expr list -> Expr /// Builds record-construction expressions + /// /// The type of record. /// The list of elements of the record. + /// /// The resulting expression. static member NewRecord: recordType:Type * elements:Expr list -> Expr /// Builds an expression that represents the creation of an array value initialized with the given elements + /// /// The type for the elements of the array. /// The list of elements of the array. + /// /// The resulting expression. static member NewArray: elementType:Type * elements:Expr list -> Expr /// Builds an expression that represents the creation of a delegate value for the given type + /// /// The type of delegate. /// The parameters for the delegate. /// The body of the function. + /// /// The resulting expression. static member NewDelegate: delegateType:Type * parameters:Var list * body:Expr -> Expr /// Builds an expression that represents the creation of a union case value + /// /// The description of the union case. /// The list of arguments for the case. + /// /// The resulting expression. static member NewUnionCase: unionCase:UnionCaseInfo * arguments:Expr list -> Expr /// Builds an expression that represents reading a property of an object + /// /// The input object. /// The description of the property. /// List of indices for the property if it is an indexed property. + /// /// The resulting expression. static member PropertyGet: obj:Expr * property:PropertyInfo * ?indexerArgs: Expr list -> Expr /// Builds an expression that represents reading a static property + /// /// The description of the property. /// List of indices for the property if it is an indexed property. + /// /// The resulting expression. static member PropertyGet: property:PropertyInfo * ?indexerArgs: Expr list -> Expr /// Builds an expression that represents writing to a property of an object + /// /// The input object. /// The description of the property. /// The value to set. /// List of indices for the property if it is an indexed property. + /// /// The resulting expression. static member PropertySet: obj:Expr * property:PropertyInfo * value:Expr * ?indexerArgs: Expr list -> Expr /// Builds an expression that represents writing to a static property + /// /// The description of the property. /// The value to set. /// List of indices for the property if it is an indexed property. + /// /// The resulting expression. static member PropertySet: property:PropertyInfo * value:Expr * ?indexerArgs: Expr list -> Expr /// Builds an expression that represents a nested typed or raw quotation literal + /// /// The expression being quoted. + /// /// The resulting expression. [] static member Quote: inner:Expr -> Expr /// Builds an expression that represents a nested raw quotation literal + /// /// The expression being quoted. + /// /// The resulting expression. static member QuoteRaw: inner:Expr -> Expr /// Builds an expression that represents a nested typed quotation literal + /// /// The expression being quoted. + /// /// The resulting expression. static member QuoteTyped: inner:Expr -> Expr /// Builds an expression that represents the sequential execution of one expression followed by another + /// /// The first expression. /// The second expression. + /// /// The resulting expression. static member Sequential: first:Expr * second:Expr -> Expr /// Builds an expression that represents a try/with construct for exception filtering and catching. + /// /// The body of the try expression. /// /// /// The variable to bind to a caught exception. /// The expression evaluated when an exception is caught. + /// /// The resulting expression. static member TryWith: body:Expr * filterVar:Var * filterBody:Expr * catchVar:Var * catchBody:Expr -> Expr /// Builds an expression that represents a try/finally construct + /// /// The body of the try expression. /// The final part of the expression to be evaluated. + /// /// The resulting expression. static member TryFinally: body:Expr * compensation:Expr -> Expr /// Builds an expression that represents getting a field of a tuple + /// /// The input tuple. /// The index of the tuple element to get. + /// /// The resulting expression. static member TupleGet: tuple:Expr * index:int -> Expr /// Builds an expression that represents a type test. + /// /// The expression to test. /// The target type. + /// /// The resulting expression. static member TypeTest: source:Expr * target:Type -> Expr /// Builds an expression that represents a test of a value is of a particular union case + /// /// The expression to test. /// The description of the union case. + /// /// The resulting expression. static member UnionCaseTest: source:Expr * unionCase:UnionCaseInfo -> Expr /// Builds an expression that represents a constant value of a particular type + /// /// The untyped object. /// The type of the object. + /// /// The resulting expression. static member Value : value:obj * expressionType:Type -> Expr /// Builds an expression that represents a constant value + /// /// The typed value. + /// /// The resulting expression. static member Value : value:'T -> Expr /// Builds an expression that represents a constant value, arising from a variable of the given name + /// /// The typed value. /// The name of the variable. + /// /// The resulting expression. static member ValueWithName : value:'T * name: string -> Expr /// Builds an expression that represents a constant value of a particular type, arising from a variable of the given name + /// /// The untyped object. /// The type of the object. /// The name of the variable. + /// /// The resulting expression. static member ValueWithName : value:obj * expressionType:Type * name: string -> Expr /// Builds an expression that represents a value and its associated reflected definition as a quotation + /// /// The value being quoted. /// The definition of the value being quoted. + /// /// The resulting expression. static member WithValue: value: 'T * definition: Expr<'T> -> Expr<'T> /// Builds an expression that represents a value and its associated reflected definition as a quotation + /// /// The untyped object. /// The type of the object. /// The definition of the value being quoted. + /// /// The resulting expression. static member WithValue: value: obj * expressionType:Type * definition: Expr -> Expr /// Builds an expression that represents a variable + /// /// The input variable. + /// /// The resulting expression. static member Var : variable:Var -> Expr /// Builds an expression that represents setting a mutable variable + /// /// The input variable. /// The value to set. + /// /// The resulting expression. static member VarSet : variable:Var * value:Expr -> Expr /// Builds an expression that represents a while loop + /// /// The predicate to control the loop iteration. /// The body of the while loop. + /// /// The resulting expression. static member WhileLoop : guard:Expr * body:Expr -> Expr @@ -376,38 +477,47 @@ type Expr = /// Returns a new typed expression given an underlying runtime-typed expression. /// A type annotation is usually required to use this function, and /// using an incorrect type annotation may result in a later runtime exception. + /// /// The expression to cast. + /// /// The resulting typed expression. static member Cast : source:Expr -> Expr<'T> /// Try and find a stored reflection definition for the given method. Stored reflection /// definitions are added to an F# assembly through the use of the [<ReflectedDefinition>] attribute. + /// /// The description of the method to find. + /// /// The reflection definition or None if a match could not be found. static member TryGetReflectedDefinition : methodBase:MethodBase -> Expr option /// This function is called automatically when quotation syntax (<@ @>) and other sources of /// quotations are used. + /// /// A type in the assembly where the quotation occurs. /// The spliced types, to replace references to type variables. /// The spliced expressions to replace references to spliced expressions. /// The serialized form of the quoted expression. + /// /// The resulting expression. static member Deserialize : qualifyingType:System.Type * spliceTypes:list * spliceExprs:list * bytes:byte[] -> Expr /// This function is called automatically when quotation syntax (<@ @>) and other sources of /// quotations are used. + /// /// A type in the assembly where the quotation occurs. /// The type definitions referenced. /// The spliced types, to replace references to type variables. /// The spliced expressions to replace references to spliced expressions. /// The serialized form of the quoted expression. + /// /// The resulting expression. static member Deserialize40 : qualifyingType:Type * referencedTypes:Type[] * spliceTypes:Type[] * spliceExprs:Expr[] * bytes:byte[] -> Expr /// Permits interactive environments such as F# Interactive /// to explicitly register new pickled resources that represent persisted /// top level definitions. + /// /// The assembly associated with the resource. /// The unique name for the resources being added. /// The serialized resource to register with the environment. @@ -416,6 +526,7 @@ type Expr = /// Permits interactive environments such as F# Interactive /// to explicitly register new pickled resources that represent persisted /// top level definitions. + /// /// The assembly associated with the resource. /// The unique name for the resources being added. /// The type definitions referenced. @@ -424,12 +535,16 @@ type Expr = /// Fetches or creates a new variable with the given name and type from a global pool of shared variables /// indexed by name and type. The type is given by the explicit or inferred type parameter + /// /// The variable name. + /// /// The created of fetched typed global variable. static member GlobalVar<'T> : name:string -> Expr<'T> /// Format the expression as a string + /// /// Indicates if method, property, constructor and type objects should be printed in detail. If false, these are abbreviated to their name. + /// /// The formatted string. member ToString : full: bool -> string @@ -449,231 +564,307 @@ and [] module Patterns = /// An active pattern to recognize expressions that represent getting the address of a value + /// /// The input expression to match against. + /// /// Expr option [] val (|AddressOf|_|) : input:Expr -> Expr option /// An active pattern to recognize expressions that represent setting the value held at an address + /// /// The input expression to match against. + /// /// (Expr * Expr) option [] val (|AddressSet|_|) : input:Expr -> (Expr * Expr) option /// An active pattern to recognize expressions that represent applications of first class function values + /// /// The input expression to match against. + /// /// (Expr * Expr) option [] val (|Application|_|) : input:Expr -> (Expr * Expr) option /// An active pattern to recognize expressions that represent calls to static and instance methods, and functions defined in modules + /// /// The input expression to match against. + /// /// (Expr option * MethodInfo * Expr list) option [] val (|Call|_|) : input:Expr -> (Expr option * MethodInfo * Expr list) option /// An active pattern to recognize expressions that represent calls to static and instance methods, and functions defined in modules, including witness arguments + /// /// The input expression to match against. + /// /// (Expr option * MethodInfo * MethodInfo * Expr list) option [] [] val (|CallWithWitnesses|_|) : input:Expr -> (Expr option * MethodInfo * MethodInfo * Expr list * Expr list) option /// An active pattern to recognize expressions that represent coercions from one type to another + /// /// The input expression to match against. + /// /// (Expr * Type) option [] val (|Coerce|_|) : input:Expr -> (Expr * Type) option /// An active pattern to recognize expressions that represent getting a static or instance field + /// /// The input expression to match against. + /// /// (Expr option * FieldInfo) option [] val (|FieldGet|_|) : input:Expr -> (Expr option * FieldInfo) option /// An active pattern to recognize expressions that represent setting a static or instance field + /// /// The input expression to match against. + /// /// (Expr option * FieldInfo * Expr) option [] val (|FieldSet|_|) : input:Expr -> (Expr option * FieldInfo * Expr) option /// An active pattern to recognize expressions that represent loops over integer ranges + /// /// The input expression to match against. + /// /// (Var * Expr * Expr * Expr) option [] val (|ForIntegerRangeLoop|_|) : input:Expr -> (Var * Expr * Expr * Expr) option /// An active pattern to recognize expressions that represent while loops + /// /// The input expression to match against. + /// /// (Expr * Expr) option [] val (|WhileLoop|_|) : input:Expr -> (Expr * Expr) option /// An active pattern to recognize expressions that represent conditionals + /// /// The input expression to match against. + /// /// (Expr * Expr * Expr) option [] val (|IfThenElse|_|) : input:Expr -> (Expr * Expr * Expr) option /// An active pattern to recognize expressions that represent first class function values + /// /// The input expression to match against. + /// /// (Var * Expr) option [] val (|Lambda|_|) : input:Expr -> (Var * Expr) option /// An active pattern to recognize expressions that represent let bindings + /// /// The input expression to match against. + /// /// (Var * Expr * Expr) option [] val (|Let|_|) : input:Expr -> (Var * Expr * Expr) option /// An active pattern to recognize expressions that represent recursive let bindings of one or more variables + /// /// The input expression to match against. + /// /// ((Var * Expr) list * Expr) option [] val (|LetRecursive|_|) : input:Expr -> ((Var * Expr) list * Expr) option /// An active pattern to recognize expressions that represent the construction of arrays + /// /// The input expression to match against. + /// /// (Type * Expr list) option [] val (|NewArray|_|) : input:Expr -> (Type * Expr list) option /// An active pattern to recognize expressions that represent invocations of a default constructor of a struct + /// /// The input expression to match against. + /// /// Type option [] val (|DefaultValue|_|) : input:Expr -> Type option /// An active pattern to recognize expressions that represent construction of delegate values + /// /// The input expression to match against. + /// /// (Type * Var list * Expr) option [] val (|NewDelegate|_|) : input:Expr -> (Type * Var list * Expr) option /// An active pattern to recognize expressions that represent invocation of object constructors + /// /// The input expression to match against. + /// /// (ConstructorInfo * Expr list) option [] val (|NewObject|_|) : input:Expr -> (ConstructorInfo * Expr list) option /// An active pattern to recognize expressions that represent construction of record values + /// /// The input expression to match against. + /// /// (Type * Expr list) option [] val (|NewRecord|_|) : input:Expr -> (Type * Expr list) option /// An active pattern to recognize expressions that represent construction of particular union case values + /// /// The input expression to match against. + /// /// (UnionCaseInfo * Expr list) option [] val (|NewUnionCase|_|) : input:Expr -> (UnionCaseInfo * Expr list) option /// An active pattern to recognize expressions that represent construction of tuple values + /// /// The input expression to match against. + /// /// (Expr list) option [] val (|NewTuple|_|) : input:Expr -> (Expr list) option /// An active pattern to recognize expressions that represent construction of struct tuple values + /// /// The input expression to match against. + /// /// (Expr list) option [] val (|NewStructTuple|_|) : input:Expr -> (Expr list) option /// An active pattern to recognize expressions that represent the read of a static or instance property, or a non-function value declared in a module + /// /// The input expression to match against. + /// /// (Expr option * PropertyInfo * Expr list) option [] val (|PropertyGet|_|) : input:Expr -> (Expr option * PropertyInfo * Expr list) option /// An active pattern to recognize expressions that represent setting a static or instance property, or a non-function value declared in a module + /// /// The input expression to match against. + /// /// (Expr option * PropertyInfo * Expr list * Expr) option [] val (|PropertySet|_|) : input:Expr -> (Expr option * PropertyInfo * Expr list * Expr) option /// An active pattern to recognize expressions that represent a nested quotation literal + /// /// The input expression to match against. + /// /// Expr option [] [] val (|Quote|_|) : input:Expr -> Expr option /// An active pattern to recognize expressions that represent a nested raw quotation literal + /// /// The input expression to match against. + /// /// Expr option [] val (|QuoteRaw|_|) : input:Expr -> Expr option /// An active pattern to recognize expressions that represent a nested typed quotation literal + /// /// The input expression to match against. + /// /// Expr option [] val (|QuoteTyped|_|) : input:Expr -> Expr option /// An active pattern to recognize expressions that represent sequential execution of one expression followed by another + /// /// The input expression to match against. + /// /// (Expr * Expr) option [] val (|Sequential|_|) : input:Expr -> (Expr * Expr) option /// An active pattern to recognize expressions that represent a try/with construct for exception filtering and catching + /// /// The input expression to match against. + /// /// (Expr * Var * Expr * Var * Expr) option [] val (|TryWith|_|) : input:Expr -> (Expr * Var * Expr * Var * Expr) option /// An active pattern to recognize expressions that represent a try/finally construct + /// /// The input expression to match against. + /// /// The body and handler parts of the try/finally expression [] val (|TryFinally|_|) : input:Expr -> (Expr * Expr) option /// An active pattern to recognize expressions that represent getting a tuple field + /// /// The input expression to match against. + /// /// The expression and tuple field being accessed [] val (|TupleGet|_|) : input:Expr -> (Expr * int) option /// An active pattern to recognize expressions that represent a dynamic type test + /// /// The input expression to match against. + /// /// The expression and type being tested [] val (|TypeTest|_|) : input:Expr -> (Expr * Type) option /// An active pattern to recognize expressions that represent a test if a value is of a particular union case + /// /// The input expression to match against. + /// /// The expression and union case being tested [] val (|UnionCaseTest|_|) : input:Expr -> (Expr * UnionCaseInfo) option /// An active pattern to recognize expressions that represent a constant value. This also matches expressions matched by ValueWithName. + /// /// The input expression to match against. + /// /// The boxed value and its static type [] val (|Value|_|) : input:Expr -> (obj * Type) option /// An active pattern to recognize expressions that represent a constant value + /// /// The input expression to match against. + /// /// The boxed value, its static type and its name [] val (|ValueWithName|_|) : input:Expr -> (obj * Type * string) option /// An active pattern to recognize expressions that are a value with an associated definition + /// /// The input expression to match against. + /// /// The boxed value, its static type and its definition [] val (|WithValue|_|) : input:Expr -> (obj * Type * Expr) option /// An active pattern to recognize expressions that represent a variable + /// /// The input expression to match against. + /// /// Var option [] val (|Var|_|) : input:Expr -> Var option /// An active pattern to recognize expressions that represent setting a mutable variable + /// /// The input expression to match against. + /// /// (Var * Expr) option [] val (|VarSet|_|) : input:Expr -> (Var * Expr) option @@ -683,115 +874,153 @@ module Patterns = module DerivedPatterns = /// An active pattern to recognize expressions that represent a (possibly curried or tupled) first class function value + /// /// The input expression to match against. + /// /// (Var list list * Expr) option [] val (|Lambdas|_|) : input:Expr -> (Var list list * Expr) option /// An active pattern to recognize expressions that represent the application of a (possibly curried or tupled) first class function value + /// /// The input expression to match against. + /// /// (Expr * Expr list list) option [] val (|Applications|_|) : input:Expr -> (Expr * Expr list list) option /// An active pattern to recognize expressions of the form a && b + /// /// The input expression to match against. + /// /// (Expr * Expr) option [] val (|AndAlso|_|) : input:Expr -> (Expr * Expr) option /// An active pattern to recognize expressions of the form a || b + /// /// The input expression to match against. + /// /// (Expr * Expr) option [] val (|OrElse|_|) : input:Expr -> (Expr * Expr) option /// An active pattern to recognize () constant expressions + /// /// The input expression to match against. + /// /// unit option [] val (|Unit|_|) : input:Expr -> unit option /// An active pattern to recognize constant boolean expressions + /// /// The input expression to match against. + /// /// bool option [] val (|Bool|_|) : input:Expr -> bool option /// An active pattern to recognize constant string expressions + /// /// The input expression to match against. + /// /// string option [] val (|String|_|) : input:Expr -> string option /// An active pattern to recognize constant 32-bit floating point number expressions + /// /// The input expression to match against. + /// /// float32 option [] val (|Single|_|) : input:Expr -> float32 option /// An active pattern to recognize constant 64-bit floating point number expressions + /// /// The input expression to match against. + /// /// float option [] val (|Double|_|) : input:Expr -> float option /// An active pattern to recognize constant unicode character expressions + /// /// The input expression to match against. + /// /// char option [] val (|Char|_|) : input:Expr -> char option /// An active pattern to recognize constant signed byte expressions + /// /// The input expression to match against. + /// /// sbyte option [] val (|SByte|_|) : input:Expr -> sbyte option /// An active pattern to recognize constant byte expressions + /// /// The input expression to match against. + /// /// byte option [] val (|Byte|_|) : input:Expr -> byte option /// An active pattern to recognize constant int16 expressions + /// /// The input expression to match against. + /// /// int16 option [] val (|Int16|_|) : input:Expr -> int16 option /// An active pattern to recognize constant unsigned int16 expressions + /// /// The input expression to match against. + /// /// uint16 option [] val (|UInt16|_|) : input:Expr -> uint16 option /// An active pattern to recognize constant int32 expressions + /// /// The input expression to match against. + /// /// int32 option [] val (|Int32|_|) : input:Expr -> int32 option /// An active pattern to recognize constant unsigned int32 expressions + /// /// The input expression to match against. + /// /// uint32 option [] val (|UInt32|_|) : input:Expr -> uint32 option /// An active pattern to recognize constant int64 expressions + /// /// The input expression to match against. + /// /// int64 option [] val (|Int64|_|) : input:Expr -> int64 option /// An active pattern to recognize constant unsigned int64 expressions + /// /// The input expression to match against. + /// /// uint64 option [] val (|UInt64|_|) : input:Expr -> uint64 option /// An active pattern to recognize constant decimal expressions + /// /// The input expression to match against. + /// /// decimal option [] val (|Decimal|_|) : input:Expr -> decimal option @@ -800,7 +1029,9 @@ module DerivedPatterns = /// The returned elements are the optional target object (present if the target is an /// instance method), the generic type instantiation (non-empty if the target is a generic /// instantiation), and the arguments to the function or method. + /// /// The input template expression to specify the method to call. + /// /// The optional target object (present if the target is an /// instance method), the generic type instantiation (non-empty if the target is a generic /// instantiation), and the arguments to the function or method. @@ -808,19 +1039,25 @@ module DerivedPatterns = val (|SpecificCall|_|) : templateParameter:Expr -> (Expr -> (Expr option * list * list) option) /// An active pattern to recognize methods that have an associated ReflectedDefinition + /// /// The description of the method. + /// /// The expression of the method definition if found, or None. [] val (|MethodWithReflectedDefinition|_|) : methodBase:MethodBase -> Expr option /// An active pattern to recognize property getters or values in modules that have an associated ReflectedDefinition + /// /// The description of the property. + /// /// The expression of the method definition if found, or None. [] val (|PropertyGetterWithReflectedDefinition|_|) : propertyInfo:PropertyInfo -> Expr option /// An active pattern to recognize property setters that have an associated ReflectedDefinition + /// /// The description of the property. + /// /// The expression of the method definition if found, or None. [] val (|PropertySetterWithReflectedDefinition|_|) : propertyInfo:PropertyInfo -> Expr option @@ -830,7 +1067,9 @@ module DerivedPatterns = module ExprShape = /// An active pattern that performs a complete decomposition viewing the expression tree as a binding structure + /// /// The input expression. + /// /// The decomposed Var, Lambda, or ConstApp. [] val (|ShapeVar|ShapeLambda|ShapeCombination|) : @@ -840,7 +1079,9 @@ module ExprShape = /// Re-build combination expressions. The first parameter should be an object /// returned by the ShapeCombination case of the active pattern in this module. + /// /// The input shape. /// The list of arguments. + /// /// The rebuilt expression. val RebuildShapeCombination : shape:obj * arguments:list -> Expr diff --git a/src/fsharp/FSharp.Core/reflect.fsi b/src/fsharp/FSharp.Core/reflect.fsi index 465529677a76..e6c2f6f9098a 100644 --- a/src/fsharp/FSharp.Core/reflect.fsi +++ b/src/fsharp/FSharp.Core/reflect.fsi @@ -26,6 +26,7 @@ type UnionCaseInfo = member GetCustomAttributes: unit -> obj[] /// Returns the custom attributes associated with the case matching the given attribute type. /// The type of attributes to return. + /// /// An array of custom attributes. member GetCustomAttributes: attributeType:System.Type -> obj[] @@ -51,7 +52,7 @@ type FSharpValue = /// Assumes the given input is a record value. If not, ArgumentException is raised. /// The record object. /// The PropertyInfo describing the field to read. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// The field from the record. static member GetRecordField: record:obj * info:PropertyInfo -> obj @@ -63,7 +64,7 @@ type FSharpValue = /// because the path executed by the computed function is optimized given the knowledge that it will be /// used to read values of the given type. /// The PropertyInfo of the field to read. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// A function to read the specified field from the record. static member PreComputeRecordFieldReader : info:PropertyInfo -> (obj -> obj) @@ -73,7 +74,7 @@ type FSharpValue = /// The type of record to make. /// The array of values to initialize the record. /// Optional binding flags for the record. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// The created record. static member MakeRecord: recordType:Type * values:obj [] * ?bindingFlags:BindingFlags -> obj @@ -82,7 +83,7 @@ type FSharpValue = /// Assumes the given input is a record value. If not, ArgumentException is raised. /// The record object. /// Optional binding flags for the record. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// The array of fields from the record. static member GetRecordFields: record:obj * ?bindingFlags:BindingFlags -> obj[] @@ -98,7 +99,7 @@ type FSharpValue = /// used to read values of the given type. /// The type of record to read. /// Optional binding flags. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// An optimized reader for the given record type. static member PreComputeRecordReader : recordType:Type * ?bindingFlags:BindingFlags -> (obj -> obj[]) /// Precompute a function for constructing a record value. @@ -107,20 +108,24 @@ type FSharpValue = /// If not, ArgumentException is raised during pre-computation. /// The type of record to construct. /// Optional binding flags. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// A function to construct records of the given type. static member PreComputeRecordConstructor : recordType:Type * ?bindingFlags:BindingFlags -> (obj[] -> obj) /// Get a ConstructorInfo for a record type + /// /// The record type. /// Optional binding flags. + /// /// A ConstructorInfo for the given record type. static member PreComputeRecordConstructorInfo: recordType:Type * ?bindingFlags:BindingFlags -> ConstructorInfo /// Create a union case value. + /// /// The description of the union case to create. /// The array of arguments to construct the given case. /// Optional binding flags. + /// /// The constructed union case. static member MakeUnion: unionCase:UnionCaseInfo * args:obj [] * ?bindingFlags:BindingFlags -> obj @@ -134,7 +139,7 @@ type FSharpValue = /// The input union case. /// The union type containing the value. /// Optional binding flags. - /// Thrown when the input type is not a union case value. + /// Thrown when the input type is not a union case value. /// The description of the union case and its fields. static member GetUnionFields: value:obj * unionType:Type * ?bindingFlags:BindingFlags -> UnionCaseInfo * obj [] @@ -146,12 +151,15 @@ type FSharpValue = /// used to read values of the given type. /// The type of union to optimize reading. /// Optional binding flags. + /// /// An optimized function to read the tags of the given union type. static member PreComputeUnionTagReader : unionType:Type * ?bindingFlags:BindingFlags -> (obj -> int) /// Precompute a property or static method for reading an integer representing the case tag of a union type. + /// /// The type of union to read. /// Optional binding flags. + /// /// The description of the union case reader. static member PreComputeUnionTagMemberInfo : unionType:Type * ?bindingFlags:BindingFlags -> MemberInfo @@ -160,18 +168,23 @@ type FSharpValue = /// Using the computed function will typically be faster than executing a corresponding call to GetFields /// The description of the union case to read. /// Optional binding flags. + /// /// A function to for reading the fields of the given union case. static member PreComputeUnionReader : unionCase:UnionCaseInfo * ?bindingFlags:BindingFlags -> (obj -> obj[]) /// Precompute a function for constructing a discriminated union value for a particular union case. + /// /// The description of the union case. /// Optional binding flags. + /// /// A function for constructing values of the given union case. static member PreComputeUnionConstructor : unionCase:UnionCaseInfo * ?bindingFlags:BindingFlags -> (obj[] -> obj) /// A method that constructs objects of the given case + /// /// The description of the union case. /// Optional binding flags. + /// /// The description of the constructor of the given union case. static member PreComputeUnionConstructorInfo: unionCase:UnionCaseInfo * ?bindingFlags:BindingFlags -> MethodInfo @@ -180,7 +193,7 @@ type FSharpValue = /// Assumes the given input is an F# exception value. If not, ArgumentException is raised. /// The exception instance. /// Optional binding flags. - /// Thrown when the input type is not an F# exception. + /// Thrown when the input type is not an F# exception. /// The fields from the given exception. static member GetExceptionFields: exn:obj * ?bindingFlags:BindingFlags -> obj[] @@ -189,7 +202,7 @@ type FSharpValue = /// Assumes at least one element is given. If not, ArgumentException is raised. /// The array of tuple fields. /// The tuple type to create. - /// Thrown if no elements are given. + /// Thrown if no elements are given. /// An instance of the tuple type with the given elements. static member MakeTuple: tupleElements:obj[] * tupleType:Type -> obj @@ -198,6 +211,7 @@ type FSharpValue = /// Assumes the given input is a tuple value. If not, ArgumentException is raised. /// The input tuple. /// The index of the field to read. + /// /// The value of the field. static member GetTupleField: tuple:obj * index:int -> obj @@ -205,7 +219,7 @@ type FSharpValue = /// /// Assumes the given input is a tuple value. If not, ArgumentException is raised. /// The input tuple. - /// Thrown when the input is not a tuple value. + /// Thrown when the input is not a tuple value. /// An array of the fields from the given tuple. static member GetTupleFields: tuple:obj -> obj [] @@ -214,13 +228,15 @@ type FSharpValue = /// Assumes the given type is a TupleType. /// If not, ArgumentException is raised during pre-computation. /// The tuple type to read. - /// Thrown when the given type is not a tuple type. + /// Thrown when the given type is not a tuple type. /// A function to read values of the given tuple type. static member PreComputeTupleReader : tupleType:Type -> (obj -> obj[]) /// Gets information that indicates how to read a field of a tuple + /// /// The input tuple type. /// The index of the tuple element to describe. + /// /// The description of the tuple element and an optional type and index if the tuple is big. static member PreComputeTuplePropertyInfo: tupleType:Type * index:int -> PropertyInfo * (Type * int) option @@ -229,7 +245,7 @@ type FSharpValue = /// Assumes the given type is a TupleType. /// If not, ArgumentException is raised during pre-computation. /// The type of tuple to read. - /// Thrown when the given type is not a tuple type. + /// Thrown when the given type is not a tuple type. /// A function to read a particular tuple type. static member PreComputeTupleConstructor : tupleType:Type -> (obj[] -> obj) @@ -243,13 +259,16 @@ type FSharpValue = /// to the ConstructorInfo. A recursive call to PreComputeTupleConstructorInfo /// can be used to determine the constructor for that the suffix type. /// The input tuple type. + /// /// The description of the tuple type constructor and an optional extra type /// for large tuples. static member PreComputeTupleConstructorInfo: tupleType:Type -> ConstructorInfo * Type option /// Builds a typed function from object from a dynamic function implementation + /// /// The function type of the implementation. /// The untyped lambda of the function implementation. + /// /// A typed function from the given dynamic implementation. static member MakeFunction : functionType:Type * implementation:(obj -> obj) -> obj @@ -262,6 +281,7 @@ type FSharpType = /// Assumes the given input is a record value. If not, ArgumentException is raised. /// The input record type. /// Optional binding flags. + /// /// An array of descriptions of the properties of the record type. static member GetRecordFields: recordType:Type * ?bindingFlags:BindingFlags -> PropertyInfo[] @@ -270,20 +290,24 @@ type FSharpType = /// Assumes the given type is a union type. If not, ArgumentException is raised during pre-computation. /// The input union type. /// Optional binding flags. - /// Thrown when the input type is not a union type. + /// Thrown when the input type is not a union type. /// An array of descriptions of the cases of the given union type. static member GetUnionCases: unionType:Type * ?bindingFlags:BindingFlags -> UnionCaseInfo[] /// Return true if the typ is a representation of an F# record type + /// /// The type to check. /// Optional binding flags. + /// /// True if the type check succeeds. static member IsRecord: typ:Type * ?bindingFlags:BindingFlags -> bool /// Returns true if the typ is a representation of an F# union type or the runtime type of a value of that type + /// /// The type to check. /// Optional binding flags. + /// /// True if the type check succeeds. static member IsUnion: typ:Type * ?bindingFlags:BindingFlags -> bool @@ -292,62 +316,82 @@ type FSharpType = /// Assumes exceptionType is an exception representation type. If not, ArgumentException is raised. /// The exception type to read. /// Optional binding flags. - /// Thrown if the given type is not an exception. + /// Thrown if the given type is not an exception. /// An array containing the PropertyInfo of each field in the exception. static member GetExceptionFields: exceptionType:Type * ?bindingFlags:BindingFlags -> PropertyInfo[] /// Returns true if the typ is a representation of an F# exception declaration + /// /// The type to check. /// Optional binding flags. + /// /// True if the type check is an F# exception. static member IsExceptionRepresentation: exceptionType:Type * ?bindingFlags:BindingFlags -> bool - /// Returns a System.Type representing the F# function type with the given domain and range + /// Returns a representing the F# function type with the given domain and range + /// /// The input type of the function. /// The output type of the function. + /// /// The function type with the given domain and range. static member MakeFunctionType: domain:Type * range:Type -> Type - /// Returns a System.Type representing an F# tuple type with the given element types + /// Returns a representing an F# tuple type with the given element types + /// /// An array of types for the tuple elements. + /// /// The type representing the tuple containing the input elements. static member MakeTupleType: types:Type[] -> Type - /// Returns a System.Type representing an F# tuple type with the given element types + /// Returns a representing an F# tuple type with the given element types + /// /// Runtime assembly containing System.Tuple definitions. /// An array of types for the tuple elements. + /// /// The type representing the tuple containing the input elements. static member MakeTupleType: asm:Assembly * types:Type[] -> Type - /// Returns a System.Type representing an F# struct tuple type with the given element types + /// Returns a representing an F# struct tuple type with the given element types + /// /// Runtime assembly containing System.ValueTuple definitions. /// An array of types for the tuple elements. + /// /// The type representing the struct tuple containing the input elements. static member MakeStructTupleType: asm:Assembly * types:Type[] -> Type /// Return true if the typ is a representation of an F# tuple type + /// /// The type to check. + /// /// True if the type check succeeds. static member IsTuple : typ:Type -> bool /// Return true if the typ is a representation of an F# function type or the runtime type of a closure implementing an F# function type + /// /// The type to check. + /// /// True if the type check succeeds. static member IsFunction : typ:Type -> bool - /// Return true if the typ is a System.Type value corresponding to the compiled form of an F# module + /// Return true if the typ is a value corresponding to the compiled form of an F# module + /// /// The type to check. + /// /// True if the type check succeeds. static member IsModule: typ:Type -> bool /// Gets the tuple elements from the representation of an F# tuple type. + /// /// The input tuple type. + /// /// An array of the types contained in the given tuple type. static member GetTupleElements : tupleType:Type -> Type[] /// Gets the domain and range types from an F# function type or from the runtime type of a closure implementing an F# type + /// /// The input function type. + /// /// A tuple of the domain and range types of the input function. static member GetFunctionElements : functionType:Type -> Type * Type @@ -360,7 +404,7 @@ module FSharpReflectionExtensions = /// The type of record to make. /// The array of values to initialize the record. /// Optional flags that denotes accessibility of the private representation. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// The created record. static member MakeRecord: recordType:Type * values:obj [] * ?allowAccessToPrivateRepresentation : bool -> obj /// Reads all the fields from a record value. @@ -368,7 +412,7 @@ module FSharpReflectionExtensions = /// Assumes the given input is a record value. If not, ArgumentException is raised. /// The record object. /// Optional flag that denotes accessibility of the private representation. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// The array of fields from the record. static member GetRecordFields: record:obj * ?allowAccessToPrivateRepresentation : bool -> obj[] @@ -384,7 +428,7 @@ module FSharpReflectionExtensions = /// used to read values of the given type. /// The type of record to read. /// Optional flag that denotes accessibility of the private representation. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// An optimized reader for the given record type. static member PreComputeRecordReader : recordType:Type * ?allowAccessToPrivateRepresentation : bool -> (obj -> obj[]) /// Precompute a function for constructing a record value. @@ -393,17 +437,19 @@ module FSharpReflectionExtensions = /// If not, ArgumentException is raised during pre-computation. /// The type of record to construct. /// Optional flag that denotes accessibility of the private representation. - /// Thrown when the input type is not a record type. + /// Thrown when the input type is not a record type. /// A function to construct records of the given type. static member PreComputeRecordConstructor : recordType:Type * ?allowAccessToPrivateRepresentation : bool -> (obj[] -> obj) /// Get a ConstructorInfo for a record type + /// /// The record type. /// Optional flag that denotes accessibility of the private representation. /// A ConstructorInfo for the given record type. static member PreComputeRecordConstructorInfo: recordType:Type * ?allowAccessToPrivateRepresentation : bool-> ConstructorInfo /// Create a union case value. + /// /// The description of the union case to create. /// The array of arguments to construct the given case. /// Optional flag that denotes accessibility of the private representation. @@ -420,7 +466,7 @@ module FSharpReflectionExtensions = /// The input union case. /// The union type containing the value. /// Optional flag that denotes accessibility of the private representation. - /// Thrown when the input type is not a union case value. + /// Thrown when the input type is not a union case value. /// The description of the union case and its fields. static member GetUnionFields: value:obj * unionType:Type * ?allowAccessToPrivateRepresentation : bool -> UnionCaseInfo * obj [] @@ -432,10 +478,12 @@ module FSharpReflectionExtensions = /// used to read values of the given type. /// The type of union to optimize reading. /// Optional flag that denotes accessibility of the private representation. + /// /// An optimized function to read the tags of the given union type. static member PreComputeUnionTagReader : unionType:Type * ?allowAccessToPrivateRepresentation : bool -> (obj -> int) /// Precompute a property or static method for reading an integer representing the case tag of a union type. + /// /// The type of union to read. /// Optional flag that denotes accessibility of the private representation. /// The description of the union case reader. @@ -450,12 +498,14 @@ module FSharpReflectionExtensions = static member PreComputeUnionReader : unionCase:UnionCaseInfo * ?allowAccessToPrivateRepresentation : bool -> (obj -> obj[]) /// Precompute a function for constructing a discriminated union value for a particular union case. + /// /// The description of the union case. /// Optional flag that denotes accessibility of the private representation. /// A function for constructing values of the given union case. static member PreComputeUnionConstructor : unionCase:UnionCaseInfo * ?allowAccessToPrivateRepresentation : bool -> (obj[] -> obj) /// A method that constructs objects of the given case + /// /// The description of the union case. /// Optional flag that denotes accessibility of the private representation. /// The description of the constructor of the given union case. @@ -466,7 +516,7 @@ module FSharpReflectionExtensions = /// Assumes the given input is an F# exception value. If not, ArgumentException is raised. /// The exception instance. /// Optional flag that denotes accessibility of the private representation. - /// Thrown when the input type is not an F# exception. + /// Thrown when the input type is not an F# exception. /// The fields from the given exception. static member GetExceptionFields: exn:obj * ?allowAccessToPrivateRepresentation : bool -> obj[] @@ -484,18 +534,20 @@ module FSharpReflectionExtensions = /// Assumes the given type is a union type. If not, ArgumentException is raised during pre-computation. /// The input union type. /// Optional flag that denotes accessibility of the private representation. - /// Thrown when the input type is not a union type. + /// Thrown when the input type is not a union type. /// An array of descriptions of the cases of the given union type. static member GetUnionCases: unionType:Type * ?allowAccessToPrivateRepresentation : bool -> UnionCaseInfo[] /// Return true if the typ is a representation of an F# record type + /// /// The type to check. /// Optional flag that denotes accessibility of the private representation. /// True if the type check succeeds. static member IsRecord: typ:Type * ?allowAccessToPrivateRepresentation : bool -> bool /// Returns true if the typ is a representation of an F# union type or the runtime type of a value of that type + /// /// The type to check. /// Optional flag that denotes accessibility of the private representation. /// True if the type check succeeds. @@ -506,11 +558,12 @@ module FSharpReflectionExtensions = /// Assumes exceptionType is an exception representation type. If not, ArgumentException is raised. /// The exception type to read. /// Optional flag that denotes accessibility of the private representation. - /// Thrown if the given type is not an exception. + /// Thrown if the given type is not an exception. /// An array containing the PropertyInfo of each field in the exception. static member GetExceptionFields: exceptionType:Type * ?allowAccessToPrivateRepresentation : bool -> PropertyInfo[] /// Returns true if the typ is a representation of an F# exception declaration + /// /// The type to check. /// Optional flag that denotes accessibility of the private representation. /// True if the type check is an F# exception. diff --git a/src/fsharp/FSharp.Core/result.fsi b/src/fsharp/FSharp.Core/result.fsi index 77e289bd17ff..2cb80c5b0f50 100644 --- a/src/fsharp/FSharp.Core/result.fsi +++ b/src/fsharp/FSharp.Core/result.fsi @@ -5,26 +5,32 @@ namespace Microsoft.FSharp.Core open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators [] + /// Basic operations for values of type . module Result = /// map f inp evaluates to match inp with Error e -> Error e | Ok x -> Ok (f x). /// A function to apply to the OK result value. /// The input result. + /// /// A result of the input value after applying the mapping function, or Error if the input is Error. [] val map : mapping:('T -> 'U) -> result:Result<'T, 'TError> -> Result<'U, 'TError> /// map f inp evaluates to match inp with Error x -> Error (f x) | Ok v -> Ok v. + /// /// A function to apply to the Error result value. /// The input result. + /// /// A result of the error value after applying the mapping function, or Ok if the input is Ok. [] val mapError: mapping:('TError -> 'U) -> result:Result<'T, 'TError> -> Result<'T, 'U> /// bind f inp evaluates to match inp with Error e -> Error e | Ok x -> f x + /// /// A function that takes the value of type T from a result and transforms it into /// a result containing a value of type U. /// The input result. + /// /// A result of the output type of the binder. [] val bind: binder:('T -> Result<'U, 'TError>) -> result:Result<'T, 'TError> -> Result<'U, 'TError> diff --git a/src/fsharp/FSharp.Core/seq.fsi b/src/fsharp/FSharp.Core/seq.fsi index 9ed5bed09653..144276df7c25 100644 --- a/src/fsharp/FSharp.Core/seq.fsi +++ b/src/fsharp/FSharp.Core/seq.fsi @@ -9,7 +9,7 @@ namespace Microsoft.FSharp.Collections open Microsoft.FSharp.Collections - /// Basic operations on IEnumerables. + /// Basic operations on values of type . [] [] module Seq = @@ -17,8 +17,9 @@ namespace Microsoft.FSharp.Collections /// Returns a new sequence that contains all pairings of elements from the first and second sequences. /// The first sequence. /// The second sequence. + /// /// The result sequence. - /// Thrown when either of the input sequences is null. + /// Thrown when either of the input sequences is null. [] val allPairs: source1:seq<'T1> -> source2:seq<'T2> -> seq<'T1 * 'T2> @@ -34,7 +35,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when either of the two provided sequences is + /// Thrown when either of the two provided sequences is /// null. [] val append: source1:seq<'T> -> source2:seq<'T> -> seq<'T> @@ -48,8 +49,8 @@ namespace Microsoft.FSharp.Collections /// /// The average. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence has zero elements. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence has zero elements. [] val inline average : source:seq<(^T)> -> ^T when ^T : (static member ( + ) : ^T * ^T -> ^T) @@ -67,8 +68,8 @@ namespace Microsoft.FSharp.Collections /// /// The average. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence has zero elements. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence has zero elements. [] val inline averageBy : projection:('T -> ^U) -> source:seq<'T> -> ^U when ^U : (static member ( + ) : ^U * ^U -> ^U) @@ -101,7 +102,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val cache: source:seq<'T> -> seq<'T> @@ -116,7 +117,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val cast: source:IEnumerable -> seq<'T> @@ -133,16 +134,18 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val choose: chooser:('T -> 'U option) -> source:seq<'T> -> seq<'U> /// Divides the input sequence into chunks of size at most chunkSize. + /// /// The maximum size of each chunk. /// The input sequence. + /// /// The sequence divided into chunks. - /// Thrown when the input sequence is null. - /// Thrown when chunkSize is not positive. + /// Thrown when the input sequence is null. + /// Thrown when chunkSize is not positive. [] val chunkBySize: chunkSize:int -> source:seq<'T> -> seq<'T[]> @@ -157,7 +160,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val collect: mapping:('T -> 'Collection) -> source:seq<'T> -> seq<'U> when 'Collection :> seq<'U> @@ -172,7 +175,7 @@ namespace Microsoft.FSharp.Collections /// is reached it returns a -1 if the first sequence is shorter and a 1 if the second sequence /// is shorter. /// - /// Thrown when either of the input sequences + /// Thrown when either of the input sequences /// is null. [] val compareWith: comparer:('T -> 'T -> int) -> source1:seq<'T> -> source2:seq<'T> -> int @@ -187,15 +190,17 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val concat: sources:seq<'Collection> -> seq<'T> when 'Collection :> seq<'T> /// Tests if the sequence contains the specified element. + /// /// The value to locate in the input sequence. /// The input sequence. + /// /// True if the input sequence contains the specified element; false otherwise. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val inline contains: value:'T -> source:seq<'T> -> bool when 'T : equality @@ -213,7 +218,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val countBy : projection:('T -> 'Key) -> source:seq<'T> -> seq<'Key * int> when 'Key : equality @@ -235,7 +240,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val distinct: source:seq<'T> -> seq<'T> when 'T : equality @@ -248,7 +253,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val distinctBy: projection:('T -> 'Key) -> source:seq<'T> -> seq<'T> when 'Key : equality @@ -257,9 +262,10 @@ namespace Microsoft.FSharp.Collections /// sequence is iterated. As a result this function should not be used with large or infinite sequences. /// The maximum number of chunks. /// The input sequence. + /// /// The sequence split into chunks. - /// Thrown when the input sequence is null. - /// Thrown when count is not positive. + /// Thrown when the input sequence is null. + /// Thrown when count is not positive. /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val splitInto: count:int -> source:seq<'T> -> seq<'T[]> @@ -285,7 +291,7 @@ namespace Microsoft.FSharp.Collections /// /// A sequence that contains the set difference of the elements of two sequences. /// - /// Thrown when either of the two input sequences is null. + /// Thrown when either of the two input sequences is null. [] val except: itemsToExclude:seq<'T> -> source:seq<'T> -> seq<'T> when 'T : equality @@ -300,7 +306,7 @@ namespace Microsoft.FSharp.Collections /// /// True if any result from the predicate is true; false otherwise. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val exists: predicate:('T -> bool) -> source:seq<'T> -> bool @@ -317,7 +323,7 @@ namespace Microsoft.FSharp.Collections /// /// True if any result from the predicate is true; false otherwise. /// - /// Thrown when either of the two input sequences is null. + /// Thrown when either of the two input sequences is null. [] val exists2: predicate:('T1 -> 'T2 -> bool) -> source1:seq<'T1> -> source2:seq<'T2> -> bool @@ -334,7 +340,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val filter: predicate:('T -> bool) -> source:seq<'T> -> seq<'T> @@ -353,7 +359,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val where: predicate:('T -> bool) -> source:seq<'T> -> seq<'T> @@ -364,9 +370,9 @@ namespace Microsoft.FSharp.Collections /// /// The first element for which the predicate returns True. /// - /// Thrown if no element returns true when + /// Thrown if no element returns true when /// evaluated by the predicate - /// Thrown when the input sequence is null + /// Thrown when the input sequence is null [] val find: predicate:('T -> bool) -> source:seq<'T> -> 'T @@ -375,10 +381,11 @@ namespace Microsoft.FSharp.Collections /// result this function should not be used with large or infinite sequences. /// A function to test whether an item in the sequence should be returned. /// The input sequence. + /// /// The last element for which the predicate returns True. - /// Thrown if no element returns true when + /// Thrown if no element returns true when /// evaluated by the predicate - /// Thrown when the input sequence is null + /// Thrown when the input sequence is null /// This function consumes the whole input sequence before returning the result. [] val findBack: predicate:('T -> bool) -> source:seq<'T> -> 'T @@ -390,9 +397,9 @@ namespace Microsoft.FSharp.Collections /// /// The index of the first element for which the predicate returns True. /// - /// Thrown if no element returns true when + /// Thrown if no element returns true when /// evaluated by the predicate - /// Thrown when the input sequence is null + /// Thrown when the input sequence is null [] val findIndex: predicate:('T -> bool) -> source:seq<'T> -> int @@ -401,10 +408,11 @@ namespace Microsoft.FSharp.Collections /// result this function should not be used with large or infinite sequences. /// A function to test whether the index of a particular element should be returned. /// The input sequence. + /// /// The index of the last element for which the predicate returns True. - /// Thrown if no element returns true when + /// Thrown if no element returns true when /// evaluated by the predicate - /// Thrown when the input sequence is null + /// Thrown when the input sequence is null /// This function consumes the whole input sequence before returning the result. [] val findIndexBack: predicate:('T -> bool) -> source:seq<'T> -> int @@ -419,7 +427,7 @@ namespace Microsoft.FSharp.Collections /// /// The state object after the folding function is applied to each element of the sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val fold<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> source:seq<'T> -> 'State @@ -428,23 +436,27 @@ namespace Microsoft.FSharp.Collections /// when one sequence is exhausted any remaining elements in the other sequence are ignored. /// If the input function is f and the elements are i0...iN and j0...jN /// then computes f (... (f s i0 j0)...) iN jN. + /// /// The function to update the state given the input elements. /// The initial state. /// The first input sequence. /// The second input sequence. + /// /// The final state value. - /// Thrown when the either of the input sequences is null. + /// Thrown when the either of the input sequences is null. [] val fold2<'T1,'T2,'State> : folder:('State -> 'T1 -> 'T2 -> 'State) -> state:'State -> source1:seq<'T1> -> source2:seq<'T2> -> 'State /// Applies a function to each element of the collection, starting from the end, threading an accumulator argument /// through the computation. If the input function is f and the elements are i0...iN /// then computes f i0 (... (f iN s)...) + /// /// The function to update the state given the input elements. /// The input sequence. /// The initial state. + /// /// The state object after the folding function is applied to each element of the sequence. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. /// This function consumes the whole input sequence before returning the result. [] val foldBack<'T,'State> : folder:('T -> 'State -> 'State) -> source:seq<'T> -> state:'State -> 'State @@ -453,12 +465,14 @@ namespace Microsoft.FSharp.Collections /// threading an accumulator argument through the computation. The two sequences need not have equal lengths. /// If the input function is f and the elements are i0...iN and j0...jM, N < M /// then computes f i0 j0 (... (f iN jN s)...). + /// /// The function to update the state given the input elements. /// The first input sequence. /// The second input sequence. /// The initial state. + /// /// The final state value. - /// Thrown when the either of the input sequences is null. + /// Thrown when the either of the input sequences is null. [] val foldBack2<'T1,'T2,'State> : folder:('T1 -> 'T2 -> 'State -> 'State) -> source1:seq<'T1> -> source2:seq<'T2> -> state:'State -> 'State @@ -473,7 +487,7 @@ namespace Microsoft.FSharp.Collections /// /// True if every element of the sequence satisfies the predicate; false otherwise. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val forall: predicate:('T -> bool) -> source:seq<'T> -> bool @@ -487,7 +501,7 @@ namespace Microsoft.FSharp.Collections /// /// True if all pairs satisfy the predicate; false otherwise. /// - /// Thrown when either of the input sequences is null. + /// Thrown when either of the input sequences is null. [] val forall2: predicate:('T1 -> 'T2 -> bool) -> source1:seq<'T1> -> source2:seq<'T2> -> bool @@ -513,8 +527,8 @@ namespace Microsoft.FSharp.Collections /// /// The first element of the sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input does not have any elements. + /// Thrown when the input sequence is null. + /// Thrown when the input does not have any elements. [] val head: source:seq<'T> -> 'T @@ -524,15 +538,17 @@ namespace Microsoft.FSharp.Collections /// /// The first element of the sequence or None. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val tryHead: source:seq<'T> -> 'T option /// Returns the last element of the sequence. + /// /// The input sequence. + /// /// The last element of the sequence. - /// Thrown when the input sequence is null. - /// Thrown when the input does not have any elements. + /// Thrown when the input sequence is null. + /// Thrown when the input does not have any elements. [] val last: source:seq<'T> -> 'T @@ -543,7 +559,7 @@ namespace Microsoft.FSharp.Collections /// /// The last element of the sequence or None. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val tryLast: source:seq<'T> -> 'T option @@ -553,8 +569,8 @@ namespace Microsoft.FSharp.Collections /// /// The only element of the sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input does not have precisely one element. + /// Thrown when the input sequence is null. + /// Thrown when the input does not have precisely one element. [] val exactlyOne: source:seq<'T> -> 'T @@ -564,7 +580,7 @@ namespace Microsoft.FSharp.Collections /// /// The only element of the sequence or None. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val tryExactlyOne: source:seq<'T> -> 'T option @@ -574,15 +590,17 @@ namespace Microsoft.FSharp.Collections /// /// True if the sequence is empty; false otherwise. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val isEmpty: source:seq<'T> -> bool /// Builds a new collection whose elements are the corresponding elements of the input collection /// paired with the integer index (from 0) of each element. + /// /// The input sequence. + /// /// The result sequence. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val indexed: source:seq<'T> -> seq @@ -599,7 +617,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when count is negative. + /// Thrown when count is negative. [] val init: count:int -> initializer:(int -> 'T) -> seq<'T> @@ -620,11 +638,13 @@ namespace Microsoft.FSharp.Collections val initInfinite: initializer:(int -> 'T) -> seq<'T> /// Computes the element at the specified index in the collection. + /// /// The index of the element to retrieve. /// The input sequence. + /// /// The element at the specified index of the sequence. - /// Thrown when the input sequence is null. - /// Thrown when the index is negative or the input sequence does not contain enough elements. + /// Thrown when the input sequence is null. + /// Thrown when the index is negative or the input sequence does not contain enough elements. [] val item: index:int -> source:seq<'T> -> 'T @@ -633,7 +653,7 @@ namespace Microsoft.FSharp.Collections /// A function to apply to each element of the sequence. /// The input sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val iter: action:('T -> unit) -> source:seq<'T> -> unit @@ -643,7 +663,7 @@ namespace Microsoft.FSharp.Collections /// A function to apply to each element of the sequence that can also access the current index. /// The input sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val iteri: action:(int -> 'T -> unit) -> source:seq<'T> -> unit @@ -654,7 +674,7 @@ namespace Microsoft.FSharp.Collections /// The first input sequence. /// The second input sequence. /// - /// Thrown when either of the input sequences is null. + /// Thrown when either of the input sequences is null. [] val iter2: action:('T1 -> 'T2 -> unit) -> source1:seq<'T1> -> source2:seq<'T2> -> unit @@ -666,7 +686,7 @@ namespace Microsoft.FSharp.Collections /// The first input sequence. /// The second input sequence. /// - /// Thrown when either of the input sequences is null. + /// Thrown when either of the input sequences is null. [] val iteri2: action:(int -> 'T1 -> 'T2 -> unit) -> source1:seq<'T1> -> source2:seq<'T2> -> unit @@ -676,7 +696,7 @@ namespace Microsoft.FSharp.Collections /// /// The length of the sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val length: source:seq<'T> -> int @@ -693,7 +713,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U> @@ -707,7 +727,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when either of the input sequences is null. + /// Thrown when either of the input sequences is null. [] val map2: mapping:('T1 -> 'T2 -> 'U) -> source1:seq<'T1> -> source2:seq<'T2> -> seq<'U> @@ -718,7 +738,7 @@ namespace Microsoft.FSharp.Collections /// The function to transform elements from the input collection and accumulate the final value. /// The initial state. /// The input collection. - /// Thrown when the input collection is null. + /// Thrown when the input collection is null. /// The collection of transformed elements, and the final accumulated value. /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] @@ -731,7 +751,7 @@ namespace Microsoft.FSharp.Collections /// The function to transform elements from the input collection and accumulate the final value. /// The input collection. /// The initial state. - /// Thrown when the input collection is null. + /// Thrown when the input collection is null. /// The collection of transformed elements, and the final accumulated value. /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] @@ -748,7 +768,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when any of the input sequences is null. + /// Thrown when any of the input sequences is null. [] val map3: mapping:('T1 -> 'T2 -> 'T3 -> 'U) -> source1:seq<'T1> -> source2:seq<'T2> -> source3:seq<'T3> -> seq<'U> @@ -761,7 +781,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val mapi: mapping:(int -> 'T -> 'U) -> source:seq<'T> -> seq<'U> @@ -776,7 +796,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when either of the input sequences is null. + /// Thrown when either of the input sequences is null. [] val mapi2: mapping:(int -> 'T1 -> 'T2 -> 'U) -> source1:seq<'T1> -> source2:seq<'T2> -> seq<'U> @@ -784,8 +804,8 @@ namespace Microsoft.FSharp.Collections /// /// The input sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. /// /// The largest element of the sequence. [] @@ -798,8 +818,8 @@ namespace Microsoft.FSharp.Collections /// /// The largest element of the sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. [] val inline maxBy : projection:('T -> 'U) -> source:seq<'T> -> 'T when 'U : comparison @@ -811,8 +831,8 @@ namespace Microsoft.FSharp.Collections /// /// The largest element of the sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. [] val inline maxValBy : projection:('T -> 'U) -> source:seq<'T> -> 'U when 'U : comparison *) @@ -823,8 +843,8 @@ namespace Microsoft.FSharp.Collections /// /// The smallest element of the sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. [] val inline min : source:seq<'T> -> 'T when 'T : comparison @@ -835,8 +855,8 @@ namespace Microsoft.FSharp.Collections /// /// The smallest element of the sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. [] val inline minBy : projection:('T -> 'U) -> source:seq<'T> -> 'T when 'U : comparison @@ -848,8 +868,8 @@ namespace Microsoft.FSharp.Collections /// /// The smallest element of the sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. [] val inline minValBy : projection:('T -> 'U) -> source:seq<'T> -> 'U when 'U : comparison *) @@ -861,8 +881,8 @@ namespace Microsoft.FSharp.Collections /// /// The nth element of the sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the index is negative or the input sequence does not contain enough elements. + /// Thrown when the input sequence is null. + /// Thrown when the index is negative or the input sequence does not contain enough elements. [] [] val nth: index:int -> source:seq<'T> -> 'T @@ -875,7 +895,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. val ofArray: source:'T[] -> seq<'T> [] @@ -893,7 +913,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val pairwise: source:seq<'T> -> seq<'T * 'T> @@ -909,8 +929,8 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when indexMap does not produce a valid permutation. + /// Thrown when the input sequence is null. + /// Thrown when indexMap does not produce a valid permutation. /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val permute: indexMap:(int -> int) -> source:seq<'T> -> seq<'T> @@ -923,8 +943,8 @@ namespace Microsoft.FSharp.Collections /// /// The selected element. /// - /// Thrown when the input sequence is null. - /// Thrown when every item of the sequence + /// Thrown when the input sequence is null. + /// Thrown when every item of the sequence /// evaluates to None when the given function is applied. [] val pick: chooser:('T -> 'U option) -> source:seq<'T> -> 'U @@ -938,7 +958,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val readonly : source:seq<'T> -> seq<'T> @@ -953,14 +973,16 @@ namespace Microsoft.FSharp.Collections /// /// The final result of the reduction function. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. [] val reduce: reduction:('T -> 'T -> 'T) -> source:seq<'T> -> 'T /// Creates a sequence by replicating the given initial value. + /// /// The number of elements to replicate. /// The value to replicate + /// /// The generated sequence. [] val replicate: count:int -> initial:'T -> seq<'T> @@ -968,20 +990,24 @@ namespace Microsoft.FSharp.Collections /// Applies a function to each element of the sequence, starting from the end, threading an accumulator argument /// through the computation. If the input function is f and the elements are i0...iN /// then computes f i0 (...(f iN-1 iN)). + /// /// A function that takes in the next-to-last element of the sequence and the /// current accumulated result to produce the next accumulated result. /// The input sequence. + /// /// The final result of the reductions. - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. /// This function consumes the whole input sequence before returning the result. [] val reduceBack: reduction:('T -> 'T -> 'T) -> source:seq<'T> -> 'T /// Returns a new sequence with the elements in reverse order. + /// /// The input sequence. + /// /// The reversed sequence. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. /// This function consumes the whole input sequence before yielding the first element of the reversed sequence. [] val rev: source:seq<'T> -> seq<'T> @@ -994,7 +1020,7 @@ namespace Microsoft.FSharp.Collections /// /// The resulting sequence of computed states. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val scan<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> source:seq<'T> -> seq<'State> @@ -1005,8 +1031,9 @@ namespace Microsoft.FSharp.Collections /// A function that updates the state with each element from the sequence. /// The input sequence. /// The initial state. + /// /// The resulting sequence of computed states. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val scanBack<'T,'State> : folder:('T -> 'State -> 'State) -> source:seq<'T> -> state:'State -> seq<'State> @@ -1027,8 +1054,8 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when count exceeds the number of elements + /// Thrown when the input sequence is null. + /// Thrown when count exceeds the number of elements /// in the sequence. [] val skip: count:int -> source:seq<'T> -> seq<'T> @@ -1041,7 +1068,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val skipWhile: predicate:('T -> bool) -> source:seq<'T> -> seq<'T> @@ -1058,7 +1085,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val sort : source:seq<'T> -> seq<'T> when 'T : comparison @@ -1072,6 +1099,7 @@ namespace Microsoft.FSharp.Collections /// This is a stable sort, that is the original order of equal elements is preserved. /// The function to compare the collection elements. /// The input sequence. + /// /// The result sequence. /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] @@ -1092,7 +1120,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val sortBy : projection:('T -> 'Key) -> source:seq<'T> -> seq<'T> when 'Key : comparison @@ -1109,7 +1137,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val inline sortDescending : source:seq<'T> -> seq<'T> when 'T : comparison @@ -1128,7 +1156,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val inline sortByDescending : projection:('T -> 'Key) -> source:seq<'T> -> seq<'T> when 'Key : comparison @@ -1163,8 +1191,8 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. [] val tail: source:seq<'T> -> seq<'T> @@ -1178,9 +1206,9 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. - /// Thrown when count exceeds the number of elements + /// Thrown when the input sequence is null. + /// Thrown when the input sequence is empty. + /// Thrown when count exceeds the number of elements /// in the sequence. [] val take: count:int -> source:seq<'T> -> seq<'T> @@ -1193,7 +1221,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val takeWhile: predicate:('T -> bool) -> source:seq<'T> -> seq<'T> @@ -1203,7 +1231,7 @@ namespace Microsoft.FSharp.Collections /// /// The result array. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val toArray: source:seq<'T> -> 'T[] @@ -1213,7 +1241,7 @@ namespace Microsoft.FSharp.Collections /// /// The result list. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val toList: source:seq<'T> -> 'T list @@ -1225,7 +1253,7 @@ namespace Microsoft.FSharp.Collections /// /// The found element or None. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val tryFind: predicate:('T -> bool) -> source:seq<'T> -> 'T option @@ -1235,8 +1263,9 @@ namespace Microsoft.FSharp.Collections /// result this function should not be used with large or infinite sequences. /// A function that evaluates to a Boolean when given an item in the sequence. /// The input sequence. + /// /// The found element or None. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. /// This function consumes the whole input sequence before returning the result. [] val tryFindBack: predicate:('T -> bool) -> source:seq<'T> -> 'T option @@ -1249,16 +1278,18 @@ namespace Microsoft.FSharp.Collections /// /// The found index or None. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val tryFindIndex : predicate:('T -> bool) -> source:seq<'T> -> int option /// Tries to find the nth element in the sequence. /// Returns None if index is negative or the input sequence does not contain enough elements. + /// /// The index of element to retrieve. /// The input sequence. + /// /// The nth element of the sequence or None. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val tryItem: index:int -> source:seq<'T> -> 'T option @@ -1268,8 +1299,9 @@ namespace Microsoft.FSharp.Collections /// result this function should not be used with large or infinite sequences. /// A function that evaluates to a Boolean when given an item in the sequence. /// The input sequence. + /// /// The found index or None. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. /// This function consumes the whole input sequence before returning the result. [] val tryFindIndexBack : predicate:('T -> bool) -> source:seq<'T> -> int option @@ -1282,7 +1314,7 @@ namespace Microsoft.FSharp.Collections /// /// The chosen element or None. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val tryPick: chooser:('T -> 'U option) -> source:seq<'T> -> 'U option @@ -1291,8 +1323,9 @@ namespace Microsoft.FSharp.Collections /// that sequence is iterated. As a result this function should not be used with /// large or infinite sequences. /// The input sequence. + /// /// The transposed sequence. - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val transpose: source:seq<'Collection> -> seq> when 'Collection :> seq<'T> @@ -1303,7 +1336,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when the input sequence is null. + /// Thrown when the input sequence is null. [] val truncate: count:int -> source:seq<'T> -> seq<'T> @@ -1328,11 +1361,13 @@ namespace Microsoft.FSharp.Collections /// Returns a sequence that yields sliding windows containing elements drawn from the input /// sequence. Each window is returned as a fresh array. + /// /// The number of elements in each window. /// The input sequence. + /// /// The result sequence. - /// Thrown when the input sequence is null. - /// Thrown when windowSize is not positive. + /// Thrown when the input sequence is null. + /// Thrown when windowSize is not positive. [] val windowed: windowSize:int -> source:seq<'T> -> seq<'T[]> @@ -1345,7 +1380,7 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when either of the input sequences is null. + /// Thrown when either of the input sequences is null. [] val zip: source1:seq<'T1> -> source2:seq<'T2> -> seq<'T1 * 'T2> @@ -1359,6 +1394,6 @@ namespace Microsoft.FSharp.Collections /// /// The result sequence. /// - /// Thrown when any of the input sequences is null. + /// Thrown when any of the input sequences is null. [] val zip3: source1:seq<'T1> -> source2:seq<'T2> -> source3:seq<'T3> -> seq<'T1 * 'T2 * 'T3> diff --git a/src/fsharp/FSharp.Core/set.fsi b/src/fsharp/FSharp.Core/set.fsi index 9293a523312f..267fefec0563 100644 --- a/src/fsharp/FSharp.Core/set.fsi +++ b/src/fsharp/FSharp.Core/set.fsi @@ -20,20 +20,25 @@ namespace Microsoft.FSharp.Collections /// Create a set containing elements drawn from the given sequence. /// The input sequence. + /// /// The result set. new : elements:seq<'T> -> Set<'T> /// A useful shortcut for Set.add. Note this operation produces a new set /// and does not mutate the original set. The new set will share many storage /// nodes with the original. See the Set module for further operations on sets. + /// /// The value to add to the set. + /// /// The result set. member Add : value:'T -> Set<'T> /// A useful shortcut for Set.remove. Note this operation produces a new set /// and does not mutate the original set. The new set will share many storage /// nodes with the original. See the Set module for further operations on sets. + /// /// The value to remove from the set. + /// /// The result set. member Remove : value:'T -> Set<'T> @@ -41,7 +46,9 @@ namespace Microsoft.FSharp.Collections member Count : int /// A useful shortcut for Set.contains. See the Set module for further operations on sets. + /// /// The value to check. + /// /// True if the set contains value. member Contains : value:'T -> bool @@ -49,37 +56,49 @@ namespace Microsoft.FSharp.Collections member IsEmpty : bool /// Returns a new set with the elements of the second set removed from the first. + /// /// The first input set. /// The second input set. + /// /// A set containing elements of the first set that are not contained in the second set. static member (-) : set1:Set<'T> * set2:Set<'T> -> Set<'T> /// Compute the union of the two sets. + /// /// The first input set. /// The second input set. + /// /// The union of the two input sets. static member (+) : set1:Set<'T> * set2:Set<'T> -> Set<'T> /// Evaluates to "true" if all elements of the first set are in the second. + /// /// The set to test against. + /// /// True if this set is a subset of otherSet. member IsSubsetOf: otherSet:Set<'T> -> bool /// Evaluates to "true" if all elements of the first set are in the second, and at least /// one element of the second is not in the first. + /// /// The set to test against. + /// /// True if this set is a proper subset of otherSet. member IsProperSubsetOf: otherSet:Set<'T> -> bool /// Evaluates to "true" if all elements of the second set are in the first. + /// /// The set to test against. + /// /// True if this set is a superset of otherSet. member IsSupersetOf: otherSet:Set<'T> -> bool /// Evaluates to "true" if all elements of the second set are in the first, and at least /// one element of the first is not in the second. + /// /// The set to test against. + /// /// True if this set is a proper superset of otherSet. member IsProperSupersetOf: otherSet:Set<'T> -> bool @@ -108,7 +127,7 @@ namespace Microsoft.FSharp.Collections [] [] - /// Functional programming operators related to the Set<_> type. + /// Basic operations on values of type . module Set = /// The empty set for the type 'T. @@ -117,59 +136,75 @@ namespace Microsoft.FSharp.Collections val empty<'T> : Set<'T> when 'T : comparison /// The set containing the given element. + /// /// The value for the set to contain. + /// /// The set containing value. [] val singleton: value:'T -> Set<'T> /// Returns a new set with an element added to the set. No exception is raised if /// the set already contains the given element. + /// /// The value to add. /// The input set. + /// /// A new set containing value. [] val add: value:'T -> set:Set<'T> -> Set<'T> /// Evaluates to "true" if the given element is in the given set. + /// /// The element to test. /// The input set. + /// /// True if element is in set. [] val contains: element:'T -> set:Set<'T> -> bool /// Evaluates to "true" if all elements of the first set are in the second + /// /// The potential subset. /// The set to test against. + /// /// True if set1 is a subset of set2. [] val isSubset: set1: Set<'T> -> set2:Set<'T> -> bool /// Evaluates to "true" if all elements of the first set are in the second, and at least /// one element of the second is not in the first. + /// /// The potential subset. /// The set to test against. + /// /// True if set1 is a proper subset of set2. [] val isProperSubset: set1: Set<'T> -> set2:Set<'T> -> bool /// Evaluates to "true" if all elements of the second set are in the first. + /// /// The potential superset. /// The set to test against. + /// /// True if set1 is a superset of set2. [] val isSuperset: set1: Set<'T> -> set2:Set<'T> -> bool /// Evaluates to "true" if all elements of the second set are in the first, and at least /// one element of the first is not in the second. + /// /// The potential superset. /// The set to test against. + /// /// True if set1 is a proper superset of set2. [] val isProperSuperset: set1: Set<'T> -> set2:Set<'T> -> bool /// Returns the number of elements in the set. Same as size. + /// /// The input set. + /// /// The number of elements in the set. [] val count: set:Set<'T> -> int @@ -177,40 +212,50 @@ namespace Microsoft.FSharp.Collections /// Tests if any element of the collection satisfies the given predicate. /// If the input function is predicate and the elements are i0...iN /// then computes p i0 or ... or p iN. + /// /// The function to test set elements. /// The input set. + /// /// True if any element of set satisfies predicate. [] val exists: predicate:('T -> bool) -> set:Set<'T> -> bool /// Returns a new collection containing only the elements of the collection /// for which the given predicate returns True. + /// /// The function to test set elements. /// The input set. + /// /// The set containing only the elements for which predicate returns true. [] val filter: predicate:('T -> bool) -> set:Set<'T> -> Set<'T> /// Returns a new collection containing the results of applying the /// given function to each element of the input set. + /// /// The function to transform elements of the input set. /// The input set. + /// /// A set containing the transformed elements. [] val map: mapping:('T -> 'U) -> set:Set<'T> -> Set<'U> /// Applies the given accumulating function to all the elements of the set + /// /// The accumulating function. /// The initial state. /// The input set. + /// /// The final state. [] val fold<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> set:Set<'T> -> 'State when 'T : comparison /// Applies the given accumulating function to all the elements of the set. + /// /// The accumulating function. /// The input set. /// The initial state. + /// /// The final state. [] val foldBack<'T,'State> : folder:('T -> 'State -> 'State) -> set:Set<'T> -> state:'State -> 'State when 'T : comparison @@ -218,46 +263,59 @@ namespace Microsoft.FSharp.Collections /// Tests if all elements of the collection satisfy the given predicate. /// If the input function is f and the elements are i0...iN and "j0...jN" /// then computes p i0 && ... && p iN. + /// /// The function to test set elements. /// The input set. + /// /// True if all elements of set satisfy predicate. [] val forall: predicate:('T -> bool) -> set:Set<'T> -> bool /// Computes the intersection of the two sets. + /// /// The first input set. /// The second input set. + /// /// The intersection of set1 and set2. [] val intersect: set1:Set<'T> -> set2:Set<'T> -> Set<'T> /// Computes the intersection of a sequence of sets. The sequence must be non-empty. + /// /// The sequence of sets to intersect. + /// /// The intersection of the input sets. [] val intersectMany: sets:seq> -> Set<'T> /// Computes the union of the two sets. + /// /// The first input set. /// The second input set. + /// /// The union of set1 and set2. [] val union: set1:Set<'T> -> set2:Set<'T> -> Set<'T> /// Computes the union of a sequence of sets. + /// /// The sequence of sets to union. + /// /// The union of the input sets. [] val unionMany: sets:seq> -> Set<'T> /// Returns "true" if the set is empty. + /// /// The input set. + /// /// True if set is empty. [] val isEmpty: set:Set<'T> -> bool /// Applies the given function to each element of the set, in order according /// to the comparison function. + /// /// The function to apply to each element. /// The input set. [] @@ -265,8 +323,10 @@ namespace Microsoft.FSharp.Collections /// Splits the set into two sets containing the elements for which the given predicate /// returns true and false respectively. + /// /// The function to test set elements. /// The input set. + /// /// A pair of sets with the first containing the elements for which predicate returns /// true and the second containing the elements for which predicate returns false. [] @@ -274,63 +334,83 @@ namespace Microsoft.FSharp.Collections /// Returns a new set with the given element removed. No exception is raised if /// the set doesn't contain the given element. + /// /// The element to remove. /// The input set. + /// /// The input set with value removed. [] val remove: value: 'T -> set:Set<'T> -> Set<'T> /// Returns the lowest element in the set according to the ordering being used for the set. + /// /// The input set. + /// /// The min value from the set. [] val minElement: set:Set<'T> -> 'T /// Returns the highest element in the set according to the ordering being used for the set. + /// /// The input set. + /// /// The max value from the set. [] val maxElement: set:Set<'T> -> 'T /// Builds a set that contains the same elements as the given list. + /// /// The input list. + /// /// A set containing the elements form the input list. [] val ofList: elements:'T list -> Set<'T> /// Builds a list that contains the elements of the set in order. + /// /// The input set. + /// /// An ordered list of the elements of set. [] val toList: set:Set<'T> -> 'T list /// Builds a set that contains the same elements as the given array. + /// /// The input array. + /// /// A set containing the elements of array. [] val ofArray: array:'T[] -> Set<'T> /// Builds an array that contains the elements of the set in order. + /// /// The input set. + /// /// An ordered array of the elements of set. [] val toArray: set:Set<'T> -> 'T[] /// Returns an ordered view of the collection as an enumerable object. + /// /// The input set. + /// /// An ordered sequence of the elements of set. [] val toSeq: set:Set<'T> -> seq<'T> /// Builds a new collection from the given enumerable object. + /// /// The input sequence. + /// /// The set containing elements. [] val ofSeq: elements:seq<'T> -> Set<'T> /// Returns a new set with the elements of the second set removed from the first. + /// /// The first input set. /// The set whose elements will be removed from set1. + /// /// The set with the elements of set2 removed from set1. [] val difference: set1:Set<'T> -> set2:Set<'T> -> Set<'T> diff --git a/src/fsharp/FSharp.Core/string.fsi b/src/fsharp/FSharp.Core/string.fsi index 59217506a6b7..78c519aa1d54 100644 --- a/src/fsharp/FSharp.Core/string.fsi +++ b/src/fsharp/FSharp.Core/string.fsi @@ -20,13 +20,15 @@ namespace Microsoft.FSharp.Core /// The separator string to be inserted between the strings /// of the input sequence. /// The sequence of strings to be concatenated. + /// /// A new string consisting of the concatenated strings separated by /// the separation string. - /// Thrown when strings is null. + /// Thrown when strings is null. [] val concat: sep:string -> strings: seq -> string /// Applies the function action to each character in the string. + /// /// The function to be applied to each character of the string. /// The input string. [] @@ -34,6 +36,7 @@ namespace Microsoft.FSharp.Core /// Applies the function action to the index of each character in the string and the /// character itself. + /// /// The function to apply to each character and index of the string. /// The input string. [] @@ -41,16 +44,20 @@ namespace Microsoft.FSharp.Core /// Builds a new string whose characters are the results of applying the function mapping /// to each of the characters of the input string. + /// /// The function to apply to the characters of the string. /// The input string. + /// /// The resulting string. [] val map: mapping:(char -> char) -> str:string -> string /// Builds a new string whose characters are the results of applying the function mapping /// to each character and index of the input string. + /// /// The function to apply to each character and index of the string. /// The input string. + /// /// The resulting string. [] val mapi: mapping:(int -> char -> char) -> str:string -> string @@ -58,8 +65,10 @@ namespace Microsoft.FSharp.Core /// Builds a new string whose characters are the results of applying the function mapping /// to each of the characters of the input string and concatenating the resulting /// strings. + /// /// The function to produce a string from each character of the input string. /// The input string. + /// /// The concatenated string. [] val collect: mapping:(char -> string) -> str:string -> string @@ -71,6 +80,7 @@ namespace Microsoft.FSharp.Core /// /// A function to test whether each character in the input sequence should be included in the output string. /// The input string. + /// /// The resulting string. [] val filter: predicate:(char -> bool) -> str:string -> string @@ -78,38 +88,48 @@ namespace Microsoft.FSharp.Core /// Builds a new string whose characters are the results of applying the function mapping /// to each index from 0 to count-1 and concatenating the resulting /// strings. + /// /// The number of strings to initialize. /// The function to take an index and produce a string to /// be concatenated with the others. + /// /// The constructed string. - /// Thrown when count is negative. + /// Thrown when count is negative. [] val init: count:int -> initializer:(int -> string) -> string /// Tests if all characters in the string satisfy the given predicate. + /// /// The function to test each character of the string. /// The input string. + /// /// True if all characters return true for the predicate and false otherwise. [] val forall: predicate:(char -> bool) -> str:string -> bool /// Tests if any character of the string satisfies the given predicate. + /// /// The function to test each character of the string. /// The input string. + /// /// True if any character returns true for the predicate and false otherwise. [] val exists: predicate:(char -> bool) -> str:string -> bool /// Returns a string by concatenating count instances of str. + /// /// The number of copies of the input string will be copied. /// The input string. + /// /// The concatenated string. - /// Thrown when count is negative. + /// Thrown when count is negative. [] val replicate: count:int -> str: string -> string /// Returns the length of the string. + /// /// The input string. + /// /// The number of characters in the string. [] val length: str:string -> int diff --git a/src/fsharp/fsiaux.fsi b/src/fsharp/fsiaux.fsi index d557c17331ba..a225e48e7aab 100644 --- a/src/fsharp/fsiaux.fsi +++ b/src/fsharp/fsiaux.fsi @@ -7,10 +7,12 @@ namespace FSharp.Compiler.Interactive type IEventLoop = /// Run the event loop. + /// /// True if the event loop was restarted; false otherwise. abstract Run : unit -> bool /// Request that the given operation be run synchronously on the event loop. + /// /// The result of the operation. abstract Invoke : (unit -> 'T) -> 'T diff --git a/src/fsharp/lib.fs b/src/fsharp/lib.fs index 5d8649d561f7..8d89ac8fb377 100755 --- a/src/fsharp/lib.fs +++ b/src/fsharp/lib.fs @@ -96,29 +96,29 @@ module NameMap = //------------------------------------------------------------------------- module Check = - /// Throw System.InvalidOperationException() if argument is None. + /// Throw System.InvalidOperationException if argument is None. /// If there is a value (e.g. Some(value)) then value is returned. let NotNone argName (arg:'T option) : 'T = match arg with | None -> raise (new System.InvalidOperationException(argName)) | Some x -> x - /// Throw System.ArgumentNullException() if argument is null. + /// Throw System.ArgumentNullException if argument is null. let ArgumentNotNull arg argName = match box(arg) with | null -> raise (new System.ArgumentNullException(argName)) | _ -> () - /// Throw System.ArgumentNullException() if array argument is null. - /// Throw System.ArgumentOutOfRangeException() is array argument is empty. + /// Throw System.ArgumentNullException if array argument is null. + /// Throw System.ArgumentOutOfRangeException is array argument is empty. let ArrayArgumentNotNullOrEmpty (arr:'T[]) argName = ArgumentNotNull arr argName if (0 = arr.Length) then raise (new System.ArgumentOutOfRangeException(argName)) - /// Throw System.ArgumentNullException() if string argument is null. - /// Throw System.ArgumentOutOfRangeException() is string argument is empty. + /// Throw System.ArgumentNullException if string argument is null. + /// Throw System.ArgumentOutOfRangeException is string argument is empty. let StringArgumentNotNullOrEmpty (s:string) argName = ArgumentNotNull s argName if s.Length = 0 then diff --git a/src/fsharp/service/FSharpCheckerResults.fsi b/src/fsharp/service/FSharpCheckerResults.fsi index 67f4900b4a5a..9705c1da0bf6 100644 --- a/src/fsharp/service/FSharpCheckerResults.fsi +++ b/src/fsharp/service/FSharpCheckerResults.fsi @@ -236,10 +236,12 @@ type public FSharpCheckFileResults = member GetDisplayContextForPos : pos : pos -> 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 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 diff --git a/src/fsharp/service/service.fsi b/src/fsharp/service/service.fsi index cb414c87ab1a..3ed57fa2f277 100755 --- a/src/fsharp/service/service.fsi +++ b/src/fsharp/service/service.fsi @@ -314,6 +314,7 @@ type public FSharpChecker = /// /// TypeCheck and compile provided AST /// + /// /// An optional string used for tracing compiler operations associated with this request. member Compile: ast:ParsedInput list * assemblyName:string * outFile:string * dependencies:string list * ?pdbFile:string * ?executable:bool * ?noframework:bool * ?userOpName: string -> Async @@ -329,12 +330,14 @@ type public FSharpChecker = /// the given TextWriters are used for the stdout and stderr streams respectively. In this /// case, a global setting is modified during the execution. /// + /// /// An optional string used for tracing compiler operations associated with this request. member CompileToDynamicAssembly: otherFlags:string [] * execute:(TextWriter * TextWriter) option * ?userOpName: string -> Async /// /// TypeCheck and compile provided AST /// + /// /// An optional string used for tracing compiler operations associated with this request. member CompileToDynamicAssembly: ast:ParsedInput list * assemblyName:string * dependencies:string list * execute:(TextWriter * TextWriter) option * ?debug:bool * ?noframework:bool * ?userOpName: string -> Async @@ -344,6 +347,7 @@ type public FSharpChecker = /// If the source of the file has changed the results returned by this function may be out of date, though may /// still be usable for generating intellisense menus and information. /// + /// /// The filename for the file. /// The options for the project or script, used to determine active --define conditionals and other options relevant to parsing. /// Optionally, specify source that must match the previous parse precisely. @@ -392,6 +396,7 @@ type public FSharpChecker = /// /// This function is called when a project has been cleaned/rebuilt, and thus any live type providers should be refreshed. /// + /// /// An optional string used for tracing compiler operations associated with this request. member NotifyProjectCleaned: options: FSharpProjectOptions * ?userOpName: string -> Async diff --git a/vsintegration/src/FSharp.ProjectSystem.Base/Project/ProjectNode.cs b/vsintegration/src/FSharp.ProjectSystem.Base/Project/ProjectNode.cs index 37f6af8e8e2f..9f6361691faf 100644 --- a/vsintegration/src/FSharp.ProjectSystem.Base/Project/ProjectNode.cs +++ b/vsintegration/src/FSharp.ProjectSystem.Base/Project/ProjectNode.cs @@ -2315,7 +2315,7 @@ public virtual void SetOrCreateBuildEventProperty(string propertyName, string pr } /// Support hex format (like 0xFF) - /// + /// /// Raise if invalid format /// The inner exception contains the real exception, of type FormatException, StackOverflowException /// From 0a88a668ef4cca711e703866d9b07470fe01eaec Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 30 Jul 2020 22:26:38 +0200 Subject: [PATCH 4/9] Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages --- .../ConstraintSolver/MemberConstraints.fs | 2 +- .../ConstraintSolver/PrimitiveConstraints.fs | 2 +- .../AccessOfTypeAbbreviationTests.fs | 63 ++-- .../ErrorMessages/AssignmentErrorTests.fs | 19 +- .../ErrorMessages/ClassesTests.fs | 110 ++++--- .../ErrorMessages/ConfusingTypeName.fs | 5 +- .../ErrorMessages/ConstructorTests.fs | 94 +++--- .../ErrorMessages/DontSuggestTests.fs | 44 ++- .../ElseBranchHasWrongTypeTests.fs | 136 ++++----- .../InvalidNumericLiteralTests.fs | 61 ++-- .../ErrorMessages/MissingElseBranch.fs | 46 ++- .../ErrorMessages/MissingExpressionTests.fs | 20 +- .../ErrorMessages/ModuleAbbreviationTests.fs | 18 +- .../ErrorMessages/NameResolutionTests.fs | 31 +- .../ErrorMessages/SuggestionsTests.fs | 283 ++++++++---------- .../ErrorMessages/TypeMismatchTests.fs | 115 ++++--- .../ErrorMessages/UnitGenericAbstactType.fs | 23 +- .../ErrorMessages/UpcastDowncastTests.fs | 46 ++- .../ErrorMessages/WarnExpressionTests.fs | 168 +++++------ .../ErrorMessages/WrongSyntaxInForLoop.fs | 15 +- .../Interop/SimpleInteropTests.fs | 3 +- .../Language/CodeQuotationTests.fs | 2 +- .../Language/CompilerDirectiveTests.fs | 4 +- tests/FSharp.Test.Utilities/Compiler.fs | 33 +- tests/FSharp.Test.Utilities/CompilerAssert.fs | 7 +- 25 files changed, 630 insertions(+), 720 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs index f14c2495c37d..77ae35463fc4 100644 --- a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/MemberConstraints.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ConstraintSolver.ComponentTests +namespace FSharp.Compiler.ComponentTests.ConstraintSolver open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs index 873864edaffc..a22d61db60cb 100644 --- a/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs +++ b/tests/FSharp.Compiler.ComponentTests/ConstraintSolver/PrimitiveConstraints.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ConstraintSolver.ComponentTests +namespace FSharp.Compiler.ComponentTests.ConstraintSolver open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs index 416c62d63f63..df9acf7efca6 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AccessOfTypeAbbreviationTests.fs @@ -1,75 +1,74 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities +open FSharp.Test.Utilities.Compiler open FSharp.Compiler.SourceCodeServices module ``Access Of Type Abbreviation`` = + let warning44Message = "This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors." + [] let ``Private type produces warning when trying to export``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type private Hidden = Hidden of unit type Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 8, 4, 16) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 8, Line 4, Col 16, warning44Message) [] let ``Internal type passes when abbrev is internal``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type internal Hidden = Hidden of unit type internal Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed [] let ``Internal type produces warning when trying to export``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type internal Hidden = Hidden of unit type Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 8, 4, 16) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 8, Line 4, Col 16, warning44Message) [] let ``Private type produces warning when abbrev is internal``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Library = type private Hidden = Hidden of unit type internal Exported = Hidden - """ - FSharpErrorSeverity.Warning - 44 - (4, 17, 4, 25) - ("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in." + System.Environment.NewLine + "As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 44, Line 4, Col 17, Line 4, Col 25, warning44Message) [] let ``Private type passes when abbrev is private``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type private Hidden = Hidden of unit type private Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed [] let ``Default access type passes when abbrev is default``() = - CompilerAssert.Pass - """ + FSharp """ module Library = type Hidden = Hidden of unit type Exported = Hidden - """ + """ + |> typecheck + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs index f2f598d9dba7..dd986cf50097 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/AssignmentErrorTests.fs @@ -1,22 +1,19 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices - +open FSharp.Test.Utilities.Compiler module ``Errors assigning to mutable objects`` = [] let ``Assign to immutable error``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 x <- 20 - """ - FSharpErrorSeverity.Error - 27 - (3, 1, 3, 8) - "This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 27, Line 3, Col 1, Line 3, Col 8, + "This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs index a51e92ed944b..e1941a3d7eb2 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Classes`` = [] let ``Tuple In Abstract Method``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IInterface = abstract Function : (int32 * int32) -> unit @@ -19,47 +17,44 @@ let x = { new IInterface with member this.Function (i, j) = () } - """ - [| - FSharpErrorSeverity.Error, 768, (7, 16, 7, 36), "The member 'Function' does not accept the correct number of arguments. 1 argument(s) are expected, but 2 were given. The required signature is 'member IInterface.Function : (int32 * int32) -> unit'.\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface." - FSharpErrorSeverity.Error, 17, (7, 21, 7, 29), "The member 'Function : 'a * 'b -> unit' does not have the correct type to override the corresponding abstract method. The required signature is 'Function : (int32 * int32) -> unit'." - FSharpErrorSeverity.Error, 783, (6, 9, 6, 19), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 768, Line 7, Col 16, Line 7, Col 36, "The member 'Function' does not accept the correct number of arguments. 1 argument(s) are expected, but 2 were given. The required signature is 'member IInterface.Function : (int32 * int32) -> unit'.\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface.") + (Error 17, Line 7, Col 21, Line 7, Col 29, "The member 'Function : 'a * 'b -> unit' does not have the correct type to override the corresponding abstract method. The required signature is 'Function : (int32 * int32) -> unit'.") + (Error 783, Line 6, Col 9, Line 6, Col 19, "At least one override did not correctly implement its corresponding abstract member")] [] let ``Wrong Arity``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyType() = static member MyMember(arg1, arg2:int ) = () static member MyMember(arg1, arg2:byte) = () MyType.MyMember("", 0, 0) - """ - FSharpErrorSeverity.Error - 503 - (7, 1, 7, 26) - "A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 503, Line 7, Col 1, Line 7, Col 26, + "A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments.") [] let ``Method Is Not Static``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Class1() = member this.X() = "F#" let x = Class1.X() - """ - FSharpErrorSeverity.Error - 3214 - (5, 9, 5, 17) - "Method or object constructor 'X' is not static" + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 3214, Line 5, Col 9, Line 5, Col 17, "Method or object constructor 'X' is not static") [] let ``Matching Method With Same Name Is Not Abstract``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Foo(x : int) = member v.MyX() = x @@ -67,17 +62,17 @@ let foo = { new Foo(3) with member v.MyX() = 4 } - """ - [| - FSharpErrorSeverity.Error, 767, (8, 16, 8, 23), "The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement." - FSharpErrorSeverity.Error, 17, (8, 18, 8, 21), "The member 'MyX : unit -> int' does not have the correct type to override any given virtual method" - FSharpErrorSeverity.Error, 783, (6, 11, 6, 14), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 767, Line 8, Col 16, Line 8, Col 23, "The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement.") + (Error 17, Line 8, Col 18, Line 8, Col 21, "The member 'MyX : unit -> int' does not have the correct type to override any given virtual method") + (Error 783, Line 6, Col 11, Line 6, Col 14, "At least one override did not correctly implement its corresponding abstract member")] [] let ``No Matching Abstract Method With Same Name``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IInterface = abstract MyFunction : int32 * int32 -> unit abstract SomeOtherFunction : int32 * int32 -> unit @@ -86,18 +81,18 @@ let x = { new IInterface with member this.Function (i, j) = () } - """ - [| - FSharpErrorSeverity.Error, 767, (8, 14, 8, 34), "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:" + System.Environment.NewLine + " MyFunction" - FSharpErrorSeverity.Error, 17, (8, 19, 8, 27), "The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method" - FSharpErrorSeverity.Error, 366, (7, 3, 9, 4), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." - FSharpErrorSeverity.Error, 783, (7, 9, 7, 19), "At least one override did not correctly implement its corresponding abstract member" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 767, Line 8, Col 14, Line 8, Col 34, "The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:" + System.Environment.NewLine + " MyFunction") + (Error 17, Line 8, Col 19, Line 8, Col 27, "The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method") + (Error 366, Line 7, Col 3, Line 9, Col 4, "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.") + (Error 783, Line 7, Col 9, Line 7, Col 19, "At least one override did not correctly implement its corresponding abstract member")] [] let ``Member Has Multiple Possible Dispatch Slots``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type IOverload = abstract member Bar : int -> int abstract member Bar : double -> int @@ -105,23 +100,24 @@ type IOverload = type Overload = interface IOverload with override __.Bar _ = 1 - """ - [| - FSharpErrorSeverity.Error, 366, (7, 15, 7, 24), "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IOverload.Bar : double -> int'" + System.Environment.NewLine + "\t'abstract member IOverload.Bar : int -> int'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'." - FSharpErrorSeverity.Error, 3213, (8, 21, 8, 24), "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:" + System.Environment.NewLine + " Bar : double -> int" + System.Environment.NewLine + " Bar : int -> int." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 366, Line 7, Col 15, Line 7, Col 24, "No implementation was given for those members: " + System.Environment.NewLine + "\t'abstract member IOverload.Bar : double -> int'" + System.Environment.NewLine + "\t'abstract member IOverload.Bar : int -> int'" + System.Environment.NewLine + "Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.") + (Error 3213, Line 8, Col 21, Line 8, Col 24, "The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:" + System.Environment.NewLine + " Bar : double -> int" + System.Environment.NewLine + " Bar : int -> int.")] [] let ``Do Cannot Have Visibility Declarations``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ type X() = do () private do () static member Y() = 1 - """ - [| - FSharpErrorSeverity.Error, 531, (4, 5, 4, 12), "Accessibility modifiers should come immediately prior to the identifier naming a construct" - FSharpErrorSeverity.Error, 512, (4, 13, 4, 18), "Accessibility modifiers are not permitted on 'do' bindings, but 'Private' was given." - FSharpErrorSeverity.Error, 222, (2, 1, 3, 1), "Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration." - |] + """ + |> parse + |> shouldFail + |> withDiagnostics [ + (Error 531, Line 4, Col 5, Line 4, Col 12, "Accessibility modifiers should come immediately prior to the identifier naming a construct") + (Error 512, Line 4, Col 13, Line 4, Col 18, "Accessibility modifiers are not permitted on 'do' bindings, but 'Private' was given.") + (Error 222, Line 2, Col 1, Line 3, Col 1, "Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs index 3c7e569007d0..9e3e75b606b5 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConfusingTypeName.fs @@ -1,12 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler -open FSharp.Test.Utilities.Utilities -open FSharp.Compiler.SourceCodeServices module ``Confusing Type Name`` = diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs index c9636e711a52..1806defe4e45 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ConstructorTests.fs @@ -1,42 +1,40 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Constructor`` = [] let ``Invalid Record``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Record = {field1:int; field2:int} let doSomething (xs) = List.map (fun {field1=x} -> x) xs doSomething {Record.field1=0; field2=0} - """ - [| - FSharpErrorSeverity.Error, 1, (4, 13, 4, 40), "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' " - FSharpErrorSeverity.Warning, 20, (4, 1, 4, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 4, Col 1, Line 4, Col 40, "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 4, Col 13, Line 4, Col 40, "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' ")] [] let ``Comma In Rec Ctor``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Person = { Name : string; Age : int; City : string } let x = { Name = "Isaac", Age = 21, City = "London" } - """ - [| - FSharpErrorSeverity.Error, 1, (3, 18, 3, 52), "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' " + System.Environment.NewLine + "A ';' is used to separate field values in records. Consider replacing ',' with ';'." - FSharpErrorSeverity.Error, 764, (3, 9, 3, 54), "No assignment given for field 'Age' of type 'Test.Person'" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 3, Col 18, Line 3, Col 52, "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' " + System.Environment.NewLine + "A ';' is used to separate field values in records. Consider replacing ',' with ';'.") + (Error 764, Line 3, Col 9, Line 3, Col 54, "No assignment given for field 'Age' of type 'Test.Person'")] [] let ``Missing Comma In Ctor``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set @@ -44,18 +42,18 @@ type Person() = let p = Person(Name = "Fred" Age = 18) - """ - [| - FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan" - FSharpErrorSeverity.Warning, 20, (7, 12, 7, 25), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." - FSharpErrorSeverity.Error, 39, (8, 12, 8, 15), "The value or constructor 'Age' is not defined." - FSharpErrorSeverity.Error, 501, (7, 5, 8, 21), "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',')." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 7, Col 12, Line 7, Col 25, "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") + (Error 39, Line 7, Col 12, Line 7, Col 16, "The value or constructor 'Name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " nan") + (Error 39, Line 8, Col 12, Line 8, Col 15, "The value or constructor 'Age' is not defined.") + (Error 501, Line 7, Col 5, Line 8, Col 21, "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',').")] [] let ``Missing Ctor Value``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person(x:int) = member val Name = "" with get,set member val Age = x with get,set @@ -63,32 +61,29 @@ type Person(x:int) = let p = Person(Name = "Fred", Age = 18) - """ - FSharpErrorSeverity.Error - 496 - (7, 5, 8, 21) - "The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 496, Line 7, Col 5, Line 8, Col 21, "The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'.") [] let ``Extra Argument In Ctor``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set let p = Person(1) - """ - FSharpErrorSeverity.Error - 501 - (7, 5, 7, 14) - "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 501, Line 7, Col 5, Line 7, Col 14, + "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'.") [] let ``Extra Argument In Ctor2``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person() = member val Name = "" with get,set member val Age = 0 with get,set @@ -97,18 +92,17 @@ let b = 1 let p = Person(1=b) - """ - FSharpErrorSeverity.Error - 501 - (9, 5, 9, 16) - "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 501, Line 9, Col 5, Line 9, Col 16, + "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'.") [] let ``Valid Comma In Rec Ctor``() = - CompilerAssert.Pass - """ + FSharp """ type Person = { Name : string * bool * bool } let Age = 22 let City = "London" let x = { Name = "Isaac", Age = 21, City = "London" } - """ + """ |> typecheck |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs index 13a6f6b0dcc4..d1511da554ca 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/DontSuggestTests.fs @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Don't Suggest`` = [] let ``Dont Suggest Completely Wrong Stuff``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let _ = Path.GetFullPath "images" - """ - FSharpErrorSeverity.Error - 39 - (2, 9, 2, 13) - ("The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 9, Line 2, Col 13, + "The value, namespace, type or module 'Path' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Math") [] let ``Dont Suggest When Things Are Open``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ module N = let name = "hallo" @@ -30,19 +27,18 @@ type T = static member myMember = 1 let x = N. - """ - [| - FSharpErrorSeverity.Error, 599, (8, 10, 8, 11), "Missing qualification after '.'" - FSharpErrorSeverity.Error, 222, (2, 1, 3, 1), "Files in libraries or multiple-file applications must begin with a namespace or module declaration. When using a module declaration at the start of a file the '=' sign is not allowed. If this is a top-level module, consider removing the = to resolve this error." - |] + """ + |> parse + |> shouldFail + |> withDiagnostics [ + (Error 599, Line 8, Col 10, Line 8, Col 11, "Missing qualification after '.'") + (Error 222, Line 2, Col 1, Line 3, Col 1, "Files in libraries or multiple-file applications must begin with a namespace or module declaration. When using a module declaration at the start of a file the '=' sign is not allowed. If this is a top-level module, consider removing the = to resolve this error.")] [] let ``Dont Suggest Intentionally Unused Variables``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let hober xy _xyz = xyz - """ - FSharpErrorSeverity.Error - 39 - (2, 21, 2, 24) - "The value or constructor 'xyz' is not defined." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 21, Line 2, Col 24, "The value or constructor 'xyz' is not defined.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs index 54d5c41a68c7..8c412854488c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ElseBranchHasWrongTypeTests.fs @@ -1,48 +1,43 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices - +open FSharp.Test.Utilities.Compiler module ``Else branch has wrong type`` = [] let ``Else branch is int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let y = if test > 10 then "test" else 123 - """ - FSharpErrorSeverity.Error - 1 - (5, 10, 5, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 10, Line 5, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a function that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x = test let y = if test > 10 then "test" else f 10 - """ - FSharpErrorSeverity.Error - 1 - (6, 10, 6, 14) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 6, Col 10, Line 6, Col 14, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a sequence of expressions that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let f x = x + 4 let y = @@ -51,17 +46,16 @@ let y = else "" |> ignore (f 5) - """ - FSharpErrorSeverity.Error - 1 - (9, 10, 9, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 9, Col 10, Line 9, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch is a longer sequence of expressions that returns int while if branch is string``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let f x = x + 4 let y = @@ -72,33 +66,31 @@ let y = let z = f 4 let a = 3 * z (f a) - """ - FSharpErrorSeverity.Error - 1 - (11, 10, 11, 13) - "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 11, Col 10, Line 11, Col 13, + "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'string'. This branch returns a value of type 'int'.") [] let ``Else branch context doesn't propagate into function application``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x : string = x let y = if test > 10 then "test" else f 123 - """ - FSharpErrorSeverity.Error - 1 - (7, 11, 7, 14) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 11, Line 7, Col 14, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch context doesn't propagate into function application even if not last expr``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let f x = printfn "%s" x let y = @@ -106,16 +98,15 @@ let y = else f 123 "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 11, 7, 14) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 11, Line 7, Col 14, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch context doesn't propagate into for loop``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let list = [1..10] let y = @@ -125,16 +116,15 @@ let y = printfn "%s" x "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 14, 7, 22) - "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 14, Line 7, Col 22, + "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ") [] let ``Else branch context doesn't propagate to lines before last line``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let test = 100 let list = [1..10] let y = @@ -143,35 +133,39 @@ let y = printfn "%s" 1 "test" - """ - FSharpErrorSeverity.Error - 1 - (7, 22, 7, 23) - "This expression was expected to have type\n 'string' \nbut here has type\n 'int' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 7, Col 22, Line 7, Col 23, + "This expression was expected to have type\n 'string' \nbut here has type\n 'int' ") [] let ``Else branch should not have wrong context type``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 let y : bool = if x = 2 then "A" else "B" - """ - [| FSharpErrorSeverity.Error, 1, (4, 19, 4, 22), "The 'if' expression needs to have type 'bool' to satisfy context type requirements. It currently has type 'string'." - FSharpErrorSeverity.Error, 1, (5, 10, 5, 13), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 4, Col 19, Line 4, Col 22, "The 'if' expression needs to have type 'bool' to satisfy context type requirements. It currently has type 'string'.") + (Error 1, Line 5, Col 10, Line 5, Col 13, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.")] [] let ``Else branch has wrong type in nested if``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 if x = 1 then true else if x = 2 then "A" else "B" - """ - [| FSharpErrorSeverity.Error, 1, (5, 19, 5, 22), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." - FSharpErrorSeverity.Error, 1, (6, 10, 6, 13), "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'." - FSharpErrorSeverity.Warning, 20, (3, 1, 6, 13), "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 3, Col 1, Line 6, Col 13, "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 5, Col 19, Line 5, Col 22, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.") + (Error 1, Line 6, Col 10, Line 6, Col 13, "All branches of an 'if' expression must return values of the same type as the first branch, which here is 'bool'. This branch returns a value of type 'string'.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index 720f18a06da0..4862927ba564 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit open FSharp.Test.Utilities +open FSharp.Test.Utilities.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.AbstractIL.Internal @@ -25,51 +26,41 @@ module ``Numeric Literals`` = [] [] let ``Invalid Numeric Literals`` literal = - CompilerAssert.TypeCheckSingleError - ("let x = " + literal) - FSharpErrorSeverity.Error - 1156 - (1, 9, 1, 9 + (String.length literal)) - "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)." + FSharp ("let x = " + literal) + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1156, Line 1, Col 9, Line 1, Col (9 + (String.length literal)), + "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger).") [] let ``3_(dot)1415F is invalid numeric literal``() = - CompilerAssert.TypeCheckWithErrors - """ -let x = 3_.1415F - """ - [| - FSharpErrorSeverity.Error, 1156, (2, 9, 2, 11), "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)."; - FSharpErrorSeverity.Error, 599, (2, 11, 2, 12),"Missing qualification after '.'" - |] + FSharp "let x = 3_.1415F" + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1156, Line 1, Col 9, Line 1, Col 11, "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger).";) + (Error 599, Line 1, Col 11, Line 1, Col 12,"Missing qualification after '.'")] [] let ``_52 is invalid numeric literal``() = - CompilerAssert.TypeCheckSingleError - """ -let x = _52 - """ - FSharpErrorSeverity.Error - 39 - (2, 9, 2, 12) - "The value or constructor '_52' is not defined." + FSharp "let x = _52" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 1, Col 9, Line 1, Col 12, "The value or constructor '_52' is not defined.") [] let ``1N is invalid numeric literal``() = - CompilerAssert.TypeCheckSingleError - """ -let x = 1N - """ - FSharpErrorSeverity.Error - 0784 - (2, 9, 2, 11) - "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope" + FSharp "let x = 1N" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 0784, Line 1, Col 9, Line 1, Col 11, + "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope") [] let ``1N is invalid numeric literal in FSI``() = if Utils.runningOnMono then () - else + else CompilerAssert.RunScriptWithOptions [| "--langversion:preview"; "--test:ErrorRanges" |] """ let x = 1N @@ -79,10 +70,10 @@ let x = 1N "Operation could not be completed due to earlier error" ] + // Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents [] [] [] let ``Valid Numeric Literals`` literal = - // Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents - - CompilerAssert.Pass ("let x = " + literal) \ No newline at end of file + FSharp ("let x = " + literal) + |> typecheck |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs index 9ab09f8a9ea6..07a40b5c9a0e 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingElseBranch.fs @@ -1,50 +1,46 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Else branch is missing`` = [] let ``Fail if else branch is missing``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = if x > 10 then "test" - """ - FSharpErrorSeverity.Error - 1 - (4, 19, 4, 25) - "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 19, Line 4, Col 25, + "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'.") [] let ``Fail on type error in condition``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = - if x > 10 then + if x > 10 then if x <> "test" then printfn "test" () - """ - FSharpErrorSeverity.Error - 1 - (5, 14, 5, 20) - "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 14, Line 5, Col 20, + "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ") [] let ``Fail if else branch is missing in nesting``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = if x > 10 then ("test") - """ - FSharpErrorSeverity.Error - 1 - (4, 20, 4, 26) - "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 20, Line 4, Col 26, + "This 'if' expression is missing an 'else' branch. Because 'if' is an expression, and not a statement, add an 'else' branch which also returns a value of type 'string'.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs index 802bcfd67506..f91d8b3d6832 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/MissingExpressionTests.fs @@ -1,23 +1,21 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Missing Expression`` = - + [] let ``Missing Expression after let``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let sum = 0 for x in 0 .. 10 do let sum = sum + x - """ - FSharpErrorSeverity.Error - 588 - (4,5,4,8) - "The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 588, Line 4, Col 5, Line 4, Col 8, + "The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs index 5c9647fb0706..932fde27aa09 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ModuleAbbreviationTests.fs @@ -1,21 +1,17 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Module Abbreviations`` = [] let ``Public Module Abbreviation``() = - CompilerAssert.TypeCheckSingleError - """ -module public L1 = List - """ - FSharpErrorSeverity.Error - 536 - (2, 1, 2, 7) - "The 'Public' accessibility attribute is not allowed on module abbreviation. Module abbreviations are always private." + FSharp "module public L1 = List" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 536, Line 1, Col 1, Line 1, Col 7, + "The 'Public' accessibility attribute is not allowed on module abbreviation. Module abbreviations are always private.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs index c48a5c9113b5..016bbdcadce9 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/NameResolutionTests.fs @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module NameResolutionTests = [] let FieldNotInRecord () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type A = { Hello:string; World:string } type B = { Size:int; Height:int } type C = { Wheels:int } @@ -20,16 +18,15 @@ type E = { Unknown:string } type F = { Wallis:int; Size:int; Height:int; } let r:F = { Size=3; Height=4; Wall=1 } - """ - FSharpErrorSeverity.Error - 1129 - (9, 31, 9, 35) - ("The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1129, Line 9, Col 31, Line 9, Col 35, + ("The record type 'F' does not contain a label 'Wall'. Maybe you want one of the following:" + System.Environment.NewLine + " Wallis")) [] let RecordFieldProposal () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type A = { Hello:string; World:string } type B = { Size:int; Height:int } type C = { Wheels:int } @@ -38,8 +35,8 @@ type E = { Unknown:string } type F = { Wallis:int; Size:int; Height:int; } let r = { Size=3; Height=4; Wall=1 } - """ - FSharpErrorSeverity.Error - 39 - (9, 29, 9, 33) - ("The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 29, Line 9, Col 33, + ("The record label 'Wall' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Walls" + System.Environment.NewLine + " Wallis")) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs index bf26f8a2102a..abdc7b92ca11 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/SuggestionsTests.fs @@ -1,87 +1,69 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module Suggestions = [] let ``Field Suggestion`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Person = { Name : string; } let x = { Person.Names = "Isaac" } - """ - FSharpErrorSeverity.Error - 39 - (4, 18, 4, 23) - ("The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 4, Col 18, Line 4, Col 23, + ("The type 'Person' does not define the field, constructor or member 'Names'. Maybe you want one of the following:" + System.Environment.NewLine + " Name")) [] let ``Suggest Array Module Functions`` () = - CompilerAssert.TypeCheckSingleError - """ -let f = - Array.blt - """ - FSharpErrorSeverity.Error - 39 - (3, 11, 3, 14) - ("The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit") - + FSharp "let f = Array.blt" + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 1, Col 15, Line 1, Col 18, + ("The value, constructor, namespace or type 'blt' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " blit")) [] let ``Suggest Async Module`` () = - CompilerAssert.TypeCheckSingleError - """ -let f = - Asnc.Sleep 1000 - """ - FSharpErrorSeverity.Error - 39 - (3, 5, 3, 9) - ("The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd") - + FSharp "let f = Asnc.Sleep 1000" + |> typecheck + |> shouldFail + |> withSingleDiagnostic( Error 39, Line 1, Col 9, Line 1, Col 13, + ("The value, namespace, type or module 'Asnc' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Async" + System.Environment.NewLine + " async" + System.Environment.NewLine + " asin" + System.Environment.NewLine + " snd")) [] let ``Suggest Attribute`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyClass<'Bar>() = abstract M<'T> : 'T -> 'T abstract M2<'T> : 'T -> 'Bar - """ - FSharpErrorSeverity.Error - 39 - (2, 3, 2, 15) - ("The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 3, Line 2, Col 15, + ("The type 'AbstractClas' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " AbstractClass" + System.Environment.NewLine + " AbstractClassAttribute")) [] let ``Suggest Double Backtick Identifiers`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module N = let ``longer name`` = "hallo" let x = N.``longe name`` - """ - FSharpErrorSeverity.Error - 39 - (5, 11, 5, 25) - ("The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 5, Col 11, Line 5, Col 25, + ("The value, constructor, namespace or type 'longe name' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " longer name")) [] let ``Suggest Double Backtick Unions`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module N = type MyUnion = | ``My Case1`` @@ -90,46 +72,41 @@ module N = open N let x = N.MyUnion.``My Case2`` - """ - FSharpErrorSeverity.Error - 39 - (9, 19, 9,31) - ("The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 19, Line 9,Col 31, + ("The type 'MyUnion' does not define the field, constructor or member 'My Case2'. Maybe you want one of the following:" + System.Environment.NewLine + " My Case1" + System.Environment.NewLine + " Case2")) [] let ``Suggest Fields In Constructor`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass() = member val MyProperty = "" with get, set member val MyProperty2 = "" with get, set member val ABigProperty = "" with get, set let c = MyClass(Property = "") - """ - FSharpErrorSeverity.Error - 495 - (7, 17, 7, 25) - ("The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 495, Line 7, Col 17, Line 7, Col 25, + ("The object constructor 'MyClass' has no argument or settable return property 'Property'. The required signature is new : unit -> MyClass. Maybe you want one of the following:" + System.Environment.NewLine + " MyProperty" + System.Environment.NewLine + " MyProperty2" + System.Environment.NewLine + " ABigProperty")) [] let ``Suggest Generic Type`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type T = System.Collections.Generic.Dictionary - """ - FSharpErrorSeverity.Error - 39 - (2, 48, 2, 53) - ("The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 48, Line 2, Col 53, + ("The type 'int11' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " int16" + System.Environment.NewLine + " int16`1" + System.Environment.NewLine + " int8" + System.Environment.NewLine + " uint16" + System.Environment.NewLine + " int")) [] let ``Suggest Methods`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Test2 = type D() = @@ -138,61 +115,53 @@ module Test2 = member x.Method1() = 10 D.Method2() - """ - FSharpErrorSeverity.Error - 39 - (9, 7, 9, 14) - ("The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 9, Col 7, Line 9, Col 14, + ("The type 'D' does not define the field, constructor or member 'Method2'. Maybe you want one of the following:" + System.Environment.NewLine + " Method1")) [] let ``Suggest Modules`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ module Collections = let f () = printfn "%s" "Hello" open Collectons - """ - FSharpErrorSeverity.Error - 39 - (6, 6, 6, 16) - ("The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 6, Line 6, Col 16, + ("The namespace or module 'Collectons' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " Collections")) [] let ``Suggest Namespaces`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ open System.Collectons - """ - FSharpErrorSeverity.Error - 39 - (2, 13, 2, 23) - "The namespace 'Collectons' is not defined." - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 13, Line 2, Col 23, + "The namespace 'Collectons' is not defined.") [] let ``Suggest Record Labels`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyRecord = { Hello: int; World: bool} let r = { Hello = 2 ; World = true} let x = r.ello - """ - FSharpErrorSeverity.Error - 39 - (6, 11, 6, 15) - ("The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 11, Line 6, Col 15, + ("The type 'MyRecord' does not define the field, constructor or member 'ello'. Maybe you want one of the following:" + System.Environment.NewLine + " Hello")) [] let ``Suggest Record Type for RequireQualifiedAccess Records`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyRecord = { Field1: string @@ -200,17 +169,15 @@ type MyRecord = { } let r = { Field1 = "hallo"; Field2 = 1 } - """ - FSharpErrorSeverity.Error - 39 - (8, 11, 8, 17) - ("The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 8, Col 11, Line 8, Col 17, + ("The record label 'Field1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyRecord.Field1")) [] let ``Suggest To Use Indexer`` () = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let d = [1,1] |> dict let y = d[1] @@ -218,90 +185,82 @@ let z = d[|1|] let f() = d let a = (f())[1] - """ - [| - FSharpErrorSeverity.Error, 3217, (3, 9, 3, 10), "This value is not a function and cannot be applied. Did you intend to access the indexer via d.[index] instead?" - FSharpErrorSeverity.Error, 3, (5, 9, 5, 10), "This value is not a function and cannot be applied." - FSharpErrorSeverity.Error, 3217, (8, 10, 8, 13), "This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3217, Line 3, Col 9, Line 3, Col 10, "This value is not a function and cannot be applied. Did you intend to access the indexer via d.[index] instead?") + (Error 3, Line 5, Col 9, Line 5, Col 10, "This value is not a function and cannot be applied.") + (Error 3217, Line 8, Col 10, Line 8, Col 13, "This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?")] [] let ``Suggest Type Parameters`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyClass<'Bar>() = abstract M<'T> : 'T -> 'T abstract M2<'T> : 'T -> 'Bar abstract M3<'T> : 'T -> 'B - """ - FSharpErrorSeverity.Error - 39 - (6, 28, 6, 30) - "The type parameter 'B is not defined." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 28, Line 6, Col 30, + "The type parameter 'B is not defined.") [] let ``Suggest Types in Module`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x : System.Collections.Generic.Lst = ResizeArray() - """ - FSharpErrorSeverity.Error - 39 - (2, 36, 2, 39) - ("The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1") + """ |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 36, Line 2, Col 39, + ("The type 'Lst' is not defined in 'System.Collections.Generic'. Maybe you want one of the following:" + System.Environment.NewLine + " List" + System.Environment.NewLine + " IList" + System.Environment.NewLine + " List`1")) [] let ``Suggest Types in Namespace`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = System.DateTie.MaxValue - """ - FSharpErrorSeverity.Error - 39 - (2, 16, 2, 23) - ("The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 2, Col 16, Line 2, Col 23, + ("The value, constructor, namespace or type 'DateTie' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " DateTime" + System.Environment.NewLine + " DateTimeKind" + System.Environment.NewLine + " DateTimeOffset" + System.Environment.NewLine + " Data")) [] let ``Suggest Union Cases`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyUnion = | ASimpleCase | AnotherCase of int let u = MyUnion.AntherCase - """ - FSharpErrorSeverity.Error - 39 - (6, 17, 6, 27) - ("The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase") - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 6, Col 17, Line 6, Col 27, + ("The type 'MyUnion' does not define the field, constructor or member 'AntherCase'. Maybe you want one of the following:" + System.Environment.NewLine + " AnotherCase")) [] let ``Suggest Union Type for RequireQualifiedAccess Unions`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyUnion = | MyCase1 | MyCase2 of string let x : MyUnion = MyCase1 - """ - FSharpErrorSeverity.Error - 39 - (7, 19, 7, 26) - ("The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 7, Col 19, Line 7, Col 26, + ("The value or constructor 'MyCase1' is not defined. Maybe you want one of the following:" + System.Environment.NewLine + " MyUnion.MyCase1")) [] let ``Suggest Unions in PatternMatch`` () = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ [] type MyUnion = | Case1 @@ -313,8 +272,8 @@ let x = match y with | MyUnion.Cas1 -> 1 | _ -> 2 - """ - FSharpErrorSeverity.Error - 39 - (11, 15, 11, 19) - ("The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 39, Line 11, Col 15, Line 11, Col 19, + ("The type 'MyUnion' does not define the field, constructor or member 'Cas1'. Maybe you want one of the following:" + System.Environment.NewLine + " Case1" + System.Environment.NewLine + " Case2")) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs index 817e0a588c61..8d2d86d1d7ca 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TypeMismatchTests.fs @@ -1,81 +1,75 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Type Mismatch`` = [] let ``return Instead Of return!``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let rec foo() = async { return foo() } - """ - FSharpErrorSeverity.Error - 1 - (2, 32, 2, 37) - "Type mismatch. Expecting a\n ''a' \nbut given a\n 'Async<'a>' \nThe types ''a' and 'Async<'a>' cannot be unified. Consider using 'return!' instead of 'return'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 2, Col 32, Line 2, Col 37, + "Type mismatch. Expecting a\n ''a' \nbut given a\n 'Async<'a>' \nThe types ''a' and 'Async<'a>' cannot be unified. Consider using 'return!' instead of 'return'.") [] let ``yield Instead Of yield!``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type Foo() = member this.Yield(x) = [x] let rec f () = Foo() { yield f ()} - """ - FSharpErrorSeverity.Error - 1 - (5, 30, 5, 34) - "Type mismatch. Expecting a\n ''a' \nbut given a\n ''a list' \nThe types ''a' and ''a list' cannot be unified. Consider using 'yield!' instead of 'yield'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 30, Line 5, Col 34, + "Type mismatch. Expecting a\n ''a' \nbut given a\n ''a list' \nThe types ''a' and ''a list' cannot be unified. Consider using 'yield!' instead of 'yield'.") [] let ``Ref Cell Instead Of Not``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = true if !x then printfn "hello" - """ - FSharpErrorSeverity.Error - 1 - (3, 5, 3, 6) - ("This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 3, Col 5, Line 3, Col 6, + ("This expression was expected to have type\n 'bool ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.")) [] let ``Ref Cell Instead Of Not 2``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = true let y = !x - """ - FSharpErrorSeverity.Error - 1 - (3, 10, 3, 11) - ("This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.") + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 3, Col 10, Line 3, Col 11, + ("This expression was expected to have type\n ''a ref' \nbut here has type\n 'bool' " + System.Environment.NewLine + "The '!' operator is used to dereference a ref cell. Consider using 'not expr' here.")) [] let ``Guard Has Wrong Type``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ let x = 1 match x with | 1 when "s" -> true | _ -> false - """ - [| - FSharpErrorSeverity.Error, 1, (4, 10, 4, 13), "A pattern match guard must be of type 'bool', but this 'when' expression is of type 'string'." - FSharpErrorSeverity.Warning, 20, (3, 1, 5, 13), "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 20, Line 3, Col 1, Line 5, Col 13, "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1, Line 4, Col 10, Line 4, Col 13, "A pattern match guard must be of type 'bool', but this 'when' expression is of type 'string'.")] [] let ``Runtime Type Test In Pattern``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() @@ -84,16 +78,16 @@ let c = match orig with | :? IDictionary -> "yes" | _ -> "no" - """ - [| - FSharpErrorSeverity.Warning, 67, (8, 5, 8, 28), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 193, (8, 5, 8, 28), "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 8, Col 5, Line 8, Col 28, "This type test or downcast will always hold") + (Error 193, Line 8, Col 5, Line 8, Col 28, "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n")] [] let ``Runtime Type Test In Pattern 2``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() @@ -102,16 +96,16 @@ let c = match orig with | :? IDictionary as y -> "yes" + y.ToString() | _ -> "no" - """ - [| - FSharpErrorSeverity.Warning, 67, (8, 5, 8, 28), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 193, (8, 5, 8, 28), "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 8, Col 5, Line 8, Col 28, "This type test or downcast will always hold") + (Error 193, Line 8, Col 5, Line 8, Col 28, "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n")] [] let ``Override Errors``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ type Base() = abstract member Member: int * string -> string default x.Member (i, s) = s @@ -127,9 +121,10 @@ type Derived2() = type Derived3() = inherit Base() override x.Member (s : string, i : int) = sprintf "Hello %s" s - """ - [| - FSharpErrorSeverity.Error, 856, (8, 16, 8, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string" - FSharpErrorSeverity.Error, 856, (12, 16, 12, 22), "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string" - FSharpErrorSeverity.Error, 1, (16, 24, 16, 34), "This expression was expected to have type\n 'int' \nbut here has type\n 'string' " - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 856, Line 8, Col 16, Line 8, Col 22, "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string") + (Error 856, Line 12, Col 16, Line 12, Col 22, "This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found:" + System.Environment.NewLine + " abstract member Base.Member : int * string -> string") + (Error 1, Line 16, Col 24, Line 16, Col 34, "This expression was expected to have type\n 'int' \nbut here has type\n 'string' ")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs index 11ec30ab19ae..2b244e121505 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnitGenericAbstactType.fs @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Unit generic abstract Type`` = [] - let ``Unit can not be used as return type of abstract method paramete on return type``() = - CompilerAssert.TypeCheckSingleError - """ + let ``Unit can not be used as return type of abstract method paramete on return type``() = + FSharp """ type EDF<'S> = abstract member Apply : int -> 'S type SomeEDF () = interface EDF with - member this.Apply d = + member this.Apply d = // [ERROR] The member 'Apply' does not have the correct type to override the corresponding abstract method. () - """ - FSharpErrorSeverity.Error - 17 - (6, 21, 6, 26) - "The member 'Apply : int -> unit' is specialized with 'unit' but 'unit' can't be used as return type of an abstract method parameterized on return type." - + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 17, Line 6, Col 21, Line 6, Col 26, + "The member 'Apply : int -> unit' is specialized with 'unit' but 'unit' can't be used as return type of an abstract method parameterized on return type.") diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs index 79e32f9e3e06..61fcaadf12d5 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UpcastDowncastTests.fs @@ -1,51 +1,49 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Upcast and Downcast`` = [] let ``Downcast Instead Of Upcast``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() :> IDictionary let c = orig :> Dictionary - """ - FSharpErrorSeverity.Error - 193 - (5, 9, 5, 36) - "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n" + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 193, Line 5, Col 9, Line 5, Col 36, + "Type constraint mismatch. The type \n 'IDictionary' \nis not compatible with type\n 'Dictionary' \n") [] let ``Upcast Instead Of Downcast``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() let c = orig :?> IDictionary - """ - [| - FSharpErrorSeverity.Warning, 67, (5, 9, 5, 38), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 3198, (5, 9, 5, 38), "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using the :> (upcast) operator instead of the :?> (downcast) operator." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 5, Col 9, Line 5, Col 38, "This type test or downcast will always hold") + (Error 3198, Line 5, Col 9, Line 5, Col 38, "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using the :> (upcast) operator instead of the :?> (downcast) operator.")] [] let ``Upcast Function Instead Of Downcast``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System.Collections.Generic let orig = Dictionary() let c : IDictionary = downcast orig - """ - [| - FSharpErrorSeverity.Warning, 67, (5, 32, 5, 45), "This type test or downcast will always hold" - FSharpErrorSeverity.Error, 3198, (5, 32, 5, 45), "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using 'upcast' instead of 'downcast'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 67, Line 5, Col 32, Line 5, Col 45, "This type test or downcast will always hold") + (Error 3198, Line 5, Col 32, Line 5, Col 45, "The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using 'upcast' instead of 'downcast'.")] diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs index 565e423407b2..28487c97aa69 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs @@ -1,62 +1,57 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Warn Expression`` = [] let ``Warn If Expression Result Unused``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ 1 + 2 printfn "%d" 3 - """ - FSharpErrorSeverity.Warning - 20 - (2, 1, 2, 6) - "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 2, Col 1, Line 2, Col 6, + "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn If Possible Assignment``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = "hello" let changeX() = x = 20 y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 11) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 11, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'.") [] let ``Warn If Possible Assignment To Mutable``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let mutable x = 10 let y = "hello" let changeX() = x = 20 y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 11) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 11, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'.") [] let ``Warn If Possible dotnet Property Setter``() = - CompilerAssert.TypeCheckWithErrors - """ + FSharp """ open System let z = System.Timers.Timer() @@ -65,16 +60,16 @@ let y = "hello" let changeProperty() = z.Enabled = true y = "test" - """ - [| - FSharpErrorSeverity.Warning, 760, (4, 9, 4, 30), "It is recommended that objects supporting the IDisposable interface are created using the syntax 'new Type(args)', rather than 'Type(args)' or 'Type' as a function value representing the constructor, to indicate that resources may be owned by the generated value" - FSharpErrorSeverity.Warning, 20, (8, 5, 8, 21), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression'." - |] + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 760, Line 4, Col 9, Line 4, Col 30, "It is recommended that objects supporting the IDisposable interface are created using the syntax 'new Type(args)', rather than 'Type(args)' or 'Type' as a function value representing the constructor, to indicate that resources may be owned by the generated value") + (Warning 20, Line 8, Col 5, Line 8, Col 21, "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression'.")] [] let ``Don't Warn If Property Without Setter``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass(property1 : int) = member val Property2 = "" with get @@ -84,33 +79,30 @@ let y = "hello" let changeProperty() = x.Property2 = "22" y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (9, 5, 9, 23) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 9, Col 5, Line 9, Col 23, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") [] let ``Warn If Implicitly Discarded``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let x = 10 let y = 20 let changeX() = y * x = 20 y = 30 - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 15) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 15, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'.") [] let ``Warn If Discarded In List``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ let div _ _ = 1 let subView _ _ = [1; 2] @@ -120,19 +112,16 @@ let view model dispatch = yield! subView model dispatch div [] [] ] - """ - [| - FSharpErrorSeverity.Warning, - 3221, - (9, 8, 9, 17), - "This expression returns a value of type 'int' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3221, Line 9, Col 8, Line 9, Col 17, + "This expression returns a value of type 'int' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.") [] let ``Warn If Discarded In List 2``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ // stupid things to make the sample compile let div _ _ = 1 let subView _ _ = [1; 2] @@ -147,19 +136,16 @@ let view model dispatch = | _ -> subView model dispatch ] ] - """ - [| - FSharpErrorSeverity.Warning, - 3222, - (13, 19, 13, 41), - "This expression returns a value of type 'int list' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3222, Line 13, Col 19, Line 13, Col 41, + "This expression returns a value of type 'int list' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.") [] let ``Warn If Discarded In List 3``() = - CompilerAssert.TypeCheckWithErrorsAndOptions - [| "--langversion:4.6" |] - """ + FSharp """ // stupid things to make the sample compile let div _ _ = 1 let subView _ _ = true @@ -174,33 +160,30 @@ let view model dispatch = | _ -> subView model dispatch ] ] - """ - [| - FSharpErrorSeverity.Warning, - 20, - (13, 19, 13, 41), - "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." - |] + """ + |> withOptions ["--langversion:4.6"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 13, Col 19, Line 13, Col 41, + "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn Only On Last Expression``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ let mutable x = 0 while x < 1 do printfn "unneeded" x <- x + 1 true - """ - FSharpErrorSeverity.Warning - 20 - (6, 5, 6, 9) - "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 6, Col 5, Line 6, Col 9, + "The result of this expression has type 'bool' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") [] let ``Warn If Possible Property Setter``() = - CompilerAssert.TypeCheckSingleError - """ + FSharp """ type MyClass(property1 : int) = member val Property1 = property1 member val Property2 = "" with get, set @@ -211,17 +194,16 @@ let y = "hello" let changeProperty() = x.Property2 = "20" y = "test" - """ - FSharpErrorSeverity.Warning - 20 - (10, 5, 10, 23) - "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression'." + """ + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 20, Line 10, Col 5, Line 10, Col 23, + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression'.") [] let ``Dont warn external function as unused``() = - CompilerAssert.Pass - """ + FSharp """ open System open System.Runtime.InteropServices @@ -240,4 +222,6 @@ let main _argv = let _ = Test.ExtractIconEx("", 0, [| |], [| |], 0u) 0 - """ + """ + |> typecheck + |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs index d7cd6068103d..89e3707c243f 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WrongSyntaxInForLoop.fs @@ -1,20 +1,21 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.ErrorMessages.ComponentTests +namespace FSharp.Compiler.ComponentTests.ErrorMessages open Xunit -open FSharp.Test.Utilities -open FSharp.Compiler.SourceCodeServices +open FSharp.Test.Utilities.Compiler module ``Wrong syntax in for loop`` = [] let ``Equals instead of in``() = - CompilerAssert.ParseWithErrors - """ + FSharp """ module X for i = 0 .. 100 do () - """ - [|FSharpErrorSeverity.Error, 3215, (3, 7, 3, 8), "Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?" |] + """ + |> parse + |> shouldFail + |> withSingleDiagnostic (Error 3215, Line 3, Col 7, Line 3, Col 8, + "Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?") diff --git a/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs b/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs index 929eab5c8093..0c8b76a9da0b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Interop/SimpleInteropTests.fs @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Interop.ComponentTests +namespace FSharp.Compiler.ComponentTests.Interop open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler module ``C# <-> F# basic interop`` = diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs index 16ee721cd0ca..03712d32e1a2 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Language.CodeQuatation +namespace FSharp.Compiler.ComponentTests.Language open Xunit open FSharp.Test.Utilities.Compiler diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs index 9f9d949667cc..32219920d931 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CompilerDirectiveTests.fs @@ -1,11 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace FSharp.Compiler.Language.ComponentTests +namespace FSharp.Compiler.ComponentTests.Language open Xunit -open FSharp.Test.Utilities open FSharp.Test.Utilities.Compiler -open FSharp.Compiler.SourceCodeServices module ``Test Compiler Directives`` = diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 88c137194ced..b31da1d4866e 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -197,11 +197,11 @@ module rec Compiler = let result = compileFSharpCompilation cmpl false match result with | Failure f -> - let message = sprintf "Compilation failed (expected to succeed).\n All errors:\n%A" (f.Errors @ f.Warnings) + let message = sprintf "Operation failed (expected to succeed).\n All errors:\n%A" (f.Errors @ f.Warnings) failwith message | Success s -> match s.OutputPath with - | None -> failwith "Compilation didn't produce any output!" + | None -> failwith "Operation didn't produce any output!" | Some p -> p |> MetadataReference.CreateFromFile | _ -> failwith "Conversion isn't possible" @@ -318,6 +318,31 @@ module rec Compiler = | CS cs -> compileCSharp cs | _ -> failwith "TODO" + let private parseFSharp (fsSource: FSharpCompilationSource) : TestResult = + let source = getSource fsSource.Source + let parseResults = CompilerAssert.Parse source + let failed = parseResults.ParseHadErrors + + let (errors, warnings) = parseResults.Errors |> fromFSharpErrorInfo + + let result = + { OutputPath = None + Dependencies = [] + Adjust = 0 + Warnings = errors + Errors = warnings + Output = None } + + if failed then + Failure result + else + Success result + + let parse (cUnit: CompilationUnit) : TestResult = + match cUnit with + | FS fs -> parseFSharp fs + | _ -> failwith "Parsing only supported for F#." + let private typecheckFSharpWithBaseline (options: string list) (dir: string) (file: string) : TestResult = // Since TypecheckWithErrorsAndOptionsAgainsBaseLine throws if doesn't match expected baseline, // We return a successfull TestResult if it succeeds. @@ -436,12 +461,12 @@ module rec Compiler = match result with | Success _ -> result | Failure r -> - let message = sprintf "Compilation failed (expected to succeed).\n All errors:\n%A" (r.Errors @ r.Warnings) + let message = sprintf "Operation failed (expected to succeed).\n All errors:\n%A" (r.Errors @ r.Warnings) failwith message let shouldFail (result: TestResult) : TestResult = match result with - | Success _ -> failwith "Compilation was \"Success\" (expected: \"Failure\")." + | Success _ -> failwith "Operation was succeeded (expected to fail)." | Failure _ -> result let private assertResultsCategory (what: string) (selector: Output -> ErrorInfo list) (expected: ErrorInfo list) (result: TestResult) : TestResult = diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index e74ef790b16e..4077979d91ad 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -663,10 +663,13 @@ let main argv = 0""" static member RunScript source expectedErrorMessages = CompilerAssert.RunScriptWithOptions [||] source expectedErrorMessages - static member ParseWithErrors (source: string) expectedParseErrors = + static member Parse (source: string) = let sourceFileName = "test.fs" let parsingOptions = { FSharpParsingOptions.Default with SourceFiles = [| sourceFileName |] } - let parseResults = checker.ParseFile(sourceFileName, SourceText.ofString source, parsingOptions) |> Async.RunSynchronously + checker.ParseFile(sourceFileName, SourceText.ofString source, parsingOptions) |> Async.RunSynchronously + + static member ParseWithErrors (source: string) expectedParseErrors = + let parseResults = CompilerAssert.Parse source Assert.True(parseResults.ParseHadErrors) From 379aff66c3249975b85ba6cb94f4f2dfe99a6ee6 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Sat, 1 Aug 2020 04:02:34 +0100 Subject: [PATCH 5/9] Feature/docs improvements (#9854) * improve xml doc spacing * improve cref nodes * fix broken xml doc * fix more crefs * doc improvements * improve docs for FSHarp.Core --- src/fsharp/FSharp.Core/array.fsi | 4 + src/fsharp/FSharp.Core/array2.fsi | 8 +- src/fsharp/FSharp.Core/array3.fsi | 4 + src/fsharp/FSharp.Core/async.fsi | 27 +++--- src/fsharp/FSharp.Core/collections.fsi | 50 +++++++---- src/fsharp/FSharp.Core/map.fsi | 8 +- src/fsharp/FSharp.Core/prim-types.fsi | 19 +++- src/fsharp/FSharp.Core/seq.fsi | 117 ++++++++++++------------- src/fsharp/FSharp.Core/set.fsi | 7 +- 9 files changed, 141 insertions(+), 103 deletions(-) diff --git a/src/fsharp/FSharp.Core/array.fsi b/src/fsharp/FSharp.Core/array.fsi index 2ae5facdbca0..aded2dcf256f 100644 --- a/src/fsharp/FSharp.Core/array.fsi +++ b/src/fsharp/FSharp.Core/array.fsi @@ -8,6 +8,10 @@ namespace Microsoft.FSharp.Collections open System.Collections.Generic /// Basic operations on arrays. + /// + /// + /// See also F# Language Guide - Arrays. + /// [] [] module Array = diff --git a/src/fsharp/FSharp.Core/array2.fsi b/src/fsharp/FSharp.Core/array2.fsi index f21e7930d93b..23d4e36b9e24 100644 --- a/src/fsharp/FSharp.Core/array2.fsi +++ b/src/fsharp/FSharp.Core/array2.fsi @@ -10,7 +10,10 @@ namespace Microsoft.FSharp.Collections [] /// Basic operations on 2-dimensional arrays. /// - /// F# and CLI multi-dimensional arrays are typically zero-based. + /// + /// See also F# Language Guide - Arrays. + /// + /// F# and CLI multi-dimensional arrays are typically zero-based. /// However, CLI multi-dimensional arrays used in conjunction with external /// libraries (e.g. libraries associated with Visual Basic) be /// non-zero based, using a potentially different base for each dimension. @@ -18,7 +21,8 @@ namespace Microsoft.FSharp.Collections /// the basing on an input array will be propagated to a matching output /// array on the Array2D.map and Array2D.mapi operations. /// Non-zero-based arrays can also be created using Array2D.zeroCreateBased, - /// Array2D.createBased and Array2D.initBased. + /// Array2D.createBased and Array2D.initBased. + /// module Array2D = /// Fetches the base-index for the first dimension of the array. diff --git a/src/fsharp/FSharp.Core/array3.fsi b/src/fsharp/FSharp.Core/array3.fsi index cc295522d449..cba604b2266c 100644 --- a/src/fsharp/FSharp.Core/array3.fsi +++ b/src/fsharp/FSharp.Core/array3.fsi @@ -10,6 +10,10 @@ namespace Microsoft.FSharp.Collections [] [] /// Basic operations on rank 3 arrays. + /// + /// + /// See also F# Language Guide - Arrays. + /// module Array3D = /// Creates an array whose elements are all initially the given value. diff --git a/src/fsharp/FSharp.Core/async.fsi b/src/fsharp/FSharp.Core/async.fsi index 594d90144f17..b19d63cbfdcb 100644 --- a/src/fsharp/FSharp.Core/async.fsi +++ b/src/fsharp/FSharp.Core/async.fsi @@ -11,24 +11,25 @@ namespace Microsoft.FSharp.Control open Microsoft.FSharp.Control open Microsoft.FSharp.Collections - /// A compositional asynchronous computation, which, when run, will eventually produce a value - /// of type T, or else raises an exception. + /// + /// An asynchronous computation, which, when run, will eventually produce a value of type T, or else raises an exception. + /// /// - /// Asynchronous computations are normally specified using an F# computation expression. + /// + /// This type has no members. Asynchronous computations are normally specified either by using an async expression + /// or the static methods in the type. /// - /// When run, asynchronous computations have two modes: as a work item (executing synchronous - /// code), or as a wait item (waiting for an event or I/O completion). - /// - /// When run, asynchronous computations can be governed by CancellationToken. This can usually - /// be specified when the async computation is started. The associated CancellationTokenSource - /// may be used to cancel the asynchronous computation. Asynchronous computations built using - /// computation expressions can check the cancellation condition regularly. Synchronous - /// computations within an asynchronous computation do not automatically check this condition. + /// See also F# Language Guide - Async Workflows. + /// [] type Async<'T> - /// This static class holds members for creating and manipulating asynchronous computations. + /// Holds static members for creating and manipulating asynchronous computations. + /// + /// + /// See also F# Language Guide - Async Workflows. + /// [] [] @@ -47,7 +48,7 @@ namespace Microsoft.FSharp.Control /// The computation to run. /// The amount of time in milliseconds to wait for the result of the /// computation before raising a . If no value is provided - /// for timeout then a default of -1 is used to correspond to System.Threading.Timeout.Infinite. + /// for timeout then a default of -1 is used to correspond to . /// If a cancellable cancellationToken is provided, timeout parameter will be ignored /// The cancellation token to be associated with the computation. /// If one is not supplied, the default cancellation token is used. diff --git a/src/fsharp/FSharp.Core/collections.fsi b/src/fsharp/FSharp.Core/collections.fsi index 8e3eab67a38f..2acb14106977 100644 --- a/src/fsharp/FSharp.Core/collections.fsi +++ b/src/fsharp/FSharp.Core/collections.fsi @@ -9,47 +9,63 @@ namespace Microsoft.FSharp.Collections open System open System.Collections.Generic - /// Common notions of comparison identity used with sorted data structures. + /// Common notions of value ordering implementing the + /// interface, for constructing sorted data structures and performing sorting operations. module ComparisonIdentity = - /// Structural comparison. Compare using Operators.compare. + /// Get an implementation of comparison semantics using structural comparison. + /// + /// An object implementing using . val inline Structural<'T> : IComparer<'T> when 'T : comparison - /// Non-structural comparison. Compare using NonStructuralComparison.compare. + /// Get an implementation of comparison semantics using non-structural comparison. + /// + /// An object implementing using . val inline NonStructural< ^T > : IComparer< ^T > when ^T : (static member ( < ) : ^T * ^T -> bool) and ^T : (static member ( > ) : ^T * ^T -> bool) - /// Compare using the given comparer function. + /// Get an implementation of comparison semantics using the given function. + /// /// A function to compare two values. /// - /// An object implementing IComparer using the supplied comparer. + /// An object implementing using the supplied function. val FromFunction : comparer:('T -> 'T -> int) -> IComparer<'T> - /// Common notions of value identity used with hash tables. + /// Common notions of value identity implementing the + /// interface, for constructing objects and other collections module HashIdentity = - /// Structural hashing. Hash using Operators.(=) and Operators.hash. + /// Get an implementation of equality semantics using structural equality and structural hashing. + /// + /// An object implementing using and . val inline Structural<'T> : IEqualityComparer<'T> when 'T : equality - /// Non-structural hashing. Equality using NonStructuralComparison.(=) and NonStructuralComparison.hash. + /// Get an implementation of equality semantics using non-structural equality and non-structural hashing. + /// + /// + /// An object implementing using + /// and . + /// val inline NonStructural<'T> : IEqualityComparer< ^T > when ^T : equality and ^T : (static member ( = ) : ^T * ^T -> bool) + /// Get an implementation of equality semantics semantics using structural equality and structural hashing. + /// + /// An object implementing . val inline LimitedStructural<'T> : limit: int -> IEqualityComparer<'T> when 'T : equality - /// Physical hashing (hash on reference identity of objects, and the contents of value types). - /// Hash using LanguagePrimitives.PhysicalEquality and LanguagePrimitives.PhysicalHash, - /// That is, for value types use GetHashCode and Object.Equals (if no other optimization available), - /// and for reference types use System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode and - /// reference equality. + /// Get an implementation of equality semantics using reference equality and reference hashing. + /// + /// + /// An object implementing using + /// and . + /// val Reference<'T> : IEqualityComparer<'T> when 'T : not struct - /// Hash using the given hashing and equality functions. + /// Get an implementation of equality semantics using the given functions. /// /// A function to generate a hash code from a value. /// A function to test equality of two values. /// - /// An object implementing IEqualityComparer using the supplied functions. - - // inline justification: allows inlining of hash functions + /// An object implementing using the given functions. val inline FromFunctions<'T> : hasher:('T -> int) -> equality:('T -> 'T -> bool) -> IEqualityComparer<'T> diff --git a/src/fsharp/FSharp.Core/map.fsi b/src/fsharp/FSharp.Core/map.fsi index 5e35b635ab10..ebbe7762c0e5 100644 --- a/src/fsharp/FSharp.Core/map.fsi +++ b/src/fsharp/FSharp.Core/map.fsi @@ -7,10 +7,10 @@ namespace Microsoft.FSharp.Collections open Microsoft.FSharp.Core open Microsoft.FSharp.Collections - /// Immutable maps. Keys are ordered by F# generic comparison. + /// Immutable maps based on binary trees, where keys are ordered by F# generic comparison. By default + /// comparison is the F# structural comparison function or uses implementations of the IComparable interface on key values. /// - /// Maps based on generic comparison are efficient for small keys. They are not a suitable choice if keys are recursive data structures - /// or if keys require bespoke comparison semantics. + /// See the module for further operations on maps. /// /// All members of this class are thread-safe and may be used concurrently from multiple threads. [] @@ -93,7 +93,7 @@ namespace Microsoft.FSharp.Collections interface IReadOnlyDictionary<'Key,'Value> override Equals : obj -> bool - /// Functional programming operators related to the Map<_,_> type. + /// Basic operations on values of type . [] [] /// Basic operations on values of type . diff --git a/src/fsharp/FSharp.Core/prim-types.fsi b/src/fsharp/FSharp.Core/prim-types.fsi index e44853e8bc88..449ac73f3cfb 100644 --- a/src/fsharp/FSharp.Core/prim-types.fsi +++ b/src/fsharp/FSharp.Core/prim-types.fsi @@ -2256,17 +2256,28 @@ namespace Microsoft.FSharp.Collections interface IReadOnlyCollection<'T> interface IReadOnlyList<'T> - /// An abbreviation for the type of immutable singly-linked lists. + /// The type of immutable singly-linked lists. /// - /// Use the constructors [] and :: (infix) to create values of this type, or - /// the notation [1;2;3]. Use the values in the List module to manipulate - /// values of this type, or pattern match against the values directly. + /// See the module for further operations related to lists. + /// + /// Use the constructors [] and :: (infix) to create values of this type, or + /// the notation [1; 2; 3]. Use the values in the List module to manipulate + /// values of this type, or pattern match against the values directly. + /// + /// See also F# Language Guide - Lists. + /// and 'T list = List<'T> /// An abbreviation for the CLI type type ResizeArray<'T> = System.Collections.Generic.List<'T> /// An abbreviation for the CLI type + /// + /// + /// See the module for further operations related to sequences. + /// + /// See also F# Language Guide - Sequences. + /// type seq<'T> = IEnumerable<'T> namespace Microsoft.FSharp.Core diff --git a/src/fsharp/FSharp.Core/seq.fsi b/src/fsharp/FSharp.Core/seq.fsi index 144276df7c25..f128def66357 100644 --- a/src/fsharp/FSharp.Core/seq.fsi +++ b/src/fsharp/FSharp.Core/seq.fsi @@ -15,10 +15,12 @@ namespace Microsoft.FSharp.Collections module Seq = /// Returns a new sequence that contains all pairings of elements from the first and second sequences. + /// /// The first sequence. /// The second sequence. /// /// The result sequence. + /// /// Thrown when either of the input sequences is null. [] val allPairs: source1:seq<'T1> -> source2:seq<'T2> -> seq<'T1 * 'T2> @@ -76,8 +78,10 @@ namespace Microsoft.FSharp.Collections and ^U : (static member DivideByInt : ^U * int -> ^U) and ^U : (static member Zero : ^U) - /// Returns a sequence that corresponds to a cached version of the input sequence. - /// This result sequence will have the same elements as the input sequence. The result + /// Returns a sequence that corresponds to a cached version of the input sequence. + /// + /// + /// The result sequence will have the same elements as the input sequence. The result /// can be enumerated multiple times. The input sequence will be enumerated at most /// once and only as far as is necessary. Caching a sequence is typically useful when repeatedly /// evaluating items in the original sequence is computationally expensive or if @@ -89,7 +93,7 @@ namespace Microsoft.FSharp.Collections /// the internal lookaside table are thread safe). Each individual IEnumerator /// is not typically thread safe and should not be accessed concurrently. /// - /// Once enumeration of the input sequence has started, + /// Once enumeration of the input sequence has started, /// it's enumerator will be kept live by this object until the enumeration has completed. /// At that point, the enumerator will be disposed. /// @@ -377,6 +381,7 @@ namespace Microsoft.FSharp.Collections val find: predicate:('T -> bool) -> source:seq<'T> -> 'T /// Returns the last element for which the given function returns True. + /// /// This function digests the whole initial sequence as soon as it is called. As a /// result this function should not be used with large or infinite sequences. /// A function to test whether an item in the sequence should be returned. @@ -404,16 +409,18 @@ namespace Microsoft.FSharp.Collections val findIndex: predicate:('T -> bool) -> source:seq<'T> -> int /// Returns the index of the last element for which the given function returns True. + /// /// This function digests the whole initial sequence as soon as it is called. As a /// result this function should not be used with large or infinite sequences. + /// /// A function to test whether the index of a particular element should be returned. /// The input sequence. /// /// The index of the last element for which the predicate returns True. + /// /// Thrown if no element returns true when /// evaluated by the predicate /// Thrown when the input sequence is null - /// This function consumes the whole input sequence before returning the result. [] val findIndexBack: predicate:('T -> bool) -> source:seq<'T> -> int @@ -432,10 +439,12 @@ namespace Microsoft.FSharp.Collections val fold<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> source:seq<'T> -> 'State /// Applies a function to corresponding elements of two collections, threading an accumulator argument - /// through the computation. The two sequences need not have equal lengths: + /// through the computation. + /// + /// The two sequences need not have equal lengths: /// when one sequence is exhausted any remaining elements in the other sequence are ignored. /// If the input function is f and the elements are i0...iN and j0...jN - /// then computes f (... (f s i0 j0)...) iN jN. + /// then computes f (... (f s i0 j0)...) iN jN. /// /// The function to update the state given the input elements. /// The initial state. @@ -457,6 +466,7 @@ namespace Microsoft.FSharp.Collections /// /// The state object after the folding function is applied to each element of the sequence. /// Thrown when the input sequence is null. + /// /// This function consumes the whole input sequence before returning the result. [] val foldBack<'T,'State> : folder:('T -> 'State -> 'State) -> source:seq<'T> -> state:'State -> 'State @@ -472,6 +482,7 @@ namespace Microsoft.FSharp.Collections /// The initial state. /// /// The final state value. + /// /// Thrown when the either of the input sequences is null. [] val foldBack2<'T1,'T2,'State> : folder:('T1 -> 'T2 -> 'State -> 'State) -> source1:seq<'T1> -> source2:seq<'T2> -> state:'State -> 'State @@ -547,6 +558,7 @@ namespace Microsoft.FSharp.Collections /// The input sequence. /// /// The last element of the sequence. + /// /// Thrown when the input sequence is null. /// Thrown when the input does not have any elements. [] @@ -643,6 +655,7 @@ namespace Microsoft.FSharp.Collections /// The input sequence. /// /// The element at the specified index of the sequence. + /// /// Thrown when the input sequence is null. /// Thrown when the index is negative or the input sequence does not contain enough elements. [] @@ -733,27 +746,33 @@ namespace Microsoft.FSharp.Collections /// Combines map and fold. Builds a new collection whose elements are the results of applying the given function /// to each of the elements of the collection. The function is also used to accumulate a final value. + /// /// This function digests the whole initial sequence as soon as it is called. As a result this function should /// not be used with large or infinite sequences. + /// /// The function to transform elements from the input collection and accumulate the final value. /// The initial state. /// The input collection. + /// /// Thrown when the input collection is null. + /// /// The collection of transformed elements, and the final accumulated value. - /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val mapFold<'T,'State,'Result> : mapping:('State -> 'T -> 'Result * 'State) -> state:'State -> source:seq<'T> -> seq<'Result> * 'State /// Combines map and foldBack. Builds a new collection whose elements are the results of applying the given function /// to each of the elements of the collection. The function is also used to accumulate a final value. + /// /// This function digests the whole initial sequence as soon as it is called. As a result this function should /// not be used with large or infinite sequences. + /// /// The function to transform elements from the input collection and accumulate the final value. /// The input collection. /// The initial state. + /// /// Thrown when the input collection is null. + /// /// The collection of transformed elements, and the final accumulated value. - /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val mapFoldBack<'T,'State,'Result> : mapping:('T -> 'State -> 'Result * 'State) -> source:seq<'T> -> state:'State -> seq<'Result> * 'State @@ -823,20 +842,6 @@ namespace Microsoft.FSharp.Collections [] val inline maxBy : projection:('T -> 'U) -> source:seq<'T> -> 'T when 'U : comparison -(* - /// Returns the greatest function result from the elements of the sequence, compared via Operators.max. - /// - /// A function to transform items from the input sequence into comparable keys. - /// The input sequence. - /// - /// The largest element of the sequence. - /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. - [] - val inline maxValBy : projection:('T -> 'U) -> source:seq<'T> -> 'U when 'U : comparison -*) - /// Returns the lowest of all elements of the sequence, compared via Operators.min. /// /// The input sequence. @@ -860,20 +865,6 @@ namespace Microsoft.FSharp.Collections [] val inline minBy : projection:('T -> 'U) -> source:seq<'T> -> 'T when 'U : comparison -(* - /// Returns the lowest function result from the elements of the sequence, compared via Operators.max. - /// - /// A function to transform items from the input sequence into comparable keys. - /// The input sequence. - /// - /// The smallest element of the sequence. - /// - /// Thrown when the input sequence is null. - /// Thrown when the input sequence is empty. - [] - val inline minValBy : projection:('T -> 'U) -> source:seq<'T> -> 'U when 'U : comparison -*) - /// Computes the nth element in the collection. /// /// The index of element to retrieve. @@ -887,7 +878,6 @@ namespace Microsoft.FSharp.Collections [] val nth: index:int -> source:seq<'T> -> 'T - [] /// Views the given array as a sequence. /// @@ -920,9 +910,7 @@ namespace Microsoft.FSharp.Collections /// Returns a sequence with all elements permuted according to the /// specified permutation. /// - /// Note that this function returns a sequence that digests the whole initial sequence as soon as - /// that sequence is iterated. As a result this function should not be used with - /// large or infinite sequences. + /// This function consumes the whole input sequence before yielding the first element of the result sequence. /// /// The function that maps input indices to output indices. /// The input sequence. @@ -931,7 +919,6 @@ namespace Microsoft.FSharp.Collections /// /// Thrown when the input sequence is null. /// Thrown when indexMap does not produce a valid permutation. - /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val permute: indexMap:(int -> int) -> source:seq<'T> -> seq<'T> @@ -996,8 +983,10 @@ namespace Microsoft.FSharp.Collections /// The input sequence. /// /// The final result of the reductions. + /// /// Thrown when the input sequence is null. /// Thrown when the input sequence is empty. + /// /// This function consumes the whole input sequence before returning the result. [] val reduceBack: reduction:('T -> 'T -> 'T) -> source:seq<'T> -> 'T @@ -1007,7 +996,9 @@ namespace Microsoft.FSharp.Collections /// The input sequence. /// /// The reversed sequence. + /// /// Thrown when the input sequence is null. + /// /// This function consumes the whole input sequence before yielding the first element of the reversed sequence. [] val rev: source:seq<'T> -> seq<'T> @@ -1025,16 +1016,18 @@ namespace Microsoft.FSharp.Collections val scan<'T,'State> : folder:('State -> 'T -> 'State) -> state:'State -> source:seq<'T> -> seq<'State> /// Like foldBack, but returns the sequence of intermediary and final results. + /// /// This function returns a sequence that digests the whole initial sequence as soon as that /// sequence is iterated. As a result this function should not be used with large or infinite sequences. /// + /// /// A function that updates the state with each element from the sequence. /// The input sequence. /// The initial state. /// /// The resulting sequence of computed states. + /// /// Thrown when the input sequence is null. - /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val scanBack<'T,'State> : folder:('T -> 'State -> 'State) -> source:seq<'T> -> state:'State -> seq<'State> @@ -1076,32 +1069,32 @@ namespace Microsoft.FSharp.Collections /// /// This function returns a sequence that digests the whole initial sequence as soon as /// that sequence is iterated. As a result this function should not be used with - /// large or infinite sequences. The function makes no assumption on the ordering of the original - /// sequence. + /// large or infinite sequences. /// - /// This is a stable sort, that is the original order of equal elements is preserved. + /// The function makes no assumption on the ordering of the original + /// sequence and uses a stable sort, that is the original order of equal elements is preserved. /// /// The input sequence. /// /// The result sequence. /// /// Thrown when the input sequence is null. - /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val sort : source:seq<'T> -> seq<'T> when 'T : comparison /// Yields a sequence ordered using the given comparison function. + /// /// This function returns a sequence that digests the whole initial sequence as soon as /// that sequence is iterated. As a result this function should not be used with - /// large or infinite sequences. The function makes no assumption on the ordering of the original - /// sequence. + /// large or infinite sequences. + /// + /// The function makes no assumption on the ordering of the original + /// sequence and uses a stable sort, that is the original order of equal elements is preserved. /// - /// This is a stable sort, that is the original order of equal elements is preserved. /// The function to compare the collection elements. /// The input sequence. /// /// The result sequence. - /// This function consumes the whole input sequence before yielding the first element of the result sequence. [] val sortWith : comparer:('T -> 'T -> int) -> source:seq<'T> -> seq<'T> @@ -1110,10 +1103,10 @@ namespace Microsoft.FSharp.Collections /// /// This function returns a sequence that digests the whole initial sequence as soon as /// that sequence is iterated. As a result this function should not be used with - /// large or infinite sequences. The function makes no assumption on the ordering of the original - /// sequence. + /// large or infinite sequences. /// - /// This is a stable sort, that is the original order of equal elements is preserved. + /// The function makes no assumption on the ordering of the original + /// sequence and uses a stable sort, that is the original order of equal elements is preserved. /// /// A function to transform items of the input sequence into comparable keys. /// The input sequence. @@ -1173,6 +1166,7 @@ namespace Microsoft.FSharp.Collections and ^T : (static member Zero : ^T) /// Returns the sum of the results generated by applying the function to each element of the sequence. + /// /// The generated elements are summed using the + operator and Zero property associated with the generated type. /// /// A function to transform items from the input sequence into the type that will be summed. @@ -1197,6 +1191,7 @@ namespace Microsoft.FSharp.Collections val tail: source:seq<'T> -> seq<'T> /// Returns the first N elements of the sequence. + /// /// Throws InvalidOperationException /// if the count exceeds the number of elements in the sequence. Seq.truncate /// returns as many items as the sequence contains instead of throwing an exception. @@ -1259,14 +1254,16 @@ namespace Microsoft.FSharp.Collections /// Returns the last element for which the given function returns True. /// Return None if no such element exists. + /// /// This function digests the whole initial sequence as soon as it is called. As a /// result this function should not be used with large or infinite sequences. + /// /// A function that evaluates to a Boolean when given an item in the sequence. /// The input sequence. /// /// The found element or None. + /// /// Thrown when the input sequence is null. - /// This function consumes the whole input sequence before returning the result. [] val tryFindBack: predicate:('T -> bool) -> source:seq<'T> -> 'T option @@ -1295,14 +1292,16 @@ namespace Microsoft.FSharp.Collections /// Returns the index of the last element in the sequence /// that satisfies the given predicate. Return None if no such element exists. + /// /// This function digests the whole initial sequence as soon as it is called. As a /// result this function should not be used with large or infinite sequences. + /// /// A function that evaluates to a Boolean when given an item in the sequence. /// The input sequence. /// /// The found index or None. + /// /// Thrown when the input sequence is null. - /// This function consumes the whole input sequence before returning the result. [] val tryFindIndexBack : predicate:('T -> bool) -> source:seq<'T> -> int option @@ -1319,12 +1318,15 @@ namespace Microsoft.FSharp.Collections val tryPick: chooser:('T -> 'U option) -> source:seq<'T> -> 'U option /// Returns the transpose of the given sequence of sequences. + /// /// This function returns a sequence that digests the whole initial sequence as soon as /// that sequence is iterated. As a result this function should not be used with /// large or infinite sequences. + /// /// The input sequence. /// /// The transposed sequence. + /// /// Thrown when the input sequence is null. [] val transpose: source:seq<'Collection> -> seq> when 'Collection :> seq<'T> @@ -1346,10 +1348,7 @@ namespace Microsoft.FSharp.Collections /// generator, until a None value is returned by the element generator. Each call to the element /// generator returns a new residual state. /// - /// The stream will be recomputed each time an IEnumerator is requested and iterated for the Seq. - /// - /// The returned sequence may be passed between threads safely. However, - /// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. + /// The stream will be recomputed each time an IEnumerator is requested and iterated for the Seq. /// /// A function that takes in the current state and returns an option tuple of the next /// element of the sequence and the next state value. diff --git a/src/fsharp/FSharp.Core/set.fsi b/src/fsharp/FSharp.Core/set.fsi index 267fefec0563..12261913cf18 100644 --- a/src/fsharp/FSharp.Core/set.fsi +++ b/src/fsharp/FSharp.Core/set.fsi @@ -7,11 +7,10 @@ namespace Microsoft.FSharp.Collections open Microsoft.FSharp.Core open Microsoft.FSharp.Collections - /// Immutable sets based on binary trees, where comparison is the - /// F# structural comparison function, potentially using implementations - /// of the IComparable interface on key values. + /// Immutable sets based on binary trees, where elements are ordered by F# generic comparison. By default + /// comparison is the F# structural comparison function or uses implementations of the IComparable interface on element values. /// - /// See the Set module for further operations on sets. + /// See the module for further operations on sets. /// /// All members of this class are thread-safe and may be used concurrently from multiple threads. [] From f36c6fbfd937be44f8e587c7f491d1e66baa3795 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Mon, 3 Aug 2020 16:30:41 -0700 Subject: [PATCH 6/9] Fix Package Scripting nuget package (#9862) --- .../FSharp.Compiler.Private.Scripting.fsproj | 3 ++- .../FSharp.Compiler.Private.Scripting.nuspec | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.fsproj b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.fsproj index 58472c59e378..3adf2846f799 100644 --- a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.fsproj +++ b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.fsproj @@ -13,7 +13,8 @@ - + + diff --git a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.nuspec b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.nuspec index 0e52e1b4300c..004852622646 100644 --- a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.nuspec +++ b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.nuspec @@ -5,13 +5,12 @@ en-US + $CommonFileElements$ - - From 57711f92aabd1f2c95a0ba6b70581d0c27bfbe07 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Mon, 3 Aug 2020 16:32:59 -0700 Subject: [PATCH 7/9] Automagic (#9845) * Automagic * update * implicit fsharpcore * e2e tests --- FSharpBuild.Directory.Build.targets | 1 + src/fsharp/FSharp.Build/FSharp.Build.fsproj | 2 ++ .../Microsoft.FSharp.NetSdk.props | 30 ++++++++++++++----- .../Microsoft.FSharp.NetSdk.targets | 6 ++-- .../BasicProvider.DesignTime.fsproj | 3 +- .../BasicProvider.Tests.fsproj | 1 + .../BasicProvider/BasicProvider.fsproj | 3 +- .../BasicProvider/TestBasicProvider.cmd | 8 ++--- .../ComboProvider.Tests.fsproj | 1 + .../ComboProvider/ComboProvider.fsproj | 3 +- .../ComboProvider/TestComboProvider.cmd | 8 ++--- .../DefaultFSharpCore - IsNotPreviewSdk.proj | 20 +++++++++++++ ... - IsNotPreviewSdkDisablePreviewCheck.proj | 21 +++++++++++++ ...e - IsNotPreviewSdkEnablePreviewCheck.proj | 21 +++++++++++++ .../DefaultFSharpCore - IsPreviewSdk.proj | 20 +++++++++++++ ...ore - IsPreviewSdkDisablePreviewCheck.proj | 21 +++++++++++++ ...Core - IsPreviewSdkEnablePreviewCheck.proj | 21 +++++++++++++ .../tests/DefaultImplicitReferenceTest.proj | 19 ------------ tests/fsharp/SDKTests/tests/Test.props | 3 +- tests/fsharp/SDKTests/tests/Test.targets | 1 + ...reSDK_FSharp_Library_netstandard2_0.fsproj | 2 -- 21 files changed, 171 insertions(+), 44 deletions(-) create mode 100644 tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdk.proj create mode 100644 tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdkDisablePreviewCheck.proj create mode 100644 tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdkEnablePreviewCheck.proj create mode 100644 tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdk.proj create mode 100644 tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdkDisablePreviewCheck.proj create mode 100644 tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdkEnablePreviewCheck.proj delete mode 100644 tests/fsharp/SDKTests/tests/DefaultImplicitReferenceTest.proj diff --git a/FSharpBuild.Directory.Build.targets b/FSharpBuild.Directory.Build.targets index 66b5508aa565..91acf15aa373 100644 --- a/FSharpBuild.Directory.Build.targets +++ b/FSharpBuild.Directory.Build.targets @@ -19,6 +19,7 @@ <_ReplacementText>$([System.IO.File]::ReadAllText('%(NoneSubstituteText.FullPath)')) <_ReplacementText Condition="'%(NoneSubstituteText.Pattern1)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern1)', '%(NoneSubstituteText.Replacement1)')) <_ReplacementText Condition="'%(NoneSubstituteText.Pattern2)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern2)', '%(NoneSubstituteText.Replacement2)')) + <_ReplacementText Condition="'%(NoneSubstituteText.Pattern3)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern3)', '%(NoneSubstituteText.Replacement3)')) <_CopyToOutputDirectory Condition="'%(NoneSubstituteText.CopyToOutputDirectory)' != ''">%(NoneSubstituteText.CopyToOutputDirectory) <_CopyToOutputDirectory Condition="'%(NoneSubstituteText.CopyToOutputDirectory)' == ''">Never diff --git a/src/fsharp/FSharp.Build/FSharp.Build.fsproj b/src/fsharp/FSharp.Build/FSharp.Build.fsproj index 2960aec35148..2f37cc454397 100644 --- a/src/fsharp/FSharp.Build/FSharp.Build.fsproj +++ b/src/fsharp/FSharp.Build/FSharp.Build.fsproj @@ -36,6 +36,8 @@ $(FSharpCoreShippedPackageVersion) {{FSharpCorePreviewPackageVersion}} $(FSharpCorePreviewPackageVersion) + {{FSCorePackageVersion}} + $(FSCorePackageVersion) diff --git a/src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.props b/src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.props index f8bae0ab9ab5..3a51d7287a51 100644 --- a/src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.props +++ b/src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.props @@ -74,12 +74,32 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and 4.4.0 - {{FSharpCoreShippedPackageVersion}} - {{FSharpCorePreviewPackageVersion}} $(DefaultValueTuplePackageVersion) - $(DefaultFSharpCorePackageVersion) + {{FSharpCoreShippedPackageVersion}} + {{FSharpCorePreviewPackageVersion}} + {{FSCorePackageVersion}} + + + + + + + + + + + + - - - - true diff --git a/src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.targets b/src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.targets index 330dc47f8b8f..7fa9d8993628 100644 --- a/src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.targets +++ b/src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.targets @@ -52,10 +52,8 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and $(TargetsForTfmSpecificContentInPackage);PackageFSharpDesignTimeTools - - - $(DefaultFSharpCorePreviewPackageVersion) - $(RestoreSources); https://dotnet.myget.org/F/fsharp/api/v3/index.json + + $(RestoreAdditionalProjectSources);https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj index 708a3b9d8939..84caced58f2d 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj @@ -2,10 +2,11 @@ Library - netcoreapp3.1;net461 + netcoreapp3.1;net472 typeproviders NO_GENERATIVE IS_DESIGNTIME + $(FSharpCoreShippedPackageVersion) diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj index 46bdb547f17d..f6d202a0d55a 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj @@ -6,6 +6,7 @@ $(TestTargetFramework) false NO_GENERATIVE + $(FSharpCoreShippedPackageVersion) diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj index 312f02e7cc92..9e6714f99d8a 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj @@ -2,8 +2,9 @@ Library - netcoreapp3.1;net461 + netcoreapp3.1;net472 typeproviders + $(FSharpCoreShippedPackageVersion) typeproviders diff --git a/tests/EndToEndBuildTests/BasicProvider/TestBasicProvider.cmd b/tests/EndToEndBuildTests/BasicProvider/TestBasicProvider.cmd index 0acebd17dd8a..bce9551e2c98 100644 --- a/tests/EndToEndBuildTests/BasicProvider/TestBasicProvider.cmd +++ b/tests/EndToEndBuildTests/BasicProvider/TestBasicProvider.cmd @@ -38,8 +38,8 @@ echo dotnet pack BasicProvider\BasicProvider.fsproj -o %~dp0artifacts -c %config dotnet pack BasicProvider\BasicProvider.fsproj -o %~dp0artifacts -c %configuration% -v minimal -p:FSharpTestCompilerVersion=net40 if ERRORLEVEL 1 echo Error: TestBasicProvider failed && goto :failure -echo dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net461 -p:FSharpTestCompilerVersion=net40 - dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net461 -p:FSharpTestCompilerVersion=net40 +echo dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net472 -p:FSharpTestCompilerVersion=net40 + dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net472 -p:FSharpTestCompilerVersion=net40 if ERRORLEVEL 1 echo Error: TestBasicProvider failed && goto :failure echo dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=netcoreapp3.1 -p:FSharpTestCompilerVersion=coreclr @@ -56,8 +56,8 @@ echo dotnet pack BasicProvider\BasicProvider.fsproj -o %~dp0artifacts -c %config dotnet pack BasicProvider\BasicProvider.fsproj -o %~dp0artifacts -c %configuration% -v minimal -p:FSharpTestCompilerVersion=coreclr if ERRORLEVEL 1 echo Error: TestBasicProvider failed && goto :failure -echo dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net461 -p:FSharpTestCompilerVersion=net40 - dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net461 -p:FSharpTestCompilerVersion=net40 +echo dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net472 -p:FSharpTestCompilerVersion=net40 + dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net472 -p:FSharpTestCompilerVersion=net40 if ERRORLEVEL 1 echo Error: TestBasicProvider failed && goto :failure echo dotnet test BasicProvider.Tests\BasicProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=netcoreapp3.1 -p:FSharpTestCompilerVersion=coreclr diff --git a/tests/EndToEndBuildTests/ComboProvider/ComboProvider.Tests/ComboProvider.Tests.fsproj b/tests/EndToEndBuildTests/ComboProvider/ComboProvider.Tests/ComboProvider.Tests.fsproj index deba0334dda2..21a2234258d5 100644 --- a/tests/EndToEndBuildTests/ComboProvider/ComboProvider.Tests/ComboProvider.Tests.fsproj +++ b/tests/EndToEndBuildTests/ComboProvider/ComboProvider.Tests/ComboProvider.Tests.fsproj @@ -5,6 +5,7 @@ netcoreapp3.1 $(TestTargetFramework) false + $(FSharpCoreShippedPackageVersion) NO_GENERATIVE diff --git a/tests/EndToEndBuildTests/ComboProvider/ComboProvider/ComboProvider.fsproj b/tests/EndToEndBuildTests/ComboProvider/ComboProvider/ComboProvider.fsproj index d76fef766d0e..68a5c70619b3 100644 --- a/tests/EndToEndBuildTests/ComboProvider/ComboProvider/ComboProvider.fsproj +++ b/tests/EndToEndBuildTests/ComboProvider/ComboProvider/ComboProvider.fsproj @@ -2,7 +2,8 @@ Library - netcoreapp3.1;net461 + netcoreapp3.1;net472 + $(FSharpCoreShippedPackageVersion) diff --git a/tests/EndToEndBuildTests/ComboProvider/TestComboProvider.cmd b/tests/EndToEndBuildTests/ComboProvider/TestComboProvider.cmd index 26f819d1b3e0..b8e68e241345 100644 --- a/tests/EndToEndBuildTests/ComboProvider/TestComboProvider.cmd +++ b/tests/EndToEndBuildTests/ComboProvider/TestComboProvider.cmd @@ -38,8 +38,8 @@ echo dotnet pack ComboProvider\ComboProvider.fsproj -o %~dp0artifacts -c %config dotnet pack ComboProvider\ComboProvider.fsproj -o %~dp0artifacts -c %configuration% -v minimal -p:FSharpTestCompilerVersion=net40 if ERRORLEVEL 1 echo Error: TestComboProvider failed && goto :failure -echo dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net461 -p:FSharpTestCompilerVersion=net40 - dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net461 -p:FSharpTestCompilerVersion=net40 +echo dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net472 -p:FSharpTestCompilerVersion=net40 + dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net472 -p:FSharpTestCompilerVersion=net40 if ERRORLEVEL 1 echo Error: TestComboProvider failed && goto :failure echo dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=netcoreapp3.1 -p:FSharpTestCompilerVersion=coreclr @@ -56,8 +56,8 @@ echo dotnet pack ComboProvider\ComboProvider.fsproj -o %~dp0artifacts -c %config dotnet pack ComboProvider\ComboProvider.fsproj -o %~dp0artifacts -c %configuration% -v minimal -p:FSharpTestCompilerVersion=coreclr if ERRORLEVEL 1 echo Error: TestComboProvider failed && goto :failure -echo dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net461 -p:FSharpTestCompilerVersion=net40 - dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net461 -p:FSharpTestCompilerVersion=net40 +echo dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net472 -p:FSharpTestCompilerVersion=net40 + dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -c %configuration% -v minimal -p:TestTargetFramework=net472 -p:FSharpTestCompilerVersion=net40 if ERRORLEVEL 1 echo Error: TestComboProvider failed && goto :failure echo dotnet test ComboProvider.Tests\ComboProvider.Tests.fsproj -v %configuration% -p:TestTargetFramework=netcoreapp3.1 -p:FSharpTestCompilerVersion=coreclr diff --git a/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdk.proj b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdk.proj new file mode 100644 index 000000000000..8dc457f7bb9f --- /dev/null +++ b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdk.proj @@ -0,0 +1,20 @@ + + + + + + <_NETCoreSdkIsPreview>false + + + + + + false + true + true + $(FSCorePackageVersion) + + + + + diff --git a/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdkDisablePreviewCheck.proj b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdkDisablePreviewCheck.proj new file mode 100644 index 000000000000..002ab3b54aad --- /dev/null +++ b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdkDisablePreviewCheck.proj @@ -0,0 +1,21 @@ + + + + + + <_NETCoreSdkIsPreview>false + + + + + + false + true + true + true + $(FSCorePackageVersion) + + + + + diff --git a/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdkEnablePreviewCheck.proj b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdkEnablePreviewCheck.proj new file mode 100644 index 000000000000..fe7c04007449 --- /dev/null +++ b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsNotPreviewSdkEnablePreviewCheck.proj @@ -0,0 +1,21 @@ + + + + + + <_NETCoreSdkIsPreview>false + + + + + + false + true + false + true + $(FSCorePackageVersion) + + + + + diff --git a/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdk.proj b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdk.proj new file mode 100644 index 000000000000..2a676575e2c2 --- /dev/null +++ b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdk.proj @@ -0,0 +1,20 @@ + + + + + + <_NETCoreSdkIsPreview>true + + + + + + false + true + true + $(FSharpCorePreviewPackageVersion) + + + + + diff --git a/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdkDisablePreviewCheck.proj b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdkDisablePreviewCheck.proj new file mode 100644 index 000000000000..247cf56d6ede --- /dev/null +++ b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdkDisablePreviewCheck.proj @@ -0,0 +1,21 @@ + + + + + + <_NETCoreSdkIsPreview>true + + + + + + false + true + true + true + $(FSharpCoreShippedPackageVersion) + + + + + diff --git a/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdkEnablePreviewCheck.proj b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdkEnablePreviewCheck.proj new file mode 100644 index 000000000000..f8a76401cc01 --- /dev/null +++ b/tests/fsharp/SDKTests/tests/DefaultFSharpCore - IsPreviewSdkEnablePreviewCheck.proj @@ -0,0 +1,21 @@ + + + + + + <_NETCoreSdkIsPreview>true + + + + + + false + true + false + true + $(FSharpCorePreviewPackageVersion) + + + + + diff --git a/tests/fsharp/SDKTests/tests/DefaultImplicitReferenceTest.proj b/tests/fsharp/SDKTests/tests/DefaultImplicitReferenceTest.proj deleted file mode 100644 index beabbba8a292..000000000000 --- a/tests/fsharp/SDKTests/tests/DefaultImplicitReferenceTest.proj +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - true - $(DefaultFSharpCorePackageVersion) - - true - $(DefaultValueTuplePackageVersion) - - - - - - diff --git a/tests/fsharp/SDKTests/tests/Test.props b/tests/fsharp/SDKTests/tests/Test.props index 8d29b210bfb5..ee01022ecc20 100644 --- a/tests/fsharp/SDKTests/tests/Test.props +++ b/tests/fsharp/SDKTests/tests/Test.props @@ -1,7 +1,8 @@ - + + net472 <_TargetFrameworkVersionWithoutV Condition="'$(_TargetFrameworkVersionWithoutV)' == ''">4.7.2 .NETFramework diff --git a/tests/fsharp/SDKTests/tests/Test.targets b/tests/fsharp/SDKTests/tests/Test.targets index 6f1638051d87..c018aa9a3265 100644 --- a/tests/fsharp/SDKTests/tests/Test.targets +++ b/tests/fsharp/SDKTests/tests/Test.targets @@ -32,6 +32,7 @@ + diff --git a/tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj b/tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj index 5581f3419b82..926080b65b58 100644 --- a/tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj +++ b/tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj @@ -1,8 +1,6 @@ netstandard2.0 - 4.6.* - 4.5.* From 129f9ecdb6023740c62b74b914d6ff5a2ea18f3e Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Mon, 3 Aug 2020 16:35:04 -0700 Subject: [PATCH 8/9] Fix CompilerLocation strings (#9859) --- .../FSharp.Compiler.Service.fsproj | 2 +- src/fsharp/CompileOps.fs | 3 +-- src/fsharp/FSComp.txt | 3 --- src/fsharp/FSharp.Build/FSBuild.txt | 1 - src/fsharp/FSharp.Build/FSharp.Build.fsproj | 1 + src/fsharp/FSharp.Build/xlf/FSBuild.txt.cs.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.de.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.es.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.fr.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.it.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.ko.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.pl.xlf | 5 ----- .../FSharp.Build/xlf/FSBuild.txt.pt-BR.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.ru.xlf | 5 ----- src/fsharp/FSharp.Build/xlf/FSBuild.txt.tr.xlf | 5 ----- .../FSharp.Build/xlf/FSBuild.txt.zh-Hans.xlf | 5 ----- .../FSharp.Build/xlf/FSBuild.txt.zh-Hant.xlf | 5 ----- .../FSharp.Compiler.Private.fsproj | 1 + .../Microsoft.DotNet.DependencyManager.fsproj | 4 ++-- src/fsharp/xlf/FSComp.txt.cs.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.de.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.es.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.fr.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.it.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.ja.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.ko.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.pl.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.pt-BR.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.ru.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.tr.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.zh-Hans.xlf | 15 --------------- src/fsharp/xlf/FSComp.txt.zh-Hant.xlf | 15 --------------- src/utils/CompilerLocationUtils.fs | 12 +++--------- src/utils/UtilsStrings.txt | 2 ++ src/utils/xlf/UtilsStrings.txt.cs.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.de.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.es.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.fr.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.it.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.ja.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.ko.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.pl.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.pt-BR.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.ru.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.tr.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.zh-Hans.xlf | 17 +++++++++++++++++ src/utils/xlf/UtilsStrings.txt.zh-Hant.xlf | 17 +++++++++++++++++ .../src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj | 1 + .../tests/Salsa/VisualFSharp.Salsa.fsproj | 1 + .../UnitTests/VisualFSharp.UnitTests.fsproj | 1 + 51 files changed, 235 insertions(+), 278 deletions(-) create mode 100644 src/utils/UtilsStrings.txt create mode 100644 src/utils/xlf/UtilsStrings.txt.cs.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.de.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.es.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.fr.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.it.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.ja.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.ko.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.pl.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.pt-BR.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.ru.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.tr.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.zh-Hans.xlf create mode 100644 src/utils/xlf/UtilsStrings.txt.zh-Hant.xlf diff --git a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj index 1877813d0672..ae8dba206749 100644 --- a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj +++ b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj @@ -10,7 +10,6 @@ $(DefineConstants);COMPILER $(DefineConstants);ENABLE_MONO_SUPPORT $(DefineConstants);NO_STRONG_NAMES - $(DefineConstants);LOCALIZATION_FSCOMP $(TargetFramework)\ $(TargetFramework)\ $(OtherFlags) /warnon:1182 @@ -289,6 +288,7 @@ ReferenceResolution/SimulatedMSBuildReferenceResolver.fs + CompilerLocation/CompilerLocationUtils.fs diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 3042ad88da81..95c6ec217433 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -2418,8 +2418,7 @@ type TcConfigBuilder = deterministic = false preferredUiLang = None lcid = None - // See bug 6071 for product banner spec - productNameForBannerText = FSComp.SR.buildProductName(FSharpEnvironment.FSharpBannerVersion) + productNameForBannerText = FSharpEnvironment.FSharpProductName showBanner = true showTimes = false showLoadedAssemblies = false diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 4005cab5efbe..9878ab603cf8 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -34,8 +34,6 @@ tupleRequiredInAbstractMethod,"\nA tuple type is required for one or more argume 203,buildInvalidWarningNumber,"Invalid warning number '%s'" 204,buildInvalidVersionString,"Invalid version string '%s'" 205,buildInvalidVersionFile,"Invalid version file '%s'" -buildProductName,"Microsoft (R) F# Compiler version %s" -buildProductNameCommunity,"F# Compiler for F# %s" 206,buildProblemWithFilename,"Problem with filename '%s': %s" 207,buildNoInputsSpecified,"No inputs specified" 209,buildPdbRequiresDebug,"The '--pdb' option requires the '--debug' option to be used" @@ -1493,7 +1491,6 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl 3351,chkFeatureNotRuntimeSupported,"Feature '%s' is not supported by target runtime." 3352,typrelInterfaceMemberNoMostSpecificImplementation,"Interface member '%s' does not have a most specific implementation." useSdkRefs,"Use reference assemblies for .NET framework references when available (Enabled by default)." -fSharpBannerVersion,"%s for F# %s" optsLangVersion,"Display the allowed values for language version, specify language version such as 'latest' or 'preview'" optsSupportedLangVersions,"Supported language versions:" nativeResourceFormatError,"Stream does not begin with a null resource and is not in '.RES' format." diff --git a/src/fsharp/FSharp.Build/FSBuild.txt b/src/fsharp/FSharp.Build/FSBuild.txt index 47d1ee7431d7..99209176b858 100644 --- a/src/fsharp/FSharp.Build/FSBuild.txt +++ b/src/fsharp/FSharp.Build/FSBuild.txt @@ -1,3 +1,2 @@ # FSharp.Build resource strings toolpathUnknown,"ToolPath is unknown; specify the path to the tool." -fSharpBannerVersion,"%s for F# %s" diff --git a/src/fsharp/FSharp.Build/FSharp.Build.fsproj b/src/fsharp/FSharp.Build/FSharp.Build.fsproj index 2f37cc454397..77e910e4db8a 100644 --- a/src/fsharp/FSharp.Build/FSharp.Build.fsproj +++ b/src/fsharp/FSharp.Build/FSharp.Build.fsproj @@ -18,6 +18,7 @@ + diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.cs.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.cs.xlf index e34a840079e4..374f1770bbb6 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.cs.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.cs.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - {0} pro F# {1} - - ToolPath is unknown; specify the path to the tool. Parametr ToolPath není známý. Zadejte cestu k nástroji. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.de.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.de.xlf index 8014aa45590e..c5a6cb42c9f6 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.de.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.de.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - {0} für F# {1} - - ToolPath is unknown; specify the path to the tool. ToolPath unbekannt. Geben Sie den Pfad zum Tool an. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.es.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.es.xlf index e70e526aa755..4791cd16b2c9 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.es.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.es.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - {0} para F# {1} - - ToolPath is unknown; specify the path to the tool. ToolPath se desconoce; especifique la ruta de acceso a la herramienta. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.fr.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.fr.xlf index 967ceecc6e47..79ddfd7ab241 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.fr.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.fr.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - {0} pour F# {1} - - ToolPath is unknown; specify the path to the tool. ToolPath est inconnu, spécifiez le chemin de l'outil. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.it.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.it.xlf index a0c02bd7658f..a7dd116bb445 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.it.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.it.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - {0} per F# {1} - - ToolPath is unknown; specify the path to the tool. Il valore di ToolPath è sconosciuto. Specificare il percorso dello strumento. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf index 558d9a4705d6..e26503cb96f1 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ja.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - F# {1} のための {0} - - ToolPath is unknown; specify the path to the tool. ToolPath が不明です。ツールンパスを指定します。 diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ko.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ko.xlf index d007db16c3c2..4c141658672b 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ko.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ko.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - F# {1}용 {0} - - ToolPath is unknown; specify the path to the tool. ToolPath를 알 수 없습니다. 도구 경로를 지정하세요. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.pl.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.pl.xlf index 565fdd2b8d21..b7734b58a758 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.pl.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.pl.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - {0} dla języka F# {1} - - ToolPath is unknown; specify the path to the tool. Właściwość ToolPath jest nieznana. Określ ścieżkę do narzędzia. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.pt-BR.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.pt-BR.xlf index 2d6ac4cf6ca5..865c593fd078 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.pt-BR.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.pt-BR.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - {0} para F# {1} - - ToolPath is unknown; specify the path to the tool. ToolPath desconhecido. Especifique o caminho para a ferramenta. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ru.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ru.xlf index 23dc6215bd4c..b1fef639ee03 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ru.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.ru.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - {0} для F# {1} - - ToolPath is unknown; specify the path to the tool. Путь к инструменту (ToolPath) неизвестен, укажите путь к инструменту. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.tr.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.tr.xlf index b56fc715900b..4dd43b355311 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.tr.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.tr.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - F# {1} için {0} - - ToolPath is unknown; specify the path to the tool. ToolPath bilinmiyor; aracın yolunu belirtin. diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.zh-Hans.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.zh-Hans.xlf index f514600395d9..bf5016a3685d 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.zh-Hans.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.zh-Hans.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - F# {1} 的 {0} - - ToolPath is unknown; specify the path to the tool. ToolPath 未知;请指定工具的路径。 diff --git a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.zh-Hant.xlf b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.zh-Hant.xlf index e3f63746fa46..0e30a5cfeca7 100644 --- a/src/fsharp/FSharp.Build/xlf/FSBuild.txt.zh-Hant.xlf +++ b/src/fsharp/FSharp.Build/xlf/FSBuild.txt.zh-Hant.xlf @@ -2,11 +2,6 @@ - - {0} for F# {1} - F # {1} 的 {0} - - ToolPath is unknown; specify the path to the tool. ToolPath 未知; 請指定工具的路徑。 diff --git a/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj b/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj index c527a50d4afe..270bc1a66370 100644 --- a/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj +++ b/src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj @@ -283,6 +283,7 @@ ReferenceResolution/SimulatedMSBuildReferenceResolver.fs + CompilerLocation\CompilerLocationUtils.fs diff --git a/src/fsharp/Microsoft.DotNet.DependencyManager/Microsoft.DotNet.DependencyManager.fsproj b/src/fsharp/Microsoft.DotNet.DependencyManager/Microsoft.DotNet.DependencyManager.fsproj index f593b99642e4..13e50e19679f 100644 --- a/src/fsharp/Microsoft.DotNet.DependencyManager/Microsoft.DotNet.DependencyManager.fsproj +++ b/src/fsharp/Microsoft.DotNet.DependencyManager/Microsoft.DotNet.DependencyManager.fsproj @@ -22,10 +22,10 @@ - + + - diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index 6b550c8e009b..0673cc54131c 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - {0} pro F# {1} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ Neplatný soubor verze {0} - - Microsoft (R) F# Compiler version {0} - Microsoft (R) F# Compiler verze {0} - - - - F# Compiler for F# {0} - Kompilátor jazyka F# pro F# {0} - - Problem with filename '{0}': {1} Problém s názvem souboru {0}: {1} diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index 89c85aff333c..b1bd351c90a3 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - {0} für F# {1} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ Ungültige Versionsdatei "{0}". - - Microsoft (R) F# Compiler version {0} - Microsoft (R) F# Compiler, Version {0} - - - - F# Compiler for F# {0} - F# Compiler für F# {0} - - Problem with filename '{0}': {1} Problem mit Dateinamen "{0}": {1} diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index ca4647c2e04d..4a557f8c505a 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - {0} para F# {1} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ Archivo de versión '{0}' no válido. - - Microsoft (R) F# Compiler version {0} - Compilador de Microsoft (R) F#, versión {0} - - - - F# Compiler for F# {0} - Compilador F# para F# {0} - - Problem with filename '{0}': {1} Problema con el nombre de archivo '{0}': {1}. diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index 053171fd5225..d64ac666877d 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - {0} pour F# {1} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ Fichier de version non valide '{0}' - - Microsoft (R) F# Compiler version {0} - Compilateur F# Microsoft (R) version {0} - - - - F# Compiler for F# {0} - Compilateur F# pour F# {0} - - Problem with filename '{0}': {1} Problème avec le nom de fichier '{0}' : {1} diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 432b3d6db2fc..8676352cf7fa 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - {0} per F# {1} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ File di versione '{0}' non valido - - Microsoft (R) F# Compiler version {0} - Compilatore Microsoft (R) F# versione {0} - - - - F# Compiler for F# {0} - Compilatore F# per F# {0} - - Problem with filename '{0}': {1} Problema con il nome di file '{0}': {1} diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index 03b666608517..756ffa2f602b 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - F# {1} のための {0} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ バージョン ファイル '{0}' が無効です - - Microsoft (R) F# Compiler version {0} - Microsoft (R) F# Compiler バージョン {0} - - - - F# Compiler for F# {0} - F# {0} の F# コンパイラ - - Problem with filename '{0}': {1} ファイル名 '{0}' に問題があります: {1} diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index eafd10e67b51..b137aef9efa1 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - F# {1}용 {0} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ 버전 파일 '{0}'이(가) 잘못되었습니다. - - Microsoft (R) F# Compiler version {0} - Microsoft (R) F# Compiler 버전 {0} - - - - F# Compiler for F# {0} - F# {0}에 대한 F# 컴파일러 - - Problem with filename '{0}': {1} 파일 이름 '{0}'에 문제가 있습니다. {1} diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index 4459d473e08c..2b18bfbb965f 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - {0} dla języka F# {1} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ Nieprawidłowy plik wersji „{0}” - - Microsoft (R) F# Compiler version {0} - Wersja {0} kompilatora języka Microsoft (R) F# - - - - F# Compiler for F# {0} - Kompilator języka F# dla języka F# {0} - - Problem with filename '{0}': {1} Problem z nazwą pliku „{0}”: {1} diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index 2f0e04e7a45f..af5c0df2ffae 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - {0} para F# {1} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ Arquivo de versão inválida '{0}' - - Microsoft (R) F# Compiler version {0} - Compilador Microsoft (R) F# versão {0} - - - - F# Compiler for F# {0} - Compilador F# para F# {0} - - Problem with filename '{0}': {1} Problema com nome de arquivo '{0}': {1} diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index f33cfdf1a9d2..79f2e14f95bc 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - {0} для F# {1} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ Недопустимый файл версии "{0}" - - Microsoft (R) F# Compiler version {0} - Microsoft (R) F# Compiler, версия {0} - - - - F# Compiler for F# {0} - Компилятор F# для F# {0} - - Problem with filename '{0}': {1} Ошибка в имени файла "{0}": {1} diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index 2849f71280ab..cdc850615fd9 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - F# {1} için {0} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ Geçersiz dosya sürümü '{0}' - - Microsoft (R) F# Compiler version {0} - Microsoft (R) F# Derleyicisi sürümü {0} - - - - F# Compiler for F# {0} - F# {0} için F# Derleyicisi - - Problem with filename '{0}': {1} Dosya adında hata: '{0}': {1} diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index 4bd5cc21c64a..c1fcf2bd350b 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - F# {1} 的 {0} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ 版本文件“{0}”无效 - - Microsoft (R) F# Compiler version {0} - Microsoft(R) F# 编译器版本 {0} - - - - F# Compiler for F# {0} - 适用于 F# {0} 的 F# 编译器 - - Problem with filename '{0}': {1} 文件名“{0}”存在问题: {1} diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 46d85486fa3f..a567a3177a8b 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -67,11 +67,6 @@ Assembly attribute '{0}' refers to a designer assembly '{1}' which cannot be loaded or doesn't exist. The exception reported was: {2} - {3} - - {0} for F# {1} - F # {1} 的 {0} - - applicative computation expressions applicative computation expressions @@ -437,16 +432,6 @@ 無效的版本檔案 '{0}' - - Microsoft (R) F# Compiler version {0} - Microsoft (R) F# 編譯器版本 {0} - - - - F# Compiler for F# {0} - 適用於 F# {0} 的 F# 編譯器 - - Problem with filename '{0}': {1} 檔名 '{0}' 有問題: {1} diff --git a/src/utils/CompilerLocationUtils.fs b/src/utils/CompilerLocationUtils.fs index eb581029ca85..58f9a03d1fb6 100644 --- a/src/utils/CompilerLocationUtils.fs +++ b/src/utils/CompilerLocationUtils.fs @@ -15,15 +15,9 @@ open Microsoft.FSharp.Core module internal FSharpEnvironment = /// The F# version reported in the banner -#if LOCALIZATION_FSBUILD - let FSharpBannerVersion = FSBuild.SR.fSharpBannerVersion(FSharp.BuildProperties.fsProductVersion, FSharp.BuildProperties.fsLanguageVersion) -#else -#if LOCALIZATION_FSCOMP - let FSharpBannerVersion = FSComp.SR.fSharpBannerVersion(FSharp.BuildProperties.fsProductVersion, FSharp.BuildProperties.fsLanguageVersion) -#else - let FSharpBannerVersion = sprintf "%s for F# %s" (FSharp.BuildProperties.fsProductVersion) (FSharp.BuildProperties.fsLanguageVersion) -#endif -#endif + let FSharpBannerVersion = UtilsStrings.SR.fSharpBannerVersion(FSharp.BuildProperties.fsProductVersion, FSharp.BuildProperties.fsLanguageVersion) + + let FSharpProductName = UtilsStrings.SR.buildProductName(FSharpBannerVersion) let versionOf<'t> = typeof<'t>.Assembly.GetName().Version.ToString() diff --git a/src/utils/UtilsStrings.txt b/src/utils/UtilsStrings.txt new file mode 100644 index 000000000000..7c6971436b7c --- /dev/null +++ b/src/utils/UtilsStrings.txt @@ -0,0 +1,2 @@ +buildProductName,"Microsoft (R) F# Compiler version %s" +fSharpBannerVersion,"%s for F# %s" \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.cs.xlf b/src/utils/xlf/UtilsStrings.txt.cs.xlf new file mode 100644 index 000000000000..7596abac27b2 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.cs.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.de.xlf b/src/utils/xlf/UtilsStrings.txt.de.xlf new file mode 100644 index 000000000000..bbac48e81500 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.de.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.es.xlf b/src/utils/xlf/UtilsStrings.txt.es.xlf new file mode 100644 index 000000000000..570040170dd9 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.es.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.fr.xlf b/src/utils/xlf/UtilsStrings.txt.fr.xlf new file mode 100644 index 000000000000..bdb1a00233ee --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.fr.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.it.xlf b/src/utils/xlf/UtilsStrings.txt.it.xlf new file mode 100644 index 000000000000..6897e5d91f28 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.it.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.ja.xlf b/src/utils/xlf/UtilsStrings.txt.ja.xlf new file mode 100644 index 000000000000..acf1b95908b3 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.ja.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.ko.xlf b/src/utils/xlf/UtilsStrings.txt.ko.xlf new file mode 100644 index 000000000000..54afe171c76d --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.ko.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.pl.xlf b/src/utils/xlf/UtilsStrings.txt.pl.xlf new file mode 100644 index 000000000000..948b605c131c --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.pl.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.pt-BR.xlf b/src/utils/xlf/UtilsStrings.txt.pt-BR.xlf new file mode 100644 index 000000000000..fc9eeb01c390 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.pt-BR.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.ru.xlf b/src/utils/xlf/UtilsStrings.txt.ru.xlf new file mode 100644 index 000000000000..449d63bdaef5 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.ru.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.tr.xlf b/src/utils/xlf/UtilsStrings.txt.tr.xlf new file mode 100644 index 000000000000..91ef9ad22305 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.tr.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.zh-Hans.xlf b/src/utils/xlf/UtilsStrings.txt.zh-Hans.xlf new file mode 100644 index 000000000000..89e1889ce0f3 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.zh-Hans.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/src/utils/xlf/UtilsStrings.txt.zh-Hant.xlf b/src/utils/xlf/UtilsStrings.txt.zh-Hant.xlf new file mode 100644 index 000000000000..6df9a338d0c9 --- /dev/null +++ b/src/utils/xlf/UtilsStrings.txt.zh-Hant.xlf @@ -0,0 +1,17 @@ + + + + + + Microsoft (R) F# Compiler version {0} + Microsoft (R) F# Compiler version {0} + + + + {0} for F# {1} + {0} for F# {1} + + + + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj b/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj index 28e4f314f5ac..1fd3eced2b64 100644 --- a/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj +++ b/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj @@ -23,6 +23,7 @@ + CompilerLocationUtils.fs diff --git a/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj b/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj index c3e21061e0b0..dedeb8bbe0f9 100644 --- a/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj +++ b/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj @@ -17,6 +17,7 @@ + CompilerLocationUtils.fs diff --git a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj index 3692a280de6a..4ce16d5e2705 100644 --- a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj +++ b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj @@ -24,6 +24,7 @@ Internal.Utilities.Collections.fs + Internal.Utilities.CompilerLocationUtils.fs From ae5c1dbd46bed0de2703b10ecf4fe3889cf5445a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Denuzi=C3=A8re?= Date: Tue, 4 Aug 2020 06:33:49 +0200 Subject: [PATCH 9/9] Further enhancements to nameof (#8754) * Implement `nameof x` as a constant pattern * Resolve ident to find `nameof` in patterns * fix build * fix build * re-enable tests * fix test * fix operators * align code * test and fix pattern matching * fix 8661, 7416 * fix tests and error messages * 'fix test' * 'fix test' * add message for C# and old compilers * fix build * suppress error 3501 when a compiler supports nameof Co-authored-by: Don Syme --- src/fsharp/AttributeChecking.fs | 6 +- src/fsharp/FSComp.txt | 3 +- src/fsharp/FSharp.Core/prim-types.fs | 5 +- src/fsharp/FSharp.Core/prim-types.fsi | 7 +- src/fsharp/NameResolution.fs | 122 ++++++++------- src/fsharp/NameResolution.fsi | 4 +- src/fsharp/TypeChecker.fs | 144 ++++++++++++------ tests/fsharp/core/nameof/preview/test.fsx | 69 ++++++++- .../NameOf/E_NameOfAdditionExpr.fs | 7 - .../DataExpressions/NameOf/env.lst | 1 - 10 files changed, 245 insertions(+), 123 deletions(-) delete mode 100644 tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAdditionExpr.fs diff --git a/src/fsharp/AttributeChecking.fs b/src/fsharp/AttributeChecking.fs index 075f70669ace..f7554e44c39f 100644 --- a/src/fsharp/AttributeChecking.fs +++ b/src/fsharp/AttributeChecking.fs @@ -299,7 +299,11 @@ let CheckFSharpAttributes (g:TcGlobals) attribs m = match namedArgs with | ExtractAttribNamedArg "IsError" (AttribBoolArg v) -> v | _ -> false - if isError && (not g.compilingFslib || n <> 1204) then ErrorD msg else WarnD msg + // If we are using a compiler that supports nameof then error 3501 is always suppressed. + // See attribute on FSharp.Core 'nameof' + if n = 3501 then CompleteD + elif isError && (not g.compilingFslib || n <> 1204) then ErrorD msg + else WarnD msg | _ -> CompleteD ) ++ (fun () -> diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 9878ab603cf8..e1fb144f1162 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -1515,4 +1515,5 @@ featureWitnessPassing,"witness passing for trait constraints in F# quotations" 3361,typrelInterfaceWithConcreteAndVariableObjectExpression,"You cannot implement the interface '%s' with the two instantiations '%s' and '%s' because they may unify." featureInterfacesWithMultipleGenericInstantiation,"interfaces with multiple generic instantiation" 3362,tcLiteralFieldAssignmentWithArg,"Cannot assign '%s' to a value marked literal" -3363,tcLiteralFieldAssignmentNoArg,"Cannot assign a value to another value marked literal" \ No newline at end of file +3363,tcLiteralFieldAssignmentNoArg,"Cannot assign a value to another value marked literal" +#3501 "This construct is not supported by your version of the F# compiler" CompilerMessage(ExperimentalAttributeMessages.NotSupportedYet, 3501, IsError=true) diff --git a/src/fsharp/FSharp.Core/prim-types.fs b/src/fsharp/FSharp.Core/prim-types.fs index 36567214f149..d912b8f97577 100644 --- a/src/fsharp/FSharp.Core/prim-types.fs +++ b/src/fsharp/FSharp.Core/prim-types.fs @@ -251,6 +251,9 @@ namespace Microsoft.FSharp.Core [] let RequiresPreview : string = "Experimental library feature, requires '--langversion:preview'" + [] + let NotSupportedYet : string = "This construct is not supported by your version of the F# compiler" + [] [] type ExperimentalAttribute(message:string) = @@ -4718,7 +4721,7 @@ namespace Microsoft.FSharp.Core [] let inline typeof<'T> = BasicInlinedOperations.typeof<'T> - [] + [] let inline nameof (_: 'T) : string = raise (Exception "may not call directly, should always be optimized away") [] diff --git a/src/fsharp/FSharp.Core/prim-types.fsi b/src/fsharp/FSharp.Core/prim-types.fsi index 449ac73f3cfb..3370b699150c 100644 --- a/src/fsharp/FSharp.Core/prim-types.fsi +++ b/src/fsharp/FSharp.Core/prim-types.fsi @@ -653,10 +653,11 @@ namespace Microsoft.FSharp.Core /// Indicates one or more adjustments to the compiled representation of an F# type or member member Flags : CompilationRepresentationFlags - module internal ExperimentalAttributeMessages = begin + module internal ExperimentalAttributeMessages = [] val RequiresPreview : string = "Experimental library feature, requires '--langversion:preview'" - end + [] + val NotSupportedYet : string = "This construct is not supported by your version of the F# compiler" /// This attribute is used to tag values that are part of an experimental library /// feature. @@ -2846,7 +2847,7 @@ namespace Microsoft.FSharp.Core val inline typeof<'T> : System.Type /// Returns the name of the given symbol. - [] + [] val inline nameof : 'T -> string /// An internal, library-only compiler intrinsic for compile-time diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 43d7d1e6f198..aeea75561726 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -2579,7 +2579,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified if first && id.idText = MangledGlobalName then match rest with | [] -> - error (Error(FSComp.SR.nrGlobalUsedOnlyAsFirstName(), id.idRange)) + raze (Error(FSComp.SR.nrGlobalUsedOnlyAsFirstName(), id.idRange)) | [next] -> ResolveExprLongIdentPrim sink ncenv false fullyQualified m ad nenv typeNameResInfo next [] isOpenDecl | id2 :: rest2 -> @@ -2603,11 +2603,12 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified let search = ChooseTyconRefInExpr (ncenv, m, ad, nenv, id, typeNameResInfo, resInfo, tcrefs) match AtMostOneResult m search with - | Result _ as res -> - let resInfo, item, rest = ForceRaise res + | Result (resInfo, item, rest) -> ResolutionInfo.SendEntityPathToSink(sink, ncenv, nenv, ItemOccurence.Use, ad, resInfo, ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) Some(item, rest) - | Exception e -> typeError <- Some e; None + | Exception e -> + typeError <- Some e + None | true, res -> let fresh = FreshenUnqualifiedItem ncenv m res @@ -2624,7 +2625,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified None match envSearch with - | Some res -> res + | Some res -> success res | None -> let innerSearch = // Check if it's a type name, e.g. a constructor call or a type instantiation @@ -2640,9 +2641,9 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified ctorSearch +++ implicitOpSearch - let resInfo, item, rest = + let res = match AtMostOneResult m innerSearch with - | Result _ as res -> ForceRaise res + | Result _ as res -> res | _ -> let failingCase = match typeError with @@ -2671,11 +2672,12 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified addToBuffer (e.Value.DisplayName + "." + id.idText) raze (UndefinedName(0, FSComp.SR.undefinedNameValueOfConstructor, id, suggestNamesAndTypes)) - ForceRaise failingCase - + failingCase + match res with + | Exception e -> raze e + | Result (resInfo, item, rest) -> ResolutionInfo.SendEntityPathToSink(sink, ncenv, nenv, ItemOccurence.Use, ad, resInfo, ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) - item, rest - + success (item, rest) // A compound identifier. // It still might be a value in the environment, or something in an F# module, namespace, type, or nested type @@ -2693,13 +2695,13 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified | _ -> false if ValIsInEnv id.idText then - nenv.eUnqualifiedItems.[id.idText], rest + success (nenv.eUnqualifiedItems.[id.idText], rest) else // Otherwise modules are searched first. REVIEW: modules and types should be searched together. // For each module referenced by 'id', search the module as if it were an F# module and/or a .NET namespace. let moduleSearch ad () = - ResolveLongIndentAsModuleOrNamespaceThen sink ResultCollectionSettings.AtMostOneResult ncenv.amap m fullyQualified nenv ad id rest isOpenDecl - (ResolveExprLongIdentInModuleOrNamespace ncenv nenv typeNameResInfo ad) + ResolveLongIndentAsModuleOrNamespaceThen sink ResultCollectionSettings.AtMostOneResult ncenv.amap m fullyQualified nenv ad id rest isOpenDecl + (ResolveExprLongIdentInModuleOrNamespace ncenv nenv typeNameResInfo ad) // REVIEW: somewhat surprisingly, this shows up on performance traces, with tcrefs non-nil. // This seems strange since we would expect in the vast majority of cases tcrefs is empty here. @@ -2717,59 +2719,59 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified NoResultsOrUsefulErrors let search = - let envSearch () = - match fullyQualified with - | FullyQualified -> - NoResultsOrUsefulErrors - | OpenQualified -> - match nenv.eUnqualifiedItems.TryGetValue id.idText with - | true, Item.UnqualifiedType _ - | false, _ -> NoResultsOrUsefulErrors - | true, res -> OneSuccess (resInfo, FreshenUnqualifiedItem ncenv m res, rest) - - moduleSearch ad () +++ tyconSearch ad +++ envSearch - - let resInfo, item, rest = + let envSearch () = + match fullyQualified with + | FullyQualified -> + NoResultsOrUsefulErrors + | OpenQualified -> + match nenv.eUnqualifiedItems.TryGetValue id.idText with + | true, Item.UnqualifiedType _ + | false, _ -> NoResultsOrUsefulErrors + | true, res -> OneSuccess (resInfo, FreshenUnqualifiedItem ncenv m res, rest) + + moduleSearch ad () +++ tyconSearch ad +++ envSearch + + let res = match AtMostOneResult m search with - | Result _ as res -> ForceRaise res + | Result _ as res -> res | _ -> let innerSearch = search +++ (moduleSearch AccessibleFromSomeFSharpCode) +++ (tyconSearch AccessibleFromSomeFSharpCode) let suggestEverythingInScope (addToBuffer: string -> unit) = - for kv in nenv.ModulesAndNamespaces fullyQualified do - for modref in kv.Value do - if IsEntityAccessible ncenv.amap m ad modref then - addToBuffer modref.DisplayName - addToBuffer modref.DemangledModuleOrNamespaceName + for kv in nenv.ModulesAndNamespaces fullyQualified do + for modref in kv.Value do + if IsEntityAccessible ncenv.amap m ad modref then + addToBuffer modref.DisplayName + addToBuffer modref.DemangledModuleOrNamespaceName - for e in nenv.TyconsByDemangledNameAndArity fullyQualified do - if IsEntityAccessible ncenv.amap m ad e.Value then - addToBuffer e.Value.DisplayName + for e in nenv.TyconsByDemangledNameAndArity fullyQualified do + if IsEntityAccessible ncenv.amap m ad e.Value then + addToBuffer e.Value.DisplayName - for e in nenv.eUnqualifiedItems do - if canSuggestThisItem e.Value then - addToBuffer e.Value.DisplayName + for e in nenv.eUnqualifiedItems do + if canSuggestThisItem e.Value then + addToBuffer e.Value.DisplayName match innerSearch with | Exception (UndefinedName(0, _, id1, suggestionsF)) when Range.equals id.idRange id1.idRange -> - let mergeSuggestions addToBuffer = - suggestionsF addToBuffer - suggestEverythingInScope addToBuffer - - let failingCase = raze (UndefinedName(0, FSComp.SR.undefinedNameValueNamespaceTypeOrModule, id, mergeSuggestions)) - ForceRaise failingCase - | Exception err -> ForceRaise(Exception err) - | Result (res :: _) -> ForceRaise(Result res) + let mergeSuggestions addToBuffer = + suggestionsF addToBuffer + suggestEverythingInScope addToBuffer + raze (UndefinedName(0, FSComp.SR.undefinedNameValueNamespaceTypeOrModule, id, mergeSuggestions)) + | Exception err -> raze err + | Result (res :: _) -> success res | Result [] -> - let failingCase = raze (UndefinedName(0, FSComp.SR.undefinedNameValueNamespaceTypeOrModule, id, suggestEverythingInScope)) - ForceRaise failingCase + raze (UndefinedName(0, FSComp.SR.undefinedNameValueNamespaceTypeOrModule, id, suggestEverythingInScope)) - ResolutionInfo.SendEntityPathToSink(sink, ncenv, nenv, ItemOccurence.Use, ad, resInfo, ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) - item, rest + match res with + | Exception e -> raze e + | Result (resInfo, item, rest) -> + ResolutionInfo.SendEntityPathToSink(sink, ncenv, nenv, ItemOccurence.Use, ad, resInfo, ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) + success (item, rest) let ResolveExprLongIdent sink (ncenv: NameResolver) m ad nenv typeNameResInfo lid = match lid with - | [] -> error (Error(FSComp.SR.nrInvalidExpression(textOfLid lid), m)) + | [] -> raze (Error(FSComp.SR.nrInvalidExpression(textOfLid lid), m)) | id :: rest -> ResolveExprLongIdentPrim sink ncenv true OpenQualified m ad nenv typeNameResInfo id rest false //------------------------------------------------------------------------- @@ -3414,15 +3416,17 @@ type AfterResolution = /// /// Called for 'TypeName.Bar' - for VS IntelliSense, we can filter out instance members from method groups let ResolveLongIdentAsExprAndComputeRange (sink: TcResultsSink) (ncenv: NameResolver) wholem ad nenv typeNameResInfo lid = - let item1, rest = ResolveExprLongIdent sink ncenv wholem ad nenv typeNameResInfo lid + match ResolveExprLongIdent sink ncenv wholem ad nenv typeNameResInfo lid with + | Exception e -> Exception e + | Result (item1, rest) -> let itemRange = ComputeItemRange wholem lid rest let item = FilterMethodGroups ncenv itemRange item1 true match item1, item with | Item.MethodGroup(name, minfos1, _), Item.MethodGroup(_, [], _) when not (isNil minfos1) -> - error(Error(FSComp.SR.methodIsNotStatic name, wholem)) - | _ -> () + raze(Error(FSComp.SR.methodIsNotStatic name, wholem)) + | _ -> // Fake idents e.g. 'Microsoft.FSharp.Core.None' have identical ranges for each part let isFakeIdents = @@ -3462,7 +3466,7 @@ let ResolveLongIdentAsExprAndComputeRange (sink: TcResultsSink) (ncenv: NameReso callSink (item, emptyTyparInst) AfterResolution.DoNothing - item, itemRange, rest, afterResolution + success (item, itemRange, rest, afterResolution) let (|NonOverridable|_|) namedItem = match namedItem with @@ -3470,8 +3474,6 @@ let (|NonOverridable|_|) namedItem = | Item.Property(_, pinfos) when pinfos |> List.exists(fun pinfo -> pinfo.IsVirtualProperty) -> None | _ -> Some () - - /// Called for 'expression.Bar' - for VS IntelliSense, we can filter out static members from method groups /// Also called for 'GenericType.Bar' - for VS IntelliSense, we can filter out non-static members from method groups let ResolveExprDotLongIdentAndComputeRange (sink: TcResultsSink) (ncenv: NameResolver) wholem ad nenv ty lid findFlag thisIsActuallyATyAppNotAnExpr = @@ -3571,7 +3573,9 @@ let IsUnionCaseUnseen ad g amap m (ucref: UnionCaseRef) = let ItemIsUnseen ad g amap m item = match item with - | Item.Value x -> IsValUnseen ad g m x + | Item.Value x -> + let isUnseenNameOfOperator = valRefEq g g.nameof_vref x && not (g.langVersion.SupportsFeature LanguageFeature.NameOf) + isUnseenNameOfOperator || IsValUnseen ad g m x | Item.UnionCase(x, _) -> IsUnionCaseUnseen ad g amap m x.UnionCaseRef | Item.ExnCase x -> IsTyconUnseen ad g amap m x | _ -> false diff --git a/src/fsharp/NameResolution.fsi b/src/fsharp/NameResolution.fsi index 685871c056a8..7caa8321a026 100755 --- a/src/fsharp/NameResolution.fsi +++ b/src/fsharp/NameResolution.fsi @@ -545,7 +545,7 @@ val internal ResolveTypeLongIdent : TcResultsSink -> NameResol val internal ResolveField : TcResultsSink -> NameResolver -> NameResolutionEnv -> AccessorDomain -> TType -> Ident list * Ident -> Ident list -> FieldResolution list /// Resolve a long identifier occurring in an expression position -val internal ResolveExprLongIdent : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item * Ident list +val internal ResolveExprLongIdent : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> ResultOrException /// Resolve a (possibly incomplete) long identifier to a loist of possible class or record fields val internal ResolvePartialLongIdentToClassOrRecdFields : NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> string list -> bool -> Item list @@ -571,7 +571,7 @@ type AfterResolution = | RecordResolution of Item option * (TyparInst -> unit) * (MethInfo * PropInfo option * TyparInst -> unit) * (unit -> unit) /// Resolve a long identifier occurring in an expression position. -val internal ResolveLongIdentAsExprAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item * range * Ident list * AfterResolution +val internal ResolveLongIdentAsExprAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> ResultOrException /// Resolve a long identifier occurring in an expression position, qualified by a type. val internal ResolveExprDotLongIdentAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TType -> Ident list -> FindMemberFlag -> bool -> Item * range * Ident list * AfterResolution diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 919c5b0ab7ad..34ba5ba884b7 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -3204,7 +3204,7 @@ let (|JoinRelation|_|) cenv env (e: SynExpr) = let isOpName opName vref s = (s = opName) && match ResolveExprLongIdent cenv.tcSink cenv.nameResolver m ad env.eNameResEnv TypeNameResolutionInfo.Default [ident(opName, m)] with - | Item.Value vref2, [] -> valRefEq cenv.g vref vref2 + | Result (Item.Value vref2, []) -> valRefEq cenv.g vref vref2 | _ -> false match e with @@ -5398,12 +5398,50 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p let args = getArgPatterns () TcPatterns warnOnUpper cenv env vFlags (tpenv, names, takenNames) (NewInferenceTypes args) args + // Note we parse arguments to parameterized pattern labels as patterns, not expressions. + // This means the range of syntactic expression forms that can be used here is limited. + let rec convSynPatToSynExpr x = + match x with + | SynPat.FromParseError(p, _) -> convSynPatToSynExpr p + | SynPat.Const (c, m) -> SynExpr.Const (c, m) + | SynPat.Named (SynPat.Wild _, id, _, None, _) -> SynExpr.Ident id + | SynPat.Typed (p, cty, m) -> SynExpr.Typed (convSynPatToSynExpr p, cty, m) + | SynPat.LongIdent (LongIdentWithDots(longId, dotms) as lidwd, _, _tyargs, args, None, m) -> + let args = match args with SynArgPats.Pats args -> args | _ -> failwith "impossible: active patterns can be used only with SynConstructorArgs.Pats" + let e = + if dotms.Length = longId.Length then + let e = SynExpr.LongIdent (false, LongIdentWithDots(longId, List.truncate (dotms.Length - 1) dotms), None, m) + SynExpr.DiscardAfterMissingQualificationAfterDot (e, unionRanges e.Range (List.last dotms)) + else SynExpr.LongIdent (false, lidwd, None, m) + List.fold (fun f x -> mkSynApp1 f (convSynPatToSynExpr x) m) e args + | SynPat.Tuple (isStruct, args, m) -> SynExpr.Tuple (isStruct, List.map convSynPatToSynExpr args, [], m) + | SynPat.Paren (p, _) -> convSynPatToSynExpr p + | SynPat.ArrayOrList (isArray, args, m) -> SynExpr.ArrayOrList (isArray,List.map convSynPatToSynExpr args, m) + | SynPat.QuoteExpr (e,_) -> e + | SynPat.Null m -> SynExpr.Null m + | _ -> error(Error(FSComp.SR.tcInvalidArgForParameterizedPattern(), x.Range)) + + let isNameof (id: Ident) = + id.idText = "nameof" && + try + match ResolveExprLongIdent cenv.tcSink cenv.nameResolver m ad env.NameEnv TypeNameResolutionInfo.Default [id] with + | Result (Item.Value vref, _) -> valRefEq cenv.g vref cenv.g.nameof_vref + | _ -> false + with _ -> false + match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver warnOnUpperForId false m ad env.NameEnv TypeNameResolutionInfo.Default longId with | Item.NewDef id -> - let _, acc = tcArgPatterns () match getArgPatterns () with - | [] -> TcPat warnOnUpperForId cenv env topValInfo vFlags acc ty (mkSynPatVar vis id) + | [] -> + TcPat warnOnUpperForId cenv env topValInfo vFlags (tpenv, names, takenNames) ty (mkSynPatVar vis id) + + | [arg] + when cenv.g.langVersion.SupportsFeature LanguageFeature.NameOf && isNameof id -> + match TcNameOfExpr cenv env tpenv (convSynPatToSynExpr arg) with + | Expr.Const(c, m, _) -> (fun _ -> TPat_const (c, m)), (tpenv, names, takenNames) + | _ -> failwith "Impossible: TcNameOfExpr must return an Expr.Const" | _ -> + let _, acc = tcArgPatterns () errorR (UndefinedName (0, FSComp.SR.undefinedNamePatternDiscriminator, id, NoSuggestions)) (fun _ -> TPat_error m), acc @@ -5438,29 +5476,6 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p if not (isNil activePatArgsAsSynPats) && apinfo.ActiveTags.Length <> 1 then errorR (Error (FSComp.SR.tcRequireActivePatternWithOneResult (), m)) - // Parse the arguments to an active pattern - // Note we parse arguments to parameterized pattern labels as patterns, not expressions. - // This means the range of syntactic expression forms that can be used here is limited. - let rec convSynPatToSynExpr x = - match x with - | SynPat.FromParseError (p, _) -> convSynPatToSynExpr p - | SynPat.Const (c, m) -> SynExpr.Const (c, m) - | SynPat.Named (SynPat.Wild _, id, _, None, _) -> SynExpr.Ident id - | SynPat.Typed (p, cty, m) -> SynExpr.Typed (convSynPatToSynExpr p, cty, m) - | SynPat.LongIdent (LongIdentWithDots (longId, dotms) as lidwd, _, _tyargs, args, None, m) -> - let args = match args with SynArgPats.Pats args -> args | _ -> failwith "impossible: active patterns can be used only with SynArgPats.Pats" - let e = - if dotms.Length = longId.Length then - let e = SynExpr.LongIdent (false, LongIdentWithDots(longId, List.truncate (dotms.Length - 1) dotms), None, m) - SynExpr.DiscardAfterMissingQualificationAfterDot (e, unionRanges e.Range (List.last dotms)) - else SynExpr.LongIdent (false, lidwd, None, m) - List.fold (fun f x -> mkSynApp1 f (convSynPatToSynExpr x) m) e args - | SynPat.Tuple (isStruct, args, m) -> SynExpr.Tuple (isStruct, List.map convSynPatToSynExpr args, [], m) - | SynPat.Paren (p, _) -> convSynPatToSynExpr p - | SynPat.ArrayOrList (isArray, args, m) -> SynExpr.ArrayOrList (isArray,List.map convSynPatToSynExpr args, m) - | SynPat.QuoteExpr (e,_) -> e - | SynPat.Null m -> SynExpr.Null m - | _ -> error(Error(FSComp.SR.tcInvalidArgForParameterizedPattern(), x.Range)) let activePatArgsAsSynExprs = List.map convSynPatToSynExpr activePatArgsAsSynPats let activePatResTys = NewInferenceTypes apinfo.Names @@ -9290,26 +9305,47 @@ and TcNameOfExpr cenv env tpenv (synArg: SynExpr) = let m = cleanSynArg.Range let rec check overallTyOpt resultOpt expr (delayed: DelayedItem list) = match expr with - | LongOrSingleIdent (false, (LongIdentWithDots(longId, _) as lidd), _, _) -> + | LongOrSingleIdent (false, (LongIdentWithDots(longId, _)), _, _) -> + let ad = env.eAccessRights let result = defaultArg resultOpt (List.last longId) - let resolvedToModuleOrNamespaceName = - if delayed.IsEmpty then - let id,rest = List.headAndTail longId - match ResolveLongIndentAsModuleOrNamespaceOrStaticClass cenv.tcSink ResultCollectionSettings.AllResults cenv.amap m false true OpenQualified env.eNameResEnv ad id rest true with - | Result modref when delayed.IsEmpty && modref |> List.exists (p23 >> IsEntityAccessible cenv.amap m ad) -> - true // resolved to a module or namespace, done with checks - | _ -> - false - else + + // Nameof resolution resolves to a symbol and in general we make that the same symbol as + // would resolve if the long ident was used as an expression at the given location. + // + // So we first check if the first identifier resolves as an expression, if so commit and and resolve. + // + // However we don't commit for a type names - nameof allows 'naked' type names and thus all type name + // resolutions are checked separately in the next step. + let typeNameResInfo = GetLongIdentTypeNameInfo delayed + let nameResolutionResult = ResolveLongIdentAsExprAndComputeRange cenv.tcSink cenv.nameResolver (rangeOfLid longId) ad env.eNameResEnv typeNameResInfo longId + let resolvesAsExpr = + match nameResolutionResult with + | Result ((item, _, _, _) as res) + when + (match item with + | Item.Types _ + | Item.DelegateCtor _ + | Item.CtorGroup _ + | Item.FakeInterfaceCtor _ -> false + | _ -> true) -> + let overallTy = match overallTyOpt with None -> NewInferenceType() | Some t -> t + let _, _ = TcItemThen cenv overallTy env tpenv res delayed + true + | _ -> false - if resolvedToModuleOrNamespaceName then result else + if resolvesAsExpr then result else + // If it's not an expression then try to resolve it as a type name let resolvedToTypeName = if (match delayed with [DelayedTypeApp _] | [] -> true | _ -> false) then let (TypeNameResolutionInfo(_, staticArgsInfo)) = GetLongIdentTypeNameInfo delayed match ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.UseInAttribute OpenQualified env.eNameResEnv ad longId staticArgsInfo PermitDirectReferenceToGeneratedType.No with - | Result tcref when (match delayed with [DelayedTypeApp _] | [] -> true | _ -> false) && IsEntityAccessible cenv.amap m ad tcref -> + | Result tcref when IsEntityAccessible cenv.amap m ad tcref -> + match delayed with + | [DelayedTypeApp (tyargs, _, mExprAndTypeArgs)] -> + TcTypeApp cenv NewTyparsOK CheckCxs ItemOccurence.UseInType env tpenv mExprAndTypeArgs tcref [] tyargs |> ignore + | _ -> () true // resolved to a type name, done with checks | _ -> false @@ -9317,11 +9353,22 @@ and TcNameOfExpr cenv env tpenv (synArg: SynExpr) = false if resolvedToTypeName then result else - let overallTy = match overallTyOpt with None -> NewInferenceType() | Some t -> t - - // This will raise an error if resolution doesn't succeed - let _, _ = TcLongIdentThen cenv overallTy env tpenv lidd delayed - result // checked as an expression, done with checks + // If it's not an expression or type name then resolve it as a module + let resolvedToModuleOrNamespaceName = + if delayed.IsEmpty then + let id,rest = List.headAndTail longId + match ResolveLongIndentAsModuleOrNamespaceOrStaticClass cenv.tcSink ResultCollectionSettings.AllResults cenv.amap m false true OpenQualified env.eNameResEnv ad id rest true with + | Result modref when delayed.IsEmpty && modref |> List.exists (p23 >> IsEntityAccessible cenv.amap m ad) -> + true // resolved to a module or namespace, done with checks + | _ -> + false + else + false + if resolvedToModuleOrNamespaceName then result else + + ForceRaise nameResolutionResult |> ignore + // If that didn't give aan exception then raise a generic error + error (Error(FSComp.SR.expressionHasNoName(), m)) // expr allowed, even with qualifications | SynExpr.TypeApp (hd, _, types, _, _, _, m) -> @@ -9418,7 +9465,9 @@ and TcLongIdentThen cenv overallTy env tpenv (LongIdentWithDots(longId, _)) dela let ad = env.eAccessRights let typeNameResInfo = GetLongIdentTypeNameInfo delayed - let nameResolutionResult = ResolveLongIdentAsExprAndComputeRange cenv.tcSink cenv.nameResolver (rangeOfLid longId) ad env.eNameResEnv typeNameResInfo longId + let nameResolutionResult = + ResolveLongIdentAsExprAndComputeRange cenv.tcSink cenv.nameResolver (rangeOfLid longId) ad env.eNameResEnv typeNameResInfo longId + |> ForceRaise TcItemThen cenv overallTy env tpenv nameResolutionResult delayed //------------------------------------------------------------------------- @@ -12141,7 +12190,7 @@ and AnalyzeAndMakeAndPublishRecursiveValue overridesOK isGeneratedEventVal cenv let prelimValScheme = ValScheme(bindingId, prelimTyscheme, topValInfo, memberInfoOpt, false, inlineFlag, NormalVal, vis, false, false, false, hasDeclaredTypars) // Check the literal r.h.s., if any - let _, konst = TcLiteral cenv ty env tpenv (bindingAttribs, bindingExpr) + let _, konst = TcLiteral cenv ty envinner tpenv (bindingAttribs, bindingExpr) let extraBindings, extraValues, tpenv, recBindIdx = let extraBindings = @@ -15269,7 +15318,10 @@ module TcExceptionDeclarations = let repr = match reprIdOpt with | Some longId -> - match ResolveExprLongIdent cenv.tcSink cenv.nameResolver m ad env.eNameResEnv TypeNameResolutionInfo.Default longId with + let resolution = + ResolveExprLongIdent cenv.tcSink cenv.nameResolver m ad env.eNameResEnv TypeNameResolutionInfo.Default longId + |> ForceRaise + match resolution with | Item.ExnCase exnc, [] -> CheckTyconAccessible cenv.amap m env.eAccessRights exnc |> ignore if not (isNil args') then diff --git a/tests/fsharp/core/nameof/preview/test.fsx b/tests/fsharp/core/nameof/preview/test.fsx index 6b6da1a17b00..3f69e973cfa6 100644 --- a/tests/fsharp/core/nameof/preview/test.fsx +++ b/tests/fsharp/core/nameof/preview/test.fsx @@ -240,11 +240,17 @@ type OperatorNameOfTests() = member this.``lookup name of + operator`` () = let b = nameof(+) - Assert.AreEqual("op_Addition",b) + Assert.AreEqual("+",b) + let b2 = nameof(op_Addition) + Assert.AreEqual("op_Addition",b2) + let b3 = nameof(FSharp.Core.Operators.(+)) + Assert.AreEqual("+",b3) + let b4 = nameof(FSharp.Core.Operators.op_Addition) + Assert.AreEqual("op_Addition",b4) member this.``lookup name of |> operator`` () = let a = nameof(|>) - let result = Assert.AreEqual("op_PipeRight",a) + let result = Assert.AreEqual("|>",a) let b = nameof(op_PipeRight) result || Assert.AreEqual("op_PipeRight",b) @@ -294,6 +300,30 @@ type Person = | x when x = nameof __.Age -> { __ with Age = value :?> int } | _ -> __ +type GenericClassNameOfTests<'TTT>() = + + static member ``can get name of class type parameter`` () = + let b = nameof<'TTT> + Assert.AreEqual("TTT", b) + +type GenericClassNameOfTests2<[] 'TTT>() = + + static member ``can get name of class unit of measure type parameter`` () = + let b = nameof<'TTT> + Assert.AreEqual("TTT", b) + +module RecTest = + let rec [] two = 2 + and twoName = nameof(two) + let ``can get name of recursive literal`` () = + Assert.AreEqual("two", twoName) + +module rec RecTest2 = + let [] two = 2 + let twoName = nameof(two) + let ``can get name of literal in recursive module`` () = + Assert.AreEqual("two", twoName) + do test "local variable name lookup" (BasicNameOfTests.``local variable name lookup`` ()) do test "local int function name" (BasicNameOfTests.``local int function name`` ()) do test "local curried function name" (BasicNameOfTests.``local curried function name`` ()) @@ -343,6 +373,41 @@ do test "lookup name of a generic class" ((NameOfOperatorForGener do test "user defined nameof should shadow the operator"(UserDefinedNameOfTests.``user defined nameof should shadow the operator`` ()) +do test "can get name of class type parameter"(GenericClassNameOfTests.``can get name of class type parameter`` ()) +do test "can get name of class type parameter"(GenericClassNameOfTests2.``can get name of class unit of measure type parameter`` ()) +do test "can get name of recursive literal"(RecTest.``can get name of recursive literal`` ()) +do test "can get name of literal in recursive module"(RecTest2.``can get name of literal in recursive module`` ()) + +module PatternMatchingWithNameof = + /// Simplified version of EventStore's API + type RecordedEvent = { EventType: string; Data: string } + + /// My concrete type: + type MyEvent = + | A of string + | B of string + + let deserialize (e: RecordedEvent) : MyEvent = + match e.EventType with + | nameof A -> A e.Data + | nameof B -> B e.Data + | t -> failwithf "Invalid EventType: %s" t + + let getData event = + match event with + | A amsg -> amsg + | B bmsg -> bmsg + + let re1 = { EventType = nameof A; Data = "hello" } + let re2 = { EventType = nameof B; Data = "world" } + + let a = deserialize re1 + let b = deserialize re2 + + check "fklwveoihwq1" (getData a) re1.Data + check "fklwveoihwq2" (getData b) re2.Data + + #if TESTS_AS_APP let RUN() = match !failures with diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAdditionExpr.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAdditionExpr.fs deleted file mode 100644 index 2fd34fa161ad..000000000000 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAdditionExpr.fs +++ /dev/null @@ -1,7 +0,0 @@ -// #Regression #Conformance #DataExpressions -// Verify that nameof doesn't work on const string -//Expression does not have a name. - -let x = nameof(1+2) - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/env.lst b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/env.lst index 9d473234e60f..2d918a0ca142 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/env.lst +++ b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/env.lst @@ -4,7 +4,6 @@ SOURCE=E_NameOfIntegerAppliedFunction.fs SCFLAGS="--langversion:preview" # E_NameOfIntegerAppliedFunction.fs SOURCE=E_NameOfPartiallyAppliedFunction.fs SCFLAGS="--langversion:preview" # E_NameOfPartiallyAppliedFunction.fs SOURCE=E_NameOfDictLookup.fs SCFLAGS="--langversion:preview" # E_NameOfDictLookup.fs - SOURCE=E_NameOfAdditionExpr.fs SCFLAGS="--langversion:preview" # E_NameOfAdditionExpr.fs SOURCE=E_NameOfParameterAppliedFunction.fs SCFLAGS="--langversion:preview" # E_NameOfParameterAppliedFunction.fs SOURCE=E_NameOfAsAFunction.fs SCFLAGS="--langversion:preview" # E_NameOfAsAFunction.fs SOURCE=E_NameOfWithPipe.fs SCFLAGS="--langversion:preview" # E_NameOfWithPipe.fs