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

github.com/xamarin/NRefactory.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2014-09-01 10:52:54 +0400
committerMike Krüger <mkrueger@xamarin.com>2014-09-01 10:53:12 +0400
commit162fda958330505961ddddebad620103f0253683 (patch)
treefda3f0497019bb5deb96faaaa9f11242ce6cb4cf /ICSharpCode.NRefactory
parent9429712ebd1eaaa0c4ffbbf1458c2cceea04b6db (diff)
Fixed InternalsVisibleTo in DefaultUnresolvedAssembly.
Code was taken from the CSharpAssembly.
Diffstat (limited to 'ICSharpCode.NRefactory')
-rw-r--r--ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs48
1 files changed, 45 insertions, 3 deletions
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
index d1cbb4f7..de9834cc 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
@@ -332,12 +332,54 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public ICompilation Compilation {
get { return compilation; }
}
-
+
public bool InternalsVisibleTo(IAssembly assembly)
{
- return assembly == this;
+ if (this == assembly)
+ return true;
+ foreach (string shortName in GetInternalsVisibleTo()) {
+ if (assembly.AssemblyName == shortName)
+ return true;
+ }
+ return false;
}
-
+
+ volatile string[] internalsVisibleTo;
+
+ string[] GetInternalsVisibleTo()
+ {
+ var result = this.internalsVisibleTo;
+ if (result != null) {
+ return result;
+ } else {
+ using (var busyLock = BusyManager.Enter(this)) {
+ Debug.Assert(busyLock.Success);
+ if (!busyLock.Success) {
+ return new string[0];
+ }
+ internalsVisibleTo = (
+ from attr in this.AssemblyAttributes
+ where attr.AttributeType.Name == "InternalsVisibleToAttribute"
+ && attr.AttributeType.Namespace == "System.Runtime.CompilerServices"
+ && attr.PositionalArguments.Count == 1
+ select GetShortName(attr.PositionalArguments.Single().ConstantValue as string)
+ ).ToArray();
+ }
+ return internalsVisibleTo;
+ }
+ }
+
+ static string GetShortName(string fullAssemblyName)
+ {
+ if (fullAssemblyName == null)
+ return null;
+ int pos = fullAssemblyName.IndexOf(',');
+ if (pos < 0)
+ return fullAssemblyName;
+ else
+ return fullAssemblyName.Substring(0, pos);
+ }
+
public ITypeDefinition GetTypeDefinition(TopLevelTypeName topLevelTypeName)
{
IUnresolvedTypeDefinition td;