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

@ -28,7 +28,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.CodeDom;
@ -50,4 +49,3 @@ namespace System.Xml.Serialization
}
}
#endif

View File

@ -33,12 +33,7 @@ using System;
namespace System.Xml.Serialization
{
[Flags]
#if NET_2_0
public
#else
[Serializable]
internal
#endif
enum CodeGenerationOptions
{
[XmlIgnore]

View File

@ -34,9 +34,7 @@ using System.Globalization;
namespace System.Xml.Serialization {
public class CodeIdentifier {
#if NET_2_0
[Obsolete ("Design mistake. It only contains static methods.")]
#endif
public
CodeIdentifier ()
{

View File

@ -50,23 +50,14 @@ namespace System.Xml.Serialization {
{
}
#if NET_2_0
public
#else
private
#endif
CodeIdentifiers (bool caseSensitive)
{
#if NET_2_0
StringComparer c = caseSensitive ?
StringComparer.Ordinal :
StringComparer.OrdinalIgnoreCase;
table = new Hashtable (c);
reserved = new Hashtable (c);
#else
table = new Hashtable ();
reserved = new Hashtable ();
#endif
}
#endregion // Constructors

View File

@ -28,7 +28,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
namespace System.Xml.Serialization
{
@ -39,4 +38,3 @@ namespace System.Xml.Serialization
}
}
#endif

View File

@ -28,7 +28,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Collections;
@ -75,4 +74,3 @@ namespace System.Xml.Serialization
}
}
#endif

View File

@ -31,10 +31,8 @@
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
#if NET_2_0
using System.ComponentModel;
using System.Diagnostics;
#endif
using System.Globalization;
using System.Xml.Schema;
@ -48,9 +46,7 @@ namespace System.Xml.Serialization {
CodeAttributeDeclarationCollection includeMetadata;
XmlTypeMapping exportedAnyType;
protected bool includeArrayTypes;
#if NET_2_0
CodeDomProvider codeProvider;
#endif
CodeGenerationOptions options;
CodeIdentifiers identifiers;
@ -70,12 +66,8 @@ namespace System.Xml.Serialization {
// this.codeCompileUnit = codeCompileUnit;
this.codeNamespace = codeNamespace;
this.options = options;
#if NET_2_0
this.codeProvider = codeProvider;
this.identifiers = new CodeIdentifiers ((codeProvider.LanguageOptions & LanguageOptions.CaseInsensitive) == 0);
#else
this.identifiers = new CodeIdentifiers ();
#endif
// this.mappings = mappings;
}
@ -139,9 +131,7 @@ namespace System.Xml.Serialization {
if (codeClass != null) {
// Regenerate attributes, since things may have changed
codeClass.CustomAttributes.Clear ();
#if NET_2_0
AddClassAttributes (codeClass);
#endif
GenerateClass (map, codeClass, isTopLevel);
ExportDerivedTypeAttributes (map, codeClass);
}
@ -166,10 +156,8 @@ namespace System.Xml.Serialization {
AddCodeType (codeClass, map.Documentation);
codeClass.Attributes = MemberAttributes.Public;
#if NET_2_0
codeClass.IsPartial = CodeProvider.Supports(GeneratorSupport.PartialTypes);
AddClassAttributes (codeClass);
#endif
GenerateClass (map, codeClass, isTopLevel);
ExportDerivedTypeAttributes (map, codeClass);
@ -500,7 +488,6 @@ namespace System.Xml.Serialization {
if (emap.IsFlags)
codeEnum.CustomAttributes.Add (new CodeAttributeDeclaration ("System.FlagsAttribute"));
#if NET_2_0
CodeAttributeDeclaration generatedCodeAttribute = new CodeAttributeDeclaration (
new CodeTypeReference (typeof(GeneratedCodeAttribute)));
generatedCodeAttribute.Arguments.Add (new CodeAttributeArgument (
@ -511,7 +498,6 @@ namespace System.Xml.Serialization {
codeEnum.CustomAttributes.Add (new CodeAttributeDeclaration (
new CodeTypeReference (typeof (SerializableAttribute))));
#endif
GenerateEnum (map, codeEnum, isTopLevel);
@ -608,7 +594,6 @@ namespace System.Xml.Serialization {
codeNamespace.Types.Add (type);
}
#if NET_2_0
void AddClassAttributes (CodeTypeDeclaration codeClass)
{
CodeAttributeDeclaration generatedCodeAttribute = new CodeAttributeDeclaration (
@ -630,14 +615,11 @@ namespace System.Xml.Serialization {
new CodePrimitiveExpression ("code")));
codeClass.CustomAttributes.Add (designerCategoryAttribute);
}
#endif
CodeTypeReference GetDomType (TypeData data, bool requiresNullable)
{
#if NET_2_0
if (data.IsValueType && (data.IsNullable || requiresNullable))
return new CodeTypeReference ("System.Nullable", new CodeTypeReference (data.FullTypeName));
#endif
if (data.SchemaType == SchemaTypes.Array)
return new CodeTypeReference (GetDomType (data.ListItemTypeData, false),1);
else
@ -648,7 +630,6 @@ namespace System.Xml.Serialization {
#region Private Properties
#if NET_2_0
private CodeDomProvider CodeProvider {
get {
if (codeProvider == null) {
@ -657,7 +638,6 @@ namespace System.Xml.Serialization {
return codeProvider;
}
}
#endif
#endregion

View File

@ -71,19 +71,13 @@ namespace System.Xml.Serialization
return new InvalidOperationException ("There was an error reflecting '" + map.TypeFullName + "': " + message);
}
#if NET_2_0
static readonly ParameterModifier [] empty_modifiers = new ParameterModifier [0];
#endif
public static void CheckSerializableType (Type type, bool allowPrivateConstructors)
{
if (type.IsArray) return;
#if NET_2_0
if (!allowPrivateConstructors && type.GetConstructor (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, empty_modifiers) == null && !type.IsAbstract && !type.IsValueType)
#else
if (!allowPrivateConstructors && type.GetConstructor (Type.EmptyTypes) == null && !type.IsAbstract && !type.IsValueType)
#endif
throw new InvalidOperationException (type.FullName + " cannot be serialized because it does not have a default public constructor");
if (type.IsInterface && !TypeTranslator.GetTypeData (type).IsListType)

View File

@ -28,7 +28,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Xml.Serialization.Advanced;
@ -54,4 +53,3 @@ namespace System.Xml.Serialization
}
}
#endif

View File

@ -1 +1 @@
27848d10ea073aee33c40a78188d74462717de4f
b66d94a0a1ddececfb6aa54801cc682993f50f39

View File

@ -36,15 +36,10 @@ using System.Collections;
namespace System.Xml.Serialization
{
public class SoapCodeExporter
#if NET_2_0
: CodeExporter
#endif
{
#region Fields
#if !NET_2_0
SoapMapCodeGenerator codeGenerator;
#endif
#endregion
@ -59,7 +54,6 @@ namespace System.Xml.Serialization
codeGenerator = new SoapMapCodeGenerator (codeNamespace, codeCompileUnit);
}
#if NET_2_0
public SoapCodeExporter (CodeNamespace codeNamespace,
CodeCompileUnit codeCompileUnit,
@ -87,17 +81,11 @@ namespace System.Xml.Serialization
codeGenerator = new SoapMapCodeGenerator (codeNamespace, codeCompileUnit, codeProvider, options, mappings);
}
#endif
#endregion // Constructors
#region Properties
#if !NET_2_0
public CodeAttributeDeclarationCollection IncludeMetadata {
get { return codeGenerator.IncludeMetadata; }
}
#endif
#endregion // Properties

View File

@ -32,14 +32,9 @@ using System;
namespace System.Xml.Serialization
{
#if NET_2_0
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
AttributeTargets.Interface | AttributeTargets.Method,
AllowMultiple=true)]
#else
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
AttributeTargets.Method, AllowMultiple=true)]
#endif
public class SoapIncludeAttribute : Attribute
{
private Type type;

View File

@ -85,10 +85,8 @@ namespace System.Xml.Serialization {
return ImportMembersMapping (elementName, ns, members, hasWrapperElement, writeAccessors, validate, XmlMappingAccess.Read | XmlMappingAccess.Write);
}
#if NET_2_0
[MonoTODO]
public
#endif
XmlMembersMapping ImportMembersMapping (string elementName, string ns, XmlReflectionMember[] members, bool hasWrapperElement, bool writeAccessors, bool validate, XmlMappingAccess access)
{
elementName = XmlConvert.EncodeLocalName (elementName);

View File

@ -35,9 +35,7 @@ using System.CodeDom.Compiler;
namespace System.Xml.Serialization
{
public class SoapSchemaImporter
#if NET_2_0
: SchemaImporter
#endif
{
#region Fields
@ -60,7 +58,6 @@ namespace System.Xml.Serialization
_importer.UseEncodedFormat = true;
}
#if NET_2_0
public SoapSchemaImporter (XmlSchemas schemas, CodeGenerationOptions options, ImportContext context)
{
@ -81,7 +78,6 @@ namespace System.Xml.Serialization
_importer.UseEncodedFormat = true;
}
#endif
#endregion // Constructors

View File

@ -32,9 +32,7 @@
using System;
using System.Collections;
#if NET_2_0
using System.Collections.Generic;
#endif
using System.Globalization;
using System.Reflection;
using System.Text;
@ -89,10 +87,8 @@ namespace System.Xml.Serialization
public TypeData (Type type, string elementName, bool isPrimitive, TypeData mappedType, XmlSchemaPatternFacet facet)
{
#if NET_2_0
if (type.IsGenericTypeDefinition)
throw new InvalidOperationException ("Generic type definition cannot be used in serialization. Only specific generic types can be used.");
#endif
this.mappedType = mappedType;
this.facet = facet;
this.type = type;
@ -139,12 +135,10 @@ namespace System.Xml.Serialization
void LookupTypeConvertor ()
{
#if NET_4_5
// We only need this for System.Xml.Linq.
var convertor = type.GetCustomAttribute<XmlTypeConvertorAttribute> ();
if (convertor != null)
typeConvertor = type.GetMethod (convertor.Method, BindingFlags.Static | BindingFlags.NonPublic);
#endif
}
internal void ConvertForAssignment (ref object value)
@ -217,7 +211,6 @@ namespace System.Xml.Serialization
sb.Append (']');
return sb.ToString ();
}
#if NET_2_0
// Generic nested types return the complete list of type arguments,
// including type arguments for the declaring class. This requires
// some special handling
@ -249,7 +242,6 @@ namespace System.Xml.Serialization
sb.Insert (0, type.Namespace + ".");
return sb.ToString ();
}
#endif
if (type.DeclaringType != null) {
sb.Append (ToCSharpName (type.DeclaringType, full)).Append ('.');
sb.Append (type.Name);
@ -318,14 +310,10 @@ namespace System.Xml.Serialization
{
if (nullableOverride)
return true;
#if NET_2_0
return !IsValueType ||
(type != null &&
type.IsGenericType &&
type.GetGenericTypeDefinition () == typeof (Nullable<>));
#else
return !IsValueType;
#endif
}
set
@ -359,11 +347,7 @@ namespace System.Xml.Serialization
throw new InvalidOperationException (Type.FullName + " is not a collection");
else if (type.IsArray)
listItemType = type.GetElementType ();
#if NET_2_0
else if (typeof (ICollection).IsAssignableFrom (type) || (genericArgument = GetGenericListItemType (type)) != null)
#else
else if (typeof (ICollection).IsAssignableFrom (type))
#endif
{
if (typeof (IDictionary).IsAssignableFrom (type))
throw new NotSupportedException (string.Format (CultureInfo.InvariantCulture,
@ -480,12 +464,9 @@ namespace System.Xml.Serialization
"namespace",
"object","bool","byte","float","uint","char","ulong","ushort",
"decimal","int","sbyte","short","double","long","string","void",
#if NET_2_0
"partial", "yield", "where"
#endif
};
#if NET_2_0
internal static Type GetGenericListItemType (Type type)
{
if (type.IsGenericType && typeof(IEnumerable).IsAssignableFrom(type.GetGenericTypeDefinition ())) {
@ -499,6 +480,5 @@ namespace System.Xml.Serialization
return t;
return null;
}
#endif
}
}

View File

@ -116,7 +116,6 @@ namespace System.Xml.Serialization
primitiveTypes.Add ("base64", new TypeData (typeof (byte[]), "base64", true));
primitiveTypes.Add ("duration", new TypeData (typeof (string), "duration", true));
#if NET_2_0
nullableTypes = Hashtable.Synchronized(new Hashtable ());
foreach (DictionaryEntry de in primitiveTypes) {
TypeData td = (TypeData) de.Value;
@ -124,7 +123,6 @@ namespace System.Xml.Serialization
ntd.IsNullable = true;
nullableTypes.Add (de.Key, ntd);
}
#endif
}
public static TypeData GetTypeData (Type type)
@ -139,7 +137,6 @@ namespace System.Xml.Serialization
Type type = runtimeType;
bool nullableOverride = false;
#if NET_2_0
// Nullable<T> is serialized as T
if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>)) {
nullableOverride = true;
@ -188,7 +185,6 @@ namespace System.Xml.Serialization
return tt;
}
}
#endif
TypeData typeData = nameCache[runtimeType] as TypeData;
if (typeData != null) return typeData;
@ -199,7 +195,6 @@ namespace System.Xml.Serialization
string sufix = GetTypeData (type.GetElementType ()).XmlType;
name = GetArrayName (sufix);
}
#if NET_2_0
else if (type.IsGenericType && !type.IsGenericTypeDefinition) {
name = XmlConvert.EncodeLocalName (type.Name.Substring (0, type.Name.IndexOf ('`'))) + "Of";
foreach (Type garg in type.GetGenericArguments ())
@ -207,7 +202,6 @@ namespace System.Xml.Serialization
GetTypeData (garg).XmlType :
CodeIdentifier.MakePascal (XmlConvert.EncodeLocalName (garg.Name));
}
#endif
else
name = XmlConvert.EncodeLocalName (type.Name);

View File

@ -31,9 +31,6 @@ using System;
namespace System.Xml.Serialization {
#if !NET_2_0
[Serializable]
#endif
public delegate void UnreferencedObjectEventHandler (object sender, UnreferencedObjectEventArgs e);
}

View File

@ -82,10 +82,8 @@ namespace System.Xml.Serialization
get { return isNamespaceSpecified; }
}
#if NET_2_0
[MonoTODO]
internal bool IsNullableSpecified { get; set; }
#endif
public int Order {
get { return order; }

View File

@ -42,9 +42,7 @@ namespace System.Xml.Serialization
private int lineNumber;
private int linePosition;
private object obj;
#if NET_2_0
private string expectedAttributes;
#endif
internal XmlAttributeEventArgs(XmlAttribute attr, int lineNum, int linePos, object source)
{
@ -70,11 +68,9 @@ namespace System.Xml.Serialization
get{ return obj; }
}
#if NET_2_0
public string ExpectedAttributes {
get { return expectedAttributes; }
internal set { expectedAttributes = value; }
}
#endif
}
}

View File

@ -31,9 +31,6 @@ using System;
namespace System.Xml.Serialization {
#if !NET_2_0
[Serializable]
#endif
public delegate void XmlAttributeEventHandler (object sender, XmlAttributeEventArgs e);
}

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