1- using System ;
1+ using BenchmarkDotNet . Serialization ;
22using System . Linq ;
3- using SimpleJson ;
3+ using System . Text . Json . Serialization ;
44
55#nullable enable
66
77namespace BenchmarkDotNet . Disassemblers
88{
99 internal struct ClrMdArgs ( int processId , string typeName , string methodName , bool printSource , int maxDepth , string syntax , string tfm , string [ ] filters , string resultsPath = "" )
1010 {
11+ [ JsonIgnore ]
1112 internal int ProcessId = processId ;
12- internal string TypeName = typeName ;
13+
14+ [ JsonIgnore ]
15+ internal string TypeName = typeName ?? "" ;
16+
17+ [ JsonInclude ]
1318 internal string MethodName = methodName ;
19+
20+ [ JsonInclude ]
1421 internal bool PrintSource = printSource ;
22+
23+ [ JsonInclude ]
1524 internal int MaxDepth = methodName == DisassemblerConstants . DisassemblerEntryMethodName && maxDepth != int . MaxValue ? maxDepth + 1 : maxDepth ;
25+
26+ [ JsonInclude ]
1627 internal string [ ] Filters = filters ;
28+
29+ [ JsonInclude ]
1730 internal string Syntax = syntax ;
31+
32+ [ JsonInclude ]
1833 internal string TargetFrameworkMoniker = tfm ;
34+
35+ [ JsonInclude ]
1936 internal string ResultsPath = resultsPath ;
2037
2138 internal static ClrMdArgs FromArgs ( string [ ] args )
@@ -30,46 +47,5 @@ internal static ClrMdArgs FromArgs(string[] args)
3047 tfm : args [ 7 ] ,
3148 filters : [ .. args . Skip ( 8 ) ]
3249 ) ;
33-
34- internal readonly string Serialize ( )
35- {
36- SimpleJsonSerializer . CurrentJsonSerializerStrategy . Indent = false ;
37- var jsonObject = new JsonObject ( )
38- {
39- [ nameof ( MethodName ) ] = MethodName ,
40- [ nameof ( PrintSource ) ] = PrintSource ,
41- [ nameof ( MaxDepth ) ] = MaxDepth ,
42- [ nameof ( Syntax ) ] = Syntax ,
43- [ nameof ( TargetFrameworkMoniker ) ] = TargetFrameworkMoniker ,
44- [ nameof ( ResultsPath ) ] = ResultsPath ,
45- } ;
46- var filters = new JsonArray ( Filters . Length ) ;
47- foreach ( var filter in Filters )
48- {
49- filters . Add ( filter ) ;
50- }
51- jsonObject [ nameof ( Filters ) ] = filters ;
52- return jsonObject . ToString ( ) ;
53- }
54-
55- internal void Deserialize ( string ? json )
56- {
57- var jsonObject = SimpleJsonSerializer . DeserializeObject < JsonObject > ( json ) ;
58- if ( jsonObject == null )
59- return ;
60-
61- MethodName = ( string ) jsonObject [ nameof ( MethodName ) ] ;
62- PrintSource = ( bool ) jsonObject [ nameof ( PrintSource ) ] ;
63- MaxDepth = Convert . ToInt32 ( jsonObject [ nameof ( MaxDepth ) ] ) ;
64- Syntax = ( string ) jsonObject [ nameof ( Syntax ) ] ;
65- TargetFrameworkMoniker = ( string ) jsonObject [ nameof ( TargetFrameworkMoniker ) ] ;
66- ResultsPath = ( string ) jsonObject [ nameof ( ResultsPath ) ] ;
67- var filters = ( JsonArray ) jsonObject [ nameof ( Filters ) ] ;
68- Filters = new string [ filters . Count ] ;
69- for ( int i = 0 ; i < filters . Count ; ++ i )
70- {
71- Filters [ i ] = ( string ) filters [ i ] ;
72- }
73- }
7450 }
7551}
0 commit comments