Skip to content
Permalink
Browse files

Rename IAssembly -> IModule.

While support for multi-module assemblies isn't fully working yet; it is clear at this point that we want
to treat each module in a multi-module assembly separately for the purposes of the type system.
  • Loading branch information...
dgrunwald committed Jul 13, 2018
1 parent 6d17926 commit 3b46776c5ef1ca79efc98f547ad71e3436a8b0d1
Showing with 548 additions and 606 deletions.
  1. +1 −1 ICSharpCode.Decompiler.Tests/Semantics/OverloadResolutionTests.cs
  2. +3 −3 ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs
  3. +8 −8 ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  4. +3 −3 ICSharpCode.Decompiler/CSharp/CallBuilder.cs
  5. +2 −2 ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  6. +5 −5 ICSharpCode.Decompiler/CSharp/RequiredNamespaceCollector.cs
  7. +2 −2 ICSharpCode.Decompiler/CSharp/Resolver/CSharpOperators.cs
  8. +6 −6 ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
  9. +8 −8 ICSharpCode.Decompiler/CSharp/Resolver/MemberLookup.cs
  10. +2 −2 ICSharpCode.Decompiler/CSharp/Resolver/ReducedExtensionMethod.cs
  11. +1 −1 ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  12. +2 −2 ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs
  13. +3 −3 ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs
  14. +3 −3 ICSharpCode.Decompiler/CSharp/Transforms/TransformContext.cs
  15. +13 −13 ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs
  16. +2 −2 ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
  17. +1 −1 ICSharpCode.Decompiler/CSharp/TypeSystem/TypeOrNamespaceReference.cs
  18. +1 −1 ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs
  19. +3 −3 ICSharpCode.Decompiler/DebugInfo/PortablePdbWriter.cs
  20. +1 −1 ICSharpCode.Decompiler/Documentation/GetPotentiallyNestedClassTypeReference.cs
  21. +6 −5 ICSharpCode.Decompiler/Documentation/IdStringProvider.cs
  22. +2 −2 ICSharpCode.Decompiler/Documentation/XmlDocKeyProvider.cs
  23. +2 −2 ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  24. +1 −1 ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs
  25. +1 −1 ICSharpCode.Decompiler/IL/Transforms/TransformCollectionAndObjectInitializers.cs
  26. +2 −2 ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs
  27. +20 −7 ICSharpCode.Decompiler/Metadata/PEFile.cs
  28. +2 −2 ICSharpCode.Decompiler/SRMExtensions.cs
  29. +1 −1 ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs
  30. +1 −1 ICSharpCode.Decompiler/TypeSystem/AssemblyQualifiedTypeName.cs
  31. +12 −20 ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs
  32. +23 −9 ICSharpCode.Decompiler/TypeSystem/IAssembly.cs
  33. +11 −9 ICSharpCode.Decompiler/TypeSystem/ICompilation.cs
  34. +1 −1 ICSharpCode.Decompiler/TypeSystem/IDecompilerTypeSystem.cs
  35. +2 −3 ICSharpCode.Decompiler/TypeSystem/IEntity.cs
  36. +2 −2 ICSharpCode.Decompiler/TypeSystem/INamespace.cs
  37. +3 −3 ICSharpCode.Decompiler/TypeSystem/ITypeReference.cs
  38. +28 −28 ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs
  39. +6 −6 ICSharpCode.Decompiler/TypeSystem/Implementation/CustomAttribute.cs
  40. +8 −8 ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAssemblyReference.cs
  41. +1 −1 ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs
  42. +16 −16 ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs
  43. +1 −1 ICSharpCode.Decompiler/TypeSystem/Implementation/KnownTypeCache.cs
  44. +2 −2 ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs
  45. +17 −17 ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataEvent.cs
  46. +20 −20 ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataField.cs
  47. +34 −34 ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs
  48. +12 −12 ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataNamespace.cs
  49. +9 −9 ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataParameter.cs
  50. +18 −23 ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs
  51. +40 −40 ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeDefinition.cs
  52. +16 −16 ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeParameter.cs
  53. +15 −15 ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs
  54. +0 −67 ICSharpCode.Decompiler/TypeSystem/Implementation/{TypeSpecification.cs → PinnedType.cs}
  55. +18 −18 ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs
  56. +2 −2 ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs
  57. +14 −15 ICSharpCode.Decompiler/TypeSystem/{MetadataAssembly.cs → MetadataModule.cs}
  58. +3 −3 ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs
  59. +13 −13 ICSharpCode.Decompiler/TypeSystem/SimpleTypeResolveContext.cs
  60. +1 −5 ICSharpCode.Decompiler/TypeSystem/SpecializingDecompilerTypeSystem.cs
  61. +7 −7 ICSharpCode.Decompiler/TypeSystem/TupleType.cs
  62. +9 −9 ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs
  63. +10 −10 ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
  64. +2 −2 ICSharpCode.Decompiler/TypeSystem/VarArgInstanceMethod.cs
  65. +1 −1 ILSpy.BamlDecompiler/CecilType.cs
  66. +1 −1 ILSpy.BamlDecompiler/CecilTypeResolver.cs
  67. +1 −1 ILSpy/Analyzers/AnalyzerEntityTreeNode.cs
  68. +1 −1 ILSpy/Analyzers/AnalyzerSearchTreeNode.cs
  69. +3 −3 ILSpy/Analyzers/Builtin/EventImplementsInterfaceAnalyzer.cs
  70. +2 −2 ILSpy/Analyzers/Builtin/EventOverriddenByAnalyzer.cs
  71. +1 −1 ILSpy/Analyzers/Builtin/FieldAccessAnalyzer.cs
  72. +3 −3 ILSpy/Analyzers/Builtin/MethodImplementsInterfaceAnalyzer.cs
  73. +2 −2 ILSpy/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs
  74. +1 −1 ILSpy/Analyzers/Builtin/MethodUsedByAnalyzer.cs
  75. +1 −1 ILSpy/Analyzers/Builtin/MethodUsesAnalyzer.cs
  76. +1 −1 ILSpy/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs
  77. +3 −3 ILSpy/Analyzers/Builtin/PropertyImplementsInterfaceAnalyzer.cs
  78. +2 −2 ILSpy/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs
  79. +1 −1 ILSpy/Analyzers/Builtin/TypeExposedByAnalyzer.cs
  80. +1 −1 ILSpy/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs
  81. +2 −2 ILSpy/Analyzers/Builtin/TypeUsedByAnalyzer.cs
  82. +3 −3 ILSpy/Analyzers/ScopedWhereUsedAnalyzer.cs
  83. +7 −7 ILSpy/Languages/CSharpLanguage.cs
  84. +3 −3 ILSpy/Languages/ILAstLanguage.cs
  85. +8 −8 ILSpy/Languages/ILLanguage.cs
  86. +1 −1 ILSpy/SearchPane.cs
  87. +1 −1 ILSpy/SearchStrategies.cs
  88. +4 −4 ILSpy/TextView/DecompilerTextView.cs
  89. +3 −5 ILSpy/TreeNodes/AssemblyListTreeNode.cs
  90. +1 −1 ILSpy/TreeNodes/AssemblyTreeNode.cs
  91. +2 −2 ILSpy/TreeNodes/BaseTypesEntryNode.cs
  92. +2 −2 ILSpy/TreeNodes/DerivedTypesTreeNode.cs
  93. +1 −1 ILSpy/TypeExtensionMethodsAnalyzer.cs
  94. +1 −1 TestPlugin/CustomLanguage.cs
@@ -49,7 +49,7 @@ ResolveResult[] MakeArgumentList(params Type[] argumentTypes)

IMethod MakeMethod(params object[] parameterTypesOrDefaultValues)
{
var context = new SimpleTypeResolveContext(compilation.MainAssembly);
var context = new SimpleTypeResolveContext(compilation.MainModule);
var m = new FakeMethod(compilation, SymbolKind.Method);
m.Name = "Method";
var parameters = new List<IParameter>();
@@ -159,7 +159,7 @@ public void DynamicParameterHasNoAttributes()
[Test]
public void AssemblyAttribute()
{
var attributes = compilation.MainAssembly.GetAssemblyAttributes().ToList();
var attributes = compilation.MainModule.GetAssemblyAttributes().ToList();
var typeTest = attributes.Single(a => a.AttributeType.FullName == typeof(TypeTestAttribute).FullName);
Assert.AreEqual(3, typeTest.FixedArguments.Length);
// first argument is (int)42
@@ -185,7 +185,7 @@ public void AssemblyAttribute()
[Test]
public void TypeForwardedTo_Attribute()
{
var attributes = compilation.MainAssembly.GetAssemblyAttributes().ToList();
var attributes = compilation.MainModule.GetAssemblyAttributes().ToList();
var forwardAttribute = attributes.Single(a => a.AttributeType.FullName == typeof(TypeForwardedToAttribute).FullName);
Assert.AreEqual(1, forwardAttribute.FixedArguments.Length);
var rt = (IType)forwardAttribute.FixedArguments[0].Value;
@@ -1813,7 +1813,7 @@ public void FindRedirectedType()
var typeRef = ReflectionHelper.ParseReflectionName("System.Func`2, System.Core");
ITypeDefinition c = typeRef.Resolve(compilationWithSystemCore.TypeResolveContext).GetDefinition();
Assert.IsNotNull(c, "System.Func<,> not found");
Assert.AreEqual("mscorlib", c.ParentAssembly.AssemblyName);
Assert.AreEqual("mscorlib", c.ParentModule.AssemblyName);
}

public void DelegateIsClass()
@@ -374,7 +374,7 @@ string SyntaxTreeToString(SyntaxTree syntaxTree)
/// </summary>
public SyntaxTree DecompileModuleAndAssemblyAttributes()
{
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainAssembly);
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainModule);
var decompileRun = new DecompileRun(settings) {
DocumentationProvider = DocumentationProvider ?? CreateDefaultDocumentationProvider(),
CancellationToken = CancellationToken
@@ -396,13 +396,13 @@ public string DecompileModuleAndAssemblyAttributesToString()

void DoDecompileModuleAndAssemblyAttributes(DecompileRun decompileRun, ITypeResolveContext decompilationContext, SyntaxTree syntaxTree)
{
foreach (var a in typeSystem.Compilation.MainAssembly.GetAssemblyAttributes()) {
foreach (var a in typeSystem.Compilation.MainModule.GetAssemblyAttributes()) {
var astBuilder = CreateAstBuilder(decompilationContext);
var attrSection = new AttributeSection(astBuilder.ConvertAttribute(a));
attrSection.AttributeTarget = "assembly";
syntaxTree.AddChild(attrSection, SyntaxTree.MemberRole);
}
foreach (var a in typeSystem.Compilation.MainAssembly.GetModuleAttributes()) {
foreach (var a in typeSystem.Compilation.MainModule.GetModuleAttributes()) {
var astBuilder = CreateAstBuilder(decompilationContext);
var attrSection = new AttributeSection(astBuilder.ConvertAttribute(a));
attrSection.AttributeTarget = "module";
@@ -439,7 +439,7 @@ void DoDecompileTypes(IEnumerable<TypeDefinitionHandle> types, DecompileRun deco
/// </summary>
public SyntaxTree DecompileWholeModuleAsSingleFile()
{
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainAssembly);
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainModule);
var decompileRun = new DecompileRun(settings) {
DocumentationProvider = DocumentationProvider ?? CreateDefaultDocumentationProvider(),
CancellationToken = CancellationToken
@@ -566,7 +566,7 @@ public SyntaxTree DecompileTypes(IEnumerable<TypeDefinitionHandle> types)
{
if (types == null)
throw new ArgumentNullException(nameof(types));
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainAssembly);
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainModule);
var decompileRun = new DecompileRun(settings) {
DocumentationProvider = DocumentationProvider ?? CreateDefaultDocumentationProvider(),
CancellationToken = CancellationToken
@@ -606,7 +606,7 @@ public SyntaxTree DecompileType(FullTypeName fullTypeName)
var type = typeSystem.Compilation.FindType(fullTypeName.TopLevelTypeName).GetDefinition();
if (type == null)
throw new InvalidOperationException($"Could not find type definition {fullTypeName} in type system.");
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainAssembly);
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainModule);
var decompileRun = new DecompileRun(settings) {
DocumentationProvider = DocumentationProvider ?? CreateDefaultDocumentationProvider(),
CancellationToken = CancellationToken
@@ -697,7 +697,7 @@ public SyntaxTree Decompile(IList<EntityHandle> definitions)
throw new NotSupportedException(entity.Kind.ToString());
}
}
RunTransforms(syntaxTree, decompileRun, parentTypeDef != null ? new SimpleTypeResolveContext(parentTypeDef) : new SimpleTypeResolveContext(typeSystem.MainAssembly));
RunTransforms(syntaxTree, decompileRun, parentTypeDef != null ? new SimpleTypeResolveContext(parentTypeDef) : new SimpleTypeResolveContext(typeSystem.MainModule));
return syntaxTree;
}

@@ -776,7 +776,7 @@ void SetNewModifier(EntityDeclaration member)
{
bool addNewModifier = false;
var entity = (IEntity)member.GetSymbol();
var lookup = new MemberLookup(entity.DeclaringTypeDefinition, entity.ParentAssembly);
var lookup = new MemberLookup(entity.DeclaringTypeDefinition, entity.ParentModule);

var baseTypes = entity.DeclaringType.GetNonInterfaceBaseTypes().Where(t => entity.DeclaringType != t);
if (entity is ITypeDefinition) {
@@ -611,7 +611,7 @@ private ExpressionWithResolveResult HandleImplicitConversion(IMethod method, Tra
out IParameterizedMember foundMember)
{
foundMember = null;
var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentAssembly);
var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentModule);
var or = new OverloadResolution(resolver.Compilation,
arguments.SelectArray(a => a.ResolveResult),
argumentNames: argumentNames,
@@ -674,7 +674,7 @@ static bool CanInferAnonymousTypePropertyNamesFromArguments(IList<Expression> ar
return false;
foundMember = result.Member;
} else {
var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentAssembly);
var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentModule);
if (method.AccessorOwner.SymbolKind == SymbolKind.Indexer) {
var or = new OverloadResolution(resolver.Compilation,
arguments.SelectArray(a => a.ResolveResult),
@@ -848,7 +848,7 @@ TranslatedExpression HandleDelegateConstruction(CallInstruction inst)
}
MemberLookup lookup = null;
if (requireTarget) {
lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentAssembly);
lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentModule);
var rr = lookup.Lookup(target.ResolveResult, method.Name, method.TypeArguments, false) ;
needsCast = true;
result = rr;
@@ -86,7 +86,7 @@ public ExpressionBuilder(IDecompilerTypeSystem typeSystem, ITypeResolveContext d
this.settings = settings;
this.cancellationToken = cancellationToken;
this.compilation = decompilationContext.Compilation;
this.resolver = new CSharpResolver(new CSharpTypeResolveContext(compilation.MainAssembly, null, decompilationContext.CurrentTypeDefinition, decompilationContext.CurrentMember));
this.resolver = new CSharpResolver(new CSharpTypeResolveContext(compilation.MainModule, null, decompilationContext.CurrentTypeDefinition, decompilationContext.CurrentMember));
this.astBuilder = new TypeSystemAstBuilder(resolver);
this.astBuilder.AlwaysUseShortTypeNames = true;
this.astBuilder.AddResolveResultAnnotations = true;
@@ -209,7 +209,7 @@ bool IsUnambiguousAccess()
var result = resolver.ResolveSimpleName(field.Name, EmptyList<IType>.Instance, isInvocationTarget: false) as MemberResolveResult;
return !(result == null || result.IsError || !result.Member.Equals(field, NormalizeTypeVisitor.TypeErasure));
} else {
var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentAssembly);
var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentModule);
var result = lookup.Lookup(target.ResolveResult, field.Name, EmptyList<IType>.Instance, false) as MemberResolveResult;
return !(result == null || result.IsError || !result.Member.Equals(field, NormalizeTypeVisitor.TypeErasure));
}
@@ -22,16 +22,16 @@ class RequiredNamespaceCollector
{
public static void CollectNamespaces(DecompilerTypeSystem typeSystem, HashSet<string> namespaces)
{
foreach (var type in typeSystem.MainAssembly.TypeDefinitions) {
foreach (var type in typeSystem.MainModule.TypeDefinitions) {
CollectNamespaces(type, typeSystem, namespaces);
}
CollectAttributeNamespaces(typeSystem, namespaces);
}

public static void CollectAttributeNamespaces(DecompilerTypeSystem typeSystem, HashSet<string> namespaces)
{
HandleAttributes(typeSystem.MainAssembly.GetAssemblyAttributes(), namespaces);
HandleAttributes(typeSystem.MainAssembly.GetModuleAttributes(), namespaces);
HandleAttributes(typeSystem.MainModule.GetAssemblyAttributes(), namespaces);
HandleAttributes(typeSystem.MainModule.GetModuleAttributes(), namespaces);
}

public static void CollectNamespaces(IEntity entity, DecompilerTypeSystem typeSystem,
@@ -42,7 +42,7 @@ public static void CollectAttributeNamespaces(DecompilerTypeSystem typeSystem, H
switch (entity) {
case ITypeDefinition td:
if (mappingInfo == null)
mappingInfo = CSharpDecompiler.GetCodeMappingInfo(entity.ParentAssembly.PEFile, entity.MetadataToken);
mappingInfo = CSharpDecompiler.GetCodeMappingInfo(entity.ParentModule.PEFile, entity.MetadataToken);
namespaces.Add(td.Namespace);
HandleAttributes(td.GetAttributes(), namespaces);

@@ -91,7 +91,7 @@ public static void CollectAttributeNamespaces(DecompilerTypeSystem typeSystem, H
}
if (!method.MetadataToken.IsNil && method.HasBody) {
if (mappingInfo == null)
mappingInfo = CSharpDecompiler.GetCodeMappingInfo(entity.ParentAssembly.PEFile, entity.MetadataToken);
mappingInfo = CSharpDecompiler.GetCodeMappingInfo(entity.ParentModule.PEFile, entity.MetadataToken);
var reader = typeSystem.ModuleDefinition.Reader;
var parts = mappingInfo.GetMethodParts((MethodDefinitionHandle)method.MetadataToken).ToList();
foreach (var part in parts) {
@@ -175,8 +175,8 @@ IEnumerable<IAttribute> IEntity.GetAttributes()
get { return false; }
}

IAssembly IEntity.ParentAssembly {
get { return compilation.MainAssembly; }
IModule IEntity.ParentModule {
get { return compilation.MainModule; }
}

TypeParameterSubstitution IMember.Substitution {
@@ -52,7 +52,7 @@ public CSharpResolver(ICompilation compilation)
throw new ArgumentNullException("compilation");
this.compilation = compilation;
this.conversions = CSharpConversions.Get(compilation);
this.context = new CSharpTypeResolveContext(compilation.MainAssembly);
this.context = new CSharpTypeResolveContext(compilation.MainModule);
}

public CSharpResolver(CSharpTypeResolveContext context)
@@ -94,8 +94,8 @@ private CSharpResolver(ICompilation compilation, CSharpConversions conversions,
get { return context; }
}

IAssembly ITypeResolveContext.CurrentAssembly {
get { return context.CurrentAssembly; }
IModule ITypeResolveContext.CurrentModule {
get { return context.CurrentModule; }
}

CSharpResolver WithContext(CSharpTypeResolveContext newContext)
@@ -1536,7 +1536,7 @@ ResolveResult LookInUsingScopeNamespace(ResolvedUsingScope usingScope, INamespac
bool TopLevelTypeDefinitionIsAccessible(ITypeDefinition typeDef)
{
if (typeDef.Accessibility == Accessibility.Internal) {
return typeDef.ParentAssembly.InternalsVisibleTo(compilation.MainAssembly);
return typeDef.ParentModule.InternalsVisibleTo(compilation.MainModule);
}
return true;
}
@@ -1651,7 +1651,7 @@ public MemberLookup CreateMemberLookup()
ITypeDefinition currentTypeDefinition = this.CurrentTypeDefinition;
bool isInEnumMemberInitializer = this.CurrentMember != null && this.CurrentMember.SymbolKind == SymbolKind.Field
&& currentTypeDefinition != null && currentTypeDefinition.Kind == TypeKind.Enum;
return new MemberLookup(currentTypeDefinition, this.Compilation.MainAssembly, isInEnumMemberInitializer);
return new MemberLookup(currentTypeDefinition, this.Compilation.MainModule, isInEnumMemberInitializer);
}

/// <summary>
@@ -1664,7 +1664,7 @@ public MemberLookup CreateMemberLookup(NameLookupMode lookupMode)
// for accessibility purposes.
// This avoids a stack overflow when referencing a protected class nested inside the base class
// of a parent class. (NameLookupTests.InnerClassInheritingFromProtectedBaseInnerClassShouldNotCauseStackOverflow)
return new MemberLookup(this.CurrentTypeDefinition.DeclaringTypeDefinition, this.Compilation.MainAssembly, false);
return new MemberLookup(this.CurrentTypeDefinition.DeclaringTypeDefinition, this.Compilation.MainModule, false);
} else {
return CreateMemberLookup();
}
@@ -47,13 +47,13 @@ public static bool IsInvocable(IMember member)
#endregion

readonly ITypeDefinition currentTypeDefinition;
readonly IAssembly currentAssembly;
readonly IModule currentModule;
readonly bool isInEnumMemberInitializer;

public MemberLookup(ITypeDefinition currentTypeDefinition, IAssembly currentAssembly, bool isInEnumMemberInitializer = false)
public MemberLookup(ITypeDefinition currentTypeDefinition, IModule currentModule, bool isInEnumMemberInitializer = false)
{
this.currentTypeDefinition = currentTypeDefinition;
this.currentAssembly = currentAssembly;
this.currentModule = currentModule;
this.isInEnumMemberInitializer = isInEnumMemberInitializer;
}

@@ -116,19 +116,19 @@ public bool IsAccessible(IEntity entity, bool allowProtectedAccess)
case Accessibility.Protected:
return IsProtectedAccessible(allowProtectedAccess, entity);
case Accessibility.Internal:
return IsInternalAccessible(entity.ParentAssembly);
return IsInternalAccessible(entity.ParentModule);
case Accessibility.ProtectedOrInternal:
return IsInternalAccessible(entity.ParentAssembly) || IsProtectedAccessible(allowProtectedAccess, entity);
return IsInternalAccessible(entity.ParentModule) || IsProtectedAccessible(allowProtectedAccess, entity);
case Accessibility.ProtectedAndInternal:
return IsInternalAccessible(entity.ParentAssembly) && IsProtectedAccessible(allowProtectedAccess, entity);
return IsInternalAccessible(entity.ParentModule) && IsProtectedAccessible(allowProtectedAccess, entity);
default:
throw new Exception("Invalid value for Accessibility");
}
}

bool IsInternalAccessible(IAssembly assembly)
bool IsInternalAccessible(IModule module)
{
return assembly != null && currentAssembly != null && assembly.InternalsVisibleTo(currentAssembly);
return module != null && currentModule != null && module.InternalsVisibleTo(currentModule);
}

bool IsProtectedAccessible(bool allowProtectedAccess, IEntity entity)
@@ -231,9 +231,9 @@ IMember IMember.Specialize(TypeParameterSubstitution substitution)
}
}

public IAssembly ParentAssembly {
public IModule ParentModule {
get {
return baseMethod.ParentAssembly;
return baseMethod.ParentModule;
}
}

@@ -204,7 +204,7 @@ public AstType ConvertType(IType type)
public AstType ConvertType(FullTypeName fullTypeName)
{
if (resolver != null) {
foreach (var asm in resolver.Compilation.Assemblies) {
foreach (var asm in resolver.Compilation.Modules) {
var def = asm.GetTypeDefinition(fullTypeName);
if (def != null) {
return ConvertType(def);
@@ -56,7 +56,7 @@ void InitializeContext(UsingScope usingScope)
usingScope = new UsingScope(usingScope, ns);
}
}
var currentContext = new CSharpTypeResolveContext(context.TypeSystem.MainAssembly, usingScope.Resolve(context.TypeSystem.Compilation), context.DecompiledTypeDefinition);
var currentContext = new CSharpTypeResolveContext(context.TypeSystem.MainModule, usingScope.Resolve(context.TypeSystem.Compilation), context.DecompiledTypeDefinition);
this.resolveContextStack.Push(currentContext);
this.resolver = new CSharpResolver(currentContext);
}
@@ -68,7 +68,7 @@ public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDec
foreach (string ident in namespaceDeclaration.Identifiers) {
usingScope = new UsingScope(usingScope, ident);
}
var currentContext = new CSharpTypeResolveContext(previousContext.CurrentAssembly, usingScope.Resolve(previousContext.Compilation));
var currentContext = new CSharpTypeResolveContext(previousContext.CurrentModule, usingScope.Resolve(previousContext.Compilation));
resolveContextStack.Push(currentContext);
try {
this.resolver = new CSharpResolver(currentContext);
@@ -130,7 +130,7 @@ public FullyQualifyAmbiguousTypeNamesVisitor(TransformContext context, UsingScop
usingScope = new UsingScope(usingScope, ns);
}
}
var currentContext = new CSharpTypeResolveContext(context.TypeSystem.MainAssembly, usingScope.Resolve(context.TypeSystem.Compilation), context.DecompiledTypeDefinition);
var currentContext = new CSharpTypeResolveContext(context.TypeSystem.MainModule, usingScope.Resolve(context.TypeSystem.Compilation), context.DecompiledTypeDefinition);
this.context.Push(currentContext);
this.astBuilder = CreateAstBuilder(currentContext);
}
@@ -150,7 +150,7 @@ public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDec
foreach (string ident in namespaceDeclaration.Identifiers) {
usingScope = new UsingScope(usingScope, ident);
}
var currentContext = new CSharpTypeResolveContext(previousContext.CurrentAssembly, usingScope.Resolve(previousContext.Compilation));
var currentContext = new CSharpTypeResolveContext(previousContext.CurrentModule, usingScope.Resolve(previousContext.Compilation));
context.Push(currentContext);
try {
astBuilder = CreateAstBuilder(currentContext);
@@ -179,7 +179,7 @@ public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
{
if (methodDeclaration.GetSymbol() is IMethod method && CSharpDecompiler.IsWindowsFormsInitializeComponentMethod(method)) {
var previousContext = context.Peek();
var currentContext = new CSharpTypeResolveContext(previousContext.CurrentAssembly);
var currentContext = new CSharpTypeResolveContext(previousContext.CurrentModule);
context.Push(currentContext);
try {
astBuilder = CreateAstBuilder(currentContext);
@@ -51,10 +51,10 @@ public class TransformContext
}

/// <summary>
/// Returns the assembly that is being decompiled.
/// Returns the module that is being decompiled.
/// </summary>
public IAssembly DecompiledAssembly {
get { return decompilationContext.CurrentAssembly; }
public IModule DecompiledModule {
get { return decompilationContext.CurrentModule; }
}

/// <summary>
Oops, something went wrong.

0 comments on commit 3b46776

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.