You've already forked linux-packaging-mono
Imported Upstream version 4.2.2.29
Former-commit-id: f069081cc0821095435a845c961ae61cbbc95121
This commit is contained in:
@@ -181,8 +181,8 @@ namespace System.Runtime.Serialization
|
||||
void ReadISerializable (ClassDataContract classContract)
|
||||
{
|
||||
ConstructorInfo ctor = classContract.GetISerializableConstructor ();
|
||||
context.ReadSerializationInfo (xmlReader, classContract.UnderlyingType);
|
||||
ctor.Invoke (objectLocal, new object [] {context.GetStreamingContext ()});
|
||||
var info = context.ReadSerializationInfo (xmlReader, classContract.UnderlyingType);
|
||||
ctor.Invoke (objectLocal, new object [] {info, context.GetStreamingContext ()});
|
||||
}
|
||||
|
||||
void ReadClass (ClassDataContract classContract)
|
||||
|
@@ -469,8 +469,13 @@ namespace System.Runtime.Serialization
|
||||
PrimitiveDataContract primitiveContract = PrimitiveDataContract.GetPrimitiveDataContract(memberType);
|
||||
if (primitiveContract != null && !writeXsiType)
|
||||
primitiveContract.XmlFormatContentWriterMethod.Invoke (writer, new object [] {memberValue});
|
||||
else
|
||||
InternalSerialize(XmlFormatGeneratorStatics.InternalSerializeMethod, () => memberValue, memberType, writeXsiType);
|
||||
else {
|
||||
// InternalSerialize(XmlFormatGeneratorStatics.InternalSerializeMethod, () => memberValue, memberType, writeXsiType);
|
||||
var typeHandleValue = Type.GetTypeHandle (memberValue);
|
||||
var isDeclaredType = typeHandleValue.Equals (CodeInterpreter.ConvertValue (memberValue, memberType, Globals.TypeOfObject));
|
||||
|
||||
ctx.InternalSerialize (writer, memberValue, isDeclaredType, writeXsiType, DataContract.GetId (memberType.TypeHandle), memberType.TypeHandle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -500,22 +505,19 @@ namespace System.Runtime.Serialization
|
||||
if (isNull2) {
|
||||
XmlFormatGeneratorStatics.WriteNullMethod.Invoke (ctx, new object [] {writer, memberType, DataContract.IsTypeSerializable(memberType)});
|
||||
} else {
|
||||
InternalSerialize((isNullableOfT ? XmlFormatGeneratorStatics.InternalSerializeMethod : XmlFormatGeneratorStatics.InternalSerializeReferenceMethod),
|
||||
() => memberValue, memberType, writeXsiType);
|
||||
var typeHandleValue = Type.GetTypeHandle (memberValue);
|
||||
var isDeclaredType = typeHandleValue.Equals (CodeInterpreter.ConvertValue (memberValue, memberType, Globals.TypeOfObject));
|
||||
if (isNullableOfT)
|
||||
ctx.InternalSerialize (writer, memberValue, isDeclaredType, writeXsiType, DataContract.GetId (memberType.TypeHandle), memberType.TypeHandle);
|
||||
else
|
||||
ctx.InternalSerializeReference (writer, memberValue, isDeclaredType, writeXsiType, DataContract.GetId (memberType.TypeHandle), memberType.TypeHandle);
|
||||
//InternalSerialize((isNullableOfT ? XmlFormatGeneratorStatics.InternalSerializeMethod : XmlFormatGeneratorStatics.InternalSerializeReferenceMethod), () => memberValue, memberType, writeXsiType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InternalSerialize (MethodInfo methodInfo, Func<object> memberValue, Type memberType, bool writeXsiType)
|
||||
{
|
||||
var v = memberValue ();
|
||||
var typeHandleValue = Type.GetTypeHandle (v);
|
||||
var isDeclaredType = typeHandleValue.Equals (CodeInterpreter.ConvertValue (v, memberType, Globals.TypeOfObject));
|
||||
methodInfo.Invoke (ctx, new object [] {writer, memberValue != null ? v : null, isDeclaredType, writeXsiType, DataContract.GetId (memberType.TypeHandle), memberType.TypeHandle});
|
||||
}
|
||||
|
||||
object UnwrapNullableObject(Func<object> memberValue, ref Type memberType, out bool isNull)// Leaves !HasValue on stack
|
||||
{
|
||||
object v = memberValue ();
|
||||
|
@@ -5,10 +5,12 @@ System.Runtime.Serialization/Bug2843Test.cs
|
||||
System.Runtime.Serialization/Bug3258Test.cs
|
||||
System.Runtime.Serialization/Bug242Test.cs
|
||||
System.Runtime.Serialization/Bug695203Test.cs
|
||||
System.Runtime.Serialization/Bug36100.cs
|
||||
System.Runtime.Serialization/DataContractResolverTest.cs
|
||||
System.Runtime.Serialization/DataContractSerializerTest_DuplicateQName.cs
|
||||
System.Runtime.Serialization/DataContractSerializerTest_NullableWithDictionary.cs
|
||||
System.Runtime.Serialization/DataContractSerializerTest_InvalidCharacters.cs
|
||||
System.Runtime.Serialization/DataContractSerializerTest_ISerializable.cs
|
||||
System.Runtime.Serialization/DataContractSerializerTest.cs
|
||||
System.Runtime.Serialization/KnownTypeAttributeTest.cs
|
||||
System.Runtime.Serialization/XmlObjectSerializerTest.cs
|
||||
|
@@ -0,0 +1 @@
|
||||
0eb5fd5cac80a730d30a79b0d0fbf4155fb5ddf1
|
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// DataContractSerializerTest_ISerializable.cs
|
||||
//
|
||||
// Author:
|
||||
// Aaron Bockover <abock@xamarin.com>
|
||||
//
|
||||
// Copyright 2015 Xamarin Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Runtime.Serialization
|
||||
{
|
||||
[TestFixture]
|
||||
public class DataContractSerializerTest_ISerializable
|
||||
{
|
||||
[Serializable]
|
||||
sealed class TestClassISerializable : ISerializable
|
||||
{
|
||||
public string Foo { get; }
|
||||
|
||||
public TestClassISerializable (string foo)
|
||||
{
|
||||
Foo = foo;
|
||||
}
|
||||
|
||||
TestClassISerializable (SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
Foo = info.GetString ("foo");
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue ("foo", Foo);
|
||||
}
|
||||
}
|
||||
|
||||
// Tests that the ISerializable constructor is properly invoked, which
|
||||
// regressed when integrating MS Reference Source DCS, et. al.:
|
||||
// https://bugzilla.xamarin.com/show_bug.cgi?id=37171
|
||||
[Test]
|
||||
public void TestISerializableCtor ()
|
||||
{
|
||||
var serializer = new DataContractSerializer (
|
||||
typeof(TestClassISerializable),
|
||||
new DataContractSerializerSettings {
|
||||
DataContractResolver = new Resolver ()
|
||||
}
|
||||
);
|
||||
|
||||
var stream = new MemoryStream ();
|
||||
|
||||
var expected = new TestClassISerializable ("hello world");
|
||||
serializer.WriteObject (stream, expected);
|
||||
|
||||
stream.Flush ();
|
||||
stream.Position = 0;
|
||||
|
||||
var actual = (TestClassISerializable)serializer.ReadObject (stream);
|
||||
|
||||
Assert.AreEqual (expected.Foo, actual.Foo, "#DCS_ISer_Ctor");
|
||||
}
|
||||
|
||||
// Resolver to force DCS to serialize any type, ensuring the ISerializable
|
||||
// path will be taken for objects implementing that interface
|
||||
class Resolver : DataContractResolver
|
||||
{
|
||||
public override Type ResolveName (string typeName, string typeNamespace,
|
||||
Type declaredType, DataContractResolver knownTypeResolver)
|
||||
{
|
||||
return Type.GetType (typeNamespace == null
|
||||
? typeName
|
||||
: typeNamespace + "." + typeName
|
||||
);
|
||||
}
|
||||
|
||||
public override bool TryResolveType (Type type, Type declaredType,
|
||||
DataContractResolver knownTypeResolver,
|
||||
out XmlDictionaryString typeName,
|
||||
out XmlDictionaryString typeNamespace)
|
||||
{
|
||||
var name = type.FullName;
|
||||
var namesp = type.Namespace;
|
||||
name = name.Substring (type.Namespace.Length + 1);
|
||||
typeName = new XmlDictionaryString (XmlDictionary.Empty, name, 0);
|
||||
typeNamespace = new XmlDictionaryString (XmlDictionary.Empty, namesp, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -121,7 +121,9 @@ namespace System.Xml.Xsl
|
||||
|
||||
public void Transform (IXPathNavigable input, XsltArgumentList arguments, Stream results)
|
||||
{
|
||||
Transform (input.CreateNavigator (), arguments, results);
|
||||
using (var sw = new StreamWriter (results)) {
|
||||
Transform (input.CreateNavigator (), arguments, sw);
|
||||
}
|
||||
}
|
||||
|
||||
public void Transform (IXPathNavigable input, XmlWriter results)
|
||||
|
@@ -168,5 +168,31 @@ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-micros
|
||||
// Returns true on .NET and False on mono 2.10.2
|
||||
Assert.IsTrue (xslCompiledTransform.OutputSettings.Indent, "#1");
|
||||
}
|
||||
|
||||
[Test] // Bug 36436
|
||||
public void TransformWithXmlDocument ()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
doc.LoadXml (@"<ROOT/>");
|
||||
XmlDocument st = new XmlDocument ();
|
||||
st.LoadXml (@"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<xsl:stylesheet version=""1.0"" xmlns:vy=""Vineyard.Elements""
|
||||
xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" xmlns:xlink=""http://www.w3.org/1999/xlink"" xmlns:user=""http://www.mydomain.com/mynamespace"">
|
||||
<xsl:output method=""xml""/>
|
||||
|
||||
<xsl:param name=""os"" select=""ios""/>
|
||||
|
||||
<xsl:template match=""/ROOT"" >
|
||||
<xsl:copy/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>");
|
||||
XslCompiledTransform xsl = new XslCompiledTransform ();
|
||||
xsl.Load (st);
|
||||
|
||||
XsltArgumentList args = new XsltArgumentList ();
|
||||
|
||||
MemoryStream mstr = new MemoryStream ();
|
||||
xsl.Transform (doc, args, mstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -162,6 +162,8 @@ namespace System.IO {
|
||||
|
||||
class KqueueMonitor : IDisposable
|
||||
{
|
||||
static bool initialized;
|
||||
|
||||
public int Connection
|
||||
{
|
||||
get { return conn; }
|
||||
@@ -171,6 +173,13 @@ namespace System.IO {
|
||||
{
|
||||
this.fsw = fsw;
|
||||
this.conn = -1;
|
||||
if (!initialized){
|
||||
int t;
|
||||
initialized = true;
|
||||
var maxenv = Environment.GetEnvironmentVariable ("MONO_DARWIN_WATCHER_MAXFDS");
|
||||
if (maxenv != null && Int32.TryParse (maxenv, out t))
|
||||
maxFds = t;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
@@ -625,7 +634,7 @@ namespace System.IO {
|
||||
const int F_GETPATH = 50;
|
||||
const int __DARWIN_MAXPATHLEN = 1024;
|
||||
static readonly kevent[] emptyEventList = new System.IO.kevent[0];
|
||||
const int maxFds = 200;
|
||||
int maxFds = Int32.MaxValue;
|
||||
|
||||
FileSystemWatcher fsw;
|
||||
int conn;
|
||||
|
@@ -170,6 +170,32 @@ namespace System
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Based on the Boyer–Moore string search algorithm */
|
||||
int LastIndexOf (Delegate[] haystack, Delegate[] needle)
|
||||
{
|
||||
if (haystack.Length < needle.Length)
|
||||
return -1;
|
||||
|
||||
if (haystack.Length == needle.Length) {
|
||||
for (int i = 0; i < haystack.Length; ++i)
|
||||
if (!haystack [i].Equals (needle [i]))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = haystack.Length - needle.Length, j; i >= 0;) {
|
||||
for (j = 0; needle [j].Equals (haystack [i]); ++i, ++j) {
|
||||
if (j == needle.Length - 1)
|
||||
return i - j;
|
||||
}
|
||||
|
||||
i -= j + 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected sealed override Delegate RemoveImpl (Delegate value)
|
||||
{
|
||||
if (value == null)
|
||||
@@ -210,42 +236,23 @@ namespace System
|
||||
return ret;
|
||||
} else {
|
||||
/* wild case : remove MulticastDelegate from MulticastDelegate
|
||||
* complexity is O(m * n), with n the number of elements in
|
||||
* complexity is O(m + n), with n the number of elements in
|
||||
* this.delegates and m the number of elements in other.delegates */
|
||||
MulticastDelegate ret = AllocDelegateLike_internal (this);
|
||||
ret.delegates = new Delegate [delegates.Length];
|
||||
|
||||
/* we should use a set with O(1) lookup complexity
|
||||
* but HashSet is implemented in System.Core.dll */
|
||||
List<Delegate> other_delegates = new List<Delegate> ();
|
||||
for (int i = 0; i < other.delegates.Length; ++i)
|
||||
other_delegates.Add (other.delegates [i]);
|
||||
|
||||
int idx = delegates.Length;
|
||||
if (delegates.Equals (other.delegates))
|
||||
return null;
|
||||
|
||||
/* we need to remove elements from the end to the beginning, as
|
||||
* the addition and removal of delegates behaves like a stack */
|
||||
for (int i = delegates.Length - 1; i >= 0; --i) {
|
||||
/* if delegates[i] is not in other_delegates,
|
||||
* then we can safely add it to ret.delegates
|
||||
* otherwise we remove it from other_delegates */
|
||||
if (!other_delegates.Remove (delegates [i]))
|
||||
ret.delegates [--idx] = delegates [i];
|
||||
}
|
||||
int idx = LastIndexOf (delegates, other.delegates);
|
||||
if (idx == -1)
|
||||
return this;
|
||||
|
||||
/* the elements are at the end of the array, we
|
||||
* need to move them back to the beginning of it */
|
||||
int count = delegates.Length - idx;
|
||||
Array.Copy (ret.delegates, idx, ret.delegates, 0, count);
|
||||
MulticastDelegate ret = AllocDelegateLike_internal (this);
|
||||
ret.delegates = new Delegate [delegates.Length - other.delegates.Length];
|
||||
|
||||
if (count == 0)
|
||||
return null;
|
||||
|
||||
if (count == 1)
|
||||
return ret.delegates [0];
|
||||
|
||||
if (count != delegates.Length)
|
||||
Array.Resize (ref ret.delegates, count);
|
||||
Array.Copy (delegates, ret.delegates, idx);
|
||||
Array.Copy (delegates, idx + other.delegates.Length, ret.delegates, idx, delegates.Length - idx - other.delegates.Length);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -35,6 +35,25 @@ namespace MonoTests.System.Threading
|
||||
[TestFixture]
|
||||
public class ThreadPoolTests
|
||||
{
|
||||
int minWorkerThreads;
|
||||
int minCompletionPortThreads;
|
||||
int maxWorkerThreads;
|
||||
int maxCompletionPortThreads;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
ThreadPool.GetMinThreads (out minWorkerThreads, out minCompletionPortThreads);
|
||||
ThreadPool.GetMaxThreads (out maxWorkerThreads, out maxCompletionPortThreads);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
ThreadPool.SetMinThreads (minWorkerThreads, minCompletionPortThreads);
|
||||
ThreadPool.SetMaxThreads (maxWorkerThreads, maxCompletionPortThreads);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RegisterWaitForSingleObject_InvalidArguments ()
|
||||
{
|
||||
@@ -99,5 +118,85 @@ namespace MonoTests.System.Threading
|
||||
Assert.IsTrue (ev.Wait (3000));
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void SetAndGetMinThreads ()
|
||||
{
|
||||
int workerThreads, completionPortThreads;
|
||||
int workerThreads_new, completionPortThreads_new;
|
||||
|
||||
ThreadPool.GetMinThreads (out workerThreads, out completionPortThreads);
|
||||
Assert.IsTrue (workerThreads > 0, "#1");
|
||||
Assert.IsTrue (completionPortThreads > 0, "#2");
|
||||
|
||||
workerThreads_new = workerThreads == 1 ? 2 : 1;
|
||||
completionPortThreads_new = completionPortThreads == 1 ? 2 : 1;
|
||||
ThreadPool.SetMinThreads (workerThreads_new, completionPortThreads_new);
|
||||
|
||||
ThreadPool.GetMinThreads (out workerThreads, out completionPortThreads);
|
||||
Assert.IsTrue (workerThreads == workerThreads_new, "#3");
|
||||
Assert.IsTrue (completionPortThreads == completionPortThreads_new, "#4");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetAndGetMaxThreads ()
|
||||
{
|
||||
int cpuCount = Environment.ProcessorCount;
|
||||
int workerThreads, completionPortThreads;
|
||||
int workerThreads_new, completionPortThreads_new;
|
||||
|
||||
ThreadPool.GetMaxThreads (out workerThreads, out completionPortThreads);
|
||||
Assert.IsTrue (workerThreads > 0, "#1");
|
||||
Assert.IsTrue (completionPortThreads > 0, "#2");
|
||||
|
||||
workerThreads_new = workerThreads == cpuCount ? cpuCount + 1 : cpuCount;
|
||||
completionPortThreads_new = completionPortThreads == cpuCount ? cpuCount + 1 : cpuCount;
|
||||
ThreadPool.SetMaxThreads (workerThreads_new, completionPortThreads_new);
|
||||
|
||||
ThreadPool.GetMaxThreads (out workerThreads, out completionPortThreads);
|
||||
Assert.IsTrue (workerThreads == workerThreads_new, "#3");
|
||||
Assert.IsTrue (completionPortThreads == completionPortThreads_new, "#4");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAvailableThreads ()
|
||||
{
|
||||
ManualResetEvent mre = new ManualResetEvent (false);
|
||||
DateTime start = DateTime.Now;
|
||||
int i, workerThreads, completionPortThreads;
|
||||
|
||||
try {
|
||||
Assert.IsTrue (ThreadPool.SetMaxThreads (Environment.ProcessorCount, Environment.ProcessorCount));
|
||||
|
||||
while (true) {
|
||||
ThreadPool.GetAvailableThreads (out workerThreads, out completionPortThreads);
|
||||
if (workerThreads == 0)
|
||||
break;
|
||||
|
||||
if ((DateTime.Now - start).TotalSeconds >= 10)
|
||||
Assert.Fail ("did not reach 0 available threads");
|
||||
|
||||
ThreadPool.QueueUserWorkItem (GetAvailableThreads_Callback, mre);
|
||||
Thread.Sleep (1);
|
||||
}
|
||||
} finally {
|
||||
mre.Set ();
|
||||
}
|
||||
}
|
||||
|
||||
void GetAvailableThreads_Callback (object state)
|
||||
{
|
||||
ManualResetEvent mre = (ManualResetEvent) state;
|
||||
|
||||
if (mre.WaitOne (0))
|
||||
return;
|
||||
|
||||
ThreadPool.QueueUserWorkItem (GetAvailableThreads_Callback, mre);
|
||||
ThreadPool.QueueUserWorkItem (GetAvailableThreads_Callback, mre);
|
||||
ThreadPool.QueueUserWorkItem (GetAvailableThreads_Callback, mre);
|
||||
ThreadPool.QueueUserWorkItem (GetAvailableThreads_Callback, mre);
|
||||
|
||||
mre.WaitOne ();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1 +1 @@
|
||||
b937698af090202f18c31201001eb77a3e464dc5
|
||||
18d510880a46b3f8fcc62ee6d2743c2ad6ec142f
|
@@ -1 +1 @@
|
||||
ce9eb809ba177cb9c5f9387d1e2d93f17a583be9
|
||||
5ea7ca0de24029a348ac8342657aa95d53925e82
|
@@ -1 +1 @@
|
||||
2f48219b5156199cf909adf76dc0097708cfd932
|
||||
0637251b61def8d6dff27a5c3ab15f3e34de3e9d
|
@@ -1 +1 @@
|
||||
d5cb6b4dd17539ae3babb95e036964746d5bb92e
|
||||
a90a1a94357eaac435b86ed064aa2078cc144b2e
|
@@ -1 +1 @@
|
||||
3fa77ec9258a44fd81c7433c3534093f2984d1cf
|
||||
c9845643332357f61fb6a54a17f807991c5e7270
|
@@ -1 +1 @@
|
||||
b656909fcd7c7447aa1b8639357c6c089a918a74
|
||||
1cc8b87d077544a9f323c682b733f0fa0d1a1567
|
@@ -1 +1 @@
|
||||
ec8668e105a38b35bf91110fe79e06e0dca1ead6
|
||||
d72025330154b3b52629a526c8cce5cbb390d58b
|
@@ -1 +1 @@
|
||||
47b95db8a26f7b940063993c07b77a5ee36746fe
|
||||
e9d53d6ca1f39de0e8e00f24d0ad7a8bc0e72500
|
Reference in New Issue
Block a user