| commit 73: | 399150f97395 |
| parent 72: | 991369f930f9 |
| branch: | default |
Suppress CodeAnalysis warning in CaseFoldTable.cs
Changed (Δ307 bytes):
raw changeset »
FParsecCS/CaseFoldTable.cs (6 lines added, 2 lines removed)
Up to file-list FParsecCS/CaseFoldTable.cs:
3 |
3 |
|
4 |
4 |
using System; |
5 |
5 |
using System.Runtime.InteropServices; |
6 |
using System.Diagnostics; |
|
7 |
using System.Diagnostics.CodeAnalysis; |
|
6 |
8 |
|
7 |
9 |
namespace FParsec { |
8 |
10 |
|
| … | … | @@ -18,7 +20,7 @@ internal static class CaseFoldTable { |
18 |
20 |
} |
19 |
21 |
|
20 |
22 |
private static char[] CreateFoldedCharsArray() { |
21 |
|
|
23 |
Debug.Assert(oneToOneMappings.Length%2 == 0); |
|
22 |
24 |
var table = new char[0x10000]; |
23 |
25 |
for (int i = 0; i < table.Length; ++i) |
24 |
26 |
table[i] = (char)i; |
| … | … | @@ -31,6 +33,8 @@ internal static class CaseFoldTable { |
31 |
33 |
public static char[] FoldedCharsArray; |
32 |
34 |
private static GCHandle FoldedCharsHandle; |
33 |
35 |
|
36 |
[SuppressMessage("Microsoft.Reliability", "CA2002:DoNotLockOnObjectsWithWeakIdentity", |
|
37 |
Justification = "The string oneToOneMappings is private and obscure enough that we don't have to worry about a calling or called method locking the same string.")] |
|
34 |
38 |
public static unsafe char* Initialize() { |
35 |
39 |
if (FoldedChars != null) return FoldedChars; |
36 |
40 |
lock (oneToOneMappings) { |
| … | … | @@ -60,7 +64,7 @@ internal static class CaseFoldTable { |
60 |
64 |
|
61 |
65 |
private static unsafe char[] CreateFoldedCharsArray() { |
62 |
66 |
int n = oneToOneMappings.Length; |
63 |
|
|
67 |
Debug.Assert(n%2 == 0); |
|
64 |
68 |
var tableArray = new char[0x10000]; |
65 |
69 |
fixed (char* table = tableArray) |
66 |
70 |
fixed (char* mappings = oneToOneMappings) { |
