Skip to content

Commit 6422e97

Browse files
committed
feat: change tables to use new array initialization method
1 parent 186c55c commit 6422e97

File tree

7 files changed

+79
-81
lines changed

7 files changed

+79
-81
lines changed

build/_build.csproj.DotSettings

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
1717
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
1818
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
19+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
20+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
1921
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
2022
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
2123
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
@@ -24,4 +26,5 @@
2426
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
2527
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
2628
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
27-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
29+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
30+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "9.0.103"
3+
"version": "9.0.200"
44
}
55
}

src/Ubiety.Stringprep.Core/Generated/Tables.cs

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ internal static class Tables
3939
/// <summary>
4040
/// A.1 Unassigned code points in Unicode 3.2.
4141
/// </summary>
42-
public static readonly List<int> A1 = new ()
43-
{
42+
public static readonly List<int> A1 =
43+
[
4444
0x0221, 0x0221,
4545
0x0234, 0x024F,
4646
0x02AE, 0x02AF,
@@ -437,12 +437,12 @@ internal static class Tables
437437
0xE0000, 0xE0000,
438438
0xE0002, 0xE001F,
439439
0xE0080, 0xEFFFD,
440-
};
440+
];
441441

442442
/// <summary>
443443
/// B.1 Commonly mapped to nothing.
444444
/// </summary>
445-
public static readonly Dictionary<int, int[]> B1 = new ()
445+
public static readonly Dictionary<int, int[]> B1 = new()
446446
{
447447
{ 0x00AD, Array.Empty<int>() }, // Map to nothing
448448
{ 0x034F, Array.Empty<int>() }, // Map to nothing
@@ -476,7 +476,7 @@ internal static class Tables
476476
/// <summary>
477477
/// B.2 Mapping for case-folding used with NFKC.
478478
/// </summary>
479-
public static readonly Dictionary<int, int[]> B2 = new ()
479+
public static readonly Dictionary<int, int[]> B2 = new()
480480
{
481481
{ 0x0041, new[] { 0x0061, } }, // Case map
482482
{ 0x0042, new[] { 0x0062, } }, // Case map
@@ -1854,7 +1854,7 @@ internal static class Tables
18541854
/// <summary>
18551855
/// B.3 Mapping for case-folding used with no normalization.
18561856
/// </summary>
1857-
public static readonly Dictionary<int, int[]> B3 = new ()
1857+
public static readonly Dictionary<int, int[]> B3 = new()
18581858
{
18591859
{ 0x0041, new[] { 0x0061, } }, // Case map
18601860
{ 0x0042, new[] { 0x0062, } }, // Case map
@@ -2702,16 +2702,16 @@ internal static class Tables
27022702
/// <summary>
27032703
/// C.1.1 ASCII space characters.
27042704
/// </summary>
2705-
public static readonly List<int> C11 = new ()
2706-
{
2705+
public static readonly List<int> C11 =
2706+
[
27072707
0x0020, 0x0020, // SPACE
2708-
};
2708+
];
27092709

27102710
/// <summary>
27112711
/// C.1.2 Non-ASCII space characters.
27122712
/// </summary>
2713-
public static readonly List<int> C12 = new ()
2714-
{
2713+
public static readonly List<int> C12 =
2714+
[
27152715
0x00A0, 0x00A0, // NO-BREAK SPACE
27162716
0x1680, 0x1680, // OGHAM SPACE MARK
27172717
0x2000, 0x2000, // EN QUAD
@@ -2729,25 +2729,25 @@ internal static class Tables
27292729
0x202F, 0x202F, // NARROW NO-BREAK SPACE
27302730
0x205F, 0x205F, // MEDIUM MATHEMATICAL SPACE
27312731
0x3000, 0x3000, // IDEOGRAPHIC SPACE
2732-
};
2732+
];
27332733

27342734
/// <summary>
27352735
/// C.2 Control characters.
27362736
/// </summary>
27372737
/// <summary>
27382738
/// C.2.1 ASCII control characters.
27392739
/// </summary>
2740-
public static readonly List<int> C21 = new ()
2741-
{
2740+
public static readonly List<int> C21 =
2741+
[
27422742
0x0000, 0x001F, // [CONTROL CHARACTERS]
27432743
0x007F, 0x007F, // DELETE
2744-
};
2744+
];
27452745

27462746
/// <summary>
27472747
/// C.2.2 Non-ASCII control characters.
27482748
/// </summary>
2749-
public static readonly List<int> C22 = new ()
2750-
{
2749+
public static readonly List<int> C22 =
2750+
[
27512751
0x0080, 0x009F, // [CONTROL CHARACTERS]
27522752
0x06DD, 0x06DD, // ARABIC END OF AYAH
27532753
0x070F, 0x070F, // SYRIAC ABBREVIATION MARK
@@ -2764,23 +2764,23 @@ internal static class Tables
27642764
0xFEFF, 0xFEFF, // ZERO WIDTH NO-BREAK SPACE
27652765
0xFFF9, 0xFFFC, // [CONTROL CHARACTERS]
27662766
0x1D173, 0x1D17A, // [MUSICAL CONTROL CHARACTERS]
2767-
};
2767+
];
27682768

27692769
/// <summary>
27702770
/// C.3 Private use.
27712771
/// </summary>
2772-
public static readonly List<int> C3 = new ()
2773-
{
2772+
public static readonly List<int> C3 =
2773+
[
27742774
0xE000, 0xF8FF, // [PRIVATE USE, PLANE 0]
27752775
0xF0000, 0xFFFFD, // [PRIVATE USE, PLANE 15]
27762776
0x100000, 0x10FFFD, // [PRIVATE USE, PLANE 16]
2777-
};
2777+
];
27782778

27792779
/// <summary>
27802780
/// C.4 Non-character code points.
27812781
/// </summary>
2782-
public static readonly List<int> C4 = new ()
2783-
{
2782+
public static readonly List<int> C4 =
2783+
[
27842784
0xFDD0, 0xFDEF, // [NONCHARACTER CODE POINTS]
27852785
0xFFFE, 0xFFFF, // [NONCHARACTER CODE POINTS]
27862786
0x1FFFE, 0x1FFFF, // [NONCHARACTER CODE POINTS]
@@ -2799,41 +2799,41 @@ internal static class Tables
27992799
0xEFFFE, 0xEFFFF, // [NONCHARACTER CODE POINTS]
28002800
0xFFFFE, 0xFFFFF, // [NONCHARACTER CODE POINTS]
28012801
0x10FFFE, 0x10FFFF, // [NONCHARACTER CODE POINTS]
2802-
};
2802+
];
28032803

28042804
/// <summary>
28052805
/// C.5 Surrogate codes.
28062806
/// </summary>
2807-
public static readonly List<int> C5 = new ()
2808-
{
2807+
public static readonly List<int> C5 =
2808+
[
28092809
0xD800, 0xDFFF, // [SURROGATE CODES]
2810-
};
2810+
];
28112811

28122812
/// <summary>
28132813
/// C.6 Inappropriate for plain text.
28142814
/// </summary>
2815-
public static readonly List<int> C6 = new ()
2816-
{
2815+
public static readonly List<int> C6 =
2816+
[
28172817
0xFFF9, 0xFFF9, // INTERLINEAR ANNOTATION ANCHOR
28182818
0xFFFA, 0xFFFA, // INTERLINEAR ANNOTATION SEPARATOR
28192819
0xFFFB, 0xFFFB, // INTERLINEAR ANNOTATION TERMINATOR
28202820
0xFFFC, 0xFFFC, // OBJECT REPLACEMENT CHARACTER
28212821
0xFFFD, 0xFFFD, // REPLACEMENT CHARACTER
2822-
};
2822+
];
28232823

28242824
/// <summary>
28252825
/// C.7 Inappropriate for canonical representation.
28262826
/// </summary>
2827-
public static readonly List<int> C7 = new ()
2828-
{
2827+
public static readonly List<int> C7 =
2828+
[
28292829
0x2FF0, 0x2FFB, // [IDEOGRAPHIC DESCRIPTION CHARACTERS]
2830-
};
2830+
];
28312831

28322832
/// <summary>
28332833
/// C.8 Change display properties or are deprecated.
28342834
/// </summary>
2835-
public static readonly List<int> C8 = new ()
2836-
{
2835+
public static readonly List<int> C8 =
2836+
[
28372837
0x0340, 0x0340, // COMBINING GRAVE TONE MARK
28382838
0x0341, 0x0341, // COMBINING ACUTE TONE MARK
28392839
0x200E, 0x200E, // LEFT-TO-RIGHT MARK
@@ -2849,22 +2849,22 @@ internal static class Tables
28492849
0x206D, 0x206D, // ACTIVATE ARABIC FORM SHAPING
28502850
0x206E, 0x206E, // NATIONAL DIGIT SHAPES
28512851
0x206F, 0x206F, // NOMINAL DIGIT SHAPES
2852-
};
2852+
];
28532853

28542854
/// <summary>
28552855
/// C.9 Tagging characters.
28562856
/// </summary>
2857-
public static readonly List<int> C9 = new ()
2858-
{
2857+
public static readonly List<int> C9 =
2858+
[
28592859
0xE0001, 0xE0001, // LANGUAGE TAG
28602860
0xE0020, 0xE007F, // [TAGGING CHARACTERS]
2861-
};
2861+
];
28622862

28632863
/// <summary>
28642864
/// D.1 Characters with bidirectional property "R" or "AL".
28652865
/// </summary>
2866-
public static readonly List<int> D1 = new ()
2867-
{
2866+
public static readonly List<int> D1 =
2867+
[
28682868
0x05BE, 0x05BE,
28692869
0x05C0, 0x05C0,
28702870
0x05C3, 0x05C3,
@@ -2899,13 +2899,13 @@ internal static class Tables
28992899
0xFDF0, 0xFDFC,
29002900
0xFE70, 0xFE74,
29012901
0xFE76, 0xFEFC,
2902-
};
2902+
];
29032903

29042904
/// <summary>
29052905
/// D.2 Characters with bidirectional property "L".
29062906
/// </summary>
2907-
public static readonly List<int> D2 = new ()
2908-
{
2907+
public static readonly List<int> D2 =
2908+
[
29092909
0x0041, 0x005A,
29102910
0x0061, 0x007A,
29112911
0x00AA, 0x00AA,
@@ -3266,6 +3266,7 @@ internal static class Tables
32663266
0x2F800, 0x2FA1D,
32673267
0xF0000, 0xFFFFD,
32683268
0x100000, 0x10FFFD,
3269-
};
3269+
];
3270+
32703271
}
32713272
}

src/Ubiety.Stringprep.Core/Generated/Tables.tt

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@ namespace Ubiety.Stringprep.Core.Generated
6868
}
6969
else if (Regex.IsMatch(line, "^----- End Table .*? -----$"))
7070
{
71-
OutputEndTable();
71+
switch(context)
72+
{
73+
case 'A':
74+
case 'C':
75+
case 'D':
76+
EndIntTable();
77+
break;
78+
case 'B':
79+
EndDictionaryTable();
80+
break;
81+
}
7282
}
7383
else if (Regex.IsMatch(line, "^----- Start Table .*? -----$"))
7484
{
@@ -130,7 +140,6 @@ namespace Ubiety.Stringprep.Core.Generated
130140
#>
131141
}
132142
}
133-
134143
<#+
135144
private void OutputDocComment(string comment)
136145
{
@@ -146,7 +155,7 @@ namespace Ubiety.Stringprep.Core.Generated
146155
private void DictionaryTable(string name)
147156
{
148157
#>
149-
public static readonly Dictionary<int, int[]> <#= name #> = new ()
158+
public static readonly Dictionary<int, int[]> <#= name #> = new()
150159
{
151160
<#+
152161
}
@@ -156,8 +165,8 @@ namespace Ubiety.Stringprep.Core.Generated
156165
private void IntTable(string name)
157166
{
158167
#>
159-
public static readonly List<int> <#= name #> = new ()
160-
{
168+
public static readonly List<int> <#= name #> =
169+
[
161170
<#+
162171
}
163172
#>
@@ -200,13 +209,21 @@ namespace Ubiety.Stringprep.Core.Generated
200209
}
201210
}
202211
#>
203-
204212
<#+
205-
private void OutputEndTable()
213+
private void EndDictionaryTable()
206214
{
207215
#>
208216
};
209217

218+
<#+
219+
}
220+
#>
221+
<#+
222+
private void EndIntTable()
223+
{
224+
#>
225+
];
226+
210227
<#+
211228
}
212229
#>

src/Ubiety.Stringprep.Core/MappingTableBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal class MappingTableBuilder(params IDictionary<int, int[]>[] baseTables)
4242
private readonly List<IDictionary<int, int[]>> _baseTables = [.. baseTables];
4343
private readonly List<IDictionary<int, int[]>> _inclusions = [];
4444
private readonly List<int> _removals = [];
45-
private readonly List<(List<int> values, int[] replacements)> _valueRangeBaseTables = [];
45+
private readonly List<(List<int> Values, int[] Replacements)> _valueRangeBaseTables = [];
4646

4747
/// <summary>
4848
/// Add value range table to mapping.
@@ -122,8 +122,8 @@ public IMappingTable Compile()
122122

123123
mappingTables.AddRange(
124124
from t in _valueRangeBaseTables
125-
let valueRangeTable = ValueRangeCompiler.Compile([t.values], [], _removals)
126-
select new ValueRangeMappingTable(new ValueRangeTable(valueRangeTable), t.replacements));
125+
let valueRangeTable = ValueRangeCompiler.Compile([t.Values], [], _removals)
126+
select new ValueRangeMappingTable(new ValueRangeTable(valueRangeTable), t.Replacements));
127127

128128
return new CompositeMappingTable(mappingTables);
129129
}

src/Ubiety.Stringprep.Core/Ubiety.Stringprep.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
26+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
2727
<PrivateAssets>all</PrivateAssets>
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2929
</PackageReference>

src/Ubiety.Stringprep.Core/ValueRangeCompiler.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,29 +180,6 @@ private static List<int> DoInclude(List<int> list, IList<int> inclusions)
180180

181181
private static List<int> DoRemove(List<int> list, IList<int> removals)
182182
{
183-
/* for (var i = 0; i < removals.Count; i += 2)
184-
{
185-
var j = 0;
186-
while (j < list.Count)
187-
{
188-
if (removals[i] == list[j] || (removals[i] < list[j] && (i == 0 || removals[i] > list[j - 1])))
189-
{
190-
list.RemoveAt(j--);
191-
CloseRemove(list, removals, ref i, ref j);
192-
}
193-
else if (removals[i] > list[j] && removals[i] < list[j + 1])
194-
{
195-
list.Insert(++j, removals[i] - 1);
196-
CloseRemove(list, removals, ref i, ref j);
197-
}
198-
else
199-
{
200-
j += 2;
201-
}
202-
}
203-
}
204-
205-
return list; */
206183
for (var i = 0; i < removals.Count; i += 2)
207184
{
208185
for (var j = 0; j < list.Count; j += 2)

0 commit comments

Comments
 (0)