Repository navigation
Conversation
It should be useful to catch warnings early at CI time, while leaving them live in Debug mode (in case some developer is debugging something locally, we don't want warnings to get in the way in that case).
Updated the dependencies to resolve the security vulnerabilities:
1. In paket.dependencies under group Build:
- Pinned Microsoft.NET.StringTools ~> 17.11.48 to align with the existing
Microsoft.Build 17.11.48 packages and avoid pulling in newer versions
targeting .NET 11+.
- Added version constraints to resolve the security advisories:
- NuGet.Packaging >= 7.0.3 (fixes GHSA-g4vj-cjjj-v7hg)
- NuGet.Protocol >= 7.0.3 (fixes GHSA-g4vj-cjjj-v7hg)
- System.Security.Cryptography.Pkcs >= 10.0.14 (fixes GHSA-2fmv-rv2c-59x7
and GHSA-846f-f764-76mx)
2. Updated paket.lock with the resolved patched package versions.
The (warnings as) errors were:
```
Run dotnet run --project build/build.fsproj
/home/runner/work/FSharpx.Collections/FSharpx.Collections/build/build.fsproj : error NU1901: Warning As Error: Package 'NuGet.Packaging' 7.0.1 has a known low severity vulnerability, GHSA-g4vj-cjjj-v7hg
/home/runner/work/FSharpx.Collections/FSharpx.Collections/build/build.fsproj : error NU1901: Warning As Error: Package 'NuGet.Protocol' 7.0.1 has a known low severity vulnerability, GHSA-g4vj-cjjj-v7hg
/home/runner/work/FSharpx.Collections/FSharpx.Collections/build/build.fsproj : error NU1902: Warning As Error: Package 'System.Security.Cryptography.Pkcs' 10.0.1 has a known moderate severity vulnerability, GHSA-2fmv-rv2c-59x7
/home/runner/work/FSharpx.Collections/FSharpx.Collections/build/build.fsproj : error NU1903: Warning As Error: Package 'System.Security.Cryptography.Pkcs' 10.0.1 has a known high severity vulnerability, GHSA-846f-f764-76mx
The build failed. Fix the build errors and run again.
Error: Process completed with exit code 1.
```
Example of one occurrence: ``` src/FSharpx.Collections/LazyList.fs(169,22): warning FS3218: The argument names in the signature 'source' and implementation 's1' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. ```
After we enabled TreatWarningsAsErrors in Directory.Build.props
then we were getting this warning in the Fable tests:
```
Error: tests/fable/FSharpx.Collections.Tests/LazyList.test.fs(35,55): error FS0040: This
and other recursive references to the object(s) being defined will be checked for
initialization-soundness at runtime through the use of a delayed reference. This is
because you are defining one or more recursive objects, rather than recursive functions.
This warning may be suppressed by using '#nowarn "40"' or '--nowarn:40'.
[/home/runner/work/FSharpx.Collections/FSharpx.Collections/tests/fable/FSharpx.Collections.Tests/FSharpx.Collections.Tests.fsproj]
0 Warning(s)
1 Error(s)
```
Not sure how to fix it, but honestly maybe it's not worth it,
since these are just tests, so let's override WarningsAsErrors
here to keep it disabled as it was before.
By updating this then we already fix security vulnerabilities from dependencies without the need to pin.
db517f0 to
cb3416b
Compare
|
Great idea! Reviewing |
| FSharp.Core (>= 4.3.4) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net461)) (&& (== netstandard2.0) (>= netcoreapp2.0)) | ||
| System.Collections.Immutable (>= 1.4) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net461)) (&& (== netstandard2.0) (>= netcoreapp2.0)) | ||
|
|
||
| GROUP Build |
There was a problem hiding this comment.
Nice, I see that we are not changing the deps of the library itself, only stuff used in the build pipeline.
There was a problem hiding this comment.
🟡 Changes recommended
The warnings-as-errors policy unintentionally applies to default Debug builds, risking CI and local build failures, while failing to cover either shipped library.
2 open issues
What changed in this PR
Introduces a warnings-as-errors policy intended to catch issues in CI while preserving non-failing warnings in Debug builds.
Changes:
- Adds conditional warning enforcement, with an explicit Fable test-project exemption.
- Aligns
LazyListimplementation parameter names and related exception text with existing signatures. - Updates NuGet tooling and cryptography dependencies in the build-tooling dependency group.
| File | Description |
|---|---|
tests/fable/FSharpx.Collections.Tests/FSharpx.Collections.Tests.fsproj |
Exempts Fable tests from warnings-as-errors. |
src/FSharpx.Collections/LazyList.fs |
Aligns parameter names with signatures to resolve warnings. |
paket.lock |
Updates build-tooling dependencies to address reported vulnerabilities. |
Directory.Build.props |
Adds the conditional warnings-as-errors policy. |
Review effort: Balanced
| @@ -0,0 +1,5 @@ | |||
| <Project> | |||
| <PropertyGroup Condition=" '$(Configuration)' != 'Debug' "> | |||
There was a problem hiding this comment.
Really, Copilot?
I will test it locally and comment here on results:
- VS build in debug and release
- cli
dotnetbuild with specified configuration and without both debug and release - Fake builds
There was a problem hiding this comment.
Confirmed: when Configuration is omitted, the condition runs before the SDK sets its Debug default. The final properties are Configuration=Debug and TreatWarningsAsErrors=true; explicitly passing Debug gives false.
The suggestion fixes that, let's commit it.
There was a problem hiding this comment.
@gdziadkiewicz Wouldn't committing this change mean that the final binaries submitted to nuget have Configuration=Debug instead of Configuration=Release?
There was a problem hiding this comment.
No, the suggested default would apply only when Configuration is not supplied.
The FAKE script defaults the build configuration to Release, allows it to be overridden by the configuration environment variable, and passes the resulting value explicitly to the solution build. The NuGet targets then use Paket to pack.
The unqualified dotnet run --project build/build.fsproj builds the FAKE driver in Debug by default. That is separate from the Release configuration the driver passes to the solution build. Same for dotnet build calls for single projects.
| @@ -0,0 +1,5 @@ | |||
| <Project> | |||
| <PropertyGroup Condition=" '$(Configuration)' != 'Debug' "> | |||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | |||
There was a problem hiding this comment.
I will check if this is true
There was a problem hiding this comment.
This also turned out to be true, let's import the policy from src/Directory.Build.props with
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
If that were the case, why did CI fail at the first commit |
The CI failure was in I made a demonstration branch based on this PR. It reintroduces one LazyList parameter-name mismatch. Please see here that the parameter mismatch is a warning, not error despite release config being used https://github.com/fsprojects/FSharpx.Collections/actions/runs/43323472080/job/131549882908 |



It should be useful* to catch warnings early at CI time, while leaving them live in Debug mode (in case some developer is debugging something locally, we don't want warnings to get in the way in that case).
* Especially because the build is right now (before this PR is/was merged) reporting security vulnerabilities in some nuget dependencies (see each commit msg independently for more details).