Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -24,7 +24,5 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_5
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.Json.DataContractJsonSerializer))]
#endif

View File

@@ -117,13 +117,11 @@ namespace System.Runtime.Serialization.Json
{
}
#if NET_4_5
public DataContractJsonSerializer (Type type, DataContractJsonSerializerSettings settings)
: this (type, settings.RootName, settings.KnownTypes, settings.MaxItemsInObjectGraph, settings.IgnoreExtensionDataObject,
settings.DataContractSurrogate, false)
{
}
#endif
#endregion
@@ -271,7 +269,6 @@ namespace System.Runtime.Serialization.Json
writer.WriteEndElement ();
}
#if NET_4_5
[MonoTODO]
public DateTimeFormat DateTimeFormat {
get { throw new NotImplementedException (); }
@@ -291,7 +288,6 @@ namespace System.Runtime.Serialization.Json
public bool UseSimpleDictionaryFormat {
get { throw new NotImplementedException (); }
}
#endif
}
}

View File

@@ -295,7 +295,9 @@ namespace System.Runtime.Serialization.Json
{
if (type.IsArray)
return type.GetElementType ();
if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (IEnumerable<>))
return type.GetGenericArguments () [0];
var inter = type.GetInterface ("System.Collections.Generic.IEnumerable`1", false);
if (inter != null)
return inter.GetGenericArguments () [0];

View File

@@ -23,7 +23,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.ComponentModel;
@@ -37,4 +36,3 @@ namespace System.ServiceModel.Configuration
}
#endif

View File

@@ -23,7 +23,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.Collections;
@@ -203,4 +202,3 @@ namespace System.ServiceModel.Configuration
}
}
#endif

View File

@@ -23,7 +23,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.ComponentModel;
@@ -37,4 +36,3 @@ namespace System.ServiceModel.Configuration
}
#endif

View File

@@ -23,7 +23,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.Collections;
@@ -173,4 +172,3 @@ namespace System.ServiceModel.Configuration
}
}
#endif

View File

@@ -61,13 +61,11 @@ namespace System.ServiceModel.Description
DefaultOutgoingResponseFormat = WebMessageFormat.Xml;
}
#if NET_4_0
public virtual bool AutomaticFormatSelectionEnabled { get; set; }
public virtual bool FaultExceptionEnabled { get; set; }
public virtual bool HelpEnabled { get; set; }
#endif
public virtual WebMessageBodyStyle DefaultBodyStyle { get; set; }

View File

@@ -23,7 +23,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
@@ -83,4 +82,3 @@ namespace System.ServiceModel.Description
}
}
}
#endif

View File

@@ -23,7 +23,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
@@ -50,4 +49,3 @@ namespace System.ServiceModel.Description
}
}
}
#endif

View File

@@ -23,7 +23,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
@@ -104,4 +103,3 @@ namespace System.ServiceModel.Description
}
}
}
#endif

View File

@@ -472,6 +472,7 @@ namespace System.ServiceModel.Dispatcher
void WriteObject (XmlObjectSerializer serializer, XmlDictionaryWriter writer, object value)
{
if (serializer != null){
#if NET_2_1
if (serializer is DataContractJsonSerializer)
((DataContractJsonSerializer) serializer).WriteObject (writer, value);
@@ -480,6 +481,7 @@ namespace System.ServiceModel.Dispatcher
#else
serializer.WriteObject (writer, value);
#endif
}
}
}
@@ -642,16 +644,7 @@ namespace System.ServiceModel.Dispatcher
var ms = Stream as MemoryStream;
if (ms == null) {
ms = new MemoryStream ();
#if NET_4_0
Stream.CopyTo (ms);
#else
byte [] tmp = new byte [0x1000];
int size;
do {
size = Stream.Read (tmp, 0, tmp.Length);
ms.Write (tmp, 0, size);
} while (size > 0);
#endif
this.Stream = ms;
}
return new RawMessageBuffer (ms.ToArray (), headers, properties);

View File

@@ -411,10 +411,10 @@ namespace System.ServiceModel.Syndication
writer.WriteStartElement ("feed", AtomNamespace);
if (Feed.BaseUri != null)
writer.WriteAttributeString ("xml:base", Feed.BaseUri.ToString ());
writer.WriteAttributeString ("xml", "base", null, Feed.BaseUri.ToString ());
if (Feed.Language != null)
writer.WriteAttributeString ("xml:lang", Feed.Language);
writer.WriteAttributeString ("xml", "lang", null, Feed.Language);
// atom:feed elements MUST contain exactly one atom:title element.
(Feed.Title ?? new TextSyndicationContent (String.Empty)).WriteTo (writer, "title", AtomNamespace);

View File

@@ -408,7 +408,7 @@ namespace System.ServiceModel.Syndication
writer.WriteStartElement ("entry", AtomNamespace);
if (Item.BaseUri != null)
writer.WriteAttributeString ("xml:base", Item.BaseUri.ToString ());
writer.WriteAttributeString ("xml", "base", null, Item.BaseUri.ToString ());
// atom:entry elements MUST contain exactly one atom:id element.
writer.WriteElementString ("id", AtomNamespace, Item.Id ?? new UniqueId ().ToString ());

View File

@@ -148,7 +148,6 @@ namespace System.ServiceModel.Syndication
{
if (serializer == null)
serializer = new DataContractSerializer (extension.GetType ());
#if NET_4_0
// FIXME: this is a nasty workaround that mcs somehow fails to resolve InternalVisibleTo(System.ServiceModel) in System.Runtime.Serialization.dll and thus rejects the use of KnownTypeCollection unlike NET_2_0 case (where System.ServiceModel.Web.dll is referenced).
XmlQualifiedName qname = null;
if (name == null || ns == null) {
@@ -160,9 +159,6 @@ namespace System.ServiceModel.Syndication
xr.MoveToContent ();
qname = new XmlQualifiedName (xr.LocalName, xr.NamespaceURI);
}
#else
var qname = name == null || ns == null ? KnownTypeCollection.GetStaticQName (extension.GetType ()) : null;
#endif
this.Name = name ?? qname.Name;
this.Namespace = ns ?? qname.Namespace;
this.extension = extension;

View File

@@ -89,23 +89,18 @@ namespace System.ServiceModel
}
#if !NET_2_1
#if NET_4_0
[DefaultValue (false)]
#endif
public bool AllowCookies {
get { return t.AllowCookies; }
set { t.AllowCookies = value; }
}
#if NET_4_0
[DefaultValue (false)]
#endif
public bool BypassProxyOnLocal {
get { return t.BypassProxyOnLocal; }
set { t.BypassProxyOnLocal = value; }
}
#if NET_4_0
[MonoTODO]
public bool CrossDomainScriptAccessEnabled { get; set; }
@@ -113,60 +108,45 @@ namespace System.ServiceModel
get { return msgenc.ContentTypeMapper; }
set { msgenc.ContentTypeMapper = value; }
}
#endif
#if NET_4_0
[DefaultValue (HostNameComparisonMode.StrongWildcard)]
#endif
public HostNameComparisonMode HostNameComparisonMode {
get { return t.HostNameComparisonMode; }
set { t.HostNameComparisonMode = value; }
}
#if NET_4_0
[DefaultValue (0x10000)]
#endif
public long MaxBufferPoolSize {
get { return t.MaxBufferPoolSize; }
set { t.MaxBufferPoolSize = value; }
}
#if NET_4_0
[DefaultValue (TransferMode.Buffered)]
#endif
public TransferMode TransferMode {
get { return t.TransferMode; }
set { t.TransferMode = value; }
}
#if NET_4_0
[DefaultValue (true)]
#endif
public bool UseDefaultWebProxy {
get { return t.UseDefaultWebProxy; }
set { t.UseDefaultWebProxy = value; }
}
#if NET_4_0
[DefaultValue (null)]
#endif
public Uri ProxyAddress {
get { return t.ProxyAddress; }
set { t.ProxyAddress = value; }
}
#endif
#if NET_4_0
[DefaultValue (0x80000)]
#endif
public int MaxBufferSize {
get { return t.MaxBufferSize; }
set { t.MaxBufferSize = value; }
}
#if NET_4_0
[DefaultValue (0x10000)]
#endif
public long MaxReceivedMessageSize {
get { return t.MaxReceivedMessageSize; }
set { t.MaxReceivedMessageSize = value; }
@@ -183,13 +163,11 @@ namespace System.ServiceModel
public WebHttpSecurity Security {
get { return security; }
#if NET_4_0
set {
if (value == null)
throw new ArgumentNullException ("value");
security = value;
}
#endif
}
public Encoding WriteEncoding {
@@ -210,7 +188,6 @@ namespace System.ServiceModel
get { return receive_synchronously; }
}
#if NET_4_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
public bool ShouldSerializeReaderQuotas ()
{
@@ -228,6 +205,5 @@ namespace System.ServiceModel
{
return false;
}
#endif
}
}

View File

@@ -31,11 +31,7 @@ namespace System.ServiceModel
{
public sealed class WebHttpSecurity
{
#if NET_4_0
public WebHttpSecurity ()
#else
internal WebHttpSecurity ()
#endif
{
// there is no public constructor for transport ...
#if !NET_2_1
@@ -50,14 +46,9 @@ namespace System.ServiceModel
set { mode = value; }
}
#if NET_4_0
public HttpTransportSecurity Transport { get; set; }
#elif !NET_2_1
public HttpTransportSecurity Transport { get; private set; }
#endif
#if NET_4_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
public bool ShouldSerializeMode ()
{
@@ -69,6 +60,5 @@ namespace System.ServiceModel
{
return false;
}
#endif
}
}

View File

@@ -321,11 +321,15 @@ namespace System
string [] parameters = Uri.UnescapeDataString (candidate.Query.Substring (1)).Split ('&'); // chop first '?'
foreach (string parameter in parameters) {
string [] pair = parameter.Split ('=');
m.QueryParameters.Add (pair [0], pair [1]);
if (!query_params.ContainsKey (pair [0]))
continue;
string templateName = query_params [pair [0]];
vc.Add (templateName, pair [1]);
if (pair.Length > 0) {
m.QueryParameters.Add (pair [0], pair.Length == 2 ? pair [1] : null);
if (!query_params.ContainsKey (pair [0]))
continue;
if (pair.Length > 1) {
string templateName = query_params [pair [0]];
vc.Add (templateName, pair [1]);
}
}
}
return m;

View File

@@ -1550,7 +1550,7 @@ namespace MonoTests.System.Runtime.Serialization.Json
public void TestHashtableSerialization ()
{
var collection = new HashtableContainer ();
var expectedOutput = "{\"Items\":[{\"Key\":\"key1\",\"Value\":\"banana\"},{\"Key\":\"key2\",\"Value\":\"apple\"}]}";
var expectedOutput = "{\"Items\":[{\"Key\":\"key2\",\"Value\":\"apple\"},{\"Key\":\"key1\",\"Value\":\"banana\"}]}";
var serializer = new DataContractJsonSerializer (collection.GetType ());
var stream = new MemoryStream ();

View File

@@ -27,6 +27,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization.Json;
@@ -866,5 +867,17 @@ namespace MonoTests.System.Runtime.Serialization.Json
Assert.AreEqual (typeof (decimal), deserializedValue.GetType ());
Assert.AreEqual (testValue, (decimal) deserializedValue);
}
[Test]
public void IEnumerableTest ()
{
string json = "[\"A\", \"B\"]";
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json))) {
DataContractJsonSerializer jsonSerializer = new
DataContractJsonSerializer(typeof(IEnumerable<string>));
var result = jsonSerializer.ReadObject(stream);
Assert.AreEqual (typeof (List<string>), result.GetType ());
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More