Browse Source

Apply changes as requested per code review.

pull/1586/head
Siegfried Pammer 7 years ago
parent
commit
6234ff7c9a
  1. 4
      ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs
  2. 23
      ICSharpCode.Decompiler/TypeSystem/Implementation/LocalFunctionMethod.cs
  3. 4
      ICSharpCode.Decompiler/TypeSystem/VarArgInstanceMethod.cs

4
ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs

@ -104,10 +104,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// </summary> /// </summary>
NullabilityAnnotations = 0x400, NullabilityAnnotations = 0x400,
/// <summary> /// <summary>
/// If this option is active,
/// </summary>
LocalFunctions = 0x800,
/// <summary>
/// Default settings: typical options for the decompiler, with all C# languages features enabled. /// Default settings: typical options for the decompiler, with all C# languages features enabled.
/// </summary> /// </summary>
Default = Dynamic | Tuple | ExtensionMethods | DecimalConstants | ReadOnlyStructsAndParameters Default = Dynamic | Tuple | ExtensionMethods | DecimalConstants | ReadOnlyStructsAndParameters

23
ICSharpCode.Decompiler/TypeSystem/Implementation/LocalFunctionMethod.cs

@ -41,21 +41,22 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{ {
if (!(obj is LocalFunctionMethod other)) if (!(obj is LocalFunctionMethod other))
return false; return false;
return baseMethod.Equals(other.baseMethod, typeNormalization); return baseMethod.Equals(other.baseMethod, typeNormalization)
&& NumberOfCompilerGeneratedParameters == other.NumberOfCompilerGeneratedParameters;
} }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
var other = obj as LocalFunctionMethod; if (!(obj is LocalFunctionMethod other))
if (other == null)
return false; return false;
return baseMethod.Equals(other.baseMethod); return baseMethod.Equals(other.baseMethod)
&& NumberOfCompilerGeneratedParameters == other.NumberOfCompilerGeneratedParameters;
} }
public override int GetHashCode() public override int GetHashCode()
{ {
unchecked { unchecked {
return baseMethod.GetHashCode() + 1; return baseMethod.GetHashCode() + NumberOfCompilerGeneratedParameters + 1;
} }
} }
@ -66,13 +67,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
internal int NumberOfCompilerGeneratedParameters { get; } internal int NumberOfCompilerGeneratedParameters { get; }
public IMember MemberDefinition { public IMember MemberDefinition => this;
get {
if (baseMethod.MemberDefinition == baseMethod)
return this;
return new LocalFunctionMethod((IMethod)baseMethod.MemberDefinition, NumberOfCompilerGeneratedParameters);
}
}
public IType ReturnType => baseMethod.ReturnType; public IType ReturnType => baseMethod.ReturnType;
IEnumerable<IMember> IMember.ExplicitlyImplementedInterfaceMembers => baseMethod.ExplicitlyImplementedInterfaceMembers; IEnumerable<IMember> IMember.ExplicitlyImplementedInterfaceMembers => baseMethod.ExplicitlyImplementedInterfaceMembers;
@ -122,6 +117,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
IEnumerable<IAttribute> IEntity.GetAttributes() => baseMethod.GetAttributes(); IEnumerable<IAttribute> IEntity.GetAttributes() => baseMethod.GetAttributes();
IEnumerable<IAttribute> IMethod.GetReturnTypeAttributes() => baseMethod.GetReturnTypeAttributes(); IEnumerable<IAttribute> IMethod.GetReturnTypeAttributes() => baseMethod.GetReturnTypeAttributes();
bool IMethod.ReturnTypeIsRefReadOnly => baseMethod.ReturnTypeIsRefReadOnly; bool IMethod.ReturnTypeIsRefReadOnly => baseMethod.ReturnTypeIsRefReadOnly;
/// <summary>
/// We consider local functions as always static, because they do not have a "this parameter".
/// Even local functions in instance methods capture this.
/// </summary>
public bool IsStatic => true; public bool IsStatic => true;
public bool IsAbstract => baseMethod.IsAbstract; public bool IsAbstract => baseMethod.IsAbstract;
public bool IsSealed => baseMethod.IsSealed; public bool IsSealed => baseMethod.IsSealed;

4
ICSharpCode.Decompiler/TypeSystem/VarArgInstanceMethod.cs

@ -129,7 +129,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
get { return baseMethod.IsExtensionMethod; } get { return baseMethod.IsExtensionMethod; }
} }
bool IMethod.IsLocalFunction => false; bool IMethod.IsLocalFunction {
get { return baseMethod.IsLocalFunction; }
}
public bool IsConstructor { public bool IsConstructor {
get { return baseMethod.IsConstructor; } get { return baseMethod.IsConstructor; }

Loading…
Cancel
Save