-
Notifications
You must be signed in to change notification settings - Fork 16
/
Guardian.cs
136 lines (113 loc) · 3.89 KB
/
Guardian.cs
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
namespace RoslynDom.Common
{
public class Guardian
{
private static Guardian _inform;
private Guardian() { }
public static Guardian Assert
{
get
{
if (_inform == null)
{ _inform = new Guardian(); }
return _inform;
}
}
public void IsTrue(bool test,
[CallerMemberName] string callerName = "",
[CallerLineNumber] int callerLineNumber = 0)
{
IsTrue(test, "", callerName, callerLineNumber);
}
public void IsTrue(bool test, string message,
[CallerMemberName] string callerName = "",
[CallerLineNumber] int callerLineNumber = 0)
{
if (!test) throw new NotImplementedException();
}
public void IsGreaterThan(int expected, int test,
[CallerMemberName] string callerName = "",
[CallerLineNumber] int callerLineNumber = 0)
{
IsGreaterThan(expected, test, "", callerName, callerLineNumber);
}
public void IsGreaterThan(int expected, int test, string message,
[CallerMemberName] string callerName = "",
[CallerLineNumber] int callerLineNumber = 0)
{
if (test <= expected) throw new NotImplementedException();
}
public void AccessedProviderBeforeInitialization(Type type)
{
throw new InvalidOperationException();
}
public void BadContainer()
{
throw new InvalidOperationException();
}
public void FactoryExists(IRDomFactory factory, Type type, IDom item)
{
if (factory == null)
{ throw new InvalidOperationException(); }
}
public void RDomHasOneCloneContructor(IEnumerable<ConstructorInfo> constructors, Type type)
{
constructors = constructors.ToList();
if (!constructors.Any())
{ throw new InvalidOperationException("Missing constructor for clone"); }
if (constructors.Count() > 1)
{ throw new InvalidOperationException("Multiple clone constructors found"); }
}
public void NeitherCreateFromNorListOverridden(Type type, SyntaxNode item)
{ throw new InvalidOperationException(); }
public void UnreachableFactoryDetected(string fullName)
{
throw new NotImplementedException();
}
internal void DuplicateFactories(string syntaxNodeName, string ignoredFactoryName)
{
Console.WriteLine(string.Format("Duplicate factories {0} : {1}", syntaxNodeName, ignoredFactoryName ));
}
/// <summary>
/// Call to inform of an unexpected null.
/// </summary>
/// <param name="value">Value to check for null</param>
/// <param name="name">Name of value where practical, generally retrieved via new nameof operator which has a noop implementation in most locations</param>
/// <remarks>
/// Please do not call on value types because this results in boxing
/// </remarks>
public void IsNotNull<T>(
T value,
string name,
[CallerMemberName] string callerName = "",
[CallerLineNumber] int callerLineNumber = 0)
where T : class
{
if (value == null) throw new NotImplementedException();
}
internal void FactoryNotFound(SyntaxNode node)
{
throw new NotImplementedException();
}
internal void FactoryNotFound(IDom item)
{
throw new InvalidOperationException();
}
public static void AmbiguousType(string name)
{
throw new NotImplementedException();
}
public static void TypeNotFound(string name)
{
throw new NotImplementedException();
}
}
}