mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
* MapCodeGenerator.cs: Do not generate base class if it is an XmlNode. Generate types using GetDomType, so if the type is an array, it creates the correct combination of types. * SerializationCodeGenerator.cs, XmlTypeMapping.cs: When trying to parse an enum, if the string is empty and the enum has [Flags], then return 0 as value. This fixes bug #55509. * XmlSchemaImporter.cs: Added check for redefines of attribute groups. They are not supported. Another check: a simple type cannot be enum if it does not have any enum facet. And another fix: use string as default type for attribtues. * XmlSchemas.cs: Fixed search for schema elements. An schema may import other schemas. An imported schema would not be in the table, but its elements (although from another namespace) would be in the schema that imported it. So, we need know to check for every schema in the table. * XmlSerializer.cs: Added environment variable to help debugging code generator output. svn path=/trunk/mcs/; revision=23957
54 lines
1.1 KiB
C#
54 lines
1.1 KiB
C#
//
|
|
// System.Xml.Serialization.CodeIdentifier.cs
|
|
//
|
|
// Author:
|
|
// Tim Coleman ([email protected])
|
|
//
|
|
// Copyright (C) Tim Coleman, 2002
|
|
//
|
|
|
|
using System;
|
|
|
|
namespace System.Xml.Serialization {
|
|
public class CodeIdentifier {
|
|
|
|
public CodeIdentifier ()
|
|
{
|
|
}
|
|
|
|
public static string MakeCamel (string identifier)
|
|
{
|
|
string validIdentifier = MakeValid (identifier);
|
|
return (Char.ToLower (validIdentifier[0]) + validIdentifier.Substring (1));
|
|
}
|
|
|
|
public static string MakePascal (string identifier)
|
|
{
|
|
string validIdentifier = MakeValid (identifier);
|
|
return (Char.ToUpper (validIdentifier[0]) + validIdentifier.Substring (1));
|
|
}
|
|
|
|
public static string MakeValid (string identifier)
|
|
{
|
|
if (identifier == null)
|
|
throw new NullReferenceException ();
|
|
if (identifier.Length == 0)
|
|
return identifier;
|
|
|
|
string output = "";
|
|
|
|
if (!Char.IsLetter (identifier[0]) && (identifier[0]!='_') )
|
|
output = "Item";
|
|
|
|
foreach (char c in identifier)
|
|
if (Char.IsLetterOrDigit (c) || c == '_')
|
|
output += c;
|
|
|
|
if (output.Length > 400)
|
|
output = output.Substring (0,400);
|
|
|
|
return output;
|
|
}
|
|
}
|
|
}
|