From 0f24b3ef42cae5d48cdafc0b80dee92de1db10b6 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2019 10:23:25 -0700 Subject: [PATCH 01/22] Update dependencies from https://github.com/dotnet/arcade build 20190715.4 (#7240) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19365.4 --- eng/Version.Details.xml | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 119dfcd3a41..19eab0f3c7e 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 0c81c2bbdc49749e9940bc8858ebd16026d51277 + fb27fd4d8a2b67d4333e33d4b898c65171c9f3c1 diff --git a/global.json b/global.json index 81be3571adc..616ab02e470 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19364.1", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19365.4", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From 863ec255f4345eb0622673414cdf3052494c5ab4 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Tue, 16 Jul 2019 20:31:30 +0300 Subject: [PATCH 02/22] Moving UpcastDowncastTests over to NUnit (#7229) * Moving UpcastDowncastTests over to NUnit * missing new line --- .../ErrorMessages/UpcastDowncastTests.fs | 51 +++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../Warnings/DowncastInsteadOfUpcast.fs | 9 ---- .../UpcastFunctionInsteadOfDowncast.fs | 9 ---- .../Warnings/UpcastInsteadOfDowncast.fs | 9 ---- tests/fsharpqa/Source/Warnings/env.lst | 3 -- 6 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 tests/fsharp/Compiler/ErrorMessages/UpcastDowncastTests.fs delete mode 100644 tests/fsharpqa/Source/Warnings/DowncastInsteadOfUpcast.fs delete mode 100644 tests/fsharpqa/Source/Warnings/UpcastFunctionInsteadOfDowncast.fs delete mode 100644 tests/fsharpqa/Source/Warnings/UpcastInsteadOfDowncast.fs diff --git a/tests/fsharp/Compiler/ErrorMessages/UpcastDowncastTests.fs b/tests/fsharp/Compiler/ErrorMessages/UpcastDowncastTests.fs new file mode 100644 index 00000000000..739f841bfca --- /dev/null +++ b/tests/fsharp/Compiler/ErrorMessages/UpcastDowncastTests.fs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module ``Upcast and Downcast`` = + + [] + let ``Downcast Instead Of Upcast``() = + CompilerAssert.TypeCheckSingleError + """ +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" + + [] + let ``Upcast Instead Of Downcast``() = + CompilerAssert.TypeCheckWithErrors + """ +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." + |] + + [] + let ``Upcast Function Instead Of Downcast``() = + CompilerAssert.TypeCheckWithErrors + """ +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'." + |] diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 55fad20ad29..ec2a852b131 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -36,6 +36,7 @@ + diff --git a/tests/fsharpqa/Source/Warnings/DowncastInsteadOfUpcast.fs b/tests/fsharpqa/Source/Warnings/DowncastInsteadOfUpcast.fs deleted file mode 100644 index a815425e294..00000000000 --- a/tests/fsharpqa/Source/Warnings/DowncastInsteadOfUpcast.fs +++ /dev/null @@ -1,9 +0,0 @@ -// #Warnings -//Type constraint mismatch. The type - -open System.Collections.Generic - -let orig = Dictionary() :> IDictionary -let c = orig :> Dictionary - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/UpcastFunctionInsteadOfDowncast.fs b/tests/fsharpqa/Source/Warnings/UpcastFunctionInsteadOfDowncast.fs deleted file mode 100644 index 6bc8c54c124..00000000000 --- a/tests/fsharpqa/Source/Warnings/UpcastFunctionInsteadOfDowncast.fs +++ /dev/null @@ -1,9 +0,0 @@ -// #Warnings -//The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. Consider using 'upcast' instead of 'downcast'. - -open System.Collections.Generic - -let orig = Dictionary() -let c : IDictionary = downcast orig - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/UpcastInsteadOfDowncast.fs b/tests/fsharpqa/Source/Warnings/UpcastInsteadOfDowncast.fs deleted file mode 100644 index 00962a1521b..00000000000 --- a/tests/fsharpqa/Source/Warnings/UpcastInsteadOfDowncast.fs +++ /dev/null @@ -1,9 +0,0 @@ -// #Warnings -//The conversion from Dictionary to IDictionary is a compile-time safe upcast, not a downcast. - -open System.Collections.Generic - -let orig = Dictionary() -let c = orig :?> IDictionary - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/env.lst b/tests/fsharpqa/Source/Warnings/env.lst index 350dc92a0d9..3a31070e079 100644 --- a/tests/fsharpqa/Source/Warnings/env.lst +++ b/tests/fsharpqa/Source/Warnings/env.lst @@ -38,9 +38,6 @@ SOURCE=SuggestToUseIndexer.fs # SuggestToUseIndexer.fs SOURCE=RefCellInsteadOfNot.fs # RefCellInsteadOfNot.fs SOURCE=RefCellInsteadOfNot2.fs # RefCellInsteadOfNot2.fs - SOURCE=UpcastInsteadOfDowncast.fs # UpcastInsteadOfDowncast.fs - SOURCE=UpcastFunctionInsteadOfDowncast.fs # UpcastFunctionInsteadOfDowncast.fs - SOURCE=DowncastInsteadOfUpcast.fs # DowncastInsteadOfUpcast.fs SOURCE=RuntimeTypeTestInPattern.fs # RuntimeTypeTestInPattern.fs SOURCE=RuntimeTypeTestInPattern2.fs # RuntimeTypeTestInPattern2.fs SOURCE=WarnIfExpressionResultUnused.fs # WarnIfExpressionResultUnused.fs From c8bac72813d88e048979dd7160d7edf82700d67a Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2019 10:24:11 -0700 Subject: [PATCH 03/22] Update dependencies from https://github.com/dotnet/arcade build 20190716.4 (#7245) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19366.4 --- eng/Version.Details.xml | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 19eab0f3c7e..86d49308d4e 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - fb27fd4d8a2b67d4333e33d4b898c65171c9f3c1 + 0dd5e2025f0049c133a8706f40e4463b193e5d17 diff --git a/global.json b/global.json index 616ab02e470..7d6048be9fe 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19365.4", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19366.4", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From 69805873b502337e8e3d2b1346796cc8ce8b7981 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Wed, 17 Jul 2019 19:44:10 +0200 Subject: [PATCH 04/22] Move ErrorMessages/NameResolution Tests to NUnit (#7237) * Mark name resoltion error message tests for port to NUnit * Add Nunit tests for FieldNotInRecord, RecordFieldProposal, and GlobalQualifierAfterDot * Fix expected error message in FieldNotInRecord Compiler test * Change global Qualifier after dot test back to original fsharpqa version. Needs seperate assert function for parsing errors instead of typechecking * Remove unnecessary double ticks from NameResolution tests --- .../ErrorMessages/NameResolutionTests.fs | 45 +++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../NameResolution/E_FieldNotInRecord.fs | 13 ------ .../E_GlobalQualifierAfterDot.fs | 2 +- .../NameResolution/E_RecordFieldProposal.fs | 13 ------ .../ErrorMessages/NameResolution/env.lst | 4 +- 6 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/NameResolution/E_FieldNotInRecord.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/NameResolution/E_RecordFieldProposal.fs diff --git a/tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs b/tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs new file mode 100644 index 00000000000..70def908d11 --- /dev/null +++ b/tests/fsharp/Compiler/ErrorMessages/NameResolutionTests.fs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module NameResolutionTests = + + [] + let FieldNotInRecord () = + CompilerAssert.TypeCheckSingleError + """ +type A = { Hello:string; World:string } +type B = { Size:int; Height:int } +type C = { Wheels:int } +type D = { Size:int; Height:int; Walls:int } +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'." + + [] + let RecordFieldProposal () = + CompilerAssert.TypeCheckSingleError + """ +type A = { Hello:string; World:string } +type B = { Size:int; Height:int } +type C = { Wheels:int } +type D = { Size:int; Height:int; Walls:int } +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." \ No newline at end of file diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index ec2a852b131..fe3d1656a91 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -36,6 +36,7 @@ + diff --git a/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_FieldNotInRecord.fs b/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_FieldNotInRecord.fs deleted file mode 100644 index 4a5361f8f67..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_FieldNotInRecord.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #ErrorMessages #NameResolution -//The record type 'F' does not contain a label 'Wall'\. - -type A = { Hello:string; World:string } -type B = { Size:int; Height:int } -type C = { Wheels:int } -type D = { Size:int; Height:int; Walls:int } -type E = { Unknown:string } -type F = { Wallis:int; Size:int; Height:int; } - -let r:F = { Size=3; Height=4; Wall=1 } - -exit 0 diff --git a/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_GlobalQualifierAfterDot.fs b/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_GlobalQualifierAfterDot.fs index b369ffad37f..9bde0edbc4f 100644 --- a/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_GlobalQualifierAfterDot.fs +++ b/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_GlobalQualifierAfterDot.fs @@ -3,4 +3,4 @@ let x = global.System.String.Empty.global.System.String.Empty -exit 0 +exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_RecordFieldProposal.fs b/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_RecordFieldProposal.fs deleted file mode 100644 index ca73d5c1e54..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_RecordFieldProposal.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #ErrorMessages #NameResolution -//The record label 'Wall' is not defined\. - -type A = { Hello:string; World:string } -type B = { Size:int; Height:int } -type C = { Wheels:int } -type D = { Size:int; Height:int; Walls:int } -type E = { Unknown:string } -type F = { Wallis:int; Size:int; Height:int; } - -let r = { Size=3; Height=4; Wall=1 } - -exit 0 diff --git a/tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst b/tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst index 42209ddd28e..71bc0eb3900 100644 --- a/tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst +++ b/tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst @@ -1,3 +1 @@ - SOURCE=E_RecordFieldProposal.fs # E_RecordFieldProposal - SOURCE=E_GlobalQualifierAfterDot.fs # E_GlobalQualifierAfterDot - SOURCE=E_FieldNotInRecord.fs # E_FieldNotInRecord \ No newline at end of file +SOURCE=E_GlobalQualifierAfterDot.fs # E_GlobalQualifierAfterDot \ No newline at end of file From 4cf7b5bc523d9701f7f0ca22711ed4165bf11afc Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Wed, 17 Jul 2019 21:11:31 +0300 Subject: [PATCH 05/22] Moving WarnExpressionTests over to NUnit (#7232) --- .../ErrorMessages/WarnExpressionTests.fs | 208 ++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../DontWarnIfPropertyWithoutSetter.fs | 14 -- .../Source/Warnings/WarnIfDiscardedInList.fs | 14 -- .../Source/Warnings/WarnIfDiscardedInList2.fs | 19 -- .../Source/Warnings/WarnIfDiscardedInList3.fs | 19 -- .../Warnings/WarnIfExpressionResultUnused.fs | 5 - .../Warnings/WarnIfImplicitlyDiscarded.fs | 11 - .../Warnings/WarnIfPossibleAssignment.fs | 11 - .../WarnIfPossibleAssignmentToMutable.fs | 11 - .../WarnIfPossibleDotNetPropertySetter.fs | 13 -- .../Warnings/WarnIfPossiblePropertySetter.fs | 15 -- .../Warnings/WarnOnlyOnLastExpression.fs | 10 - tests/fsharpqa/Source/Warnings/env.lst | 11 - 14 files changed, 209 insertions(+), 153 deletions(-) create mode 100644 tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs delete mode 100644 tests/fsharpqa/Source/Warnings/DontWarnIfPropertyWithoutSetter.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList2.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList3.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfExpressionResultUnused.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfImplicitlyDiscarded.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfPossibleAssignment.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfPossibleAssignmentToMutable.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfPossibleDotNetPropertySetter.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnIfPossiblePropertySetter.fs delete mode 100644 tests/fsharpqa/Source/Warnings/WarnOnlyOnLastExpression.fs diff --git a/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs b/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs new file mode 100644 index 00000000000..557aa81a4d4 --- /dev/null +++ b/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module ``Warn Expression`` = + + [] + let ``Warn If Expression Result Unused``() = + CompilerAssert.TypeCheckSingleError + """ +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'." + + [] + let ``Warn If Possible Assignment``() = + CompilerAssert.TypeCheckSingleError + """ +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'." + + [] + let ``Warn If Possible Assignment To Mutable``() = + CompilerAssert.TypeCheckSingleError + """ +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'." + + [] + let ``Warn If Possible dotnet Property Setter``() = + CompilerAssert.TypeCheckWithErrors + """ +open System + +let z = System.Timers.Timer() +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'." + |] + + [] + let ``Don't Warn If Property Without Setter``() = + CompilerAssert.TypeCheckSingleError + """ +type MyClass(property1 : int) = + member val Property2 = "" with get + +let x = MyClass(1) +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'." + + [] + let ``Warn If Implicitly Discarded``() = + CompilerAssert.TypeCheckSingleError + """ +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'." + + [] + let ``Warn If Discarded In List``() = + CompilerAssert.TypeCheckSingleError + """ +let div _ _ = 1 +let subView _ _ = [1; 2] + +// elmish view +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'." + + [] + let ``Warn If Discarded In List 2``() = + CompilerAssert.TypeCheckSingleError + """ +// stupid things to make the sample compile +let div _ _ = 1 +let subView _ _ = [1; 2] +let y = 1 + +// elmish view +let view model dispatch = + [ + div [] [ + match y with + | 1 -> yield! subView 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!'." + + [] + let ``Warn If Discarded In List 3``() = + CompilerAssert.TypeCheckSingleError + """ +// stupid things to make the sample compile +let div _ _ = 1 +let subView _ _ = true +let y = 1 + +// elmish view +let view model dispatch = + [ + div [] [ + match y with + | 1 -> () + | _ -> 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'." + + [] + let ``Warn Only On Last Expression``() = + CompilerAssert.TypeCheckSingleError + """ +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'." + + [] + let ``Warn If Possible Property Setter``() = + CompilerAssert.TypeCheckSingleError + """ +type MyClass(property1 : int) = + member val Property1 = property1 + member val Property2 = "" with get, set + +let x = MyClass(1) +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'." diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index fe3d1656a91..b1bb4c1e33a 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -38,6 +38,7 @@ + diff --git a/tests/fsharpqa/Source/Warnings/DontWarnIfPropertyWithoutSetter.fs b/tests/fsharpqa/Source/Warnings/DontWarnIfPropertyWithoutSetter.fs deleted file mode 100644 index 4492e6338c6..00000000000 --- a/tests/fsharpqa/Source/Warnings/DontWarnIfPropertyWithoutSetter.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Warnings -//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'. - -type MyClass(property1 : int) = - member val Property2 = "" with get - -let x = MyClass(1) -let y = "hello" - -let changeProperty() = - x.Property2 = "22" - y = "test" - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList.fs b/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList.fs deleted file mode 100644 index d47a4c13769..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Warnings -// - -let div _ _ = 1 -let subView _ _ = [1; 2] - -// elmish view -let view model dispatch = - [ - yield! subView model dispatch - div [] [] - ] - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList2.fs b/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList2.fs deleted file mode 100644 index d360da4d666..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList2.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Warnings -// - -// stupid things to make the sample compile -let div _ _ = 1 -let subView _ _ = [1; 2] -let y = 1 - -// elmish view -let view model dispatch = - [ - div [] [ - match y with - | 1 -> yield! subView model dispatch - | _ -> subView model dispatch - ] - ] - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList3.fs b/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList3.fs deleted file mode 100644 index 238d4388f9e..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfDiscardedInList3.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Warnings -// - -// stupid things to make the sample compile -let div _ _ = 1 -let subView _ _ = true -let y = 1 - -// elmish view -let view model dispatch = - [ - div [] [ - match y with - | 1 -> () - | _ -> subView model dispatch - ] - ] - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnIfExpressionResultUnused.fs b/tests/fsharpqa/Source/Warnings/WarnIfExpressionResultUnused.fs deleted file mode 100644 index 9480f35b6b6..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfExpressionResultUnused.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Warnings -//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'.$ - -1 + 2 -printfn "%d" 3 diff --git a/tests/fsharpqa/Source/Warnings/WarnIfImplicitlyDiscarded.fs b/tests/fsharpqa/Source/Warnings/WarnIfImplicitlyDiscarded.fs deleted file mode 100644 index ad7f9deacdd..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfImplicitlyDiscarded.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Warnings -//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 x = 10 -let y = 20 - -let changeX() = - y * x = 20 - y = 30 - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnIfPossibleAssignment.fs b/tests/fsharpqa/Source/Warnings/WarnIfPossibleAssignment.fs deleted file mode 100644 index b3fca3a0b92..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfPossibleAssignment.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Warnings -//If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'. - -let x = 10 -let y = "hello" - -let changeX() = - x = 20 - y = "test" - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnIfPossibleAssignmentToMutable.fs b/tests/fsharpqa/Source/Warnings/WarnIfPossibleAssignmentToMutable.fs deleted file mode 100644 index bd827ec4adc..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfPossibleAssignmentToMutable.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Warnings -//If you intended to mutate a value, then use the '<-' operator e.g. 'x <- expression'. - -let mutable x = 10 -let y = "hello" - -let changeX() = - x = 20 - y = "test" - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnIfPossibleDotNetPropertySetter.fs b/tests/fsharpqa/Source/Warnings/WarnIfPossibleDotNetPropertySetter.fs deleted file mode 100644 index 7c461349ec2..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfPossibleDotNetPropertySetter.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Warnings -//If you intended to set a value to a property, then use the '<-' operator e.g. 'z.Enabled <- expression' - -open System - -let z = System.Timers.Timer() -let y = "hello" - -let changeProperty() = - z.Enabled = true - y = "test" - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnIfPossiblePropertySetter.fs b/tests/fsharpqa/Source/Warnings/WarnIfPossiblePropertySetter.fs deleted file mode 100644 index 7548d204685..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnIfPossiblePropertySetter.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Warnings -//If you intended to set a value to a property, then use the '<-' operator e.g. 'x.Property2 <- expression' - -type MyClass(property1 : int) = - member val Property1 = property1 - member val Property2 = "" with get, set - -let x = MyClass(1) -let y = "hello" - -let changeProperty() = - x.Property2 = "20" - y = "test" - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/WarnOnlyOnLastExpression.fs b/tests/fsharpqa/Source/Warnings/WarnOnlyOnLastExpression.fs deleted file mode 100644 index 7b0b968c23b..00000000000 --- a/tests/fsharpqa/Source/Warnings/WarnOnlyOnLastExpression.fs +++ /dev/null @@ -1,10 +0,0 @@ -// #Warnings -//The result of this expression has type 'bool' and is implicitly ignored - -let mutable x = 0 -while x < 1 do - printfn "unneeded" - x <- x + 1 - true - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/env.lst b/tests/fsharpqa/Source/Warnings/env.lst index 3a31070e079..9b5fbffaeba 100644 --- a/tests/fsharpqa/Source/Warnings/env.lst +++ b/tests/fsharpqa/Source/Warnings/env.lst @@ -40,19 +40,8 @@ SOURCE=RefCellInsteadOfNot2.fs # RefCellInsteadOfNot2.fs SOURCE=RuntimeTypeTestInPattern.fs # RuntimeTypeTestInPattern.fs SOURCE=RuntimeTypeTestInPattern2.fs # RuntimeTypeTestInPattern2.fs - SOURCE=WarnIfExpressionResultUnused.fs # WarnIfExpressionResultUnused.fs SOURCE=MemberHasMultiplePossibleDispatchSlots.fs # MemberHasMultiplePossibleDispatchSlots.fs SOURCE=Repro1548.fs SCFLAGS="-r:Repro1548.dll" # Repro1548.fs - SOURCE=WarnIfPossibleAssignment.fs - SOURCE=WarnIfPossibleAssignmentToMutable.fs - SOURCE=WarnIfPossibleDotNetPropertySetter.fs - SOURCE=DontWarnIfPropertyWithoutSetter.fs - SOURCE=WarnIfImplicitlyDiscarded.fs - SOURCE=WarnIfDiscardedInList.fs - SOURCE=WarnIfDiscardedInList2.fs - SOURCE=WarnIfDiscardedInList3.fs - SOURCE=WarnOnlyOnLastExpression.fs - SOURCE=WarnIfPossiblePropertySetter.fs SOURCE=DoCannotHaveVisibilityDeclarations.fs SOURCE=ModuleAbbreviationsArePrivate.fs SOURCE=DontSuggestIntentionallyUnusedVariables.fs SCFLAGS="--vserrors" # DontSuggestIntentionallyUnusedVariables.fs From 650805b36840bd9ded0d4472a31bc756a42e8243 Mon Sep 17 00:00:00 2001 From: Sean McLemon Date: Wed, 17 Jul 2019 23:01:51 +0200 Subject: [PATCH 06/22] move some error and warning tests to NUnit (#7244) * move some error and warning tests to NUnit * CompilerAssert.ParseWithErrors now uses ParseFile instead of ParseAndCheckFileInProject * merge conflicts --- tests/fsharp/Compiler/CompilerAssert.fs | 19 +++ .../ErrorMessages/AssignmentErrorTests.fs | 23 ++++ .../Warnings/AssignmentWarningTests.fs | 108 ++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 2 + .../E_GlobalQualifierAfterDot.fs | 6 - .../ErrorMessages/NameResolution/env.lst | 1 - .../Source/Warnings/AssignmentOnImmutable.fs | 7 -- tests/fsharpqa/Source/Warnings/env.lst | 1 - tests/fsharpqa/Source/test.lst | 1 - 9 files changed, 152 insertions(+), 16 deletions(-) create mode 100644 tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs create mode 100644 tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/NameResolution/E_GlobalQualifierAfterDot.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst delete mode 100644 tests/fsharpqa/Source/Warnings/AssignmentOnImmutable.fs diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index d5f93d7810e..ade3ca8e4a3 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -217,3 +217,22 @@ module CompilerAssert = Assert.AreEqual(expectedErrorMessage, errorMessage) ) + let ParseWithErrors (source: string) expectedParseErrors = + let parseResults = checker.ParseFile("test.fs", SourceText.ofString source, FSharpParsingOptions.Default) |> Async.RunSynchronously + + Assert.True(parseResults.ParseHadErrors) + + let errors = + parseResults.Errors + |> Array.distinctBy (fun e -> e.Severity, e.ErrorNumber, e.StartLineAlternate, e.StartColumn, e.EndLineAlternate, e.EndColumn, e.Message) + + Assert.AreEqual(Array.length expectedParseErrors, errors.Length, sprintf "Type check errors: %A" parseResults.Errors) + + Array.zip errors expectedParseErrors + |> Array.iter (fun (info, expectedError) -> + let (expectedServerity: FSharpErrorSeverity, expectedErrorNumber: int, expectedErrorRange: int * int * int * int, expectedErrorMsg: string) = expectedError + Assert.AreEqual(expectedServerity, info.Severity) + Assert.AreEqual(expectedErrorNumber, info.ErrorNumber, "expectedErrorNumber") + Assert.AreEqual(expectedErrorRange, (info.StartLineAlternate, info.StartColumn + 1, info.EndLineAlternate, info.EndColumn + 1), "expectedErrorRange") + Assert.AreEqual(expectedErrorMsg, info.Message, "expectedErrorMsg") + ) \ No newline at end of file diff --git a/tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs b/tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs new file mode 100644 index 00000000000..51b75dd87d7 --- /dev/null +++ b/tests/fsharp/Compiler/ErrorMessages/AssignmentErrorTests.fs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module ``Errors assigning to mutable objects`` = + + [] + let ``Assign to immutable error``() = + CompilerAssert.TypeCheckSingleError + """ +let x = 10 +x <- 20 + +exit 0 + """ + FSharpErrorSeverity.Error + 27 + (3, 1, 3, 8) + "This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'." \ No newline at end of file diff --git a/tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs b/tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs new file mode 100644 index 00000000000..2a0d15d8f8b --- /dev/null +++ b/tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module ``Warnings assigning to mutable and immutable objects`` = + + [] + let ``Unused compare with immutable when assignment might be intended``() = + CompilerAssert.TypeCheckSingleError + """ +let x = 10 +let y = "hello" + +let changeX() = + x = 20 + y = "test" + +exit 0 + """ + 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'." + + [] + let ``Unused compare with mutable when assignment might be intended``() = + CompilerAssert.TypeCheckSingleError + """ +let mutable x = 10 +let y = "hello" + +let changeX() = + x = 20 + y = "test" + +exit 0 + """ + 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'." + + [] + let ``Unused comparison of property in dotnet object when assignment might be intended``() = + CompilerAssert.TypeCheckSingleError + """ +open System + +let z = new System.Timers.Timer() +let y = "hello" + +let changeProperty() = + z.Enabled = true + y = "test" + +exit 0 + """ + 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'." + + [] + let ``Unused comparison of property when assignment might be intended ``() = + CompilerAssert.TypeCheckSingleError + """ +type MyClass(property1 : int) = + member val Property1 = property1 + member val Property2 = "" with get, set + +let x = MyClass(1) +let y = "hello" + +let changeProperty() = + x.Property2 = "20" + y = "test" + +exit 0 + """ + 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'." + + [] + let ``Don't warn if assignment to property without setter ``() = + CompilerAssert.TypeCheckSingleError + """ +type MyClass(property1 : int) = + member val Property2 = "" with get + +let x = MyClass(1) +let y = "hello" + +let changeProperty() = + x.Property2 = "22" + y = "test" + +exit 0 + """ + 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'." \ No newline at end of file diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index b1bb4c1e33a..50e3e4f2d47 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -38,6 +38,7 @@ + @@ -45,6 +46,7 @@ + diff --git a/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_GlobalQualifierAfterDot.fs b/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_GlobalQualifierAfterDot.fs deleted file mode 100644 index 9bde0edbc4f..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/NameResolution/E_GlobalQualifierAfterDot.fs +++ /dev/null @@ -1,6 +0,0 @@ -// #ErrorMessages #NameResolution -//'global' may only be used as the first name in a qualified path - -let x = global.System.String.Empty.global.System.String.Empty - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst b/tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst deleted file mode 100644 index 71bc0eb3900..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/NameResolution/env.lst +++ /dev/null @@ -1 +0,0 @@ -SOURCE=E_GlobalQualifierAfterDot.fs # E_GlobalQualifierAfterDot \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/AssignmentOnImmutable.fs b/tests/fsharpqa/Source/Warnings/AssignmentOnImmutable.fs deleted file mode 100644 index a2e35c78a90..00000000000 --- a/tests/fsharpqa/Source/Warnings/AssignmentOnImmutable.fs +++ /dev/null @@ -1,7 +0,0 @@ -// #Warnings -//This value is not mutable. Consider using the mutable keyword, e.g. 'let mutable x = expression'. - -let x = 10 -x <- 20 - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/env.lst b/tests/fsharpqa/Source/Warnings/env.lst index 9b5fbffaeba..a3d677bf0fc 100644 --- a/tests/fsharpqa/Source/Warnings/env.lst +++ b/tests/fsharpqa/Source/Warnings/env.lst @@ -32,7 +32,6 @@ SOURCE=MatchingMethodWithSameNameIsNotAbstract.fs # MatchingMethodWithSameNameIsNotAbstract.fs SOURCE=NoMatchingAbstractMethodWithSameName.fs # NoMatchingAbstractMethodWithSameName.fs SOURCE=MissingExpressionAfterLet.fs # MissingExpressionAfterLet.fs - SOURCE=AssignmentOnImmutable.fs # AssignmentOnImmutable.fs SOURCE=SuggestFieldsInCtor.fs # SuggestFieldsInCtor.fs SOURCE=FieldSuggestion.fs # FieldSuggestion.fs SOURCE=SuggestToUseIndexer.fs # SuggestToUseIndexer.fs diff --git a/tests/fsharpqa/Source/test.lst b/tests/fsharpqa/Source/test.lst index f3d79d7a03f..147475acc7f 100644 --- a/tests/fsharpqa/Source/test.lst +++ b/tests/fsharpqa/Source/test.lst @@ -264,7 +264,6 @@ Misc01 Libraries\Core\Operators Misc01 Libraries\Core\Reflection Misc01 Libraries\Core\Unchecked Misc01 Warnings -Misc01 ErrorMessages\NameResolution Misc01 ErrorMessages\UnitGenericAbstractType Misc01 ErrorMessages\ConfusingTypeName From 375fd7c63f29d74d18c30c285d726107d8af301f Mon Sep 17 00:00:00 2001 From: dotnet-maestro <@dotnet-maestro> Date: Thu, 18 Jul 2019 12:51:28 +0000 Subject: [PATCH 07/22] Update dependencies from https://github.com/dotnet/arcade build 20190717.8 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19367.8 --- eng/Version.Details.xml | 4 ++-- eng/common/init-tools-native.sh | 2 +- .../templates/post-build/channels/internal-servicing.yml | 1 + eng/common/templates/post-build/channels/public-release.yml | 1 + eng/common/tools.ps1 | 2 +- global.json | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 86d49308d4e..35196ac2a5f 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 0dd5e2025f0049c133a8706f40e4463b193e5d17 + 2359dc4184133defa27c8f3072622270b71b4ecf diff --git a/eng/common/init-tools-native.sh b/eng/common/init-tools-native.sh index fc72d13948e..5f2e77f448b 100644 --- a/eng/common/init-tools-native.sh +++ b/eng/common/init-tools-native.sh @@ -71,7 +71,7 @@ function ReadGlobalJsonNativeTools { local native_tools_list=$(echo $native_tools_section | awk -F"[{}]" '{print $2}') native_tools_list=${native_tools_list//[\" ]/} native_tools_list=${native_tools_list//,/$'\n'} - native_tools_list="$(echo -e "${native_tools_list}" | tr -d '[:space:]')" + native_tools_list="$(echo -e "${native_tools_list}" | tr -d '[[:space:]]')" local old_IFS=$IFS while read -r line; do diff --git a/eng/common/templates/post-build/channels/internal-servicing.yml b/eng/common/templates/post-build/channels/internal-servicing.yml index 50ad724fc0c..648e854e0ed 100644 --- a/eng/common/templates/post-build/channels/internal-servicing.yml +++ b/eng/common/templates/post-build/channels/internal-servicing.yml @@ -84,6 +84,7 @@ stages: /p:AzureStorageAccountName=$(ProxyBackedFeedsAccountName) /p:AzureStorageAccountKey=$(dotnetfeed-storage-access-key-1) /p:AzureDevOpsFeedsBaseUrl=$(dotnetfeed-internal-private-feed-url) + /p:StaticInternalFeed=$(dotnetfeed-internal-nonstable-feed-url) /p:NugetPath=$(Agent.BuildDirectory)\Nuget\NuGet.exe /p:BARBuildId=$(BARBuildId) /p:MaestroApiEndpoint='https://maestro-prod.westus2.cloudapp.azure.com' diff --git a/eng/common/templates/post-build/channels/public-release.yml b/eng/common/templates/post-build/channels/public-release.yml index 574cb1c2b92..f6a7efdfe9d 100644 --- a/eng/common/templates/post-build/channels/public-release.yml +++ b/eng/common/templates/post-build/channels/public-release.yml @@ -84,6 +84,7 @@ stages: /p:AzureStorageAccountName=$(ProxyBackedFeedsAccountName) /p:AzureStorageAccountKey=$(dotnetfeed-storage-access-key-1) /p:AzureDevOpsFeedsBaseUrl=$(dotnetfeed-internal-private-feed-url) + /p:StaticInternalFeed=$(dotnetfeed-internal-nonstable-feed-url) /p:NugetPath=$(Agent.BuildDirectory)\Nuget\NuGet.exe /p:BARBuildId=$(BARBuildId) /p:MaestroApiEndpoint='https://maestro-prod.westus2.cloudapp.azure.com' diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 9abaac015fb..8fe2b11ad21 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -169,7 +169,7 @@ function InstallDotNetSdk([string] $dotnetRoot, [string] $version, [string] $arc InstallDotNet $dotnetRoot $version $architecture } -function InstallDotNet([string] $dotnetRoot, [string] $version, [string] $architecture = "", [string] $runtime = "", [bool] $skipNonVersionedFiles = $false) { $installScript = GetDotNetInstallScript $dotnetRoot +function InstallDotNet([string] $dotnetRoot, [string] $version, [string] $architecture = "", [string] $runtime = "", [bool] $skipNonVersionedFiles = $false) { $installScript = GetDotNetInstallScript $dotnetRoot $installParameters = @{ Version = $version diff --git a/global.json b/global.json index 7d6048be9fe..b4297bf622c 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19366.4", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19367.8", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From c423de9078db600cb0b95f48a518823417217b91 Mon Sep 17 00:00:00 2001 From: Faisal Alfaddaghi Date: Fri, 19 Jul 2019 20:36:19 +0300 Subject: [PATCH 08/22] Move UnitGenericAbstractType To Nunit (#7257) --- .../ErrorMessages/UnitGenericAbstactType.fs | 27 +++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../E_UnitGenericAbstractType1.fs | 9 ------- .../UnitGenericAbstractType/env.lst | 1 - 4 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 tests/fsharp/Compiler/ErrorMessages/UnitGenericAbstactType.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/UnitGenericAbstractType/E_UnitGenericAbstractType1.fs delete mode 100644 tests/fsharpqa/Source/ErrorMessages/UnitGenericAbstractType/env.lst diff --git a/tests/fsharp/Compiler/ErrorMessages/UnitGenericAbstactType.fs b/tests/fsharp/Compiler/ErrorMessages/UnitGenericAbstactType.fs new file mode 100644 index 00000000000..e9165a4cf6a --- /dev/null +++ b/tests/fsharp/Compiler/ErrorMessages/UnitGenericAbstactType.fs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module ``Unit generic abstract Type`` = + + [] + let ``Unit can not be used as return type of abstract method paramete on return type``() = + CompilerAssert.TypeCheckSingleError + """ +type EDF<'S> = + abstract member Apply : int -> 'S +type SomeEDF () = + interface EDF with + 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." + diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 50e3e4f2d47..0c9578f2192 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -36,6 +36,7 @@ + diff --git a/tests/fsharpqa/Source/ErrorMessages/UnitGenericAbstractType/E_UnitGenericAbstractType1.fs b/tests/fsharpqa/Source/ErrorMessages/UnitGenericAbstractType/E_UnitGenericAbstractType1.fs deleted file mode 100644 index 0b7f1d98a6d..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/UnitGenericAbstractType/E_UnitGenericAbstractType1.fs +++ /dev/null @@ -1,9 +0,0 @@ -// #ErrorMessages #UnitGenericAbstractType -//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\. -type EDF<'S> = - abstract member Apply : int -> 'S -type SomeEDF () = - interface EDF with - member this.Apply d = - // [ERROR] The member 'Apply' does not have the correct type to override the corresponding abstract method. - () \ No newline at end of file diff --git a/tests/fsharpqa/Source/ErrorMessages/UnitGenericAbstractType/env.lst b/tests/fsharpqa/Source/ErrorMessages/UnitGenericAbstractType/env.lst deleted file mode 100644 index 26ae602bd6a..00000000000 --- a/tests/fsharpqa/Source/ErrorMessages/UnitGenericAbstractType/env.lst +++ /dev/null @@ -1 +0,0 @@ - SOURCE=E_UnitGenericAbstractType1.fs # E_UnitGenericAbstractType1 \ No newline at end of file From 4151eb23b521f74e3ec1292779c8ab47a9d8014a Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2019 10:38:48 -0700 Subject: [PATCH 09/22] Update dependencies from https://github.com/dotnet/arcade build 20190718.7 (#7256) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19368.7 --- eng/Version.Details.xml | 4 +- eng/common/pipeline-logging-functions.sh | 82 ++++++++++++++++++++++-- eng/common/tools.sh | 19 +++--- global.json | 2 +- 4 files changed, 87 insertions(+), 20 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 35196ac2a5f..7a60463a0fb 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 2359dc4184133defa27c8f3072622270b71b4ecf + eecde8a8751dbe7fdb17ba4dfbd032e26f4cae7d diff --git a/eng/common/pipeline-logging-functions.sh b/eng/common/pipeline-logging-functions.sh index 6098f9a5438..1c560a50613 100644 --- a/eng/common/pipeline-logging-functions.sh +++ b/eng/common/pipeline-logging-functions.sh @@ -39,11 +39,11 @@ function Write-PipelineTaskError { return fi - message_type="error" - sourcepath='' - linenumber='' - columnnumber='' - error_code='' + local message_type="error" + local sourcepath='' + local linenumber='' + local columnnumber='' + local error_code='' while [[ $# -gt 0 ]]; do opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')" @@ -76,7 +76,7 @@ function Write-PipelineTaskError { shift done - message="##vso[task.logissue" + local message="##vso[task.logissue" message="$message type=$message_type" @@ -100,3 +100,73 @@ function Write-PipelineTaskError { echo "$message" } +function Write-PipelineSetVariable { + if [[ "$ci" != true ]]; then + return + fi + + local name='' + local value='' + local secret=false + local as_output=false + local is_multi_job_variable=true + + while [[ $# -gt 0 ]]; do + opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')" + case "$opt" in + -name|-n) + name=$2 + shift + ;; + -value|-v) + value=$2 + shift + ;; + -secret|-s) + secret=true + ;; + -as_output|-a) + as_output=true + ;; + -is_multi_job_variable|-i) + is_multi_job_variable=$2 + shift + ;; + esac + shift + done + + value=${value/;/%3B} + value=${value/\\r/%0D} + value=${value/\\n/%0A} + value=${value/]/%5D} + + local message="##vso[task.setvariable variable=$name;isSecret=$secret;isOutput=$is_multi_job_variable]$value" + + if [[ "$as_output" == true ]]; then + $message + else + echo "$message" + fi +} + +function Write-PipelinePrependPath { + local prepend_path='' + + while [[ $# -gt 0 ]]; do + opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')" + case "$opt" in + -path|-p) + prepend_path=$2 + shift + ;; + esac + shift + done + + export PATH="$prepend_path:$PATH" + + if [[ "$ci" == true ]]; then + echo "##vso[task.prependpath]$prepend_path" + fi +} \ No newline at end of file diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 70d92cf85aa..0deb01c480b 100644 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -146,14 +146,10 @@ function InitializeDotNetCli { # Add dotnet to PATH. This prevents any bare invocation of dotnet in custom # build steps from using anything other than what we've downloaded. - export PATH="$dotnet_root:$PATH" + Write-PipelinePrependPath -path "$dotnet_root" - if [[ $ci == true ]]; then - # Make Sure that our bootstrapped dotnet cli is available in future steps of the Azure Pipelines build - echo "##vso[task.prependpath]$dotnet_root" - echo "##vso[task.setvariable variable=DOTNET_MULTILEVEL_LOOKUP]0" - echo "##vso[task.setvariable variable=DOTNET_SKIP_FIRST_TIME_EXPERIENCE]1" - fi + Write-PipelineSetVariable -name "DOTNET_MULTILEVEL_LOOKUP" -value "0" + Write-PipelineSetVariable -name "DOTNET_SKIP_FIRST_TIME_EXPERIENCE" -value "1" # return value _InitializeDotNetCli="$dotnet_root" @@ -387,7 +383,8 @@ mkdir -p "$toolset_dir" mkdir -p "$temp_dir" mkdir -p "$log_dir" -if [[ $ci == true ]]; then - export TEMP="$temp_dir" - export TMP="$temp_dir" -fi +Write-PipelineSetVariable -name "Artifacts" -value "$artifacts_dir" +Write-PipelineSetVariable -name "Artifacts.Toolset" -value "$toolset_dir" +Write-PipelineSetVariable -name "Artifacts.Log" -value "$log_dir" +Write-PipelineSetVariable -name "Temp" -value "$temp_dir" +Write-PipelineSetVariable -name "TMP" -value "$temp_dir" diff --git a/global.json b/global.json index b4297bf622c..78425fae2ed 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19367.8", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19368.7", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From bdb2b79e06bcb1b515ba4243103a9ff3cfbb2ea2 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Fri, 19 Jul 2019 21:02:07 +0300 Subject: [PATCH 10/22] Moving TypeMismatchTests over to NUnit (#7250) * Moving TypeMismatchTests over to NUnit * ci restart --- .../ErrorMessages/TypeMismatchTests.fs | 135 ++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../Source/Warnings/GuardHasWrongType.fs | 9 -- .../Source/Warnings/OverrideErrors.fs | 22 --- .../Source/Warnings/RefCellInsteadOfNot.fs | 9 -- .../Source/Warnings/RefCellInsteadOfNot2.fs | 8 -- .../Warnings/ReturnInsteadOfReturnBang.fs | 10 -- .../Warnings/RuntimeTypeTestInPattern.fs | 13 -- .../Warnings/RuntimeTypeTestInPattern2.fs | 13 -- .../Warnings/YieldInsteadOfYieldBang.fs | 13 -- tests/fsharpqa/Source/Warnings/env.lst | 8 -- 11 files changed, 136 insertions(+), 105 deletions(-) create mode 100644 tests/fsharp/Compiler/ErrorMessages/TypeMismatchTests.fs delete mode 100644 tests/fsharpqa/Source/Warnings/GuardHasWrongType.fs delete mode 100644 tests/fsharpqa/Source/Warnings/OverrideErrors.fs delete mode 100644 tests/fsharpqa/Source/Warnings/RefCellInsteadOfNot.fs delete mode 100644 tests/fsharpqa/Source/Warnings/RefCellInsteadOfNot2.fs delete mode 100644 tests/fsharpqa/Source/Warnings/ReturnInsteadOfReturnBang.fs delete mode 100644 tests/fsharpqa/Source/Warnings/RuntimeTypeTestInPattern.fs delete mode 100644 tests/fsharpqa/Source/Warnings/RuntimeTypeTestInPattern2.fs delete mode 100644 tests/fsharpqa/Source/Warnings/YieldInsteadOfYieldBang.fs diff --git a/tests/fsharp/Compiler/ErrorMessages/TypeMismatchTests.fs b/tests/fsharp/Compiler/ErrorMessages/TypeMismatchTests.fs new file mode 100644 index 00000000000..652361045c9 --- /dev/null +++ b/tests/fsharp/Compiler/ErrorMessages/TypeMismatchTests.fs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module ``Type Mismatch`` = + + [] + let ``return Instead Of return!``() = + CompilerAssert.TypeCheckSingleError + """ +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'." + + [] + let ``yield Instead Of yield!``() = + CompilerAssert.TypeCheckSingleError + """ +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'." + + [] + let ``Ref Cell Instead Of Not``() = + CompilerAssert.TypeCheckSingleError + """ +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' \r\nThe '!' operator is used to dereference a ref cell. Consider using 'not expr' here." + + [] + let ``Ref Cell Instead Of Not 2``() = + CompilerAssert.TypeCheckSingleError + """ +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' \r\nThe '!' operator is used to dereference a ref cell. Consider using 'not expr' here." + + [] + let ``Guard Has Wrong Type``() = + CompilerAssert.TypeCheckWithErrors + """ +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'." + |] + + [] + let ``Runtime Type Test In Pattern``() = + CompilerAssert.TypeCheckWithErrors + """ +open System.Collections.Generic + +let orig = Dictionary() + +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" + |] + + [] + let ``Runtime Type Test In Pattern 2``() = + CompilerAssert.TypeCheckWithErrors + """ +open System.Collections.Generic + +let orig = Dictionary() + +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" + |] + + [] + let ``Override Errors``() = + CompilerAssert.TypeCheckWithErrors + """ +type Base() = + abstract member Member: int * string -> string + default x.Member (i, s) = s + +type Derived1() = + inherit Base() + override x.Member() = 5 + +type Derived2() = + inherit Base() + override x.Member (i : int) = "Hello" + +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:\r\n 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:\r\n 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' " + |] diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 0c9578f2192..9d80400c401 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -38,6 +38,7 @@ + diff --git a/tests/fsharpqa/Source/Warnings/GuardHasWrongType.fs b/tests/fsharpqa/Source/Warnings/GuardHasWrongType.fs deleted file mode 100644 index ac0c3cb4f3c..00000000000 --- a/tests/fsharpqa/Source/Warnings/GuardHasWrongType.fs +++ /dev/null @@ -1,9 +0,0 @@ -// #Warnings -//A pattern match guard must be of type 'bool' - -let x = 1 -match x with -| 1 when "s" -> true -| _ -> false - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/OverrideErrors.fs b/tests/fsharpqa/Source/Warnings/OverrideErrors.fs deleted file mode 100644 index ff03ba6ed4e..00000000000 --- a/tests/fsharpqa/Source/Warnings/OverrideErrors.fs +++ /dev/null @@ -1,22 +0,0 @@ -// #Warnings -//This override takes a different number of arguments to the corresponding abstract member. The following abstract members were found: -//abstract member Base.Member : int * string -> string -//This expression was expected to have type - -type Base() = - abstract member Member: int * string -> string - default x.Member (i, s) = s - -type Derived1() = - inherit Base() - override x.Member() = 5 - -type Derived2() = - inherit Base() - override x.Member (i : int) = "Hello" - -type Derived3() = - inherit Base() - override x.Member (s : string, i : int) = sprintf "Hello %s" s - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/RefCellInsteadOfNot.fs b/tests/fsharpqa/Source/Warnings/RefCellInsteadOfNot.fs deleted file mode 100644 index 1c6987bfa63..00000000000 --- a/tests/fsharpqa/Source/Warnings/RefCellInsteadOfNot.fs +++ /dev/null @@ -1,9 +0,0 @@ -// #Warnings -//This expression was expected to have type -//The '!' operator is used to dereference a ref cell. Consider using 'not expr' here. - -let x = true -if !x then - printfn "hello" - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/RefCellInsteadOfNot2.fs b/tests/fsharpqa/Source/Warnings/RefCellInsteadOfNot2.fs deleted file mode 100644 index 090934d8f56..00000000000 --- a/tests/fsharpqa/Source/Warnings/RefCellInsteadOfNot2.fs +++ /dev/null @@ -1,8 +0,0 @@ -// #Warnings -//This expression was expected to have type -//The '!' operator is used to dereference a ref cell. Consider using 'not expr' here. - -let x = true -let y = !x - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/ReturnInsteadOfReturnBang.fs b/tests/fsharpqa/Source/Warnings/ReturnInsteadOfReturnBang.fs deleted file mode 100644 index d9f87c521bd..00000000000 --- a/tests/fsharpqa/Source/Warnings/ReturnInsteadOfReturnBang.fs +++ /dev/null @@ -1,10 +0,0 @@ -// #Warnings -//Type mismatch. Expecting a -//''a' -//but given a -//'Async<'a>' -//The types ''a' and 'Async<'a>' cannot be unified. Consider using 'return!' instead of 'return'. - -let rec foo() = async { return foo() } - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/RuntimeTypeTestInPattern.fs b/tests/fsharpqa/Source/Warnings/RuntimeTypeTestInPattern.fs deleted file mode 100644 index 67ae796376d..00000000000 --- a/tests/fsharpqa/Source/Warnings/RuntimeTypeTestInPattern.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Warnings -//Type constraint mismatch. The type - -open System.Collections.Generic - -let orig = Dictionary() - -let c = - match orig with - | :? IDictionary -> "yes" - | _ -> "no" - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/RuntimeTypeTestInPattern2.fs b/tests/fsharpqa/Source/Warnings/RuntimeTypeTestInPattern2.fs deleted file mode 100644 index 098969482c5..00000000000 --- a/tests/fsharpqa/Source/Warnings/RuntimeTypeTestInPattern2.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Warnings -//Type constraint mismatch. The type - -open System.Collections.Generic - -let orig = Dictionary() - -let c = - match orig with - | :? IDictionary as y -> "yes" + y.ToString() - | _ -> "no" - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/YieldInsteadOfYieldBang.fs b/tests/fsharpqa/Source/Warnings/YieldInsteadOfYieldBang.fs deleted file mode 100644 index bd547fa7b28..00000000000 --- a/tests/fsharpqa/Source/Warnings/YieldInsteadOfYieldBang.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Warnings -//Type mismatch. Expecting a -//''a' -//but given a -//''a list' -//The types ''a' and ''a list' cannot be unified. Consider using 'yield!' instead of 'yield'. - -type Foo() = - member this.Yield(x) = [x] - -let rec f () = Foo() { yield f ()} - -exit 0 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/env.lst b/tests/fsharpqa/Source/Warnings/env.lst index a3d677bf0fc..18ef811a2a5 100644 --- a/tests/fsharpqa/Source/Warnings/env.lst +++ b/tests/fsharpqa/Source/Warnings/env.lst @@ -1,10 +1,7 @@ SOURCE=WrongNumericLiteral.fs # WrongNumericLiteral.fs - SOURCE=ReturnInsteadOfReturnBang.fs # ReturnInsteadOfReturnBang.fs - SOURCE=YieldInsteadOfYieldBang.fs # YieldInsteadOfYieldBang.fs SOURCE=TupleInAbstractMethod.fs # TupleInAbstractMethod.fs SOURCE=FS0988AtEndOfFile.fs # FS0988AtEndOfFile.fs SOURCE=WrongArity.fs # WrongArity.fs - SOURCE=OverrideErrors.fs # OverrideErrors.fs SOURCE=MethodIsNotStatic.fs # MethodIsNotStatic.fs SOURCE=EqualsInsteadOfInInForLoop.fs # EqualsInsteadOfInInForLoop.fs SOURCE=DontWarnExternalFunctionAsUnused.fs SCFLAGS="--warnon:1182 --warnaserror+" # DontWarnExternalFunctionAsUnused.fs @@ -28,17 +25,12 @@ SOURCE=DontSuggestWhenThingsAreOpen.fs SCFLAGS="--vserrors" # DontSuggestWhenThingsAreOpen.fs SOURCE=SuggestDoubleBacktickIdentifiers.fs SCFLAGS="--vserrors" # SuggestDoubleBacktickIdentifiers.fs SOURCE=SuggestDoubleBacktickUnions.fs SCFLAGS="--vserrors" # SuggestDoubleBacktickUnions.fs - SOURCE=GuardHasWrongType.fs # GuardHasWrongType.fs SOURCE=MatchingMethodWithSameNameIsNotAbstract.fs # MatchingMethodWithSameNameIsNotAbstract.fs SOURCE=NoMatchingAbstractMethodWithSameName.fs # NoMatchingAbstractMethodWithSameName.fs SOURCE=MissingExpressionAfterLet.fs # MissingExpressionAfterLet.fs SOURCE=SuggestFieldsInCtor.fs # SuggestFieldsInCtor.fs SOURCE=FieldSuggestion.fs # FieldSuggestion.fs SOURCE=SuggestToUseIndexer.fs # SuggestToUseIndexer.fs - SOURCE=RefCellInsteadOfNot.fs # RefCellInsteadOfNot.fs - SOURCE=RefCellInsteadOfNot2.fs # RefCellInsteadOfNot2.fs - SOURCE=RuntimeTypeTestInPattern.fs # RuntimeTypeTestInPattern.fs - SOURCE=RuntimeTypeTestInPattern2.fs # RuntimeTypeTestInPattern2.fs SOURCE=MemberHasMultiplePossibleDispatchSlots.fs # MemberHasMultiplePossibleDispatchSlots.fs SOURCE=Repro1548.fs SCFLAGS="-r:Repro1548.dll" # Repro1548.fs SOURCE=DoCannotHaveVisibilityDeclarations.fs From b0e59263c73f5194c514ec36d48b861527e7d65b Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Fri, 19 Jul 2019 14:44:36 -0700 Subject: [PATCH 11/22] publish pdbs in FSharp.Core.nupkg (#7255) Also publish native symbols so they can be archived later. --- .vsts-signed.yaml | 8 ++++++++ azure-pipelines.yml | 6 ++++++ src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec | 2 ++ 3 files changed, 16 insertions(+) diff --git a/.vsts-signed.yaml b/.vsts-signed.yaml index 3ec301bbe0c..ed30cb74ef2 100644 --- a/.vsts-signed.yaml +++ b/.vsts-signed.yaml @@ -105,6 +105,14 @@ jobs: continueOnError: true condition: succeeded() + # Publish native PDBs for archiving + - task: PublishBuildArtifacts@1 + displayName: Publish Artifact Symbols + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/artifacts/SymStore/$(BuildConfiguration)' + ArtifactName: NativeSymbols + condition: succeeded() + # Execute cleanup tasks - task: ms-vseng.MicroBuildTasks.521a94ea-9e68-468a-8167-6dcf361ea776.MicroBuildCleanup@1 displayName: Execute cleanup tasks diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2207a4792eb..87306e5c604 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -113,6 +113,12 @@ jobs: PathtoPublish: '$(Build.SourcesDirectory)\artifacts\VSSetup\$(_BuildConfig)\VisualFSharpFull.vsix' ArtifactName: 'Nightly' condition: succeeded() + - task: PublishBuildArtifacts@1 + displayName: Publish Artifact Symbols + inputs: + PathtoPublish: '$(Build.SourcesDirectory)\artifacts\SymStore\$(_BuildConfig)' + ArtifactName: 'NativeSymbols' + condition: succeeded() #---------------------------------------------------------------------------------------------------------------------# # PR builds # diff --git a/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec b/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec index ee7a88b29d6..750052c45db 100644 --- a/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec +++ b/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec @@ -38,11 +38,13 @@ + + From 3e7b66dcd0bb58c575eda182a0aee24819577942 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Fri, 19 Jul 2019 20:17:49 -0700 Subject: [PATCH 12/22] Enable hash algorithm selection (#7252) * Enable hash algorithm selection * Feedback * More feedback * Revert "Feedback" This reverts commit 6ab1b077b413712f552bad9b2562aeb63994ad4c. * feedback --- src/absil/ilwrite.fs | 127 ++++++++++------- src/absil/ilwrite.fsi | 10 +- src/absil/ilwritepdb.fs | 129 ++++++++++++------ src/absil/ilwritepdb.fsi | 12 +- src/fsharp/CompileOps.fs | 4 + src/fsharp/CompileOps.fsi | 3 + src/fsharp/CompileOptions.fs | 12 ++ src/fsharp/FSComp.txt | 2 + src/fsharp/FSharp.Build/Fsc.fs | 15 +- .../FSharp.Build/Microsoft.FSharp.Targets | 1 + .../FSharp.Compiler.Private.fsproj | 6 +- src/fsharp/fsc.fs | 1 + src/fsharp/xlf/FSComp.txt.cs.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.de.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.es.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.fr.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.it.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.ja.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.ko.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.pl.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.pt-BR.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.ru.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.tr.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.zh-Hans.xlf | 10 ++ src/fsharp/xlf/FSComp.txt.zh-Hant.xlf | 10 ++ .../ProvidedTypes/ProvidedTypes.fs | 2 +- tests/fsharp/.gitignore | 3 +- .../fsc/dumpAllCommandLineOptions/dummy.fs | 1 + .../fsc/help/help40.437.1033.bsl | 4 + 29 files changed, 359 insertions(+), 103 deletions(-) diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs index 5d6bfd3ee06..66d2dd9a667 100644 --- a/src/absil/ilwrite.fs +++ b/src/absil/ilwrite.fs @@ -3025,7 +3025,8 @@ let generateIL requiredDataFixups (desiredMetadataVersion, generatePdb, ilg : IL //===================================================================== // TABLES+BLOBS --> PHYSICAL METADATA+BLOBS //===================================================================== -let chunk sz next = ({addr=next; size=sz}, next + sz) +let chunk sz next = ({addr=next; size=sz}, next + sz) +let emptychunk next = ({addr=next; size=0}, next) let nochunk next = ({addr= 0x0;size= 0x0; }, next) let count f arr = @@ -3516,7 +3517,7 @@ let writeBytes (os: BinaryWriter) (chunk: byte[]) = os.Write(chunk, 0, chunk.Len let writeBinaryAndReportMappings (outfile, ilg: ILGlobals, pdbfile: string option, signer: ILStrongNameSigner option, portablePDB, embeddedPDB, - embedAllSource, embedSourceList, sourceLink, emitTailcalls, deterministic, showTimes, dumpDebugInfo, pathMap) + embedAllSource, embedSourceList, sourceLink, checksumAlgorithm, emitTailcalls, deterministic, showTimes, dumpDebugInfo, pathMap) modul normalizeAssemblyRefs = // Store the public key from the signer into the manifest. This means it will be written // to the binary and also acts as an indicator to leave space for delay sign @@ -3565,7 +3566,7 @@ let writeBinaryAndReportMappings (outfile, with e -> failwith ("Could not open file for writing (binary mode): " + outfile) - let pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugEmbeddedPdbChunk, textV2P, mappings = + let pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugChecksumPdbChunk, debugEmbeddedPdbChunk, debugDeterministicPdbChunk, textV2P, mappings = try let imageBaseReal = modul.ImageBase // FIXED CHOICE @@ -3670,42 +3671,61 @@ let writeBinaryAndReportMappings (outfile, let pdbOpt = match portablePDB with | true -> - let (uncompressedLength, contentId, stream) as pdbStream = - generatePortablePdb embedAllSource embedSourceList sourceLink showTimes pdbData deterministic pathMap + let (uncompressedLength, contentId, stream, algorithmName, checkSum) as pdbStream = + generatePortablePdb embedAllSource embedSourceList sourceLink checksumAlgorithm showTimes pdbData pathMap - if embeddedPDB then Some (compressPortablePdbStream uncompressedLength contentId stream) + if embeddedPDB then + let uncompressedLength, contentId, stream = compressPortablePdbStream uncompressedLength contentId stream + Some (uncompressedLength, contentId, stream, algorithmName, checkSum) else Some pdbStream | _ -> None - let debugDirectoryChunk, next = - chunk (if pdbfile = None then - 0x0 - else if embeddedPDB && portablePDB then - sizeof_IMAGE_DEBUG_DIRECTORY * 2 + let debugDirectoryChunk, next = + chunk (if pdbfile = None then + 0x0 else - sizeof_IMAGE_DEBUG_DIRECTORY + sizeof_IMAGE_DEBUG_DIRECTORY * 2 + + (if embeddedPDB then sizeof_IMAGE_DEBUG_DIRECTORY else 0) + + (if deterministic then sizeof_IMAGE_DEBUG_DIRECTORY else 0) ) next + // The debug data is given to us by the PDB writer and appears to // typically be the type of the data plus the PDB file name. We fill // this in after we've written the binary. We approximate the size according // to what PDB writers seem to require and leave extra space just in case... let debugDataJustInCase = 40 - let debugDataChunk, next = + let debugDataChunk, next = chunk (align 0x4 (match pdbfile with | None -> 0 | Some f -> (24 + System.Text.Encoding.Unicode.GetByteCount f // See bug 748444 + debugDataJustInCase))) next - let debugEmbeddedPdbChunk, next = - let streamLength = - match pdbOpt with - | Some (_, _, stream) -> int stream.Length - | None -> 0 - chunk (align 0x4 (match embeddedPDB with - | true -> 8 + streamLength - | _ -> 0 )) next + let debugChecksumPdbChunk, next = + chunk (align 0x4 (match pdbOpt with + | Some (_, _, _, algorithmName, checkSum) -> + let alg = System.Text.Encoding.UTF8.GetBytes(algorithmName) + let size = alg.Length + 1 + checkSum.Length + size + | None -> 0)) next + + let debugEmbeddedPdbChunk, next = + if embeddedPDB then + let streamLength = + match pdbOpt with + | Some (_, _, stream, _, _) -> int stream.Length + | None -> 0 + chunk (align 0x4 (match embeddedPDB with + | true -> 8 + streamLength + | _ -> 0 )) next + else + nochunk next + + let debugDeterministicPdbChunk, next = + if deterministic then emptychunk next + else nochunk next + let textSectionSize = next - textSectionAddr let nextPhys = align alignPhys (textSectionPhysLoc + textSectionSize) @@ -3804,35 +3824,39 @@ let writeBinaryAndReportMappings (outfile, if pCurrent <> pExpected then failwith ("warning: "+chunkName+" not where expected, pCurrent = "+string pCurrent+", p.addr = "+string pExpected) writeBytes os chunk - + let writePadding (os: BinaryWriter) _comment sz = if sz < 0 then failwith "writePadding: size < 0" for i = 0 to sz - 1 do os.Write 0uy - + // Now we've computed all the offsets, write the image - + write (Some msdosHeaderChunk.addr) os "msdos header" msdosHeader - + write (Some peSignatureChunk.addr) os "pe signature" [| |] - + writeInt32 os 0x4550 - + write (Some peFileHeaderChunk.addr) os "pe file header" [| |] - + if (modul.Platform = Some AMD64) then writeInt32AsUInt16 os 0x8664 // Machine - IMAGE_FILE_MACHINE_AMD64 elif isItanium then writeInt32AsUInt16 os 0x200 else writeInt32AsUInt16 os 0x014c // Machine - IMAGE_FILE_MACHINE_I386 - + writeInt32AsUInt16 os numSections - let pdbData = + let pdbData = + // Hash code, data and metadata if deterministic then - // Hash code, data and metadata - use sha = System.Security.Cryptography.SHA1.Create() // IncrementalHash is core only + use sha = + match checksumAlgorithm with + | HashAlgorithm.Sha1 -> System.Security.Cryptography.SHA1.Create() :> System.Security.Cryptography.HashAlgorithm + | HashAlgorithm.Sha256 -> System.Security.Cryptography.SHA256.Create() :> System.Security.Cryptography.HashAlgorithm + let hCode = sha.ComputeHash code let hData = sha.ComputeHash data let hMeta = sha.ComputeHash metadata @@ -3848,6 +3872,7 @@ let writeBinaryAndReportMappings (outfile, // Use last 4 bytes for timestamp - High bit set, to stop tool chains becoming confused let timestamp = int final.[16] ||| (int final.[17] <<< 8) ||| (int final.[18] <<< 16) ||| (int (final.[19] ||| 128uy) <<< 24) writeInt32 os timestamp + // Update pdbData with new guid and timestamp. Portable and embedded PDBs don't need the ModuleID // Full and PdbOnly aren't supported under deterministic builds currently, they rely on non-determinsitic Windows native code { pdbData with ModuleID = final.[0..15] ; Timestamp = timestamp } @@ -4133,10 +4158,14 @@ let writeBinaryAndReportMappings (outfile, if pdbfile.IsSome then write (Some (textV2P debugDirectoryChunk.addr)) os "debug directory" (Array.create debugDirectoryChunk.size 0x0uy) write (Some (textV2P debugDataChunk.addr)) os "debug data" (Array.create debugDataChunk.size 0x0uy) + write (Some (textV2P debugChecksumPdbChunk.addr)) os "debug checksum" (Array.create debugChecksumPdbChunk.size 0x0uy) if embeddedPDB then write (Some (textV2P debugEmbeddedPdbChunk.addr)) os "debug data" (Array.create debugEmbeddedPdbChunk.size 0x0uy) + if deterministic then + write (Some (textV2P debugDeterministicPdbChunk.addr)) os "debug deterministic" Array.empty + writePadding os "end of .text" (dataSectionPhysLoc - textSectionPhysLoc - textSectionSize) // DATA SECTION @@ -4182,7 +4211,7 @@ let writeBinaryAndReportMappings (outfile, FileSystemUtilites.setExecutablePermission outfile with _ -> () - pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugEmbeddedPdbChunk, textV2P, mappings + pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugChecksumPdbChunk, debugEmbeddedPdbChunk, debugDeterministicPdbChunk, textV2P, mappings // Looks like a finally with e -> @@ -4207,11 +4236,11 @@ let writeBinaryAndReportMappings (outfile, try let idd = match pdbOpt with - | Some (originalLength, contentId, stream) -> + | Some (originalLength, contentId, stream, algorithmName, checkSum) -> if embeddedPDB then - embedPortablePdbInfo originalLength contentId stream showTimes fpdb debugDataChunk debugEmbeddedPdbChunk + embedPortablePdbInfo originalLength contentId stream showTimes fpdb debugDataChunk debugEmbeddedPdbChunk debugDeterministicPdbChunk debugChecksumPdbChunk algorithmName checkSum embeddedPDB deterministic else - writePortablePdbInfo contentId stream showTimes fpdb pathMap debugDataChunk + writePortablePdbInfo contentId stream showTimes fpdb pathMap debugDataChunk debugDeterministicPdbChunk debugChecksumPdbChunk algorithmName checkSum embeddedPDB deterministic | None -> #if FX_NO_PDB_WRITER Array.empty @@ -4232,16 +4261,17 @@ let writeBinaryAndReportMappings (outfile, writeInt32AsUInt16 os2 i.iddMajorVersion writeInt32AsUInt16 os2 i.iddMinorVersion writeInt32 os2 i.iddType - writeInt32 os2 i.iddData.Length // IMAGE_DEBUG_DIRECTORY.SizeOfData - writeInt32 os2 i.iddChunk.addr // IMAGE_DEBUG_DIRECTORY.AddressOfRawData - writeInt32 os2 (textV2P i.iddChunk.addr) // IMAGE_DEBUG_DIRECTORY.PointerToRawData + writeInt32 os2 i.iddData.Length // IMAGE_DEBUG_DIRECTORY.SizeOfData + writeInt32 os2 i.iddChunk.addr // IMAGE_DEBUG_DIRECTORY.AddressOfRawData + writeInt32 os2 (textV2P i.iddChunk.addr) // IMAGE_DEBUG_DIRECTORY.PointerToRawData // Write the Debug Data for i in idd do - // write the debug raw data as given us by the PDB writer - os2.BaseStream.Seek (int64 (textV2P i.iddChunk.addr), SeekOrigin.Begin) |> ignore - if i.iddChunk.size < i.iddData.Length then failwith "Debug data area is not big enough. Debug info may not be usable" - writeBytes os2 i.iddData + if i.iddChunk.size <> 0 then + // write the debug raw data as given us by the PDB writer + os2.BaseStream.Seek (int64 (textV2P i.iddChunk.addr), SeekOrigin.Begin) |> ignore + if i.iddChunk.size < i.iddData.Length then failwith "Debug data area is not big enough. Debug info may not be usable" + writeBytes os2 i.iddData os2.Dispose() with e -> failwith ("Error while writing debug directory entry: "+e.Message) @@ -4250,9 +4280,7 @@ let writeBinaryAndReportMappings (outfile, with e -> reraise() - end - ignore debugDataChunk - ignore debugEmbeddedPdbChunk + end reportTime showTimes "Finalize PDB" /// Sign the binary. No further changes to binary allowed past this point! @@ -4280,9 +4308,10 @@ type options = embedAllSource: bool embedSourceList: string list sourceLink: string + checksumAlgorithm: HashAlgorithm signer: ILStrongNameSigner option - emitTailcalls : bool - deterministic : bool + emitTailcalls: bool + deterministic: bool showTimes: bool dumpDebugInfo: bool pathMap: PathMap } @@ -4290,5 +4319,5 @@ type options = let WriteILBinary (outfile, (args: options), modul, normalizeAssemblyRefs) = writeBinaryAndReportMappings (outfile, args.ilg, args.pdbfile, args.signer, args.portablePDB, args.embeddedPDB, args.embedAllSource, - args.embedSourceList, args.sourceLink, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo, args.pathMap) modul normalizeAssemblyRefs + args.embedSourceList, args.sourceLink, args.checksumAlgorithm, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo, args.pathMap) modul normalizeAssemblyRefs |> ignore diff --git a/src/absil/ilwrite.fsi b/src/absil/ilwrite.fsi index f1955f82a20..9dba89c9b6c 100644 --- a/src/absil/ilwrite.fsi +++ b/src/absil/ilwrite.fsi @@ -1,12 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// The IL Binary writer. -module internal FSharp.Compiler.AbstractIL.ILBinaryWriter +module internal FSharp.Compiler.AbstractIL.ILBinaryWriter open Internal.Utilities -open FSharp.Compiler.AbstractIL -open FSharp.Compiler.AbstractIL.Internal -open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILPdbWriter [] type ILStrongNameSigner = @@ -24,6 +25,7 @@ type options = embedAllSource: bool embedSourceList: string list sourceLink: string + checksumAlgorithm: HashAlgorithm signer : ILStrongNameSigner option emitTailcalls: bool deterministic: bool diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs index 2a992ed4855..c1ffd692249 100644 --- a/src/absil/ilwritepdb.fs +++ b/src/absil/ilwritepdb.fs @@ -11,8 +11,9 @@ open System.Reflection open System.Reflection.Metadata open System.Reflection.Metadata.Ecma335 open System.Reflection.PortableExecutable +open System.Text open Internal.Utilities -open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.AbstractIL.Internal.Support open FSharp.Compiler.AbstractIL.Internal.Library @@ -125,6 +126,27 @@ type idd = iddData: byte[] iddChunk: BinaryChunk } +/// The specified Hash algorithm to use on portable pdb files. +type HashAlgorithm = + | Sha1 + | Sha256 + +// Document checksum algorithms +let guidSha1 = Guid("ff1816ec-aa5e-4d10-87f7-6f4963833460") +let guidSha2 = Guid("8829d00f-11b8-4213-878b-770e8597ac16") + +let checkSum (url: string) (checksumAlgorithm: HashAlgorithm) = + try + use file = FileSystem.FileStreamReadShim url + let guid, alg = + match checksumAlgorithm with + | HashAlgorithm.Sha1 -> guidSha1, System.Security.Cryptography.SHA1.Create() :> System.Security.Cryptography.HashAlgorithm + | HashAlgorithm.Sha256 -> guidSha2, System.Security.Cryptography.SHA256.Create() :> System.Security.Cryptography.HashAlgorithm + + let checkSum = alg.ComputeHash file + Some (guid, checkSum) + with _ -> None + //--------------------------------------------------------------------- // Portable PDB Writer //--------------------------------------------------------------------- @@ -153,7 +175,7 @@ let pdbGetCvDebugInfo (mvid: byte[]) (timestamp: int32) (filepath: string) (cvCh } let pdbMagicNumber= 0x4244504dL -let pdbGetPdbDebugInfo (embeddedPDBChunk: BinaryChunk) (uncompressedLength: int64) (stream: MemoryStream) = +let pdbGetEmbeddedPdbDebugInfo (embeddedPdbChunk: BinaryChunk) (uncompressedLength: int64) (stream: MemoryStream) = let iddPdbBuffer = let buffer = Array.zeroCreate (sizeof + sizeof + int(stream.Length)) let (offset, size) = (0, sizeof) // Magic Number dword: 0x4244504dL @@ -169,28 +191,52 @@ let pdbGetPdbDebugInfo (embeddedPDBChunk: BinaryChunk) (uncompressedLength: int6 iddType = 17 // IMAGE_DEBUG_TYPE_EMBEDDEDPDB iddTimestamp = 0 iddData = iddPdbBuffer // Path name to the pdb file when built - iddChunk = embeddedPDBChunk + iddChunk = embeddedPdbChunk } -let pdbGetDebugInfo (mvid: byte[]) (timestamp: int32) (filepath: string) (cvChunk: BinaryChunk) (embeddedPDBChunk: BinaryChunk option) (uncompressedLength: int64) (stream: MemoryStream option) = - match stream, embeddedPDBChunk with - | None, _ | _, None -> [| pdbGetCvDebugInfo mvid timestamp filepath cvChunk |] - | Some s, Some chunk -> [| pdbGetCvDebugInfo mvid timestamp filepath cvChunk; pdbGetPdbDebugInfo chunk uncompressedLength s |] +let pdbChecksumDebugInfo timestamp (checksumPdbChunk: BinaryChunk) (algorithmName:string) (checksum: byte[]) = + let iddBuffer = + let alg = Encoding.UTF8.GetBytes(algorithmName) + let buffer = Array.zeroCreate (alg.Length + 1 + checksum.Length) + Buffer.BlockCopy(alg, 0, buffer, 0, alg.Length) + Buffer.BlockCopy(checksum, 0, buffer, alg.Length + 1, checksum.Length) + buffer + { iddCharacteristics = 0 // Reserved + iddMajorVersion = 1 // VersionMajor should be 1 + iddMinorVersion = 0x0100 // VersionMinor should be 0x0100 + iddType = 19 // IMAGE_DEBUG_TYPE_CHECKSUMPDB + iddTimestamp = timestamp + iddData = iddBuffer // Path name to the pdb file when built + iddChunk = checksumPdbChunk + } -// Document checksum algorithms -let guidSourceHashMD5 = System.Guid(0x406ea660u, 0x64cfus, 0x4c82us, 0xb6uy, 0xf0uy, 0x42uy, 0xd4uy, 0x81uy, 0x72uy, 0xa7uy, 0x99uy) //406ea660-64cf-4c82-b6f0-42d48172a799 -let hashSizeOfMD5 = 16 +let pdbGetPdbDebugDeterministicInfo (deterministicPdbChunk: BinaryChunk) = + { iddCharacteristics = 0 // Reserved + iddMajorVersion = 0 // VersionMajor should be 0 + iddMinorVersion = 0 // VersionMinor should be 00 + iddType = 16 // IMAGE_DEBUG_TYPE_DETERMINISTIC + iddTimestamp = 0 + iddData = Array.empty // No DATA + iddChunk = deterministicPdbChunk + } -// If the FIPS algorithm policy is enabled on the computer (e.g., for US government employees and contractors) -// then obtaining the MD5 implementation in BCL will throw. -// In this case, catch the failure, and not set a checksum. -let checkSum (url: string) = - try - use file = FileSystem.FileStreamReadShim url - use md5 = System.Security.Cryptography.MD5.Create() - let checkSum = md5.ComputeHash file - Some (guidSourceHashMD5, checkSum) - with _ -> None +let pdbGetDebugInfo (contentId: byte[]) (timestamp: int32) (filepath: string) + (cvChunk: BinaryChunk) + (embeddedPdbChunk: BinaryChunk option) + (deterministicPdbChunk: BinaryChunk) + (checksumPdbChunk: BinaryChunk) (algorithmName:string) (checksum: byte []) + (uncompressedLength: int64) (stream: MemoryStream option) + (embeddedPdb: bool) (deterministic: bool) = + [| yield pdbGetCvDebugInfo contentId timestamp filepath cvChunk + yield pdbChecksumDebugInfo timestamp checksumPdbChunk algorithmName checksum + if embeddedPdb then + match stream, embeddedPdbChunk with + | None, _ | _, None -> () + | Some s, Some chunk -> + yield pdbGetEmbeddedPdbDebugInfo chunk uncompressedLength s + if deterministic then + yield pdbGetPdbDebugDeterministicInfo deterministicPdbChunk + |] //------------------------------------------------------------------------------ // PDB Writer. The function [WritePdbInfo] abstracts the @@ -219,7 +265,7 @@ let getRowCounts tableRowCounts = tableRowCounts |> Seq.iter(fun x -> builder.Add x) builder.MoveToImmutable() -let generatePortablePdb (embedAllSource: bool) (embedSourceList: string list) (sourceLink: string) showTimes (info: PdbData) isDeterministic (pathMap: PathMap) = +let generatePortablePdb (embedAllSource: bool) (embedSourceList: string list) (sourceLink: string) checksumAlgorithm showTimes (info: PdbData) (pathMap: PathMap) = sortMethods showTimes info let externalRowCounts = getRowCounts info.TableRowCounts let docs = @@ -286,7 +332,7 @@ let generatePortablePdb (embedAllSource: bool) (embedSourceList: string list) (s metadata.SetCapacity(TableIndex.Document, docLength) for doc in docs do let handle = - match checkSum doc.File with + match checkSum doc.File checksumAlgorithm with | Some (hashAlg, checkSum) -> let dbgInfo = (serializeDocumentName doc.File, @@ -481,25 +527,28 @@ let generatePortablePdb (embedAllSource: bool) (embedSourceList: string list) (s | None -> MetadataTokens.MethodDefinitionHandle 0 | Some x -> MetadataTokens.MethodDefinitionHandle x - let deterministicIdProvider isDeterministic : System.Func, BlobContentId> = - match isDeterministic with - | false -> null - | true -> - let convert (content: IEnumerable) = - use sha = System.Security.Cryptography.SHA1.Create() // IncrementalHash is core only - let hash = content - |> Seq.collect (fun c -> c.GetBytes().Array |> sha.ComputeHash) - |> Array.ofSeq |> sha.ComputeHash - BlobContentId.FromHash hash - System.Func, BlobContentId>( convert ) - - let serializer = PortablePdbBuilder(metadata, externalRowCounts, entryPoint, deterministicIdProvider isDeterministic) + // Compute the contentId for the pdb. Always do it deterministically, since we have to compute the anyway. + // The contentId is the hash of the ID using whichever algorithm has been specified to the compiler + let mutable contentHash = Array.empty + + let algorithmName, hashAlgorithm = + match checksumAlgorithm with + | HashAlgorithm.Sha1 -> "SHA1", System.Security.Cryptography.SHA1.Create() :> System.Security.Cryptography.HashAlgorithm + | HashAlgorithm.Sha256 -> "SHA256", System.Security.Cryptography.SHA256.Create() :> System.Security.Cryptography.HashAlgorithm + let idProvider: System.Func, BlobContentId> = + let convert (content: IEnumerable) = + let contentBytes = content |> Seq.collect (fun c -> c.GetBytes()) |> Array.ofSeq + contentHash <- contentBytes |> hashAlgorithm.ComputeHash + BlobContentId.FromHash contentHash + System.Func, BlobContentId>(convert) + + let serializer = PortablePdbBuilder(metadata, externalRowCounts, entryPoint, idProvider) let blobBuilder = new BlobBuilder() let contentId= serializer.Serialize blobBuilder let portablePdbStream = new MemoryStream() blobBuilder.WriteContentTo portablePdbStream reportTime showTimes "PDB: Created" - (portablePdbStream.Length, contentId, portablePdbStream) + (portablePdbStream.Length, contentId, portablePdbStream, algorithmName, contentHash) let compressPortablePdbStream (uncompressedLength: int64) (contentId: BlobContentId) (stream: MemoryStream) = let compressedStream = new MemoryStream() @@ -507,17 +556,17 @@ let compressPortablePdbStream (uncompressedLength: int64) (contentId: BlobConten stream.WriteTo compressionStream (uncompressedLength, contentId, compressedStream) -let writePortablePdbInfo (contentId: BlobContentId) (stream: MemoryStream) showTimes fpdb pathMap cvChunk = +let writePortablePdbInfo (contentId: BlobContentId) (stream: MemoryStream) showTimes fpdb pathMap cvChunk deterministicPdbChunk checksumPdbChunk algName checksum embeddedPdb deterministicPdb = try FileSystem.FileDelete fpdb with _ -> () use pdbFile = new FileStream(fpdb, FileMode.Create, FileAccess.ReadWrite) stream.WriteTo pdbFile reportTime showTimes "PDB: Closed" - pdbGetDebugInfo (contentId.Guid.ToByteArray()) (int32 (contentId.Stamp)) (PathMap.apply pathMap fpdb) cvChunk None 0L None + pdbGetDebugInfo (contentId.Guid.ToByteArray()) (int32 (contentId.Stamp)) (PathMap.apply pathMap fpdb) cvChunk None deterministicPdbChunk checksumPdbChunk algName checksum 0L None embeddedPdb deterministicPdb -let embedPortablePdbInfo (uncompressedLength: int64) (contentId: BlobContentId) (stream: MemoryStream) showTimes fpdb cvChunk pdbChunk = +let embedPortablePdbInfo (uncompressedLength: int64) (contentId: BlobContentId) (stream: MemoryStream) showTimes fpdb cvChunk pdbChunk deterministicPdbChunk checksumPdbChunk algName checksum embeddedPdb deterministicPdb = reportTime showTimes "PDB: Closed" let fn = Path.GetFileName fpdb - pdbGetDebugInfo (contentId.Guid.ToByteArray()) (int32 (contentId.Stamp)) fn cvChunk (Some pdbChunk) uncompressedLength (Some stream) + pdbGetDebugInfo (contentId.Guid.ToByteArray()) (int32 (contentId.Stamp)) fn cvChunk (Some pdbChunk) deterministicPdbChunk checksumPdbChunk algName checksum uncompressedLength (Some stream) embeddedPdb deterministicPdb #if !FX_NO_PDB_WRITER //--------------------------------------------------------------------- diff --git a/src/absil/ilwritepdb.fsi b/src/absil/ilwritepdb.fsi index 2713d9769b2..748e178a461 100644 --- a/src/absil/ilwritepdb.fsi +++ b/src/absil/ilwritepdb.fsi @@ -4,7 +4,7 @@ module internal FSharp.Compiler.AbstractIL.ILPdbWriter open Internal.Utilities -open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.ErrorLogger open FSharp.Compiler.Range open System.Collections.Generic @@ -83,10 +83,14 @@ type idd = iddData: byte[]; iddChunk: BinaryChunk } -val generatePortablePdb : embedAllSource:bool -> embedSourceList:string list -> sourceLink: string -> showTimes:bool -> info:PdbData -> isDeterministic:bool -> pathMap:PathMap -> (int64 * BlobContentId * MemoryStream) +type HashAlgorithm = + | Sha1 + | Sha256 + +val generatePortablePdb : embedAllSource: bool -> embedSourceList: string list -> sourceLink: string -> checksumAlgorithm: HashAlgorithm -> showTimes: bool -> info: PdbData -> pathMap:PathMap -> (int64 * BlobContentId * MemoryStream * string * byte[]) val compressPortablePdbStream : uncompressedLength:int64 -> contentId:BlobContentId -> stream:MemoryStream -> (int64 * BlobContentId * MemoryStream) -val embedPortablePdbInfo : uncompressedLength:int64 -> contentId:BlobContentId -> stream:MemoryStream -> showTimes:bool -> fpdb:string -> cvChunk:BinaryChunk -> pdbChunk:BinaryChunk -> idd[] -val writePortablePdbInfo : contentId:BlobContentId -> stream:MemoryStream -> showTimes:bool -> fpdb:string -> pathMap:PathMap -> cvChunk:BinaryChunk -> idd[] +val embedPortablePdbInfo: uncompressedLength: int64 -> contentId: BlobContentId -> stream: MemoryStream -> showTimes: bool -> fpdb: string -> cvChunk: BinaryChunk -> pdbChunk: BinaryChunk -> deterministicPdbChunk: BinaryChunk -> checksumPdbChunk: BinaryChunk -> algorithmName: string -> checksum: byte[] -> embeddedPDB: bool -> deterministic: bool -> idd[] +val writePortablePdbInfo: contentId: BlobContentId -> stream: MemoryStream -> showTimes: bool -> fpdb: string -> pathMap: PathMap -> cvChunk: BinaryChunk -> deterministicPdbChunk: BinaryChunk -> checksumPdbChunk: BinaryChunk -> algorithmName: string -> checksum: byte[] -> embeddedPDB: bool -> deterministic: bool -> idd[] #if !FX_NO_PDB_WRITER val writePdbInfo : showTimes:bool -> f:string -> fpdb:string -> info:PdbData -> cvChunk:BinaryChunk -> idd[] diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 85728909cf3..5b75cf1077c 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -17,6 +17,7 @@ open Internal.Utilities.Text open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.ILPdbWriter open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.Extensions.ILX @@ -2100,6 +2101,7 @@ type TcConfigBuilder = mutable maxErrors: int mutable abortOnError: bool (* intended for fsi scripts that should exit on first error *) mutable baseAddress: int32 option + mutable checksumAlgorithm: HashAlgorithm #if DEBUG mutable showOptimizationData: bool #endif @@ -2231,6 +2233,7 @@ type TcConfigBuilder = maxErrors = 100 abortOnError = false baseAddress = None + checksumAlgorithm = HashAlgorithm.Sha256 delaysign = false publicsign = false @@ -2740,6 +2743,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = member x.flatErrors = data.flatErrors member x.maxErrors = data.maxErrors member x.baseAddress = data.baseAddress + member x.checksumAlgorithm = data.checksumAlgorithm #if DEBUG member x.showOptimizationData = data.showOptimizationData #endif diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi index 71bb7c6f8b6..1262542cd9f 100644 --- a/src/fsharp/CompileOps.fsi +++ b/src/fsharp/CompileOps.fsi @@ -10,6 +10,7 @@ open Internal.Utilities open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.ILPdbWriter open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler open FSharp.Compiler.TypeChecker @@ -337,6 +338,7 @@ type TcConfigBuilder = mutable maxErrors: int mutable abortOnError: bool mutable baseAddress: int32 option + mutable checksumAlgorithm: HashAlgorithm #if DEBUG mutable showOptimizationData: bool #endif @@ -497,6 +499,7 @@ type TcConfig = member maxErrors: int member baseAddress: int32 option + member checksumAlgorithm: HashAlgorithm #if DEBUG member showOptimizationData: bool #endif diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs index 0c385cc3670..e548a49e712 100644 --- a/src/fsharp/CompileOptions.fs +++ b/src/fsharp/CompileOptions.fs @@ -9,6 +9,7 @@ open System open FSharp.Compiler open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILPdbWriter open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.Extensions.ILX open FSharp.Compiler.AbstractIL.Diagnostics @@ -522,6 +523,7 @@ let tagFullPDBOnlyPortable = "{full|pdbonly|portable|embedded}" let tagWarnList = "" let tagSymbolList = "" let tagAddress = "
" +let tagAlgorithm = "{SHA1|SHA256}" let tagInt = "" let tagPathMap = "" let tagNone = "" @@ -933,6 +935,16 @@ let advancedFlagsFsc tcConfigB = OptionString (fun s -> tcConfigB.baseAddress <- Some(int32 s)), None, Some (FSComp.SR.optsBaseaddress())) + yield CompilerOption + ("checksumalgorithm", tagAlgorithm, + OptionString (fun s -> + tcConfigB.checksumAlgorithm <- + match s.ToUpperInvariant() with + | "SHA1" -> HashAlgorithm.Sha1 + | "SHA256" -> HashAlgorithm.Sha256 + | _ -> error(Error(FSComp.SR.optsUnknownChecksumAlgorithm s, rangeCmdArgs))), None, + Some (FSComp.SR.optsChecksumAlgorithm())) + yield noFrameworkFlag true tcConfigB yield CompilerOption diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index ee2b41f2e9d..831597c031a 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -878,6 +878,7 @@ optsUtf8output,"Output messages in UTF-8 encoding" optsFullpaths,"Output messages with fully qualified paths" optsLib,"Specify a directory for the include path which is used to resolve source files and assemblies (Short form: -I)" optsBaseaddress,"Base address for the library to be built" +optsChecksumAlgorithm,"Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default)" optsNoframework,"Do not reference the default CLI assemblies by default" optsStandalone,"Statically link the F# library and all referenced DLLs that depend on it into the assembly being generated" optsStaticlink,"Statically link the given assembly and all referenced DLLs that depend on this assembly. Use an assembly name e.g. mylib, not a DLL name." @@ -900,6 +901,7 @@ optsHelpBannerLanguage,"- LANGUAGE -" optsHelpBannerErrsAndWarns,"- ERRORS AND WARNINGS -" 1063,optsUnknownArgumentToTheTestSwitch,"Unknown --test argument: '%s'" 1064,optsUnknownPlatform,"Unrecognized platform '%s', valid values are 'x86', 'x64', 'Itanium', 'anycpu32bitpreferred', and 'anycpu'" +1065,optsUnknownChecksumAlgorithm,"Algorithm '%s' is not supported" optsInternalNoDescription,"The command-line option '%s' is for test purposes only" optsDCLONoDescription,"The command-line option '%s' has been deprecated" optsDCLODeprecatedSuggestAlternative,"The command-line option '%s' has been deprecated. Use '%s' instead." diff --git a/src/fsharp/FSharp.Build/Fsc.fs b/src/fsharp/FSharp.Build/Fsc.fs index 19d8cd171fa..8080637fcdf 100644 --- a/src/fsharp/FSharp.Build/Fsc.fs +++ b/src/fsharp/FSharp.Build/Fsc.fs @@ -24,6 +24,7 @@ type public Fsc () as this = let mutable baseAddress : string = null let mutable capturedArguments : string list = [] // list of individual args, to pass to HostObject Compile() let mutable capturedFilenames : string list = [] // list of individual source filenames, to pass to HostObject Compile() + let mutable checksumAlgorithm: string = null let mutable codePage : string = null let mutable commandLineArgs : ITaskItem list = [] let mutable debugSymbols = false @@ -135,7 +136,7 @@ type public Fsc () as this = builder.AppendSwitch("--tailcalls-") // PdbFile builder.AppendSwitchIfNotNull("--pdb:", pdbFile) - // Platform +// Platform builder.AppendSwitchIfNotNull("--platform:", let ToUpperInvariant (s:string) = if s = null then null else s.ToUpperInvariant() match ToUpperInvariant(platform), prefer32bit, ToUpperInvariant(targetType) with @@ -145,6 +146,13 @@ type public Fsc () as this = | "X86", _, _ -> "x86" | "X64", _, _ -> "x64" | _ -> null) + // checksumAlgorithm + builder.AppendSwitchIfNotNull("--checksumalgorithm:", + let ToUpperInvariant (s:string) = if s = null then null else s.ToUpperInvariant() + match ToUpperInvariant(checksumAlgorithm) with + | "SHA1" -> "Sha1" + | "SHA256" -> "Sha256" + | _ -> null) // Resources if resources <> null then for item in resources do @@ -258,6 +266,11 @@ type public Fsc () as this = with get() = baseAddress and set(s) = baseAddress <- s + // --checksumalgorithm + member fsc.ChecksumAlgorithm + with get() = checksumAlgorithm + and set(s) = checksumAlgorithm <- s + // --codepage : Specify the codepage to use when opening source files member fsc.CodePage with get() = codePage diff --git a/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets b/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets index c36ce52c50f..a5d036b885a 100644 --- a/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets +++ b/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets @@ -276,6 +276,7 @@ this file. AbsIL\ilread.fs - - AbsIL\ilwrite.fsi - AbsIL\ilwritepdb.fsi AbsIL\ilwritepdb.fs + + AbsIL\ilwrite.fsi + AbsIL\ilwrite.fs diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index e4e693e99ca..7799d409e5d 100644 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -2145,6 +2145,7 @@ let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, tcImports: TcImports, t embedAllSource = tcConfig.embedAllSource embedSourceList = tcConfig.embedSourceList sourceLink = tcConfig.sourceLink + checksumAlgorithm = tcConfig.checksumAlgorithm signer = GetStrongNameSigner signingInfo dumpDebugInfo = tcConfig.dumpDebugInfo pathMap = tcConfig.pathMap }, diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index 3354ee57b5f..883582e5e67 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. Není definovaný obor názvů {0}. diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index 320acf4e03d..12791db46fa 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. Der Namespace "{0}" ist nicht definiert. diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index b08960e4861..e4096bec532 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. El espacio de nombres "{0}" no está definido. diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index f23037f6a88..1a0d745e9f2 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. L'espace de noms '{0}' n'est pas défini. diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 32637f988da..baec2ba7fd6 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. Lo spazio dei nomi '{0}' non è definito. diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index 8157060c9d8..a2a18f153ad 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. 名前空間 '{0}' が定義されていません。 diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index f642d6b444d..92ead77838e 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. '{0}' 네임스페이스가 정의되지 않았습니다. diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index b9749bedda5..0187c22d016 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. Nie zdefiniowano przestrzeni nazw „{0}”. diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index 39537bc8cde..1ed97eb22d3 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. O namespace '{0}' não está definido. diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index fcd4c723f70..bdeac0f9592 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. Пространство имен "{0}" не определено. diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index 80929708832..de62c337f55 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. '{0}' ad alanı tanımlı değil. diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index 1a7945d7124..b0264288fb1 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. 未定义命名空间“{0}”。 diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 0f67d46dbc2..ab73b60a7f4 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -7,6 +7,16 @@ {0} for F# {1} + + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + Specify algorithm for calculating source file checksum stored in PDB. Supported values are: SHA1 or SHA256 (default) + + + + Algorithm '{0}' is not supported + Algorithm '{0}' is not supported + + The namespace '{0}' is not defined. 未定義命名空間 '{0}'。 diff --git a/tests/EndToEndBuildTests/ProvidedTypes/ProvidedTypes.fs b/tests/EndToEndBuildTests/ProvidedTypes/ProvidedTypes.fs index 45974519909..f6395b91c49 100644 --- a/tests/EndToEndBuildTests/ProvidedTypes/ProvidedTypes.fs +++ b/tests/EndToEndBuildTests/ProvidedTypes/ProvidedTypes.fs @@ -12495,7 +12495,7 @@ namespace ProviderImplementation.ProvidedTypes let pdbOpt = match portablePDB with | true -> - let (uncompressedLength, contentId, stream) as pdbStream = generatePortablePdb embedAllSource embedSourceList sourceLink showTimes pdbData deterministic + let (uncompressedLength, contentId, stream) as pdbStream = generatePortablePdb embedAllSource embedSourceList sourceLink showTimes pdbData if embeddedPDB then Some (compressPortablePdbStream uncompressedLength contentId stream) else Some (pdbStream) | _ -> None diff --git a/tests/fsharp/.gitignore b/tests/fsharp/.gitignore index 0493c881790..ea4771517da 100644 --- a/tests/fsharp/.gitignore +++ b/tests/fsharp/.gitignore @@ -13,4 +13,5 @@ Library1.dll cd.tmp - +*.err +*.vserr diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/dumpAllCommandLineOptions/dummy.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/dumpAllCommandLineOptions/dummy.fs index 65d7f3ba86d..0c3c619c33e 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/dumpAllCommandLineOptions/dummy.fs +++ b/tests/fsharpqa/Source/CompilerOptions/fsc/dumpAllCommandLineOptions/dummy.fs @@ -39,6 +39,7 @@ //section='- ADVANCED - ' ! option=fullpaths kind=OptionUnit //section='- ADVANCED - ' ! option=lib kind=OptionStringList //section='- ADVANCED - ' ! option=baseaddress kind=OptionString +//section='- ADVANCED - ' ! option=checksumalgorithm kind=OptionString //section='- ADVANCED - ' ! option=noframework kind=OptionUnit //section='- ADVANCED - ' ! option=standalone kind=OptionUnit //section='- ADVANCED - ' ! option=staticlink kind=OptionString diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/help/help40.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsc/help/help40.437.1033.bsl index b0fd6746810..9309a03e5e6 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/help/help40.437.1033.bsl +++ b/tests/fsharpqa/Source/CompilerOptions/fsc/help/help40.437.1033.bsl @@ -133,6 +133,10 @@ Copyright (c) Microsoft Corporation. All Rights Reserved. Default - mscorlib --baseaddress:
Base address for the library to be built +--checksumalgorithm:{SHA1|SHA256} Specify algorithm for calculating + source file checksum stored in PDB. + Supported values are: SHA1 or SHA256 + (default) --noframework Do not reference the default CLI assemblies by default --standalone Statically link the F# library and From c70ead8048a2dd7865195bd90edfd64a260dc1e9 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Sat, 20 Jul 2019 10:04:05 -0700 Subject: [PATCH 13/22] Update dependencies from https://github.com/dotnet/arcade build 20190719.2 (#7260) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19369.2 --- eng/Version.Details.xml | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 7a60463a0fb..7228968c11e 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - eecde8a8751dbe7fdb17ba4dfbd032e26f4cae7d + a190d4865fe3c86a168ec49c4fc61c90c96ae051 diff --git a/global.json b/global.json index 78425fae2ed..c8c5b129393 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19368.7", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19369.2", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From ff7b8ff392cee40388a08e377138030784c7cc35 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Mon, 22 Jul 2019 12:24:18 -0700 Subject: [PATCH 14/22] Improve netcore reference selection (#7263) * Improve netcore reference selection * Update baselines --- tests/fsharp/Compiler/CompilerAssert.fs | 87 ++++++++++-- .../Language/SpanOptimizationTests.fs | 124 +++++++++--------- 2 files changed, 136 insertions(+), 75 deletions(-) diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index ade3ca8e4a3..52ec325df86 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -32,6 +32,76 @@ module CompilerAssert = let private config = TestFramework.initializeSuite () + +// Do a one time dotnet sdk build to compute the proper set of reference assemblies to pass to the compiler +#if !NETCOREAPP +#else + let projectFile = """ + + + + Exe + netcoreapp2.1 + + + + + + + + +""" + + let programFs = """ +open System + +[] +let main argv = 0""" + + let getNetCoreAppReferences = + let mutable output = "" + let mutable errors = "" + let mutable cleanUp = true + let projectDirectory = Path.Combine(Path.GetTempPath(), "netcoreapp2.1", Path.GetRandomFileName()) + try + try + Directory.CreateDirectory(projectDirectory) |> ignore + let projectFileName = Path.Combine(projectDirectory, "ProjectFile.fsproj") + let programFsFileName = Path.Combine(projectDirectory, "Program.fs") + let frameworkReferencesFileName = Path.Combine(projectDirectory, "FrameworkReferences.txt") + + File.WriteAllText(projectFileName, projectFile) + File.WriteAllText(programFsFileName, programFs) + + let pInfo = ProcessStartInfo () + + pInfo.FileName <- config.DotNetExe + pInfo.Arguments <- "build" + pInfo.WorkingDirectory <- projectDirectory + pInfo.RedirectStandardOutput <- true + pInfo.RedirectStandardError <- true + pInfo.UseShellExecute <- false + + let p = Process.Start(pInfo) + p.WaitForExit() + + output <- p.StandardOutput.ReadToEnd () + errors <- p.StandardError.ReadToEnd () + if not (String.IsNullOrWhiteSpace errors) then Assert.Fail errors + + if p.ExitCode <> 0 then Assert.Fail(sprintf "Program exited with exit code %d" p.ExitCode) + + File.ReadLines(frameworkReferencesFileName) |> Seq.toArray + with | e -> + cleanUp <- false + printfn "%s" output + printfn "%s" errors + raise (new Exception (sprintf "An error occured getting netcoreapp references: %A" e)) + finally + if cleanUp then + try Directory.Delete(projectDirectory) with | _ -> () +#endif + let private defaultProjectOptions = { ProjectFileName = "Z:\\test.fsproj" @@ -41,14 +111,7 @@ module CompilerAssert = OtherOptions = [|"--preferreduilang:en-US";|] #else OtherOptions = - // Hack: Currently a hack to get the runtime assemblies for netcore in order to compile. - let assemblies = - typeof.Assembly.Location - |> Path.GetDirectoryName - |> Directory.EnumerateFiles - |> Seq.toArray - |> Array.filter (fun x -> x.ToLowerInvariant().Contains("system.")) - |> Array.map (fun x -> sprintf "-r:%s" x) + let assemblies = getNetCoreAppReferences |> Array.map (fun x -> sprintf "-r:%s" x) Array.append [|"--preferreduilang:en-US"; "--targetprofile:netcore"; "--noframework"|] assemblies #endif ReferencedProjects = [||] @@ -60,7 +123,7 @@ module CompilerAssert = ExtraProjectInfo = None Stamp = None } - + let private gate = obj () let private compile isExe source f = @@ -110,8 +173,6 @@ module CompilerAssert = Assert.IsEmpty(typeCheckResults.Errors, sprintf "Type Check errors: %A" typeCheckResults.Errors) - - let TypeCheckWithErrors (source: string) expectedTypeErrors = lock gate <| fun () -> let parseResults, fileAnswer = checker.ParseAndCheckFileInProject("test.fs", 0, SourceText.ofString source, defaultProjectOptions) |> Async.RunSynchronously @@ -141,7 +202,7 @@ module CompilerAssert = TypeCheckWithErrors (source: string) [| expectedServerity, expectedErrorNumber, expectedErrorRange, expectedErrorMsg |] let CompileExe (source: string) = - compile true source (fun (errors, _) -> + compile true source (fun (errors, _) -> if errors.Length > 0 then Assert.Fail (sprintf "Compile had warnings and/or errors: %A" errors)) @@ -216,7 +277,7 @@ module CompilerAssert = ||> Seq.iter2 (fun expectedErrorMessage errorMessage -> Assert.AreEqual(expectedErrorMessage, errorMessage) ) - + let ParseWithErrors (source: string) expectedParseErrors = let parseResults = checker.ParseFile("test.fs", SourceText.ofString source, FSharpParsingOptions.Default) |> Async.RunSynchronously diff --git a/tests/fsharp/Compiler/Language/SpanOptimizationTests.fs b/tests/fsharp/Compiler/Language/SpanOptimizationTests.fs index efcea68afd3..c5fd682e993 100644 --- a/tests/fsharp/Compiler/Language/SpanOptimizationTests.fs +++ b/tests/fsharp/Compiler/Language/SpanOptimizationTests.fs @@ -27,45 +27,45 @@ let test () = verifier.VerifyIL [ """.method public static void test() cil managed -{ - - .maxstack 5 - .locals init (valuetype [System.Private.CoreLib]System.Span`1 V_0, - int32 V_1, - valuetype [System.Private.CoreLib]System.Int32 V_2, - class [System.Private.CoreLib]System.Object& V_3) - IL_0000: call valuetype [System.Private.CoreLib]System.Span`1 valuetype [System.Private.CoreLib]System.Span`1::get_Empty() - IL_0005: stloc.0 - IL_0006: ldc.i4.0 - IL_0007: stloc.2 - IL_0008: ldloca.s V_0 - IL_000a: call instance int32 valuetype [System.Private.CoreLib]System.Span`1::get_Length() - IL_000f: ldc.i4.1 - IL_0010: sub - IL_0011: stloc.1 - IL_0012: ldloc.1 - IL_0013: ldloc.2 - IL_0014: blt.s IL_0034 - - IL_0016: ldloca.s V_0 - IL_0018: ldloc.2 - IL_0019: call instance !0& valuetype [System.Private.CoreLib]System.Span`1::get_Item(int32) - IL_001e: stloc.3 - IL_001f: ldloc.3 - IL_0020: ldobj [System.Private.CoreLib]System.Object - IL_0025: call void [System.Console]System.Console::WriteLine(object) - IL_002a: ldloc.2 - IL_002b: ldc.i4.1 - IL_002c: add - IL_002d: stloc.2 - IL_002e: ldloc.2 - IL_002f: ldloc.1 - IL_0030: ldc.i4.1 - IL_0031: add - IL_0032: bne.un.s IL_0016 - - IL_0034: ret -} """ + { + + .maxstack 5 + .locals init (valuetype [System.Runtime]System.Span`1 V_0, + int32 V_1, + int32 V_2, + object& V_3) + IL_0000: call valuetype [System.Runtime]System.Span`1 valuetype [System.Runtime]System.Span`1::get_Empty() + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: stloc.2 + IL_0008: ldloca.s V_0 + IL_000a: call instance int32 valuetype [System.Runtime]System.Span`1::get_Length() + IL_000f: ldc.i4.1 + IL_0010: sub + IL_0011: stloc.1 + IL_0012: ldloc.1 + IL_0013: ldloc.2 + IL_0014: blt.s IL_0034 + + IL_0016: ldloca.s V_0 + IL_0018: ldloc.2 + IL_0019: call instance !0& valuetype [System.Runtime]System.Span`1::get_Item(int32) + IL_001e: stloc.3 + IL_001f: ldloc.3 + IL_0020: ldobj [System.Runtime]System.Object + IL_0025: call void [System.Console]System.Console::WriteLine(object) + IL_002a: ldloc.2 + IL_002b: ldc.i4.1 + IL_002c: add + IL_002d: stloc.2 + IL_002e: ldloc.2 + IL_002f: ldloc.1 + IL_0030: ldc.i4.1 + IL_0031: add + IL_0032: bne.un.s IL_0016 + + IL_0034: ret + }""" ]) [] @@ -88,18 +88,18 @@ let test () = [ """.method public static void test() cil managed { - + .maxstack 5 - .locals init (valuetype [System.Private.CoreLib]System.ReadOnlySpan`1 V_0, + .locals init (valuetype [System.Runtime]System.ReadOnlySpan`1 V_0, int32 V_1, - valuetype [System.Private.CoreLib]System.Int32 V_2, - class [System.Private.CoreLib]System.Object& V_3) - IL_0000: call valuetype [System.Private.CoreLib]System.ReadOnlySpan`1 valuetype [System.Private.CoreLib]System.ReadOnlySpan`1::get_Empty() + int32 V_2, + object& V_3) + IL_0000: call valuetype [System.Runtime]System.ReadOnlySpan`1 valuetype [System.Runtime]System.ReadOnlySpan`1::get_Empty() IL_0005: stloc.0 IL_0006: ldc.i4.0 IL_0007: stloc.2 IL_0008: ldloca.s V_0 - IL_000a: call instance int32 valuetype [System.Private.CoreLib]System.ReadOnlySpan`1::get_Length() + IL_000a: call instance int32 valuetype [System.Runtime]System.ReadOnlySpan`1::get_Length() IL_000f: ldc.i4.1 IL_0010: sub IL_0011: stloc.1 @@ -109,10 +109,10 @@ let test () = IL_0016: ldloca.s V_0 IL_0018: ldloc.2 - IL_0019: call instance !0& modreq([System.Private.CoreLib]System.Runtime.InteropServices.InAttribute) valuetype [System.Private.CoreLib]System.ReadOnlySpan`1::get_Item(int32) + IL_0019: call instance !0& modreq([System.Runtime]System.Runtime.InteropServices.InAttribute) valuetype [System.Runtime]System.ReadOnlySpan`1::get_Item(int32) IL_001e: stloc.3 IL_001f: ldloc.3 - IL_0020: ldobj [System.Private.CoreLib]System.Object + IL_0020: ldobj [System.Runtime]System.Object IL_0025: call void [System.Console]System.Console::WriteLine(object) IL_002a: ldloc.2 IL_002b: ldc.i4.1 @@ -176,29 +176,29 @@ module Test = [ """.method public static void test() cil managed { - + .maxstack 3 - .locals init (valuetype System.Span`1 V_0, - class [System.Private.CoreLib]System.Collections.IEnumerator V_1, + .locals init (valuetype System.Span`1 V_0, + class [System.Runtime]System.Collections.IEnumerator V_1, class [FSharp.Core]Microsoft.FSharp.Core.Unit V_2, - class [System.Private.CoreLib]System.IDisposable V_3) + class [System.Runtime]System.IDisposable V_3) IL_0000: ldc.i4.0 - IL_0001: newarr [System.Private.CoreLib]System.Object - IL_0006: newobj instance void valuetype System.Span`1::.ctor(!0[]) + IL_0001: newarr [System.Runtime]System.Object + IL_0006: newobj instance void valuetype System.Span`1::.ctor(!0[]) IL_000b: stloc.0 IL_000c: ldloc.0 - IL_000d: box valuetype System.Span`1 - IL_0012: unbox.any [System.Private.CoreLib]System.Collections.IEnumerable - IL_0017: callvirt instance class [System.Private.CoreLib]System.Collections.IEnumerator [System.Private.CoreLib]System.Collections.IEnumerable::GetEnumerator() + IL_000d: box valuetype System.Span`1 + IL_0012: unbox.any [System.Runtime]System.Collections.IEnumerable + IL_0017: callvirt instance class [System.Runtime]System.Collections.IEnumerator [System.Runtime]System.Collections.IEnumerable::GetEnumerator() IL_001c: stloc.1 .try { IL_001d: ldloc.1 - IL_001e: callvirt instance bool [System.Private.CoreLib]System.Collections.IEnumerator::MoveNext() + IL_001e: callvirt instance bool [System.Runtime]System.Collections.IEnumerator::MoveNext() IL_0023: brfalse.s IL_0032 IL_0025: ldloc.1 - IL_0026: callvirt instance object [System.Private.CoreLib]System.Collections.IEnumerator::get_Current() + IL_0026: callvirt instance object [System.Runtime]System.Collections.IEnumerator::get_Current() IL_002b: call void [System.Console]System.Console::WriteLine(object) IL_0030: br.s IL_001d @@ -206,24 +206,24 @@ module Test = IL_0033: stloc.2 IL_0034: leave.s IL_004c - } + } finally { IL_0036: ldloc.1 - IL_0037: isinst [System.Private.CoreLib]System.IDisposable + IL_0037: isinst [System.Runtime]System.IDisposable IL_003c: stloc.3 IL_003d: ldloc.3 IL_003e: brfalse.s IL_0049 IL_0040: ldloc.3 - IL_0041: callvirt instance void [System.Private.CoreLib]System.IDisposable::Dispose() + IL_0041: callvirt instance void [System.Runtime]System.IDisposable::Dispose() IL_0046: ldnull IL_0047: pop IL_0048: endfinally IL_0049: ldnull IL_004a: pop IL_004b: endfinally - } + } IL_004c: ldloc.2 IL_004d: pop IL_004e: ret From d53a38c019b361a1f5b72362f199c86e829adc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Chassaing?= Date: Tue, 23 Jul 2019 00:57:02 +0200 Subject: [PATCH 15/22] Moving Libraries Control tests to NUnit (#7234) * Moving Libraries Control tests to NUnit * Names tests as Async instead of Control --- tests/fsharp/FSharpSuite.Tests.fsproj | 1 + tests/fsharp/Libraries/Async/AsyncTests.fs | 168 ++++++++++++++++++ .../Control/ExecuteAsyncMultipleTimes01.fs | 17 -- .../Libraries/Control/JoiningStartChild01.fs | 25 --- .../Control/MailboxAsyncNoStackOverflow01.fs | 78 -------- .../StartChildNoObjectDisposedException01.fs | 12 -- .../StartChildTestTrampolineHijackLimit01.fs | 19 -- .../fsharpqa/Source/Libraries/Control/env.lst | 6 - 8 files changed, 169 insertions(+), 157 deletions(-) create mode 100644 tests/fsharp/Libraries/Async/AsyncTests.fs delete mode 100644 tests/fsharpqa/Source/Libraries/Control/ExecuteAsyncMultipleTimes01.fs delete mode 100644 tests/fsharpqa/Source/Libraries/Control/JoiningStartChild01.fs delete mode 100644 tests/fsharpqa/Source/Libraries/Control/MailboxAsyncNoStackOverflow01.fs delete mode 100644 tests/fsharpqa/Source/Libraries/Control/StartChildNoObjectDisposedException01.fs delete mode 100644 tests/fsharpqa/Source/Libraries/Control/StartChildTestTrampolineHijackLimit01.fs delete mode 100644 tests/fsharpqa/Source/Libraries/Control/env.lst diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 9d80400c401..9291db2f740 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -48,6 +48,7 @@ + diff --git a/tests/fsharp/Libraries/Async/AsyncTests.fs b/tests/fsharp/Libraries/Async/AsyncTests.fs new file mode 100644 index 00000000000..04a82a97160 --- /dev/null +++ b/tests/fsharp/Libraries/Async/AsyncTests.fs @@ -0,0 +1,168 @@ +namespace FSharp.Libraries.UnitTests + +open System +open NUnit.Framework +open FSharp.Compiler.UnitTests + +[] +module AsyncTests = + // Regression for FSHARP1.0:5969 + // Async.StartChild: error when wait async is executed more than once + [] + let ``Execute Async multiple times``() = + CompilerAssert.CompileExeAndRun + """ +module M + +let a = async { + let! a = Async.StartChild( + async { + do! Async.Sleep(1) + return 27 + }) + let! result = Async.Parallel [ a; a; a; a ] + return result + } |> Async.RunSynchronously + +exit 0 + """ + + + // Regression for FSHARP1.0:5970 + // Async.StartChild: race in implementation of ResultCell in FSharp.Core + [] + let ``Joining StartChild``() = + CompilerAssert.CompileExeAndRun + """ +module M + +let Join (a1: Async<'a>) (a2: Async<'b>) = async { + let! task1 = a1 |> Async.StartChild + let! task2 = a2 |> Async.StartChild + + let! res1 = task1 + let! res2 = task2 + return (res1,res2) } + +let r = + try + Async.RunSynchronously (Join (async { do! Async.Sleep(30) + failwith "fail" + return 3+3 }) + (async { do! Async.Sleep(30) + return 2 + 2 } )) + with _ -> + (0,0) + +exit 0 + + """ + + // Regression test for FSHARP1.0:6086 + [] + let ``Mailbox Async dot not StackOverflow``() = + CompilerAssert.CompileExeAndRun + """ +open Microsoft.FSharp.Control + +type Color = Blue | Red | Yellow +let complement = function + | (Red, Yellow) | (Yellow, Red) -> Blue + | (Red, Blue) | (Blue, Red) -> Yellow + | (Yellow, Blue) | (Blue, Yellow) -> Red + | (Blue, Blue) -> Blue + | (Red, Red) -> Red + | (Yellow, Yellow) -> Yellow + +type Message = Color * AsyncReplyChannel + +let chameleon (meetingPlace : MailboxProcessor) initial = + let rec loop c meets = async { + let replyMessage = meetingPlace.PostAndReply(fun reply -> c, reply) + match replyMessage with + | Some(newColor) -> return! loop newColor (meets + 1) + | None -> return meets + } + loop initial 0 + +let meetingPlace chams n = MailboxProcessor.Start(fun (processor : MailboxProcessor)-> + let rec fadingLoop total = + async { + if total <> 0 then + let! (_, reply) = processor.Receive() + reply.Reply None + return! fadingLoop (total - 1) + else + printfn "Done" + } + let rec mainLoop curr = + async { + if (curr > 0) then + let! (color1, reply1) = processor.Receive() + let! (color2, reply2) = processor.Receive() + let newColor = complement (color1, color2) + reply1.Reply <| Some(newColor) + reply2.Reply <| Some(newColor) + return! mainLoop (curr - 1) + else + return! fadingLoop chams + } + mainLoop n + ) + +open System +open System.Diagnostics + +let meetings = 100000 + +let colors = [Blue; Red; Yellow; Blue] +let mp = meetingPlace (colors.Length) meetings +let watch = Stopwatch.StartNew() +let meets = + colors + |> List.map (chameleon mp) + |> Async.Parallel + |> Async.RunSynchronously +watch.Stop() +for meet in meets do + printfn "%d" meet +printfn "Total: %d in %O" (Seq.sum meets) (watch.Elapsed) + +exit 0 + """ + + // Regression for FSHARP1.0:5971 + [] + let ``StartChild do not throw ObjectDisposedException``() = + CompilerAssert.CompileExeAndRun + """ +module M + +let b = async {return 5} |> Async.StartChild +printfn "%A" (b |> Async.RunSynchronously |> Async.RunSynchronously) + +exit 0 + """ + + + [] + let ``StartChild test Trampoline HijackLimit``() = + CompilerAssert.CompileExeAndRun + """ +module M + +let r = + async { + let! a = Async.StartChild( + async { + do! Async.Sleep(1) + return 5 + } + ) + let! _ = a + for __ in 1..10000 do // 10000 > bindHijackLimit + () + } |> Async.RunSynchronously + +exit 0 + """ diff --git a/tests/fsharpqa/Source/Libraries/Control/ExecuteAsyncMultipleTimes01.fs b/tests/fsharpqa/Source/Libraries/Control/ExecuteAsyncMultipleTimes01.fs deleted file mode 100644 index e042c6f02df..00000000000 --- a/tests/fsharpqa/Source/Libraries/Control/ExecuteAsyncMultipleTimes01.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Regression #Libraries #Async -// Regression for FSHARP1.0:5969 -// Async.StartChild: error when wait async is executed more than once - -module M - -let a = async { - let! a = Async.StartChild( - async { - do! Async.Sleep(500) - return 27 - }) - let! result = Async.Parallel [ a; a; a; a ] - return result - } |> Async.RunSynchronously - -exit 0 diff --git a/tests/fsharpqa/Source/Libraries/Control/JoiningStartChild01.fs b/tests/fsharpqa/Source/Libraries/Control/JoiningStartChild01.fs deleted file mode 100644 index 692bb583844..00000000000 --- a/tests/fsharpqa/Source/Libraries/Control/JoiningStartChild01.fs +++ /dev/null @@ -1,25 +0,0 @@ -// #Regression #Libraries #Async -// Regression for FSHARP1.0:5970 -// Async.StartChild: race in implementation of ResultCell in FSharp.Core - -module M - -let Join (a1: Async<'a>) (a2: Async<'b>) = async { - let! task1 = a1 |> Async.StartChild - let! task2 = a2 |> Async.StartChild - - let! res1 = task1 - let! res2 = task2 - return (res1,res2) } - -let r = - try - Async.RunSynchronously (Join (async { do! Async.Sleep(30) - failwith "fail" - return 3+3 }) - (async { do! Async.Sleep(30) - return 2 + 2 } )) - with _ -> - (0,0) - -exit 0 diff --git a/tests/fsharpqa/Source/Libraries/Control/MailboxAsyncNoStackOverflow01.fs b/tests/fsharpqa/Source/Libraries/Control/MailboxAsyncNoStackOverflow01.fs deleted file mode 100644 index 33e0e590a7b..00000000000 --- a/tests/fsharpqa/Source/Libraries/Control/MailboxAsyncNoStackOverflow01.fs +++ /dev/null @@ -1,78 +0,0 @@ -// #Regression #Libraries #Async -// Regression test for FSHARP1.0:6086 -// This is a bit of duplication because the same/similar test -// can also be found under the FSHARP suite. Yet, I like to have -// it here... - -// The interesting thing about this test is that is used to throw -// an exception when executed on 64bit (FSharp.Core 2.0) - -open Microsoft.FSharp.Control - -type Color = Blue | Red | Yellow -let complement = function - | (Red, Yellow) | (Yellow, Red) -> Blue - | (Red, Blue) | (Blue, Red) -> Yellow - | (Yellow, Blue) | (Blue, Yellow) -> Red - | (Blue, Blue) -> Blue - | (Red, Red) -> Red - | (Yellow, Yellow) -> Yellow - -type Message = Color * AsyncReplyChannel - -let chameleon (meetingPlace : MailboxProcessor) initial = - let rec loop c meets = async { - let replyMessage = meetingPlace.PostAndReply(fun reply -> c, reply) - match replyMessage with - | Some(newColor) -> return! loop newColor (meets + 1) - | None -> return meets - } - loop initial 0 - -let meetingPlace chams n = MailboxProcessor.Start(fun (processor : MailboxProcessor)-> - let rec fadingLoop total = - async { - if total <> 0 then - let! (_, reply) = processor.Receive() - reply.Reply None - return! fadingLoop (total - 1) - else - printfn "Done" - } - let rec mainLoop curr = - async { - if (curr > 0) then - let! (color1, reply1) = processor.Receive() - let! (color2, reply2) = processor.Receive() - let newColor = complement (color1, color2) - reply1.Reply <| Some(newColor) - reply2.Reply <| Some(newColor) - return! mainLoop (curr - 1) - else - return! fadingLoop chams - } - mainLoop n - ) - -open System -open System.Diagnostics - -[] -let main(args : string[]) = - printfn "CommandLine : %s" (String.concat ", " args) - let meetings = if args.Length > 0 then Int32.Parse(args.[0]) else 100000 - - let colors = [Blue; Red; Yellow; Blue] - let mp = meetingPlace (colors.Length) meetings - let watch = Stopwatch.StartNew() - let meets = - colors - |> List.map (chameleon mp) - |> Async.Parallel - |> Async.RunSynchronously - watch.Stop() - for meet in meets do - printfn "%d" meet - printfn "Total: %d in %O" (Seq.sum meets) (watch.Elapsed) - 0 - diff --git a/tests/fsharpqa/Source/Libraries/Control/StartChildNoObjectDisposedException01.fs b/tests/fsharpqa/Source/Libraries/Control/StartChildNoObjectDisposedException01.fs deleted file mode 100644 index 5186548c79a..00000000000 --- a/tests/fsharpqa/Source/Libraries/Control/StartChildNoObjectDisposedException01.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Regression #Libraries #Async -// Regression for FSHARP1.0:5971 -// Async.StartChild: ObjectDisposedException - -module M - -let shortVersion(args: string []) = - let b = async {return 5} |> Async.StartChild - printfn "%A" (b |> Async.RunSynchronously |> Async.RunSynchronously) - (0) - -exit 0 diff --git a/tests/fsharpqa/Source/Libraries/Control/StartChildTestTrampolineHijackLimit01.fs b/tests/fsharpqa/Source/Libraries/Control/StartChildTestTrampolineHijackLimit01.fs deleted file mode 100644 index 46cfeb59376..00000000000 --- a/tests/fsharpqa/Source/Libraries/Control/StartChildTestTrampolineHijackLimit01.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Regression #Libraries #Async -// Regression for FSHARP1.0:5972 -// Async.StartChild: fails to install trampolines properly -module M - -let r = - async { - let! a = Async.StartChild( - async { - do! Async.Sleep(500) - return 5 - } - ) - let! b = a - for i in 1..10000 do // 10000 > bindHijackLimit - () - } |> Async.RunSynchronously - -exit 0 diff --git a/tests/fsharpqa/Source/Libraries/Control/env.lst b/tests/fsharpqa/Source/Libraries/Control/env.lst deleted file mode 100644 index 6c034ca5b46..00000000000 --- a/tests/fsharpqa/Source/Libraries/Control/env.lst +++ /dev/null @@ -1,6 +0,0 @@ - SOURCE=MailboxAsyncNoStackOverflow01.fs # MailboxAsyncNoStackOverflow01.fs - - SOURCE=ExecuteAsyncMultipleTimes01.fs # ExecuteAsyncMultipleTimes01.fs - SOURCE=JoiningStartChild01.fs # JoiningStartChild01.fs - SOURCE=StartChildNoObjectDisposedException01.fs # StartChildNoObjectDisposedException01.fs - SOURCE=StartChildTestTrampolineHijackLimit01.fs # StartChildTestTrampolineHijackLimit01.fs \ No newline at end of file From 5efa8a7ba0bd4e3d62515f14d0b48c8a0edd5c58 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 23 Jul 2019 01:00:28 +0200 Subject: [PATCH 16/22] Member constraints and PrimitiveConstraints (#7210) --- tests/fsharp/Compiler/CompilerAssert.fs | 18 ++- .../ConstraintSolver/MemberConstraints.fs | 45 ++++++++ .../ConstraintSolver/PrimitiveConstraints.fs | 109 ++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 2 + .../E_MemberConstraints01.fs | 6 - .../ConstraintSolving/E_PrimConstraint04.fs | 16 --- .../ConstraintSolving/MemberConstraints01.fs | 24 ---- .../ConstraintSolving/PrimConstraint01.fs | 26 ----- .../ConstraintSolving/PrimConstraint02.fs | 33 ------ .../ConstraintSolving/PrimConstraint03.fs | 23 ---- .../ConstraintSolving/env.lst | 8 -- 11 files changed, 171 insertions(+), 139 deletions(-) create mode 100644 tests/fsharp/Compiler/ConstraintSolver/MemberConstraints.fs create mode 100644 tests/fsharp/Compiler/ConstraintSolver/PrimitiveConstraints.fs delete mode 100644 tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/E_MemberConstraints01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/E_PrimConstraint04.fs delete mode 100644 tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/MemberConstraints01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint03.fs diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index 52ec325df86..9f64824bb48 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -173,9 +173,15 @@ let main argv = 0""" Assert.IsEmpty(typeCheckResults.Errors, sprintf "Type Check errors: %A" typeCheckResults.Errors) - let TypeCheckWithErrors (source: string) expectedTypeErrors = + let TypeCheckWithErrorsAndOptions options (source: string) expectedTypeErrors = lock gate <| fun () -> - let parseResults, fileAnswer = checker.ParseAndCheckFileInProject("test.fs", 0, SourceText.ofString source, defaultProjectOptions) |> Async.RunSynchronously + let parseResults, fileAnswer = + checker.ParseAndCheckFileInProject( + "test.fs", + 0, + SourceText.ofString source, + { defaultProjectOptions with OtherOptions = Array.append options defaultProjectOptions.OtherOptions}) + |> Async.RunSynchronously Assert.IsEmpty(parseResults.Errors, sprintf "Parse errors: %A" parseResults.Errors) @@ -198,8 +204,14 @@ let main argv = 0""" Assert.AreEqual(expectedErrorMsg, info.Message, "expectedErrorMsg") ) + let TypeCheckWithErrors (source: string) expectedTypeErrors = + TypeCheckWithErrorsAndOptions [||] source expectedTypeErrors + + let TypeCheckSingleErrorWithOptions options (source: string) (expectedServerity: FSharpErrorSeverity) (expectedErrorNumber: int) (expectedErrorRange: int * int * int * int) (expectedErrorMsg: string) = + TypeCheckWithErrorsAndOptions options source [| expectedServerity, expectedErrorNumber, expectedErrorRange, expectedErrorMsg |] + let TypeCheckSingleError (source: string) (expectedServerity: FSharpErrorSeverity) (expectedErrorNumber: int) (expectedErrorRange: int * int * int * int) (expectedErrorMsg: string) = - TypeCheckWithErrors (source: string) [| expectedServerity, expectedErrorNumber, expectedErrorRange, expectedErrorMsg |] + TypeCheckWithErrors source [| expectedServerity, expectedErrorNumber, expectedErrorRange, expectedErrorMsg |] let CompileExe (source: string) = compile true source (fun (errors, _) -> diff --git a/tests/fsharp/Compiler/ConstraintSolver/MemberConstraints.fs b/tests/fsharp/Compiler/ConstraintSolver/MemberConstraints.fs new file mode 100644 index 00000000000..d422c9b31fd --- /dev/null +++ b/tests/fsharp/Compiler/ConstraintSolver/MemberConstraints.fs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module MemberConstraints = + + [] + let ``we can overload operators on a type and not add all the extra jazz such as inlining and the ^ operator.``() = + CompilerAssert.CompileExeAndRun + """ +type Foo(x : int) = + member this.Val = x + + static member (-->) ((src : Foo), (target : Foo)) = new Foo(src.Val + target.Val) + static member (-->) ((src : Foo), (target : int)) = new Foo(src.Val + target) + + static member (+) ((src : Foo), (target : Foo)) = new Foo(src.Val + target.Val) + static member (+) ((src : Foo), (target : int)) = new Foo(src.Val + target) + +let x = Foo(3) --> 4 +let y = Foo(3) --> Foo(4) +let x2 = Foo(3) + 4 +let y2 = Foo(3) + Foo(4) + +if x.Val <> 7 then exit 1 +if y.Val <> 7 then exit 1 +if x2.Val <> 7 then exit 1 +if y2.Val <> 7 then exit 1 + """ + + [] + let ``Invalid member constraint with ErrorRanges``() = // Regression test for FSharp1.0:2262 + CompilerAssert.TypeCheckSingleErrorWithOptions + [| "--test:ErrorRanges" |] + """ +let inline length (x: ^a) : int = (^a : (member Length : int with get, set) (x, ())) + """ + FSharpErrorSeverity.Error + 697 + (2, 42, 2, 75) + "Invalid constraint" diff --git a/tests/fsharp/Compiler/ConstraintSolver/PrimitiveConstraints.fs b/tests/fsharp/Compiler/ConstraintSolver/PrimitiveConstraints.fs new file mode 100644 index 00000000000..fbfedfb550d --- /dev/null +++ b/tests/fsharp/Compiler/ConstraintSolver/PrimitiveConstraints.fs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module PrimitiveConstraints = + + [] + let ``Test primitive : constraints``() = + CompilerAssert.CompileExeAndRun + """ +#light + +type Foo(x : int) = + member this.Value = x + override this.ToString() = "Foo" + +type Bar(x : int) = + inherit Foo(-1) + member this.Value2 = x + override this.ToString() = "Bar" + +let test1 (x : Foo) = x.Value +let test2 (x : Bar) = (x.Value, x.Value2) + +let f = new Foo(128) +let b = new Bar(256) + +if test1 f <> 128 then exit 1 +if test2 b <> (-1, 256) then exit 1 +""" + + [] + let ``Test primitive :> constraints``() = + CompilerAssert.CompileExeAndRun + """ +#light +type Foo(x : int) = + member this.Value = x + override this.ToString() = "Foo" + +type Bar(x : int) = + inherit Foo(-1) + member this.Value2 = x + override this.ToString() = "Bar" + +type Ram(x : int) = + inherit Foo(10) + member this.ValueA = x + override this.ToString() = "Ram" + +let test (x : Foo) = (x.Value, x.ToString()) + +let f = new Foo(128) +let b = new Bar(256) +let r = new Ram(314) + +if test f <> (128, "Foo") then exit 1 +if test b <> (-1, "Bar") then exit 1 +if test r <> (10, "Ram") then exit 1 +""" + + [] + let ``Test primitive : null constraint``() = + CompilerAssert.CompileExeAndRun + """ +let inline isNull<'a when 'a : null> (x : 'a) = + match x with + | null -> "is null" + | _ -> (x :> obj).ToString() + +let runTest = + // Wrapping in try block to work around FSB 1989 + try + if isNull null <> "is null" then exit 1 + if isNull "F#" <> "F#" then exit 1 + true + with _ -> exit 1 + +if runTest <> true then exit 1 + +exit 0 +""" + + [] + /// Title: Type checking oddity + /// + /// This suggestion was resolved as by design, + /// so the test makes sure, we're emitting error message about 'not being a valid object construction expression' + let ``Invalid object constructor``() = // Regression test for FSharp1.0:4189 + CompilerAssert.TypeCheckWithErrorsAndOptions + [| "--test:ErrorRanges" |] + """ +type ImmutableStack<'a> private(items: 'a list) = + + member this.Push item = ImmutableStack(item::items) + member this.Pop = match items with | [] -> failwith "No elements in stack" | x::xs -> x,ImmutableStack(xs) + + // Notice type annotation is commented out, which results in an error + new(col (*: seq<'a>*)) = ImmutableStack(List.ofSeq col) + + """ + [| FSharpErrorSeverity.Error, 41, (4, 29, 4, 56), "A unique overload for method 'ImmutableStack`1' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: new : col:'b -> ImmutableStack<'a>, private new : items:'a list -> ImmutableStack<'a>" + FSharpErrorSeverity.Error, 41, (5, 93, 5, 111), "A unique overload for method 'ImmutableStack`1' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: new : col:'b -> ImmutableStack<'a>, private new : items:'a list -> ImmutableStack<'a>" + FSharpErrorSeverity.Error, 41, (8, 30, 8, 60), "A unique overload for method 'ImmutableStack`1' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: new : col:'b -> ImmutableStack<'a> when 'b :> seq<'c>, private new : items:'a list -> ImmutableStack<'a>" + FSharpErrorSeverity.Error, 696, (8, 30, 8, 60), "This is not a valid object construction expression. Explicit object constructors must either call an alternate constructor or initialize all fields of the object and specify a call to a super class constructor." |] \ No newline at end of file diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 9291db2f740..2be8d09cd72 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -35,6 +35,8 @@ + + diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/E_MemberConstraints01.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/E_MemberConstraints01.fs deleted file mode 100644 index 643ec7f7db7..00000000000 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/E_MemberConstraints01.fs +++ /dev/null @@ -1,6 +0,0 @@ -// #Regression #Conformance #TypeInference #TypeConstraints -// Regression test for FSharp1.0:2262 -// We should emit an error, not ICE -//Invalid constraint - -let inline length (x: ^a) : int = (^a : (member Length : int with get, set) (x, ())) diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/E_PrimConstraint04.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/E_PrimConstraint04.fs deleted file mode 100644 index 08dcbfde122..00000000000 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/E_PrimConstraint04.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Regression #Conformance #TypeInference #TypeConstraints -// Regression test for FSharp1.0:4189 -// Title: Type checking oddity - -// This suggestion was resolved as by design, -// so the test makes sure, we're emitting error message about 'not being avalid object construction expression' - -//This is not a valid object construction expression\. Explicit object constructors must either call an alternate constructor or initialize all fields of the object and specify a call to a super class constructor\.$ - -type ImmutableStack<'a> private(items: 'a list) = - - member this.Push item = ImmutableStack(item::items) - member this.Pop = match items with | [] -> failwith "No elements in stack" | x::xs -> x,ImmutableStack(xs) - - // Notice type annotation is commented out, which results in an error - new(col (*: seq<'a>*)) = ImmutableStack(List.ofSeq col) diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/MemberConstraints01.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/MemberConstraints01.fs deleted file mode 100644 index af263142458..00000000000 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/MemberConstraints01.fs +++ /dev/null @@ -1,24 +0,0 @@ -// #Conformance #TypeInference #TypeConstraints -// Verify you can overload operators on a type and not add all the extra jazz -// such as inlining and the ^ operator. - -type Foo(x : int) = - member this.Val = x - - static member (-->) ((src : Foo), (target : Foo)) = new Foo(src.Val + target.Val) - static member (-->) ((src : Foo), (target : int)) = new Foo(src.Val + target) - - static member (+) ((src : Foo), (target : Foo)) = new Foo(src.Val + target.Val) - static member (+) ((src : Foo), (target : int)) = new Foo(src.Val + target) - -let x = Foo(3) --> 4 -let y = Foo(3) --> Foo(4) -let x2 = Foo(3) + 4 -let y2 = Foo(3) + Foo(4) - -if x.Val <> 7 then exit 1 -if y.Val <> 7 then exit 1 -if x2.Val <> 7 then exit 1 -if y2.Val <> 7 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint01.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint01.fs deleted file mode 100644 index e9b11b1c99f..00000000000 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint01.fs +++ /dev/null @@ -1,26 +0,0 @@ -// #Conformance #TypeInference #TypeConstraints -#light - -// Test primitive constraints - -// Test ':' constraints - -type Foo(x : int) = - member this.Value = x - override this.ToString() = "Foo" - -type Bar(x : int) = - inherit Foo(-1) - member this.Value2 = x - override this.ToString() = "Bar" - -let test1 (x : Foo) = x.Value -let test2 (x : Bar) = (x.Value, x.Value2) - -let f = new Foo(128) -let b = new Bar(256) - -if test1 f <> 128 then exit 1 -if test2 b <> (-1, 256) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint02.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint02.fs deleted file mode 100644 index b410f4e528f..00000000000 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint02.fs +++ /dev/null @@ -1,33 +0,0 @@ -// #Conformance #TypeInference #TypeConstraints - -#light - -// Test primitive constraints - -// Test ':>' constraints - -type Foo(x : int) = - member this.Value = x - override this.ToString() = "Foo" - -type Bar(x : int) = - inherit Foo(-1) - member this.Value2 = x - override this.ToString() = "Bar" - -type Ram(x : int) = - inherit Foo(10) - member this.ValueA = x - override this.ToString() = "Ram" - -let test (x : Foo) = (x.Value, x.ToString()) - -let f = new Foo(128) -let b = new Bar(256) -let r = new Ram(314) - -if test f <> (128, "Foo") then exit 1 -if test b <> (-1, "Bar") then exit 1 -if test r <> (10, "Ram") then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint03.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint03.fs deleted file mode 100644 index 7f9a072fd65..00000000000 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/PrimConstraint03.fs +++ /dev/null @@ -1,23 +0,0 @@ -// #Conformance #TypeInference #TypeConstraints -#light - -// Test primitive constraints - -// Test ': null' constraints - -let inline isNull<'a when 'a : null> (x : 'a) = - match x with - | null -> "is null" - | _ -> (x :> obj).ToString() - -let runTest = - // Wrapping in try block to work around FSB 1989 - try - if isNull null <> "is null" then exit 1 - if isNull "F#" <> "F#" then exit 1 - true - with _ -> exit 1 - -if runTest <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/env.lst b/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/env.lst index 4b89bcc2ba8..041ba830d0b 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/env.lst +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/ConstraintSolving/env.lst @@ -1,10 +1,5 @@ SOURCE=E_NoImplicitDowncast01.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_NoImplicitDowncast01.fs - SOURCE=PrimConstraint01.fs # PrimConstraint01.fs - SOURCE=PrimConstraint02.fs # PrimConstraint02.fs - SOURCE=PrimConstraint03.fs # PrimConstraint03.fs - SOURCE=E_PrimConstraint04.fs SCFLAGS="--test:ErrorRanges" # E_PrimConstraint04.fs - SOURCE=E_TypeFuncDeclaredExplicit01.fs # E_TypeFuncDeclaredExplicit01.fs SOURCE=ValueRestriction01.fs # ValueRestriction01.fs @@ -16,7 +11,4 @@ SOURCE=DelegateConstraint01.fs # DelegateConstraint01.fs SOURCE=E_DelegateConstraint01.fs # E_DelegateConstraint01.fs - SOURCE=MemberConstraints01.fs # MemberConstraints01.fs - SOURCE=E_MemberConstraints01.fs SCFLAGS="--test:ErrorRanges" # E_MemberConstraints01.fs - SOURCE=ConstructorConstraint01.fs # ConstructorConstraint01.fs \ No newline at end of file From a7c68c3aed7980a6220a40738b718a7196de017a Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2019 09:48:39 -0700 Subject: [PATCH 17/22] Update dependencies from https://github.com/dotnet/arcade build 20190722.10 (#7268) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19372.10 --- eng/Version.Details.xml | 4 ++-- eng/common/init-tools-native.ps1 | 8 +++++++- global.json | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 7228968c11e..e278bed29a9 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - a190d4865fe3c86a168ec49c4fc61c90c96ae051 + 0793e2df782efc9ccae387bc779b2549208fa4a1 diff --git a/eng/common/init-tools-native.ps1 b/eng/common/init-tools-native.ps1 index 9d18645f455..eaa05880c55 100644 --- a/eng/common/init-tools-native.ps1 +++ b/eng/common/init-tools-native.ps1 @@ -103,7 +103,13 @@ try { if ($LASTEXITCODE -Ne "0") { $errMsg = "$ToolName installation failed" if ((Get-Variable 'DoNotAbortNativeToolsInstallationOnFailure' -ErrorAction 'SilentlyContinue') -and $DoNotAbortNativeToolsInstallationOnFailure) { - Write-Warning $errMsg + $showNativeToolsWarning = $true + if ((Get-Variable 'DoNotDisplayNativeToolsInstallationWarnings' -ErrorAction 'SilentlyContinue') -and $DoNotDisplayNativeToolsInstallationWarnings) { + $showNativeToolsWarning = $false + } + if ($showNativeToolsWarning) { + Write-Warning $errMsg + } $toolInstallationFailure = $true } else { Write-Error $errMsg diff --git a/global.json b/global.json index c8c5b129393..1d496dc84bf 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19369.2", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19372.10", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From 37970b41db5c858411fc42876233e608844c9f58 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Wed, 24 Jul 2019 18:08:15 -0700 Subject: [PATCH 18/22] fixes issue #6832 (#7259) * fixes issue #6832 * Fix comment * Forgot to remove pdbs from fsharp.compiler.nuget * Rename Program.fs and exclude FSharpSdk from checks * Embedded doesn't need to verify tmp or obj directories. * typo * typo * Don't check FSharpSdk for hash * Make comment match code * Empty commit to force rebuild --- FSharpBuild.Directory.Build.props | 3 +- eng/Build.ps1 | 11 ++-- eng/build-utils.ps1 | 3 +- src/absil/ilwritepdb.fs | 2 +- .../buildtools/AssemblyCheck/AssemblyCheck.fs | 66 +++++++++++++++---- .../AssemblyCheck/AssemblyCheck.fsproj | 17 +++++ src/buildtools/buildtools.proj | 1 + .../Microsoft.FSharp.Compiler.nuspec | 14 +--- .../FSharp.Core.nuget/FSharp.Core.nuspec | 2 - 9 files changed, 86 insertions(+), 33 deletions(-) rename scripts/AssemblyVersionCheck.fsx => src/buildtools/AssemblyCheck/AssemblyCheck.fs (51%) create mode 100644 src/buildtools/AssemblyCheck/AssemblyCheck.fsproj diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props index 515de9bbdc7..6687fb40888 100644 --- a/FSharpBuild.Directory.Build.props +++ b/FSharpBuild.Directory.Build.props @@ -75,6 +75,7 @@ https://github.com/Microsoft/visualfsharp git + <_DotGitDir>$(RepoRoot).git <_HeadFileContent Condition="Exists('$(_DotGitDir)/HEAD')">$([System.IO.File]::ReadAllText('$(_DotGitDir)/HEAD').Trim()) @@ -87,7 +88,7 @@ $(NoWarn);FS2003 true - portable + embedded fs false true diff --git a/eng/Build.ps1 b/eng/Build.ps1 index f329cba02ac..8011827a643 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -224,13 +224,14 @@ function UpdatePath() { TestAndAddToPath "$ArtifactsDir\bin\fsiAnyCpu\$configuration\net472" } -function VerifyAssemblyVersions() { - $fsiPath = Join-Path $ArtifactsDir "bin\fsi\Proto\net472\publish\fsi.exe" +function VerifyAssemblyVersionsAndSymbols() { + $assemblyVerCheckPath = Join-Path $ArtifactsDir "Bootstrap\AssemblyCheck\AssemblyCheck.dll" # Only verify versions on CI or official build if ($ci -or $official) { - $asmVerCheckPath = "$RepoRoot\scripts" - Exec-Console $fsiPath """$asmVerCheckPath\AssemblyVersionCheck.fsx"" -- ""$ArtifactsDir""" + $dotnetPath = InitializeDotNetCli + $dotnetExe = Join-Path $dotnetPath "dotnet.exe" + Exec-Console $dotnetExe """$assemblyVerCheckPath"" ""$ArtifactsDir""" } } @@ -307,7 +308,7 @@ try { } if ($build) { - VerifyAssemblyVersions + VerifyAssemblyVersionsAndSymbols } $desktopTargetFramework = "net472" diff --git a/eng/build-utils.ps1 b/eng/build-utils.ps1 index fcda1a58e26..772de110ca2 100644 --- a/eng/build-utils.ps1 +++ b/eng/build-utils.ps1 @@ -236,10 +236,11 @@ function Make-BootstrapBuild() { Remove-Item -re $dir -ErrorAction SilentlyContinue Create-Directory $dir - # prepare FsLex and Fsyacc + # prepare FsLex and Fsyacc and AssemblyCheck Run-MSBuild "$RepoRoot\src\buildtools\buildtools.proj" "/restore /t:Publish" -logFileName "BuildTools" -configuration $bootstrapConfiguration Copy-Item "$ArtifactsDir\bin\fslex\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\fslex" -Force -Recurse Copy-Item "$ArtifactsDir\bin\fsyacc\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\fsyacc" -Force -Recurse + Copy-Item "$ArtifactsDir\bin\AssemblyCheck\$bootstrapConfiguration\netcoreapp2.1\publish" -Destination "$dir\AssemblyCheck" -Force -Recurse # prepare compiler $projectPath = "$RepoRoot\proto.proj" diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs index c1ffd692249..86b7ee9224f 100644 --- a/src/absil/ilwritepdb.fs +++ b/src/absil/ilwritepdb.fs @@ -186,7 +186,7 @@ let pdbGetEmbeddedPdbDebugInfo (embeddedPdbChunk: BinaryChunk) (uncompressedLeng Buffer.BlockCopy(stream.ToArray(), 0, buffer, offset, size) buffer { iddCharacteristics = 0 // Reserved - iddMajorVersion = 0 // VersionMajor should be 0 + iddMajorVersion = 0x0100 // VersionMajor should be 0x0100 iddMinorVersion = 0x0100 // VersionMinor should be 0x0100 iddType = 17 // IMAGE_DEBUG_TYPE_EMBEDDEDPDB iddTimestamp = 0 diff --git a/scripts/AssemblyVersionCheck.fsx b/src/buildtools/AssemblyCheck/AssemblyCheck.fs similarity index 51% rename from scripts/AssemblyVersionCheck.fsx rename to src/buildtools/AssemblyCheck/AssemblyCheck.fs index 0f3816a2e6c..c6bd035a673 100644 --- a/scripts/AssemblyVersionCheck.fsx +++ b/src/buildtools/AssemblyCheck/AssemblyCheck.fs @@ -1,22 +1,50 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. open System open System.Diagnostics open System.IO open System.Reflection +open System.Reflection.PortableExecutable open System.Text.RegularExpressions -module AssemblyVersionCheck = +module AssemblyCheck = let private versionZero = Version(0, 0, 0, 0) let private versionOne = Version(1, 0, 0, 0) let private commitHashPattern = new Regex(@"Commit Hash: ()|([0-9a-fA-F]{40})", RegexOptions.Compiled) let private devVersionPattern = new Regex(@"-(ci|dev)", RegexOptions.Compiled) - let verifyAssemblyVersions (binariesPath:string) = + let verifyEmbeddedPdb (filename:string) = + use fileStream = File.OpenRead(filename) + let reader = new PEReader(fileStream) + let mutable hasEmbeddedPdb = false + + try + for entry in reader.ReadDebugDirectory() do + match entry.Type with + | DebugDirectoryEntryType.CodeView -> + let _ = reader.ReadCodeViewDebugDirectoryData(entry) + () + + | DebugDirectoryEntryType.EmbeddedPortablePdb -> + let _ = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry) + hasEmbeddedPdb <- true + () + + | DebugDirectoryEntryType.PdbChecksum -> + let _ = reader.ReadPdbChecksumDebugDirectoryData(entry) + () + + | _ -> () + with | e -> printfn "Error validating assembly %s\nMessage: %s" filename (e.ToString()) + hasEmbeddedPdb + + let verifyAssemblies (binariesPath:string) = + let excludedAssemblies = [ "FSharp.Data.TypeProviders.dll" ] |> Set.ofList + let fsharpAssemblies = [ "FSharp*.dll" "fsc.exe" @@ -28,12 +56,17 @@ module AssemblyVersionCheck = |> List.ofSeq |> List.filter (fun p -> (Set.contains (Path.GetFileName(p)) excludedAssemblies) |> not) + let fsharpExecutingWithEmbeddedPdbs = + fsharpAssemblies + |> List.filter (fun p -> not (p.Contains(@"\Proto\") || p.Contains(@"\Bootstrap\") || p.Contains(@".resources.") || p.Contains(@"\FSharpSdk\") || p.Contains(@"\tmp\") || p.Contains(@"\obj\"))) + // verify that all assemblies have a version number other than 0.0.0.0 or 1.0.0.0 let failedVersionCheck = fsharpAssemblies |> List.filter (fun a -> let assemblyVersion = AssemblyName.GetAssemblyName(a).Version assemblyVersion = versionZero || assemblyVersion = versionOne) + if failedVersionCheck.Length > 0 then printfn "The following assemblies had a version of %A or %A" versionZero versionOne printfn "%s\r\n" <| String.Join("\r\n", failedVersionCheck) @@ -43,27 +76,36 @@ module AssemblyVersionCheck = // verify that all assemblies have a commit hash let failedCommitHash = fsharpAssemblies + |> List.filter (fun p -> not (p.Contains(@"\FSharpSdk\"))) |> List.filter (fun a -> let fileProductVersion = FileVersionInfo.GetVersionInfo(a).ProductVersion not (commitHashPattern.IsMatch(fileProductVersion) || devVersionPattern.IsMatch(fileProductVersion))) + if failedCommitHash.Length > 0 then printfn "The following assemblies don't have a commit hash set" printfn "%s\r\n" <| String.Join("\r\n", failedCommitHash) else printfn "All shipping assemblies had an appropriate commit hash." + // verify that all assemblies have an embedded pdb + let failedVerifyEmbeddedPdb = + fsharpExecutingWithEmbeddedPdbs + |> List.filter (fun a -> not (verifyEmbeddedPdb a)) + + if failedVerifyEmbeddedPdb.Length > 0 then + printfn "The following assemblies don't have an embedded pdb" + printfn "%s\r\n" <| String.Join("\r\n", failedVerifyEmbeddedPdb) + else + printfn "All shipping assemblies had an embedded PDB." + // return code is the number of failures - failedVersionCheck.Length + failedCommitHash.Length + failedVersionCheck.Length + failedCommitHash.Length + failedVerifyEmbeddedPdb.Length + +[] let main (argv:string array) = if argv.Length <> 1 then - printfn "Usage: fsi.exe AssemblyVersionCheck.fsx -- path/to/binaries" + printfn "Usage: dotnet AssemblyCheck.dll -- path/to/binaries" 1 else - AssemblyVersionCheck.verifyAssemblyVersions argv.[0] - -Environment.GetCommandLineArgs() -|> Seq.skipWhile ((<>) "--") -|> Seq.skip 1 -|> Array.ofSeq -|> main + AssemblyCheck.verifyAssemblies argv.[0] diff --git a/src/buildtools/AssemblyCheck/AssemblyCheck.fsproj b/src/buildtools/AssemblyCheck/AssemblyCheck.fsproj new file mode 100644 index 00000000000..72f79d02f93 --- /dev/null +++ b/src/buildtools/AssemblyCheck/AssemblyCheck.fsproj @@ -0,0 +1,17 @@ + + + + Exe + netcoreapp2.1 + true + + + + + + + + + + + diff --git a/src/buildtools/buildtools.proj b/src/buildtools/buildtools.proj index 630bb678561..7ac48ba2a37 100644 --- a/src/buildtools/buildtools.proj +++ b/src/buildtools/buildtools.proj @@ -8,6 +8,7 @@ + diff --git a/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec b/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec index d3756ebc392..a82fbb1ac3e 100644 --- a/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec +++ b/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec @@ -49,15 +49,7 @@ - - - - - - - + target="lib\netcoreapp2.1" /> @@ -69,9 +61,9 @@ + target="lib\netcoreapp2.1" /> + target="lib\netcoreapp2.1" /> diff --git a/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec b/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec index 750052c45db..ee7a88b29d6 100644 --- a/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec +++ b/src/fsharp/FSharp.Core.nuget/FSharp.Core.nuspec @@ -38,13 +38,11 @@ - - From 8e843ae254c7c1e2fd29dbe23e0b45e5fbf514d2 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2019 17:47:38 -0700 Subject: [PATCH 19/22] [master] Update dependencies from dotnet/arcade (#7269) * Update dependencies from https://github.com/dotnet/arcade build 20190723.6 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19373.6 * Update dependencies from https://github.com/dotnet/arcade build 20190724.2 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19374.2 * Update dependencies from https://github.com/dotnet/arcade build 20190725.2 - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19375.2 --- eng/Version.Details.xml | 4 +-- eng/common/build.sh | 0 eng/common/cibuild.sh | 0 eng/common/cross/armel/tizen-build-rootfs.sh | 0 eng/common/cross/armel/tizen-fetch.sh | 0 eng/common/cross/build-android-rootfs.sh | 0 eng/common/cross/build-rootfs.sh | 0 eng/common/darc-init.sh | 0 eng/common/dotnet-install.sh | 0 eng/common/init-tools-native.sh | 0 eng/common/internal-feed-operations.sh | 0 eng/common/msbuild.sh | 0 eng/common/native/common-library.sh | 0 eng/common/native/install-cmake.sh | 0 eng/common/performance/performance-setup.sh | 0 eng/common/pipeline-logging-functions.sh | 0 eng/common/post-build/darc-gather-drop.ps1 | 36 +++++++++++++++++++ .../channels/internal-servicing.yml | 23 ------------ .../channels/public-dev-release.yml | 24 ++----------- .../post-build/channels/public-release.yml | 23 ------------ .../channels/public-validation-release.yml | 26 ++------------ .../templates/post-build/darc-gather-drop.yml | 22 ++++++++++++ .../post-build/trigger-subscription.yml | 2 +- eng/common/tools.sh | 0 global.json | 2 +- 25 files changed, 68 insertions(+), 94 deletions(-) mode change 100644 => 100755 eng/common/build.sh mode change 100644 => 100755 eng/common/cibuild.sh mode change 100644 => 100755 eng/common/cross/armel/tizen-build-rootfs.sh mode change 100644 => 100755 eng/common/cross/armel/tizen-fetch.sh mode change 100644 => 100755 eng/common/cross/build-android-rootfs.sh mode change 100644 => 100755 eng/common/cross/build-rootfs.sh mode change 100644 => 100755 eng/common/darc-init.sh mode change 100644 => 100755 eng/common/dotnet-install.sh mode change 100644 => 100755 eng/common/init-tools-native.sh mode change 100644 => 100755 eng/common/internal-feed-operations.sh mode change 100644 => 100755 eng/common/msbuild.sh mode change 100644 => 100755 eng/common/native/common-library.sh mode change 100644 => 100755 eng/common/native/install-cmake.sh mode change 100644 => 100755 eng/common/performance/performance-setup.sh mode change 100644 => 100755 eng/common/pipeline-logging-functions.sh create mode 100644 eng/common/post-build/darc-gather-drop.ps1 create mode 100644 eng/common/templates/post-build/darc-gather-drop.yml mode change 100644 => 100755 eng/common/tools.sh diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index e278bed29a9..1ed95d393af 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 0793e2df782efc9ccae387bc779b2549208fa4a1 + 3dfa62fddcde597959c323d17426f215384e773a diff --git a/eng/common/build.sh b/eng/common/build.sh old mode 100644 new mode 100755 diff --git a/eng/common/cibuild.sh b/eng/common/cibuild.sh old mode 100644 new mode 100755 diff --git a/eng/common/cross/armel/tizen-build-rootfs.sh b/eng/common/cross/armel/tizen-build-rootfs.sh old mode 100644 new mode 100755 diff --git a/eng/common/cross/armel/tizen-fetch.sh b/eng/common/cross/armel/tizen-fetch.sh old mode 100644 new mode 100755 diff --git a/eng/common/cross/build-android-rootfs.sh b/eng/common/cross/build-android-rootfs.sh old mode 100644 new mode 100755 diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh old mode 100644 new mode 100755 diff --git a/eng/common/darc-init.sh b/eng/common/darc-init.sh old mode 100644 new mode 100755 diff --git a/eng/common/dotnet-install.sh b/eng/common/dotnet-install.sh old mode 100644 new mode 100755 diff --git a/eng/common/init-tools-native.sh b/eng/common/init-tools-native.sh old mode 100644 new mode 100755 diff --git a/eng/common/internal-feed-operations.sh b/eng/common/internal-feed-operations.sh old mode 100644 new mode 100755 diff --git a/eng/common/msbuild.sh b/eng/common/msbuild.sh old mode 100644 new mode 100755 diff --git a/eng/common/native/common-library.sh b/eng/common/native/common-library.sh old mode 100644 new mode 100755 diff --git a/eng/common/native/install-cmake.sh b/eng/common/native/install-cmake.sh old mode 100644 new mode 100755 diff --git a/eng/common/performance/performance-setup.sh b/eng/common/performance/performance-setup.sh old mode 100644 new mode 100755 diff --git a/eng/common/pipeline-logging-functions.sh b/eng/common/pipeline-logging-functions.sh old mode 100644 new mode 100755 diff --git a/eng/common/post-build/darc-gather-drop.ps1 b/eng/common/post-build/darc-gather-drop.ps1 new file mode 100644 index 00000000000..9cc2f1a0091 --- /dev/null +++ b/eng/common/post-build/darc-gather-drop.ps1 @@ -0,0 +1,36 @@ +param( + [Parameter(Mandatory=$true)][string] $BarBuildId, # ID of the build which assets should be downloaded + [Parameter(Mandatory=$true)][string] $MaestroAccessToken, # Token used to access Maestro API + [Parameter(Mandatory=$true)][string] $DropLocation # Where the assets should be downloaded to +) + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 2.0 + +. $PSScriptRoot\..\tools.ps1 + +try { + Write-Host "Installing DARC ..." + + . $PSScriptRoot\..\darc-init.ps1 + $exitCode = $LASTEXITCODE + + if ($exitCode -ne 0) { + Write-PipelineTaskError "Something failed while running 'darc-init.ps1'. Check for errors above. Exiting now..." + ExitWithExitCode $exitCode + } + + darc gather-drop --non-shipping ` + --continue-on-error ` + --id $BarBuildId ` + --output-dir $DropLocation ` + --bar-uri https://maestro-prod.westus2.cloudapp.azure.com/ ` + --password $MaestroAccessToken ` + --latest-location +} +catch { + Write-Host $_ + Write-Host $_.Exception + Write-Host $_.ScriptStackTrace + ExitWithExitCode 1 +} diff --git a/eng/common/templates/post-build/channels/internal-servicing.yml b/eng/common/templates/post-build/channels/internal-servicing.yml index 648e854e0ed..5c07b66926f 100644 --- a/eng/common/templates/post-build/channels/internal-servicing.yml +++ b/eng/common/templates/post-build/channels/internal-servicing.yml @@ -143,29 +143,6 @@ stages: filePath: $(Build.SourcesDirectory)/eng/common/post-build/symbols-validation.ps1 arguments: -InputPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ -ExtractPath $(Agent.BuildDirectory)/Temp/ -DotnetSymbolVersion $(SymbolToolVersion) - - job: - displayName: Gather Drop - dependsOn: setupMaestroVars - variables: - BARBuildId: $[ dependencies.setupMaestroVars.outputs['setReleaseVars.BARBuildId'] ] - condition: contains(dependencies.setupMaestroVars.outputs['setReleaseVars.InitialChannels'], variables.InternalServicing_30_Channel_Id) - pool: - vmImage: 'windows-2019' - steps: - - task: PowerShell@2 - displayName: Setup Darc CLI - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/eng/common/darc-init.ps1' - - - task: PowerShell@2 - displayName: Run Darc gather-drop - inputs: - targetType: inline - script: | - darc gather-drop --non-shipping --continue-on-error --id $(BARBuildId) --output-dir $(Agent.BuildDirectory)/Temp/Drop/ --bar-uri https://maestro-prod.westus2.cloudapp.azure.com/ --password $(MaestroAccessToken) --latest-location - enabled: false - - template: ../promote-build.yml parameters: ChannelId: ${{ variables.InternalServicing_30_Channel_Id }} diff --git a/eng/common/templates/post-build/channels/public-dev-release.yml b/eng/common/templates/post-build/channels/public-dev-release.yml index bdc631016b6..b46b0699233 100644 --- a/eng/common/templates/post-build/channels/public-dev-release.yml +++ b/eng/common/templates/post-build/channels/public-dev-release.yml @@ -140,27 +140,9 @@ stages: filePath: $(Build.SourcesDirectory)/eng/common/post-build/symbols-validation.ps1 arguments: -InputPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ -ExtractPath $(Agent.BuildDirectory)/Temp/ -DotnetSymbolVersion $(SymbolToolVersion) - - job: - displayName: Gather Drop - dependsOn: setupMaestroVars - variables: - BARBuildId: $[ dependencies.setupMaestroVars.outputs['setReleaseVars.BARBuildId'] ] - condition: contains(dependencies.setupMaestroVars.outputs['setReleaseVars.InitialChannels'], variables.PublicDevRelease_30_Channel_Id) - pool: - vmImage: 'windows-2019' - steps: - - task: PowerShell@2 - displayName: Setup Darc CLI - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/eng/common/darc-init.ps1' - - - task: PowerShell@2 - displayName: Run Darc gather-drop - inputs: - targetType: inline - script: | - darc gather-drop --non-shipping --continue-on-error --id $(BARBuildId) --output-dir $(Agent.BuildDirectory)/Temp/Drop/ --bar-uri https://maestro-prod.westus2.cloudapp.azure.com/ --password $(MaestroAccessToken) --latest-location + - template: ../darc-gather-drop.yml + parameters: + ChannelId: ${{ variables.PublicDevRelease_30_Channel_Id }} - template: ../promote-build.yml parameters: diff --git a/eng/common/templates/post-build/channels/public-release.yml b/eng/common/templates/post-build/channels/public-release.yml index f6a7efdfe9d..a31d37139b7 100644 --- a/eng/common/templates/post-build/channels/public-release.yml +++ b/eng/common/templates/post-build/channels/public-release.yml @@ -143,29 +143,6 @@ stages: filePath: $(Build.SourcesDirectory)/eng/common/post-build/symbols-validation.ps1 arguments: -InputPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ -ExtractPath $(Agent.BuildDirectory)/Temp/ -DotnetSymbolVersion $(SymbolToolVersion) - - job: - displayName: Gather Drop - dependsOn: setupMaestroVars - variables: - BARBuildId: $[ dependencies.setupMaestroVars.outputs['setReleaseVars.BARBuildId'] ] - condition: contains(dependencies.setupMaestroVars.outputs['setReleaseVars.InitialChannels'], variables.PublicRelease_30_Channel_Id) - pool: - vmImage: 'windows-2019' - steps: - - task: PowerShell@2 - displayName: Setup Darc CLI - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/eng/common/darc-init.ps1' - - - task: PowerShell@2 - displayName: Run Darc gather-drop - inputs: - targetType: inline - script: | - darc gather-drop --non-shipping --continue-on-error --id $(BARBuildId) --output-dir $(Agent.BuildDirectory)/Temp/Drop/ --bar-uri https://maestro-prod.westus2.cloudapp.azure.com/ --password $(MaestroAccessToken) --latest-location - enabled: false - - template: ../promote-build.yml parameters: ChannelId: ${{ variables.PublicRelease_30_Channel_Id }} diff --git a/eng/common/templates/post-build/channels/public-validation-release.yml b/eng/common/templates/post-build/channels/public-validation-release.yml index f12f402ad9a..02dae0937da 100644 --- a/eng/common/templates/post-build/channels/public-validation-release.yml +++ b/eng/common/templates/post-build/channels/public-validation-release.yml @@ -91,29 +91,9 @@ stages: jobs: - template: ../setup-maestro-vars.yml - - job: - displayName: Gather Drop - dependsOn: setupMaestroVars - condition: contains(dependencies.setupMaestroVars.outputs['setReleaseVars.InitialChannels'], variables.PublicValidationRelease_30_Channel_Id) - variables: - - name: BARBuildId - value: $[ dependencies.setupMaestroVars.outputs['setReleaseVars.BARBuildId'] ] - - group: Publish-Build-Assets - pool: - vmImage: 'windows-2019' - steps: - - task: PowerShell@2 - displayName: Setup Darc CLI - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/eng/common/darc-init.ps1' - - - task: PowerShell@2 - displayName: Run Darc gather-drop - inputs: - targetType: inline - script: | - darc gather-drop --non-shipping --continue-on-error --id $(BARBuildId) --output-dir $(Agent.BuildDirectory)/Temp/Drop/ --bar-uri https://maestro-prod.westus2.cloudapp.azure.com --password $(MaestroAccessToken) --latest-location + - template: ../darc-gather-drop.yml + parameters: + ChannelId: ${{ variables.PublicValidationRelease_30_Channel_Id }} - template: ../promote-build.yml parameters: diff --git a/eng/common/templates/post-build/darc-gather-drop.yml b/eng/common/templates/post-build/darc-gather-drop.yml new file mode 100644 index 00000000000..e0a9f0a6d26 --- /dev/null +++ b/eng/common/templates/post-build/darc-gather-drop.yml @@ -0,0 +1,22 @@ +parameters: + ChannelId: 0 + +jobs: +- job: gatherDrop + displayName: Gather Drop + dependsOn: setupMaestroVars + condition: contains(dependencies.setupMaestroVars.outputs['setReleaseVars.InitialChannels'], ${{ parameters.ChannelId }}) + variables: + - group: Publish-Build-Assets + - name: BARBuildId + value: $[ dependencies.setupMaestroVars.outputs['setReleaseVars.BARBuildId'] ] + pool: + vmImage: 'windows-2019' + steps: + - task: PowerShell@2 + displayName: Darc gather-drop + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/post-build/darc-gather-drop.ps1 + arguments: -BarBuildId $(BARBuildId) + -DropLocation $(Agent.BuildDirectory)/Temp/Drop/ + -MaestroAccessToken $(MaestroAccessToken) diff --git a/eng/common/templates/post-build/trigger-subscription.yml b/eng/common/templates/post-build/trigger-subscription.yml index 65259d4e685..3915cdcd1ad 100644 --- a/eng/common/templates/post-build/trigger-subscription.yml +++ b/eng/common/templates/post-build/trigger-subscription.yml @@ -8,4 +8,4 @@ steps: filePath: $(Build.SourcesDirectory)/eng/common/post-build/trigger-subscriptions.ps1 arguments: -SourceRepo $(Build.Repository.Uri) -ChannelId ${{ parameters.ChannelId }} - -BarToken $(MaestroAccessTokenInt) \ No newline at end of file + -BarToken $(MaestroAccessToken) diff --git a/eng/common/tools.sh b/eng/common/tools.sh old mode 100644 new mode 100755 diff --git a/global.json b/global.json index 1d496dc84bf..ef694a9855a 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19372.10", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19375.2", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From ce483c0e01625949a49aeb45c97d87d0549773c5 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2019 12:37:13 -0700 Subject: [PATCH 20/22] Update dependencies from https://github.com/dotnet/arcade build 20190725.15 (#7282) - Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19375.15 --- eng/Version.Details.xml | 4 +-- eng/common/init-tools-native.ps1 | 2 +- eng/common/native/CommonLibrary.psm1 | 33 +++++++++++++++++-- .../channels/public-dev-release.yml | 2 +- .../channels/public-validation-release.yml | 2 +- eng/common/tools.sh | 4 +-- global.json | 2 +- 7 files changed, 39 insertions(+), 10 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 1ed95d393af..7a0a634b410 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - 3dfa62fddcde597959c323d17426f215384e773a + ef1c110152df0d500fffb87878a86f88d1ca5295 diff --git a/eng/common/init-tools-native.ps1 b/eng/common/init-tools-native.ps1 index eaa05880c55..8cf18bcfeba 100644 --- a/eng/common/init-tools-native.ps1 +++ b/eng/common/init-tools-native.ps1 @@ -98,7 +98,7 @@ try { } Write-Verbose "Installing $ToolName version $ToolVersion" - Write-Verbose "Executing '$InstallerPath $LocalInstallerArguments'" + Write-Verbose "Executing '$InstallerPath $($LocalInstallerArguments.Keys.ForEach({"-$_ '$($LocalInstallerArguments.$_)'"}) -join ' ')'" & $InstallerPath @LocalInstallerArguments if ($LASTEXITCODE -Ne "0") { $errMsg = "$ToolName installation failed" diff --git a/eng/common/native/CommonLibrary.psm1 b/eng/common/native/CommonLibrary.psm1 index 7a34c7e8a42..2a08d5246e7 100644 --- a/eng/common/native/CommonLibrary.psm1 +++ b/eng/common/native/CommonLibrary.psm1 @@ -59,9 +59,38 @@ function DownloadAndExtract { -Verbose:$Verbose if ($UnzipStatus -Eq $False) { - Write-Error "Unzip failed" - return $False + # Retry Download one more time with Force=true + $DownloadRetryStatus = CommonLibrary\Get-File -Uri $Uri ` + -Path $TempToolPath ` + -DownloadRetries 1 ` + -RetryWaitTimeInSeconds $RetryWaitTimeInSeconds ` + -Force:$True ` + -Verbose:$Verbose + + if ($DownloadRetryStatus -Eq $False) { + Write-Error "Last attempt of download failed as well" + return $False + } + + # Retry unzip again one more time with Force=true + $UnzipRetryStatus = CommonLibrary\Expand-Zip -ZipPath $TempToolPath ` + -OutputDirectory $InstallDirectory ` + -Force:$True ` + -Verbose:$Verbose + if ($UnzipRetryStatus -Eq $False) + { + Write-Error "Last attempt of unzip failed as well" + # Clean up partial zips and extracts + if (Test-Path $TempToolPath) { + Remove-Item $TempToolPath -Force + } + if (Test-Path $InstallDirectory) { + Remove-Item $InstallDirectory -Force -Recurse + } + return $False + } } + return $True } diff --git a/eng/common/templates/post-build/channels/public-dev-release.yml b/eng/common/templates/post-build/channels/public-dev-release.yml index b46b0699233..4eaa6e4ff0f 100644 --- a/eng/common/templates/post-build/channels/public-dev-release.yml +++ b/eng/common/templates/post-build/channels/public-dev-release.yml @@ -77,7 +77,7 @@ stages: filePath: eng\common\sdk-task.ps1 arguments: -task PublishArtifactsInManifest -restore -msbuildEngine dotnet /p:ChannelId=$(PublicDevRelease_30_Channel_Id) - /p:ArtifactsCategory=.NetCore + /p:ArtifactsCategory=$(_DotNetArtifactsCategory) /p:IsStableBuild=$(IsStableBuild) /p:IsInternalBuild=$(IsInternalBuild) /p:RepositoryName=$(Build.Repository.Name) diff --git a/eng/common/templates/post-build/channels/public-validation-release.yml b/eng/common/templates/post-build/channels/public-validation-release.yml index 02dae0937da..8c4d8f6ef33 100644 --- a/eng/common/templates/post-build/channels/public-validation-release.yml +++ b/eng/common/templates/post-build/channels/public-validation-release.yml @@ -48,7 +48,7 @@ stages: filePath: eng\common\sdk-task.ps1 arguments: -task PublishArtifactsInManifest -restore -msbuildEngine dotnet /p:ChannelId=$(PublicValidationRelease_30_Channel_Id) - /p:ArtifactsCategory=.NetCoreValidation + /p:ArtifactsCategory=$(_DotNetArtifactsCategory) /p:IsStableBuild=$(IsStableBuild) /p:IsInternalBuild=$(IsInternalBuild) /p:RepositoryName=$(Build.Repository.Name) diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 0deb01c480b..738bb5669da 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -77,7 +77,7 @@ function ReadGlobalVersion { local pattern="\"$key\" *: *\"(.*)\"" if [[ ! $line =~ $pattern ]]; then - Write-PipelineTelemetryError -category 'InitializeTools' "Error: Cannot find \"$key\" in $global_json_file" + Write-PipelineTelemetryError -category 'InitializeToolset' "Error: Cannot find \"$key\" in $global_json_file" ExitWithExitCode 1 fi @@ -245,7 +245,7 @@ function InitializeNativeTools() { then local nativeArgs="" if [[ "$ci" == true ]]; then - nativeArgs="-InstallDirectory $tools_dir" + nativeArgs="--installDirectory $tools_dir" fi "$_script_dir/init-tools-native.sh" $nativeArgs fi diff --git a/global.json b/global.json index ef694a9855a..67df8eb1531 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19375.2", + "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19375.15", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From 969a9c4661b277093aedf804e92d68532f991b92 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Fri, 26 Jul 2019 15:42:35 -0700 Subject: [PATCH 21/22] Fix test assert (#7283) --- tests/fsharp/Compiler/CompilerAssert.fs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index 9f64824bb48..c663e9b9c29 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -290,8 +290,10 @@ let main argv = 0""" Assert.AreEqual(expectedErrorMessage, errorMessage) ) - let ParseWithErrors (source: string) expectedParseErrors = - let parseResults = checker.ParseFile("test.fs", SourceText.ofString source, FSharpParsingOptions.Default) |> Async.RunSynchronously + let ParseWithErrors (source: string) expectedParseErrors = + let sourceFileName = "test.fs" + let parsingOptions = { FSharpParsingOptions.Default with SourceFiles = [| sourceFileName |] } + let parseResults = checker.ParseFile(sourceFileName, SourceText.ofString source, parsingOptions) |> Async.RunSynchronously Assert.True(parseResults.ParseHadErrors) From c03755fa47fe9660b40394b3e45779b9e02e409b Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Fri, 26 Jul 2019 21:31:00 -0700 Subject: [PATCH 22/22] disablewarningtests --- .../ErrorMessages/WarnExpressionTests.fs | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs b/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs index 557aa81a4d4..7bf6cc211c1 100644 --- a/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs +++ b/tests/fsharp/Compiler/ErrorMessages/WarnExpressionTests.fs @@ -105,9 +105,10 @@ let changeX() = (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'." - [] + // [] // Disable this test until we refactor tcImports and tcGlobals let ``Warn If Discarded In List``() = - CompilerAssert.TypeCheckSingleError + CompilerAssert.TypeCheckWithErrorsAndOptions + [| "--langversion:4.6" |] """ let div _ _ = 1 let subView _ _ = [1; 2] @@ -119,14 +120,17 @@ let view 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'." + [| + 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'." + |] - [] + // [] // Disable this test until we refactor tcImports and tcGlobals let ``Warn If Discarded In List 2``() = - CompilerAssert.TypeCheckSingleError + CompilerAssert.TypeCheckWithErrorsAndOptions + [| "--langversion:4.6" |] """ // stupid things to make the sample compile let div _ _ = 1 @@ -143,14 +147,17 @@ let view 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!'." + [| + 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!'." + |] - [] + // [] // Disable this test until we refactor tcImports and tcGlobals let ``Warn If Discarded In List 3``() = - CompilerAssert.TypeCheckSingleError + CompilerAssert.TypeCheckWithErrorsAndOptions + [| "--langversion:4.6" |] """ // stupid things to make the sample compile let div _ _ = 1 @@ -167,10 +174,12 @@ let view 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'." + [| + 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'." + |] [] let ``Warn Only On Last Expression``() =