Conversation
…ment position Co-authored-by: meziantou <509220+meziantou@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix MA0074 for MSTest Assert.Contains with message
MA0074: Fix StringComparison argument inserted at wrong position when trailing parameters exist
Mar 4, 2026
meziantou
reviewed
Mar 4, 2026
| return -1; | ||
|
|
||
| var targetMethod = operation.TargetMethod; | ||
| foreach (var member in targetMethod.ContainingType.GetMembers(targetMethod.Name)) |
Owner
There was a problem hiding this comment.
@copilot Can you reuse the logic from the analyzer to find an overload instead of duplicating it. If the analyzer logic changed, it should be reflected in the fixer.
Contributor
Author
There was a problem hiding this comment.
Done in d338601. Added OverloadFinder, OverloadOptions, and OverloadParameterType to the CodeFixers project, then replaced the duplicated overload-finding logic with overloadFinder.FindOverloadWithAdditionalParameterOfType(operation, options: default, [stringComparison]). The FindStringComparisonParameterIndex method now just uses the existing OverloadFinder and extracts the position of the StringComparison parameter from the returned overload.
…arameter index Co-authored-by: meziantou <509220+meziantou@users.noreply.github.com>
This was referenced Mar 4, 2026
Merged
Merged
This was referenced Apr 6, 2026
Closed
This was referenced Apr 14, 2026
Open
This was referenced Apr 21, 2026
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.
StringComparisonat the end of argument list instead of at the correct positionUseStringComparisonFixer.csto find the correct index for theStringComparisonargument based on the target overload's parameter listOverloadFinder,OverloadOptions,OverloadParameterTypeto CodeFixers projectOverloadFinder.FindOverloadWithAdditionalParameterOfTypeContains_WithTrailingMessageParameter_ShouldInsertStringComparisonBeforeMessageOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.