Skip to content

Commit

Permalink
Apply various code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Pihrt committed Jun 5, 2022
1 parent 6a8500f commit 464dd7f
Show file tree
Hide file tree
Showing 44 changed files with 219 additions and 220 deletions.
1 change: 0 additions & 1 deletion src/Examples/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancy", "RCS1163:Unused parameter.", Justification = "<Pending>", Scope = "member", Target = "~M:Pihrtsoft.Text.RegularExpressions.Linq.Examples.Program.Main(System.String[])")]

6 changes: 3 additions & 3 deletions src/LinqToRegex/Anchor/Assertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal Assertion(object content)
/// <summary>
/// Returns an instance of the <see cref="NegativeAssertion"/> class.
/// </summary>
public NegativeAssertion Negate() => new NegativeAssertion(this);
public NegativeAssertion Negate() => new(this);

internal override void AppendTo(PatternBuilder builder)
{
Expand All @@ -31,10 +31,10 @@ internal override void AppendTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
public static NegativeAssertion operator !(Assertion value)
{
if (value == null)
if (value is null)
throw new ArgumentNullException(nameof(value));

return value.Negate();
}
}
}
}
6 changes: 3 additions & 3 deletions src/LinqToRegex/Anchor/BackAssertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal BackAssertion(object content)
/// <summary>
/// Returns a new instance of the <see cref="NegativeBackAssertion"/> class.
/// </summary>
public NegativeBackAssertion Negate() => new NegativeBackAssertion(this);
public NegativeBackAssertion Negate() => new(this);

internal override void AppendTo(PatternBuilder builder)
{
Expand All @@ -31,10 +31,10 @@ internal override void AppendTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
public static NegativeBackAssertion operator !(BackAssertion value)
{
if (value == null)
if (value is null)
throw new ArgumentNullException(nameof(value));

return value.Negate();
}
}
}
}
2 changes: 1 addition & 1 deletion src/LinqToRegex/Anchor/NegativeAssertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ internal override void AppendTo(PatternBuilder builder)
builder.AppendNegativeAssertion(Content);
}
}
}
}
2 changes: 1 addition & 1 deletion src/LinqToRegex/Anchor/NegativeBackAssertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ internal override void AppendTo(PatternBuilder builder)
builder.AppendNegativeBackAssertion(Content);
}
}
}
}
4 changes: 2 additions & 2 deletions src/LinqToRegex/Anchor/WordBoundary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class WordBoundary : QuantifiablePattern, INegateable<NegativeWord
/// <summary>
/// Returns an instance of the <see cref="NegativeWordBoundary"/> class.
/// </summary>
public NegativeWordBoundary Negate() => new NegativeWordBoundary();
public NegativeWordBoundary Negate() => new();

internal override void AppendTo(PatternBuilder builder)
{
Expand All @@ -27,7 +27,7 @@ internal override void AppendTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
public static NegativeWordBoundary operator !(WordBoundary value)
{
if (value == null)
if (value is null)
throw new ArgumentNullException(nameof(value));

return value.Negate();
Expand Down
6 changes: 3 additions & 3 deletions src/LinqToRegex/CharGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal static CharGroup Create(CharGroup value, bool negative)
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <c>null</c>.</exception>
public void AppendBaseGroupTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

if (Negative)
Expand All @@ -91,7 +91,7 @@ public void AppendBaseGroupTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <c>null</c>.</exception>
public void AppendExcludedGroupTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

AppendTo(builder);
Expand All @@ -109,7 +109,7 @@ public void AppendExcludedGroupTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
public static CharGroup operator !(CharGroup value)
{
if (value == null)
if (value is null)
throw new ArgumentNullException(nameof(value));

return value.Negate();
Expand Down
14 changes: 7 additions & 7 deletions src/LinqToRegex/CharGroup_.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public CharCharGroup(char value, bool negative)

internal override void AppendContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.Append(_value, true);
Expand All @@ -44,7 +44,7 @@ public AsciiCharCharGroup(AsciiChar value, bool negative)

internal override void AppendContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.Append(_value, true);
Expand All @@ -64,7 +64,7 @@ internal sealed class TextCharGroup : CharGroup

public TextCharGroup(string characters, bool negative)
{
if (characters == null)
if (characters is null)
throw new ArgumentNullException(nameof(characters));

if (characters.Length == 0)
Expand All @@ -76,7 +76,7 @@ public TextCharGroup(string characters, bool negative)

internal override void AppendContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.Append(_characters, true);
Expand All @@ -96,7 +96,7 @@ internal sealed class CharactersCharGroup : CharGroup

public CharactersCharGroup(char[] characters, bool negative)
{
if (characters == null)
if (characters is null)
throw new ArgumentNullException(nameof(characters));

if (characters.Length == 0)
Expand All @@ -108,7 +108,7 @@ public CharactersCharGroup(char[] characters, bool negative)

internal override void AppendContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.Append(_characters, true);
Expand Down Expand Up @@ -139,7 +139,7 @@ public CharRangeCharGroup(char firstChar, char lastChar, bool negative)

internal override void AppendContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.AppendCharRange(_firstChar, _lastChar);
Expand Down
32 changes: 16 additions & 16 deletions src/LinqToRegex/CharGrouping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public override string ToString()

private CharGrouping Append(CharGrouping value)
{
if (value == null)
if (value is null)
throw new ArgumentNullException(nameof(value));

CharGrouping first = value;

while (first.Previous != null)
while (first.Previous is not null)
first = first.Previous;

first.Previous = this;
Expand Down Expand Up @@ -414,7 +414,7 @@ public CharGrouping Character(GeneralCategory category)
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <c>null</c>.</exception>
public void AppendBaseGroupTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

AppendContentTo(builder);
Expand All @@ -427,15 +427,15 @@ public void AppendBaseGroupTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <c>null</c>.</exception>
public void AppendExcludedGroupTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.Append(this);
}

internal void AppendContentTo(PatternBuilder builder)
{
if (Previous != null)
if (Previous is not null)
{
Stack<CharGrouping> stack = builder.CharGroupings;
int cnt = stack.Count;
Expand All @@ -445,8 +445,8 @@ internal void AppendContentTo(PatternBuilder builder)
{
stack.Push(item);
item = item.Previous;

} while (item != null);
}
while (item is not null);

while (stack.Count > cnt)
stack.Pop().AppendItemContentTo(builder);
Expand All @@ -465,10 +465,10 @@ internal void AppendContentTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="left"/> or <paramref name="right"/> is <c>null</c>.</exception>
public static CharGrouping operator +(CharGrouping left, CharGrouping right)
{
if (left == null)
if (left is null)
throw new ArgumentNullException(nameof(left));

if (right == null)
if (right is null)
throw new ArgumentNullException(nameof(right));

return left.Append(Chars.Character(right));
Expand All @@ -482,10 +482,10 @@ internal void AppendContentTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="left"/> or <paramref name="right"/> is <c>null</c>.</exception>
public static CharGrouping operator +(CharGrouping left, string right)
{
if (left == null)
if (left is null)
throw new ArgumentNullException(nameof(left));

if (right == null)
if (right is null)
throw new ArgumentNullException(nameof(right));

return left.Append(right);
Expand All @@ -499,10 +499,10 @@ internal void AppendContentTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="left"/> or <paramref name="right"/> is <c>null</c>.</exception>
public static CharGrouping operator +(string left, CharGrouping right)
{
if (left == null)
if (left is null)
throw new ArgumentNullException(nameof(left));

if (right == null)
if (right is null)
throw new ArgumentNullException(nameof(right));

return Chars.Character(left).Append(Chars.Character(right));
Expand All @@ -516,7 +516,7 @@ internal void AppendContentTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="left"/> is <c>null</c>.</exception>
public static CharGrouping operator +(CharGrouping left, char right)
{
if (left == null)
if (left is null)
throw new ArgumentNullException(nameof(left));

return left.Append(right);
Expand All @@ -530,7 +530,7 @@ internal void AppendContentTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="right"/> is <c>null</c>.</exception>
public static CharGrouping operator +(char left, CharGrouping right)
{
if (right == null)
if (right is null)
throw new ArgumentNullException(nameof(right));

return Chars.Character(left).Append(Chars.Character(right));
Expand All @@ -543,7 +543,7 @@ internal void AppendContentTo(PatternBuilder builder)
/// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
public static CharGroup operator !(CharGrouping value)
{
if (value == null)
if (value is null)
throw new ArgumentNullException(nameof(value));

return Patterns.NotChar(value);
Expand Down
18 changes: 9 additions & 9 deletions src/LinqToRegex/CharGrouping_.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public CharacterCharGrouping(char value)

protected override void AppendItemContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.Append(_value, true);
Expand All @@ -35,7 +35,7 @@ public AsciiCharacterCharGrouping(AsciiChar value)

protected override void AppendItemContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.Append(_value, true);
Expand All @@ -48,7 +48,7 @@ internal sealed class CharactersCharGrouping : CharGrouping

public CharactersCharGrouping(string characters)
{
if (characters == null)
if (characters is null)
throw new ArgumentNullException(nameof(characters));

if (characters.Length == 0)
Expand All @@ -59,7 +59,7 @@ public CharactersCharGrouping(string characters)

protected override void AppendItemContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.Append(_characters, true);
Expand All @@ -82,7 +82,7 @@ public CharacterRangeCharGrouping(char firstChar, char lastChar)

protected override void AppendItemContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.AppendCharRange(_firstChar, _lastChar);
Expand All @@ -100,7 +100,7 @@ public CharacterClassCharGrouping(CharClass value)

protected override void AppendItemContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.AppendCharClass(_value);
Expand All @@ -119,7 +119,7 @@ public GeneralCategoryCharGrouping(GeneralCategory category, bool negative)

protected override void AppendItemContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.AppendGeneralCategory(_category, Negative);
Expand All @@ -140,7 +140,7 @@ public NamedBlockCharGrouping(NamedBlock block, bool negative)

protected override void AppendItemContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

builder.AppendNamedBlock(_block, Negative);
Expand All @@ -160,7 +160,7 @@ public CharGroupingCharGrouping(CharGrouping value)

protected override void AppendItemContentTo(PatternBuilder builder)
{
if (builder == null)
if (builder is null)
throw new ArgumentNullException(nameof(builder));

_value.AppendContentTo(builder);
Expand Down
Loading

0 comments on commit 464dd7f

Please sign in to comment.