Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit da830d1

Browse files
ViktorHoferdanmoseley
authored andcommitted
Limit access modifers throughout the Regex codebase
1 parent e3228df commit da830d1

19 files changed

+986
-1009
lines changed

src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/CompiledRegexRunner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ internal sealed class CompiledRegexRunner : RegexRunner
1010
private Func<RegexRunner, bool> _findFirstCharMethod;
1111
private Action<RegexRunner> _initTrackCountMethod;
1212

13-
internal CompiledRegexRunner() { }
13+
public CompiledRegexRunner() { }
1414

15-
internal void SetDelegates(Action<RegexRunner> go, Func<RegexRunner,bool> firstChar, Action<RegexRunner> trackCount)
15+
public void SetDelegates(Action<RegexRunner> go, Func<RegexRunner,bool> firstChar, Action<RegexRunner> trackCount)
1616
{
1717
_goMethod = go;
1818
_findFirstCharMethod = firstChar;

src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/CompiledRegexRunnerFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal sealed class CompiledRegexRunnerFactory : RegexRunnerFactory
1212
private readonly DynamicMethod _findFirstCharMethod;
1313
private readonly DynamicMethod _initTrackCountMethod;
1414

15-
internal CompiledRegexRunnerFactory(DynamicMethod go, DynamicMethod firstChar, DynamicMethod trackCount)
15+
public CompiledRegexRunnerFactory(DynamicMethod go, DynamicMethod firstChar, DynamicMethod trackCount)
1616
{
1717
_goMethod = go;
1818
_findFirstCharMethod = firstChar;

src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Reference.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal sealed class ExclusiveReference
2121
/// If the exclusive lock can't be obtained, null is returned;
2222
/// if the object can't be returned, the lock is released.
2323
/// </summary>
24-
internal object Get()
24+
public object Get()
2525
{
2626
// try to obtain the lock
2727

@@ -53,7 +53,7 @@ internal object Get()
5353
/// If the object is the one that's under lock, the lock is released.
5454
/// If there is no cached object, then the lock is obtained and the object is placed in the cache.
5555
/// </summary>
56-
internal void Release(object obj)
56+
public void Release(object obj)
5757
{
5858
if (obj == null)
5959
throw new ArgumentNullException(nameof(obj));
@@ -100,7 +100,7 @@ internal sealed class SharedReference
100100
/// If the exclusive lock can't be obtained, null is returned;
101101
/// Note that _ref.Target is referenced only under the protection of the lock. (Is this necessary?)
102102
/// </summary>
103-
internal object Get()
103+
public object Get()
104104
{
105105
if (0 == Interlocked.Exchange(ref _locked, 1))
106106
{
@@ -117,7 +117,7 @@ internal object Get()
117117
///
118118
/// Note that _ref.Target is referenced only under the protection of the lock. (Is this necessary?)
119119
/// </summary>
120-
internal void Cache(object obj)
120+
public void Cache(object obj)
121121
{
122122
if (0 == Interlocked.Exchange(ref _locked, 1))
123123
{

src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Cache.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public partial class Regex
1313
internal static LinkedList<CachedCodeEntry> s_livecode = new LinkedList<CachedCodeEntry>();// the cache of code and factories that are currently loaded
1414
internal static int s_cacheSize = 15;
1515

16-
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread-safety")]
1716
public static int CacheSize
1817
{
1918
get
@@ -101,7 +100,7 @@ private CachedCodeEntry CacheCode(CachedCodeEntryKey key)
101100
private readonly string _cultureKey;
102101
private readonly string _pattern;
103102

104-
internal CachedCodeEntryKey(RegexOptions options, string cultureKey, string pattern)
103+
public CachedCodeEntryKey(RegexOptions options, string cultureKey, string pattern)
105104
{
106105
_options = options;
107106
_cultureKey = cultureKey;
@@ -139,19 +138,20 @@ public override int GetHashCode()
139138
/// </summary>
140139
internal sealed class CachedCodeEntry
141140
{
142-
internal CachedCodeEntryKey _key;
143-
internal RegexCode _code;
144-
internal Hashtable _caps;
145-
internal Hashtable _capnames;
146-
internal string[] _capslist;
141+
public CachedCodeEntryKey _key;
142+
public RegexCode _code;
143+
public Hashtable _caps;
144+
public Hashtable _capnames;
145+
public string[] _capslist;
147146
#if FEATURE_COMPILED
148-
internal RegexRunnerFactory _factory;
147+
public RegexRunnerFactory _factory;
149148
#endif
150-
internal int _capsize;
151-
internal ExclusiveReference _runnerref;
152-
internal SharedReference _replref;
149+
public int _capsize;
150+
public ExclusiveReference _runnerref;
151+
public SharedReference _replref;
153152

154-
internal CachedCodeEntry(CachedCodeEntryKey key, Hashtable capnames, string[] capslist, RegexCode code, Hashtable caps, int capsize, ExclusiveReference runner, SharedReference repl)
153+
public CachedCodeEntry(CachedCodeEntryKey key, Hashtable capnames, string[] capslist, RegexCode code,
154+
Hashtable caps, int capsize, ExclusiveReference runner, SharedReference repl)
155155
{
156156
_key = key;
157157
_capnames = capnames;
@@ -166,7 +166,7 @@ internal CachedCodeEntry(CachedCodeEntryKey key, Hashtable capnames, string[] ca
166166
}
167167

168168
#if FEATURE_COMPILED
169-
internal void AddCompiled(RegexRunnerFactory factory)
169+
public void AddCompiled(RegexRunnerFactory factory)
170170
{
171171
_factory = factory;
172172
_code = null;

src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ private Regex(string pattern, RegexOptions options, TimeSpan matchTimeout, bool
124124
RegexTree tree = RegexParser.Parse(pattern, roptions);
125125

126126
// Extract the relevant information
127-
capnames = tree._capnames;
128-
capslist = tree._capslist;
127+
capnames = tree.CapNames;
128+
capslist = tree.CapsList;
129129
_code = RegexWriter.Write(tree);
130-
caps = _code._caps;
131-
capsize = _code._capsize;
130+
caps = _code.Caps;
131+
capsize = _code.CapSize;
132132

133133
InitializeReferences();
134134

0 commit comments

Comments
 (0)