Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Add INamespace.ContributingAssemblies.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrunwald committed Jul 22, 2012
1 parent 8b026d4 commit a3534f2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs
Expand Up @@ -290,6 +290,10 @@ select t.Value
get { return assembly.Compilation; } get { return assembly.Compilation; }
} }


IEnumerable<IAssembly> INamespace.ContributingAssemblies {
get { return new [] { assembly }; }
}

INamespace INamespace.GetChildNamespace(string name) INamespace INamespace.GetChildNamespace(string name)
{ {
var nameComparer = assembly.compilation.NameComparer; var nameComparer = assembly.compilation.NameComparer;
Expand Down
Expand Up @@ -172,6 +172,10 @@ public DummyNamespace(INamespace parentNamespace, string name)
get { return EmptyList<ITypeDefinition>.Instance; } get { return EmptyList<ITypeDefinition>.Instance; }
} }


IEnumerable<IAssembly> INamespace.ContributingAssemblies {
get { return EmptyList<IAssembly>.Instance; }
}

ICompilation IResolved.Compilation { ICompilation IResolved.Compilation {
get { return parentNamespace.Compilation; } get { return parentNamespace.Compilation; }
} }
Expand Down
5 changes: 5 additions & 0 deletions ICSharpCode.NRefactory/TypeSystem/INamespace.cs
Expand Up @@ -62,6 +62,11 @@ public interface INamespace : IResolved
/// </summary> /// </summary>
IEnumerable<ITypeDefinition> Types { get; } IEnumerable<ITypeDefinition> Types { get; }


/// <summary>
/// Gets the assemblies that contribute types to this namespace (or to child namespaces).
/// </summary>
IEnumerable<IAssembly> ContributingAssemblies { get; }

/// <summary> /// <summary>
/// Gets a direct child namespace by its short name. /// Gets a direct child namespace by its short name.
/// Returns null when the namespace cannot be found. /// Returns null when the namespace cannot be found.
Expand Down
Expand Up @@ -378,6 +378,10 @@ public NS(DefaultResolvedAssembly assembly, UnresolvedNamespace ns, INamespace p
get { return parentNamespace; } get { return parentNamespace; }
} }


IEnumerable<IAssembly> INamespace.ContributingAssemblies {
get { return new [] { assembly }; }
}

IEnumerable<INamespace> INamespace.ChildNamespaces { IEnumerable<INamespace> INamespace.ChildNamespaces {
get { return childNamespaces; } get { return childNamespaces; }
} }
Expand Down
Expand Up @@ -20,7 +20,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.Utils; using ICSharpCode.NRefactory.Utils;


namespace ICSharpCode.NRefactory.TypeSystem.Implementation namespace ICSharpCode.NRefactory.TypeSystem.Implementation
Expand Down Expand Up @@ -96,6 +95,10 @@ public MergedNamespace(INamespace parentNamespace, INamespace[] namespaces)
get { return compilation; } get { return compilation; }
} }


public IEnumerable<IAssembly> ContributingAssemblies {
get { return namespaces.SelectMany(ns => ns.ContributingAssemblies); }

This comment has been minimized.

Copy link
@erik-kallen

erik-kallen Jul 23, 2012

Contributor

Shouldn't there be a Distinct() here?

This comment has been minimized.

Copy link
@dgrunwald

dgrunwald Jul 23, 2012

Author Member

Each assembly only appears in one of the input namespaces. Otherwise we'd also get duplicates in INamespace.Types.

}

public IEnumerable<INamespace> ChildNamespaces { public IEnumerable<INamespace> ChildNamespaces {
get { return GetChildNamespaces().Values; } get { return GetChildNamespaces().Values; }
} }
Expand Down

0 comments on commit a3534f2

Please sign in to comment.