@@ -28,31 +28,22 @@ public static class ExceptionSerializer
2828
2929 public static string Serialize ( System . Exception exception , string id , string userId , string logs )
3030 {
31- var error = CreateModelExceptionAndBinaries ( exception ) ;
32- var report = new ErrorReport
33- {
34- Id = id ,
35- UserId = userId ,
36- ApplicationVersion = _service . ApplicationVersion2 ,
37- ApplicationArchitecture = Package . Current . Id . Architecture . ToString ( ) ,
38- SystemVersion = _service . SystemVersion2 ,
39- DeviceModel = _service . DeviceModel ,
40- Type = error . Exception . Type ,
41- Message = error . Exception . Message ,
42- ExitPoint = error . Exception . StackTrace ,
43- StackTrace = error ,
44- LogTail = logs ,
45- GroupHash = error . Hash ,
46- Time = MonotonicUnixTime . Now ,
47- LaunchTime = WatchDog . LaunchTime
48- } ;
31+ var hashBuilder = new StringBuilder ( ) ;
32+ var error = CreateModelExceptionAndBinaries ( exception , hashBuilder ) ;
4933
50- return JsonSerializer . Serialize ( report , ErrorJsonContext . Default . ErrorReport ) ;
34+ return Serialize ( error , id , userId , logs , hashBuilder ) ;
5135 }
5236
5337 public static string Serialize ( FatalError exception , string id , string userId , string logs )
5438 {
55- var error = CreateModelExceptionAndBinaries ( exception ) ;
39+ var hashBuilder = new StringBuilder ( ) ;
40+ var error = CreateModelExceptionAndBinaries ( exception , hashBuilder ) ;
41+
42+ return Serialize ( error , id , userId , logs , hashBuilder ) ;
43+ }
44+
45+ private static string Serialize ( ErrorExceptionAndBinaries error , string id , string userId , string logs , StringBuilder hashBuilder )
46+ {
5647 var report = new ErrorReport
5748 {
5849 Id = id ,
@@ -66,39 +57,37 @@ public static string Serialize(FatalError exception, string id, string userId, s
6657 ExitPoint = error . Exception . StackTrace ,
6758 StackTrace = error ,
6859 LogTail = logs ,
69- GroupHash = error . Hash ,
7060 Time = MonotonicUnixTime . Now ,
7161 LaunchTime = WatchDog . LaunchTime
7262 } ;
7363
64+ hashBuilder . Append ( report . ApplicationVersion ) ;
65+ report . GroupHash = ComputeHash ( hashBuilder . ToString ( ) ) ;
66+
7467 return JsonSerializer . Serialize ( report , ErrorJsonContext . Default . ErrorReport ) ;
7568 }
7669
77- public static ErrorExceptionAndBinaries CreateModelExceptionAndBinaries ( System . Exception exception )
70+ private static ErrorExceptionAndBinaries CreateModelExceptionAndBinaries ( System . Exception exception , StringBuilder hashBuilder )
7871 {
7972 var binaries = new Dictionary < long , ExceptionBinary > ( ) ;
80- var hashBuilder = new StringBuilder ( ) ;
8173 var modelException = ProcessException ( exception , null , binaries , hashBuilder ) ;
8274
8375 return new ErrorExceptionAndBinaries
8476 {
8577 Binaries = binaries . Count > 0 ? binaries . Values . ToList ( ) : null ,
86- Exception = modelException ,
87- Hash = ComputeHash ( hashBuilder . ToString ( ) )
78+ Exception = modelException
8879 } ;
8980 }
9081
91- public static ErrorExceptionAndBinaries CreateModelExceptionAndBinaries ( FatalError exception )
82+ private static ErrorExceptionAndBinaries CreateModelExceptionAndBinaries ( FatalError exception , StringBuilder hashBuilder )
9283 {
9384 var binaries = new Dictionary < long , ExceptionBinary > ( ) ;
94- var hashBuilder = new StringBuilder ( ) ;
9585 var modelException = ProcessException ( exception , binaries , hashBuilder ) ;
9686
9787 return new ErrorExceptionAndBinaries
9888 {
9989 Binaries = binaries . Count > 0 ? binaries . Values . ToList ( ) : null ,
100- Exception = modelException ,
101- Hash = ComputeHash ( hashBuilder . ToString ( ) )
90+ Exception = modelException
10291 } ;
10392 }
10493
@@ -179,7 +168,7 @@ void AppendHash(ExceptionBinary binary)
179168 }
180169 else
181170 {
182- hashBuilder . Append ( binary . StartAddress ) ;
171+ hashBuilder . Append ( binary . Name ) ;
183172 }
184173 }
185174
@@ -245,7 +234,7 @@ void AppendHash(ExceptionBinary binary)
245234 }
246235 else
247236 {
248- hashBuilder . Append ( binary . StartAddress ) ;
237+ hashBuilder . Append ( binary . Name ) ;
249238 }
250239 }
251240
@@ -657,9 +646,6 @@ public partial class ErrorExceptionAndBinaries
657646
658647 [ JsonPropertyName ( "exception" ) ]
659648 public ExceptionModel Exception { get ; set ; }
660-
661- [ JsonIgnore ]
662- public string Hash { get ; set ; }
663649 }
664650
665651 public partial class ExceptionModel
0 commit comments