From 33ec62c0727754e63fa20dc03b8f74e576ad32d8 Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 5 Jan 2021 11:50:37 -0800 Subject: [PATCH 01/14] Turn on unused warnings by default --- src/fsharp/CompilerDiagnostics.fs | 3 +- .../CreateFSharpManifestResourceName.fs | 2 +- .../FSharp.Build/FSharpEmbedResourceText.fs | 8 +- src/fsharp/FSharp.Build/Fsc.fs | 6 +- src/fsharp/FSharp.Build/Fsi.fs | 13 +-- src/fsharp/FSharp.Build/MapSourceRoots.fs | 2 +- .../FSharpInteractiveServer.fs | 2 +- .../FSharp.Build.UnitTests.fsproj | 1 + .../ErrorMessages/WarnExpressionTests.fs | 2 +- .../RecordTypes/Overload_Equals.fs | 4 +- .../RecordTypes/Overload_GetHashCode.fs | 4 +- .../RecordTypes/Overload_ToString.fs | 4 +- .../UnionTypes/Overload_Equals.fs | 4 +- .../UnionTypes/Overload_GetHashCode.fs | 4 +- .../UnionTypes/Overload_ToString.fs | 4 +- .../Shift/Generics/RightShift001.fs | 2 +- .../Shift/Generics/RightShift002.fs | 2 +- .../IndentationWithComputationExpression01.fs | 4 +- .../StructTypes/Overload_Equals.fs | 4 +- .../StructTypes/Overload_GetHashCode.fs | 4 +- .../StructTypes/Overload_ToString.fs | 4 +- .../Conformance/UnitsOfMeasure/Basic/Stats.fs | 2 +- .../TypeChecker/GenericSubType01.fs | 2 +- .../FSharp.Compiler.Service.Tests.fsproj | 2 + .../FSharp.Compiler.UnitTests.fsproj | 2 +- .../FSharp.Core.UnitTests.fsproj | 1 + tests/fsharp/FSharpSuite.Tests.fsproj | 2 +- .../RedundantNewDiagnosticAnalyzer.fs | 82 +++++++++++++++++++ .../GetTypesVS.UnitTests.fsproj | 2 +- ...myProviderForLanguageServiceTesting.fsproj | 1 + .../tests/Salsa/VisualFSharp.Salsa.fsproj | 1 + .../UnitTests/VisualFSharp.UnitTests.fsproj | 2 +- 32 files changed, 129 insertions(+), 53 deletions(-) create mode 100644 vsintegration/src/FSharp.Editor/Diagnostics/RedundantNewDiagnosticAnalyzer.fs diff --git a/src/fsharp/CompilerDiagnostics.fs b/src/fsharp/CompilerDiagnostics.fs index 4e8fffc493d..2e4822f557d 100644 --- a/src/fsharp/CompilerDiagnostics.fs +++ b/src/fsharp/CompilerDiagnostics.fs @@ -374,8 +374,7 @@ let warningOn err level specificWarnOn = let n = GetDiagnosticNumber err List.contains n specificWarnOn || // Some specific warnings are never on by default, i.e. unused variable warnings - match n with - | 1182 -> false // chkUnusedValue - off by default + match n with | 3180 -> false // abImplicitHeapAllocation - off by default | _ -> level >= GetWarningLevel err diff --git a/src/fsharp/FSharp.Build/CreateFSharpManifestResourceName.fs b/src/fsharp/FSharp.Build/CreateFSharpManifestResourceName.fs index e4defc092e6..1e981b88503 100644 --- a/src/fsharp/FSharp.Build/CreateFSharpManifestResourceName.fs +++ b/src/fsharp/FSharp.Build/CreateFSharpManifestResourceName.fs @@ -19,7 +19,7 @@ type CreateFSharpManifestResourceName public () = (linkFileName:string), (rootNamespace:string), (* may be null *) (dependentUponFileName:string), (* may be null *) - (binaryStream:System.IO.Stream) (* may be null *)) : string = + (_binaryStream:System.IO.Stream) (* may be null *)) : string = // The Visual CSharp and XBuild CSharp toolchains transform resource names like this: // SubDir\abc.resx --> SubDir.abc.resources diff --git a/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs b/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs index 3428d60ad8f..f0abd155b95 100644 --- a/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs @@ -356,7 +356,7 @@ open Printf printMessage (sprintf "Reading %s" filename) let lines = File.ReadAllLines(filename) |> Array.mapi (fun i s -> i,s) // keep line numbers - |> Array.filter (fun (i,s) -> not(s.StartsWith "#")) // filter out comments + |> Array.filter (fun (_,s) -> not(s.StartsWith "#")) // filter out comments printMessage (sprintf "Parsing %s" filename) let stringInfos = lines |> Array.map (fun (i,s) -> ParseLine filename i s) @@ -391,7 +391,7 @@ open Printf printMessage (sprintf "Generating resource methods for %s" outFilename) // gen each resource method - stringInfos |> Seq.iter (fun (lineNum, (optErrNum,ident), str, holes, netFormatString) -> + stringInfos |> Seq.iter (fun (lineNum, (optErrNum,ident), str, holes, _) -> let formalArgs = new System.Text.StringBuilder() let actualArgs = new System.Text.StringBuilder() let mutable firstTime = true @@ -428,14 +428,14 @@ open Printf // gen validation method fprintfn out " /// Call this method once to validate that all known resources are valid; throws if not" fprintfn out " static member RunStartupValidation() =" - stringInfos |> Seq.iter (fun (lineNum, (optErrNum,ident), str, holes, netFormatString) -> + stringInfos |> Seq.iter (fun (_, (_,ident), _, _, _) -> fprintfn out " ignore(GetString(\"%s\"))" ident ) fprintfn out " ()" // in case there are 0 strings, we need the generated code to parse // gen to resx let xd = new System.Xml.XmlDocument() xd.LoadXml(xmlBoilerPlateString) - stringInfos |> Seq.iter (fun (lineNum, (optErrNum,ident), str, holes, netFormatString) -> + stringInfos |> Seq.iter (fun (_, (_,ident), _, _, netFormatString) -> let xn = xd.CreateElement("data") xn.SetAttribute("name",ident) |> ignore xn.SetAttribute("xml:space","preserve") |> ignore diff --git a/src/fsharp/FSharp.Build/Fsc.fs b/src/fsharp/FSharp.Build/Fsc.fs index 74632ca2044..7399f363b36 100644 --- a/src/fsharp/FSharp.Build/Fsc.fs +++ b/src/fsharp/FSharp.Build/Fsc.fs @@ -63,7 +63,6 @@ type public Fsc () as this = let mutable tailcalls : bool = true let mutable targetProfile : string = null let mutable targetType : string = null - let mutable toolExe : string = "fsc.exe" let defaultToolPath = let locationOfThisDll = try Some(Path.GetDirectoryName(typeof.Assembly.Location)) @@ -568,7 +567,6 @@ type public Fsc () as this = match host with | null -> base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands) | _ -> - let sources = sources|>Array.map(fun i->i.ItemSpec) let invokeCompiler baseCallDelegate = try let ret = @@ -581,8 +579,8 @@ type public Fsc () as this = // Do a string compare on the type name to do eliminate a compile time dependency on Microsoft.Build.dll | :? TargetInvocationException as tie when not (isNull tie.InnerException) && (tie.InnerException).GetType().FullName = "Microsoft.Build.Exceptions.BuildAbortedException" -> fsc.Log.LogError(tie.InnerException.Message, [| |]) - -1 - | e -> reraise() + -1 // ok, this is what happens when VS IDE cancels the build, no need to assert, just log the build-canceled error and return -1 to denote task failed + | _ -> reraise() let baseCallDelegate = Func(fun () -> fsc.BaseExecuteTool(pathToTool, responseFileCommands, commandLineCommands) ) try diff --git a/src/fsharp/FSharp.Build/Fsi.fs b/src/fsharp/FSharp.Build/Fsi.fs index ffe833e0e01..c7b71c7c1d1 100644 --- a/src/fsharp/FSharp.Build/Fsi.fs +++ b/src/fsharp/FSharp.Build/Fsi.fs @@ -37,15 +37,12 @@ type public Fsi () as this = let mutable provideCommandLineArgs = false let mutable references : ITaskItem[] = [||] let mutable referencePath : string = null - let mutable resources : ITaskItem[] = [||] let mutable skipCompilerExecution = false let mutable sources : ITaskItem[] = [||] let mutable loadSources : ITaskItem[] = [||] let mutable useSources : ITaskItem[] = [||] let mutable tailcalls : bool = true let mutable targetProfile : string = null - let mutable targetType : string = null - let mutable toolExe : string = "fsi.exe" let mutable toolPath : string = let locationOfThisDll = try Some(Path.GetDirectoryName(typeof.Assembly.Location)) @@ -85,11 +82,6 @@ type public Fsi () as this = for item in references do builder.AppendSwitchIfNotNull("-r:", item.ItemSpec) - let referencePathArray = // create a array of strings - match referencePath with - | null -> null - | _ -> referencePath.Split([|';'; ','|], StringSplitOptions.RemoveEmptyEntries) - // NoWarn match disabledWarnings with | null -> () @@ -293,7 +285,6 @@ type public Fsi () as this = match host with | null -> base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands) | _ -> - let sources = sources|>Array.map(fun i->i.ItemSpec) let invokeCompiler baseCallDelegate = try let ret = @@ -306,8 +297,8 @@ type public Fsi () as this = // Do a string compare on the type name to do eliminate a compile time dependency on Microsoft.Build.dll | :? TargetInvocationException as tie when not (isNull tie.InnerException) && (tie.InnerException).GetType().FullName = "Microsoft.Build.Exceptions.BuildAbortedException" -> fsi.Log.LogError(tie.InnerException.Message, [| |]) - -1 - | e -> reraise() + -1 // ok, this is what happens when VS IDE cancels the build, no need to assert, just log the build-canceled error and return -1 to denote task failed + | _ -> reraise() let baseCallDelegate = Func(fun () -> fsi.BaseExecuteTool(pathToTool, responseFileCommands, commandLineCommands) ) try diff --git a/src/fsharp/FSharp.Build/MapSourceRoots.fs b/src/fsharp/FSharp.Build/MapSourceRoots.fs index 84310352b8d..2d1b671bf54 100644 --- a/src/fsharp/FSharp.Build/MapSourceRoots.fs +++ b/src/fsharp/FSharp.Build/MapSourceRoots.fs @@ -122,7 +122,7 @@ type MapSourceRoots () = for root in mappedSourceRoots do match root.GetMetadata SourceControl with - | HasValue v when isSourceControlled -> mapNestedRootIfEmpty root + | HasValue _ when isSourceControlled -> mapNestedRootIfEmpty root | NullOrEmpty when not isSourceControlled -> mapNestedRootIfEmpty root | _ -> () diff --git a/src/fsharp/FSharp.Compiler.Server.Shared/FSharpInteractiveServer.fs b/src/fsharp/FSharp.Compiler.Server.Shared/FSharpInteractiveServer.fs index eca486f48cc..bc13218a5d8 100644 --- a/src/fsharp/FSharp.Compiler.Server.Shared/FSharpInteractiveServer.fs +++ b/src/fsharp/FSharp.Compiler.Server.Shared/FSharpInteractiveServer.fs @@ -37,7 +37,7 @@ type internal FSharpInteractiveServer() = LifetimeServices.RenewOnCallTime <- TimeSpan(7,0,0,0); LifetimeServices.SponsorshipTimeout <- TimeSpan(7,0,0,0); ChannelServices.RegisterChannel(chan,false); - let objRef = RemotingServices.Marshal(server,"FSIServer") + RemotingServices.Marshal(server,"FSIServer") |> ignore () static member StartClient(channelName) = diff --git a/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj b/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj index 2572d28cc62..a3fa15b8a1e 100644 --- a/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj +++ b/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj @@ -8,6 +8,7 @@ Library true nunit + 1182 diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs index 1380869d383..95f986f6dd5 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs @@ -70,7 +70,7 @@ let changeProperty() = [] let ``Don't Warn If Property Without Setter``() = FSharp """ -type MyClass(property1 : int) = +type MyClass(_property1 : int) = member val Property2 = "" with get let x = MyClass(1) diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_Equals.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_Equals.fs index 5749edc7ef8..0e2822484c9 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_Equals.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_Equals.fs @@ -4,9 +4,9 @@ type R = { x: int } - member this.Equals(s:char) = true + member this.Equals(_:char) = true // member this.Equals(s:R) = 1. - member this.Equals(?s:char) = true + member this.Equals(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_GetHashCode.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_GetHashCode.fs index 25aa07cd456..dddc506aa4f 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_GetHashCode.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_GetHashCode.fs @@ -3,9 +3,9 @@ // Overloading of GetHashCode() type R = { x: int } - member this.GetHashCode(s:char) = 1 + member this.GetHashCode(_s:char) = 1 //member this.GetHashCode() = 1. - member this.GetHashCode(?s:char) = 1 + member this.GetHashCode(?_s:char) = 1 #if INTERACTIVE exit 0;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_ToString.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_ToString.fs index 2e651f776dd..cb3c47a39ac 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_ToString.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_ToString.fs @@ -4,9 +4,9 @@ type R = { x: int } - member this.ToString(s:char) = true + member this.ToString(_s:char) = true member this.ToString() = true - member this.ToString(?s:char) = true + member this.ToString(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_Equals.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_Equals.fs index 0e289605e5a..7eab984dc44 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_Equals.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_Equals.fs @@ -3,9 +3,9 @@ // Overloading of Equals() type DU = | A - member this.Equals(s:char) = true + member this.Equals(_s:char) = true //member this.Equals(s:DU) = 1. - member this.Equals(?s:char) = true + member this.Equals(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_GetHashCode.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_GetHashCode.fs index f85e1c1dbd1..8e4d6dba20a 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_GetHashCode.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_GetHashCode.fs @@ -3,9 +3,9 @@ // Overloading of GetHashCode() type DU = | A - member this.GetHashCode(s:char) = 1 + member this.GetHashCode(_s:char) = 1 //member this.GetHashCode() = 1. - member this.GetHashCode(?s:char) = 1 + member this.GetHashCode(?_s:char) = 1 #if INTERACTIVE exit 0;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_ToString.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_ToString.fs index 64400c453da..2e4b6e8d6d8 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_ToString.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_ToString.fs @@ -3,9 +3,9 @@ // Overloading of ToString() type DU = | A - member this.ToString(s:char) = true + member this.ToString(_s:char) = true member this.ToString() = true - member this.ToString(?s:char) = true + member this.ToString(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalAnalysis/Shift/Generics/RightShift001.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalAnalysis/Shift/Generics/RightShift001.fs index 251673d2e07..acea144b3cd 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalAnalysis/Shift/Generics/RightShift001.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalAnalysis/Shift/Generics/RightShift001.fs @@ -9,4 +9,4 @@ type ID<'T> = static member id (x:'T) = x -let f x = ID>.id (* ok *) +let f _x = ID>.id (* ok *) diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalAnalysis/Shift/Generics/RightShift002.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalAnalysis/Shift/Generics/RightShift002.fs index ec1187fbd79..a3333984cb3 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalAnalysis/Shift/Generics/RightShift002.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalAnalysis/Shift/Generics/RightShift002.fs @@ -9,4 +9,4 @@ type ID<'T> = static member id (x:'T) = x -let f x = ID> .id (* ok *) +let f _x = ID> .id (* ok *) diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalFiltering/HashLight/IndentationWithComputationExpression01.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalFiltering/HashLight/IndentationWithComputationExpression01.fs index 5121084b063..c4e4117e82c 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalFiltering/HashLight/IndentationWithComputationExpression01.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/LexicalFiltering/HashLight/IndentationWithComputationExpression01.fs @@ -10,7 +10,7 @@ async { return 5 } ) - let! b = a - for i in 1..10000 do + let! _b = a + for _ in 1..10000 do () } |> Async.RunSynchronously diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_Equals.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_Equals.fs index 398f407add6..3e38632656f 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_Equals.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_Equals.fs @@ -4,9 +4,9 @@ [] type S3 = - member this.Equals(s:char) = true + member this.Equals(_s:char) = true //member this.Equals(s:S3) = 1. - member this.Equals(?s:char) = true + member this.Equals(?_s:char) = true #if INTERACTIVE ;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_GetHashCode.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_GetHashCode.fs index aca1cc87f7b..8ef04689c68 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_GetHashCode.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_GetHashCode.fs @@ -4,9 +4,9 @@ [] type S2 = - member this.GetHashCode(s:char) = 1 + member this.GetHashCode(_s:char) = 1 //member this.GetHashCode() = 1. - member this.GetHashCode(?s:char) = 1 + member this.GetHashCode(?_s:char) = 1 #if INTERACTIVE ;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_ToString.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_ToString.fs index 8a5ad46511f..af2c64e3c6c 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_ToString.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_ToString.fs @@ -4,9 +4,9 @@ [] type S1 = - member this.ToString(s:char) = true + member this.ToString(_s:char) = true member this.ToString() = true - member this.ToString(?s:char) = true + member this.ToString(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/UnitsOfMeasure/Basic/Stats.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/UnitsOfMeasure/Basic/Stats.fs index 8bdb04c9dc1..7158a8f5a04 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/UnitsOfMeasure/Basic/Stats.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/UnitsOfMeasure/Basic/Stats.fs @@ -18,7 +18,7 @@ let variance xs = let m = mean xs in meanMap (fun x -> sqr (x-m)) xs let sdeviation xs = sqrt (variance xs) let skewness xs = - let n = float (List.length xs) + let _n = float (List.length xs) let m = mean xs let s = sdeviation xs meanMap (fun x -> cube(x-m)) xs / (cube s) diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/UnitsOfMeasure/TypeChecker/GenericSubType01.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/UnitsOfMeasure/TypeChecker/GenericSubType01.fs index b6a3b29de86..3f7042a9d17 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/UnitsOfMeasure/TypeChecker/GenericSubType01.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/UnitsOfMeasure/TypeChecker/GenericSubType01.fs @@ -5,7 +5,7 @@ type SC< [] 'u>() = class end type TC< [] 'u>() = inherit SC<'u>() -let wff (x:SC<'u>) = () +let wff (_x:SC<'u>) = () let wgg (x:TC<'v>) = wff x // OK diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index ec7f2fa2f84..25e79535e7d 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -4,6 +4,8 @@ Exe net472;net5.0 $(NoWarn);44;75; + netcoreapp3.1 + $(NoWarn);44;75;1182 true false true diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 643c86038f6..0016c397d81 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -9,7 +9,7 @@ true $(DefineConstants);ASSUME_PREVIEW_FSHARP_CORE xunit - $(NoWarn);3186;1104 + $(NoWarn);3186;1104;1182 diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj index e0d363f10a2..b093c728e27 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj +++ b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj @@ -6,6 +6,7 @@ net472;net5.0 net5.0 Library + 1182 FSharp.Core.UnitTests Microsoft.FSharp.Core.UnitTests diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index a6f0066aca0..cd29f82c15d 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -13,7 +13,7 @@ false $(OtherFlags) --warnon:1182 nunit - 3186 + 3186;1182 diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/RedundantNewDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/RedundantNewDiagnosticAnalyzer.fs new file mode 100644 index 00000000000..956669396ed --- /dev/null +++ b/vsintegration/src/FSharp.Editor/Diagnostics/RedundantNewDiagnosticAnalyzer.fs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Microsoft.VisualStudio.FSharp.Editor + +open System.Composition +open System.Collections.Immutable +open System.Threading +open System.Threading.Tasks + +open Microsoft.CodeAnalysis +open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics + +open FSharp.Compiler.CodeAnalysis +open FSharp.Compiler.Syntax +open FSharp.Compiler.Text +open FSharp.Compiler.Symbols + +[] +module Ass = + type FSharpParseFileResults with + member this.Fart(pos) = + let ranges = ResizeArray() + SyntaxTraversal.Traverse(pos, this.ParseTree, { new SyntaxVisitorBase<_>() with + member _.VisitExpr(_path, _traverseSynExpr, defaultTraverse, expr) = + match expr with + | SynExpr.New(_, SynType.LongIdent(identifier), _, _range) -> + ranges.Add(identifier.Range) + defaultTraverse expr + | _ -> defaultTraverse expr }) + |> ignore + ranges + +[)>] +type internal RedundantNewDiagnosticAnalyzer + [] + ( + checkerProvider: FSharpCheckerProvider, + projectInfoManager: FSharpProjectOptionsManager + ) = + + static let userOpName = "RedundantNewDiagnosticAnalyzer" + static let descriptorId = "FSIDE0001" + static let descriptor = + DiagnosticDescriptor( + descriptorId, + "This ain't necessary", + "This ain't necessary", + "Style", + DiagnosticSeverity.Info, + true, + null, + null, + FSharpDiagnosticCustomTags.Unnecessary) + + interface IFSharpDocumentDiagnosticAnalyzer with + + member this.AnalyzeSyntaxAsync(_document: Document, _cancellationToken: CancellationToken): Task> = + Task.FromResult(ImmutableArray.Empty) + + member this.AnalyzeSemanticsAsync(document: Document, cancellationToken: CancellationToken): Task> = + asyncMaybe { + match! projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken, userOpName) with + | (_parsingOptions, projectOptions) -> + let! sourceText = document.GetTextAsync() + let checker = checkerProvider.Checker + let! parseResults, _, checkResults = checker.ParseAndCheckDocument(document, projectOptions, sourceText = sourceText, userOpName = userOpName) + let symbolUses = checkResults.GetAllUsesOfAllSymbolsInFile(cancellationToken) + let ranges = parseResults.Fart(parseResults.ParseTree.Range.End) + let toot = + symbolUses + |> Seq.distinctBy (fun su -> su.Range) // Account for "hidden" uses, like a val in a member val definition. These aren't relevant + |> Seq.filter(fun su -> su.IsFromDefinition) + |> Seq.filter (fun su -> ranges.Contains(su.Range)) + |> Seq.filter (fun su -> match su.Symbol with :? FSharpEntity as entity -> not entity.IsDisposableType | _ -> false) + |> Seq.map (fun su -> su.Range) + |> Seq.map (fun m -> Diagnostic.Create(descriptor, RoslynHelpers.RangeToLocation(m, sourceText, document.FilePath))) + |> Seq.toImmutableArray + + return toot + } + |> Async.map (Option.defaultValue ImmutableArray.Empty) + |> RoslynHelpers.StartAsyncAsTask cancellationToken diff --git a/vsintegration/tests/GetTypesVS.UnitTests/GetTypesVS.UnitTests.fsproj b/vsintegration/tests/GetTypesVS.UnitTests/GetTypesVS.UnitTests.fsproj index 911e5e9a944..e083923ad29 100644 --- a/vsintegration/tests/GetTypesVS.UnitTests/GetTypesVS.UnitTests.fsproj +++ b/vsintegration/tests/GetTypesVS.UnitTests/GetTypesVS.UnitTests.fsproj @@ -6,7 +6,7 @@ net472 x86 Library - $(NoWarn);3005 + $(NoWarn);3005;1182 true true false diff --git a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj index 84b50e8a6a7..f3cdb6188be 100644 --- a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj +++ b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj @@ -6,6 +6,7 @@ net472 true $(OtherFlags) --nowarn:3390 --nowarn:3218 + --nowarn:3390 --nowarn:3218 --nowarn:1182 diff --git a/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj b/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj index d5161fa6687..f4367680ecc 100644 --- a/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj +++ b/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj @@ -5,6 +5,7 @@ Library $(NoWarn);44;45;47;52;58;75 + $(NoWarn);45;47;52;58;75;1182 true true $(SystemValueTupleVersion) diff --git a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj index d2161ed8a4b..1811294c04f 100644 --- a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj +++ b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj @@ -6,7 +6,7 @@ net472 x86 Library - $(NoWarn);44;58;75;3005 + $(NoWarn);44;58;75;3005;1182 true true $(SystemValueTupleVersion) From b7e0494cf83b66311ce37cded75fea26d2842dd1 Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 5 Jan 2021 13:00:28 -0800 Subject: [PATCH 02/14] more nowarning in tests --- .../FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj | 2 +- tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj | 2 +- tests/fsharp/FSharpSuite.Tests.fsproj | 3 +-- tests/service/data/TestTP/TestTP.fsproj | 1 + .../DummyProviderForLanguageServiceTesting.fsproj | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 0016c397d81..643c86038f6 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -9,7 +9,7 @@ true $(DefineConstants);ASSUME_PREVIEW_FSHARP_CORE xunit - $(NoWarn);3186;1104;1182 + $(NoWarn);3186;1104 diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj index b093c728e27..bdc33d5eaeb 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj +++ b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj @@ -6,7 +6,7 @@ net472;net5.0 net5.0 Library - 1182 + $(NoWarn);1182 FSharp.Core.UnitTests Microsoft.FSharp.Core.UnitTests diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index cd29f82c15d..3f152f21ccd 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -11,9 +11,8 @@ true false false - $(OtherFlags) --warnon:1182 nunit - 3186;1182 + $(NoWarn);3186 diff --git a/tests/service/data/TestTP/TestTP.fsproj b/tests/service/data/TestTP/TestTP.fsproj index 442fc909f7a..f4b69cf7154 100644 --- a/tests/service/data/TestTP/TestTP.fsproj +++ b/tests/service/data/TestTP/TestTP.fsproj @@ -6,6 +6,7 @@ true nunit $(OtherFlags) --nowarn:3390 --nowarn:3218 + $(NoWarn);3390;3218;1182 diff --git a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj index f3cdb6188be..9280b94230a 100644 --- a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj +++ b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj @@ -7,6 +7,7 @@ true $(OtherFlags) --nowarn:3390 --nowarn:3218 --nowarn:3390 --nowarn:3218 --nowarn:1182 + $(NoWarn);3390;3218;1182 From 15e5840b620ceeef0088170ca5d9207889d779b2 Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Tue, 16 Mar 2021 19:58:51 -0700 Subject: [PATCH 03/14] Delete RedundantNewDiagnosticAnalyzer.fs --- .../RedundantNewDiagnosticAnalyzer.fs | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100644 vsintegration/src/FSharp.Editor/Diagnostics/RedundantNewDiagnosticAnalyzer.fs diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/RedundantNewDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/RedundantNewDiagnosticAnalyzer.fs deleted file mode 100644 index 956669396ed..00000000000 --- a/vsintegration/src/FSharp.Editor/Diagnostics/RedundantNewDiagnosticAnalyzer.fs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -namespace Microsoft.VisualStudio.FSharp.Editor - -open System.Composition -open System.Collections.Immutable -open System.Threading -open System.Threading.Tasks - -open Microsoft.CodeAnalysis -open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics - -open FSharp.Compiler.CodeAnalysis -open FSharp.Compiler.Syntax -open FSharp.Compiler.Text -open FSharp.Compiler.Symbols - -[] -module Ass = - type FSharpParseFileResults with - member this.Fart(pos) = - let ranges = ResizeArray() - SyntaxTraversal.Traverse(pos, this.ParseTree, { new SyntaxVisitorBase<_>() with - member _.VisitExpr(_path, _traverseSynExpr, defaultTraverse, expr) = - match expr with - | SynExpr.New(_, SynType.LongIdent(identifier), _, _range) -> - ranges.Add(identifier.Range) - defaultTraverse expr - | _ -> defaultTraverse expr }) - |> ignore - ranges - -[)>] -type internal RedundantNewDiagnosticAnalyzer - [] - ( - checkerProvider: FSharpCheckerProvider, - projectInfoManager: FSharpProjectOptionsManager - ) = - - static let userOpName = "RedundantNewDiagnosticAnalyzer" - static let descriptorId = "FSIDE0001" - static let descriptor = - DiagnosticDescriptor( - descriptorId, - "This ain't necessary", - "This ain't necessary", - "Style", - DiagnosticSeverity.Info, - true, - null, - null, - FSharpDiagnosticCustomTags.Unnecessary) - - interface IFSharpDocumentDiagnosticAnalyzer with - - member this.AnalyzeSyntaxAsync(_document: Document, _cancellationToken: CancellationToken): Task> = - Task.FromResult(ImmutableArray.Empty) - - member this.AnalyzeSemanticsAsync(document: Document, cancellationToken: CancellationToken): Task> = - asyncMaybe { - match! projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken, userOpName) with - | (_parsingOptions, projectOptions) -> - let! sourceText = document.GetTextAsync() - let checker = checkerProvider.Checker - let! parseResults, _, checkResults = checker.ParseAndCheckDocument(document, projectOptions, sourceText = sourceText, userOpName = userOpName) - let symbolUses = checkResults.GetAllUsesOfAllSymbolsInFile(cancellationToken) - let ranges = parseResults.Fart(parseResults.ParseTree.Range.End) - let toot = - symbolUses - |> Seq.distinctBy (fun su -> su.Range) // Account for "hidden" uses, like a val in a member val definition. These aren't relevant - |> Seq.filter(fun su -> su.IsFromDefinition) - |> Seq.filter (fun su -> ranges.Contains(su.Range)) - |> Seq.filter (fun su -> match su.Symbol with :? FSharpEntity as entity -> not entity.IsDisposableType | _ -> false) - |> Seq.map (fun su -> su.Range) - |> Seq.map (fun m -> Diagnostic.Create(descriptor, RoslynHelpers.RangeToLocation(m, sourceText, document.FilePath))) - |> Seq.toImmutableArray - - return toot - } - |> Async.map (Option.defaultValue ImmutableArray.Empty) - |> RoslynHelpers.StartAsyncAsTask cancellationToken From 4ca343f4e44c4cbd4c31dbab23d3527bd741ffff Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 16 Mar 2021 20:35:56 -0700 Subject: [PATCH 04/14] update --- tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj b/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj index a3fa15b8a1e..fedc0818bc8 100644 --- a/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj +++ b/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj @@ -8,7 +8,7 @@ Library true nunit - 1182 + $(NOWARN);1182 From ddfe443a415e1855f32a1ce081a48ccc8ed49023 Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 16 Mar 2021 20:51:54 -0700 Subject: [PATCH 05/14] more updates --- tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj | 2 +- .../FSharp.Compiler.Private.Scripting.UnitTests.fsproj | 1 + .../FSharp.Compiler.Service.Tests.fsproj | 2 -- .../FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj b/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj index fedc0818bc8..69c05f34b17 100644 --- a/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj +++ b/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj @@ -8,7 +8,7 @@ Library true nunit - $(NOWARN);1182 + $(NoWarn);1182 diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj index d30dd32729c..b8b9c5df2b7 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj @@ -8,6 +8,7 @@ true xunit true + $(NoWarn);1182 diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 25e79535e7d..9f00d791fbc 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -3,8 +3,6 @@ Exe net472;net5.0 - $(NoWarn);44;75; - netcoreapp3.1 $(NoWarn);44;75;1182 true false diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 643c86038f6..0016c397d81 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -9,7 +9,7 @@ true $(DefineConstants);ASSUME_PREVIEW_FSHARP_CORE xunit - $(NoWarn);3186;1104 + $(NoWarn);3186;1104;1182 From 219921a22bd905a35b6ed2bcd8061a2bea64a9ce Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 16 Mar 2021 21:06:08 -0700 Subject: [PATCH 06/14] try this --- src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs b/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs index f0abd155b95..9c882f8b64e 100644 --- a/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs @@ -319,13 +319,13 @@ open Printf static let mutable swallowResourceText = false - static let GetStringFunc((messageID : string),(fmt : Printf.StringFormat<'T>)) : 'T = - if swallowResourceText then - sprintf fmt - else - let mutable messageString = GetString(messageID) - messageString <- postProcessString messageString - createMessageString messageString fmt + // static let GetStringFunc((messageID : string),(fmt : Printf.StringFormat<'T>)) : 'T = + // if swallowResourceText then + // sprintf fmt + // else + // let mutable messageString = GetString(messageID) + // messageString <- postProcessString messageString + // createMessageString messageString fmt /// If set to true, then all error messages will just return the filled 'holes' delimited by ',,,'s - this is for language-neutral testing (e.g. localization-invariant baselines). static member SwallowResourceText with get () = swallowResourceText From 82fa6584cd9b826e01e966092ee1da4ba8271ee2 Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 16 Mar 2021 21:07:31 -0700 Subject: [PATCH 07/14] more --- .../DummyProviderForLanguageServiceTesting.fsproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj index 9280b94230a..a53d2c628ec 100644 --- a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj +++ b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj @@ -5,8 +5,6 @@ net472 true - $(OtherFlags) --nowarn:3390 --nowarn:3218 - --nowarn:3390 --nowarn:3218 --nowarn:1182 $(NoWarn);3390;3218;1182 From 197b19a84d7f7ae9fb1c508fc7bab89dd95e9ccc Mon Sep 17 00:00:00 2001 From: cartermp Date: Tue, 16 Mar 2021 21:19:00 -0700 Subject: [PATCH 08/14] again --- src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs b/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs index 9c882f8b64e..f0abd155b95 100644 --- a/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs @@ -319,13 +319,13 @@ open Printf static let mutable swallowResourceText = false - // static let GetStringFunc((messageID : string),(fmt : Printf.StringFormat<'T>)) : 'T = - // if swallowResourceText then - // sprintf fmt - // else - // let mutable messageString = GetString(messageID) - // messageString <- postProcessString messageString - // createMessageString messageString fmt + static let GetStringFunc((messageID : string),(fmt : Printf.StringFormat<'T>)) : 'T = + if swallowResourceText then + sprintf fmt + else + let mutable messageString = GetString(messageID) + messageString <- postProcessString messageString + createMessageString messageString fmt /// If set to true, then all error messages will just return the filled 'holes' delimited by ',,,'s - this is for language-neutral testing (e.g. localization-invariant baselines). static member SwallowResourceText with get () = swallowResourceText From 11eeaa6b70180070c5187aa3814983be1e111109 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 4 Aug 2021 15:06:43 +0200 Subject: [PATCH 09/14] Remove 1182 from WarningsAsErrors, since we have it now enabled by default, and treat warnings as errors by default --- FSharpBuild.Directory.Build.props | 2 +- .../FSharp.Compiler.Benchmarks.fsproj | 1 + tests/benchmarks/MicroPerf/MicroPerf.fsproj | 2 ++ tests/benchmarks/TaskPerf/TaskPerf.fsproj | 3 +++ vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj | 2 +- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props index bcdbffa1c12..8f1f756c639 100644 --- a/FSharpBuild.Directory.Build.props +++ b/FSharpBuild.Directory.Build.props @@ -19,7 +19,7 @@ $(ArtifactsDir)\SymStore $(ArtifactsDir)\Bootstrap 4.4.0 - 1182;0025;$(WarningsAsErrors) + 0025;$(WarningsAsErrors) $(OtherFlags) --nowarn:3384 diff --git a/tests/benchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj b/tests/benchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj index 68b175fc21a..18f6ace7f7b 100644 --- a/tests/benchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj +++ b/tests/benchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj @@ -4,6 +4,7 @@ Exe net5.0 true + $(NoWarn);1182 diff --git a/tests/benchmarks/MicroPerf/MicroPerf.fsproj b/tests/benchmarks/MicroPerf/MicroPerf.fsproj index 6e9e411e438..7fa08e87e65 100644 --- a/tests/benchmarks/MicroPerf/MicroPerf.fsproj +++ b/tests/benchmarks/MicroPerf/MicroPerf.fsproj @@ -11,6 +11,8 @@ $(OtherFlags) --langversion:preview $(OtherFlags) --define:PREVIEW + $(NoWarn);1182 + diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs index 439b0bd7bdb..9800bb3512c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnsupportedAttributes.fs @@ -20,6 +20,7 @@ type C() = member _.G() = () """ |> FSharp + |> withOptions ["--nowarn:1182"] |> typecheck |> shouldFail |> withResults [ From ac05d5df4a073bfebfefe9b8fff77d7dab5fffba Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 5 Aug 2021 16:47:51 +0200 Subject: [PATCH 11/14] Added --nowarn:1182 to the service tests, fixed an unused value in the unit test. --- .../FSharpScriptTests.fs | 2 +- tests/service/Common.fs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs index 431ac983ec4..864ffbfee8d 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs @@ -418,7 +418,7 @@ let y = 2 foundInner <- foundInner || name = "inner") let code = @" let x = - let inner = 1 + let _inner = 1 () " script.Eval(code) |> ignoreValue diff --git a/tests/service/Common.fs b/tests/service/Common.fs index d0105acca52..eb13638a368 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -136,6 +136,7 @@ let mkProjectCommandLineArgsSilent (dllName, fileNames) = yield "--fullpaths" yield "--flaterrors" yield "--target:library" + yield "--nowarn:1182" for x in fileNames do yield x let references = mkStandardProjectReferences () From a1a306bb1e0bdd2c600759d00fba408b58a8f7a7 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 5 Aug 2021 18:24:22 +0200 Subject: [PATCH 12/14] Fix 1182 in F#QA tests, fix in service script tests --- tests/fsharp/Compiler/Language/ByrefTests.fs | 20 +- .../Language/StructActivePatternTests.fs | 34 +- .../NullableOptionalRegressionTests.fs | 2 +- .../Warnings/AssignmentWarningTests.fs | 6 +- .../RecordTypes/Overload_Equals.fs | 4 +- .../RecordTypes/Overload_GetHashCode.fs | 4 +- .../RecordTypes/Overload_ToString.fs | 4 +- .../UnionTypes/Overload_Equals.fs | 4 +- .../UnionTypes/Overload_GetHashCode.fs | 4 +- .../basic/InternalizedIFaces02.fs | 2 +- .../CustomAttributes/Basic/InExternDecl.fs | 2 +- ...WarningWhenDoingDispatchSlotInference01.fs | 6 +- .../Expressions/ConstantExpressions/bigint.fs | 2 +- .../ConstantExpressions/bigint02.fs | 2 +- .../QueryExpressions/UppercaseIdentifier04.fs | Bin 1066 -> 1098 bytes .../final_yield_dash_gt_01.fs | 2 +- .../TypeInference/AdHoc.fs | 3 + .../TypeInference/OneTypeVariable03.fs | 3 + .../TypeInference/OneTypeVariable03rec.fs | 3 + .../TypeInference/RegressionTest01.fs | 3 + .../TypeInference/RegressionTest02.fs | 3 + .../TwoDifferentTypeVariables01.fs | 3 + .../TwoDifferentTypeVariables01rec.fs | 3 + .../TwoDifferentTypeVariablesGen00.fs | 3 + .../TwoDifferentTypeVariablesGen00rec.fs | 3 + .../TypeInference/TwoEqualTypeVariables02.fs | 3 + .../TwoEqualTypeVariables02rec.fs | 3 + .../Directives/multiple_nowarn01.fs | 2 +- .../Directives/multiple_nowarn01.fsx | 2 +- .../Directives/multiple_nowarn02.fsx | 2 +- .../Directives/multiple_nowarn_many.fs | 2 + .../MemberDeclarations/CtorAndCCtor01.fs | 2 + .../MemberDeclarations/CtorAndCCtor02.fs | 2 + .../TypeInferenceVariable01.fsx | 2 +- .../StructTypes/Overload_ToString.fs | 4 +- .../TypeChecker/Generalization01.fs | 2 +- .../General/W_NoValueHasBeenCopiedWarning.fs | 2 +- tests/service/Common.fs | 1 + .../DocumentDiagnosticAnalyzerTests.fs | 18 +- .../Tests.LanguageService.ErrorList.fs | 8 +- .../Tests.LanguageService.Script.fs | 762 +++++++++--------- 41 files changed, 491 insertions(+), 451 deletions(-) diff --git a/tests/fsharp/Compiler/Language/ByrefTests.fs b/tests/fsharp/Compiler/Language/ByrefTests.fs index 2bb9709a86f..14ddbd9b6dc 100644 --- a/tests/fsharp/Compiler/Language/ByrefTests.fs +++ b/tests/fsharp/Compiler/Language/ByrefTests.fs @@ -248,7 +248,7 @@ type MyClass() = let test () = let mutable x = 1 - let y = &&x + let _y = &&x () """ @@ -280,12 +280,12 @@ type C() = let verifyProperty = """.property instance int32& modreq([runtime]System.Runtime.InteropServices.InAttribute) X() { - .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 ) .get instance int32& modreq([runtime]System.Runtime.InteropServices.InAttribute) Test/C::get_X() }""" - let verifyMethod = """.method public hidebysig specialname - instance int32& modreq([runtime]System.Runtime.InteropServices.InAttribute) + let verifyMethod = """.method public hidebysig specialname + instance int32& modreq([runtime]System.Runtime.InteropServices.InAttribute) get_X() cil managed { .param [0] @@ -307,7 +307,7 @@ type C<'T>() = member _.X<'U>(): inref<'T> = &x """ - let verifyMethod = """.method public hidebysig instance !T& modreq([runtime]System.Runtime.InteropServices.InAttribute) + let verifyMethod = """.method public hidebysig instance !T& modreq([runtime]System.Runtime.InteropServices.InAttribute) X() cil managed { .param [0] @@ -329,8 +329,8 @@ type C<'T>() = abstract X<'U> : unit -> inref<'U> """ - let verifyMethod = """.method public hidebysig abstract virtual - instance !!U& modreq([runtime]System.Runtime.InteropServices.InAttribute) + let verifyMethod = """.method public hidebysig abstract virtual + instance !!U& modreq([runtime]System.Runtime.InteropServices.InAttribute) X() cil managed { .param [0] @@ -348,18 +348,18 @@ type C<'T>() = module Test type C = - abstract X: inref + abstract X: inref """ let verifyProperty = """.property instance int32& modreq([runtime]System.Runtime.InteropServices.InAttribute) X() { - .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 ) .get instance int32& modreq([runtime]System.Runtime.InteropServices.InAttribute) Test/C::get_X() }""" let verifyMethod = """.method public hidebysig specialname abstract virtual - instance int32& modreq([runtime]System.Runtime.InteropServices.InAttribute) + instance int32& modreq([runtime]System.Runtime.InteropServices.InAttribute) get_X() cil managed { .param [0] diff --git a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs index 6107d368ef9..bfff68e5b4e 100644 --- a/tests/fsharp/Compiler/Language/StructActivePatternTests.fs +++ b/tests/fsharp/Compiler/Language/StructActivePatternTests.fs @@ -19,18 +19,18 @@ let fail msg = [] let ``Partial active pattern returns Option`1`` () = - pass "let (|Foo|_|) x = None" + pass "let (|Foo|_|) _x = None" [] let ``Partial struct active pattern returns ValueOption`1`` () = - pass "[] let (|P1|_|) x = ValueNone" + pass "[] let (|P1|_|) _x = ValueNone" [] let ``StructAttribute can be placed at the active pattern return type annotation`` () = pass """ -let (|P1|_|) x: [] _ = ValueNone -let (|P2|_|) x: [] _ = ValueNone +let (|P1|_|) _x: [] _ = ValueNone +let (|P2|_|) _x: [] _ = ValueNone """ [] @@ -38,7 +38,7 @@ let (|P2|_|) x: [] _ = ValueNone run """ [] type T1 = { v1: int } -and T2 = +and T2 = | T2C1 of int * string | T2C2 of T1 * T2 and [] T3 = { v3: T2 } @@ -46,25 +46,25 @@ and T4() = let mutable _v4 = { v3 = T2C2({v1=0}, T2C1(1, "hey")) } member __.v4 with get() = _v4 and set (x) = _v4 <- x -[] +[] let (|P1|_|) = function | 0 -> ValueNone | _ -> ValueSome() -[] +[] let (|P2|_|) = function | "foo" -> ValueNone | _ -> ValueSome "bar" -[] +[] let (|P3|_|) (x: T2) = match x with | T2C1(a, b) -> ValueSome(a, b) | _ -> ValueNone -[] +[] let (|P4|_|) (x: T4) = match x.v4 with | { v3 = T2C2 ({v1=a}, P3(b, c)) } -> ValueSome (a, b, c) @@ -87,7 +87,7 @@ match t4 with """ [] - let ``[] attribute is rotated to the return value``() = + let ``[] attribute is rotated to the return value``() = run """ open System @@ -96,7 +96,7 @@ open System type MyAttribute() = inherit Attribute() -let extract xs = +let extract xs = xs |> Seq.map (fun x -> x.GetType().Name) |> List.ofSeq @@ -121,7 +121,7 @@ match ret_attrs, binding_attrs with | _ -> fail $"ret_attrs = {ret_attrs}, binding_attrs = {binding_attrs} method = {method}" """ [] - let ``Implicitly-targeted attribute on let binding do not target return``() = + let ``Implicitly-targeted attribute on let binding do not target return``() = run """ open System @@ -130,7 +130,7 @@ open System type MyAttribute() = inherit Attribute() -let extract xs = +let extract xs = xs |> Seq.map (fun x -> x.GetType().Name) |> List.ofSeq @@ -170,7 +170,7 @@ let (|Foo|_|) x = ValueNone [] let ``StructAttribute must explicitly target active pattern return value`` () = - fail + fail """ [] let (|Foo|_|) x = ValueNone @@ -179,15 +179,15 @@ let (|Foo|_|) x = ValueNone "This attribute is not valid for use on this language element"); (FSharpDiagnosticSeverity.Error, 1, (2, 1, 3, 16), "This expression was expected to have type - ''a option' + ''a option' but here has type ''b voption' ")|] [] let ``StructAttribute not allowed on other bindings than partial active pattern definitions`` () = - fail + fail """ -[] +[] let x = 1 [] diff --git a/tests/fsharp/Compiler/Regressions/NullableOptionalRegressionTests.fs b/tests/fsharp/Compiler/Regressions/NullableOptionalRegressionTests.fs index c4009ee5233..8e8b96db39e 100644 --- a/tests/fsharp/Compiler/Regressions/NullableOptionalRegressionTests.fs +++ b/tests/fsharp/Compiler/Regressions/NullableOptionalRegressionTests.fs @@ -26,7 +26,7 @@ type Node (child:Node)= let test () = let parent = Node() let b1 = OverloadMeths.Map(parent.child, fun x -> x.child) - let c1 = OverloadMeths.Map(b1, fun x -> x.child) + let _c1 = OverloadMeths.Map(b1, fun x -> x.child) () """ |> withLangVersion50 diff --git a/tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs b/tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs index d6ef26bcdf1..68354fae739 100644 --- a/tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs +++ b/tests/fsharp/Compiler/Warnings/AssignmentWarningTests.fs @@ -66,7 +66,7 @@ let changeProperty() = type MyClass(property1 : int) = member val Property1 = property1 member val Property2 = "" with get, set - + let x = MyClass(1) let y = "hello" @@ -83,9 +83,9 @@ let changeProperty() = let ``Don't warn if assignment to property without setter ``() = CompilerAssert.TypeCheckSingleError """ -type MyClass(property1 : int) = +type MyClass(_property1 : int) = member val Property2 = "" with get - + let x = MyClass(1) let y = "hello" diff --git a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_Equals.fs b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_Equals.fs index 5749edc7ef8..6b8188e7cf0 100644 --- a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_Equals.fs +++ b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_Equals.fs @@ -4,9 +4,9 @@ type R = { x: int } - member this.Equals(s:char) = true + member this.Equals(_s:char) = true // member this.Equals(s:R) = 1. - member this.Equals(?s:char) = true + member this.Equals(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_GetHashCode.fs b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_GetHashCode.fs index 25aa07cd456..dddc506aa4f 100644 --- a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_GetHashCode.fs +++ b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_GetHashCode.fs @@ -3,9 +3,9 @@ // Overloading of GetHashCode() type R = { x: int } - member this.GetHashCode(s:char) = 1 + member this.GetHashCode(_s:char) = 1 //member this.GetHashCode() = 1. - member this.GetHashCode(?s:char) = 1 + member this.GetHashCode(?_s:char) = 1 #if INTERACTIVE exit 0;; diff --git a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_ToString.fs b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_ToString.fs index 2e651f776dd..cb3c47a39ac 100644 --- a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_ToString.fs +++ b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/RecordTypes/Overload_ToString.fs @@ -4,9 +4,9 @@ type R = { x: int } - member this.ToString(s:char) = true + member this.ToString(_s:char) = true member this.ToString() = true - member this.ToString(?s:char) = true + member this.ToString(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_Equals.fs b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_Equals.fs index 0e289605e5a..7eab984dc44 100644 --- a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_Equals.fs +++ b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_Equals.fs @@ -3,9 +3,9 @@ // Overloading of Equals() type DU = | A - member this.Equals(s:char) = true + member this.Equals(_s:char) = true //member this.Equals(s:DU) = 1. - member this.Equals(?s:char) = true + member this.Equals(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_GetHashCode.fs b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_GetHashCode.fs index f85e1c1dbd1..8e4d6dba20a 100644 --- a/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_GetHashCode.fs +++ b/tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/UnionTypes/Overload_GetHashCode.fs @@ -3,9 +3,9 @@ // Overloading of GetHashCode() type DU = | A - member this.GetHashCode(s:char) = 1 + member this.GetHashCode(_s:char) = 1 //member this.GetHashCode() = 1. - member this.GetHashCode(?s:char) = 1 + member this.GetHashCode(?_s:char) = 1 #if INTERACTIVE exit 0;; diff --git a/tests/fsharpqa/Source/Conformance/DeclarationElements/AccessibilityAnnotations/basic/InternalizedIFaces02.fs b/tests/fsharpqa/Source/Conformance/DeclarationElements/AccessibilityAnnotations/basic/InternalizedIFaces02.fs index c3959b59f7c..ea85e8eb5fc 100644 --- a/tests/fsharpqa/Source/Conformance/DeclarationElements/AccessibilityAnnotations/basic/InternalizedIFaces02.fs +++ b/tests/fsharpqa/Source/Conformance/DeclarationElements/AccessibilityAnnotations/basic/InternalizedIFaces02.fs @@ -12,6 +12,6 @@ module N.M and Gen<'a> = | Gen of (int -> StdGen -> 'a) - member x.Map f = failwith "" + member x.Map _f = failwith "" interface IGen with member x.AsGenObject = x.Map box diff --git a/tests/fsharpqa/Source/Conformance/DeclarationElements/CustomAttributes/Basic/InExternDecl.fs b/tests/fsharpqa/Source/Conformance/DeclarationElements/CustomAttributes/Basic/InExternDecl.fs index 10bc1a73ad1..f2ed3e4a277 100644 --- a/tests/fsharpqa/Source/Conformance/DeclarationElements/CustomAttributes/Basic/InExternDecl.fs +++ b/tests/fsharpqa/Source/Conformance/DeclarationElements/CustomAttributes/Basic/InExternDecl.fs @@ -5,4 +5,4 @@ module M type myAttrib() = inherit System.Attribute() -extern int A([] int a) +extern int A([] int _a) diff --git a/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/OverloadingMembers/NoWarningWhenDoingDispatchSlotInference01.fs b/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/OverloadingMembers/NoWarningWhenDoingDispatchSlotInference01.fs index 5dbadd0b1c5..f09fdd3bad3 100644 --- a/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/OverloadingMembers/NoWarningWhenDoingDispatchSlotInference01.fs +++ b/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/OverloadingMembers/NoWarningWhenDoingDispatchSlotInference01.fs @@ -5,9 +5,9 @@ type MyTraceListener = class inherit System.Diagnostics.TraceListener - override x.Write (message:string) = () - override x.WriteLine (message:string) = () - override x.Fail (message:string) = exit 0 + override x.Write (_message:string) = () + override x.WriteLine (_message:string) = () + override x.Fail (_message:string) = exit 0 end exit 0 diff --git a/tests/fsharpqa/Source/Conformance/Expressions/ConstantExpressions/bigint.fs b/tests/fsharpqa/Source/Conformance/Expressions/ConstantExpressions/bigint.fs index f66aeb7c56e..00f08806dda 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/ConstantExpressions/bigint.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/ConstantExpressions/bigint.fs @@ -10,6 +10,6 @@ open System.Numerics // <- we need this since the deprecated let v1 = 99999999I // bigint (System.Numerics.BigInteger) -let check(x:BigInteger) = true +let check(_x:BigInteger) = true exit (if check(v1) then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/Expressions/ConstantExpressions/bigint02.fs b/tests/fsharpqa/Source/Conformance/Expressions/ConstantExpressions/bigint02.fs index 1b2b4df8dea..3ffb3420bd2 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/ConstantExpressions/bigint02.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/ConstantExpressions/bigint02.fs @@ -9,7 +9,7 @@ let v1 = 99999999I // bigint (Microsoft.FSharp.Core.bigint) -let check(x:bigint) = true +let check(_x:bigint) = true if check(v1) = false then exit 1 diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/UppercaseIdentifier04.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/QueryExpressions/UppercaseIdentifier04.fs index de1f4a7ecdce806a86a29b19a0755f8e805aeb06..e2451f56d7754f760d854c368ee08b9666374aca 100644 GIT binary patch delta 40 tcmZ3*af)NZF-B=+hCGIRhH{2Ph9V$KfkBDE5C|<8j2M(QA7spA0szdt2;Tqz delta 12 TcmX@bv5I5EF~-f$7*m)4Bb)^M diff --git a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/SequenceExpressions/final_yield_dash_gt_01.fs b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/SequenceExpressions/final_yield_dash_gt_01.fs index 537141f6eae..41162b52161 100644 --- a/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/SequenceExpressions/final_yield_dash_gt_01.fs +++ b/tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/SequenceExpressions/final_yield_dash_gt_01.fs @@ -6,5 +6,5 @@ // #light -let s1 = seq { for i in [ 1 .. 2 ] -> 10 } +let s1 = seq { for _i in [ 1 .. 2 ] -> 10 } (if (Seq.head s1) = 10 then 0 else 1) |> exit diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/AdHoc.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/AdHoc.fs index 19d6d8d2a2d..21744ae6bde 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/AdHoc.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/AdHoc.fs @@ -5,6 +5,9 @@ // Notice that the [] attribute is no longer needed // These different return types are used to determine which overload got chosen namespace N + +#nowarn "1182" + type One = | One type Two = | Two type Three = | Three diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/OneTypeVariable03.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/OneTypeVariable03.fs index 983a5d0eab1..19f3303b338 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/OneTypeVariable03.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/OneTypeVariable03.fs @@ -3,6 +3,9 @@ // Type Inference // Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution namespace N + +#nowarn "1182" + // These different return types are used to determine which overload got chosen type One = | One type Two = | Two diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/OneTypeVariable03rec.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/OneTypeVariable03rec.fs index 8e531e6e9d4..1607e683cef 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/OneTypeVariable03rec.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/OneTypeVariable03rec.fs @@ -3,6 +3,9 @@ // Type Inference // Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution namespace N + +#nowarn "1182" + // These different return types are used to determine which overload got chosen type One = | One type Two = | Two diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/RegressionTest01.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/RegressionTest01.fs index 932582bb26c..cbc44aa259a 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/RegressionTest01.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/RegressionTest01.fs @@ -2,6 +2,9 @@ // Regression test for FSHARP1.0:4758 // Type Inference namespace N + +#nowarn "1182" + module ActualTests1 = type Var<'a> = static member Foo(x:Var<'a>,y:'a) = failwith "" : Var diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/RegressionTest02.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/RegressionTest02.fs index ccb5255099a..75adafdb0d4 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/RegressionTest02.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/RegressionTest02.fs @@ -2,6 +2,9 @@ // Regression test for FSHARP1.0:4758 // Type Inference namespace N + +#nowarn "1182" + module ActualTests2 = type Var<'a> = diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariables01.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariables01.fs index 401f439a41d..4f8153b6e1b 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariables01.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariables01.fs @@ -3,6 +3,9 @@ // Type Inference // Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution namespace N + +#nowarn "1182" + // These different return types are used to determine which overload got chosen type One = | One type Two = | Two diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariables01rec.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariables01rec.fs index 2b2193b09bc..bab9ab53972 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariables01rec.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariables01rec.fs @@ -3,6 +3,9 @@ // Type Inference // Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution namespace N + +#nowarn "1182" + // These different return types are used to determine which overload got chosen type One = | One type Two = | Two diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariablesGen00.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariablesGen00.fs index 790b885d766..22676ea0c83 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariablesGen00.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariablesGen00.fs @@ -3,6 +3,9 @@ // Type Inference // Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution namespace N + +#nowarn "1182" + // These different return types are used to determine which overload got chosen type One = | One type Two = | Two diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariablesGen00rec.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariablesGen00rec.fs index 157074da583..d89157fcbf2 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariablesGen00rec.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoDifferentTypeVariablesGen00rec.fs @@ -3,6 +3,9 @@ // Type Inference // Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution namespace N + +#nowarn "1182" + // These different return types are used to determine which overload got chosen type One = | One type Two = | Two diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoEqualTypeVariables02.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoEqualTypeVariables02.fs index 7cd8d6398e5..34861de16a0 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoEqualTypeVariables02.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoEqualTypeVariables02.fs @@ -3,6 +3,9 @@ // Type Inference // Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution namespace N + +#nowarn "1182" + // These different return types are used to determine which overload got chosen type One = | One type Two = | Two diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoEqualTypeVariables02rec.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoEqualTypeVariables02rec.fs index b7bf6a248ee..867e5322f10 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoEqualTypeVariables02rec.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/TwoEqualTypeVariables02rec.fs @@ -3,6 +3,9 @@ // Type Inference // Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution namespace N + +#nowarn "1182" + // These different return types are used to determine which overload got chosen type One = | One type Two = | Two diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs index 726f2b8658b..3f0f235d45f 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fs @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "49" +#nowarn "44" "49" "1182" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx index 726f2b8658b..3f0f235d45f 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn01.fsx @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "49" +#nowarn "44" "49" "1182" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx index 02a97bb444e..234344feb5e 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn02.fsx @@ -1,7 +1,7 @@ // #Regression #Conformance #LexicalAnalysis #ReqNOMT // Regression test for FSHARP1.0:6044 -#nowarn "44" "49" +#nowarn "44" "49" "1182" [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs index c4c1f6278c7..0a3c54009ba 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/Directives/multiple_nowarn_many.fs @@ -3,6 +3,8 @@ // 100 nowarns... #nowarn "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83" "84" "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95" "96" "97" "98" "99" +#nowarn "1182" + [] let obsoleteIdentifier = 12 diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/CtorAndCCtor01.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/CtorAndCCtor01.fs index 133525b0b00..0708a191955 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/CtorAndCCtor01.fs +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/CtorAndCCtor01.fs @@ -5,6 +5,8 @@ namespace N +#nowarn "1182" + type T1(``.ctor`` : char) = let ``.ctor`` = 10 static member ``.ctor ``(``.ctor`` : int) = ``.ctor`` + 1 diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/CtorAndCCtor02.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/CtorAndCCtor02.fs index 92f2123ed62..60f94fbc444 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/CtorAndCCtor02.fs +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/CtorAndCCtor02.fs @@ -5,6 +5,8 @@ namespace N +#nowarn "1182" + type T2(``.cctor`` : char) = let ``.cctor`` = 10 static member ``.cctor ``(``.cctor`` : int) = ``.cctor`` + 1 diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/ValueRestriction/TypeInferenceVariable01.fsx b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/ValueRestriction/TypeInferenceVariable01.fsx index baceab8e5db..a629d4562ad 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/ValueRestriction/TypeInferenceVariable01.fsx +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/ValueRestriction/TypeInferenceVariable01.fsx @@ -5,5 +5,5 @@ // We expect no value restriction here. The inferred signature is: // val x0 : ('T -> unit) // Here the type inference variable is generalized at 'x0'. -let f0 (x:obj) = () +let f0 (_x:obj) = () let x0 = f0 diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_ToString.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_ToString.fs index 8a5ad46511f..af2c64e3c6c 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_ToString.fs +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/StructTypes/Overload_ToString.fs @@ -4,9 +4,9 @@ [] type S1 = - member this.ToString(s:char) = true + member this.ToString(_s:char) = true member this.ToString() = true - member this.ToString(?s:char) = true + member this.ToString(?_s:char) = true #if INTERACTIVE exit 0;; diff --git a/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/TypeChecker/Generalization01.fs b/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/TypeChecker/Generalization01.fs index c46cefad1f4..ea27b64fc69 100644 --- a/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/TypeChecker/Generalization01.fs +++ b/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/TypeChecker/Generalization01.fs @@ -9,7 +9,7 @@ type Kg type M<[] 'a> = class end -type T = static member star ( y:'b when 'b :> M<'a>) = 0 +type T = static member star ( _y:'b when 'b :> M<'a>) = 0 let p = 1 let m = Unchecked.defaultof> diff --git a/tests/fsharpqa/Source/Diagnostics/General/W_NoValueHasBeenCopiedWarning.fs b/tests/fsharpqa/Source/Diagnostics/General/W_NoValueHasBeenCopiedWarning.fs index 61315afcef0..7fa76132ea2 100644 --- a/tests/fsharpqa/Source/Diagnostics/General/W_NoValueHasBeenCopiedWarning.fs +++ b/tests/fsharpqa/Source/Diagnostics/General/W_NoValueHasBeenCopiedWarning.fs @@ -12,6 +12,6 @@ let main(_) = () with | :? 'TException as e -> - let msg = e.ToString() + let _msg = e.ToString() () 0 diff --git a/tests/service/Common.fs b/tests/service/Common.fs index eb13638a368..4f6f677e2c5 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -164,6 +164,7 @@ let mkProjectCommandLineArgsForScript (dllName, fileNames) = yield "--fullpaths" yield "--flaterrors" yield "--target:library" + yield "--nowarn:1182" for x in fileNames do yield x let references = mkStandardProjectReferences () diff --git a/vsintegration/tests/UnitTests/DocumentDiagnosticAnalyzerTests.fs b/vsintegration/tests/UnitTests/DocumentDiagnosticAnalyzerTests.fs index 2f3b76b2965..f1107464f99 100644 --- a/vsintegration/tests/UnitTests/DocumentDiagnosticAnalyzerTests.fs +++ b/vsintegration/tests/UnitTests/DocumentDiagnosticAnalyzerTests.fs @@ -124,7 +124,7 @@ type (*start*)=(*end*) member public this.AbstractClasses_Constructors_PositiveTests_1() = this.VerifyNoErrors(""" [] -type C(a : int) = +type C(_a : int) = new(a : string) = C(int a) new(b) = match b with Some _ -> C(1) | _ -> C("") """) @@ -133,7 +133,7 @@ type C(a : int) = member public this.AbstractClasses_Constructors_PositiveTests_2() = this.VerifyNoErrors(""" [] -type C(a : int) = +type C(_a : int) = new(a : string) = new C(int a) new(b) = match b with Some _ -> new C(1) | _ -> new C("") """) @@ -142,7 +142,7 @@ type C(a : int) = member public this.AbstractClasses_Constructors_PositiveTests_3() = this.VerifyNoErrors(""" [] -type O(o : int) = +type O(_o : int) = new() = O(1) """) @@ -150,7 +150,7 @@ type O(o : int) = member public this.AbstractClasses_Constructors_PositiveTests_4() = this.VerifyNoErrors(""" [] -type O(o : int) = +type O(_o : int) = new() = O() then printfn "A" """) @@ -158,7 +158,7 @@ type O(o : int) = member public this.AbstractClasses_Constructors_PositiveTests_5() = this.VerifyNoErrors(""" [] -type O(o : int) = +type O(_o : int) = new() = new O(1) then printfn "A" """) @@ -253,7 +253,7 @@ type (*start*)A(*end*) = int * A this.VerifyWarningBetweenMarkers( fileContents = """ [] -let fn x = 0 +let fn _x = 0 let y = (*start*)fn(*end*) 1 """, expectedMessage = "This construct is deprecated. x") @@ -282,7 +282,7 @@ let r = (*start*)f 3(*end*) 4 this.VerifyWarningBetweenMarkers( fileContents = """ let a = async { - let! (*start*)[| r1; r2 |](*end*) = Async.Parallel [| async.Return(1); async.Return(2) |] + let! (*start*)[| _r1; _r2 |](*end*) = Async.Parallel [| async.Return(1); async.Return(2) |] let yyyy = 4 return r1,r2 } @@ -293,7 +293,7 @@ let a = async { member public this.InComputationExpression_Bug6095_B() = this.VerifyWarningBetweenMarkers( fileContents = """ -let f = (*start*)function(*end*) | [| a;b |] -> () +let f = (*start*)function(*end*) | [| _a;_b |] -> () """, expectedMessage = "Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).") @@ -301,7 +301,7 @@ let f = (*start*)function(*end*) | [| a;b |] -> () member public this.InComputationExpression_Bug6095_C() = this.VerifyWarningBetweenMarkers( fileContents = """ -for (*start*)[|a;b|](*end*) in [| [|42|] |] do () +for (*start*)[|_a;_b|](*end*) in [| [|42|] |] do () """, expectedMessage = "Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s). Unmatched elements will be ignored.") diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs index aff227acd96..608fcc2710b 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs @@ -561,7 +561,7 @@ but here has type member public this.``NoError.FlagsAndSettings.TargetOptionsRespected``() = let fileContent = """ [] - let fn x = 0 + let fn _x = 0 let y = fn 1""" // Turn off the "Obsolete" warning. let (solution, project, file) = this.CreateSingleFileProject(fileContent, disabledWarnings = ["44"]) @@ -654,15 +654,15 @@ but here has type fileContents = """ #nowarn "47" - type Fruit (shelfLife : int) as x = + type Fruit (_shelfLife : int) as x = - let mutable m_age = (fun () -> x) + let mutable _m_age = (fun () -> x) #nowarn "25" // FS0025: Incomplete pattern matches on this expression. For example, the value 'C' type DU = A | B | C - let f x = function A -> true | B -> false + let f _x = function A -> true | B -> false #nowarn "58" // FS0058: possible incorrect indentation: this token is offside of context started at diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Script.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Script.fs index ea2d28ad606..e8e4c25e72b 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Script.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Script.fs @@ -15,31 +15,31 @@ open UnitTests.TestLib.ProjectSystem [] [] -type UsingMSBuild() as this = - inherit LanguageServiceBaseTests() +type UsingMSBuild() as this = + inherit LanguageServiceBaseTests() let notAA l = None,l - let createSingleFileFsx (code : string) = + let createSingleFileFsx (code : string) = let (_, p, f) = this.CreateSingleFileProject(code, fileKind = SourceFileKind.FSX) (p, f) - let createSingleFileFsxFromLines (code : list) = + let createSingleFileFsxFromLines (code : list) = let (_, p, f) = this.CreateSingleFileProject(code, fileKind = SourceFileKind.FSX) (p, f) (* Timings ----------------------------------------------------------------------------- *) let stopWatch = new System.Diagnostics.Stopwatch() let ResetStopWatch() = stopWatch.Reset(); stopWatch.Start() - let time1 op a message = + let time1 op a message = ResetStopWatch() let result = op a printf "%s %d ms\n" message stopWatch.ElapsedMilliseconds result - let ShowErrors(project:OpenProject) = + let ShowErrors(project:OpenProject) = for error in (GetErrors(project)) do - printf "%s\n" (error.ToString()) + printf "%s\n" (error.ToString()) let AssertListContainsInOrder(s:string list,cs:string list) = let s : string array = Array.ofList s @@ -47,68 +47,68 @@ type UsingMSBuild() as this = AssertContainsInOrder(s,cs) /// Assert that there is no squiggle. - let AssertNoSquiggle(squiggleOption) = - match squiggleOption with + let AssertNoSquiggle(squiggleOption) = + match squiggleOption with | None -> () | Some(severity,message) -> Assert.Fail(sprintf "Expected no squiggle but got '%A' with message: %s" severity message) - let VerifyErrorListContainedExpetedStr(expectedStr:string,project : OpenProject) = + let VerifyErrorListContainedExpetedStr(expectedStr:string,project : OpenProject) = let errorList = GetErrors(project) let GetErrorMessages(errorList : Error list) = [ for i = 0 to errorList.Length - 1 do yield errorList.[i].Message] - + Assert.IsTrue(errorList |> GetErrorMessages |> Seq.exists (fun errorMessage -> errorMessage.Contains(expectedStr))) - let AssertNoErrorsOrWarnings(project:OpenProject) = + let AssertNoErrorsOrWarnings(project:OpenProject) = let count = List.length (GetErrors(project)) if count<>0 then printf "Saw %d errors and expected none.\n" count - printf "Errors are: \n" - for e in GetErrors project do + printf "Errors are: \n" + for e in GetErrors project do printf " path = <<<%s>>>\n" e.Path - printf " message = <<<%s> \n" e.Message + printf " message = <<<%s> \n" e.Message AssertEqual(0,count) let AssertExactlyCountErrorSeenContaining(project:OpenProject,text,expectedCount) = let nMatching = (GetErrors(project)) |> List.filter (fun e ->e.ToString().Contains(text)) |> List.length match nMatching with - | 0 -> + | 0 -> failwith (sprintf "No errors containing \"%s\"" text) | x when x = expectedCount -> () - | _ -> + | _ -> failwith (sprintf "Multiple errors containing \"%s\"" text) let AssertExactlyOneErrorSeenContaining(project:OpenProject,text) = AssertExactlyCountErrorSeenContaining(project,text,1) - /// Assert that a given squiggle is an Error (or warning) containing the given text - let AssertSquiggleIsErrorContaining,AssertSquiggleIsWarningContaining, AssertSquiggleIsErrorNotContaining,AssertSquiggleIsWarningNotContaining = - let AssertSquiggle expectedSeverity nameOfExpected nameOfNotExpected assertf (squiggleOption,containing) = + /// Assert that a given squiggle is an Error (or warning) containing the given text + let AssertSquiggleIsErrorContaining,AssertSquiggleIsWarningContaining, AssertSquiggleIsErrorNotContaining,AssertSquiggleIsWarningNotContaining = + let AssertSquiggle expectedSeverity nameOfExpected nameOfNotExpected assertf (squiggleOption,containing) = match squiggleOption with | None -> Assert.Fail("Expected a squiggle but none was seen.") | Some(severity,message) -> Assert.IsTrue((severity=expectedSeverity), sprintf "Expected %s but saw %s: %s" nameOfExpected nameOfNotExpected message) - assertf(message,containing) + assertf(message,containing) AssertSquiggle Microsoft.VisualStudio.FSharp.LanguageService.Severity.Error "Error" "Warning" AssertContains, AssertSquiggle Microsoft.VisualStudio.FSharp.LanguageService.Severity.Warning "Warning" "Error" AssertContains, AssertSquiggle Microsoft.VisualStudio.FSharp.LanguageService.Severity.Error "Error" "Warning" AssertNotContains, - AssertSquiggle Microsoft.VisualStudio.FSharp.LanguageService.Severity.Warning "Warning" "Error" AssertNotContains + AssertSquiggle Microsoft.VisualStudio.FSharp.LanguageService.Severity.Warning "Warning" "Error" AssertNotContains //Verify the error list in fsx file containd the expected string member private this.VerifyFSXErrorListContainedExpectedString(fileContents : string, expectedStr : string) = let (_, project, file) = this.CreateSingleFileProject(fileContents, fileKind = SourceFileKind.FSX) - VerifyErrorListContainedExpetedStr(expectedStr,project) + VerifyErrorListContainedExpetedStr(expectedStr,project) - //Verify no error list in fsx file + //Verify no error list in fsx file member private this.VerifyFSXNoErrorList(fileContents : string) = let (_, project, file) = this.CreateSingleFileProject(fileContents, fileKind = SourceFileKind.FSX) - AssertNoErrorsOrWarnings(project) + AssertNoErrorsOrWarnings(project) //Verify QuickInfo Containd In Fsx file member public this.AssertQuickInfoContainsAtEndOfMarkerInFsxFile (code : string) marker expected = @@ -124,7 +124,7 @@ type UsingMSBuild() as this = MoveCursorToStartOfMarker(file, marker) let tooltip = GetQuickInfoAtCursor file AssertContains(tooltip, expected) - //Verify QuickInfo Not Containd In Fsx file + //Verify QuickInfo Not Containd In Fsx file member public this.AssertQuickInfoNotContainsAtEndOfMarkerInFsxFile code marker notexpected = let (_, _, file) = this.CreateSingleFileProject((code : string), fileKind = SourceFileKind.FSX) @@ -134,94 +134,94 @@ type UsingMSBuild() as this = /// There was a problem with Salsa that caused squiggles not to be shown for .fsx files. [] - member public this.``Fsx.Squiggles.ShowInFsxFiles``() = + member public this.``Fsx.Squiggles.ShowInFsxFiles``() = let fileContent = """open Thing1.Thing2""" this.VerifyFSXErrorListContainedExpectedString(fileContent,"Thing1") - + /// Regression test for FSharp1.0:4861 - #r to non-existent file causes the first line to be squiggled /// There was a problem with Salsa that caused squiggles not to be shown for .fsx files. [] - member public this.``Fsx.Hash.RProperSquiggleForNonExistentFile``() = + member public this.``Fsx.Hash.RProperSquiggleForNonExistentFile``() = let fileContent = """#r "NonExistent" """ - this.VerifyFSXErrorListContainedExpectedString(fileContent,"was not found or is invalid") + this.VerifyFSXErrorListContainedExpectedString(fileContent,"was not found or is invalid") /// Nonexistent hash. There was a problem with Salsa that caused squiggles not to be shown for .fsx files. [] - member public this.``Fsx.Hash.RDoesNotExist.Bug3325``() = + member public this.``Fsx.Hash.RDoesNotExist.Bug3325``() = let fileContent = """#r "ThisDLLDoesNotExist" """ - this.VerifyFSXErrorListContainedExpectedString(fileContent,"'ThisDLLDoesNotExist' was not found or is invalid") + this.VerifyFSXErrorListContainedExpectedString(fileContent,"'ThisDLLDoesNotExist' was not found or is invalid") // There was a spurious error message on the first line. [] [] - member public this.``Fsx.ExactlyOneError.Bug4861``() = - let code = + member public this.``Fsx.ExactlyOneError.Bug4861``() = + let code = ["#light" // First line is important in this repro "#r \"Nonexistent\"" ] let (project, _) = createSingleFileFsxFromLines code AssertExactlyCountErrorSeenContaining(project, "Nonexistent", 2) // ...and not an error on the first line. - + [] - member public this.``Fsx.InvalidHashLoad.ShouldBeASquiggle.Bug3012``() = + member public this.``Fsx.InvalidHashLoad.ShouldBeASquiggle.Bug3012``() = let fileContent = """ #light #load "Bar.fs" """ - this.VerifyFSXErrorListContainedExpectedString(fileContent,"Bar.fs") + this.VerifyFSXErrorListContainedExpectedString(fileContent,"Bar.fs") // Transitive to existing property. [] [] - member public this.``Fsx.ScriptClosure.TransitiveLoad1``() = - use _guard = this.UsingNewVS() + member public this.``Fsx.ScriptClosure.TransitiveLoad1``() = + use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public Property = 0" - ]) - let file1 = OpenFile(project,"File1.fs") + ]) + let file1 = OpenFile(project,"File1.fs") let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"File1.fs\"" - ]) - let script2 = OpenFile(project,"Script2.fsx") + ]) + let script2 = OpenFile(project,"Script2.fsx") let script2 = AddFileFromText(project,"Script1.fsx", ["#load \"Script1.fsx\"" - "Namespace.Foo.Property" - ]) - let script2 = OpenFile(project,"Script2.fsx") + "Namespace.Foo.Property" + ]) + let script2 = OpenFile(project,"Script2.fsx") TakeCoffeeBreak(this.VS) AssertNoErrorsOrWarnings(project) // Transitive to nonexisting property. [] [] - member public this.``Fsx.ScriptClosure.TransitiveLoad2``() = - use _guard = this.UsingNewVS() + member public this.``Fsx.ScriptClosure.TransitiveLoad2``() = + use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public Property = 0" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"File1.fs\"" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"Script2.fsx\"" - "Namespace.Foo.NonExistingProperty" - ]) - let script1 = OpenFile(project,"Script1.fsx") + "Namespace.Foo.NonExistingProperty" + ]) + let script1 = OpenFile(project,"Script1.fsx") TakeCoffeeBreak(this.VS) AssertExactlyOneErrorSeenContaining(project, "NonExistingProperty") /// FEATURE: Typing a #r into a file will cause it to be recognized by intellisense. [] [] - member public this.``Fsx.HashR.AddedIn``() = + member public this.``Fsx.HashR.AddedIn``() = let code = ["#light" "//#r \"System.Transactions.dll\"" // Pick anything that isn't in the standard set of assemblies. @@ -229,7 +229,7 @@ type UsingMSBuild() as this = ] let (project, file) = createSingleFileFsxFromLines code VerifyErrorListContainedExpetedStr("Transactions",project) - + let gpatcc = GlobalParseAndTypeCheckCounter.StartNew(this.VS) ReplaceFileInMemory file ["#light" @@ -241,29 +241,29 @@ type UsingMSBuild() as this = // FEATURE: Adding a #load to a file will cause types from that file to be visible in intellisense [] - member public this.``Fsx.HashLoad.Added``() = + member public this.``Fsx.HashLoad.Added``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") let fs = AddFileFromText(project,"File1.fs", ["#light" - "namespace MyNamespace" + "namespace MyNamespace" " module MyModule =" - " let x = 1" - ]) - + " let x = 1" + ]) + let fsx = AddFileFromText(project,"File2.fsx", ["#light" - "//#load \"File1.fs\"" + "//#load \"File1.fs\"" "open MyNamespace.MyModule" "printfn \"%d\" x" - ]) - let fsx = OpenFile(project,"File2.fsx") + ]) + let fsx = OpenFile(project,"File2.fsx") VerifyErrorListContainedExpetedStr("MyNamespace",project) - + ReplaceFileInMemory fsx ["#light" - "#load \"File1.fs\"" + "#load \"File1.fs\"" "open MyNamespace.MyModule" "printfn \"%d\" x" ] @@ -272,35 +272,35 @@ type UsingMSBuild() as this = // FEATURE: Removing a #load to a file will cause types from that file to no longer be visible in intellisense [] - member public this.``Fsx.HashLoad.Removed``() = + member public this.``Fsx.HashLoad.Removed``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") let fs = AddFileFromText(project,"File1.fs", ["#light" - "namespace MyNamespace" + "namespace MyNamespace" " module MyModule =" - " let x = 1" - ]) - + " let x = 1" + ]) + let fsx = AddFileFromText(project,"File2.fsx", ["#light" - "#load \"File1.fs\"" + "#load \"File1.fs\"" "open MyNamespace.MyModule" "printfn \"%d\" x" - ]) - let fsx = OpenFile(project,"File2.fsx") + ]) + let fsx = OpenFile(project,"File2.fsx") AssertNoErrorsOrWarnings(project) - + ReplaceFileInMemory fsx ["#light" - "//#load \"File1.fs\"" + "//#load \"File1.fs\"" "open MyNamespace.MyModule" "printfn \"%d\" x" ] TakeCoffeeBreak(this.VS) VerifyErrorListContainedExpetedStr("MyNamespace",project) - + [] member public this.``Fsx.HashLoad.Conditionals``() = use _guard = this.UsingNewVS() @@ -318,13 +318,13 @@ type UsingMSBuild() as this = "#else" "let B = 4" "#endif" - ]) - + ]) + let fsx = AddFileFromText(project,"File2.fsx", [ - "#load \"File1.fs\"" + "#load \"File1.fs\"" "InDifferentFS." - ]) + ]) let fsx = OpenFile(project,"File2.fsx") MoveCursorToEndOfMarker(fsx, "InDifferentFS.") @@ -333,12 +333,12 @@ type UsingMSBuild() as this = Assert.AreEqual(Set.count completion, 2, "Expected 2 elements in the completion list") Assert.IsTrue(completion.Contains "x", "Completion list should contain x because INTERACTIVE is defined") Assert.IsTrue(completion.Contains "B", "Completion list should contain B because DEBUG is not defined") - + /// FEATURE: Removing a #r into a file will cause it to no longer be seen by intellisense. [] [] - member public this.``Fsx.HashR.Removed``() = + member public this.``Fsx.HashR.Removed``() = let code = ["#light" "#r \"System.Transactions.dll\"" // Pick anything that isn't in the standard set of assemblies. @@ -346,8 +346,8 @@ type UsingMSBuild() as this = ] let (project, file) = createSingleFileFsxFromLines code TakeCoffeeBreak(this.VS) - AssertNoErrorsOrWarnings(project) - + AssertNoErrorsOrWarnings(project) + let gpatcc = GlobalParseAndTypeCheckCounter.StartNew(this.VS) ReplaceFileInMemory file ["#light" @@ -358,184 +358,184 @@ type UsingMSBuild() as this = TakeCoffeeBreak(this.VS) VerifyErrorListContainedExpetedStr("Transactions",project) gpatcc.AssertExactly(notAA[file], notAA[file], true (* expectCreate, because dependent DLL set changed *)) - + // Corecursive load to existing property. [] [] - member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad3``() = + member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad3``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public Property = 0" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"Script1.fsx\"" "#load \"File1.fs\"" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"Script2.fsx\"" "#load \"File1.fs\"" - "Namespace.Foo.Property" - ]) - let script1 = OpenFile(project,"Script1.fsx") + "Namespace.Foo.Property" + ]) + let script1 = OpenFile(project,"Script1.fsx") TakeCoffeeBreak(this.VS) AssertNoErrorsOrWarnings(project) - + // #load of .fsi is respected (for non-hidden property) [] [] - member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad9``() = + member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad9``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1fsi = AddFileFromText(project,"File1.fsi", ["namespace Namespace" "type Foo =" " class" " static member Property : int" // Not exposing 'HiddenProperty' " end" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public HiddenProperty = 0" " static member public Property = 0" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fsi\"" "#load \"File1.fs\"" - "Namespace.Foo.Property" - ]) - let script1 = OpenFile(project,"Script1.fsx") - AssertNoErrorsOrWarnings(project) + "Namespace.Foo.Property" + ]) + let script1 = OpenFile(project,"Script1.fsx") + AssertNoErrorsOrWarnings(project) - // #load of .fsi is respected at second #load level (for non-hidden property) + // #load of .fsi is respected at second #load level (for non-hidden property) [] [] - member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad10``() = + member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad10``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1fsi = AddFileFromText(project,"File1.fsi", ["namespace Namespace" "type Foo =" " class" " static member Property : int" // Not exposing 'HiddenProperty' " end" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public HiddenProperty = 0" " static member public Property = 0" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fsi\"" "#load \"File1.fs\"" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"Script1.fsx\"" - "Namespace.Foo.Property" - ]) - let script2 = OpenFile(project,"Script2.fsx") - AssertNoErrorsOrWarnings(project) + "Namespace.Foo.Property" + ]) + let script2 = OpenFile(project,"Script2.fsx") + AssertNoErrorsOrWarnings(project) // #load of .fsi is respected when dispersed between two #load levels (for non-hidden property) [] [] - member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad11``() = + member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad11``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1fsi = AddFileFromText(project,"File1.fsi", ["namespace Namespace" "type Foo =" " class" " static member Property : int" // Not exposing 'HiddenProperty' " end" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public HiddenProperty = 0" " static member public Property = 0" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fsi\"" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"Script1.fsx\"" "#load \"File1.fs\"" - "Namespace.Foo.Property" - ]) - let script2 = OpenFile(project,"Script2.fsx") - AssertNoErrorsOrWarnings(project) - + "Namespace.Foo.Property" + ]) + let script2 = OpenFile(project,"Script2.fsx") + AssertNoErrorsOrWarnings(project) + // #load of .fsi is respected when dispersed between two #load levels (the other way) (for non-hidden property) [] [] - member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad12``() = + member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad12``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1fsi = AddFileFromText(project,"File1.fsi", ["namespace Namespace" "type Foo =" " class" " static member Property : int" // Not exposing 'HiddenProperty' " end" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public HiddenProperty = 0" " static member public Property = 0" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fs\"" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"File1.fsi\"" "#load \"Script1.fsx\"" - "Namespace.Foo.Property" - ]) - let script2 = OpenFile(project,"Script2.fsx") - AssertNoErrorsOrWarnings(project) - + "Namespace.Foo.Property" + ]) + let script2 = OpenFile(project,"Script2.fsx") + AssertNoErrorsOrWarnings(project) + // #nowarn seen in closed .fsx is global to the closure [] [] - member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad16``() = + member public this.``Fsx.NoError.ScriptClosure.TransitiveLoad16``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let thisProject = AddFileFromText(project,"ThisProject.fsx", ["#nowarn \"44\"" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"ThisProject.fsx\"" // Should bring in #nowarn "44" so we don't see this warning: "[]" - "let fn x = 0" + "let fn _x = 0" "let y = fn 1" - ]) + ]) - let script1 = OpenFile(project,"Script1.fsx") - MoveCursorToEndOfMarker(script1,"let y = f") - TakeCoffeeBreak(this.VS) - AssertNoErrorsOrWarnings(project) + let script1 = OpenFile(project,"Script1.fsx") + MoveCursorToEndOfMarker(script1,"let y = f") + TakeCoffeeBreak(this.VS) + AssertNoErrorsOrWarnings(project) /// FEATURE: #r in .fsx to a .dll name works. [] - member public this.``Fsx.NoError.HashR.DllWithNoPath``() = + member public this.``Fsx.NoError.HashR.DllWithNoPath``() = let fileContent = """ #light #r "System.Transactions.dll" @@ -545,7 +545,7 @@ type UsingMSBuild() as this = [] // 'System' is in the default set. Make sure we can still resolve it. - member public this.``Fsx.NoError.HashR.BugDefaultReferenceFileIsAlsoResolved``() = + member public this.``Fsx.NoError.HashR.BugDefaultReferenceFileIsAlsoResolved``() = let fileContent = """ #light #r "System" @@ -554,7 +554,7 @@ type UsingMSBuild() as this = [] [] - member public this.``Fsx.NoError.HashR.DoubleReference``() = + member public this.``Fsx.NoError.HashR.DoubleReference``() = let fileContent = """ #light #r "System" @@ -565,7 +565,7 @@ type UsingMSBuild() as this = [] [] // 'CustomMarshalers' is loaded from the GAC _and_ it is available on XP and above. - member public this.``Fsx.NoError.HashR.ResolveFromGAC``() = + member public this.``Fsx.NoError.HashR.ResolveFromGAC``() = let fileContent = """ #light #r "CustomMarshalers" @@ -591,14 +591,14 @@ type UsingMSBuild() as this = ["module Lib" "let X = 42" ]) - + let bld = Build(project) let script1Dir = Path.Combine(ProjectDirectory(project), "ccc") let script1Path = Path.Combine(script1Dir, "Script1.fsx") let script2Dir = Path.Combine(ProjectDirectory(project), "aaa\\bbb") let script2Path = Path.Combine(script2Dir, "Script2.fsx") - + Directory.CreateDirectory(script1Dir) |> ignore Directory.CreateDirectory(script2Dir) |> ignore File.Move(bld.ExecutableOutput, Path.Combine(ProjectDirectory(project), "aaa\\lib.exe")) @@ -611,17 +611,17 @@ type UsingMSBuild() as this = ["#r \"../lib.exe\"" ]) - let script1 = OpenFile(project, script1Path) + let script1 = OpenFile(project, script1Path) TakeCoffeeBreak(this.VS) - + MoveCursorToEndOfMarker(script1,"#load") let ans = GetSquiggleAtCursor(script1) AssertNoSquiggle(ans) [] [] - member public this.``Fsx.NoError.HashR.RelativePath2``() = - use _guard = this.UsingNewVS() + member public this.``Fsx.NoError.HashR.RelativePath2``() = + use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") let file1 = AddFileFromText(project,"lib.fs", @@ -635,7 +635,7 @@ type UsingMSBuild() as this = let script1Path = Path.Combine(script1Dir, "Script1.fsx") let script2Dir = Path.Combine(ProjectDirectory(project), "aaa") let script2Path = Path.Combine(script2Dir, "Script2.fsx") - + Directory.CreateDirectory(script1Dir) |> ignore Directory.CreateDirectory(script2Dir) |> ignore File.Move(bld.ExecutableOutput, Path.Combine(ProjectDirectory(project), "aaa\\lib.exe")) @@ -647,60 +647,60 @@ type UsingMSBuild() as this = let script2 = File.WriteAllLines(script2Path, ["#r \"lib.exe\"" ]) - - let script1 = OpenFile(project, script1Path) + + let script1 = OpenFile(project, script1Path) TakeCoffeeBreak(this.VS) - + MoveCursorToEndOfMarker(script1,"#load") let ans = GetSquiggleAtCursor(script1) AssertNoSquiggle(ans) /// FEATURE: #load in an .fsx file will include that file in the 'build' of the .fsx. [] - member public this.``Fsx.NoError.HashLoad.Simple``() = + member public this.``Fsx.NoError.HashLoad.Simple``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") let fs = AddFileFromText(project,"File1.fs", ["#light" - "namespace MyNamespace" + "namespace MyNamespace" " module MyModule =" - " let x = 1" - ]) - + " let x = 1" + ]) + let fsx = AddFileFromText(project,"File2.fsx", ["#light" - "#load \"File1.fs\"" + "#load \"File1.fs\"" "open MyNamespace.MyModule" "printfn \"%d\" x" - ]) - let fsx = OpenFile(project,"File2.fsx") + ]) + let fsx = OpenFile(project,"File2.fsx") AssertNoErrorsOrWarnings(project) // In this bug the #loaded file contains a level-4 warning (copy to avoid mutation). This warning was reported at the #load in file2.fsx but shouldn't have been.s [] [] - member public this.``Fsx.NoWarn.OnLoadedFile.Bug4837``() = + member public this.``Fsx.NoWarn.OnLoadedFile.Bug4837``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") let fs = AddFileFromText(project,"File1.fs", ["module File1Module" "let x = System.DateTime.Now - System.DateTime.Now" - "x.Add(x) |> ignore" - ]) - + "x.Add(x) |> ignore" + ]) + let fsx = AddFileFromText(project,"File2.fsx", [ - "#load \"File1.fs\"" - ]) - let fsx = OpenFile(project,"File2.fsx") - AssertNoErrorsOrWarnings(project) + "#load \"File1.fs\"" + ]) + let fsx = OpenFile(project,"File2.fsx") + AssertNoErrorsOrWarnings(project) /// FEATURE: .fsx files have automatic imports of certain system assemblies. //There is a test bug here. The actual scenario works. Need to revisit. [] - [] + [] member public this.``Fsx.NoError.AutomaticImportsForFsxFiles``() = let fileContent = """ #light @@ -714,186 +714,186 @@ type UsingMSBuild() as this = open System.Web open System.Web.Services open System.Windows.Forms""" - this.VerifyFSXNoErrorList(fileContent) + this.VerifyFSXNoErrorList(fileContent) // Corecursive load to nonexisting property. [] [] - member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad4``() = + member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad4``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public Property = 0" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"Script1.fsx\"" "#load \"File1.fs\"" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"Script2.fsx\"" "#load \"File1.fs\"" - "Namespace.Foo.NonExistingProperty" - ]) - let script1 = OpenFile(project,"Script1.fsx") - AssertExactlyOneErrorSeenContaining(project, "NonExistingProperty") + "Namespace.Foo.NonExistingProperty" + ]) + let script1 = OpenFile(project,"Script1.fsx") + AssertExactlyOneErrorSeenContaining(project, "NonExistingProperty") // #load of .fsi is respected [] [] - member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad5``() = + member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad5``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1fsi = AddFileFromText(project,"File1.fsi", ["namespace Namespace" "type Foo =" " class" " static member Property : int" // Not exposing 'HiddenProperty' " end" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public HiddenProperty = 0" " static member public Property = 0" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fsi\"" "#load \"File1.fs\"" - "Namespace.Foo.HiddenProperty" - ]) - let script1 = OpenFile(project,"Script1.fsx") - AssertExactlyOneErrorSeenContaining(project, "HiddenProperty") + "Namespace.Foo.HiddenProperty" + ]) + let script1 = OpenFile(project,"Script1.fsx") + AssertExactlyOneErrorSeenContaining(project, "HiddenProperty") // #load of .fsi is respected at second #load level [] [] - member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad6``() = + member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad6``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1fsi = AddFileFromText(project,"File1.fsi", ["namespace Namespace" "type Foo =" " class" " static member Property : int" // Not exposing 'HiddenProperty' " end" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public HiddenProperty = 0" " static member public Property = 0" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fsi\"" "#load \"File1.fs\"" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"Script1.fsx\"" - "Namespace.Foo.HiddenProperty" - ]) - let script2 = OpenFile(project,"Script2.fsx") - AssertExactlyOneErrorSeenContaining(project, "HiddenProperty") - + "Namespace.Foo.HiddenProperty" + ]) + let script2 = OpenFile(project,"Script2.fsx") + AssertExactlyOneErrorSeenContaining(project, "HiddenProperty") + // #load of .fsi is respected when dispersed between two #load levels [] [] - member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad7``() = + member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad7``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1fsi = AddFileFromText(project,"File1.fsi", ["namespace Namespace" "type Foo =" " class" " static member Property : int" // Not exposing 'HiddenProperty' " end" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public HiddenProperty = 0" " static member public Property = 0" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fsi\"" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"Script1.fsx\"" "#load \"File1.fs\"" - "Namespace.Foo.HiddenProperty" - ]) - let script2 = OpenFile(project,"Script2.fsx") - AssertExactlyOneErrorSeenContaining(project, "HiddenProperty") - + "Namespace.Foo.HiddenProperty" + ]) + let script2 = OpenFile(project,"Script2.fsx") + AssertExactlyOneErrorSeenContaining(project, "HiddenProperty") + // #load of .fsi is respected when dispersed between two #load levels (the other way) [] [] - member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad8``() = + member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad8``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file1fsi = AddFileFromText(project,"File1.fsi", ["namespace Namespace" "type Foo =" " class" " static member Property : int" // Not exposing 'HiddenProperty' " end" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["namespace Namespace" "type Foo = " " static member public HiddenProperty = 0" " static member public Property = 0" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fs\"" - ]) + ]) let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"File1.fsi\"" "#load \"Script1.fsx\"" - "Namespace.Foo.HiddenProperty" - ]) - let script2 = OpenFile(project,"Script2.fsx") - AssertExactlyOneErrorSeenContaining(project, "HiddenProperty") - + "Namespace.Foo.HiddenProperty" + ]) + let script2 = OpenFile(project,"Script2.fsx") + AssertExactlyOneErrorSeenContaining(project, "HiddenProperty") + // Bug seen during development: A #load in an .fs would be followed. [] [] - member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad15``() = + member public this.``Fsx.ExactlyOneError.ScriptClosure.TransitiveLoad15``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let file2 = AddFileFromText(project,"File2.fs", ["namespace Namespace" "type Type() =" " static member Property = 0" - ]) + ]) let file1 = AddFileFromText(project,"File1.fs", ["#load \"File2.fs\"" // This is not allowed but it was working anyway. "namespace File2Namespace" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"File1.fs\"" "Namespace.Type.Property" - ]) + ]) - let script1 = OpenFile(project,"Script1.fsx") + let script1 = OpenFile(project,"Script1.fsx") TakeCoffeeBreak(this.VS) - AssertExactlyOneErrorSeenContaining(project, "Namespace") + AssertExactlyOneErrorSeenContaining(project, "Namespace") [] member public this.``Fsx.Bug4311HoverOverReferenceInFirstLine``() = let fileContent = """#r "PresentationFramework.dll" - + #r "PresentationCore.dll" """ let marker = "#r \"PresentationFrame" this.AssertQuickInfoContainsAtEndOfMarkerInFsxFile fileContent marker "PresentationFramework.dll" @@ -901,19 +901,19 @@ type UsingMSBuild() as this = [] member public this.``Fsx.QuickInfo.Bug4979``() = - let code = + let code = ["System.ConsoleModifiers.Shift |> ignore " "(3).ToString().Length |> ignore "] let (project, file) = createSingleFileFsxFromLines code MoveCursorToEndOfMarker(file, "System.ConsoleModifiers.Sh") let tooltip = GetQuickInfoAtCursor file - AssertContains(tooltip, @"The left or right SHIFT modifier key.") - + AssertContains(tooltip, @"The left or right SHIFT modifier key.") + MoveCursorToEndOfMarker(file, "(3).ToString().Len") let tooltip = GetQuickInfoAtCursor file AssertContains(tooltip, @"[Signature:P:System.String.Length]") // A message from the mock IDocumentationBuilder - AssertContains(tooltip, @"[Filename:") - AssertContains(tooltip, @"netstandard.dll]") // The assembly we expect the documentation to get taken from + AssertContains(tooltip, @"[Filename:") + AssertContains(tooltip, @"netstandard.dll]") // The assembly we expect the documentation to get taken from // Especially under 4.0 we need #r of .NET framework assemblies to resolve from like, // @@ -944,25 +944,25 @@ type UsingMSBuild() as this = this.AssertQuickInfoContainsAtEndOfMarkerInFsxFile """#r "System" """ // 'System' is in the default set. Make sure we can still resolve it. "#r \"Syst" "System.dll" - + [] [] member public this.``Fsx.HashR_QuickInfo.DoubleReference``() = let fileContent = """#r "System" // Mark1 - #r "System" // Mark2 """ // The same reference repeated twice. + #r "System" // Mark2 """ // The same reference repeated twice. this.AssertQuickInfoContainsAtStartOfMarkerInFsxFile fileContent "tem\" // Mark1" "System.dll" this.AssertQuickInfoContainsAtStartOfMarkerInFsxFile fileContent "tem\" // Mark2" "System.dll" - + [] [] - member public this.``Fsx.HashR_QuickInfo.ResolveFromGAC``() = + member public this.``Fsx.HashR_QuickInfo.ResolveFromGAC``() = this.AssertQuickInfoContainsAtEndOfMarkerInFsxFile """#r "CustomMarshalers" """ // 'mscorcfg' is loaded from the GAC _and_ it is available on XP and above. "#r \"Custo" ".NET Framework" [] [] - member public this.``Fsx.HashR_QuickInfo.ResolveFromFullyQualifiedPath``() = + member public this.``Fsx.HashR_QuickInfo.ResolveFromFullyQualifiedPath``() = let fullyqualifiepathtoddll = System.IO.Path.Combine( System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), "System.configuration.dll" ) // Can be any fully qualified path to an assembly let expectedtooltip = System.Reflection.Assembly.ReflectionOnlyLoadFrom(fullyqualifiepathtoddll).FullName let fileContent = "#r @\"" + fullyqualifiepathtoddll + "\"" @@ -971,12 +971,12 @@ type UsingMSBuild() as this = //this.AssertQuickInfoNotContainsAtEndOfMarkerInFsxFile fileContent marker ".dll" [] - member public this.``Fsx.InvalidHashReference.ShouldBeASquiggle.Bug3012``() = - let code = + member public this.``Fsx.InvalidHashReference.ShouldBeASquiggle.Bug3012``() = + let code = ["#light" "#r \"Bar.dll\""] let (project, file) = createSingleFileFsxFromLines code - MoveCursorToEndOfMarker(file,"#r \"Ba") + MoveCursorToEndOfMarker(file,"#r \"Ba") let squiggle = GetSquiggleAtCursor(file) TakeCoffeeBreak(this.VS) Assert.IsTrue(snd squiggle.Value |> fun str -> str.Contains("Bar.dll")) @@ -984,63 +984,63 @@ type UsingMSBuild() as this = // Bug seen during development: The unresolved reference error would x-ray through to the root. [] [] - member public this.``Fsx.ScriptClosure.TransitiveLoad14``() = + member public this.``Fsx.ScriptClosure.TransitiveLoad14``() = use _guard = this.UsingNewVS() let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject") + let project = CreateProject(solution,"testproject") let script2 = AddFileFromText(project,"Script2.fsx", ["#load \"Script1.fsx\"" "#r \"NonExisting\"" - ]) + ]) let script1 = AddFileFromText(project,"Script1.fsx", ["#load \"Script2.fsx\"" "#r \"System\"" - ]) + ]) - let script1 = OpenFile(project,"Script1.fsx") - TakeCoffeeBreak(this.VS) - MoveCursorToEndOfMarker(script1,"#r \"Sys") + let script1 = OpenFile(project,"Script1.fsx") + TakeCoffeeBreak(this.VS) + MoveCursorToEndOfMarker(script1,"#r \"Sys") AssertEqual(None,GetSquiggleAtCursor(script1)) - - member private this.TestFsxHashDirectivesAreErrors(mark : string, expectedStr : string) = - let code = + + member private this.TestFsxHashDirectivesAreErrors(mark : string, expectedStr : string) = + let code = ["#light" "#r \"JoeBob\"" "#I \".\"" "#load \"Dooby\"" ] let (_, _, file) = this.CreateSingleFileProject(code) - MoveCursorToEndOfMarker(file,mark) + MoveCursorToEndOfMarker(file,mark) let ans = GetSquiggleAtCursor(file) match ans with - | Some(sev,msg) -> + | Some(sev,msg) -> AssertEqual(Microsoft.VisualStudio.FSharp.LanguageService.Severity.Error,sev) AssertContains(msg,expectedStr) - | _ -> Assert.Fail() + | _ -> Assert.Fail() /// FEATURE: #r, #I, #load are all errors when running under the language service [] - member public this.``Fsx.HashDirectivesAreErrors.InNonScriptFiles.Case1``() = + member public this.``Fsx.HashDirectivesAreErrors.InNonScriptFiles.Case1``() = this.TestFsxHashDirectivesAreErrors("#r \"Joe","#r") - + [] - member public this.``Fsx.HashDirectivesAreErrors.InNonScriptFiles.Case2``() = - this.TestFsxHashDirectivesAreErrors("#I \"","#I") - + member public this.``Fsx.HashDirectivesAreErrors.InNonScriptFiles.Case2``() = + this.TestFsxHashDirectivesAreErrors("#I \"","#I") + [] - member public this.``Fsx.HashDirectivesAreErrors.InNonScriptFiles.Case3``() = - this.TestFsxHashDirectivesAreErrors("#load \"Doo","may only be used in F# script files") + member public this.``Fsx.HashDirectivesAreErrors.InNonScriptFiles.Case3``() = + this.TestFsxHashDirectivesAreErrors("#load \"Doo","may only be used in F# script files") /// FEATURE: #reference against a non-assembly .EXE gives a reasonable error message //[] - member public this.``Fsx.HashReferenceAgainstNonAssemblyExe``() = + member public this.``Fsx.HashReferenceAgainstNonAssemblyExe``() = let windows = System.Environment.GetEnvironmentVariable("windir") let code = ["#light" sprintf "#reference @\"%s\"" (Path.Combine(windows,"notepad.exe")) " let x = 1"] let (_, file) = createSingleFileFsxFromLines code - + MoveCursorToEndOfMarker(file,"#refe") let ans = GetSquiggleAtCursor(file) AssertSquiggleIsErrorContaining(ans, "was not found or is invalid") @@ -1054,10 +1054,10 @@ type UsingMSBuild() as this = use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") - - let file1 = AddFileFromText(project,"File1.fs", + + let file1 = AddFileFromText(project,"File1.fs", ["#light" - "module File1" + "module File1" "DogChow" // <-- error ]) @@ -1066,13 +1066,13 @@ type UsingMSBuild() as this = "#load @\"File1.fs\"" ]) let file2 = OpenFile(project,"File2.fsx") - + MoveCursorToEndOfMarker(file2,"#load @\"Fi") - TakeCoffeeBreak(this.VS) - let ans = GetSquiggleAtCursor(file2) - AssertSquiggleIsErrorContaining(ans, "DogChow") - - + TakeCoffeeBreak(this.VS) + let ans = GetSquiggleAtCursor(file2) + AssertSquiggleIsErrorContaining(ans, "DogChow") + + // FEATURE: A #loaded file is squiggled with a warning if there are warning that file. [] [] @@ -1080,8 +1080,8 @@ type UsingMSBuild() as this = use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") - - let file1 = AddFileFromText(project,"File1.fs", + + let file1 = AddFileFromText(project,"File1.fs", ["module File1Module" "type WarningHere<'a> = static member X() = 0" "let y = WarningHere.X" @@ -1092,10 +1092,10 @@ type UsingMSBuild() as this = "#load @\"File1.fs\"" ]) let file2 = OpenFile(project,"File2.fsx") - + MoveCursorToEndOfMarker(file2,"#load @\"Fi") let ans = GetSquiggleAtCursor(file2) - AssertSquiggleIsWarningContaining(ans, "WarningHere") + AssertSquiggleIsWarningContaining(ans, "WarningHere") // Bug: #load should report the first error message from a file [] @@ -1104,10 +1104,10 @@ type UsingMSBuild() as this = use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") - - let file1 = AddFileFromText(project,"File1.fs", + + let file1 = AddFileFromText(project,"File1.fs", [ "#light" - "module File1" + "module File1" "let a = 1 + \"\"" "let c = new obj()" "let b = c.foo()" @@ -1117,7 +1117,7 @@ type UsingMSBuild() as this = "#load @\"File1.fs\"" ]) let file2 = OpenFile(project,"File2.fsx") - + MoveCursorToEndOfMarker(file2,"#load @\"Fi") let ans = GetSquiggleAtCursor(file2) AssertSquiggleIsErrorContaining(ans, "'string'") @@ -1130,7 +1130,7 @@ type UsingMSBuild() as this = use _guard = this.UsingNewVS() let stopWatch = new System.Diagnostics.Stopwatch() let ResetStopWatch() = stopWatch.Reset(); stopWatch.Start() - let time1 op a message = + let time1 op a message = ResetStopWatch() let result = op a printf "%s %d ms\n" message stopWatch.ElapsedMilliseconds @@ -1141,23 +1141,23 @@ type UsingMSBuild() as this = let projectOutput = time1 Build project "Time to build project" printfn "Output of building project was %s" projectOutput.ExecutableOutput printfn "Project directory is %s" (ProjectDirectory project) - + let file2 = AddFileFromText(project,"File2.fsx", ["#light" "#reference @\"bin\\Debug\\testproject.exe\"" ]) let file2 = OpenFile(project,"File2.fsx") - + MoveCursorToEndOfMarker(file2,"#reference @\"bin\\De") let ans = GetSquiggleAtCursor(file2) AssertNoSquiggle(ans) - + /// In this bug, multiple references to mscorlib .dll were causing problem in load closure [] [] - member public this.``Fsx.BugAllowExplicitReferenceToMsCorlib``() = + member public this.``Fsx.BugAllowExplicitReferenceToMsCorlib``() = let code = ["#r \"mscorlib\"" "fsi." @@ -1166,13 +1166,13 @@ type UsingMSBuild() as this = MoveCursorToEndOfMarker(file,"fsi.") TakeCoffeeBreak(this.VS) let completions = AutoCompleteAtCursor file - AssertCompListContains(completions,"CommandLineArgs") - - /// FEATURE: There is a global fsi module that should be in scope for script files. + AssertCompListContains(completions,"CommandLineArgs") + + /// FEATURE: There is a global fsi module that should be in scope for script files. [] [] - member public this.``Fsx.Bug2530FsiObject``() = - let code = + member public this.``Fsx.Bug2530FsiObject``() = + let code = ["#light" "fsi." ] @@ -1181,12 +1181,12 @@ type UsingMSBuild() as this = TakeCoffeeBreak(this.VS) let completions = AutoCompleteAtCursor file AssertCompListContains(completions,"CommandLineArgs") - + // Ensure that the script closure algorithm gets the right order of hash directives [] [] - member public this.``Fsx.ScriptClosure.SurfaceOrderOfHashes``() = - let code = + member public this.``Fsx.ScriptClosure.SurfaceOrderOfHashes``() = + let code = ["#r \"System.Runtime.Remoting\"" "#r \"System.Transactions\"" "#load \"Load1.fs\"" @@ -1205,21 +1205,21 @@ type UsingMSBuild() as this = /// FEATURE: #reference against a strong name should work. [] - member public this.``Fsx.HashReferenceAgainstStrongName``() = + member public this.``Fsx.HashReferenceAgainstStrongName``() = let code = ["#light" sprintf "#reference \"System.Core, Version=%s, Culture=neutral, PublicKeyToken=b77a5c561934e089\"" (System.Environment.Version.ToString()) "open System."] let (_, file) = createSingleFileFsxFromLines code - MoveCursorToEndOfMarker(file,"open System.") + MoveCursorToEndOfMarker(file,"open System.") let completions = AutoCompleteAtCursor file - AssertCompListContains(completions,"Linq") + AssertCompListContains(completions,"Linq") /// Try out some bogus file names in #r, #I and #load. [] member public this.``Fsx.InvalidMetaCommandFilenames``() = - let code = + let code = [ "#r @\"\"" "#load @\"\"" @@ -1246,9 +1246,9 @@ type UsingMSBuild() as this = ] let (_, file) = createSingleFileFsxFromLines code MoveCursorToEndOfMarker(file,"let xy") - AssertEqual(TokenType.Identifier ,GetTokenTypeAtCursor(file)) + AssertEqual(TokenType.Identifier ,GetTokenTypeAtCursor(file)) - // Ensure that basic compile of an .fsx works + // Ensure that basic compile of an .fsx works [] [] [] @@ -1256,15 +1256,15 @@ type UsingMSBuild() as this = use _guard = this.UsingNewVS() let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") - + let file1 = AddFileFromTextEx(project,"Script.fsx","Script.fsx",BuildAction.Compile, ["printfn \"Hello world\""]) let build = time1 Build project "Time to build project" Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") ShowErrors(project) - - // Compile a script which #loads a source file. The build can't succeed without the loaded file. + + // Compile a script which #loads a source file. The build can't succeed without the loaded file. [] [] [] @@ -1281,13 +1281,13 @@ type UsingMSBuild() as this = ["#load \"File.fs\"" "printfn \"%d\" Namespace.Module.Value"]) let build = time1 Build project "Time to build project" - if SupportsOutputWindowPane(this.VS) then + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) for line in lines do printfn "%s" line () Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") - - // Compile a script which #loads a source file. The build can't succeed without + + // Compile a script which #loads a source file. The build can't succeed without [] [] [] @@ -1303,13 +1303,13 @@ type UsingMSBuild() as this = let fsx = AddFileFromTextEx(project,"Script.fsx","Script.fsx",BuildAction.Compile, ["#load \"File.fs\"" "printfn \"%d\" Namespace.Module.Value"]) - let build = time1 Build project "Time to build project" - if SupportsOutputWindowPane(this.VS) then + let build = time1 Build project "Time to build project" + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) for line in lines do printfn "%s" line () - Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") - + Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") + // Must be explicitly referenced by compile. [] [] @@ -1320,13 +1320,13 @@ type UsingMSBuild() as this = let project = CreateProject(solution,"testproject") let fsx = AddFileFromTextEx(project,"Script.fsx","Script.fsx",BuildAction.Compile, ["let x = fsi.CommandLineArgs"]) - let build = time1 Build project "Time to build project" - if SupportsOutputWindowPane(this.VS) then + let build = time1 Build project "Time to build project" + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) for line in lines do printfn "%s" line () - Assert.IsTrue(not(build.BuildSucceeded), "Expected build to fail") - + Assert.IsTrue(not(build.BuildSucceeded), "Expected build to fail") + // Must be explicitly referenced by compile. [] [] @@ -1350,16 +1350,16 @@ type UsingMSBuild() as this = let fsx = AddFileFromTextEx(project,"Script.fsx","Script.fsx",BuildAction.Compile, ["let x = fsi.CommandLineArgs"]) - let build = time1 Build project "Time to build project" - if SupportsOutputWindowPane(this.VS) then + let build = time1 Build project "Time to build project" + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) for line in lines do printfn "%s" line () - if not(SupportsOutputWindowPane(this.VS)) then - Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") - - - // Ensure that #load order is preserved when #loading multiple files. + if not(SupportsOutputWindowPane(this.VS)) then + Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") + + + // Ensure that #load order is preserved when #loading multiple files. [] [] [] @@ -1376,20 +1376,20 @@ type UsingMSBuild() as this = ["namespace Namespace" "module Module2 =" " let Value = Module1.Value" - ]) + ]) let fsx = AddFileFromTextEx(project,"Script.fsx","Script.fsx",BuildAction.Compile, [ "#load \"File1.fs\"" "#load \"File2.fs\"" "printfn \"%d\" Namespace.Module2.Value"]) - let build = time1 Build project "Time to build project" - if SupportsOutputWindowPane(this.VS) then + let build = time1 Build project "Time to build project" + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) for line in lines do printfn "%s" line () - Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") - - // If an fs file is explicitly passed in to the compiler and also #loaded then + Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") + + // If an fs file is explicitly passed in to the compiler and also #loaded then // the command-line order is respected rather than the #load order [] [] @@ -1407,21 +1407,21 @@ type UsingMSBuild() as this = ["namespace Namespace" "module Module2 =" " let Value = Module1.Value" - ]) + ]) let fsx = AddFileFromTextEx(project,"Script.fsx","Script.fsx",BuildAction.Compile, [ "#load \"File2.fs\"" // Wrong order "#load \"File1.fs\"" "printfn \"%d\" Namespace.Module2.Value"]) - let build = time1 Build project "Time to build project" - if SupportsOutputWindowPane(this.VS) then + let build = time1 Build project "Time to build project" + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) for line in lines do printfn "%s" line () - Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") + Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") + + - - // If a #loaded file does not exist, there should be an error [] [] @@ -1434,15 +1434,15 @@ type UsingMSBuild() as this = [ "#load \"NonexistentFile.fs\"" ]) - let build = time1 Build project "Time to build project" - if SupportsOutputWindowPane(this.VS) then + let build = time1 Build project "Time to build project" + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) for line in lines do printfn "%s" line - AssertListContainsInOrder(lines, ["error FS0079: Could not load file"; "NonexistentFile.fs"; "because it does not exist or is inaccessible"]) - - Assert.IsTrue(not(build.BuildSucceeded), "Expected build to fail") - - + AssertListContainsInOrder(lines, ["error FS0079: Could not load file"; "NonexistentFile.fs"; "because it does not exist or is inaccessible"]) + + Assert.IsTrue(not(build.BuildSucceeded), "Expected build to fail") + + // #r references should be respected. [] [] @@ -1456,14 +1456,14 @@ type UsingMSBuild() as this = "#r \"System.Messaging\"" "let a = new System.Messaging.AccessControlEntry()" ]) - let build = time1 Build project "Time to build project" - if SupportsOutputWindowPane(this.VS) then + let build = time1 Build project "Time to build project" + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) for line in lines do printfn "%s" line - - Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") - - + + Assert.IsTrue(build.BuildSucceeded, "Expected build to succeed") + + // Missing script file should be a reasonable failure, not a callstack. [] [] @@ -1473,24 +1473,24 @@ type UsingMSBuild() as this = let solution = this.CreateSolution() let project = CreateProject(solution,"testproject") let fsx = AddFileFromTextEx(project,"Script.fsx","Script.fsx",BuildAction.Compile,[]) - DeleteFileFromDisk(this.VS, fsx) - + DeleteFileFromDisk(this.VS, fsx) + let build = Build project - if SupportsOutputWindowPane(this.VS) then + if SupportsOutputWindowPane(this.VS) then let lines = GetOutputWindowPaneLines(this.VS) - AssertListContainsInOrder(lines, + AssertListContainsInOrder(lines, ["Could not find file " - "Script.fsx"]) - for line in lines do + "Script.fsx"]) + for line in lines do printfn "%s" line AssertNotContains(line,"error MSB") // Microsoft.FSharp.Targets(135,9): error MSB6006: "fsc.exe" exited with code -532462766. - Assert.IsTrue(not(build.BuildSucceeded), "Expected build to fail") - - + Assert.IsTrue(not(build.BuildSucceeded), "Expected build to fail") + + /// There was a problem in which synthetic tokens like #load were causing asserts [] - member public this.``Fsx.SyntheticTokens``() = + member public this.``Fsx.SyntheticTokens``() = Helper.ExhaustivelyScrutinize( this.TestRunner, ["#light" @@ -1498,49 +1498,49 @@ type UsingMSBuild() as this = "#reference \"\"" "#load \"\"" "#line 52" - "#nowarn 72"] + "#nowarn 72"] ) - + /// There was a problem where an unclosed reference picked up the text of the reference on the next line. [] - member public this.``Fsx.ShouldBeAbleToReference30Assemblies.Bug2050``() = - let code = + member public this.``Fsx.ShouldBeAbleToReference30Assemblies.Bug2050``() = + let code = ["#light" "#r \"System.Core.dll\"" "open System." ] let (_, file) = createSingleFileFsxFromLines code - MoveCursorToEndOfMarker(file,"open System.") + MoveCursorToEndOfMarker(file,"open System.") let completions = AutoCompleteAtCursor file AssertCompListContains(completions,"Linq") /// There was a problem where an unclosed reference picked up the text of the reference on the next line. [] - member public this.``Fsx.UnclosedHashReference.Case1``() = + member public this.``Fsx.UnclosedHashReference.Case1``() = Helper.ExhaustivelyScrutinize( this.TestRunner, ["#light" "#reference \"" // Unclosed - "#reference \"Hello There\""] + "#reference \"Hello There\""] ) [] - member public this.``Fsx.UnclosedHashReference.Case2``() = + member public this.``Fsx.UnclosedHashReference.Case2``() = Helper.ExhaustivelyScrutinize( this.TestRunner, ["#light" "#r \"" // Unclosed - "# \"Hello There\""] + "# \"Hello There\""] ) - + /// There was a problem where an unclosed reference picked up the text of the reference on the next line. [] - member public this.``Fsx.UnclosedHashLoad``() = + member public this.``Fsx.UnclosedHashLoad``() = Helper.ExhaustivelyScrutinize( - this.TestRunner, + this.TestRunner, [ "#light" "#load \"" // Unclosed "#load \"Hello There\""] - ) + ) [] [] @@ -1551,7 +1551,7 @@ type UsingMSBuild() as this = "let x2 : int = N1.T1().MethodWithErasedCodeUsingConditional()" "let x3 : int = N1.T1().MethodWithErasedCodeUsingTypeAs()" ] - let refs = + let refs = [ PathRelativeToTestAssembly(@"DummyProviderForLanguageServiceTesting.dll") ] @@ -1586,7 +1586,7 @@ type UsingMSBuild() as this = let totalInvaldiationHandlersAdded() = totalInvaldiationHandlersAddedMeth.Invoke(null, [| |]) :?> int let totalInvaldiationHandlersRemoved() = totalInvaldiationHandlersRemovedMeth.Invoke(null, [| |]) :?> int - + let startCreations = totalCreations() let startDisposals = totalDisposals() let startInvaldiationHandlersAdded = totalInvaldiationHandlersAdded() @@ -1598,12 +1598,12 @@ type UsingMSBuild() as this = Assert.IsTrue(startCreations >= startDisposals, "Check0") Assert.IsTrue(startInvaldiationHandlersAdded >= startInvaldiationHandlersRemoved, "Check0") - for i in 1 .. 50 do + for i in 1 .. 50 do let solution = this.CreateSolution() - let project = CreateProject(solution,"testproject" + string (i % 20)) + let project = CreateProject(solution,"testproject" + string (i % 20)) this.AddAssemblyReference(project, PathRelativeToTestAssembly(@"DummyProviderForLanguageServiceTesting.dll")) let fileName = sprintf "File%d.fs" i - let file1 = AddFileFromText(project,fileName, ["let x" + string i + " = N1.T1()" ]) + let file1 = AddFileFromText(project,fileName, ["let x" + string i + " = N1.T1()" ]) let file = OpenFile(project,fileName) TakeCoffeeBreak(this.VS) AssertNoErrorsOrWarnings project // ...and not an error on the first line. @@ -1615,9 +1615,9 @@ type UsingMSBuild() as this = ignore (GetF1KeywordAtCursor file) let parmInfo = GetParameterInfoAtCursor file - let file1 = OpenFile(project,fileName) + let file1 = OpenFile(project,fileName) - // The disposals should be at least one less + // The disposals should be at least one less let c = countCreations() let d = countDisposals() @@ -1628,15 +1628,15 @@ type UsingMSBuild() as this = // even after we've moved on from it. Assert.IsTrue((c >= i), "Check3, countCreations() >= i, iteration " + string i + ", countCreations() = " + string c) - if not clearing then + if not clearing then // By default we hold 3 build incrementalBuilderCache entries and 5 typeCheckInfo entries, so if we're not clearing // there should be some roots to project builds still present - if i >= 3 then + if i >= 3 then Assert.IsTrue(c >= d + 3, "Check4a, c >= countDisposals() + 3, iteration " + string i + ", i = " + string i + ", countDisposals() = " + string d) printfn "Check4a2, i = %d, countInvaldiationHandlersRemoved() = %d" i (countInvaldiationHandlersRemoved()) // If we forcefully clear out caches and force a collection, then we can say much stronger things... - if clearing then + if clearing then ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients(this.VS) let c = countCreations() let d = countDisposals() @@ -1644,7 +1644,7 @@ type UsingMSBuild() as this = // Creations should be equal to disposals after a `ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients` Assert.IsTrue((c = d), "Check4b, countCreations() = countDisposals(), iteration " + string i) Assert.IsTrue((countInvaldiationHandlersAdded() = countInvaldiationHandlersRemoved()), "Check4b2, all invlidation handlers removed, iteration " + string i) - + let c = countCreations() let d = countDisposals() Assert.IsTrue(c >= 50, "Check5, at end, countCreations() >= 50") @@ -1666,7 +1666,7 @@ type UsingMSBuild() as this = // Context project system -[] -type UsingProjectSystem() = +[] +type UsingProjectSystem() = inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour) From f5f558b3de48f7dffe23679255ec3ff212c0e953 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 5 Aug 2021 19:24:58 +0200 Subject: [PATCH 13/14] Add 1182 nowarn for cambridge suite --- tests/fsharp/single-test.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/fsharp/single-test.fs b/tests/fsharp/single-test.fs index 7c9d7aae2c8..00cb57f4ca2 100644 --- a/tests/fsharp/single-test.fs +++ b/tests/fsharp/single-test.fs @@ -146,6 +146,7 @@ let generateProjectArtifacts (pc:ProjectConfiguration) outputType (targetFramewo portable $(LANGUAGEVERSION) $(OPTIMIZE) + $(NOWARN);1182; false NETCOREAPP false From ee64b8206805ac2597087cb0854b77bb906e5f9a Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Fri, 6 Aug 2021 15:05:23 +0200 Subject: [PATCH 14/14] Added --nowarn:1182 by default, when running tests --- tests/fsharp/single-test.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/fsharp/single-test.fs b/tests/fsharp/single-test.fs index 00cb57f4ca2..947eba4064f 100644 --- a/tests/fsharp/single-test.fs +++ b/tests/fsharp/single-test.fs @@ -355,8 +355,8 @@ let singleTestBuildAndRunCore cfg copyFiles p languageVersion = let sources = extraSources |> List.filter (fileExists cfg) - fsc cfg "%s --optimize -a -o:test--optimize-lib.dll -g --langversion:preview " cfg.fsc_flags sources - fsc cfg "%s --optimize -r:test--optimize-lib.dll -o:test--optimize-client-of-lib.exe -g --langversion:preview " cfg.fsc_flags sources + fsc cfg "%s --optimize -a -o:test--optimize-lib.dll -g --langversion:preview --nowarn:1182 " cfg.fsc_flags sources + fsc cfg "%s --optimize -r:test--optimize-lib.dll -o:test--optimize-client-of-lib.exe -g --langversion:preview --nowarn:1182 " cfg.fsc_flags sources peverify cfg "test--optimize-lib.dll" peverify cfg "test--optimize-client-of-lib.exe" @@ -429,11 +429,11 @@ let singleVersionedNegTest (cfg: TestConfig) version testname = if cfg.fsc_flags.Contains("--warnaserror-") then String.Empty else "--warnaserror" - fscAppendErrExpectFail cfg (sprintf "%s.err" testname) """%s --vserrors %s --nologo --maxerrors:10000 -a -o:%s.dll""" cfg.fsc_flags warnaserror testname sources + fscAppendErrExpectFail cfg (sprintf "%s.err" testname) """%s --vserrors %s --nologo --nowarn:1182 --maxerrors:10000 -a -o:%s.dll""" cfg.fsc_flags warnaserror testname sources let diff = fsdiff cfg (sprintf "%s.err" testname) (sprintf "%s.bsl" testname) - fscAppendErrExpectFail cfg (sprintf "%s.vserr" testname) "%s --test:ContinueAfterParseFailure --vserrors %s --nologo --maxerrors:10000 -a -o:%s.dll" cfg.fsc_flags warnaserror testname sources + fscAppendErrExpectFail cfg (sprintf "%s.vserr" testname) "%s --test:ContinueAfterParseFailure --vserrors %s --nologo --nowarn:1182 --maxerrors:10000 -a -o:%s.dll" cfg.fsc_flags warnaserror testname sources let vbslDiff = fsdiff cfg (sprintf "%s.vserr" testname) VSBSLFILE