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

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2012-07-26 11:00:03 +0400
committerMike Krüger <mkrueger@xamarin.com>2012-07-26 11:00:03 +0400
commitd1791bf0701a051a0d1faf626fe4973f9b95e15a (patch)
treeb8d0b8e2585422583839b95a555b58c90cc52168 /main/contrib
parentc6465f7b2c649f8e256e6811157bc27bb46f6cc9 (diff)
[NRefactory] Updated nrefactory.
Diffstat (limited to 'main/contrib')
-rw-r--r--main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs2
-rw-r--r--main/contrib/ICSharpCode.NRefactory/Properties/GlobalAssemblyInfo.cs26
-rw-r--r--main/contrib/ICSharpCode.NRefactory/Semantics/Conversion.cs16
-rw-r--r--main/contrib/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs2
-rw-r--r--main/contrib/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs208
-rw-r--r--main/contrib/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs12
-rw-r--r--main/contrib/ICSharpCode.NRefactory/TypeSystem/INamespace.cs5
-rw-r--r--main/contrib/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs4
-rw-r--r--main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs2
-rw-r--r--main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs6
-rw-r--r--main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs5
11 files changed, 219 insertions, 69 deletions
diff --git a/main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs b/main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs
index 78f8cd9043..a5a88689b6 100644
--- a/main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs
+++ b/main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs
@@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.Completion
{
if (entity == null)
throw new ArgumentNullException ("entity");
-
+
var browsableState = entity.Attributes.FirstOrDefault(attr => attr.AttributeType.Name == "EditorBrowsableAttribute" && attr.AttributeType.Namespace == "System.ComponentModel");
if (browsableState != null && browsableState.PositionalArguments.Count == 1) {
try {
diff --git a/main/contrib/ICSharpCode.NRefactory/Properties/GlobalAssemblyInfo.cs b/main/contrib/ICSharpCode.NRefactory/Properties/GlobalAssemblyInfo.cs
new file mode 100644
index 0000000000..3c6b82ac4b
--- /dev/null
+++ b/main/contrib/ICSharpCode.NRefactory/Properties/GlobalAssemblyInfo.cs
@@ -0,0 +1,26 @@
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyCompany("ICSharpCode")]
+[assembly: AssemblyProduct("SharpDevelop/MonoDevelop")]
+[assembly: AssemblyCopyright("Copyright 2010-2012 AlphaSierraPapa")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// We keep the AssemblyVersion at 5.0.0.0 for all versions of NRefactory 5.
+// This eliminates the need for binding redirects.
+[assembly: AssemblyVersion("5.0.0.0")]
+
+// [AssemblyFileVersion] is the version of the NuGet package,
+// should follow http://semver.org/ rules
+[assembly: AssemblyFileVersion("5.1.0")]
diff --git a/main/contrib/ICSharpCode.NRefactory/Semantics/Conversion.cs b/main/contrib/ICSharpCode.NRefactory/Semantics/Conversion.cs
index a68a7f407f..fc5889d55f 100644
--- a/main/contrib/ICSharpCode.NRefactory/Semantics/Conversion.cs
+++ b/main/contrib/ICSharpCode.NRefactory/Semantics/Conversion.cs
@@ -185,6 +185,14 @@ namespace ICSharpCode.NRefactory.Semantics
get { return type == 0; }
}
+ public override bool IsNullLiteralConversion {
+ get { return type == 1; }
+ }
+
+ public override bool IsConstantExpressionConversion {
+ get { return type == 2; }
+ }
+
public override bool IsReferenceConversion {
get { return type == 3; }
}
@@ -365,6 +373,14 @@ namespace ICSharpCode.NRefactory.Semantics
get { return false; }
}
+ public virtual bool IsNullLiteralConversion {
+ get { return false; }
+ }
+
+ public virtual bool IsConstantExpressionConversion {
+ get { return false; }
+ }
+
public virtual bool IsNumericConversion {
get { return false; }
}
diff --git a/main/contrib/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs b/main/contrib/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs
index f861920b45..3a2430856f 100644
--- a/main/contrib/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs
+++ b/main/contrib/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs
@@ -28,7 +28,7 @@ namespace ICSharpCode.NRefactory.Semantics
/// <summary>
/// Represents the result of a member invocation.
/// Used for field/property/event access.
- /// Also, <see cref="InvocationResultResult"/> derives from MemberResolveResult.
+ /// Also, <see cref="InvocationResolveResult"/> derives from MemberResolveResult.
/// </summary>
public class MemberResolveResult : ResolveResult
{
diff --git a/main/contrib/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs b/main/contrib/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
index 9292016391..0eb735a759 100644
--- a/main/contrib/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
+++ b/main/contrib/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
@@ -55,6 +55,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// the Cecil objects to stay in memory (which can significantly increase memory usage).
/// It also prevents serialization of the Cecil-loaded type system.
/// </summary>
+ /// <remarks>
+ /// Because the type system can be used on multiple threads, but Cecil is not
+ /// thread-safe for concurrent read access, the CecilLoader will lock on the <see cref="ModuleDefinition"/> instance
+ /// for every delay-loading operation.
+ /// If you access the Cecil objects directly in your application, you may need to take the same lock.
+ /// </remarks>
public bool LazyLoad { get; set; }
/// <summary>
@@ -73,6 +79,17 @@ namespace ICSharpCode.NRefactory.TypeSystem
public CancellationToken CancellationToken { get; set; }
/// <summary>
+ /// This delegate gets executed whenever an entity was loaded.
+ /// </summary>
+ /// <remarks>
+ /// This callback may be to build a dictionary that maps between
+ /// entities and cecil objects.
+ /// Warning: if delay-loading is used and the type system is accessed by multiple threads,
+ /// the callback may be invoked concurrently on multiple threads.
+ /// </remarks>
+ public Action<IUnresolvedEntity, MemberReference> OnEntityLoaded { get; set; }
+
+ /// <summary>
/// Gets a value indicating whether this instance stores references to the cecil objects.
/// </summary>
/// <value>
@@ -87,16 +104,39 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary>
/// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.CecilLoader"/> class.
/// </summary>
+ public CecilLoader()
+ {
+ // Enable interning by default.
+ this.InterningProvider = new SimpleInterningProvider();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.CecilLoader"/> class.
+ /// </summary>
/// <param name='createCecilReferences'>
/// If true references to the cecil objects are hold. In this case the cecil loader can do a type system -> cecil mapping.
/// </param>
- public CecilLoader (bool createCecilReferences = false)
+ [Obsolete("The built-in entity<->cecil mapping is obsolete. Use the OnEntityLoaded callback instead!")]
+ public CecilLoader(bool createCecilReferences) : this()
{
if (createCecilReferences)
typeSystemTranslationTable = new Dictionary<object, object> ();
-
- // Enable interning by default.
- this.InterningProvider = new SimpleInterningProvider();
+ }
+
+ /// <summary>
+ /// Creates a nested CecilLoader for lazy-loading.
+ /// </summary>
+ private CecilLoader(CecilLoader loader)
+ {
+ // use a shared typeSystemTranslationTable
+ this.typeSystemTranslationTable = loader.typeSystemTranslationTable;
+ this.IncludeInternalMembers = loader.IncludeInternalMembers;
+ this.LazyLoad = loader.LazyLoad;
+ this.OnEntityLoaded = loader.OnEntityLoaded;
+ this.currentModule = loader.currentModule;
+ this.currentAssembly = loader.currentAssembly;
+ // don't use interning - the interning provider is most likely not thread-safe
+ // don't use cancellation for delay-loaded members
}
#region Load From AssemblyDefinition
@@ -105,69 +145,76 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
/// <returns>IProjectContent that represents the assembly</returns>
[CLSCompliant(false)]
- public IUnresolvedAssembly LoadAssembly (AssemblyDefinition assemblyDefinition, string location = null)
+ public IUnresolvedAssembly LoadAssembly(AssemblyDefinition assemblyDefinition)
{
if (assemblyDefinition == null)
- throw new ArgumentNullException ("assemblyDefinition");
+ throw new ArgumentNullException("assemblyDefinition");
this.currentModule = assemblyDefinition.MainModule;
-
+
// Read assembly and module attributes
- IList<IUnresolvedAttribute> assemblyAttributes = new List<IUnresolvedAttribute> ();
- IList<IUnresolvedAttribute> moduleAttributes = new List<IUnresolvedAttribute> ();
- AddAttributes (assemblyDefinition, assemblyAttributes);
- AddAttributes (assemblyDefinition.MainModule, moduleAttributes);
+ IList<IUnresolvedAttribute> assemblyAttributes = new List<IUnresolvedAttribute>();
+ IList<IUnresolvedAttribute> moduleAttributes = new List<IUnresolvedAttribute>();
+ AddAttributes(assemblyDefinition, assemblyAttributes);
+ AddAttributes(assemblyDefinition.MainModule, moduleAttributes);
if (this.InterningProvider != null) {
- assemblyAttributes = this.InterningProvider.InternList (assemblyAttributes);
- moduleAttributes = this.InterningProvider.InternList (moduleAttributes);
+ assemblyAttributes = this.InterningProvider.InternList(assemblyAttributes);
+ moduleAttributes = this.InterningProvider.InternList(moduleAttributes);
}
- this.currentAssembly = new CecilUnresolvedAssembly (assemblyDefinition.Name.Name, this.DocumentationProvider);
- currentAssembly.AssemblyAttributes.AddRange (assemblyAttributes);
- currentAssembly.ModuleAttributes.AddRange (assemblyAttributes);
+ this.currentAssembly = new CecilUnresolvedAssembly(assemblyDefinition.Name.Name, this.DocumentationProvider);
+ currentAssembly.Location = assemblyDefinition.MainModule.FullyQualifiedName;
+ currentAssembly.AssemblyAttributes.AddRange(assemblyAttributes);
+ currentAssembly.ModuleAttributes.AddRange(assemblyAttributes);
// Register type forwarders:
foreach (ExportedType type in assemblyDefinition.MainModule.ExportedTypes) {
if (type.IsForwarder) {
int typeParameterCount;
- string name = ReflectionHelper.SplitTypeParameterCountFromReflectionName (type.Name, out typeParameterCount);
- var typeRef = new GetClassTypeReference (GetAssemblyReference (type.Scope), type.Namespace, name, typeParameterCount);
- typeRef = this.InterningProvider.Intern (typeRef);
- var key = new FullNameAndTypeParameterCount (type.Namespace, name, typeParameterCount);
- currentAssembly.AddTypeForwarder (key, typeRef);
+ string name = ReflectionHelper.SplitTypeParameterCountFromReflectionName(type.Name, out typeParameterCount);
+ var typeRef = new GetClassTypeReference(GetAssemblyReference(type.Scope), type.Namespace, name, typeParameterCount);
+ if (this.InterningProvider != null)
+ typeRef = this.InterningProvider.Intern(typeRef);
+ var key = new FullNameAndTypeParameterCount(type.Namespace, name, typeParameterCount);
+ currentAssembly.AddTypeForwarder(key, typeRef);
}
}
// Create and register all types:
- List<TypeDefinition> cecilTypeDefs = new List<TypeDefinition> ();
- List<DefaultUnresolvedTypeDefinition> typeDefs = new List<DefaultUnresolvedTypeDefinition> ();
+ CecilLoader cecilLoaderCloneForLazyLoading = LazyLoad ? new CecilLoader(this) : null;
+ List<TypeDefinition> cecilTypeDefs = new List<TypeDefinition>();
+ List<DefaultUnresolvedTypeDefinition> typeDefs = new List<DefaultUnresolvedTypeDefinition>();
foreach (ModuleDefinition module in assemblyDefinition.Modules) {
foreach (TypeDefinition td in module.Types) {
- this.CancellationToken.ThrowIfCancellationRequested ();
+ this.CancellationToken.ThrowIfCancellationRequested();
if (this.IncludeInternalMembers || (td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public) {
string name = td.Name;
if (name.Length == 0)
continue;
- var t = CreateTopLevelTypeDefinition (td);
- cecilTypeDefs.Add (td);
- typeDefs.Add (t);
- currentAssembly.AddTypeDefinition (t);
+ if (this.LazyLoad) {
+ var t = new LazyCecilTypeDefinition(cecilLoaderCloneForLazyLoading, td);
+ currentAssembly.AddTypeDefinition(t);
+ RegisterCecilObject(t, td);
+ } else {
+ var t = CreateTopLevelTypeDefinition(td);
+ cecilTypeDefs.Add(td);
+ typeDefs.Add(t);
+ currentAssembly.AddTypeDefinition(t);
+ // The registration will happen after the members are initialized
+ }
}
}
}
// Initialize the type's members:
for (int i = 0; i < typeDefs.Count; i++) {
- InitTypeDefinition (cecilTypeDefs [i], typeDefs [i]);
+ InitTypeDefinition(cecilTypeDefs[i], typeDefs[i]);
}
- if (HasCecilReferences) {
- typeSystemTranslationTable [this.currentAssembly] = assemblyDefinition;
- }
+ AddToTypeSystemTranslationTable(this.currentAssembly, assemblyDefinition);
var result = this.currentAssembly;
- result.Location = location ?? "";
this.currentAssembly = null;
this.currentModule = null;
return result;
@@ -230,10 +277,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
throw new ArgumentNullException("fileName");
var param = new ReaderParameters { AssemblyResolver = new DummyAssemblyResolver() };
AssemblyDefinition asm = AssemblyDefinition.ReadAssembly(fileName, param);
- var result = LoadAssembly(asm, fileName);
- if (HasCecilReferences)
- typeSystemTranslationTable[result] = asm;
- return result;
+ return LoadAssembly(asm);
}
// used to prevent Cecil from loading referenced assemblies
@@ -1179,14 +1223,14 @@ namespace ICSharpCode.NRefactory.TypeSystem
EntityType memberType;
var b = ReadByte();
switch (b) {
- case 0x53:
- memberType = EntityType.Field;
- break;
- case 0x54:
- memberType = EntityType.Property;
- break;
- default:
- throw new NotSupportedException(string.Format("Custom member type 0x{0:x} is not supported.", b));
+ case 0x53:
+ memberType = EntityType.Field;
+ break;
+ case 0x54:
+ memberType = EntityType.Property;
+ break;
+ default:
+ throw new NotSupportedException(string.Format("Custom member type 0x{0:x} is not supported.", b));
}
IType type = ReadCustomAttributeFieldOrPropType();
string name = ReadSerString();
@@ -1502,12 +1546,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
td.AddDefaultConstructorIfRequired = (td.Kind == TypeKind.Struct || td.Kind == TypeKind.Enum);
InitMembers(typeDefinition, td, td.Members);
- if (HasCecilReferences)
- typeSystemTranslationTable[td] = typeDefinition;
if (this.InterningProvider != null) {
td.ApplyInterningProvider(this.InterningProvider);
}
td.Freeze();
+ RegisterCecilObject(td, typeDefinition);
}
void InitBaseTypes(TypeDefinition typeDefinition, IList<ITypeReference> baseTypes)
@@ -1659,7 +1702,18 @@ namespace ICSharpCode.NRefactory.TypeSystem
bool getterVisible = property.GetMethod != null && IsVisible(property.GetMethod.Attributes);
bool setterVisible = property.SetMethod != null && IsVisible(property.SetMethod.Attributes);
if (getterVisible || setterVisible) {
- EntityType type = property.Name == defaultMemberName ? EntityType.Indexer : EntityType.Property;
+ EntityType type = EntityType.Property;
+ if (property.HasParameters) {
+ // Try to detect indexer:
+ if (property.Name == defaultMemberName) {
+ type = EntityType.Indexer; // normal indexer
+ } else if (property.Name.EndsWith(".Item", StringComparison.Ordinal) && (property.GetMethod ?? property.SetMethod).HasOverrides) {
+ // explicit interface implementation of indexer
+ type = EntityType.Indexer;
+ // We can't really tell parameterized properties and indexers apart in this case without
+ // resolving the interface, so we rely on the "Item" naming convention instead.
+ }
+ }
members.Add(ReadProperty(property, td, type));
}
}
@@ -1710,8 +1764,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
loader.AddAttributes(typeDefinition, this);
flags[FlagHasExtensionMethods] = HasExtensionAttribute(typeDefinition);
- if (loader.HasCecilReferences)
- loader.typeSystemTranslationTable[this] = typeDefinition;
if (loader.InterningProvider != null) {
this.ApplyInterningProvider(loader.InterningProvider);
}
@@ -1723,6 +1775,15 @@ namespace ICSharpCode.NRefactory.TypeSystem
set { throw new NotSupportedException(); }
}
+ public override string FullName {
+ // This works because LazyCecilTypeDefinition is only used for top-level types
+ get { return cecilTypeDef.FullName; }
+ }
+
+ public override string ReflectionName {
+ get { return cecilTypeDef.FullName; }
+ }
+
public TypeKind Kind {
get { return kind; }
}
@@ -1736,7 +1797,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
var result = LazyInit.VolatileRead(ref this.baseTypes);
if (result != null) {
return result;
- } else {
+ }
+ lock (loader.currentModule) {
result = new List<ITypeReference>();
loader.InitBaseTypes(cecilTypeDef, result);
return LazyInit.GetOrSet(ref this.baseTypes, FreezableHelper.FreezeList(result));
@@ -1749,7 +1811,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
var result = LazyInit.VolatileRead(ref this.nestedTypes);
if (result != null) {
return result;
- } else {
+ }
+ lock (loader.currentModule) {
+ if (this.nestedTypes != null)
+ return this.nestedTypes;
result = new List<IUnresolvedTypeDefinition>();
loader.InitNestedTypes(cecilTypeDef, this, result);
return LazyInit.GetOrSet(ref this.nestedTypes, FreezableHelper.FreezeList(result));
@@ -1762,7 +1827,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
var result = LazyInit.VolatileRead(ref this.members);
if (result != null) {
return result;
- } else {
+ }
+ lock (loader.currentModule) {
+ if (this.members != null)
+ return this.members;
result = new List<IUnresolvedMember>();
loader.InitMembers(cecilTypeDef, this, result);
return LazyInit.GetOrSet(ref this.members, FreezableHelper.FreezeList(result));
@@ -2124,16 +2192,34 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
#endregion
- void FinishReadMember(AbstractUnresolvedMember member, object cecilDefinition)
+ void FinishReadMember(AbstractUnresolvedMember member, MemberReference cecilDefinition)
{
- member.ApplyInterningProvider(this.InterningProvider);
+ if (this.InterningProvider != null)
+ member.ApplyInterningProvider(this.InterningProvider);
member.Freeze();
- if (HasCecilReferences)
- typeSystemTranslationTable[member] = cecilDefinition;
+ RegisterCecilObject(member, cecilDefinition);
}
#region Type system translation table
- Dictionary<object, object> typeSystemTranslationTable;
+ readonly Dictionary<object, object> typeSystemTranslationTable;
+
+ void RegisterCecilObject(IUnresolvedEntity typeSystemObject, MemberReference cecilObject)
+ {
+ if (OnEntityLoaded != null)
+ OnEntityLoaded(typeSystemObject, cecilObject);
+
+ AddToTypeSystemTranslationTable(typeSystemObject, cecilObject);
+ }
+
+ void AddToTypeSystemTranslationTable(object typeSystemObject, object cecilObject)
+ {
+ if (typeSystemTranslationTable != null) {
+ // When lazy-loading, the dictionary might be shared between multiple cecil-loaders that are used concurrently
+ lock (typeSystemTranslationTable) {
+ typeSystemTranslationTable[typeSystemObject] = cecilObject;
+ }
+ }
+ }
T InternalGetCecilObject<T> (object typeSystemObject) where T : class
{
@@ -2142,8 +2228,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
if (!HasCecilReferences)
throw new NotSupportedException ("This instance contains no cecil references.");
object result;
- if (!typeSystemTranslationTable.TryGetValue (typeSystemObject, out result))
- return null;
+ lock (typeSystemTranslationTable) {
+ if (!typeSystemTranslationTable.TryGetValue (typeSystemObject, out result))
+ return null;
+ }
return result as T;
}
diff --git a/main/contrib/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs b/main/contrib/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs
index a0a59c3560..0f02617087 100644
--- a/main/contrib/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs
+++ b/main/contrib/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs
@@ -92,7 +92,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
#endregion
- #region IsOpen / IsUnbound
+ #region IsOpen / IsUnbound / IsKnownType
sealed class TypeClassificationVisitor : TypeVisitor
{
internal bool isOpen;
@@ -140,6 +140,16 @@ namespace ICSharpCode.NRefactory.TypeSystem
throw new ArgumentNullException("type");
return type is ITypeDefinition && type.TypeParameterCount > 0;
}
+
+ /// <summary>
+ /// Gets whether the type is the specified known type.
+ /// For generic known types, this returns true any parameterization of the type (and also for the definition itself).
+ /// </summary>
+ public static bool IsKnownType(this IType type, KnownTypeCode knownType)
+ {
+ var def = type.GetDefinition();
+ return def != null && def.KnownTypeCode == knownType;
+ }
#endregion
#region Import
diff --git a/main/contrib/ICSharpCode.NRefactory/TypeSystem/INamespace.cs b/main/contrib/ICSharpCode.NRefactory/TypeSystem/INamespace.cs
index 487e4fc3e3..b3631fe060 100644
--- a/main/contrib/ICSharpCode.NRefactory/TypeSystem/INamespace.cs
+++ b/main/contrib/ICSharpCode.NRefactory/TypeSystem/INamespace.cs
@@ -63,6 +63,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
IEnumerable<ITypeDefinition> Types { get; }
/// <summary>
+ /// Gets the assemblies that contribute types to this namespace (or to child namespaces).
+ /// </summary>
+ IEnumerable<IAssembly> ContributingAssemblies { get; }
+
+ /// <summary>
/// Gets a direct child namespace by its short name.
/// Returns null when the namespace cannot be found.
/// </summary>
diff --git a/main/contrib/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs b/main/contrib/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs
index 33982c9d2a..4a731c42ce 100644
--- a/main/contrib/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs
+++ b/main/contrib/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs
@@ -69,12 +69,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Changes the assembly name of this project content.
/// </summary>
IProjectContent SetAssemblyName(string newAssemblyName);
-
+
/// <summary>
/// Changes the location of this project content.
/// </summary>
IProjectContent SetLocation(string newLocation);
-
+
/// <summary>
/// Add assembly references to this project content.
/// </summary>
diff --git a/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs b/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs
index d027f0b21d..0ff0b25a58 100644
--- a/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs
+++ b/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs
@@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
result.Add(member);
}
return result.ToArray();
- } else if (unresolved.IsStatic) {
+ } else if (unresolved.IsStatic || DeclaringTypeDefinition == null || DeclaringTypeDefinition.Kind == TypeKind.Interface) {
return EmptyList<IMember>.Instance;
} else {
// TODO: implement interface member mappings correctly
diff --git a/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs b/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
index 81866619ec..d74c1cae84 100644
--- a/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
+++ b/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
@@ -76,8 +76,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
return location;
}
set {
- if (value == null)
- throw new ArgumentNullException("value");
FreezableHelper.ThrowIfFrozen(this);
location = value;
}
@@ -380,6 +378,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return parentNamespace; }
}
+ IEnumerable<IAssembly> INamespace.ContributingAssemblies {
+ get { return new [] { assembly }; }
+ }
+
IEnumerable<INamespace> INamespace.ChildNamespaces {
get { return childNamespaces; }
}
diff --git a/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs b/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
index 4363253f05..1ab85bcd4e 100644
--- a/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
+++ b/main/contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
@@ -20,7 +20,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
-using System.Text;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
@@ -96,6 +95,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return compilation; }
}
+ public IEnumerable<IAssembly> ContributingAssemblies {
+ get { return namespaces.SelectMany(ns => ns.ContributingAssemblies); }
+ }
+
public IEnumerable<INamespace> ChildNamespaces {
get { return GetChildNamespaces().Values; }
}