You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
KTSU0002 code fix duplicates the file header, adds an unused using and a CRLF line, so a ktsu-style file fails to build (IDE0005/IDE0055) after the fix #70
Sdk.Analyzers/AddInternalsVisibleToAttributeCodeFixProvider.cs (~L70-110) inserts [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(...)]. It has four problems:
It adds a top-level using System.Runtime.CompilerServices; even though the attribute is written fully qualified, so the using is dead (IDE0005).
It checks only compilationUnit.Usings for an existing using. The ktsu .editorconfig requires csharp_using_directive_placement = inside_namespace:error, so in a conforming file the usings live inside the namespace and are never seen.
It hard-codes SyntaxFactory.CarriageReturnLineFeed as trailing trivia (L83, L102), while the ktsu .editorconfig sets end_of_line = lf.
It copies the compilation unit's leading trivia (the copyright header) onto the new first token, but the original first token (namespace) keeps its own copy, so the header appears twice.
Failure scenario
The input is a typical ktsu file: a copyright header, then namespace ktsu.Service;, then using System.Text; inside the namespace.
The provider was run from the built DLL on an AdhocWorkspace document at bafee81, and the output compiled with the repo's .editorconfig, EnforceCodeStyleInBuild=true and AnalysisLevel 10.0-all:
The header appears twice: once above the new using, again above namespace.
The attribute line ends in CRLF inside an LF file.
The build fails with error IDE0005 (unnecessary using) and error IDE0055 (formatting). The original file builds clean.
So accepting the light-bulb fix in a ktsu repo turns a warning into build errors. There is no code-fix test for KTSU0002 under test/, which is how this went unnoticed.
Suggested fix
Don't add a using: the fully-qualified attribute doesn't need one. Alternatively, write the short name and add the using inside the namespace when the file uses that placement.
Don't duplicate leading trivia. Insert the attribute after the header, or move the trivia rather than copy it.
Take the end-of-line from the document's existing trivia or its FormattingOptions.NewLine, rather than hard-coding CRLF.
Acceptance: add a code-fix test that applies the fix to a file with a header and an in-namespace using, then asserts a single header, no added using, LF endings, and a clean compile with no IDE0005/IDE0055.
Priority: Medium. Accepting the KTSU0002 light-bulb fix in any conforming ktsu file turns a warning into IDE0005/IDE0055 build errors and duplicates the copyright header. The damage is immediate and visible, so it won't ship silently, but the fix can't be used as offered in the org's own repositories.
Area / suggested assignment:Sdk.Analyzers, AddInternalsVisibleToAttributeCodeFixProvider. The missing piece is a code-fix test for KTSU0002 under test/.
Activity
matt-edmondson commentedon Sep 30, 2026
Triage
IDE0005/IDE0055build errors and duplicates the copyright header. The damage is immediate and visible, so it won't ship silently, but the fix can't be used as offered in the org's own repositories.Sdk.Analyzers,AddInternalsVisibleToAttributeCodeFixProvider. The missing piece is a code-fix test for KTSU0002 undertest/..editorconfig. One shared "apply the fix, then compile with the org's.editorconfig" test helper would cover all three.Generated by Claude Code