Skip to content

Standardize project settings to opt-out from 'unused bindings' detection across the repo #18431

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions FSharp.Profiles.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
<DefineConstants>BUILDING_WITH_LKG;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.fsproj' and $(TolerateUnusedBindings) != 'true'">
<WarningsAsErrors>1182;$(WarningsAsErrors)</WarningsAsErrors>
<WarnOn>1182;$(WarnOn)</WarnOn>
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.fsproj' and $(TolerateUnusedBindings) == 'true'">
<WarningsNotAsErrors>1182;$(WarningsNotAsErrors)</WarningsNotAsErrors>
<NoWarn>1182;$(NoWarn)</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' != 'Proto' and '$(BUILDING_USING_DOTNET)' != 'true' and '$(MSBuildProjectExtension)' == '.fsproj'"> <!-- VB.NET does not understand "preview". It only knows "old","older" and "boomer" :-)) (jk)-->
<LangVersion>preview</LangVersion>
</PropertyGroup>
Expand Down
3 changes: 1 addition & 2 deletions FSharpBuild.Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
<SymStoreDirectory>$(ArtifactsDir)\SymStore</SymStoreDirectory>
<ProtoOutputPath>$(ArtifactsDir)\Bootstrap</ProtoOutputPath>
<ValueTupleImplicitPackageVersion>4.4.0</ValueTupleImplicitPackageVersion>
<WarnOn>$(WarnOn);1182</WarnOn>
<WarningsAsErrors>1182;0025;$(WarningsAsErrors)</WarningsAsErrors>
<WarningsAsErrors>0025;$(WarningsAsErrors)</WarningsAsErrors>
<OtherFlags>$(OtherFlags) --nowarn:3384</OtherFlags>
<OtherFlags>$(OtherFlags) --times --nowarn:75</OtherFlags>
<OtherFlags Condition="$(AdditionalFscCmdFlags) != ''">$(OtherFlags) $(AdditionalFscCmdFlags)</OtherFlags>
Expand Down
4 changes: 2 additions & 2 deletions buildtools/fslex/fslex.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFramework>$(FSharpNetCoreProductTargetFramework)</TargetFramework>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<RollForward Condition="'$(BUILDING_USING_DOTNET)' == 'true'">LatestMajor</RollForward>
<NoWarn>$(NoWarn);64;1204;1182</NoWarn> <!--Temporary fix for sourcebuild -->
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
<NoWarn>$(NoWarn);64;1204</NoWarn> <!--Temporary fix for sourcebuild -->
<TolerateUnusedBindings>true</TolerateUnusedBindings>
</PropertyGroup>

<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions buildtools/fsyacc/fsyacc.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFramework>$(FSharpNetCoreProductTargetFramework)</TargetFramework>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<RollForward Condition="'$(BUILDING_USING_DOTNET)' == 'true'">LatestMajor</RollForward>
<NoWarn>$(NoWarn);64;1204;1182</NoWarn> <!--Temporary fix for sourcebuild -->
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
<NoWarn>$(NoWarn);64;1204</NoWarn> <!--Temporary fix for sourcebuild -->
<TolerateUnusedBindings>true</TolerateUnusedBindings>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/FSharp.Core/FSharp.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
<DefineConstants>$(DefineConstants);FSHARP_CORE</DefineConstants>
<!-- 3218: ArgumentsInSigAndImplMismatch -->
<OtherFlags>$(OtherFlags) --warnon:3218</OtherFlags>
<!-- 1182: Unused variables -->
<OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags>
<!-- 3390: xmlDocBadlyFormed -->
<OtherFlags>$(OtherFlags) --warnon:3390</OtherFlags>
<!-- 3520: invalidXmlDocPosition -->
Expand Down
1 change: 0 additions & 1 deletion src/fsi/fsi.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<Configurations>Debug;Release;Proto</Configurations>
<NoWarn>$(NoWarn);44</NoWarn> <!-- Obsolete -->
<AllowCrossTargeting>true</AllowCrossTargeting>
<OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags>
<Win32Resource>$(MSBuildThisFileDirectory)fsi.res</Win32Resource>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<ExcludeFromSourceOnlyBuild>true</ExcludeFromSourceOnlyBuild>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags>
<NoWarn>$(NoWarn);FS0988</NoWarn> <!-- "program does nothing" warning -->
<DefineConstants Condition="'$(Configuration)'=='release'">$(DefineConstants);RELEASE</DefineConstants>
<DefineConstants Condition="'$(Configuration)'=='debug'">$(DefineConstants);DEBUG</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<TargetFrameworks>net472;$(FSharpNetCoreProductTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Unix' or '$(BUILDING_USING_DOTNET)' == 'true'">$(FSharpNetCoreProductTargetFramework)</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);1182</NoWarn> <!-- suppress warning for unused values in FSharp.Compiler.Service.Tests tests, very often checker results are needed, but not used -->
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
<TolerateUnusedBindings>true</TolerateUnusedBindings>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<UnitTestType>xunit</UnitTestType>
</PropertyGroup>
Expand Down
3 changes: 1 addition & 2 deletions tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<PackageVersion>$(FSCoreUnitTestsPackageVersion)</PackageVersion>
<PreRelease>true</PreRelease>
<LangVersion>preview</LangVersion>
<NoWarn>$(NoWarn);1182</NoWarn> <!-- suppress warning for unused values in FSharp.Core tests, there are way too many of edge case scenarios tested -->
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
<TolerateUnusedBindings>true</TolerateUnusedBindings>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<UnitTestType>xunit</UnitTestType>
<IsTestProject>true</IsTestProject>
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Tailcalls>false</Tailcalls>
<UnitTestType>xunit</UnitTestType>
<IsTestProject>true</IsTestProject>
<OtherFlags>$(OtherFlags) --warnon:1182 --realsig-</OtherFlags>
<OtherFlags>$(OtherFlags) --realsig-</OtherFlags>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!--Extra xUnit customizations, not required for the test suite to work, but can speed up local test runs and help with debugging.-->
<DefineConstants>XUNIT_EXTRAS</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion tests/fsharp/FSharpSuite.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OtherFlags>$(OtherFlags) --warnon:1182 --langversion:preview</OtherFlags>
<OtherFlags>$(OtherFlags) --langversion:preview</OtherFlags>
<UnitTestType>xunit</UnitTestType>
<NoWarn>3186</NoWarn>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NoWarn>$(NoWarn);75</NoWarn>
<NoWarn>$(NoWarn);44</NoWarn><!-- warning about Roslyn API only for F# and TypeScript -->
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<OtherFlags>$(OtherFlags) --warnon:1182 --subsystemversion:6.00</OtherFlags>
<OtherFlags>$(OtherFlags) --subsystemversion:6.00</OtherFlags>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NoWarn>$(NoWarn);75</NoWarn>
<NoWarn>$(NoWarn);44</NoWarn><!-- warning about Roslyn API only for F# and TypeScript -->
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<OtherFlags>$(OtherFlags) --warnon:1182 --subsystemversion:6.00</OtherFlags>
<OtherFlags>$(OtherFlags) --subsystemversion:6.00</OtherFlags>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyName>FSharp.ProjectSystem.FSharp</AssemblyName>
<NoWarn>$(NoWarn);52;62;75</NoWarn>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<OtherFlags>$(OtherFlags) --warnon:1182 --subsystemversion:6.00</OtherFlags>
<OtherFlags>$(OtherFlags) --subsystemversion:6.00</OtherFlags>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>

Expand Down
5 changes: 3 additions & 2 deletions vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<NoWarn>$(NoWarn);47;75;1182</NoWarn><!-- 1182 - unused bindings, too many of them here -->
<NoWarn>$(NoWarn);47;75</NoWarn>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<OtherFlags>$(OtherFlags) --subsystemversion:6.00 --warnaserror-:1182</OtherFlags>
<OtherFlags>$(OtherFlags) --subsystemversion:6.00</OtherFlags>
<TolerateUnusedBindings>true</TolerateUnusedBindings>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<GenerateProgramFile>false</GenerateProgramFile>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<NoWarn>$(NoWarn);FS3511</NoWarn> <!-- This state machine is not statically compilable. -->
<OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<OtherFlags>$(OtherFlags) --nowarn:3390 --nowarn:3218 --nowarn:1182 --warnaserror-:1182</OtherFlags>
<TolerateUnusedBindings>true</TolerateUnusedBindings>
<OtherFlags>$(OtherFlags) --nowarn:3390 --nowarn:3218</OtherFlags>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<NoWarn>$(NoWarn);44;45;47;52;58;75;1182</NoWarn><!-- 1182 - unused bindings, too many of them here -->
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
<NoWarn>$(NoWarn);44;45;47;52;58;75</NoWarn>
<TolerateUnusedBindings>true</TolerateUnusedBindings>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<UsePackageTargetFallbackHack>true</UsePackageTargetFallbackHack>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
Expand Down
4 changes: 2 additions & 2 deletions vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<TargetFramework>net472</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<OutputType>Library</OutputType>
<NoWarn>$(NoWarn);44;58;75;3005;1182</NoWarn><!-- 1182 - unused bindings, too many of them here -->
<OtherFlags>$(OtherFlags) --warnaserror-:1182</OtherFlags>
<NoWarn>$(NoWarn);44;58;75;3005</NoWarn>
<TolerateUnusedBindings>true</TolerateUnusedBindings>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<UsePackageTargetFallbackHack>true</UsePackageTargetFallbackHack>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down