From 48fcf0313e7a54e956a2c9be7237adcba9e44498 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 15 Aug 2026 10:12:42 +0200 Subject: [PATCH] Move UsingScope and CSharpTypeResolveContext into the type system Both types are consumed well outside the C# output layer - DecompileRun carries the using scope, and the IL transforms build a resolve context from it - so living in ICSharpCode.Decompiler.CSharp.TypeSystem misrepresented where they belong and forced a C#-specific namespace import on every consumer. Assisted-by: Claude:claude-opus-5[1m]:Claude Code --- ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs | 2 +- ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs | 1 - ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs | 1 - ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs | 1 - .../CSharp/Transforms/IntroduceExtensionMethods.cs | 2 +- .../CSharp/Transforms/IntroduceUsingDeclarations.cs | 1 - ICSharpCode.Decompiler/DecompileRun.cs | 4 ++-- ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs | 1 - ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs | 2 +- .../Implementation}/CSharpTypeResolveContext.cs | 4 +--- ICSharpCode.Decompiler/{CSharp => }/TypeSystem/UsingScope.cs | 4 ++-- 11 files changed, 8 insertions(+), 15 deletions(-) rename ICSharpCode.Decompiler/{CSharp/TypeSystem => TypeSystem/Implementation}/CSharpTypeResolveContext.cs (97%) rename ICSharpCode.Decompiler/{CSharp => }/TypeSystem/UsingScope.cs (97%) diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 0a2cd75f8..240ac9395 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -32,7 +32,6 @@ using ICSharpCode.Decompiler.CSharp.OutputVisitor; using ICSharpCode.Decompiler.CSharp.Resolver; using ICSharpCode.Decompiler.CSharp.Syntax; using ICSharpCode.Decompiler.CSharp.Transforms; -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.DebugSteps; using ICSharpCode.Decompiler.DebugInfo; using ICSharpCode.Decompiler.Disassembler; @@ -44,6 +43,7 @@ using ICSharpCode.Decompiler.Instrumentation; using ICSharpCode.Decompiler.Metadata; using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.TypeSystem.Implementation; using ICSharpCode.Decompiler.Util; using SRM = System.Reflection.Metadata; diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index 231c00890..20b0ca445 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -28,7 +28,6 @@ using System.Threading; using ICSharpCode.Decompiler.CSharp.Resolver; using ICSharpCode.Decompiler.CSharp.Syntax; using ICSharpCode.Decompiler.CSharp.Transforms; -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.IL; using ICSharpCode.Decompiler.IL.Transforms; using ICSharpCode.Decompiler.Semantics; diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs b/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs index 06ff69a16..862983865 100644 --- a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs +++ b/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs @@ -23,7 +23,6 @@ using System.Diagnostics; using System.Linq; using ICSharpCode.Decompiler.CSharp.Syntax; -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem.Implementation; diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs index 696277501..70c880fd0 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs @@ -27,7 +27,6 @@ using System.Reflection.Metadata.Ecma335; using System.Runtime.CompilerServices; using ICSharpCode.Decompiler.CSharp.Resolver; -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem.Implementation; diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs index 7cb5ac668..edde48815 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs @@ -25,9 +25,9 @@ using System.Linq; using ICSharpCode.Decompiler.CSharp.Resolver; using ICSharpCode.Decompiler.CSharp.Syntax; -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.TypeSystem.Implementation; using ICSharpCode.Decompiler.Util; namespace ICSharpCode.Decompiler.CSharp.Transforms diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs index 7144e718f..b953e0652 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs @@ -29,7 +29,6 @@ using ICSharpCode.Decompiler.CSharp.Syntax; #if STEP using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching; #endif -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.IL; using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.TypeSystem; diff --git a/ICSharpCode.Decompiler/DecompileRun.cs b/ICSharpCode.Decompiler/DecompileRun.cs index 10cb42fda..8f9242aef 100644 --- a/ICSharpCode.Decompiler/DecompileRun.cs +++ b/ICSharpCode.Decompiler/DecompileRun.cs @@ -46,9 +46,9 @@ namespace ICSharpCode.Decompiler public Dictionary TypeHierarchyIsKnown { get; } = new(); - public CSharp.TypeSystem.UsingScope UsingScope { get; } + public UsingScope UsingScope { get; } - public DecompileRun(DecompilerSettings settings, CSharp.TypeSystem.UsingScope usingScope) + public DecompileRun(DecompilerSettings settings, UsingScope usingScope) { this.Settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.UsingScope = usingScope ?? throw new ArgumentNullException(nameof(usingScope)); diff --git a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs index 2aa1f5a4d..3e626d956 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs @@ -29,7 +29,6 @@ using Humanizer.Inflections; using ICSharpCode.Decompiler.CSharp; using ICSharpCode.Decompiler.CSharp.OutputVisitor; using ICSharpCode.Decompiler.CSharp.Transforms; -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem.Implementation; using ICSharpCode.Decompiler.Util; diff --git a/ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs index 4c00a8871..e56b1cc3e 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs @@ -24,10 +24,10 @@ using System.Diagnostics; using System.Threading; using ICSharpCode.Decompiler.CSharp.Resolver; -using ICSharpCode.Decompiler.CSharp.TypeSystem; using ICSharpCode.Decompiler.DebugSteps; using ICSharpCode.Decompiler.DebugInfo; using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.TypeSystem.Implementation; using ICSharpCode.Decompiler.Util; namespace ICSharpCode.Decompiler.IL.Transforms diff --git a/ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/CSharpTypeResolveContext.cs similarity index 97% rename from ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs rename to ICSharpCode.Decompiler/TypeSystem/Implementation/CSharpTypeResolveContext.cs index 7cf1716b6..f2999d198 100644 --- a/ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/CSharpTypeResolveContext.cs @@ -18,9 +18,7 @@ using System; -using ICSharpCode.Decompiler.TypeSystem; - -namespace ICSharpCode.Decompiler.CSharp.TypeSystem +namespace ICSharpCode.Decompiler.TypeSystem.Implementation { public sealed class CSharpTypeResolveContext : ITypeResolveContext { diff --git a/ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs b/ICSharpCode.Decompiler/TypeSystem/UsingScope.cs similarity index 97% rename from ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs rename to ICSharpCode.Decompiler/TypeSystem/UsingScope.cs index 545f83694..374d5ee4d 100644 --- a/ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs +++ b/ICSharpCode.Decompiler/TypeSystem/UsingScope.cs @@ -23,12 +23,12 @@ using System.Collections.Immutable; using ICSharpCode.Decompiler.CSharp.Syntax; using ICSharpCode.Decompiler.Semantics; -using ICSharpCode.Decompiler.TypeSystem; +using ICSharpCode.Decompiler.TypeSystem.Implementation; using ICSharpCode.Decompiler.Util; #nullable enable -namespace ICSharpCode.Decompiler.CSharp.TypeSystem +namespace ICSharpCode.Decompiler.TypeSystem { /// /// Represents a scope that contains "using" statements.