2016-05-26 16:06:52 +03:00
|
|
|
|
// Copyright 2015 Xamarin Inc. All rights reserved.
|
|
|
|
|
|
|
|
|
|
using System;
|
2016-07-20 13:12:54 +03:00
|
|
|
|
using System.Collections.Generic;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
using System.IO;
|
[mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087. (#2121)
* [mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087.
Don't look for assembly references in attributes in assemblies we ship,
because it takes a significant amount of time to do this, and we can
precompute the fact that there aren't any such assembly references.
Additionally add a test to ensure we catch any changes to this assumption.
For a simple test app this makes rebuilding (without any changes) go from
~1.1s to ~0.4s.
https://bugzilla.xamarin.com/show_bug.cgi?id=49087
* [tests] Simplify tests to not use [TestCaseSource].
Using [TestCaseSource] is nice when running from the IDE, since it shows all
test cases in the test tree.
Unfortunately it causes the console runner to freak out [1], because the method
that lists all the test cases calls Configuration's cctor, which calls
TestContext.CurrentContext.TestDirectory, which is apparently not safe this
early in the test run.
[1] I think 'freak out' is the appropriate term for this behavior, which has
absolutely no direct nor obvious connection to the cause of the problem:
System.Runtime.Remoting.RemotingException: Cannot create channel sink to connect to URL 93a78115_c0da_4b6a_9661_9f9b9d9fb935/6669afd6_4.rem. An appropriate channel has probably not been registered.
Server stack trace:
at System.Runtime.Remoting.RemotingServices.GetClientChannelSinkChain (System.String url, System.Object channelData, System.String& objectUri) [0x00019] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetOrCreateClientIdentity (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType, System.Object& clientProxy) [0x0001d] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetRemoteObject (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetProxyForRemoteObject (System.Runtime.Remoting.ObjRef objref, System.Type classToProxy) [0x0001b] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef, System.Boolean fRefine) [0x0007a] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.ObjRef.GetRealObject (System.Runtime.Serialization.StreamingContext context) [0x0000f] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.ObjectManager.ResolveObjectReference (System.Runtime.Serialization.ObjectHolder holder) [0x00010] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.ObjectManager.DoFixups () [0x0007f] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00077] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x000a2] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.DeserializeMethodResponse (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (System.Runtime.Remoting.Messaging.IMessage msg) [0x00083] in <270c90abbc234cde9d33eb198a97cf71>:0
2017-05-24 22:05:21 +03:00
|
|
|
|
using System.Linq;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
|
[mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087. (#2121)
* [mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087.
Don't look for assembly references in attributes in assemblies we ship,
because it takes a significant amount of time to do this, and we can
precompute the fact that there aren't any such assembly references.
Additionally add a test to ensure we catch any changes to this assumption.
For a simple test app this makes rebuilding (without any changes) go from
~1.1s to ~0.4s.
https://bugzilla.xamarin.com/show_bug.cgi?id=49087
* [tests] Simplify tests to not use [TestCaseSource].
Using [TestCaseSource] is nice when running from the IDE, since it shows all
test cases in the test tree.
Unfortunately it causes the console runner to freak out [1], because the method
that lists all the test cases calls Configuration's cctor, which calls
TestContext.CurrentContext.TestDirectory, which is apparently not safe this
early in the test run.
[1] I think 'freak out' is the appropriate term for this behavior, which has
absolutely no direct nor obvious connection to the cause of the problem:
System.Runtime.Remoting.RemotingException: Cannot create channel sink to connect to URL 93a78115_c0da_4b6a_9661_9f9b9d9fb935/6669afd6_4.rem. An appropriate channel has probably not been registered.
Server stack trace:
at System.Runtime.Remoting.RemotingServices.GetClientChannelSinkChain (System.String url, System.Object channelData, System.String& objectUri) [0x00019] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetOrCreateClientIdentity (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType, System.Object& clientProxy) [0x0001d] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetRemoteObject (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetProxyForRemoteObject (System.Runtime.Remoting.ObjRef objref, System.Type classToProxy) [0x0001b] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef, System.Boolean fRefine) [0x0007a] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.ObjRef.GetRealObject (System.Runtime.Serialization.StreamingContext context) [0x0000f] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.ObjectManager.ResolveObjectReference (System.Runtime.Serialization.ObjectHolder holder) [0x00010] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.ObjectManager.DoFixups () [0x0007f] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00077] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x000a2] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.DeserializeMethodResponse (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (System.Runtime.Remoting.Messaging.IMessage msg) [0x00083] in <270c90abbc234cde9d33eb198a97cf71>:0
2017-05-24 22:05:21 +03:00
|
|
|
|
using Mono.Cecil;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
using Xamarin.Tests;
|
|
|
|
|
|
|
|
|
|
namespace Xamarin.Linker {
|
|
|
|
|
|
|
|
|
|
public abstract class BaseProfile {
|
|
|
|
|
|
|
|
|
|
protected abstract bool IsSdk (string assemblyName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ProfilePoker : MobileProfile {
|
|
|
|
|
|
|
|
|
|
static ProfilePoker p = new ProfilePoker ();
|
|
|
|
|
|
|
|
|
|
public static bool IsWellKnownSdk (string assemblyName)
|
|
|
|
|
{
|
|
|
|
|
return p.IsSdk (assemblyName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public partial class SdkTest {
|
|
|
|
|
|
|
|
|
|
static string UnifiedPath { get { return Path.Combine (Configuration.MonoTouchRootDirectory, "lib/mono/Xamarin.iOS/"); } }
|
|
|
|
|
static string tvOSPath { get { return Path.Combine (Configuration.MonoTouchRootDirectory, "lib/mono/Xamarin.TVOS/"); } }
|
|
|
|
|
static string watchOSPath { get { return Path.Combine (Configuration.MonoTouchRootDirectory, "lib/mono/Xamarin.WatchOS/"); } }
|
|
|
|
|
|
|
|
|
|
void BCL (string path)
|
|
|
|
|
{
|
2016-07-20 13:12:54 +03:00
|
|
|
|
var failed_bcl = new List<string> ();
|
2016-05-26 16:06:52 +03:00
|
|
|
|
foreach (var file in Directory.GetFiles (path, "*.dll")) {
|
|
|
|
|
var aname = Path.GetFileNameWithoutExtension (file);
|
|
|
|
|
switch (aname) {
|
|
|
|
|
case "FSharp.Core":
|
|
|
|
|
case "I18N":
|
|
|
|
|
case "I18N.CJK":
|
|
|
|
|
case "I18N.MidEast":
|
|
|
|
|
case "I18N.Other":
|
|
|
|
|
case "I18N.Rare":
|
|
|
|
|
case "I18N.West":
|
|
|
|
|
// need to be sure they are link-capable to include them into MobileProfile
|
|
|
|
|
break;
|
|
|
|
|
case "MonoTouch.Dialog-1":
|
|
|
|
|
case "MonoTouch.NUnitLite":
|
|
|
|
|
case "Xamarin.iOS":
|
|
|
|
|
case "Xamarin.TVOS":
|
|
|
|
|
case "Xamarin.WatchOS":
|
|
|
|
|
// product assembly (use a different check than SDK/BCL)
|
|
|
|
|
break;
|
|
|
|
|
case "Newtonsoft.Json":
|
|
|
|
|
case "Xamarin.iOS.Tasks":
|
|
|
|
|
case "Xamarin.iOS.Tasks.Core":
|
|
|
|
|
case "Xamarin.ObjcBinding.Tasks":
|
|
|
|
|
case "Xamarin.MacDev":
|
|
|
|
|
case "Xamarin.MacDev.Tasks":
|
|
|
|
|
case "Xamarin.MacDev.Tasks.Core":
|
2016-06-08 18:47:09 +03:00
|
|
|
|
case "Xamarin.Analysis.Tasks":
|
2016-05-26 16:06:52 +03:00
|
|
|
|
// other stuff that is not part of the SDK but shipped in the same 2.1 directory
|
2016-09-30 22:02:17 +03:00
|
|
|
|
failed_bcl.Add (aname);
|
2016-05-26 16:06:52 +03:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2016-07-20 13:12:54 +03:00
|
|
|
|
if (!ProfilePoker.IsWellKnownSdk (aname))
|
|
|
|
|
failed_bcl.Add (aname);
|
2016-05-26 16:06:52 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-20 13:12:54 +03:00
|
|
|
|
CollectionAssert.IsEmpty (failed_bcl, "BCL");
|
2016-05-26 16:06:52 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void REPL (string path)
|
|
|
|
|
{
|
|
|
|
|
var repl = Path.Combine (path, "repl");
|
2016-07-20 13:12:54 +03:00
|
|
|
|
var failed_repl = new List<string> ();
|
2016-05-26 16:06:52 +03:00
|
|
|
|
foreach (var file in Directory.GetFiles (repl, "*.dll")) {
|
|
|
|
|
var aname = Path.GetFileNameWithoutExtension (file);
|
|
|
|
|
switch (aname) {
|
|
|
|
|
// sub-list that are SDK assemblies
|
|
|
|
|
case "mscorlib":
|
|
|
|
|
case "System":
|
|
|
|
|
case "System.Core":
|
|
|
|
|
case "System.Xml":
|
|
|
|
|
case "Mono.CSharp":
|
2016-07-20 13:12:54 +03:00
|
|
|
|
if (!ProfilePoker.IsWellKnownSdk (aname))
|
|
|
|
|
failed_repl.Add (aname);
|
2016-05-26 16:06:52 +03:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2016-07-20 13:12:54 +03:00
|
|
|
|
failed_repl.Add (aname);
|
2016-05-26 16:06:52 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-20 13:12:54 +03:00
|
|
|
|
CollectionAssert.IsEmpty (failed_repl, "Repl");
|
2016-05-26 16:06:52 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Facades (string path)
|
|
|
|
|
{
|
|
|
|
|
var facades = Path.Combine (path, "Facades");
|
2016-07-20 13:12:54 +03:00
|
|
|
|
var failed_facades = new List<string> ();
|
2016-05-26 16:06:52 +03:00
|
|
|
|
foreach (var file in Directory.GetFiles (facades, "*.dll")) {
|
|
|
|
|
var aname = Path.GetFileNameWithoutExtension (file);
|
2016-07-20 13:12:54 +03:00
|
|
|
|
if (!ProfilePoker.IsWellKnownSdk (aname))
|
|
|
|
|
failed_facades.Add (aname);
|
2016-05-26 16:06:52 +03:00
|
|
|
|
}
|
2016-07-20 13:12:54 +03:00
|
|
|
|
CollectionAssert.IsEmpty (failed_facades, "Facades");
|
2016-05-26 16:06:52 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void iOS_Unified ()
|
|
|
|
|
{
|
|
|
|
|
BCL (UnifiedPath);
|
|
|
|
|
REPL (UnifiedPath);
|
|
|
|
|
Facades (UnifiedPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void tvOS ()
|
|
|
|
|
{
|
|
|
|
|
BCL (tvOSPath);
|
|
|
|
|
REPL (tvOSPath);
|
|
|
|
|
Facades (tvOSPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void watchOS ()
|
|
|
|
|
{
|
|
|
|
|
BCL (watchOSPath);
|
|
|
|
|
REPL (watchOSPath);
|
|
|
|
|
Facades (watchOSPath);
|
|
|
|
|
}
|
[mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087. (#2121)
* [mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087.
Don't look for assembly references in attributes in assemblies we ship,
because it takes a significant amount of time to do this, and we can
precompute the fact that there aren't any such assembly references.
Additionally add a test to ensure we catch any changes to this assumption.
For a simple test app this makes rebuilding (without any changes) go from
~1.1s to ~0.4s.
https://bugzilla.xamarin.com/show_bug.cgi?id=49087
* [tests] Simplify tests to not use [TestCaseSource].
Using [TestCaseSource] is nice when running from the IDE, since it shows all
test cases in the test tree.
Unfortunately it causes the console runner to freak out [1], because the method
that lists all the test cases calls Configuration's cctor, which calls
TestContext.CurrentContext.TestDirectory, which is apparently not safe this
early in the test run.
[1] I think 'freak out' is the appropriate term for this behavior, which has
absolutely no direct nor obvious connection to the cause of the problem:
System.Runtime.Remoting.RemotingException: Cannot create channel sink to connect to URL 93a78115_c0da_4b6a_9661_9f9b9d9fb935/6669afd6_4.rem. An appropriate channel has probably not been registered.
Server stack trace:
at System.Runtime.Remoting.RemotingServices.GetClientChannelSinkChain (System.String url, System.Object channelData, System.String& objectUri) [0x00019] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetOrCreateClientIdentity (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType, System.Object& clientProxy) [0x0001d] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetRemoteObject (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetProxyForRemoteObject (System.Runtime.Remoting.ObjRef objref, System.Type classToProxy) [0x0001b] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef, System.Boolean fRefine) [0x0007a] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.ObjRef.GetRealObject (System.Runtime.Serialization.StreamingContext context) [0x0000f] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.ObjectManager.ResolveObjectReference (System.Runtime.Serialization.ObjectHolder holder) [0x00010] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.ObjectManager.DoFixups () [0x0007f] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00077] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x000a2] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.DeserializeMethodResponse (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (System.Runtime.Remoting.Messaging.IMessage msg) [0x00083] in <270c90abbc234cde9d33eb198a97cf71>:0
2017-05-24 22:05:21 +03:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void NoAssemblyReferenceInAttributes ()
|
|
|
|
|
{
|
|
|
|
|
var dir = Path.Combine (Configuration.MonoTouchRootDirectory, "lib/mono");
|
|
|
|
|
foreach (var filename in Directory.GetFiles (dir, "*.dll", SearchOption.AllDirectories)) {
|
|
|
|
|
// This tests verifies that there aren't any attributes in any assembly we ship
|
|
|
|
|
// that references an assembly that's not in the normal assembly references.
|
|
|
|
|
// It takes a significant amount of time to look in all the attributes for assembly references,
|
|
|
|
|
// and knowing that no such attributes exist in any assembly we ship, allows us
|
|
|
|
|
// to complete skip this step in mtouch
|
|
|
|
|
VerifyNoAdditionalAssemblyReferenceInAttributes (filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VerifyNoAdditionalAssemblyReferenceInAttributes (string filename)
|
|
|
|
|
{
|
|
|
|
|
var references = new HashSet<AssemblyNameReference> ();
|
|
|
|
|
using (var assembly = AssemblyDefinition.ReadAssembly (filename)) {
|
|
|
|
|
var main = assembly.MainModule;
|
|
|
|
|
references.UnionWith (main.AssemblyReferences);
|
|
|
|
|
|
|
|
|
|
var pre_attributes = new HashSet<AssemblyNameReference> (references);
|
|
|
|
|
|
|
|
|
|
GetCustomAttributeReferences (assembly, references);
|
|
|
|
|
GetCustomAttributeReferences (main, references);
|
|
|
|
|
if (main.HasTypes) {
|
|
|
|
|
foreach (var ca in main.GetCustomAttributes ())
|
|
|
|
|
GetCustomAttributeReferences (ca, references);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var post_attributes = pre_attributes.Except (references).ToArray ();
|
|
|
|
|
Assert.IsEmpty (post_attributes, assembly.Name.Name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GetCustomAttributeReferences (ICustomAttributeProvider cap, HashSet<AssemblyNameReference> references)
|
|
|
|
|
{
|
|
|
|
|
if (!cap.HasCustomAttributes)
|
|
|
|
|
return;
|
|
|
|
|
foreach (var ca in cap.CustomAttributes)
|
|
|
|
|
GetCustomAttributeReferences (ca, references);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void GetCustomAttributeReferences (CustomAttribute ca, HashSet<AssemblyNameReference> references)
|
|
|
|
|
{
|
|
|
|
|
if (ca.HasConstructorArguments) {
|
|
|
|
|
foreach (var arg in ca.ConstructorArguments)
|
|
|
|
|
GetCustomAttributeArgumentReference (arg, references);
|
|
|
|
|
}
|
|
|
|
|
if (ca.HasFields) {
|
|
|
|
|
foreach (var arg in ca.Fields)
|
|
|
|
|
GetCustomAttributeArgumentReference (arg.Argument, references);
|
|
|
|
|
}
|
|
|
|
|
if (ca.HasProperties) {
|
|
|
|
|
foreach (var arg in ca.Properties)
|
|
|
|
|
GetCustomAttributeArgumentReference (arg.Argument, references);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void GetCustomAttributeArgumentReference (CustomAttributeArgument arg, HashSet<AssemblyNameReference> references)
|
|
|
|
|
{
|
|
|
|
|
if (!arg.Type.Is ("System", "Type"))
|
|
|
|
|
return;
|
|
|
|
|
var ar = (arg.Value as TypeReference)?.Scope as AssemblyNameReference;
|
|
|
|
|
if (ar == null)
|
|
|
|
|
return;
|
|
|
|
|
references.Add (ar);
|
|
|
|
|
}
|
2016-05-26 16:06:52 +03:00
|
|
|
|
}
|
[mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087. (#2121)
* [mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087.
Don't look for assembly references in attributes in assemblies we ship,
because it takes a significant amount of time to do this, and we can
precompute the fact that there aren't any such assembly references.
Additionally add a test to ensure we catch any changes to this assumption.
For a simple test app this makes rebuilding (without any changes) go from
~1.1s to ~0.4s.
https://bugzilla.xamarin.com/show_bug.cgi?id=49087
* [tests] Simplify tests to not use [TestCaseSource].
Using [TestCaseSource] is nice when running from the IDE, since it shows all
test cases in the test tree.
Unfortunately it causes the console runner to freak out [1], because the method
that lists all the test cases calls Configuration's cctor, which calls
TestContext.CurrentContext.TestDirectory, which is apparently not safe this
early in the test run.
[1] I think 'freak out' is the appropriate term for this behavior, which has
absolutely no direct nor obvious connection to the cause of the problem:
System.Runtime.Remoting.RemotingException: Cannot create channel sink to connect to URL 93a78115_c0da_4b6a_9661_9f9b9d9fb935/6669afd6_4.rem. An appropriate channel has probably not been registered.
Server stack trace:
at System.Runtime.Remoting.RemotingServices.GetClientChannelSinkChain (System.String url, System.Object channelData, System.String& objectUri) [0x00019] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetOrCreateClientIdentity (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType, System.Object& clientProxy) [0x0001d] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetRemoteObject (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.GetProxyForRemoteObject (System.Runtime.Remoting.ObjRef objref, System.Type classToProxy) [0x0001b] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef, System.Boolean fRefine) [0x0007a] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.ObjRef.GetRealObject (System.Runtime.Serialization.StreamingContext context) [0x0000f] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.ObjectManager.ResolveObjectReference (System.Runtime.Serialization.ObjectHolder holder) [0x00010] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.ObjectManager.DoFixups () [0x0007f] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00077] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x000a2] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.DeserializeMethodResponse (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (System.Runtime.Remoting.Messaging.IMessage msg) [0x00083] in <270c90abbc234cde9d33eb198a97cf71>:0
2017-05-24 22:05:21 +03:00
|
|
|
|
}
|