|
|
|
@ -157,31 +157,46 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -157,31 +157,46 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Loads the assembly definition into a project content.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>IProjectContent that represents the assembly</returns>
|
|
|
|
|
/// <returns>Unresolved type system representing the assembly</returns>
|
|
|
|
|
[CLSCompliant(false)] |
|
|
|
|
public IUnresolvedAssembly LoadAssembly(AssemblyDefinition assemblyDefinition) |
|
|
|
|
{ |
|
|
|
|
if (assemblyDefinition == null) |
|
|
|
|
throw new ArgumentNullException("assemblyDefinition"); |
|
|
|
|
return LoadModule(assemblyDefinition.MainModule); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Loads the module definition into a project content.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>Unresolved type system representing the assembly</returns>
|
|
|
|
|
[CLSCompliant(false)] |
|
|
|
|
public IUnresolvedAssembly LoadModule(ModuleDefinition moduleDefinition) |
|
|
|
|
{ |
|
|
|
|
if (moduleDefinition == null) |
|
|
|
|
throw new ArgumentNullException("moduleDefinition"); |
|
|
|
|
|
|
|
|
|
this.currentModule = assemblyDefinition.MainModule; |
|
|
|
|
this.currentModule = moduleDefinition; |
|
|
|
|
|
|
|
|
|
// Read assembly and module attributes
|
|
|
|
|
IList<IUnresolvedAttribute> assemblyAttributes = new List<IUnresolvedAttribute>(); |
|
|
|
|
IList<IUnresolvedAttribute> moduleAttributes = new List<IUnresolvedAttribute>(); |
|
|
|
|
AssemblyDefinition assemblyDefinition = moduleDefinition.Assembly; |
|
|
|
|
if (assemblyDefinition != null) { |
|
|
|
|
AddAttributes(assemblyDefinition, assemblyAttributes); |
|
|
|
|
AddAttributes(assemblyDefinition.MainModule, moduleAttributes); |
|
|
|
|
} |
|
|
|
|
AddAttributes(moduleDefinition, moduleAttributes); |
|
|
|
|
|
|
|
|
|
assemblyAttributes = interningProvider.InternList(assemblyAttributes); |
|
|
|
|
moduleAttributes = interningProvider.InternList(moduleAttributes); |
|
|
|
|
|
|
|
|
|
this.currentAssembly = new CecilUnresolvedAssembly(assemblyDefinition.Name, this.DocumentationProvider); |
|
|
|
|
currentAssembly.Location = assemblyDefinition.MainModule.FullyQualifiedName; |
|
|
|
|
this.currentAssembly = new CecilUnresolvedAssembly(assemblyDefinition != null ? assemblyDefinition.Name.FullName : moduleDefinition.Name, this.DocumentationProvider); |
|
|
|
|
currentAssembly.Location = moduleDefinition.FullyQualifiedName; |
|
|
|
|
currentAssembly.AssemblyAttributes.AddRange(assemblyAttributes); |
|
|
|
|
currentAssembly.ModuleAttributes.AddRange(assemblyAttributes); |
|
|
|
|
|
|
|
|
|
// Register type forwarders:
|
|
|
|
|
foreach (ExportedType type in assemblyDefinition.MainModule.ExportedTypes) { |
|
|
|
|
foreach (ExportedType type in moduleDefinition.ExportedTypes) { |
|
|
|
|
if (type.IsForwarder) { |
|
|
|
|
int typeParameterCount; |
|
|
|
|
string ns = type.Namespace; |
|
|
|
@ -199,8 +214,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -199,8 +214,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
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) { |
|
|
|
|
foreach (TypeDefinition td in moduleDefinition.Types) { |
|
|
|
|
this.CancellationToken.ThrowIfCancellationRequested(); |
|
|
|
|
if (this.IncludeInternalMembers || (td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public) { |
|
|
|
|
string name = td.Name; |
|
|
|
@ -220,7 +234,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -220,7 +234,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Initialize the type's members:
|
|
|
|
|
for (int i = 0; i < typeDefs.Count; i++) { |
|
|
|
|
InitTypeDefinition(cecilTypeDefs[i], typeDefs[i]); |
|
|
|
@ -276,10 +289,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -276,10 +289,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
{ |
|
|
|
|
readonly IDocumentationProvider documentationProvider; |
|
|
|
|
|
|
|
|
|
public CecilUnresolvedAssembly(AssemblyNameDefinition assemblyName, IDocumentationProvider documentationProvider) |
|
|
|
|
: base(assemblyName.FullName) |
|
|
|
|
public CecilUnresolvedAssembly(string fullAssemblyName, IDocumentationProvider documentationProvider) |
|
|
|
|
: base(fullAssemblyName) |
|
|
|
|
{ |
|
|
|
|
Debug.Assert(assemblyName != null); |
|
|
|
|
this.documentationProvider = documentationProvider; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -299,8 +311,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -299,8 +311,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
if (fileName == null) |
|
|
|
|
throw new ArgumentNullException("fileName"); |
|
|
|
|
var param = new ReaderParameters { AssemblyResolver = new DummyAssemblyResolver() }; |
|
|
|
|
AssemblyDefinition asm = AssemblyDefinition.ReadAssembly(fileName, param); |
|
|
|
|
return LoadAssembly(asm); |
|
|
|
|
ModuleDefinition module = ModuleDefinition.ReadModule(fileName, param); |
|
|
|
|
return LoadModule(module); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// used to prevent Cecil from loading referenced assemblies
|
|
|
|
|