Skip to content

Commit 14abbab

Browse files
committed
nullable types support, new dumping for - datetime objects, events, event handlers, fixed dictionary dumping
1 parent 887ff8f commit 14abbab

17 files changed

Lines changed: 389 additions & 165 deletions

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = tab
7+
tab_width = 4
8+
charset = utf-8
9+
end_of_line = lf
10+
insert_final_newline = false
11+
trim_trailing_whitespace = false

Completers/Detector.cs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Data;
66
using System.Reflection;
77
using System.Runtime.InteropServices;
8+
using System.Text;
89

910
namespace Desharp.Completers {
1011
/// <summary>
@@ -24,6 +25,15 @@ public class Detector {
2425
/// Common `System.Delegate` `Type` object instance
2526
/// </summary>
2627
protected static Type delegateType = typeof(System.Delegate);
28+
/// <summary>
29+
/// `System.Tuple` string value (backwards compatibility for .NET 4.0+)
30+
/// </summary>
31+
protected static string systemTupleStr = "System.Tuple";
32+
/// <summary>
33+
/// `System.Tuple` string value length (backwards compatibility for .NET 4.0+)
34+
/// </summary>
35+
protected static int systemTupleStrLen = 12;
36+
2737
/// <summary>
2838
/// True if value is sbyte | byte | short | ushort | int | uint | long | ulong | float | double | decimal | char | bool | string | object.
2939
/// </summary>
@@ -32,7 +42,7 @@ public class Detector {
3242
/// <returns>True if `obj` is any primitive value except `enum`, `struct` and `unmanaged`.</returns>
3343
public static bool IsPrimitiveType (ref object obj, ref Type objType) {
3444
// https://docs.microsoft.com/en-US/dotnet/api/system.type.isprimitive?view=netframework-4.8
35-
if (objType.IsPrimitive || obj is string || obj is decimal || obj is System.Decimal) return true; // decimal and string is not primitive
45+
if (objType.IsPrimitive || obj is string || obj is decimal || obj is System.DBNull) return true; // decimal and string is not primitive
3646
return false;
3747
}
3848
/// <summary>
@@ -69,9 +79,9 @@ public static bool IsDictionary (ref object obj, ref Type objType) {
6979
if (objType.IsGenericType && objType.GetGenericTypeDefinition() == typeof(Dictionary<,>)) {
7080
return true;
7181
} else if (
72-
objType.GetProperty("Count") is PropertyInfo &&
73-
objType.GetProperty("Keys") is PropertyInfo &&
74-
objType.GetProperty("Values") is PropertyInfo
82+
objType.GetProperty("Count", BindingFlags.Instance | BindingFlags.Public) is PropertyInfo &&
83+
objType.GetProperty("Keys", BindingFlags.Instance | BindingFlags.Public) is PropertyInfo &&
84+
objType.GetProperty("Values", BindingFlags.Instance | BindingFlags.Public) is PropertyInfo
7585
) {
7686
return true;
7787
}
@@ -105,7 +115,7 @@ public static bool IsEnum (ref object obj, ref Type objType) {
105115
/// <param name="objType">Type object for value or null.</param>
106116
/// <returns>True if `obj` is `Type` object.</returns>
107117
public static bool IsTypeObject (ref object obj, ref Type objType) {
108-
if (obj is Type) return true;
118+
if (obj is _Type) return true;
109119
return false;
110120
}
111121
/// <summary>
@@ -137,7 +147,10 @@ public static bool IsCollection (ref object obj, ref Type objType) {
137147
/// <returns>True if `obj` is `System.Func&lt;,&gt;`.</returns>
138148
public static bool IsTuple(ref object obj, ref Type objType) {
139149
// this string comparison is because of backward compatibility for .NET 4.0+
140-
if (objType.FullName.IndexOf("System.Tuple") == 0) return true;
150+
//if (objType.FullName.IndexOf("System.Tuple") == 0) return true;
151+
string objTypefullName = objType.FullName;
152+
int sysTupleLen = Detector.systemTupleStrLen;
153+
if (objTypefullName.Length >= sysTupleLen && Detector.systemTupleStr == objTypefullName.Substring(0, sysTupleLen)) return true;
141154
return false;
142155
}
143156
/// <summary>
@@ -163,15 +176,24 @@ public static bool IsDelegate(ref object obj, ref Type objType) {
163176
) return true;
164177
return false;
165178
}
166-
167179
/// <summary>
168180
/// True if value is MethodInfo | PropertyInfo | FieldInfo | EventInfo | MemberInfo | ConstructorInfo.
169181
/// </summary>
170182
/// <param name="obj">Any value except null.</param>
171183
/// <param name="objType">Type object for value or null.</param>
172184
/// <returns>True if value is MethodInfo | PropertyInfo | FieldInfo | EventInfo | MemberInfo | ConstructorInfo.</returns>
173185
public static bool IsReflectionObject (ref object obj, ref Type objType) {
174-
if (obj is MemberInfo || obj is _MemberInfo) return true;
186+
if (obj is _MemberInfo) return true;
187+
return false;
188+
}
189+
/// <summary>
190+
/// True if `obj` implements `IFormattable` or if `obj` is `Stringbuilder`
191+
/// </summary>
192+
/// <param name="obj">Any value except null.</param>
193+
/// <param name="objType">Type object for value or null.</param>
194+
/// <returns>True if `obj` implements `IFormattable` or if `obj` is `Stringbuilder`</returns>
195+
public static bool IsExtraFormatedObject (ref object obj, ref Type objType) {
196+
if (obj is IFormattable || obj is StringBuilder || obj is System.Guid) return true;
175197
return false;
176198
}
177199
}

Core/Dispatcher.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,25 @@ static Dispatcher () {
103103
appRootInitialized = true;
104104
} catch {
105105
}
106+
bool exited = false;
107+
/*
108+
var bgThread = new System.Threading.Thread(new ThreadStart(delegate () {
109+
while (true) {
110+
System.Threading.Thread.Sleep(1000);
111+
if (exited) break;
112+
}
113+
}));
114+
bgThread.IsBackground = true;
115+
bgThread.Priority = ThreadPriority.Lowest;
116+
bgThread.Start();
117+
*/
106118
AppDomain.CurrentDomain.UnhandledException += delegate (object o, UnhandledExceptionEventArgs e1) {
107119
Debug.Log(e1.ExceptionObject as Exception);
120+
exited = true;
108121
if (e1.IsTerminating) Dispatcher.Disposed();
122+
Environment.Exit(1);
109123
};
110124
if (Dispatcher.LogWriteMilisecond > 0) {
111-
bool exited = false;
112125
AppDomain.CurrentDomain.ProcessExit += delegate (object o, EventArgs e2) {
113126
Dispatcher.Disposed();
114127
exited = true;

Core/Structs/DumpType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace Desharp {
22
internal struct DumpType {
3-
public string Text;
4-
public string ValueTypeCode;
5-
public string NameCssClass;
3+
internal string Text;
4+
internal string ValueTypeCode;
5+
internal string NameCssClass;
66
}
77
}

Core/Structs/ExceptionToRender.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Desharp {
44
internal struct ExceptionToRender {
5-
public Exception Exception;
6-
public Exception CausedBy;
7-
public bool Catched;
5+
internal Exception Exception;
6+
internal Exception CausedBy;
7+
internal bool Catched;
88
}
99
}

Core/Structs/FireDumpItem.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
6-
namespace Desharp {
1+
namespace Desharp {
72
internal struct FireDumpItem {
83
internal FireDumpType Type;
94
internal object Content;

Core/Structs/RenderingCollection.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Desharp {
44
internal struct RenderingCollection {
5-
public StackTraceItem? ErrorFileStackTrace;
6-
public List<StackTraceItem> AllStackTraces;
7-
public List<string[]> Headers;
8-
public bool Catched;
9-
public string ExceptionHash;
10-
public string ExceptionType;
11-
public string ExceptionMessage;
12-
public string CausedByHash;
13-
public string CausedByType;
14-
public string CausedByMessage;
5+
internal StackTraceItem? ErrorFileStackTrace;
6+
internal List<StackTraceItem> AllStackTraces;
7+
internal List<string[]> Headers;
8+
internal bool Catched;
9+
internal string ExceptionHash;
10+
internal string ExceptionType;
11+
internal string ExceptionMessage;
12+
internal string CausedByHash;
13+
internal string CausedByType;
14+
internal string CausedByMessage;
1515
}
1616
}

Core/Structs/RouteMatchedParam.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
1+
using System.Collections.Generic;
52

63
namespace Desharp {
74
internal class RouteMatchedParam {

Core/Structs/RouteTarget.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
1+
using System.Collections.Generic;
52

63
namespace Desharp {
74
internal class RouteTarget {

Core/Structs/RouteTargetArg.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
52

63
namespace Desharp {
74
internal struct RouteTargetArg {

0 commit comments

Comments
 (0)