This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Porting roslyn regex tests to corefx #29178
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c3950e9
Add regex roslyn tests
ViktorHofer 17cf0a0
Switch from InternalsVisibleTo to reflection
ViktorHofer ee4928f
Offset & serialization in exception, remove internal error in error e…
ViktorHofer b21452c
Adding serialization ctor
ViktorHofer 472bc9e
Enable parser tests on uapaot & netfx
ViktorHofer 0b01a32
Improve error message for netfx & uapaot
ViktorHofer 787713a
Move match parser tests over to RegexParserTests
ViktorHofer d6408aa
Add offset to the error message
ViktorHofer 6357cc9
Disabled failing tests for netfx because of missing fixes
ViktorHofer c993ef9
Minor code cleanup
ViktorHofer f178655
Add subexpression parsing
ViktorHofer f7c5328
Improved RegexParseError option names
ViktorHofer ce5e4aa
Make subexpression parsing useful
ViktorHofer 916e525
Clean up test cases
ViktorHofer 9b98a4a
Error message refined, code cleanup, serialization test added
ViktorHofer 622ba99
Add test case for SetType in RegexParseException
ViktorHofer 3bc1e97
Remove duplicates
ViktorHofer e0dcc0f
Disable netfx failing tests
ViktorHofer 62474a1
Change exp regex exception in some bcl libs
ViktorHofer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseError.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Text.RegularExpressions | ||
{ | ||
internal enum RegexParseError | ||
{ | ||
TooManyAlternates, | ||
IllegalCondition, | ||
IncompleteSlashP, | ||
MalformedSlashP, | ||
UnrecognizedEscape, | ||
UnrecognizedControl, | ||
MissingControl, | ||
TooFewHex, | ||
CaptureGroupOutOfRange, | ||
UndefinedNameRef, | ||
UndefinedBackref, | ||
MalformedNameRef, | ||
IllegalEndEscape, | ||
UnterminatedComment, | ||
UnrecognizedGrouping, | ||
AlternationCantCapture, | ||
AlternationCantHaveComment, | ||
MalformedReference, | ||
UndefinedReference, | ||
InvalidGroupName, | ||
CapnumNotZero, | ||
UnterminatedBracket, | ||
SubtractionMustBeLast, | ||
ReversedCharRange, | ||
BadClassInCharRange, | ||
NotEnoughParentheses, | ||
IllegalRange, | ||
NestedQuantify, | ||
QuantifyAfterNothing, | ||
TooManyParentheses, | ||
UnknownUnicodeProperty | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Runtime.Serialization; | ||
|
||
namespace System.Text.RegularExpressions | ||
{ | ||
[Serializable] | ||
internal sealed class RegexParseException : ArgumentException | ||
{ | ||
private readonly RegexParseError _error; | ||
|
||
/// <summary> | ||
/// The error that happened during parsing. | ||
/// </summary> | ||
public RegexParseError Error => _error; | ||
|
||
/// <summary> | ||
/// The offset in the supplied pattern. | ||
/// </summary> | ||
public int Offset { get; } | ||
|
||
public RegexParseException(RegexParseError error, int offset, string message) : base(message) | ||
{ | ||
_error = error; | ||
Offset = offset; | ||
} | ||
|
||
public RegexParseException() : base() | ||
{ | ||
} | ||
|
||
public RegexParseException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public RegexParseException(string message, Exception inner) : base(message, inner) | ||
{ | ||
} | ||
|
||
private RegexParseException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ | ||
} | ||
|
||
public override void GetObjectData(SerializationInfo info, StreamingContext context) | ||
{ | ||
base.GetObjectData(info, context); | ||
// To maintain serialization support with netfx. | ||
info.SetType(typeof(ArgumentException)); | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
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.
Do we have a test that breaks when this attribute (or SetType below) is missing?
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.
I just added one.