Add tests for code paths not covered by the test suite - #1527
Merged
Merged
Conversation
Cover the branches found with code coverage in MA0003, MA0005, MA0011, MA0015, MA0043, MA0076, MA0110, MA0151, MA0192, MA0193 and MA0194. MinimumNumberOfParameters_2 did not exercise the option, as its argument is never reported, so it now uses a boolean literal.
meziantou
enabled auto-merge (squash)
September 15, 2026 15:28
This was referenced Sep 18, 2026
Closed
Closed
Closed
Closed
This was referenced Sep 26, 2026
Merged
Merged
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.
This PR only adds tests. No analyzer or code fixer code changes. I found the gaps by running the Roslyn 5.9 test suite with code coverage, and the new tests cover about 150 more lines and 130 more branches.
Tests added
ArgumentNullException.ThrowIfNull(arg, "arg")is fixed to usenameof.InvalidEnumArgumentException.&&that can't be merged next to ones that can.(value & Flag) == 0for every enum underlying type, using the highest bit (reported) and a combined flag (not reported).0Land0usizes, and multi-dimensional arrays.paramsarrays for constructors and indexers.minimum_method_parametersoption, including an invalid value.paramselement.ReferenceEqualsandParse/TryParseexclusions.SyntaxNode.With*methods with several parameters.!operator, parenthesized expressions and blank expressions.string.FormatandStringBuilder.AppendFormatwith an explicitobject[].nuint,StringBuilderandVersion.FontStretch/Brushand NuGetSemanticVersiontypes, as stubs that implementIFormattableso the exclusion is what prevents the diagnostic.IFloatingPoint<T>without explicit interface syntax.MinimumNumberOfParameters_2passed without reading the option, because its argument (new object()) is never reported. It now passes a boolean literal, so the option is what prevents the diagnostic.Notes for reviewers
string.Format("", ["test", -1]). The argument is wrapped in an implicit conversion toReadOnlySpan<object?>, so theICollectionExpressionOperationchecks inCultureSensitiveFormattingContextnever match. The fix would add new diagnostics, so it belongs in its own PR, and this PR has no tests for it.MethodBase.Invoke,FieldInfo/PropertyInfo.GetValueandSetValuenever run, because their first parameter is namedobjand is filtered out earlier.Volatile.Readexclusion never runs, because its only parameter isrefand can't take a literal.IVariableDeclarationOperation.Initializer, which is only set for VB.Testing
dotnet build: 0 errors, 0 warnings.dotnet teston all Roslyn versions (4.8, 4.14, 5.0, 5.6, 5.9): 23,625 tests passed.