Browse Source

Move the remaining ResolveResult subclasses into the Semantics namespace

The resolve-result hierarchy was split between ICSharpCode.Decompiler.Semantics
and ICSharpCode.Decompiler.CSharp.Resolver, so consumers had to know which half
a given result came from and import both namespaces. All subclasses now live
next to their base class; MethodListWithDeclaringType follows the method group
it describes, and ILVariableResolveResult gets its own file instead of sitting
among the syntax-tree annotation helpers.

Assisted-by: Claude:claude-opus-5[1m]:Claude Code
pull/4006/head
Siegfried Pammer 1 month ago
parent
commit
471c3b1776
  1. 19
      ICSharpCode.Decompiler/CSharp/Annotations.cs
  2. 1
      ICSharpCode.Decompiler/CSharp/Transforms/CombineQueryExpressions.cs
  3. 1
      ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs
  4. 1
      ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs
  5. 1
      ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs
  6. 7
      ICSharpCode.Decompiler/Output/TextTokenWriter.cs
  7. 4
      ICSharpCode.Decompiler/Semantics/CSharpInvocationResolveResult.cs
  8. 3
      ICSharpCode.Decompiler/Semantics/DynamicInvocationResolveResult.cs
  9. 3
      ICSharpCode.Decompiler/Semantics/DynamicMemberResolveResult.cs
  10. 45
      ICSharpCode.Decompiler/Semantics/ILVariableResolveResult.cs
  11. 4
      ICSharpCode.Decompiler/Semantics/LambdaResolveResult.cs
  12. 5
      ICSharpCode.Decompiler/Semantics/MethodGroupResolveResult.cs
  13. 4
      ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
  14. 1
      ILSpy/Languages/CSharpHighlightingTokenWriter.cs

19
ICSharpCode.Decompiler/CSharp/Annotations.cs

@ -20,7 +20,6 @@ using System; @@ -20,7 +20,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Semantics;
@ -240,24 +239,6 @@ namespace ICSharpCode.Decompiler.CSharp @@ -240,24 +239,6 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
/// <summary>
/// Represents a reference to a local variable.
/// </summary>
public class ILVariableResolveResult : ResolveResult
{
public readonly ILVariable Variable;
public ILVariableResolveResult(ILVariable v) : base(v.Type)
{
this.Variable = v;
}
public ILVariableResolveResult(ILVariable v, IType type) : base(type)
{
this.Variable = v ?? throw new ArgumentNullException(nameof(v));
}
}
/// <summary>
/// Annotates a <see cref="ForeachStatement"/> with the instructions for the GetEnumerator, MoveNext
/// and get_Current calls.

1
ICSharpCode.Decompiler/CSharp/Transforms/CombineQueryExpressions.cs

@ -24,6 +24,7 @@ using System.Linq; @@ -24,6 +24,7 @@ using System.Linq;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.CSharp.Transforms

1
ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs

@ -25,6 +25,7 @@ using System.Linq; @@ -25,6 +25,7 @@ using System.Linq;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Semantics;
namespace ICSharpCode.Decompiler.CSharp.Transforms
{

1
ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs

@ -21,7 +21,6 @@ @@ -21,7 +21,6 @@
using System.Diagnostics;
using System.Linq;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.TypeSystem;

1
ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs

@ -26,7 +26,6 @@ using System.Linq; @@ -26,7 +26,6 @@ using System.Linq;
using System.Reflection;
using System.Reflection.Metadata.Ecma335;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
using ICSharpCode.Decompiler.IL;

7
ICSharpCode.Decompiler/Output/TextTokenWriter.cs

@ -22,7 +22,6 @@ using System.Linq; @@ -22,7 +22,6 @@ using System.Linq;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Semantics;
@ -157,14 +156,14 @@ namespace ICSharpCode.Decompiler @@ -157,14 +156,14 @@ namespace ICSharpCode.Decompiler
/// </summary>
static bool IsDynamicMemberReference(AstNode node)
{
if (node.Annotation<ResolveResult>() is CSharp.Resolver.DynamicMemberResolveResult)
if (node.Annotation<ResolveResult>() is DynamicMemberResolveResult)
return true;
// The node itself is a dynamic invocation/indexing (a.Method(b), a[b]): its parentheses/brackets
// carry the synthesized member.
if (node.Annotation<ResolveResult>() is CSharp.Resolver.DynamicInvocationResolveResult)
if (node.Annotation<ResolveResult>() is DynamicInvocationResolveResult)
return true;
if (node.Slot?.Kind == Slots.TargetExpression && node.Parent is InvocationExpression
&& node.Parent.Annotation<ResolveResult>() is CSharp.Resolver.DynamicInvocationResolveResult)
&& node.Parent.Annotation<ResolveResult>() is DynamicInvocationResolveResult)
return true;
// new T(dynamicArg): the object creation (or its type-name slot) is backed by a dynamic newobj,
// whose synthesized constructor has no metadata to navigate to.

4
ICSharpCode.Decompiler/CSharp/Resolver/CSharpInvocationResolveResult.cs → ICSharpCode.Decompiler/Semantics/CSharpInvocationResolveResult.cs

@ -20,10 +20,10 @@ using System; @@ -20,10 +20,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Resolver
namespace ICSharpCode.Decompiler.Semantics
{
/// <summary>
/// Represents the result of a method, constructor or indexer invocation.

3
ICSharpCode.Decompiler/CSharp/Resolver/DynamicInvocationResolveResult.cs → ICSharpCode.Decompiler/Semantics/DynamicInvocationResolveResult.cs

@ -19,11 +19,10 @@ @@ -19,11 +19,10 @@
using System.Collections.Generic;
using System.Globalization;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.CSharp.Resolver
namespace ICSharpCode.Decompiler.Semantics
{
public enum DynamicInvocationType
{

3
ICSharpCode.Decompiler/CSharp/Resolver/DynamicMemberResolveResult.cs → ICSharpCode.Decompiler/Semantics/DynamicMemberResolveResult.cs

@ -18,10 +18,9 @@ @@ -18,10 +18,9 @@
using System.Globalization;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Resolver
namespace ICSharpCode.Decompiler.Semantics
{
/// <summary>
/// Represents the result of an access to a member of a dynamic object.

45
ICSharpCode.Decompiler/Semantics/ILVariableResolveResult.cs

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
// Copyright (c) 2014 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.TypeSystem;
#nullable enable
namespace ICSharpCode.Decompiler.Semantics
{
/// <summary>
/// Represents a reference to a local variable.
/// </summary>
public class ILVariableResolveResult : ResolveResult
{
public readonly ILVariable Variable;
public ILVariableResolveResult(ILVariable v) : base(v.Type)
{
this.Variable = v;
}
public ILVariableResolveResult(ILVariable v, IType type) : base(type)
{
this.Variable = v ?? throw new ArgumentNullException(nameof(v));
}
}
}

4
ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs → ICSharpCode.Decompiler/Semantics/LambdaResolveResult.cs

@ -19,10 +19,10 @@ @@ -19,10 +19,10 @@
using System;
using System.Collections.Generic;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Resolver
namespace ICSharpCode.Decompiler.Semantics
{
/// <summary>
/// Represents an anonymous method or lambda expression.

5
ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs → ICSharpCode.Decompiler/Semantics/MethodGroupResolveResult.cs

@ -20,13 +20,12 @@ using System; @@ -20,13 +20,12 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.NetworkInformation;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.CSharp.Resolver
namespace ICSharpCode.Decompiler.Semantics
{
/// <summary>
/// A method list that belongs to a declaring type.

4
ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs

@ -825,11 +825,11 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -825,11 +825,11 @@ namespace ICSharpCode.Decompiler.TypeSystem
{
return ((ConversionResolveResult)rr).Input.GetSymbol();
}
else if (rr is CSharp.Resolver.DynamicMemberResolveResult dynamicMember)
else if (rr is DynamicMemberResolveResult dynamicMember)
{
return dynamicMember.Symbol;
}
else if (rr is CSharp.Resolver.DynamicInvocationResolveResult dynamicInvocation)
else if (rr is DynamicInvocationResolveResult dynamicInvocation)
{
return dynamicInvocation.Symbol;
}

1
ILSpy/Languages/CSharpHighlightingTokenWriter.cs

@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.CSharp; @@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX.Extensions;

Loading…
Cancel
Save