From f487d459f4856b5966706aec73b9c815ab6f51bc Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 24 Apr 2025 18:45:23 +0200 Subject: [PATCH 1/2] Standardize project settings to opt-out from 'unused bindings' detection across the repo (#18431) --- FSharp.Profiles.props | 10 ++++++++++ FSharpBuild.Directory.Build.props | 3 +-- buildtools/fslex/fslex.fsproj | 4 ++-- buildtools/fsyacc/fsyacc.fsproj | 4 ++-- src/FSharp.Core/FSharp.Core.fsproj | 2 -- src/fsi/fsi.targets | 1 - .../FSharp.Compiler.ComponentTests.fsproj | 1 - .../FSharp.Compiler.Service.Tests.fsproj | 3 +-- .../FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj | 3 +-- .../FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj | 2 +- tests/fsharp/FSharpSuite.Tests.fsproj | 2 +- vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj | 2 +- .../FSharp.LanguageService.fsproj | 2 +- .../FSharp.ProjectSystem.FSharp.fsproj | 2 +- vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj | 5 +++-- .../FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj | 1 - .../DummyProviderForLanguageServiceTesting.fsproj | 3 ++- vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj | 4 ++-- .../tests/UnitTests/VisualFSharp.UnitTests.fsproj | 4 ++-- 19 files changed, 31 insertions(+), 27 deletions(-) diff --git a/FSharp.Profiles.props b/FSharp.Profiles.props index 35a907b2e6..da4a7147c0 100644 --- a/FSharp.Profiles.props +++ b/FSharp.Profiles.props @@ -6,6 +6,16 @@ BUILDING_WITH_LKG;$(DefineConstants) + + 1182;$(WarningsAsErrors) + 1182;$(WarnOn) + + + + 1182;$(WarningsNotAsErrors) + 1182;$(NoWarn) + + preview diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props index 33772456e2..f9f9128feb 100644 --- a/FSharpBuild.Directory.Build.props +++ b/FSharpBuild.Directory.Build.props @@ -27,8 +27,7 @@ $(ArtifactsDir)\SymStore $(ArtifactsDir)\Bootstrap 4.4.0 - $(WarnOn);1182 - 1182;0025;$(WarningsAsErrors) + 0025;$(WarningsAsErrors) $(OtherFlags) --nowarn:3384 $(OtherFlags) --times --nowarn:75 $(OtherFlags) $(AdditionalFscCmdFlags) diff --git a/buildtools/fslex/fslex.fsproj b/buildtools/fslex/fslex.fsproj index 684fecb11d..3b8aafb532 100644 --- a/buildtools/fslex/fslex.fsproj +++ b/buildtools/fslex/fslex.fsproj @@ -5,8 +5,8 @@ $(FSharpNetCoreProductTargetFramework) true LatestMajor - $(NoWarn);64;1204;1182 - $(OtherFlags) --warnaserror-:1182 + $(NoWarn);64;1204 + true diff --git a/buildtools/fsyacc/fsyacc.fsproj b/buildtools/fsyacc/fsyacc.fsproj index 38280006de..ba57de811c 100644 --- a/buildtools/fsyacc/fsyacc.fsproj +++ b/buildtools/fsyacc/fsyacc.fsproj @@ -5,8 +5,8 @@ $(FSharpNetCoreProductTargetFramework) true LatestMajor - $(NoWarn);64;1204;1182 - $(OtherFlags) --warnaserror-:1182 + $(NoWarn);64;1204 + true diff --git a/src/FSharp.Core/FSharp.Core.fsproj b/src/FSharp.Core/FSharp.Core.fsproj index b0abd5048b..a1dddc32c7 100644 --- a/src/FSharp.Core/FSharp.Core.fsproj +++ b/src/FSharp.Core/FSharp.Core.fsproj @@ -13,8 +13,6 @@ $(DefineConstants);FSHARP_CORE $(OtherFlags) --warnon:3218 - - $(OtherFlags) --warnon:1182 $(OtherFlags) --warnon:3390 diff --git a/src/fsi/fsi.targets b/src/fsi/fsi.targets index 1fb29b4bff..bbdcba8f74 100644 --- a/src/fsi/fsi.targets +++ b/src/fsi/fsi.targets @@ -7,7 +7,6 @@ Debug;Release;Proto $(NoWarn);44 true - $(OtherFlags) --warnon:1182 $(MSBuildThisFileDirectory)fsi.res diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 60b867c781..49b459e279 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -13,7 +13,6 @@ true false false - $(OtherFlags) --warnon:1182 $(NoWarn);FS0988 $(DefineConstants);RELEASE $(DefineConstants);DEBUG 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 d9db689952..967f5aacfc 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -5,8 +5,7 @@ net472;$(FSharpNetCoreProductTargetFramework) $(FSharpNetCoreProductTargetFramework) true - $(NoWarn);1182 - $(OtherFlags) --warnaserror-:1182 + true true xunit diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj index d4dbfdd434..b51337c353 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj +++ b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj @@ -12,8 +12,7 @@ $(FSCoreUnitTestsPackageVersion) true preview - $(NoWarn);1182 - $(OtherFlags) --warnaserror-:1182 + true true xunit true diff --git a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj index b98f57603c..7788cbe652 100644 --- a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj +++ b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj @@ -12,7 +12,7 @@ false xunit true - $(OtherFlags) --warnon:1182 --realsig- + $(OtherFlags) --realsig- true XUNIT_EXTRAS diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 32ff617c0d..dfc4840d0c 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -11,7 +11,7 @@ true false false - $(OtherFlags) --warnon:1182 --langversion:preview + $(OtherFlags) --langversion:preview xunit 3186 diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj index 5fedad089d..fbafe3bd83 100644 --- a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj +++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj @@ -7,7 +7,7 @@ $(NoWarn);75 $(NoWarn);44 true - $(OtherFlags) --warnon:1182 --subsystemversion:6.00 + $(OtherFlags) --subsystemversion:6.00 false diff --git a/vsintegration/src/FSharp.LanguageService/FSharp.LanguageService.fsproj b/vsintegration/src/FSharp.LanguageService/FSharp.LanguageService.fsproj index 9c82f79ec9..9968c121f7 100644 --- a/vsintegration/src/FSharp.LanguageService/FSharp.LanguageService.fsproj +++ b/vsintegration/src/FSharp.LanguageService/FSharp.LanguageService.fsproj @@ -7,7 +7,7 @@ $(NoWarn);75 $(NoWarn);44 true - $(OtherFlags) --warnon:1182 --subsystemversion:6.00 + $(OtherFlags) --subsystemversion:6.00 false diff --git a/vsintegration/src/FSharp.ProjectSystem.FSharp/FSharp.ProjectSystem.FSharp.fsproj b/vsintegration/src/FSharp.ProjectSystem.FSharp/FSharp.ProjectSystem.FSharp.fsproj index b472ed00da..e6a2e4abe8 100644 --- a/vsintegration/src/FSharp.ProjectSystem.FSharp/FSharp.ProjectSystem.FSharp.fsproj +++ b/vsintegration/src/FSharp.ProjectSystem.FSharp/FSharp.ProjectSystem.FSharp.fsproj @@ -7,7 +7,7 @@ FSharp.ProjectSystem.FSharp $(NoWarn);52;62;75 true - $(OtherFlags) --warnon:1182 --subsystemversion:6.00 + $(OtherFlags) --subsystemversion:6.00 false diff --git a/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj b/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj index cc40ac675c..43e8352845 100644 --- a/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj +++ b/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj @@ -4,9 +4,10 @@ Library - $(NoWarn);47;75;1182 + $(NoWarn);47;75 true - $(OtherFlags) --subsystemversion:6.00 --warnaserror-:1182 + $(OtherFlags) --subsystemversion:6.00 + true false diff --git a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj index 738a3e1323..2a760da0f5 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj +++ b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj @@ -7,7 +7,6 @@ false true $(NoWarn);FS3511 - $(OtherFlags) --warnon:1182 true diff --git a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj index faca7cb840..c94be43a0b 100644 --- a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj +++ b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fsproj @@ -5,7 +5,8 @@ net472 true - $(OtherFlags) --nowarn:3390 --nowarn:3218 --nowarn:1182 --warnaserror-:1182 + true + $(OtherFlags) --nowarn:3390 --nowarn:3218 diff --git a/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj b/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj index 7f24444a6e..e1e657a651 100644 --- a/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj +++ b/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj @@ -4,8 +4,8 @@ Library - $(NoWarn);44;45;47;52;58;75;1182 - $(OtherFlags) --warnaserror-:1182 + $(NoWarn);44;45;47;52;58;75 + true true true false diff --git a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj index 77c7d12e01..30a871ad28 100644 --- a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj +++ b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj @@ -6,8 +6,8 @@ net472 x86 Library - $(NoWarn);44;58;75;3005;1182 - $(OtherFlags) --warnaserror-:1182 + $(NoWarn);44;58;75;3005 + true true true true From eb00cdba2dc81a266fc6854a05f25cb0479a875d Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Tue, 1 Apr 2025 20:43:06 -0700 Subject: [PATCH 2/2] Fix PM --- src/Compiler/Driver/ScriptClosure.fs | 6 ++++-- vsintegration/src/FSharp.Editor/Common/Extensions.fs | 2 +- .../LanguageService/FSharpProjectOptionsManager.fs | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Compiler/Driver/ScriptClosure.fs b/src/Compiler/Driver/ScriptClosure.fs index b97b11a805..b45049627c 100644 --- a/src/Compiler/Driver/ScriptClosure.fs +++ b/src/Compiler/Driver/ScriptClosure.fs @@ -327,11 +327,13 @@ module ScriptPreprocessClosure = for kv in tcConfig.packageManagerLines do let packageManagerKey, packageManagerLines = kv.Key, kv.Value - match packageManagerLines |> List.filter (not << isEditorCursorInPackageLines) with + let packageManagerLines = + packageManagerLines |> List.filter (not << isEditorCursorInPackageLines) + + match packageManagerLines with | [] -> () | packageManagerLine :: _ -> let m = packageManagerLine.Range - let packageManagerLines = packageManagerLines yield! processPackageManagerLines m packageManagerLines scriptName packageManagerKey ] diff --git a/vsintegration/src/FSharp.Editor/Common/Extensions.fs b/vsintegration/src/FSharp.Editor/Common/Extensions.fs index 2ed87e5ec8..ff17ac4366 100644 --- a/vsintegration/src/FSharp.Editor/Common/Extensions.fs +++ b/vsintegration/src/FSharp.Editor/Common/Extensions.fs @@ -139,7 +139,7 @@ type Document with | hr, _, _, docData, _ when ErrorHandler.Succeeded(hr) && docData <> IntPtr.Zero -> match Marshal.GetObjectForIUnknown docData with | :? IVsTextBuffer as ivsTextBuffer -> - match textManager.GetActiveView(1, ivsTextBuffer) with + match textManager.GetActiveView(0, ivsTextBuffer) with | hr, vsTextView when ErrorHandler.Succeeded(hr) -> Some vsTextView | _ -> None | _ -> None diff --git a/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs b/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs index edf31e68a5..d61ba717b4 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs @@ -200,13 +200,16 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) = cancellableTask { let! ct = CancellableTask.getCancellationToken () let! fileStamp = document.GetTextVersionAsync(ct) + let textViewAndCaret () : (IVsTextView * Position) option = document.TryGetTextViewAndCaretPos() match singleFileCache.TryGetValue(document.Id) with | false, _ -> let! sourceText = document.GetTextAsync(ct) let getProjectOptionsFromScript textViewAndCaret = - match textViewAndCaret with + let caret = textViewAndCaret () + + match caret with | None -> checker.GetProjectOptionsFromScript( document.FilePath, @@ -226,7 +229,6 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) = userOpName = userOpName ) - let textViewAndCaret = document.TryGetTextViewAndCaretPos() let! scriptProjectOptions, _ = getProjectOptionsFromScript textViewAndCaret let project = document.Project @@ -266,7 +268,7 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) = let updateProjectOptions () = async { - let! scriptProjectOptions, _ = getProjectOptionsFromScript None + let! scriptProjectOptions, _ = getProjectOptionsFromScript textViewAndCaret checker.NotifyFileChanged(document.FilePath, scriptProjectOptions) |> Async.Start @@ -281,7 +283,7 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) = match value with | projectId, fileStamp, parsingOptions, projectOptions, _ -> let subscription = - match textViewAndCaret with + match textViewAndCaret () with | Some(textView, _) -> subscribeToTextViewEvents (textView, (Some onChangeCaretHandler), (Some onKillFocus), (Some onSetFocus)) | None -> None