Changing warning CS8002 to an error still results in binary being outputted despite error
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**: 4.11.0-2.24304.1 (e68227ea)
**Steps to Reproduce**:
1. Clone https://github.com/jasonmalinowski/StrongNameSigningProblem
2. Run dotnet build. See it errors out.
3. Run dotnet build again. Observe it succeeds.
**Expected Behavior**: Build is stable.
**Actual Behavior**: It's not stable.
I debugged into this a bit and here's what's happening: CS8002 is normally a warning. If it's changed to be an error the compiler emits the error, _but still writes out the assembly for the build output._ Hence the next time (or two) you build. The build will succeeded since MSBuild considers the CoreCompile target to be up to date.
One thing I noticed is this the diagnostic is only emitted if you actually use a type from the library -- I'm guessing what's happening here is during emit we do a final walk through the list of assemblies used, and at that point we're flagging this as an error. But that never aborts the build anymore since it wasn't expected to have an error like this so late.
Contributor guide
Research direction
Clone the linked StrongNameSigningProblem repository and run dotnet build twice to reproduce the unstable result. Start by tracing the compiler emit path where CS8002 is reported and the MSBuild CoreCompile target's up-to-date decision. Done means treating CS8002 as an error prevents the assembly from being emitted and repeated builds remain stable, with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100