-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Make RegexParseException and RegexParseError public, rename enum fields #40902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make RegexParseException and RegexParseError public, rename enum fields #40902
Conversation
Looks like I need to inform the system that there's a new kid in town ;) |
That would be the ref file. |
@am11 thanks! That's bascially it then? |
I think usually that is enough. There might be some target which will complain about compatibility (which may require some mechanical change), but we will find out soon. :) |
Here's a summary of the renaming of the enum fields in
|
How to update ref with tool : https://github.com/dotnet/runtime/blob/2a4284b9f3eb2ad95fdf324f0249d372abff96df/docs/coding-guidelines/updating-ref-source.md Avoid typos etc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks about right but I'll have to look again when I'm at a computer!
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs
Outdated
Show resolved
Hide resolved
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs
Show resolved
Hide resolved
src/libraries/System.Text.RegularExpressions/tests/RegexParserTests.cs
Outdated
Show resolved
Hide resolved
Just a note that if you use the tool, you might end up with a bunch of changes in the ref file. We usually just commit the changes we really need and discard the rest. |
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs
Outdated
Show resolved
Hide resolved
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs
Show resolved
Hide resolved
@pgovind, only now I see the tool, what I did here was by hand. Thanks for the warning though. |
This happens in Ok, I kinda expected something like that, but also expected that it is public now. If I add a forced EDIT: I see it is the |
That is happening only for net48, which I suspected might. :) |
That would work. Thanks! |
Next one up, this one I've no clue yet. Guess I'll have to dive in the logs, or it is some fluke... |
That could be an intermittent failure, unrelated to PR changes. |
As you saw, the tests run on .NET Framework as well purely for comparison. I think To verify, you should run tests locally on .NET Framework before pushing that change. This seems to work for me
When I try that, the second test run seems to test both (?) .. this should be simpler/better documented, I'll ask about it A random, unrelated failure like in Http tests can be ignored: no need to run CI again for that. CI runs a vast number of tests/legs and will never be 100% stable. |
Apparently, already part of the tests were in a non-NET48 section, so I ended up just moving the file in the
Good to know :) |
I'm not entirely confident about adding the switch statement for the default message. It kinda feels odd. As mentioned above, there are some messages that expect extra info, which I've left as-is. My estimate is that if someone wants to use the exception-ctor, they are far more likely to do it to have extra control over the message, which we don't give them here anyway. So their only way out is to come up with their own exception. I wouldn't feel bad if we drop the extra ctor altogether, just saying ;). I'll look into adding the offset-data to the test coverage. it wasn't done before, but it looks like there was an effort underway to test for offset info, just never fully implemented. |
src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs
Outdated
Show resolved
Hide resolved
...braries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseError.cs
Show resolved
Hide resolved
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs
Show resolved
Hide resolved
@pgovind Do note, that all error messages are already properly constructed right now, except for the public ctor, which isn't used internally. I'd suggest writing the error message population code once there's new agreement on the proper ctors,otherwise we run the risk doing it twice. |
@pgovind Only read that edit now. Sure, np (and then I sure hope you can convince them ;) ) |
Alright, I got semi-official sign-off from @GrabYourPitchforks (granted he only went through the following summary) for:
If we can make those changes in time, I'll re-approve and then @danmosemsft can still likely get this in :) Note: Levi did mention the following that in .NET6, we likely wouldn't want |
To summarize:
|
(again we posted at the same time 😆 )
Yes, no problem with that 🙌 |
I'll start implementing the internal ctor. One detail I'd need an agreement on though:
@pgovind, what do you think? |
Hmmm, maybe I'm not understanding, but if there is a placeholder, you can just use the |
These ones have no additional info (#40902 (comment)), the others do, like for instance if you have a non-existing unicode property, the error will also show you that wrong property in an additional placeholder. I don't think it matters much for now, really, as we've decided above to create the internal constructor with the necessary logic, but it won't be called anywhere (the original exceptions remain as they were, of course). |
I went for the generic version of specific message. I.e., if the resource string requires an extra param: <data name="UndefinedNumberedReference" xml:space="preserve">
<value>Reference to undefined group number {0}.</value>
</data> Then I add: <data name="UndefinedNumberedReferenceNoPlaceholder" xml:space="preserve">
<value>Reference to undefined group number.</value>
</data> This will also help in the future adding this overload. |
Oh now I see what you mean. Yes, I think that's fine :) |
@pgovind, @danmosemsft, @stephentoub, done. Could you re-review? 😃 I had one small issue with the ref file, it didn't accept the absence of a ctor (it required a default ctor to be there). By adding a private ctor to the ref file, it appeared to be fine and it compiled, but I don't know if that's "the right way". |
Basically, these last two commits should resolve the "semi-official" agreement with @GrabYourPitchforks / @pgovind above:
|
Not yet: the internal ctor would only be a placeholder for a later public one. It isn't referenced anywhere. The original code that throws the exceptions uses the other internal exception already. Since there's a difference in behavior: extra data is n/a for the later-to-be-externalized ctor, they should be split. Though the logic could be improved (we could centralize it for all exceptions), I'm not sure that helps much right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, re-approved. LGTM.
@danmosemsft , when CI finishes, I'm good with merging this.
Mono build "Libraries Test Run release mono OSX x64 Debug" gives one of those weird ones again (doesn't seem to be related in any way):
|
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs
Show resolved
Hide resolved
@danmosemsft, all checks past, except that intermittent one above. |
Thanks @abelbraaksma for your efforts. given it only just missed the cutoff, I'm OK porting it when the branch is up. |
@Anipik is the RC1 branch up and ready for PR's? (I assume we missed the cut) |
Oh, that's too bad, so it won't be in 5.0?
Uh wait, you mean it'll be in the release candidate for 5.0, right? |
I mean I am OK porting it if we can do it today-ish. It's marginal, but it's pretty hard that it missed by 20 mins. |
Indeed it is, that's basically just the last commit ;)
That'd be super!! |
It made a cutoff, testing a couple of infra changes. But the snap should be in 30 minutes or so. |
OK, it's in. Great.
|
Thanks for all the help @danmosemsft and all others, couldn't have done it so fast without it! |
Fixes #38872.
This PR does the following things (as agreed on in #38872 (comment) by @terrajobst):
RegexParseException
publicNotImplementedException
(it is serialized as anArgumentException
).RegexParseError
publicUnknown
as the zero-fieldRegexParseException
a bit w.r.t. using automatic propertiesTodo:
Inline documentation (I need a little help as to what is expected here)doneadd tests for offsetdoneLocally tested against test set, but full build with all other tests not yet. However, I did not find dependencies elsewhere, apart from a binary serialization test on the exception.
Tagging: @danmosemsft.