Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/linker
diff options
context:
space:
mode:
authorEugene Rozenfeld <erozen@microsoft.com>2017-03-31 03:02:37 +0300
committerEugene Rozenfeld <erozen@microsoft.com>2017-04-01 09:37:46 +0300
commitf489c8c3fbe0c0d25cf367a0d9c408bfc8fa1040 (patch)
tree1371a47719b252a738480fa80e3568fa7952f2da /linker
parentd6910ee0d3374b2bb1808d3b4edbf68a47c532c5 (diff)
Mark members of Event-related types.
1. Mark static fields in Keywords, Tasks, and Opcodes classes nested inside EventSource-derived classes. Details on the pattern relying on this are described here: https://msdn.microsoft.com/en-us/library/dn774985(v=pandp.20).aspx 2. Mark public instance properties inside types with EventDataAttribute. Details are here: https://msdn.microsoft.com/en-us/library/dn823294(v=vs.110).aspx
Diffstat (limited to 'linker')
-rw-r--r--linker/Mono.Linker.Steps/MarkStep.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/linker/Mono.Linker.Steps/MarkStep.cs b/linker/Mono.Linker.Steps/MarkStep.cs
index 1e48b68d4..2ad7d508b 100644
--- a/linker/Mono.Linker.Steps/MarkStep.cs
+++ b/linker/Mono.Linker.Steps/MarkStep.cs
@@ -565,6 +565,10 @@ namespace Mono.Linker.Steps {
if (IsSerializable (type))
MarkSerializable (type);
+ if (IsEventSource (type)) {
+ MarkEventSource (type);
+ }
+
MarkTypeSpecialCustomAttributes (type);
MarkGenericParameterProvider (type);
@@ -616,6 +620,9 @@ namespace Mono.Linker.Steps {
case "System.Diagnostics.DebuggerTypeProxyAttribute":
MarkTypeWithDebuggerTypeProxyAttribute (type, attribute);
break;
+ case "System.Diagnostics.Tracing.EventDataAttribute":
+ MarkTypeWithEventDataAttribute (type, attribute);
+ break;
}
}
}
@@ -634,6 +641,11 @@ namespace Mono.Linker.Steps {
}
}
+ void MarkTypeWithEventDataAttribute (TypeDefinition type, CustomAttribute attribute)
+ {
+ MarkMethodsIf (type.Methods, IsPublicInstancePropertyMethod);
+ }
+
void MarkXmlSchemaProvider (TypeDefinition type, CustomAttribute attribute)
{
string method_name;
@@ -897,6 +909,33 @@ namespace Mono.Linker.Steps {
return td.BaseType != null && td.BaseType.FullName == "System.MulticastDelegate";
}
+ bool IsEventSource (TypeDefinition td)
+ {
+ TypeReference type = td;
+ do {
+ if (type.FullName == "System.Diagnostics.Tracing.EventSource") {
+ return true;
+ }
+
+ TypeDefinition typeDef = type.Resolve ();
+ if (typeDef == null) {
+ HandleUnresolvedType (type);
+ return false;
+ }
+ type = typeDef.BaseType;
+ } while (type != null);
+ return false;
+ }
+
+ void MarkEventSource (TypeDefinition td)
+ {
+ foreach (var nestedType in td.NestedTypes) {
+ if (nestedType.Name == "Keywords" || nestedType.Name == "Tasks" || nestedType.Name == "Opcodes") {
+ MarkStaticFields (nestedType);
+ }
+ }
+ }
+
protected TypeDefinition ResolveTypeDefinition (TypeReference type)
{
TypeDefinition td = type as TypeDefinition;
@@ -1028,6 +1067,17 @@ namespace Mono.Linker.Steps {
}
}
+ protected void MarkStaticFields(TypeDefinition type)
+ {
+ if (!type.HasFields)
+ return;
+
+ foreach (FieldDefinition field in type.Fields) {
+ if (field.IsStatic)
+ MarkField (field);
+ }
+ }
+
protected virtual void MarkMethods (TypeDefinition type)
{
if (type.HasMethods)
@@ -1223,6 +1273,11 @@ namespace Mono.Linker.Steps {
(md.SemanticsAttributes & MethodSemanticsAttributes.Setter) != 0;
}
+ static internal bool IsPublicInstancePropertyMethod (MethodDefinition md)
+ {
+ return md.IsPublic && !md.IsStatic && IsPropertyMethod (md);
+ }
+
static bool IsEventMethod (MethodDefinition md)
{
return (md.SemanticsAttributes & MethodSemanticsAttributes.AddOn) != 0 ||