Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortherzok <marius.ungureanu@xamarin.com>2019-12-08 09:04:06 +0300
committermonojenkins <jo.shields+jenkins@xamarin.com>2020-01-15 14:54:36 +0300
commitd8237ec4ee9dc2f58b73f469cc6862fd0d0772c2 (patch)
tree7e567074ba86a06104bf9de923b30e8e1132b1cd
parent5ca981ef55229bc73a579ffaa7695ff6990ab829 (diff)
Switch UnitTesting binary store to json
Also switched collections to List<T>, CollectionBase does not deserialize properly
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj5
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs28
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs17
3 files changed, 15 insertions, 35 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj
index 8d42275ca8..d768bb8c33 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj
+++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj
@@ -48,11 +48,6 @@
<Name>Xwt</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
- <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
- <Name>ICSharpCode.NRefactory</Name>
- <Private>False</Private>
- </ProjectReference>
<ProjectReference Include="..\MonoDevelop.DotNetCore\MonoDevelop.DotNetCore.csproj">
<Project>{6868153E-41EA-43A4-A81A-C1E7256373F7}</Project>
<Name>MonoDevelop.DotNetCore</Name>
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs
index ba03343c15..43bba4ebe1 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs
@@ -401,37 +401,21 @@ namespace MonoDevelop.UnitTesting
}
[Serializable]
- public class TestRecordCollection: CollectionBase
+ public class TestRecordCollection: List<TestRecord>
{
- public TestRecord this [int n] {
- get { return (TestRecord) ((IList)this) [n]; }
- }
-
public TestRecord this [string name] {
get {
- for (int n=0; n<List.Count; n++)
- if (((TestRecord)List [n]).Name == name)
- return (TestRecord) List [n];
+ foreach (var value in this) {
+ if (value.Name == name)
+ return value;
+ }
return null;
}
}
-
- public void Add (TestRecord test)
- {
- ((IList)this).Add (test);
- }
}
[Serializable]
- public class UnitTestResultCollection: CollectionBase
+ public class UnitTestResultCollection: List<UnitTestResult>
{
- public UnitTestResult this [int n] {
- get { return (UnitTestResult) ((IList)this) [n]; }
- }
-
- public void Add (UnitTestResult test)
- {
- ((IList)this).Add (test);
- }
}
}
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs
index 449ce82484..d57c51d0f7 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs
@@ -26,7 +26,7 @@
using System;
using System.Xml.Serialization;
using System.IO;
-using ICSharpCode.NRefactory.Utils;
+using Newtonsoft.Json;
namespace MonoDevelop.UnitTesting
{
@@ -54,7 +54,7 @@ namespace MonoDevelop.UnitTesting
const string binaryExtension = ".test-result";
const string xmlExtension = ".xml";
- FastSerializer fastSerializer = new FastSerializer();
+ JsonSerializer jsonSerializer = JsonSerializer.CreateDefault ();
XmlSerializer xmlSerializer;
XmlSerializer XmlSerializer {
@@ -72,9 +72,10 @@ namespace MonoDevelop.UnitTesting
// no need for xml serialization because next time it will be
// deserialized from the binary format
string binaryFilePath = GetBinaryFilePath (xmlFilePath);
- using (var stream = File.OpenWrite(binaryFilePath)) {
- fastSerializer.Serialize (stream, testRecord);
- }
+ using var stream = File.OpenWrite (binaryFilePath);
+ using var writer = new StreamWriter (stream);
+
+ jsonSerializer.Serialize (writer, testRecord);
}
public TestRecord Deserialize (string xmlFilePath)
@@ -83,9 +84,9 @@ namespace MonoDevelop.UnitTesting
// deserialize from the binary format if the file exists
if (File.Exists(binaryFilePath)) {
- using (var stream = File.OpenRead (binaryFilePath)) {
- return (TestRecord) fastSerializer.Deserialize (stream);
- }
+ using var stream = File.OpenRead (binaryFilePath);
+ using var reader = new JsonTextReader (new StreamReader (stream));
+ return jsonSerializer.Deserialize<TestRecord> (reader);
}
// deserialize from xml if the file exists