Stop NOTA0001 and NOTA0002 reporting files nobody can fix - #14
Merged
henrikottesorensen merged 1 commit intoAug 18, 2026
Conversation
Microsoft.NET.Test.Sdk contributes a source file of its own to @(Compile) - Microsoft.NET.Test.Sdk.Program.cs, the generated test entry point - and it carries a UTF-8 byte order mark. It lives in the read-only NuGet cache. So NOTA0002 fired on every test project that installed this package, naming a file the consumer did not write, cannot re-save, and which is restored again the moment it is touched. That is worse than a missing check. The only escape was NotaValidateSourceEncoding=false, which switches off NOTA0001 as well - so a rule against corruption was talking people into turning off the one guard against it. NotaAllowUtf8Bom=true would have kept NOTA0001, but silences the mark check everywhere rather than in the one place it is wrong. The task now skips anything under the NuGet package root or the intermediate output path. Both are the same idea: sources compiled into the project that the project does not own. Generated files under obj carry no mark today, and are included because they are rewritten on the next build, so a report on one is noise that cannot be acted on either. The roots are passed in as items rather than matched by wildcard - globbing the package cache to exclude it would read every file in it - and NuGetPackageRoot is only passed when it has a value, since an empty root is a prefix of every path and would skip the entire check. Not caught before because the verification project is not a test project and so never installed the SDK that carries the file. It does now, in the throwaway consumer verify-package.sh builds, referenced for what it drags in rather than anything it does - and the script asserts NOTA000x names no file under the cache. Confirmed against the unfixed targets, where it fails with the file named. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-on to #13.
NOTA0002fires on every test project that installsMicrosoft.NET.Test.Sdk, naming a file the consumer did not write and cannot fix.What happens
Microsoft.NET.Test.Sdkcontributes its generated test entry point to@(Compile), and that file carries a UTF-8 byte order mark:It lives in the read-only NuGet cache. It is shared by every project on the machine, and restored the moment it is touched. There is no re-saving it.
Why this is worse than a missing check
The only way to a clean build was
NotaValidateSourceEncoding=false— which switches offNOTA0001as well. So a rule written to catch corruption was talking people into disabling the only guard against it.NotaAllowUtf8Bom=truekeepsNOTA0001, but silences the mark check everywhere rather than in the one place it is wrong.The advice in the message made it worse: it points at
tools/de-bom.sh, which would have someone rewriting their NuGet cache.The change
The task skips anything under the NuGet package root or the intermediate output path — sources compiled into the project that the project does not own.
Two details that are deliberate:
Remove="$(NuGetPackageRoot)**"would glob the entire package cache on every build.NuGetPackageRootis only passed when it has a value. It is empty in some restore-less contexts, and an empty string is a prefix of every path — it would skip every file and check nothing, silently.objcarries no mark today. It is included because generated files are rewritten on the next build, so a report on one cannot be acted on either.Why the suite missed it
The verification project is not a test project, so it never installed the SDK that carries the file. Every check passed while every consuming test project warned.
verify-package.shnow referencesMicrosoft.NET.Test.Sdkin its throwaway consumer — for what it drags in, not anything it does — and asserts thatNOTA000xnames no file under the cache. Confirmed against the unfixed targets, where it fails:With the fix, all three pass:
Real violations still report — checked with a marked file and a Windows-1252 file in a consuming project,
NOTA0002andNOTA0001respectively.Release
Worth releasing promptly: as it stands, anyone on
2.2.2with a test project sees this, and the obvious reaction is to switch the encoding check off entirely.🤖 Generated with Claude Code