diff options
author | Jb Evain <jbevain@gmail.com> | 2010-01-13 16:28:35 +0300 |
---|---|---|
committer | Jb Evain <jbevain@gmail.com> | 2010-01-13 16:28:35 +0300 |
commit | a5f096e879aaf42cf2e1f4c0c795fb39d6f657c5 (patch) | |
tree | 1f3619a1b9fc2036b8133b9f9bc5290a7653dfa9 /mcs/tools | |
parent | 694b59cf8a99bf687bd07c730bd0f4b11e051e51 (diff) |
2010-01-13 Jb Evain <jbevain@novell.com>
* MarkStep.cs: preserve methods specified by the
XmlSchemaProvider attribute.
backport r149460.
svn path=/branches/mono-2-6/mcs/; revision=149461
Diffstat (limited to 'mcs/tools')
-rw-r--r-- | mcs/tools/linker/ChangeLog | 9 | ||||
-rw-r--r-- | mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs | 45 |
2 files changed, 53 insertions, 1 deletions
diff --git a/mcs/tools/linker/ChangeLog b/mcs/tools/linker/ChangeLog index 2d09299921c..8519d5371d4 100644 --- a/mcs/tools/linker/ChangeLog +++ b/mcs/tools/linker/ChangeLog @@ -1,4 +1,11 @@ -2010-12-06 Jb Evain <jbevain@novell.com> +2010-01-13 Jb Evain <jbevain@novell.com> + + * MarkStep.cs: preserve methods specified by the + XmlSchemaProvider attribute. + + backport r149460. + +2010-01-06 Jb Evain <jbevain@novell.com> * Descriptors/mscorlib.xml: optimize descriptor. diff --git a/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs b/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs index f68d6039d27..9e8235b6e40 100644 --- a/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs +++ b/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs @@ -385,6 +385,8 @@ namespace Mono.Linker.Steps { MarkMethodsIf (type.Constructors, IsSpecialSerializationConstructorPredicate); } + MarkXmlSchemaProvider (type); + MarkGenericParameterProvider (type); if (type.IsValueType) @@ -406,6 +408,49 @@ namespace Mono.Linker.Steps { ApplyPreserveInfo (type); } + void MarkXmlSchemaProvider (TypeDefinition type) + { + if (!type.HasCustomAttributes) + return; + + foreach (CustomAttribute attribute in type.CustomAttributes) { + if (!IsXmlSchemaProvider (attribute)) + continue; + + MarkXmlSchemaProvider (type, attribute); + } + } + + void MarkXmlSchemaProvider (TypeDefinition type, CustomAttribute attribute) + { + if (!attribute.Resolved || attribute.ConstructorParameters.Count < 1) + return; + + var method_name = attribute.ConstructorParameters [0] as string; + if (method_name == null) + return; + + MarkNamedMethod (type, method_name); + } + + void MarkNamedMethod (TypeDefinition type, string method_name) + { + if (!type.HasMethods) + return; + + foreach (MethodDefinition method in type.Methods) { + if (method.Name != method_name) + continue; + + MarkMethod (method); + } + } + + static bool IsXmlSchemaProvider (CustomAttribute attribute) + { + return attribute.Constructor.DeclaringType.FullName == "System.Xml.Serialization.XmlSchemaProviderAttribute"; + } + void MarkGenericParameterProvider (IGenericParameterProvider provider) { if (!provider.HasGenericParameters) |