diff --git a/ICSharpCode.Decompiler/CSharp/Annotations.cs b/ICSharpCode.Decompiler/CSharp/Annotations.cs index 55039ac66..927692e65 100644 --- a/ICSharpCode.Decompiler/CSharp/Annotations.cs +++ b/ICSharpCode.Decompiler/CSharp/Annotations.cs @@ -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 } } - /// - /// Represents a reference to a local variable. - /// - 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)); - } - } - /// /// Annotates a with the instructions for the GetEnumerator, MoveNext /// and get_Current calls. diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/CombineQueryExpressions.cs b/ICSharpCode.Decompiler/CSharp/Transforms/CombineQueryExpressions.cs index a98365095..cd5e99c38 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/CombineQueryExpressions.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/CombineQueryExpressions.cs @@ -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 diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs index 4745061e3..2230ab49c 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs @@ -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 { diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs index 846c70c83..3b76be62a 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs @@ -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; diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs b/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs index 48aefd873..b7d379594 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs @@ -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; diff --git a/ICSharpCode.Decompiler/Output/TextTokenWriter.cs b/ICSharpCode.Decompiler/Output/TextTokenWriter.cs index 134fcc725..424387b21 100644 --- a/ICSharpCode.Decompiler/Output/TextTokenWriter.cs +++ b/ICSharpCode.Decompiler/Output/TextTokenWriter.cs @@ -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 /// static bool IsDynamicMemberReference(AstNode node) { - if (node.Annotation() is CSharp.Resolver.DynamicMemberResolveResult) + if (node.Annotation() 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() is CSharp.Resolver.DynamicInvocationResolveResult) + if (node.Annotation() is DynamicInvocationResolveResult) return true; if (node.Slot?.Kind == Slots.TargetExpression && node.Parent is InvocationExpression - && node.Parent.Annotation() is CSharp.Resolver.DynamicInvocationResolveResult) + && node.Parent.Annotation() 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. diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpInvocationResolveResult.cs b/ICSharpCode.Decompiler/Semantics/CSharpInvocationResolveResult.cs similarity index 98% rename from ICSharpCode.Decompiler/CSharp/Resolver/CSharpInvocationResolveResult.cs rename to ICSharpCode.Decompiler/Semantics/CSharpInvocationResolveResult.cs index af4028d65..310d443db 100644 --- a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpInvocationResolveResult.cs +++ b/ICSharpCode.Decompiler/Semantics/CSharpInvocationResolveResult.cs @@ -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 { /// /// Represents the result of a method, constructor or indexer invocation. diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/DynamicInvocationResolveResult.cs b/ICSharpCode.Decompiler/Semantics/DynamicInvocationResolveResult.cs similarity index 97% rename from ICSharpCode.Decompiler/CSharp/Resolver/DynamicInvocationResolveResult.cs rename to ICSharpCode.Decompiler/Semantics/DynamicInvocationResolveResult.cs index 0cac1b0b0..636879377 100644 --- a/ICSharpCode.Decompiler/CSharp/Resolver/DynamicInvocationResolveResult.cs +++ b/ICSharpCode.Decompiler/Semantics/DynamicInvocationResolveResult.cs @@ -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 { diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/DynamicMemberResolveResult.cs b/ICSharpCode.Decompiler/Semantics/DynamicMemberResolveResult.cs similarity index 96% rename from ICSharpCode.Decompiler/CSharp/Resolver/DynamicMemberResolveResult.cs rename to ICSharpCode.Decompiler/Semantics/DynamicMemberResolveResult.cs index aad95c3d3..bd9f88764 100644 --- a/ICSharpCode.Decompiler/CSharp/Resolver/DynamicMemberResolveResult.cs +++ b/ICSharpCode.Decompiler/Semantics/DynamicMemberResolveResult.cs @@ -18,10 +18,9 @@ using System.Globalization; -using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.TypeSystem; -namespace ICSharpCode.Decompiler.CSharp.Resolver +namespace ICSharpCode.Decompiler.Semantics { /// /// Represents the result of an access to a member of a dynamic object. diff --git a/ICSharpCode.Decompiler/Semantics/ILVariableResolveResult.cs b/ICSharpCode.Decompiler/Semantics/ILVariableResolveResult.cs new file mode 100644 index 000000000..4de63e0af --- /dev/null +++ b/ICSharpCode.Decompiler/Semantics/ILVariableResolveResult.cs @@ -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 +{ + /// + /// Represents a reference to a local variable. + /// + 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)); + } + } +} diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs b/ICSharpCode.Decompiler/Semantics/LambdaResolveResult.cs similarity index 98% rename from ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs rename to ICSharpCode.Decompiler/Semantics/LambdaResolveResult.cs index b82e4f591..67c0d0b6f 100644 --- a/ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs +++ b/ICSharpCode.Decompiler/Semantics/LambdaResolveResult.cs @@ -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 { /// /// Represents an anonymous method or lambda expression. diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs b/ICSharpCode.Decompiler/Semantics/MethodGroupResolveResult.cs similarity index 98% rename from ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs rename to ICSharpCode.Decompiler/Semantics/MethodGroupResolveResult.cs index 9e7b2de6d..e999ce6f2 100644 --- a/ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs +++ b/ICSharpCode.Decompiler/Semantics/MethodGroupResolveResult.cs @@ -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 { /// /// A method list that belongs to a declaring type. diff --git a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs index 898977377..af109ad1e 100644 --- a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs +++ b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs @@ -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; } diff --git a/ILSpy/Languages/CSharpHighlightingTokenWriter.cs b/ILSpy/Languages/CSharpHighlightingTokenWriter.cs index 09684fcfd..9b9f8529f 100644 --- a/ILSpy/Languages/CSharpHighlightingTokenWriter.cs +++ b/ILSpy/Languages/CSharpHighlightingTokenWriter.cs @@ -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;