|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
//
|
|
|
|
|
// InvocatedExtensionMethod.cs
|
|
|
|
|
// ReducedExtensionMethod.cs
|
|
|
|
|
//
|
|
|
|
|
// Author:
|
|
|
|
|
// Mike Krüger <mkrueger@xamarin.com>
|
|
|
|
@ -35,26 +35,64 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -35,26 +35,64 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
/// It's used to hide the internals of extension method invocation in certain situation to simulate the
|
|
|
|
|
/// syntactic way of writing extension methods on semantic level.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class InvocatedExtensionMethod : IMethod |
|
|
|
|
public class ReducedExtensionMethod : IMethod |
|
|
|
|
{ |
|
|
|
|
readonly IMethod baseMethod; |
|
|
|
|
|
|
|
|
|
public IMethod InvocatedMethod { |
|
|
|
|
get { |
|
|
|
|
return baseMethod; |
|
|
|
|
public ReducedExtensionMethod(IMethod baseMethod) |
|
|
|
|
{ |
|
|
|
|
this.baseMethod = baseMethod; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj) |
|
|
|
|
{ |
|
|
|
|
var other = obj as ReducedExtensionMethod; |
|
|
|
|
if (other == null) |
|
|
|
|
return false; |
|
|
|
|
return baseMethod.Equals(other.baseMethod); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override int GetHashCode() |
|
|
|
|
{ |
|
|
|
|
unchecked { |
|
|
|
|
return baseMethod.GetHashCode() + 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public InvocatedExtensionMethod(IMethod baseMethod) |
|
|
|
|
public override string ToString() |
|
|
|
|
{ |
|
|
|
|
this.baseMethod = baseMethod; |
|
|
|
|
return string.Format("[ReducedExtensionMethod: ReducedFrom={0}]", ReducedFrom); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region IMember implementation
|
|
|
|
|
|
|
|
|
|
[Serializable] |
|
|
|
|
public sealed class ReducedExtensionMethodMemberReference : IMemberReference |
|
|
|
|
{ |
|
|
|
|
readonly IMethod baseMethod; |
|
|
|
|
|
|
|
|
|
public ReducedExtensionMethodMemberReference (IMethod baseMethod) |
|
|
|
|
{ |
|
|
|
|
this.baseMethod = baseMethod; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region IMemberReference implementation
|
|
|
|
|
public IMember Resolve(ITypeResolveContext context) |
|
|
|
|
{ |
|
|
|
|
return new ReducedExtensionMethod ((IMethod)baseMethod.ToMemberReference ().Resolve (context)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ITypeReference DeclaringTypeReference { |
|
|
|
|
get { |
|
|
|
|
return baseMethod.ToMemberReference ().DeclaringTypeReference; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IMemberReference ToMemberReference() |
|
|
|
|
{ |
|
|
|
|
return baseMethod.ToMemberReference (); |
|
|
|
|
return new ReducedExtensionMethodMemberReference (baseMethod); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IMember MemberDefinition { |
|
|
|
@ -129,7 +167,7 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -129,7 +167,7 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
|
|
|
|
|
public bool IsExtensionMethod { |
|
|
|
|
get { |
|
|
|
|
return baseMethod.IsExtensionMethod; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -181,6 +219,10 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -181,6 +219,10 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IMethod ReducedFrom { |
|
|
|
|
get { return baseMethod; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IParameterizedMember implementation
|