|
// <auto-generated/>
#nullable enable
#pragma warning disable
namespace Microsoft.NET.Build.Containers
{
partial class AuthHandshakeMessageHandler
{
/// <remarks>
/// Pattern:<br/>
/// <code>(?<key>\w+)="(?<value>[^"]*)"(?:,|$)</code><br/>
/// Explanation:<br/>
/// <code>
/// ○ "key" capture group.<br/>
/// ○ Match a word character atomically at least once.<br/>
/// ○ Match the string "=\"".<br/>
/// ○ "value" capture group.<br/>
/// ○ Match a character other than '"' atomically any number of times.<br/>
/// ○ Match '"'.<br/>
/// ○ Match with 2 alternative expressions, atomically.<br/>
/// ○ Match ','.<br/>
/// ○ Match if at the end of the string or if before an ending newline.<br/>
/// </code>
/// </remarks>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "11.0.14.26904")]
private static partial global::System.Text.RegularExpressions.Regex BearerParameterSplitter() => global::System.Text.RegularExpressions.Generated.BearerParameterSplitter_0.Instance;
}
}
namespace System.Text.RegularExpressions.Generated
{
using System;
using System.Buffers;
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Threading;
/// <summary>Custom <see cref="Regex"/>-derived type for the BearerParameterSplitter method.</summary>
[GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "11.0.14.26904")]
file sealed class BearerParameterSplitter_0 : Regex
{
/// <summary>Cached, thread-safe singleton instance.</summary>
internal static readonly BearerParameterSplitter_0 Instance = new();
/// <summary>Initializes the instance.</summary>
private BearerParameterSplitter_0()
{
base.pattern = "(?<key>\\w+)=\"(?<value>[^\"]*)\"(?:,|$)";
base.roptions = RegexOptions.None;
ValidateMatchTimeout(Utilities.s_defaultTimeout);
base.internalMatchTimeout = Utilities.s_defaultTimeout;
base.factory = new RunnerFactory();
base.CapNames = new Hashtable { { "0", 0 } , { "key", 1 } , { "value", 2 } };
base.capslist = new string[] {"0", "key", "value" };
base.capsize = 3;
}
/// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see cref="Regex"/>.</summary>
private sealed class RunnerFactory : RegexRunnerFactory
{
/// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</summary>
protected override RegexRunner CreateInstance() => new Runner();
/// <summary>Provides the runner that contains the custom logic implementing the specified regular expression.</summary>
private sealed class Runner : RegexRunner
{
/// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</summary>
/// <param name="inputSpan">The text being scanned by the regular expression.</param>
protected override void Scan(ReadOnlySpan<char> inputSpan)
{
// Search until we can't find a valid starting position, we find a match, or we reach the end of the input.
while (TryFindNextPossibleStartingPosition(inputSpan) &&
!TryMatchAtCurrentPosition(inputSpan) &&
base.runtextpos != inputSpan.Length)
{
base.runtextpos++;
if (Utilities.s_hasTimeout)
{
base.CheckTimeout();
}
}
}
/// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a match could possibly start.</summary>
/// <param name="inputSpan">The text being scanned by the regular expression.</param>
/// <returns>true if a possible match was found; false if no more matches are possible.</returns>
private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan)
{
int pos = base.runtextpos;
// Any possible match is at least 4 characters.
if (pos <= inputSpan.Length - 4)
{
// The pattern begins with an atomic loop for a word character, followed by the string "=\"".
// Search for the literal, and then walk backwards to the beginning of the loop.
while (true)
{
ReadOnlySpan<char> slice = inputSpan.Slice(pos);
int i = slice.IndexOf("=\"");
if (i < 0)
{
break;
}
int prev = i - 1;
while ((uint)prev < (uint)slice.Length && Utilities.IsWordChar(slice[prev]))
{
prev--;
}
if ((i - prev - 1) < 1)
{
pos += i + 1;
continue;
}
base.runtextpos = pos + prev + 1;
base.runtrackpos = pos + i;
return true;
}
}
// No match found.
base.runtextpos = inputSpan.Length;
return false;
}
/// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regular expression.</summary>
/// <param name="inputSpan">The text being scanned by the regular expression.</param>
/// <returns>true if the regular expression matches at the current position; otherwise, false.</returns>
private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan)
{
int pos = base.runtextpos;
int matchStart = pos;
int capture_starting_pos = 0;
int capture_starting_pos1 = 0;
ReadOnlySpan<char> slice = inputSpan.Slice(pos);
// "key" capture group.
{
capture_starting_pos = pos;
// Skip loop already matched in TryFindNextPossibleStartingPosition.
pos = base.runtrackpos;
slice = inputSpan.Slice(pos);
base.Capture(1, capture_starting_pos, pos);
}
// Match the string "=\"".
if (!slice.StartsWith("=\""))
{
UncaptureUntil(0);
return false; // The input didn't match.
}
// "value" capture group.
{
pos += 2;
slice = inputSpan.Slice(pos);
capture_starting_pos1 = pos;
// Match a character other than '"' atomically any number of times.
{
int iteration = slice.IndexOf('"');
if (iteration < 0)
{
iteration = slice.Length;
}
slice = slice.Slice(iteration);
pos += iteration;
}
base.Capture(2, capture_starting_pos1, pos);
}
// Match '"'.
if (slice.IsEmpty || slice[0] != '"')
{
UncaptureUntil(0);
return false; // The input didn't match.
}
// Match with 2 alternative expressions, atomically.
{
int alternation_starting_pos = pos;
// Branch 0
{
// Match ','.
if ((uint)slice.Length < 2 || slice[1] != ',')
{
goto AlternationBranch;
}
pos += 2;
slice = inputSpan.Slice(pos);
goto AlternationMatch;
AlternationBranch:
pos = alternation_starting_pos;
slice = inputSpan.Slice(pos);
}
// Branch 1
{
// Match if at the end of the string or if before an ending newline.
if (2 < slice.Length || (1 < slice.Length && slice[1] != '\n'))
{
UncaptureUntil(0);
return false; // The input didn't match.
}
pos++;
slice = inputSpan.Slice(pos);
}
AlternationMatch:;
}
// The input matched.
base.runtextpos = pos;
base.Capture(0, matchStart, pos);
return true;
// <summary>Undo captures until it reaches the specified capture position.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void UncaptureUntil(int capturePosition)
{
while (base.Crawlpos() > capturePosition)
{
base.Uncapture();
}
}
}
}
}
}
/// <summary>Helper methods used by generated <see cref="Regex"/>-derived implementations.</summary>
[GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "11.0.14.26904")]
file static class Utilities
{
/// <summary>Default timeout value set in <see cref="AppContext"/>, or <see cref="Regex.InfiniteMatchTimeout"/> if none was set.</summary>
internal static readonly TimeSpan s_defaultTimeout = AppContext.GetData("REGEX_DEFAULT_MATCH_TIMEOUT") is TimeSpan timeout ? timeout : Regex.InfiniteMatchTimeout;
/// <summary>Whether <see cref="s_defaultTimeout"/> is non-infinite.</summary>
internal static readonly bool s_hasTimeout = s_defaultTimeout != Regex.InfiniteMatchTimeout;
/// <summary>Determines whether the character is part of the [\w] set.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsWordChar(char ch)
{
// If the char is ASCII, look it up in the bitmap. Otherwise, query its Unicode category.
ReadOnlySpan<byte> ascii = WordCharBitmap;
int chDiv8 = ch >> 3;
return (uint)chDiv8 < (uint)ascii.Length ?
(ascii[chDiv8] & (1 << (ch & 0x7))) != 0 :
(WordCategoriesMask & (1 << (int)CharUnicodeInfo.GetUnicodeCategory(ch))) != 0;
}
/// <summary>Provides a mask of Unicode categories that combine to form [\w].</summary>
private const int WordCategoriesMask =
1 << (int)UnicodeCategory.UppercaseLetter |
1 << (int)UnicodeCategory.LowercaseLetter |
1 << (int)UnicodeCategory.TitlecaseLetter |
1 << (int)UnicodeCategory.ModifierLetter |
1 << (int)UnicodeCategory.OtherLetter |
1 << (int)UnicodeCategory.NonSpacingMark |
1 << (int)UnicodeCategory.DecimalDigitNumber |
1 << (int)UnicodeCategory.ConnectorPunctuation;
/// <summary>Gets a bitmap for whether each character 0 through 127 is in [\w]</summary>
private static ReadOnlySpan<byte> WordCharBitmap => new byte[]
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
0xFE, 0xFF, 0xFF, 0x87, 0xFE, 0xFF, 0xFF, 0x07
};
}
}
|