Imported Upstream version 3.10.0

Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
Jo Shields
2014-10-04 11:27:48 +01:00
parent fe777c5c82
commit 8b9b85e7f5
970 changed files with 20242 additions and 31308 deletions

View File

@ -53,7 +53,6 @@ using System.Runtime.InteropServices;
[assembly: ComVisible (false)]
#if !TARGET_JVM
[assembly: CLSCompliant (true)]
[assembly: AssemblyDelaySign (true)]
#if NET_2_1
@ -61,7 +60,6 @@ using System.Runtime.InteropServices;
#else
[assembly: AssemblyKeyFile ("../ecma.pub")]
#endif
#endif
#if NET_2_1
[assembly: InternalsVisibleTo ("System.Runtime.Serialization, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]

View File

@ -140,7 +140,8 @@ namespace Mono.Xml.Xsl.Operations {
if (children != null) children.Evaluate (p);
if (isEmptyElement)
var templateContent = children as XslTemplateContent;
if (isEmptyElement || (templateContent != null && templateContent.IsEmptyElement))
p.Out.WriteEndElement ();
else
p.Out.WriteFullEndElement ();

View File

@ -46,6 +46,7 @@ namespace Mono.Xml.Xsl.Operations
int stackSize;
XPathNodeType parentType;
bool xslForEach;
bool isEmptyElement;
public XslTemplateContent (Compiler c,
XPathNodeType parentType, bool xslForEach)
@ -60,6 +61,10 @@ namespace Mono.Xml.Xsl.Operations
get { return parentType; }
}
public bool IsEmptyElement {
get { return isEmptyElement; }
}
protected override void Compile (Compiler c)
{
if (c.Debugger != null)
@ -178,6 +183,14 @@ namespace Mono.Xml.Xsl.Operations
} while (c.Input.MoveToNext ());
isEmptyElement = true;
foreach (var n in content) {
if (n is XslAttribute)
continue;
isEmptyElement = false;
break;
}
if (hasStack) {
stackSize = c.PopScope ().VariableHighTide;

View File

@ -129,7 +129,7 @@ namespace Mono.Xml.Xsl {
public object Compile (XPathNavigator node)
{
#if TARGET_JVM || MOBILE
#if MOBILE
throw new NotImplementedException ();
#else
string suffix = "";

View File

@ -1,155 +0,0 @@
//
// XslDecimalFormat.jvm.cs
//
// Authors:
// Andrew Skiba <andrews@mainsoft.com>
//
// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
//
//
// 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.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using QName = System.Xml.XmlQualifiedName;
namespace Mono.Xml.Xsl {
internal class XslDecimalFormat {
java.text.DecimalFormatSymbols javaFormat;
string baseUri;
int lineNumber;
int linePosition;
public static readonly XslDecimalFormat Default = new XslDecimalFormat ();
XslDecimalFormat ()
{
javaFormat = new java.text.DecimalFormatSymbols ();
javaFormat.setNaN ("NaN");
javaFormat.setInfinity ("Infinity");
}
public XslDecimalFormat (Compiler c)
:this ()
{
Initialize(c);
}
private void Initialize(Compiler c)
{
XPathNavigator n = c.Input;
IXmlLineInfo li = n as IXmlLineInfo;
if (li != null) {
lineNumber = li.LineNumber;
linePosition = li.LinePosition;
}
baseUri = n.BaseURI;
if (n.MoveToFirstAttribute ()) {
do {
if (n.NamespaceURI != String.Empty)
continue;
switch (n.LocalName) {
case "name": break; // already handled
case "decimal-separator":
if (n.Value.Length != 1)
throw new XsltCompileException ("XSLT decimal-separator value must be exact one character.", null, n);
javaFormat.setDecimalSeparator (n.Value[0]);
break;
case "grouping-separator":
if (n.Value.Length != 1)
throw new XsltCompileException ("XSLT grouping-separator value must be exact one character.", null, n);
javaFormat.setGroupingSeparator (n.Value[0]);
break;
case "infinity":
javaFormat.setInfinity (n.Value);
break;
case "minus-sign":
if (n.Value.Length != 1)
throw new XsltCompileException ("XSLT minus-sign value must be exact one character.", null, n);
javaFormat.setMinusSign (n.Value[0]);
break;
case "NaN":
javaFormat.setNaN (n.Value);
break;
case "percent":
if (n.Value.Length != 1)
throw new XsltCompileException ("XSLT percent value must be exact one character.", null, n);
javaFormat.setPercent (n.Value[0]);
break;
case "per-mille":
if (n.Value.Length != 1)
throw new XsltCompileException ("XSLT per-mille value must be exact one character.", null, n);
javaFormat.setPerMill (n.Value[0]);
break;
case "digit":
if (n.Value.Length != 1)
throw new XsltCompileException ("XSLT digit value must be exact one character.", null, n);
javaFormat.setDigit (n.Value[0]);
break;
case "zero-digit":
if (n.Value.Length != 1)
throw new XsltCompileException ("XSLT zero-digit value must be exact one character.", null, n);
javaFormat.setZeroDigit (n.Value [0]);
break;
case "pattern-separator":
if (n.Value.Length != 1)
throw new XsltCompileException ("XSLT pattern-separator value must be exact one character.", null, n);
javaFormat.setPatternSeparator (n.Value [0]);
break;
}
} while (n.MoveToNextAttribute ());
n.MoveToParent ();
}
}
public void CheckSameAs (XslDecimalFormat other)
{
if (! this.javaFormat.Equals (other.javaFormat))
throw new XsltCompileException (null, other.baseUri, other.lineNumber, other.linePosition);
}
public string FormatNumber (double number, string pattern)
{
java.text.DecimalFormat frm = new java.text.DecimalFormat("", javaFormat);
frm.applyLocalizedPattern (pattern);
//TODO: the next 4 string could be replaced by just
//return frm.format (number);
//I don't want to do that before release
java.lang.StringBuffer buffer= new java.lang.StringBuffer ();
java.text.FieldPosition fld = new java.text.FieldPosition (0);
frm.format (number, buffer, fld);
return buffer.ToString();
}
}
}

View File

@ -31,9 +31,7 @@
#if NET_2_0
using System;
#if !TARGET_JVM
using System.Xml.Serialization.Advanced;
#endif
namespace System.Xml.Serialization
{

View File

@ -1 +1 @@
86c63bc66a229be12e357a6bdb66bfffaf2ccf23
0ac2cd5e0ba7d882e76c0a148eb6203b65602140

View File

@ -45,44 +45,13 @@ namespace System.Xml.Serialization
static Hashtable primitiveArrayTypes;
static Hashtable nullableTypes;
#if TARGET_JVM
static readonly object AppDomain_TypeTranslatorCacheLock = new object ();
const string AppDomain_nameCacheName = "System.Xml.Serialization.TypeTranslator.nameCache";
const string AppDomain_nullableTypesName = "System.Xml.Serialization.TypeTranslator.nullableTypes";
static Hashtable AppDomain_nameCache {
get { return GetAppDomainCache (AppDomain_nameCacheName); }
}
static Hashtable AppDomain_nullableTypes {
get { return GetAppDomainCache (AppDomain_nullableTypesName); }
}
static Hashtable GetAppDomainCache(string name) {
Hashtable res = (Hashtable) AppDomain.CurrentDomain.GetData (name);
if (res == null) {
lock (AppDomain_TypeTranslatorCacheLock) {
res = (Hashtable) AppDomain.CurrentDomain.GetData (name);
if (res == null) {
res = Hashtable.Synchronized (new Hashtable ());
AppDomain.CurrentDomain.SetData (name, res);
}
}
}
return res;
}
#endif
static TypeTranslator ()
{
nameCache = new Hashtable ();
primitiveArrayTypes = Hashtable.Synchronized (new Hashtable ());
#if !TARGET_JVM
nameCache = Hashtable.Synchronized (nameCache);
#endif
// XSD Types with direct map to CLR types
nameCache.Add (typeof (bool), new TypeData (typeof (bool), "boolean", true));
@ -211,18 +180,10 @@ namespace System.Xml.Serialization
TypeData pt = GetTypeData (type); // beware this recursive call btw ...
if (pt != null) {
TypeData tt = (TypeData) nullableTypes [pt.XmlType];
#if TARGET_JVM
if (tt == null)
tt = (TypeData) AppDomain_nullableTypes [pt.XmlType];
#endif
if (tt == null) {
tt = new TypeData (type, pt.XmlType, false);
tt.IsNullable = true;
#if TARGET_JVM
AppDomain_nullableTypes [pt.XmlType] = tt;
#else
nullableTypes [pt.XmlType] = tt;
#endif
}
return tt;
}
@ -232,11 +193,6 @@ namespace System.Xml.Serialization
TypeData typeData = nameCache[runtimeType] as TypeData;
if (typeData != null) return typeData;
#if TARGET_JVM
Hashtable dynamicCache = AppDomain_nameCache;
typeData = dynamicCache[runtimeType] as TypeData;
if (typeData != null) return typeData;
#endif
string name;
if (type.IsArray) {
@ -258,11 +214,7 @@ namespace System.Xml.Serialization
typeData = new TypeData (type, name, false);
if (nullableOverride)
typeData.IsNullable = true;
#if TARGET_JVM
dynamicCache[runtimeType] = typeData;
#else
nameCache[runtimeType] = typeData;
#endif
return typeData;
}

View File

@ -126,7 +126,7 @@ namespace System.Xml.Serialization
{
get { return _mapMember.Name; }
}
#if !TARGET_JVM && !NET_2_1
#if !NET_2_1
public string GenerateTypeName (System.CodeDom.Compiler.CodeDomProvider codeProvider)
{
string ret = codeProvider.CreateValidIdentifier (_mapMember.TypeData.FullTypeName);

View File

@ -326,21 +326,21 @@ namespace System.Xml.Serialization {
return map;
}
XmlTypeMapping ImportClassMapping (Type type, XmlRootAttribute root, string defaultNamespace)
XmlTypeMapping ImportClassMapping (Type type, XmlRootAttribute root, string defaultNamespace, bool isBaseType = false)
{
TypeData typeData = TypeTranslator.GetTypeData (type);
return ImportClassMapping (typeData, root, defaultNamespace);
return ImportClassMapping (typeData, root, defaultNamespace, isBaseType);
}
XmlTypeMapping ImportClassMapping (TypeData typeData, XmlRootAttribute root, string defaultNamespace)
XmlTypeMapping ImportClassMapping (TypeData typeData, XmlRootAttribute root, string defaultNamespace, bool isBaseType = false)
{
Type type = typeData.Type;
if (!allowPrivateTypes && !isBaseType)
ReflectionHelper.CheckSerializableType (type, false);
XmlTypeMapping map = helper.GetRegisteredClrType (type, GetTypeNamespace (typeData, root, defaultNamespace));
if (map != null) return map;
if (!allowPrivateTypes)
ReflectionHelper.CheckSerializableType (type, false);
map = CreateTypeMapping (typeData, root, null, defaultNamespace);
helper.RegisterClrType (map, type, map.XmlTypeNamespace);
@ -372,7 +372,7 @@ namespace System.Xml.Serialization {
string ns = map.XmlTypeNamespace;
if (rmember.XmlAttributes.XmlIgnore) continue;
if (rmember.DeclaringType != null && rmember.DeclaringType != type) {
XmlTypeMapping bmap = ImportClassMapping (rmember.DeclaringType, root, defaultNamespace);
XmlTypeMapping bmap = ImportClassMapping (rmember.DeclaringType, root, defaultNamespace, true);
if (bmap.HasXmlTypeNamespace)
ns = bmap.XmlTypeNamespace;
}
@ -400,7 +400,7 @@ namespace System.Xml.Serialization {
if (type.BaseType != null)
{
XmlTypeMapping bmap = ImportClassMapping (type.BaseType, root, defaultNamespace);
XmlTypeMapping bmap = ImportClassMapping (type.BaseType, root, defaultNamespace, true);
ClassMap cbmap = bmap.ObjectMap as ClassMap;
if (type.BaseType != typeof (object)) {
@ -709,16 +709,6 @@ namespace System.Xml.Serialization {
// Read all Fields via reflection.
ArrayList fieldList = new ArrayList();
FieldInfo[] tfields = type.GetFields (BindingFlags.Instance | BindingFlags.Public);
#if TARGET_JVM
// This statement ensures fields are ordered starting from the base type.
for (int ti=0; ti<typeList.Count; ti++) {
for (int i=0; i<tfields.Length; i++) {
FieldInfo field = tfields[i];
if (field.DeclaringType == typeList[ti])
fieldList.Add (field);
}
}
#else
currentType = null;
int currentIndex = 0;
foreach (FieldInfo field in tfields)
@ -731,22 +721,9 @@ namespace System.Xml.Serialization {
}
fieldList.Insert(currentIndex++, field);
}
#endif
// Read all Properties via reflection.
ArrayList propList = new ArrayList();
PropertyInfo[] tprops = type.GetProperties (BindingFlags.Instance | BindingFlags.Public);
#if TARGET_JVM
// This statement ensures properties are ordered starting from the base type.
for (int ti=0; ti<typeList.Count; ti++) {
for (int i=0; i<tprops.Length; i++) {
PropertyInfo prop = tprops[i];
if (!prop.CanRead) continue;
if (prop.GetIndexParameters().Length > 0) continue;
if (prop.DeclaringType == typeList[ti])
propList.Add (prop);
}
}
#else
currentType = null;
currentIndex = 0;
foreach (PropertyInfo prop in tprops)
@ -761,7 +738,6 @@ namespace System.Xml.Serialization {
if (prop.GetIndexParameters().Length > 0) continue;
propList.Insert(currentIndex++, prop);
}
#endif
var members = new List<XmlReflectionMember>();
int fieldIndex=0;
int propIndex=0;
@ -1041,6 +1017,9 @@ namespace System.Xml.Serialization {
if (choiceEnumMap != null) {
string cname = choiceEnumMap.GetEnumName (choiceEnumType.FullName, elem.ElementName);
if (cname == null && elem.Namespace != null)
cname = choiceEnumMap.GetEnumName (choiceEnumType.FullName,
elem.Namespace.ToString () + ":" + elem.ElementName);
if (cname == null)
throw new InvalidOperationException (string.Format (
CultureInfo.InvariantCulture, "Type {0} is missing"

View File

@ -30,7 +30,7 @@
//
using System.Xml;
#if !TARGET_JVM && !MOBILE
#if !MOBILE
using System.CodeDom.Compiler;
#endif
using System.Xml.Schema;
@ -98,7 +98,7 @@ namespace System.Xml.Serialization
this.typeIdentifiers = typeIdentifiers;
}
#if !TARGET_JVM && !MOBILE
#if !MOBILE
[MonoTODO]
public XmlSchemaImporter (XmlSchemas schemas, CodeGenerationOptions options, CodeDomProvider codeProvider, ImportContext context)
{

View File

@ -178,7 +178,7 @@ namespace System.Xml.Serialization
}
else
{
if (Reader.LocalName != rootMap.ElementName || Reader.NamespaceURI != rootMap.Namespace)
if (!rootMap.IsAny && (Reader.LocalName != rootMap.ElementName || Reader.NamespaceURI != rootMap.Namespace))
throw CreateUnknownNodeException();
return ReadObject (rootMap, rootMap.IsNullable, true);
@ -835,7 +835,7 @@ namespace System.Xml.Serialization
Reader.MoveToContent ();
if (Reader.NodeType == XmlNodeType.Element)
{
if (Reader.LocalName == typeMap.ElementName && Reader.NamespaceURI == typeMap.Namespace)
if (typeMap.IsAny || (Reader.LocalName == typeMap.ElementName && Reader.NamespaceURI == typeMap.Namespace))
{
object ob = CreateInstance (typeMap.TypeData.Type, true);
return ReadSerializable ((IXmlSerializable)ob);

View File

@ -315,6 +315,8 @@ namespace System.Xml.Serialization
if (isNullable)
WriteNullTagEncoded (name, ns);
}
else if (any)
WriteXmlNode (node);
else
{
Writer.WriteStartElement (name, ns);
@ -335,6 +337,8 @@ namespace System.Xml.Serialization
if (isNullable)
WriteNullTagLiteral (name, ns);
}
else if (any)
WriteXmlNode (node);
else
{
Writer.WriteStartElement (name, ns);

View File

@ -109,14 +109,14 @@ namespace System.Xml.Serialization
if (ob is XmlNode)
{
if (_format == SerializationFormat.Literal) WriteElementLiteral((XmlNode)ob, "", "", true, false);
else WriteElementEncoded((XmlNode)ob, "", "", true, false);
if (_format == SerializationFormat.Literal) WriteElementLiteral((XmlNode)ob, "", "", true, typeMap.IsAny);
else WriteElementEncoded((XmlNode)ob, "", "", true, typeMap.IsAny);
return;
}
if (typeMap.TypeData.SchemaType == SchemaTypes.XmlSerializable)
{
WriteSerializable ((IXmlSerializable)ob, element, namesp, isNullable);
WriteSerializable ((IXmlSerializable)ob, element, namesp, isNullable, !typeMap.IsAny);
return;
}

View File

@ -37,7 +37,7 @@ using System.Reflection;
using System.Xml;
using System.Xml.Schema;
using System.Text;
#if !TARGET_JVM && !NET_2_1
#if !NET_2_1
using System.CodeDom;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
@ -68,6 +68,7 @@ namespace System.Xml.Serialization
internal class SerializerData
{
public int UsageCount;
public bool Generated;
public Type ReaderType;
public MethodInfo ReaderMethod;
public Type WriterType;
@ -120,7 +121,7 @@ namespace System.Xml.Serialization
// debugging pourposes by adding the "nofallback" option.
// For example: MONO_XMLSERIALIZER_THS=0,nofallback
#if TARGET_JVM || NET_2_1
#if NET_2_1
string db = null;
string th = null;
generationThreshold = -1;
@ -145,7 +146,6 @@ namespace System.Xml.Serialization
else {
generationThreshold = int.Parse (th, CultureInfo.InvariantCulture);
backgroundGeneration = (generationThreshold != 0);
if (generationThreshold < 1) generationThreshold = 1;
}
}
#endif
@ -521,7 +521,7 @@ namespace System.Xml.Serialization
throw new NotImplementedException ();
}
#if !TARGET_JVM && !MOBILE
#if !MOBILE
public static Assembly GenerateSerializer (Type[] types, XmlMapping[] mappings)
{
return GenerateSerializer (types, mappings, null);
@ -630,7 +630,7 @@ namespace System.Xml.Serialization
return new XmlSerializationReaderInterpreter (typeMapping);
}
#if TARGET_JVM || NET_2_1
#if NET_2_1
void CheckGeneratedTypes (XmlMapping typeMapping)
{
throw new NotImplementedException();
@ -664,7 +664,10 @@ namespace System.Xml.Serialization
bool generate = false;
lock (serializerData)
{
generate = (++serializerData.UsageCount == generationThreshold);
if (serializerData.UsageCount >= generationThreshold && !serializerData.Generated)
serializerData.Generated = generate = true;
serializerData.UsageCount++;
}
if (generate)

View File

@ -49,6 +49,7 @@ namespace System.Xml.Serialization
string documentation;
bool includeInSchema;
bool isNullable = true;
bool isAny;
ArrayList _derivedTypes = new ArrayList();
@ -158,6 +159,12 @@ namespace System.Xml.Serialization
set { isNullable = value; }
}
internal bool IsAny
{
get { return isAny; }
set { isAny = value; }
}
internal XmlTypeMapping GetRealTypeMap (Type objectType)
{
if (TypeData.SchemaType == SchemaTypes.Enum)
@ -205,6 +212,13 @@ namespace System.Xml.Serialization
XmlSchemaProviderAttribute schemaProvider = (XmlSchemaProviderAttribute) Attribute.GetCustomAttribute (typeData.Type, typeof (XmlSchemaProviderAttribute));
if (schemaProvider != null) {
_schemaTypeName = XmlQualifiedName.Empty;
if (schemaProvider.IsAny) {
IsAny = true;
return;
}
string method = schemaProvider.MethodName;
MethodInfo mi = typeData.Type.GetMethod (method, BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
if (mi == null)
@ -216,7 +230,6 @@ namespace System.Xml.Serialization
throw new InvalidOperationException (String.Format ("Method '{0}' indicated by XmlSchemaProviderAttribute must have its return type as XmlQualifiedName", method));
XmlSchemaSet xs = new XmlSchemaSet ();
object retVal = mi.Invoke (null, new object [] { xs });
_schemaTypeName = XmlQualifiedName.Empty;
if (retVal == null)
return;

View File

@ -47,7 +47,7 @@ namespace System.Xml.Xsl
bool enable_debug;
object debugger;
CompiledStylesheet s;
#if !TARGET_JVM && !MOBILE
#if !MOBILE
// TempFileCollection temporary_files;
#endif
XmlWriterSettings output_settings = new XmlWriterSettings ();
@ -70,7 +70,7 @@ namespace System.Xml.Xsl
get { return output_settings; }
}
#if !TARGET_JVM && !MOBILE
#if !MOBILE
[MonoTODO]
public TempFileCollection TemporaryFiles {
get { return null; /*temporary_files;*/ }

View File

@ -838,7 +838,6 @@ namespace System.Xml {
}
#if NET_2_0 // actually NET_3_5
#if !TARGET_JVM
public static DateTimeOffset ToDateTimeOffset (string s)
{
@ -867,7 +866,6 @@ namespace System.Xml {
{
return value.ToString (format, CultureInfo.InvariantCulture);
}
#endif
// it is used only from 2.1 System.Xml.Serialization.dll from
// MS Silverlight SDK. We don't use it so far.

View File

@ -466,12 +466,6 @@ namespace System.Xml
}
}
}
#if TARGET_JVM
else {
if (bufLength >= 10 && Encoding.Unicode.GetString (buffer, 2, 8) == "?xml")
enc = Encoding.Unicode;
}
#endif
bufPos = 0;
break;
default:

View File

@ -494,12 +494,12 @@ namespace System.Xml
void IDisposable.Dispose()
#endif
{
Dispose (false);
Dispose (true);
}
protected virtual void Dispose (bool disposing)
{
if (ReadState != ReadState.Closed)
if (disposing && ReadState != ReadState.Closed)
Close ();
}
#endif

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