3 using System
.Runtime
.CompilerServices
;
4 using System
.Reflection
;
5 using System
.Web
.Script
.Serialization
;
12 var monoType
= Type
.GetType ("Mono.Runtime", false);
13 var convert
= monoType
.GetMethod("DumpStateSingle", BindingFlags
.NonPublic
| BindingFlags
.Static
);
14 var output
= (Tuple
<String
, ulong, ulong>) convert
.Invoke(null, Array
.Empty
<object> ());
15 var checker
= new JavaScriptSerializer ();
17 Console
.WriteLine ("Validating: {0}", output
.Item1
);
18 checker
.DeserializeObject (output
.Item1
);
24 var monoType
= Type
.GetType ("Mono.Runtime", false);
25 var m
= monoType
.GetMethod("EnableMicrosoftTelemetry", BindingFlags
.NonPublic
| BindingFlags
.Static
);
27 // This leads to open -a /bin/cat, which errors out, but errors
28 // in invoking merp are only logged errors, not fatal assertions.
29 var merpGUIPath
= "/bin/cat";
30 var appBundleId
= "com.xam.Minimal";
31 var appSignature
= "Test.Xam.Minimal";
32 var appVersion
= "123456";
33 var eventType
= "AppleAppCrash";
34 var appPath
= "/where/mono/lives";
37 var m_params
= new object[] { appBundleId, appSignature, appVersion, merpGUIPath, eventType, appPath, configDir }
;
39 m
.Invoke(null, m_params
);
41 var add_method
= monoType
.GetMethod("AnnotateMicrosoftTelemetry", BindingFlags
.NonPublic
| BindingFlags
.Static
);
42 var add_params
= new object[] { "sessionId", "12345" }
;
43 add_method
.Invoke(null, add_params
);
46 throw new Exception ("");
47 } catch (Exception exc
) {
48 var send
= monoType
.GetMethod("SendExceptionToTelemetry", BindingFlags
.NonPublic
| BindingFlags
.Static
);
49 var send_params
= new object[] {exc}
;
51 bool caught_expected_exception
= false;
53 send
.Invoke(null, send_params
);
54 } catch (Exception exc2
) {
55 if (exc2
.InnerException
!= null && exc2
.InnerException
.Message
== "We were unable to start the Microsoft Error Reporting client.")
56 caught_expected_exception
= true;
58 throw new Exception (String
.Format ("Got exception from Merp icall with wrong message {0}", exc2
.InnerException
!= null ? exc2
.InnerException
.Message
: exc2
.Message
));
62 var xmlFilePath
= String
.Format("{0}CustomLogsMetadata.xml", configDir
);
63 var paramsFilePath
= String
.Format("{0}MERP.uploadparams.txt", configDir
);
64 var crashFilePath
= String
.Format("{0}lastcrashlog.txt", configDir
);
66 // Fixme: Maybe parse these json files rather than
67 // just checking they exist
68 var xmlFileExists
= File
.Exists (xmlFilePath
);
69 var paramsFileExists
= File
.Exists (paramsFilePath
);
70 var crashFileExists
= File
.Exists (crashFilePath
);
73 File
.ReadAllText (xmlFilePath
);
74 File
.Delete (xmlFilePath
);
77 if (paramsFileExists
) {
78 File
.ReadAllText (paramsFilePath
);
79 File
.Delete (paramsFilePath
);
82 if (crashFileExists
) {
83 var crashFile
= File
.ReadAllText (crashFilePath
);
84 //File.Delete (crashFilePath);
86 var checker
= new JavaScriptSerializer ();
88 // Throws if invalid json
89 Console
.WriteLine("Validating: {0}", crashFile
);
90 checker
.DeserializeObject (crashFile
);
94 throw new Exception (String
.Format ("Did not produce {0}", xmlFilePath
));
96 if (!paramsFileExists
)
97 throw new Exception (String
.Format ("Did not produce {0}", paramsFilePath
));
100 throw new Exception (String
.Format ("Did not produce {0}", crashFilePath
));
103 public static void Main ()
105 JsonValidateState ();