Repository navigation
SA1316: always check explicit element names in tuple expressions - #4202
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4202 +/- ##
=======================================
Coverage 97.54% 97.54%
=======================================
Files 1277 1277
Lines 134157 134193 +36
Branches 4291 4292 +1
=======================================
+ Hits 130863 130901 +38
+ Misses 2152 2151 -1
+ Partials 1142 1141 -1 🚀 New features to boost your workflow:
|
AArnott
marked this pull request as ready for review
October 9, 2026 15:38
bjornhellander
approved these changes
Oct 9, 2026
This was referenced Nov 11, 2026
Bump StyleCop.Analyzers from 1.2.0-beta.556 to 1.3.180
microsoftgraph/aspnetcore-webhooks-sample#436
Open
Open
This was referenced Nov 13, 2026
Open
Open
Merged
Open
Bump StyleCop.Analyzers from 1.2.0-beta.556 to 1.3.180
microsoftgraph/msgraph-sample-aspnet-core#256
Open
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.
Fixes #3947
SA1316 skipped tuple expressions entirely unless
includeInferredTupleElementNameswastrue. So an explicitly named element likevar tuple = (x: 1, Y: 2);was never checked by default, even though the setting is documented as covering only inferred names. With the setting on, explicit names were reported at the value expression and had no code fix.HandleTupleExpressionActionnow:NameColonnames (C# 7.0+), reporting on the name with the existing rename code fixincludeInferredTupleElementNamesis on (C# 7.1+), as beforeBehavior change: projects with mis-cased explicit names in tuple expressions will get new SA1316 warnings by default. I think this matches the documented intent of the setting, but it's the one part of this PR worth a conscious OK. Perf: the tuple-expression callback was already registered. It now loops over the arguments by default and does no semantic-model work for these names, so the extra cost is negligible.
Tests (C# 7 project, inherited by later versions):
ValidateImproperCasedExplicitTupleExpressionElementNamesAsyncruns all 7 settings variants and checks diagnostics on the names plus the code fix (including comments around the name and a_element). All 7 fail on master. Existing SA1316 tests pass unchanged.Docs:
SA1316.mddescribes the explicit/inferred split, and theincludeInferredTupleElementNamesrow inConfiguration.mdnotes that explicit names are always analyzed.