-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBugChecks.cs
More file actions
51 lines (41 loc) · 1.47 KB
/
Copy pathBugChecks.cs
File metadata and controls
51 lines (41 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JSIL.Internal {
public static class BugChecks {
internal class MyKey {
public readonly int HashCode;
public MyKey (int hashCode) {
HashCode = hashCode;
}
public override bool Equals (object obj) {
return Object.ReferenceEquals(this, obj);
}
public override int GetHashCode () {
return HashCode;
}
}
private static void Fail (string message) {
Console.Error.WriteLine("Bug check failed: {0}", message);
throw new PlatformNotSupportedException(message);
}
public static void RunBugChecks () {
BrokenConcurrentDictionary();
}
public static void BrokenConcurrentDictionary () {
const string msg = "Broken ConcurrentDictionary: https://bugzilla.xamarin.com/show_bug.cgi?id=6225";
var keyA = new MyKey(1);
var keyB = new MyKey(1);
var dict = new ConcurrentDictionary<MyKey, string>(1, 2);
if (!dict.TryAdd(keyA, "a"))
Fail(msg);
string foundValue;
if (!dict.TryGetValue(keyA, out foundValue) || foundValue != "a")
Fail(msg);
if (dict.TryGetValue(keyB, out foundValue))
Fail(msg);
}
}
}