Skip to content

Commit 780275a

Browse files
committed
refactor: change ToString from JSON serialization to formatted text
1 parent 023a2df commit 780275a

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

deadlock-dotnet-sdk/Domain/SafeFileHandleEx.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
using System.Data;
12
using System.Runtime.InteropServices;
2-
using System.Text.Json;
33
using Windows.Win32.Foundation;
44
using Windows.Win32.Storage.FileSystem;
55
using static deadlock_dotnet_sdk.Domain.NativeMethods;
@@ -110,6 +110,30 @@ private unsafe string TryGetFinalPath()
110110

111111
public override string ToString()
112112
{
113-
return JsonSerializer.Serialize(this, options: new() { WriteIndented = true });
113+
string[] exLog = ExceptionLog.Cast<string>().ToArray();
114+
for (int i = 0; i < exLog.Length; i++)
115+
{
116+
exLog[i] = $" {exLog[i]}".Replace("\n", "\n ");
117+
}
118+
119+
return @$"{GetType().Name} hash:{GetHashCode()}
120+
{nameof(CreatorBackTraceIndex)} : {CreatorBackTraceIndex}
121+
{nameof(FileFullPath)} : {FileFullPath}
122+
{nameof(IsDirectory)} : {IsDirectory}
123+
{nameof(FileName)} : {FileName}
124+
{nameof(GrantedAccess)} : {GrantedAccess}
125+
{nameof(handle)} : {handle}
126+
{nameof(HandleObjectType)} : {HandleObjectType}
127+
{nameof(HandleValue)} : {HandleValue}
128+
{nameof(IsClosed)} : {IsClosed}
129+
{nameof(IsFileHandle)} : {IsFileHandle}
130+
{nameof(IsInvalid)} : {IsInvalid}
131+
{nameof(Object)} : {Object}
132+
{nameof(ProcessCommandLine)} : {ProcessCommandLine}
133+
{nameof(ProcessId)} : {ProcessId}
134+
{nameof(ProcessMainModulePath)} : {ProcessMainModulePath}
135+
{nameof(ProcessName)} : {ProcessName}
136+
{nameof(ExceptionLog)} : ...
137+
" + exLog;
114138
}
115139
}

0 commit comments

Comments
 (0)