Merge branch 'upstream'

Former-commit-id: d5e3c8d72df7d8d9f54f2dfe50084361d3275244
This commit is contained in:
Xamarin Public Jenkins (auto-signing) 2018-05-25 08:48:26 +00:00
commit 5d369969bc
50 changed files with 281 additions and 138 deletions

View File

@ -1 +1 @@
8dde0017e6f63b3054466a77bab8ef5722a54870 a716110cdcded6f6c9a459907b56b1f4d6eeadbe

View File

@ -1 +1 @@
43264e0ee4e38c606242bd6d2a3541ca4b06049f 1b47868002d8f5b8e4c85708dc50e855d259353b

View File

@ -34,3 +34,5 @@ corebuild/global.json
corebuild/**/bin corebuild/**/bin
corebuild/**/obj corebuild/**/obj
corebuild/testbin corebuild/testbin
monobuild/TestResults.xml

View File

@ -12,6 +12,7 @@ namespace Microsoft.NET.Build.Tasks
internal class LockFileCache internal class LockFileCache
{ {
private IBuildEngine4 _buildEngine; private IBuildEngine4 _buildEngine;
private static string s_taskObjectPrefix = null;
public LockFileCache(IBuildEngine4 buildEngine) public LockFileCache(IBuildEngine4 buildEngine)
{ {
@ -45,7 +46,11 @@ namespace Microsoft.NET.Build.Tasks
private static string GetTaskObjectKey(string lockFilePath) private static string GetTaskObjectKey(string lockFilePath)
{ {
return $"{nameof(LockFileCache)}:{lockFilePath}"; if (s_taskObjectPrefix == null)
{
s_taskObjectPrefix = typeof(LockFile).AssemblyQualifiedName;
}
return $"{s_taskObjectPrefix}:{lockFilePath}";
} }
private LockFile LoadLockFile(string path) private LockFile LoadLockFile(string path)

View File

@ -47,7 +47,7 @@ namespace Mono.Linker.Steps {
try { try {
Context.LogMessage ("Processing resource linker descriptor: {0}", name); Context.LogMessage ("Processing resource linker descriptor: {0}", name);
Context.Pipeline.AddStepAfter (typeof (TypeMapStep), GetResolveStep (name)); AddToPipeline (GetResolveStep (name));
} catch (XmlException ex) { } catch (XmlException ex) {
/* This could happen if some broken XML file is included. */ /* This could happen if some broken XML file is included. */
Context.LogMessage ("Error processing {0}: {1}", name, ex); Context.LogMessage ("Error processing {0}: {1}", name, ex);
@ -64,7 +64,7 @@ namespace Mono.Linker.Steps {
try { try {
Context.LogMessage ("Processing embedded resource linker descriptor: {0}", rsc.Name); Context.LogMessage ("Processing embedded resource linker descriptor: {0}", rsc.Name);
Context.Pipeline.AddStepAfter (typeof (TypeMapStep), GetExternalResolveStep (rsc, asm)); AddToPipeline (GetExternalResolveStep (rsc, asm));
} catch (XmlException ex) { } catch (XmlException ex) {
/* This could happen if some broken XML file is embedded. */ /* This could happen if some broken XML file is embedded. */
Context.LogMessage ("Error processing {0}: {1}", rsc.Name, ex); Context.LogMessage ("Error processing {0}: {1}", rsc.Name, ex);
@ -108,6 +108,11 @@ namespace Mono.Linker.Steps {
return null; return null;
} }
protected virtual void AddToPipeline (IStep resolveStep)
{
Context.Pipeline.AddStepAfter (typeof (BlacklistStep), resolveStep);
}
protected virtual IStep GetExternalResolveStep (EmbeddedResource resource, AssemblyDefinition assembly) protected virtual IStep GetExternalResolveStep (EmbeddedResource resource, AssemblyDefinition assembly)
{ {
return new ResolveFromXmlStep (GetExternalDescriptor (resource), resource.Name, assembly, "resource " + resource.Name + " in " + assembly.FullName); return new ResolveFromXmlStep (GetExternalDescriptor (resource), resource.Name, assembly, "resource " + resource.Name + " in " + assembly.FullName);

View File

@ -27,7 +27,7 @@
// //
using System; using System;
using System.Linq;
using Mono.Cecil; using Mono.Cecil;
namespace Mono.Linker.Steps { namespace Mono.Linker.Steps {
@ -46,7 +46,7 @@ namespace Mono.Linker.Steps {
protected override bool ConditionToProcess () protected override bool ConditionToProcess ()
{ {
return _assemblies != I18nAssemblies.None && return _assemblies != I18nAssemblies.None &&
Type.GetType ("System.MonoType") != null; Context.GetAssemblies ().FirstOrDefault (a => a.Name.Name == "mscorlib")?.MainModule.GetType ("System.MonoType") != null;
} }
protected override void Process() protected override void Process()

View File

@ -49,6 +49,8 @@ namespace Mono.Linker.Steps {
_references.Add (assembly.Name, assembly); _references.Add (assembly.Name, assembly);
Context.RegisterAssembly (assembly);
foreach (AssemblyDefinition referenceDefinition in Context.ResolveReferences (assembly)) { foreach (AssemblyDefinition referenceDefinition in Context.ResolveReferences (assembly)) {
try { try {
ProcessReferences (referenceDefinition); ProcessReferences (referenceDefinition);

View File

@ -43,10 +43,8 @@ namespace Mono.Linker.Steps {
protected LinkContext _context; protected LinkContext _context;
protected Queue<MethodDefinition> _methods; protected Queue<MethodDefinition> _methods;
protected List<MethodDefinition> _virtual_methods; protected List<MethodDefinition> _virtual_methods;
protected Dictionary<TypeDefinition, CustomAttribute> _assemblyDebuggerDisplayAttributes; protected Queue<AttributeProviderPair> _assemblyLevelAttributes;
protected Dictionary<TypeDefinition, CustomAttribute> _assemblyDebuggerTypeProxyAttributes; protected Queue<AttributeProviderPair> _lateMarkedAttributes;
protected Queue<CustomAttribute> _topLevelAttributes;
protected Queue<CustomAttribute> _lateMarkedAttributes;
public AnnotationStore Annotations { public AnnotationStore Annotations {
get { return _context.Annotations; } get { return _context.Annotations; }
@ -62,11 +60,8 @@ namespace Mono.Linker.Steps {
{ {
_methods = new Queue<MethodDefinition> (); _methods = new Queue<MethodDefinition> ();
_virtual_methods = new List<MethodDefinition> (); _virtual_methods = new List<MethodDefinition> ();
_topLevelAttributes = new Queue<CustomAttribute> (); _assemblyLevelAttributes = new Queue<AttributeProviderPair> ();
_lateMarkedAttributes = new Queue<CustomAttribute> (); _lateMarkedAttributes = new Queue<AttributeProviderPair> ();
_assemblyDebuggerDisplayAttributes = new Dictionary<TypeDefinition, CustomAttribute> ();
_assemblyDebuggerTypeProxyAttributes = new Dictionary<TypeDefinition, CustomAttribute> ();
} }
public virtual void Process (LinkContext context) public virtual void Process (LinkContext context)
@ -260,9 +255,9 @@ namespace Mono.Linker.Steps {
foreach (CustomAttribute ca in provider.CustomAttributes) { foreach (CustomAttribute ca in provider.CustomAttributes) {
if (_context.KeepUsedAttributeTypesOnly) { if (_context.KeepUsedAttributeTypesOnly) {
_lateMarkedAttributes.Enqueue (ca); _lateMarkedAttributes.Enqueue (new AttributeProviderPair (ca, provider));
} else { } else {
if (!ShouldMarkCustomAttribute (ca)) if (!ShouldMarkCustomAttribute (ca, provider))
continue; continue;
MarkCustomAttribute (ca); MarkCustomAttribute (ca);
@ -273,13 +268,13 @@ namespace Mono.Linker.Steps {
} }
} }
void LazyMarkCustomAttributes (ICustomAttributeProvider provider) void LazyMarkCustomAttributes (ICustomAttributeProvider provider, AssemblyDefinition assembly)
{ {
if (!provider.HasCustomAttributes) if (!provider.HasCustomAttributes)
return; return;
foreach (CustomAttribute ca in provider.CustomAttributes) foreach (CustomAttribute ca in provider.CustomAttributes)
_topLevelAttributes.Enqueue (ca); _assemblyLevelAttributes.Enqueue (new AttributeProviderPair (ca, assembly));
} }
protected virtual void MarkCustomAttribute (CustomAttribute ca) protected virtual void MarkCustomAttribute (CustomAttribute ca)
@ -306,7 +301,7 @@ namespace Mono.Linker.Steps {
} }
} }
protected virtual bool ShouldMarkCustomAttribute (CustomAttribute ca) protected virtual bool ShouldMarkCustomAttribute (CustomAttribute ca, ICustomAttributeProvider provider)
{ {
if (_context.KeepUsedAttributeTypesOnly) { if (_context.KeepUsedAttributeTypesOnly) {
switch (ca.AttributeType.FullName) { switch (ca.AttributeType.FullName) {
@ -323,16 +318,27 @@ namespace Mono.Linker.Steps {
return true; return true;
} }
protected virtual bool ShouldMarkTopLevelCustomAttribute (CustomAttribute ca, MethodDefinition resolvedConstructor) protected virtual bool ShouldMarkTopLevelCustomAttribute (AttributeProviderPair app, MethodDefinition resolvedConstructor)
{ {
if (!ShouldMarkCustomAttribute (ca)) var ca = app.Attribute;
if (!ShouldMarkCustomAttribute (app.Attribute, app.Provider))
return false; return false;
// If an attribute's module has not been marked after processing all types in all assemblies and the attribute itself has not been marked, // If an attribute's module has not been marked after processing all types in all assemblies and the attribute itself has not been marked,
// then surely nothing is using this attribute and there is no need to mark it // then surely nothing is using this attribute and there is no need to mark it
if (!Annotations.IsMarked (resolvedConstructor.Module) && !Annotations.IsMarked (ca.AttributeType)) if (!Annotations.IsMarked (resolvedConstructor.Module) && !Annotations.IsMarked (ca.AttributeType))
return false; return false;
if (ca.Constructor.DeclaringType.Namespace == "System.Diagnostics") {
string attributeName = ca.Constructor.DeclaringType.Name;
if (attributeName == "DebuggerDisplayAttribute" || attributeName == "DebuggerTypeProxyAttribute") {
var displayTargetType = GetDebuggerAttributeTargetType (app.Attribute, (AssemblyDefinition) app.Provider);
if (displayTargetType == null || !Annotations.IsMarked (displayTargetType))
return false;
}
}
return true; return true;
} }
@ -541,7 +547,7 @@ namespace Mono.Linker.Steps {
MarkSecurityDeclarations (assembly); MarkSecurityDeclarations (assembly);
foreach (ModuleDefinition module in assembly.Modules) foreach (ModuleDefinition module in assembly.Modules)
LazyMarkCustomAttributes (module); LazyMarkCustomAttributes (module, assembly);
} }
void ProcessModule (AssemblyDefinition assembly) void ProcessModule (AssemblyDefinition assembly)
@ -560,15 +566,16 @@ namespace Mono.Linker.Steps {
bool ProcessLazyAttributes () bool ProcessLazyAttributes ()
{ {
var startingQueueCount = _topLevelAttributes.Count; var startingQueueCount = _assemblyLevelAttributes.Count;
if (startingQueueCount == 0) if (startingQueueCount == 0)
return false; return false;
var skippedItems = new List<CustomAttribute> (); var skippedItems = new List<AttributeProviderPair> ();
var markOccurred = false; var markOccurred = false;
while (_topLevelAttributes.Count != 0) { while (_assemblyLevelAttributes.Count != 0) {
var customAttribute = _topLevelAttributes.Dequeue (); var assemblyLevelAttribute = _assemblyLevelAttributes.Dequeue ();
var customAttribute = assemblyLevelAttribute.Attribute;
var resolved = customAttribute.Constructor.Resolve (); var resolved = customAttribute.Constructor.Resolve ();
if (resolved == null) { if (resolved == null) {
@ -576,18 +583,28 @@ namespace Mono.Linker.Steps {
continue; continue;
} }
if (!ShouldMarkTopLevelCustomAttribute (customAttribute, resolved)) { if (!ShouldMarkTopLevelCustomAttribute (assemblyLevelAttribute, resolved)) {
skippedItems.Add (customAttribute); skippedItems.Add (assemblyLevelAttribute);
continue; continue;
} }
string attributeFullName = customAttribute.Constructor.DeclaringType.FullName;
switch (attributeFullName) {
case "System.Diagnostics.DebuggerDisplayAttribute":
MarkTypeWithDebuggerDisplayAttribute (GetDebuggerAttributeTargetType (assemblyLevelAttribute.Attribute, (AssemblyDefinition) assemblyLevelAttribute.Provider), customAttribute);
break;
case "System.Diagnostics.DebuggerTypeProxyAttribute":
MarkTypeWithDebuggerTypeProxyAttribute (GetDebuggerAttributeTargetType (assemblyLevelAttribute.Attribute, (AssemblyDefinition) assemblyLevelAttribute.Provider), customAttribute);
break;
}
markOccurred = true; markOccurred = true;
MarkCustomAttribute (customAttribute); MarkCustomAttribute (customAttribute);
} }
// requeue the items we skipped in case we need to make another pass // requeue the items we skipped in case we need to make another pass
foreach (var item in skippedItems) foreach (var item in skippedItems)
_topLevelAttributes.Enqueue (item); _assemblyLevelAttributes.Enqueue (item);
return markOccurred; return markOccurred;
} }
@ -598,11 +615,12 @@ namespace Mono.Linker.Steps {
if (startingQueueCount == 0) if (startingQueueCount == 0)
return false; return false;
var skippedItems = new List<CustomAttribute> (); var skippedItems = new List<AttributeProviderPair> ();
var markOccurred = false; var markOccurred = false;
while (_lateMarkedAttributes.Count != 0) { while (_lateMarkedAttributes.Count != 0) {
var customAttribute = _lateMarkedAttributes.Dequeue (); var attributeProviderPair = _lateMarkedAttributes.Dequeue ();
var customAttribute = attributeProviderPair.Attribute;
var resolved = customAttribute.Constructor.Resolve (); var resolved = customAttribute.Constructor.Resolve ();
if (resolved == null) { if (resolved == null) {
@ -610,8 +628,8 @@ namespace Mono.Linker.Steps {
continue; continue;
} }
if (!ShouldMarkCustomAttribute (customAttribute)) { if (!ShouldMarkCustomAttribute (customAttribute, attributeProviderPair.Provider)) {
skippedItems.Add (customAttribute); skippedItems.Add (attributeProviderPair);
continue; continue;
} }
@ -771,59 +789,38 @@ namespace Mono.Linker.Steps {
if (!assembly.HasCustomAttributes) if (!assembly.HasCustomAttributes)
return; return;
foreach (CustomAttribute attribute in assembly.CustomAttributes) { foreach (CustomAttribute attribute in assembly.CustomAttributes)
string attributeFullName = attribute.Constructor.DeclaringType.FullName; _assemblyLevelAttributes.Enqueue (new AttributeProviderPair (attribute, assembly));
switch (attributeFullName) {
case "System.Diagnostics.DebuggerDisplayAttribute":
StoreDebuggerTypeTarget (assembly, attribute, _assemblyDebuggerDisplayAttributes);
break;
case "System.Diagnostics.DebuggerTypeProxyAttribute":
StoreDebuggerTypeTarget (assembly, attribute, _assemblyDebuggerTypeProxyAttributes);
break;
default:
_topLevelAttributes.Enqueue (attribute);
break;
}
}
} }
void StoreDebuggerTypeTarget (AssemblyDefinition assembly, CustomAttribute attribute, Dictionary<TypeDefinition, CustomAttribute> dictionary) TypeDefinition GetDebuggerAttributeTargetType (CustomAttribute ca, AssemblyDefinition asm)
{ {
if (_context.KeepMembersForDebuggerAttributes) { TypeReference targetTypeReference = null;
TypeReference targetTypeReference = null; foreach (var property in ca.Properties) {
TypeDefinition targetTypeDefinition = null; if (property.Name == "Target") {
foreach (var property in attribute.Properties) { targetTypeReference = (TypeReference) property.Argument.Value;
if (property.Name == "Target") { break;
targetTypeReference = (TypeReference) property.Argument.Value;
break;
}
if (property.Name == "TargetTypeName") {
targetTypeReference = assembly.MainModule.GetType ((string) property.Argument.Value);
break;
}
} }
if (targetTypeReference != null) { if (property.Name == "TargetTypeName") {
targetTypeDefinition = ResolveTypeDefinition (targetTypeReference); if (TypeNameParser.TryParseTypeAssemblyQualifiedName ((string) property.Argument.Value, out string typeName, out string assemblyName)) {
if (targetTypeDefinition != null) { if (string.IsNullOrEmpty (assemblyName))
dictionary[targetTypeDefinition] = attribute; targetTypeReference = asm.MainModule.GetType (typeName);
else
targetTypeReference = _context.GetAssemblies ().FirstOrDefault (a => a.Name.Name == assemblyName)?.MainModule.GetType (typeName);
} }
break;
} }
} }
}
if (targetTypeReference != null)
return ResolveTypeDefinition (targetTypeReference);
return null;
}
void MarkTypeSpecialCustomAttributes (TypeDefinition type) void MarkTypeSpecialCustomAttributes (TypeDefinition type)
{ {
CustomAttribute debuggerAttribute;
if (_assemblyDebuggerDisplayAttributes.TryGetValue (type, out debuggerAttribute)) {
MarkTypeWithDebuggerDisplayAttribute (type, debuggerAttribute);
}
if (_assemblyDebuggerTypeProxyAttributes.TryGetValue (type, out debuggerAttribute)) {
MarkTypeWithDebuggerTypeProxyAttribute (type, debuggerAttribute);
}
if (!type.HasCustomAttributes) if (!type.HasCustomAttributes)
return; return;
@ -1161,7 +1158,7 @@ namespace Mono.Linker.Steps {
MarkMethodCollection (type.Methods); MarkMethodCollection (type.Methods);
} }
protected TypeDefinition ResolveTypeDefinition (TypeReference type) protected static TypeDefinition ResolveTypeDefinition (TypeReference type)
{ {
TypeDefinition td = type as TypeDefinition; TypeDefinition td = type as TypeDefinition;
if (td == null) if (td == null)
@ -1636,6 +1633,7 @@ namespace Mono.Linker.Steps {
MarkSomethingUsedViaReflection ("GetProperty", MarkPropertyUsedViaReflection, body.Instructions); MarkSomethingUsedViaReflection ("GetProperty", MarkPropertyUsedViaReflection, body.Instructions);
MarkSomethingUsedViaReflection ("GetField", MarkFieldUsedViaReflection, body.Instructions); MarkSomethingUsedViaReflection ("GetField", MarkFieldUsedViaReflection, body.Instructions);
MarkSomethingUsedViaReflection ("GetEvent", MarkEventUsedViaReflection, body.Instructions); MarkSomethingUsedViaReflection ("GetEvent", MarkEventUsedViaReflection, body.Instructions);
MarkTypeUsedViaReflection (body.Instructions);
} }
protected virtual void MarkInstruction (Instruction instruction) protected virtual void MarkInstruction (Instruction instruction)
@ -1684,22 +1682,30 @@ namespace Mono.Linker.Steps {
MarkType (iface.InterfaceType); MarkType (iface.InterfaceType);
} }
bool CheckReflectionMethod (Instruction instruction, string reflectionMethod)
{
if (instruction.OpCode != OpCodes.Call && instruction.OpCode != OpCodes.Callvirt)
return false;
var methodBeingCalled = instruction.Operand as MethodReference;
if (methodBeingCalled == null || methodBeingCalled.DeclaringType.Name != "Type" || methodBeingCalled.DeclaringType.Namespace != "System")
return false;
if (methodBeingCalled.Name != reflectionMethod)
return false;
return true;
}
void MarkSomethingUsedViaReflection (string reflectionMethod, Action<Collection<Instruction>, string, TypeDefinition, BindingFlags> markMethod, Collection<Instruction> instructions) void MarkSomethingUsedViaReflection (string reflectionMethod, Action<Collection<Instruction>, string, TypeDefinition, BindingFlags> markMethod, Collection<Instruction> instructions)
{ {
for (var i = 0; i < instructions.Count; i++) { for (var i = 0; i < instructions.Count; i++) {
var instruction = instructions [i]; var instruction = instructions [i];
if (instruction.OpCode != OpCodes.Call && instruction.OpCode != OpCodes.Callvirt)
if (!CheckReflectionMethod (instruction, reflectionMethod))
continue; continue;
var methodBeingCalled = instruction.Operand as MethodReference; _context.Tracer.Push ($"Reflection-{instruction.Operand as MethodReference}");
if (methodBeingCalled == null || methodBeingCalled.DeclaringType.Name != "Type" || methodBeingCalled.DeclaringType.Namespace != "System")
continue;
if (methodBeingCalled.Name != reflectionMethod)
continue;
_context.Tracer.Push ($"Reflection-{methodBeingCalled}");
var nameOfThingUsedViaReflection = OperandOfNearestInstructionBefore<string> (i, OpCodes.Ldstr, instructions); var nameOfThingUsedViaReflection = OperandOfNearestInstructionBefore<string> (i, OpCodes.Ldstr, instructions);
var bindingFlags = (BindingFlags) OperandOfNearestInstructionBefore<sbyte> (i, OpCodes.Ldc_I4_S, instructions); var bindingFlags = (BindingFlags) OperandOfNearestInstructionBefore<sbyte> (i, OpCodes.Ldc_I4_S, instructions);
@ -1715,6 +1721,35 @@ namespace Mono.Linker.Steps {
} }
} }
void MarkTypeUsedViaReflection (Collection<Instruction> instructions)
{
for (var i = 0; i < instructions.Count; i++) {
var instruction = instructions [i];
if (!CheckReflectionMethod (instruction, "GetType"))
continue;
_context.Tracer.Push ($"Reflection-{instruction.Operand as MethodReference}");
var typeAssemblyQualifiedName = OperandOfNearestInstructionBefore<string> (i, OpCodes.Ldstr, instructions);
if (!TypeNameParser.TryParseTypeAssemblyQualifiedName (typeAssemblyQualifiedName, out string typeName, out string assemblyName))
continue;
foreach (var assemblyDefinition in _context.GetAssemblies ()) {
if (assemblyName != null && assemblyDefinition.Name.Name != assemblyName)
continue;
var type = assemblyDefinition.MainModule.GetType (typeName);
if (type != null)
{
MarkType(type);
break;
}
}
_context.Tracer.Pop ();
}
}
void MarkConstructorsUsedViaReflection (Collection<Instruction> instructions, string unused, TypeDefinition declaringType, BindingFlags bindingFlags) void MarkConstructorsUsedViaReflection (Collection<Instruction> instructions, string unused, TypeDefinition declaringType, BindingFlags bindingFlags)
{ {
foreach (var method in declaringType.Methods) { foreach (var method in declaringType.Methods) {
@ -1796,6 +1831,17 @@ namespace Mono.Linker.Steps {
return operands; return operands;
} }
protected class AttributeProviderPair {
public AttributeProviderPair (CustomAttribute attribute, ICustomAttributeProvider provider)
{
Attribute = attribute;
Provider = provider;
}
public CustomAttribute Attribute { get; private set; }
public ICustomAttributeProvider Provider { get; private set; }
}
} }
// Make our own copy of the BindingFlags enum, so that we don't depend on System.Reflection. // Make our own copy of the BindingFlags enum, so that we don't depend on System.Reflection.

View File

@ -245,6 +245,12 @@ namespace Mono.Linker.Steps {
return; return;
} }
if (Annotations.IsMarked (type)) {
var existingLevel = Annotations.IsPreserved (type) ? Annotations.GetPreserve (type) : TypePreserve.Nothing;
var duplicateLevel = preserve != TypePreserve.Nothing ? preserve : nav.HasChildren ? TypePreserve.Nothing : TypePreserve.All;
Context.LogMessage ($"Duplicate preserve in {_xmlDocumentLocation} of {type.FullName} ({existingLevel}). Duplicate uses ({duplicateLevel})");
}
Annotations.MarkAndPush (type); Annotations.MarkAndPush (type);
Tracer.AddDirectDependency (this, type); Tracer.AddDirectDependency (this, type);
@ -341,10 +347,14 @@ namespace Mono.Linker.Steps {
void MarkField (TypeDefinition type, FieldDefinition field, string signature) void MarkField (TypeDefinition type, FieldDefinition field, string signature)
{ {
if (field != null) if (field != null) {
if (Annotations.IsMarked (field))
Context.LogMessage ($"Duplicate preserve in {_xmlDocumentLocation} of {field.FullName}");
Annotations.Mark (field); Annotations.Mark (field);
else } else {
AddUnresolveMarker (string.Format ("T: {0}; F: {1}", type, signature)); AddUnresolveMarker (string.Format ("T: {0}; F: {1}", type, signature));
}
} }
void ProcessFieldName (TypeDefinition type, string name) void ProcessFieldName (TypeDefinition type, string name)
@ -357,7 +367,7 @@ namespace Mono.Linker.Steps {
MarkField (type, field, name); MarkField (type, field, name);
} }
static FieldDefinition GetField (TypeDefinition type, string signature) protected static FieldDefinition GetField (TypeDefinition type, string signature)
{ {
if (!type.HasFields) if (!type.HasFields)
return null; return null;
@ -407,6 +417,9 @@ namespace Mono.Linker.Steps {
void MarkMethod (MethodDefinition method) void MarkMethod (MethodDefinition method)
{ {
if (Annotations.IsMarked (method))
Context.LogMessage ($"Duplicate preserve in {_xmlDocumentLocation} of {method.FullName}");
Annotations.Mark (method); Annotations.Mark (method);
Tracer.AddDirectDependency (this, method); Tracer.AddDirectDependency (this, method);
Annotations.SetAction (method, MethodAction.Parse); Annotations.SetAction (method, MethodAction.Parse);
@ -485,6 +498,9 @@ namespace Mono.Linker.Steps {
void MarkEvent (TypeDefinition type, EventDefinition @event, string signature) void MarkEvent (TypeDefinition type, EventDefinition @event, string signature)
{ {
if (@event != null) { if (@event != null) {
if (Annotations.IsMarked (@event))
Context.LogMessage ($"Duplicate preserve in {_xmlDocumentLocation} of {@event.FullName}");
Annotations.Mark (@event); Annotations.Mark (@event);
MarkMethod (@event.AddMethod); MarkMethod (@event.AddMethod);
@ -504,7 +520,7 @@ namespace Mono.Linker.Steps {
MarkEvent (type, @event, name); MarkEvent (type, @event, name);
} }
static EventDefinition GetEvent (TypeDefinition type, string signature) protected static EventDefinition GetEvent (TypeDefinition type, string signature)
{ {
if (!type.HasEvents) if (!type.HasEvents)
return null; return null;
@ -547,6 +563,9 @@ namespace Mono.Linker.Steps {
void MarkProperty (TypeDefinition type, PropertyDefinition property, string signature, string[] accessors) void MarkProperty (TypeDefinition type, PropertyDefinition property, string signature, string[] accessors)
{ {
if (property != null) { if (property != null) {
if (Annotations.IsMarked (property))
Context.LogMessage ($"Duplicate preserve in {_xmlDocumentLocation} of {property.FullName}");
Annotations.Mark (property); Annotations.Mark (property);
MarkPropertyAccessors (type, property, accessors); MarkPropertyAccessors (type, property, accessors);
@ -585,7 +604,7 @@ namespace Mono.Linker.Steps {
MarkProperty (type, property, name, accessors); MarkProperty (type, property, name, accessors);
} }
static PropertyDefinition GetProperty (TypeDefinition type, string signature) protected static PropertyDefinition GetProperty (TypeDefinition type, string signature)
{ {
if (!type.HasProperties) if (!type.HasProperties)
return null; return null;
@ -641,7 +660,7 @@ namespace Mono.Linker.Steps {
return GetAttribute (nav, _fullname); return GetAttribute (nav, _fullname);
} }
static string[] GetAccessors (XPathNavigator nav) protected static string[] GetAccessors (XPathNavigator nav)
{ {
string accessorsValue = GetAttribute (nav, _accessors); string accessorsValue = GetAttribute (nav, _accessors);

View File

@ -73,7 +73,7 @@ namespace Mono.Linker.Steps {
} }
} }
void SweepAssembly (AssemblyDefinition assembly) protected virtual void SweepAssembly (AssemblyDefinition assembly)
{ {
switch (Annotations.GetAction (assembly)) { switch (Annotations.GetAction (assembly)) {
case AssemblyAction.Link: case AssemblyAction.Link:

View File

@ -246,7 +246,13 @@ namespace Mono.Linker {
p.AddStepAfter (typeof (SweepStep), new AddBypassNGenStep ()); p.AddStepAfter (typeof (SweepStep), new AddBypassNGenStep ());
} }
p.Process (context); try {
p.Process (context);
}
finally {
if (dumpDependencies)
context.Tracer.Finish ();
}
} }
} }

View File

@ -212,10 +212,8 @@ namespace Mono.Linker {
try { try {
AssemblyDefinition assembly = _resolver.Resolve (reference, _readerParameters); AssemblyDefinition assembly = _resolver.Resolve (reference, _readerParameters);
if (assembly != null && SeenFirstTime (assembly)) { if (assembly != null)
SafeReadSymbols (assembly); RegisterAssembly (assembly);
SetAction (assembly);
}
return assembly; return assembly;
} }
@ -224,6 +222,14 @@ namespace Mono.Linker {
} }
} }
public void RegisterAssembly (AssemblyDefinition assembly)
{
if (SeenFirstTime (assembly)) {
SafeReadSymbols (assembly);
SetAction (assembly);
}
}
protected bool SeenFirstTime (AssemblyDefinition assembly) protected bool SeenFirstTime (AssemblyDefinition assembly)
{ {
return !_annotations.HasAction (assembly); return !_annotations.HasAction (assembly);
@ -245,8 +251,15 @@ namespace Mono.Linker {
if (symbolReader == null) if (symbolReader == null)
return; return;
try {
assembly.MainModule.ReadSymbols (symbolReader);
} catch {
symbolReader.Dispose ();
return;
}
// Add symbol reader to annotations only if we have successfully read it
_annotations.AddSymbolReader (assembly, symbolReader); _annotations.AddSymbolReader (assembly, symbolReader);
assembly.MainModule.ReadSymbols (symbolReader);
} catch { } } catch { }
} }
@ -289,7 +302,7 @@ namespace Mono.Linker {
_annotations.SetAction (assembly, action); _annotations.SetAction (assembly, action);
} }
static bool IsCore (AssemblyNameReference name) public static bool IsCore (AssemblyNameReference name)
{ {
switch (name.Name) { switch (name.Name) {
case "mscorlib": case "mscorlib":

View File

@ -58,6 +58,7 @@ namespace Mono.Linker
if (string.IsNullOrEmpty (Path.GetDirectoryName (DependenciesFileName)) && !string.IsNullOrEmpty (context.OutputDirectory)) { if (string.IsNullOrEmpty (Path.GetDirectoryName (DependenciesFileName)) && !string.IsNullOrEmpty (context.OutputDirectory)) {
DependenciesFileName = Path.Combine (context.OutputDirectory, DependenciesFileName); DependenciesFileName = Path.Combine (context.OutputDirectory, DependenciesFileName);
Directory.CreateDirectory (context.OutputDirectory);
} }
var depsFile = File.OpenWrite (DependenciesFileName); var depsFile = File.OpenWrite (DependenciesFileName);

View File

@ -0,0 +1,48 @@
using System;
namespace Mono.Linker {
public static class TypeNameParser {
public static bool TryParseTypeAssemblyQualifiedName (string value, out string typeName, out string assemblyName) {
if (string.IsNullOrEmpty (value)) {
typeName = null;
assemblyName = null;
return false;
}
//Filter the assembly qualified name down to the basic type by removing pointer, reference, and array markers on the type
//We must also convert nested types from + to / to match cecil's formatting
value = value
.Replace ('+', '/')
.Replace ("*", string.Empty)
.Replace ("&", string.Empty);
while (value.IndexOf ('[') > 0) {
var openidx = value.IndexOf ('[');
var closeidx = value.IndexOf (']');
// No matching close ] or out of order
if (closeidx < 0 || closeidx < openidx) {
typeName = null;
assemblyName = null;
return false;
}
value = value.Remove (openidx, closeidx + 1 - openidx);
}
var tokens = value.Split (',');
typeName = tokens [0].Trim ();
assemblyName = null;
if (tokens.Length > 1)
assemblyName = tokens [1].Trim ();
if (string.IsNullOrWhiteSpace (typeName)) {
typeName = null;
assemblyName = null;
return false;
}
return true;
}
}
}

View File

@ -93,6 +93,7 @@
<Compile Include="Linker\Pipeline.cs" /> <Compile Include="Linker\Pipeline.cs" />
<Compile Include="Linker\TypePreserve.cs" /> <Compile Include="Linker\TypePreserve.cs" />
<Compile Include="Linker\TypeReferenceExtensions.cs" /> <Compile Include="Linker\TypeReferenceExtensions.cs" />
<Compile Include="Linker\TypeNameParser.cs" />
<Compile Include="Linker\XApiReader.cs" /> <Compile Include="Linker\XApiReader.cs" />
<Compile Include="Linker.Steps\TypeMapStep.cs" /> <Compile Include="Linker.Steps\TypeMapStep.cs" />
<Compile Include="Linker\ILogger.cs" /> <Compile Include="Linker\ILogger.cs" />

View File

@ -34,7 +34,7 @@ static class Consts
// Use these assembly version constants to make code more maintainable. // Use these assembly version constants to make code more maintainable.
// //
public const string MonoVersion = "5.14.0.100"; public const string MonoVersion = "5.14.0.103";
public const string MonoCompany = "Mono development team"; public const string MonoCompany = "Mono development team";
public const string MonoProduct = "Mono Common Language Infrastructure"; public const string MonoProduct = "Mono Common Language Infrastructure";
public const string MonoCopyright = "(c) Various Mono authors"; public const string MonoCopyright = "(c) Various Mono authors";

View File

@ -339,7 +339,6 @@ namespace MonoTests.System.Threading.Tasks
bool result = false; bool result = false;
Func<int, int> func = (i) => { Func<int, int> func = (i) => {
Assert.IsTrue (Thread.CurrentThread.IsThreadPoolThread);
result = true; return i + 3; result = true; return i + 3;
}; };
@ -445,14 +444,12 @@ namespace MonoTests.System.Threading.Tasks
} }
[Test] [Test]
[Category ("MacNotWorking")] // Randomly fails - https://bugzilla.xamarin.com/show_bug.cgi?id=51255
public void FromAsync_Completed () public void FromAsync_Completed ()
{ {
var completed = new CompletedAsyncResult (); var completed = new CompletedAsyncResult ();
bool? valid = null; bool? valid = null;
Action<IAsyncResult> end = l => { Action<IAsyncResult> end = l => {
Assert.IsFalse (Thread.CurrentThread.IsThreadPoolThread, "#2");
valid = l == completed; valid = l == completed;
}; };
Task task = factory.FromAsync (completed, end); Task task = factory.FromAsync (completed, end);
@ -557,7 +554,6 @@ namespace MonoTests.System.Threading.Tasks
factory = new TaskFactory (scheduler); factory = new TaskFactory (scheduler);
Task task = factory.FromAsync (result, l => { Task task = factory.FromAsync (result, l => {
Assert.IsTrue (Thread.CurrentThread.IsThreadPoolThread, "#6");
called = true; called = true;
}, TaskCreationOptions.AttachedToParent); }, TaskCreationOptions.AttachedToParent);
@ -582,8 +578,6 @@ namespace MonoTests.System.Threading.Tasks
if ((TaskCreationOptions) c != TaskCreationOptions.AttachedToParent) if ((TaskCreationOptions) c != TaskCreationOptions.AttachedToParent)
Assert.Fail ("#11"); Assert.Fail ("#11");
Assert.IsFalse (Thread.CurrentThread.IsThreadPoolThread, "#12");
called2 = true; called2 = true;
var ar = Task.CompletedTask; var ar = Task.CompletedTask;
b.Invoke (ar); b.Invoke (ar);

View File

@ -1 +1 @@
387874c33279821ecf4c3c65c4b6be0fbf4530ca 1fce0633a2a5188d412fa7bed6596cdbf46eed99

View File

@ -1 +1 @@
94a0e366dc7a3a32249f013acdb108113871c9f0 5df81156024fc164400114fca16e4f834ba26389

View File

@ -1 +1 @@
b29ac60ca35d1e9dae87583d2b7183dd9bc0e356 e394ddb4f7e90f8160b816ceb2f3ddfd6ec43b20

View File

@ -1 +1 @@
dce6045ebed689ee7cc0cf98225aa3474f3eb3d8 c9706b15a376f8937072f1dfbd168d1058896a6e

View File

@ -1 +1 @@
fa787623a7ef5d34d480976111f5791b0d92c4a8 c34d1c37d97cfc74cfd58b908db37dba0cc12f68

View File

@ -1 +1 @@
80f27b413640ff25223e654724f276a4c6925abc 7df9781615674ecdde80b8234d890a4ff3983533

View File

@ -1 +1 @@
ffde4cb2ef12a7462c5b6e336ae8c5e27f8b79ed 45fc2f719b760217c096d2e896ae9a39a2f6c446

View File

@ -1 +1 @@
387874c33279821ecf4c3c65c4b6be0fbf4530ca 1fce0633a2a5188d412fa7bed6596cdbf46eed99

View File

@ -1 +1 @@
94a0e366dc7a3a32249f013acdb108113871c9f0 5df81156024fc164400114fca16e4f834ba26389

View File

@ -1 +1 @@
b29ac60ca35d1e9dae87583d2b7183dd9bc0e356 e394ddb4f7e90f8160b816ceb2f3ddfd6ec43b20

View File

@ -1 +1 @@
dce6045ebed689ee7cc0cf98225aa3474f3eb3d8 c9706b15a376f8937072f1dfbd168d1058896a6e

View File

@ -1 +1 @@
fa787623a7ef5d34d480976111f5791b0d92c4a8 c34d1c37d97cfc74cfd58b908db37dba0cc12f68

View File

@ -1 +1 @@
80f27b413640ff25223e654724f276a4c6925abc 7df9781615674ecdde80b8234d890a4ff3983533

View File

@ -1 +1 @@
ffde4cb2ef12a7462c5b6e336ae8c5e27f8b79ed 45fc2f719b760217c096d2e896ae9a39a2f6c446

View File

@ -1 +1 @@
387874c33279821ecf4c3c65c4b6be0fbf4530ca 1fce0633a2a5188d412fa7bed6596cdbf46eed99

View File

@ -1 +1 @@
94a0e366dc7a3a32249f013acdb108113871c9f0 5df81156024fc164400114fca16e4f834ba26389

View File

@ -1 +1 @@
b29ac60ca35d1e9dae87583d2b7183dd9bc0e356 e394ddb4f7e90f8160b816ceb2f3ddfd6ec43b20

View File

@ -1 +1 @@
dce6045ebed689ee7cc0cf98225aa3474f3eb3d8 c9706b15a376f8937072f1dfbd168d1058896a6e

View File

@ -1 +1 @@
fa787623a7ef5d34d480976111f5791b0d92c4a8 c34d1c37d97cfc74cfd58b908db37dba0cc12f68

View File

@ -1 +1 @@
80f27b413640ff25223e654724f276a4c6925abc 7df9781615674ecdde80b8234d890a4ff3983533

View File

@ -1 +1 @@
ffde4cb2ef12a7462c5b6e336ae8c5e27f8b79ed 45fc2f719b760217c096d2e896ae9a39a2f6c446

View File

@ -18,6 +18,7 @@
../../../external/linker/linker/Linker/MarkException.cs ../../../external/linker/linker/Linker/MarkException.cs
../../../external/linker/linker/Linker/MethodReferenceExtensions.cs ../../../external/linker/linker/Linker/MethodReferenceExtensions.cs
../../../external/linker/linker/Linker/MarkingHelpers.cs ../../../external/linker/linker/Linker/MarkingHelpers.cs
../../../external/linker/linker/Linker/TypeNameParser.cs
../../../external/linker/linker/Linker/Tracer.cs ../../../external/linker/linker/Linker/Tracer.cs
../../../external/linker/linker/Linker.Steps/BaseStep.cs ../../../external/linker/linker/Linker.Steps/BaseStep.cs
../../../external/linker/linker/Linker.Steps/LoadReferencesStep.cs ../../../external/linker/linker/Linker.Steps/LoadReferencesStep.cs

View File

@ -1 +1 @@
2076561604c744a9962b1d7c8730136b7c0c977c 6fc683409abfde2a99a06268c825e77dcc16edcd

View File

@ -1 +1 @@
#define FULL_VERSION "explicit/46e3bd5" #define FULL_VERSION "explicit/8c55e41"

Binary file not shown.

View File

@ -1 +1 @@
83af2976a93b0983251f67c0ea05e5287c80e184 7724023d7bbd0c27a29e20cfd192b6f0c87f8e46

Binary file not shown.

View File

@ -1 +1 @@
f1f65123a870f0cedc5c52aa1d95d1b55de05f15 4541123f4a3b60c078f9453b0aee658b5d9f84d8

Binary file not shown.

View File

@ -1 +1 @@
96d403b13912cb1f80d597268bd150ef3450f798 69665d4daa34511c8358f5081b675ed8491a37ed

View File

@ -6,9 +6,9 @@
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: mono 5.14.0.100\n" "Project-Id-Version: mono 5.14.0.103\n"
"Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n"
"POT-Creation-Date: 2018-05-24 08:55+0000\n" "POT-Creation-Date: 2018-05-25 08:15+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"

Binary file not shown.

View File

@ -1 +1 @@
8af8d403183ca79d00c207dd9a703ba567d6b6b2 8a5f460a338d9e65fe7009b48441ceac63a6fa5d