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
SA1121 currently reports every use of an alias to a built-in type, making it difficult to retain a deliberate alias while applying the rule elsewhere. ⚑ Diagnostics now point to the built-in type in the alias declaration, and alias uses are left unreported. In C# 12 and later, the existing fix rewrites the alias target; before C# 12, the fix is not offered because the language does not allow a built-in keyword as an alias target.
The new regression test fails on master with two diagnostics at alias uses instead of the expected single diagnostic at the declaration. C# 6 and C# 15 SA1121 suites pass; C# 12 targeted alias-fix tests pass. The analyzer adds one alias-symbol lookup only after a candidate resolves to a built-in type, with no new registrations or tree walks.
Updated the English, Czech, and Russian rule pages and added guidance to keep existing translated rule pages synchronized with visible behavior changes. Cultures without an existing page continue to use English fallback.
Report built-in type aliases on their declarations instead of each use. Update code-fix coverage, rule documentation, and the bug-fixing guidance for translated pages.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Honor allowBuiltInTypeAliases for non-misleading named aliases while continuing to report direct built-in type references and misleading aliases. Update configuration docs, assert the pre-C# 12 code fix is unavailable, and keep localized documentation guidance accurate.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Skip pre-C# 12 alias targets during Fix All and update inherited C# 10 expectations. Add a mixed Fix All regression test to ensure valid type references are fixed while unsupported alias targets remain unchanged.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This adds a second semantic-model lookup for every candidate that resolves to a built-in type, even when the syntax tree contains no aliases. The analyzer performance rules require unaffected code to avoid new semantic work, and UsingAliasCache can prove that GetAliasInfo cannot succeed. Gate the lookup on that cache so ordinary System.Int32 diagnostics do not pay for alias resolution.
Allow fixes for built-ins nested in generic alias arguments
documentation/SA1121.md:15
The pre-C# 12 statement is too broad: TestUsingNameChangeGenericAsync still reports and fixes System.Int32 inside using IntAction = Action<System.Int32>;, and IsUnsupportedUsingAliasTarget explicitly exempts type arguments. Clarify that only a direct alias target has no fix before C# 12; nested generic type arguments remain fixable.
Clarify generic alias argument fixes in Czech documentation
documentation/cs-cz/SA1121.md:15
This has the same overgeneralization as the English page: before C# 12, a direct alias target cannot be fixed, but built-in names nested in generic type arguments are still reported and fixed. Add that distinction to keep the Czech page aligned with the implemented behavior.
Clarify generic alias argument fixes in Russian documentation
documentation/ru-ru/SA1121.md:15
This has the same overgeneralization as the English page: before C# 12, a direct alias target cannot be fixed, but built-in names nested in generic type arguments are still reported and fixed. Add that distinction to keep the Russian page aligned with the implemented behavior.
❌ Patch coverage is 93.30144% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.63%. Comparing base (52dff91) to head (5edf756). ⚠️ Report is 8 commits behind head on master.
With the default setting, line 220 has already asked UsingAliasCache whether any alias can apply, yet this still performs GetAliasInfo for every resolved SA1121 candidate when that cached answer is false. This adds an avoidable semantic-model query to ordinary System.Int32 references. Reuse the cache result to retain the previous cost for files without aliases, while preserving the current configured-setting path.
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
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.
Fixes #3640
SA1121 currently reports every use of an alias to a built-in type, making it difficult to retain a deliberate alias while applying the rule elsewhere. ⚑ Diagnostics now point to the built-in type in the alias declaration, and alias uses are left unreported. In C# 12 and later, the existing fix rewrites the alias target; before C# 12, the fix is not offered because the language does not allow a built-in keyword as an alias target.
The new regression test fails on master with two diagnostics at alias uses instead of the expected single diagnostic at the declaration. C# 6 and C# 15 SA1121 suites pass; C# 12 targeted alias-fix tests pass. The analyzer adds one alias-symbol lookup only after a candidate resolves to a built-in type, with no new registrations or tree walks.
Updated the English, Czech, and Russian rule pages and added guidance to keep existing translated rule pages synchronized with visible behavior changes. Cultures without an existing page continue to use English fallback.