Skip to content

Add CSharpPattern capture support tests for as operator#6999

Merged
knutwannheden merged 1 commit intomainfrom
add-as-operator-support-to-csharppattern
Mar 17, 2026
Merged

Add CSharpPattern capture support tests for as operator#6999
knutwannheden merged 1 commit intomainfrom
add-as-operator-support-to-csharppattern

Conversation

@knutwannheden
Copy link
Contributor

Summary

  • The as operator already works with CSharpPattern via CsBinary matching, but lacked test coverage for capture-based patterns
  • Add FindCsBinary(TemplateStringHandler) helper overload to enable capture-based test patterns
  • Add tests for as with captures on both sides, left-only, right-only, and a negative test confirming as patterns don't match is expressions

Test plan

  • All 5 as-related pattern match tests pass (1 existing + 4 new)

The `as` operator already works with CSharpPattern via CsBinary matching,
but lacked test coverage for capture-based patterns. Add tests for
captures on both sides, left-only, right-only, and a negative test
confirming `as` patterns don't match `is` expressions. Also add the
missing FindCsBinary(TemplateStringHandler) helper overload.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 17, 2026
@knutwannheden knutwannheden changed the title Add CSharpPattern capture support tests for as operator Add CSharpPattern capture support tests for as operator Mar 17, 2026
@knutwannheden knutwannheden merged commit a06d43b into main Mar 17, 2026
1 check passed
@knutwannheden knutwannheden deleted the add-as-operator-support-to-csharppattern branch March 17, 2026 07:50
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant