diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index fc96edc93..b1987262e 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -532,7 +532,7 @@ namespace ICSharpCode.Decompiler.CSharp } } - ResolvedUsingScope usingScope = new ResolvedUsingScope( + UsingScope usingScope = new UsingScope( new CSharpTypeResolveContext(typeSystem.MainModule), typeSystem.RootNamespace, resolvedNamespaces.ToImmutableArray() diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs b/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs index 9e691fb40..e761ed231 100644 --- a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs +++ b/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs @@ -162,14 +162,14 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver /// /// Gets the current using scope that is used to look up identifiers as class names. /// - public ResolvedUsingScope CurrentUsingScope { + public UsingScope CurrentUsingScope { get { return context.CurrentUsingScope; } } /// /// Sets the current using scope that is used to look up identifiers as class names. /// - public CSharpResolver WithCurrentUsingScope(ResolvedUsingScope usingScope) + public CSharpResolver WithCurrentUsingScope(UsingScope usingScope) { return WithContext(context.WithUsingScope(usingScope)); } @@ -1656,8 +1656,8 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver ResolveResult LookInCurrentUsingScope(string identifier, IReadOnlyList typeArguments, bool isInUsingDeclaration, bool parameterizeResultType) { // look in current namespace definitions - ResolvedUsingScope currentUsingScope = this.CurrentUsingScope; - for (ResolvedUsingScope u = currentUsingScope; u != null; u = u.Parent) + UsingScope currentUsingScope = this.CurrentUsingScope; + for (UsingScope u = currentUsingScope; u != null; u = u.Parent) { var resultInNamespace = LookInUsingScopeNamespace(u, u.Namespace, identifier, typeArguments, parameterizeResultType); if (resultInNamespace != null) @@ -1714,7 +1714,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver return null; } - ResolveResult LookInUsingScopeNamespace(ResolvedUsingScope usingScope, INamespace n, string identifier, IReadOnlyList typeArguments, bool parameterizeResultType) + ResolveResult LookInUsingScopeNamespace(UsingScope usingScope, INamespace n, string identifier, IReadOnlyList typeArguments, bool parameterizeResultType) { if (n == null) return null; @@ -1764,7 +1764,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver if (identifier == "global") return new NamespaceResolveResult(compilation.RootNamespace); - for (ResolvedUsingScope n = this.CurrentUsingScope; n != null; n = n.Parent) + for (UsingScope n = this.CurrentUsingScope; n != null; n = n.Parent) { if (n.ExternAliases.Contains(identifier)) { @@ -2190,7 +2190,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver } extensionMethodGroups = new List>(); List m; - for (ResolvedUsingScope scope = currentUsingScope; scope != null; scope = scope.Parent) + for (UsingScope scope = currentUsingScope; scope != null; scope = scope.Parent) { INamespace ns = scope.Namespace; if (ns != null) diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs index 05a62d68d..f4eb64901 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs @@ -495,7 +495,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax // Look if there's an alias to the target type if (UseAliases) { - for (ResolvedUsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent) + for (UsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent) { foreach (var pair in usingScope.UsingAliases) { @@ -643,7 +643,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax // Look if there's an alias to the target namespace if (UseAliases) { - for (ResolvedUsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent) + for (UsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent) { foreach (var pair in usingScope.UsingAliases) { diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs index 2ec0fefc2..146a3c65d 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs @@ -42,11 +42,11 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms { this.context = context; this.conversions = CSharpConversions.Get(context.TypeSystem); - InitializeContext(rootNode.Annotation()); + InitializeContext(rootNode.Annotation()); rootNode.AcceptVisitor(this); } - void InitializeContext(ResolvedUsingScope usingScope) + void InitializeContext(UsingScope usingScope) { if (!string.IsNullOrEmpty(context.CurrentTypeDefinition?.Namespace)) { diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs index 4e712379a..22eb80e1f 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs @@ -73,7 +73,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms } } - var usingScope = new ResolvedUsingScope( + var usingScope = new UsingScope( new CSharpTypeResolveContext(context.TypeSystem.MainModule), context.TypeSystem.RootNamespace, resolvedNamespaces.ToImmutableArray() @@ -189,7 +189,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms CSharpResolver resolver; TypeSystemAstBuilder astBuilder; - public FullyQualifyAmbiguousTypeNamesVisitor(TransformContext context, ResolvedUsingScope usingScope) + public FullyQualifyAmbiguousTypeNamesVisitor(TransformContext context, UsingScope usingScope) { this.ignoreUsingScope = !context.Settings.UsingDeclarations; this.settings = context.Settings; diff --git a/ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs b/ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs index 986ee1020..7a0952b17 100644 --- a/ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs +++ b/ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs @@ -25,12 +25,12 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem public sealed class CSharpTypeResolveContext : ITypeResolveContext { readonly IModule module; - readonly ResolvedUsingScope currentUsingScope; + readonly UsingScope currentUsingScope; readonly ITypeDefinition currentTypeDefinition; readonly IMember currentMember; readonly string[] methodTypeParameterNames; - public CSharpTypeResolveContext(IModule module, ResolvedUsingScope usingScope = null, ITypeDefinition typeDefinition = null, IMember member = null) + public CSharpTypeResolveContext(IModule module, UsingScope usingScope = null, ITypeDefinition typeDefinition = null, IMember member = null) { if (module == null) throw new ArgumentNullException(nameof(module)); @@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem this.currentMember = member; } - private CSharpTypeResolveContext(IModule module, ResolvedUsingScope usingScope, ITypeDefinition typeDefinition, IMember member, string[] methodTypeParameterNames) + private CSharpTypeResolveContext(IModule module, UsingScope usingScope, ITypeDefinition typeDefinition, IMember member, string[] methodTypeParameterNames) { this.module = module; this.currentUsingScope = usingScope; @@ -49,7 +49,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem this.methodTypeParameterNames = methodTypeParameterNames; } - public ResolvedUsingScope CurrentUsingScope { + public UsingScope CurrentUsingScope { get { return currentUsingScope; } } @@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem return WithCurrentMember(member); } - public CSharpTypeResolveContext WithUsingScope(ResolvedUsingScope usingScope) + public CSharpTypeResolveContext WithUsingScope(UsingScope usingScope) { return new CSharpTypeResolveContext(module, usingScope, currentTypeDefinition, currentMember, methodTypeParameterNames); } diff --git a/ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs b/ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs similarity index 93% rename from ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs rename to ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs index 7ad08283b..c1ae68b72 100644 --- a/ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs +++ b/ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs @@ -34,14 +34,14 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem /// Represents a scope that contains "using" statements. /// This is either the mo itself, or a namespace declaration. /// - public class ResolvedUsingScope + public class UsingScope { readonly CSharpTypeResolveContext parentContext; internal readonly ConcurrentDictionary ResolveCache = new ConcurrentDictionary(); internal List>? AllExtensionMethods; - public ResolvedUsingScope(CSharpTypeResolveContext context, INamespace @namespace, ImmutableArray usings) + public UsingScope(CSharpTypeResolveContext context, INamespace @namespace, ImmutableArray usings) { this.parentContext = context ?? throw new ArgumentNullException(nameof(context)); this.Usings = usings; @@ -50,7 +50,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem public INamespace Namespace { get; } - public ResolvedUsingScope Parent { + public UsingScope Parent { get { return parentContext.CurrentUsingScope; } } @@ -66,10 +66,10 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem /// public bool HasAlias(string identifier) => false; - internal ResolvedUsingScope WithNestedNamespace(string simpleName) + internal UsingScope WithNestedNamespace(string simpleName) { var ns = Namespace.GetChildNamespace(simpleName) ?? new DummyNamespace(Namespace, simpleName); - return new ResolvedUsingScope( + return new UsingScope( parentContext.WithUsingScope(this), ns, []); diff --git a/ICSharpCode.Decompiler/DecompileRun.cs b/ICSharpCode.Decompiler/DecompileRun.cs index edfdca568..2e1219e62 100644 --- a/ICSharpCode.Decompiler/DecompileRun.cs +++ b/ICSharpCode.Decompiler/DecompileRun.cs @@ -37,9 +37,9 @@ namespace ICSharpCode.Decompiler public Dictionary TypeHierarchyIsKnown { get; } = new(); - public CSharp.TypeSystem.ResolvedUsingScope UsingScope { get; } + public CSharp.TypeSystem.UsingScope UsingScope { get; } - public DecompileRun(DecompilerSettings settings, CSharp.TypeSystem.ResolvedUsingScope usingScope) + public DecompileRun(DecompilerSettings settings, CSharp.TypeSystem.UsingScope usingScope) { this.Settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.UsingScope = usingScope ?? throw new ArgumentNullException(nameof(usingScope)); diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj index a0eeab536..284298a19 100644 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj +++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj @@ -338,7 +338,7 @@ - + diff --git a/ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs index 330300953..bf1b08b4f 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms public Metadata.MetadataFile PEFile => TypeSystem.MainModule.MetadataFile; internal DecompileRun? DecompileRun { get; set; } - internal ResolvedUsingScope? UsingScope => DecompileRun?.UsingScope; + internal UsingScope? UsingScope => DecompileRun?.UsingScope; CSharpResolver? csharpResolver;