Home icon indicating copy to clipboard operation
Home copied to clipboard

RegularExpressions: Group Captures collection has only the last capture. Unit test RegExpTest_6_Group_Test_0 gives false positive

Open jazzman55 opened this issue 2 years ago • 4 comments

Library/API/IoT binding

System.Text.RegularExpressions

Visual Studio version

VS2022

.NET nanoFramework extension version

No response

Target name(s)

No response

Firmware version

No response

Device capabilities

No response

Description

When regular expression match group captures multiple items, only the last one appears in Group[GROUP_NO].Captures. This is not caught by unit tests, as GroupTests.RegExpTest_6_Group_Test_0 gives false positive. See screenshot.

How to reproduce

  1. Run RegExpTest_6_Group_Test_0 test.
  2. Observe output and compare with comments in the test.

Expected behaviour

  • Output should match the comment i.e. multiple captures appear in groups 2 and 3.
  • Test should fail if captures count does not match expected numbers.

Screenshots

image

Sample project or code

No response

Aditional information

No response

jazzman55 avatar Sep 23 '22 08:09 jazzman55

Related to https://github.com/nanoframework/Home/issues/1136?

torbacz avatar Sep 23 '22 08:09 torbacz

@jazzman55, it's just a debug related issue as @torbacz pointed out from my perspective. That will require quite some investigation. Have you tried to run the code and release mode?

Ellerbach avatar Sep 23 '22 09:09 Ellerbach

It doesn't work in Release either. I added a few Asserts that validate Captures counts and they fail in both Debug and Release. See screenshot. image

jazzman55 avatar Sep 23 '22 10:09 jazzman55

ok, so definitely a bug. If you have time to dig into, we're always happy to get PR to fix those :-)

Ellerbach avatar Sep 23 '22 10:09 Ellerbach