Browse Source

Apply changes as requested per code review.

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

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

@ -41,21 +41,22 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -41,21 +41,22 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
if (!(obj is LocalFunctionMethod other))
return false;
return baseMethod.Equals(other.baseMethod, typeNormalization);
return baseMethod.Equals(other.baseMethod, typeNormalization)
&& NumberOfCompilerGeneratedParameters == other.NumberOfCompilerGeneratedParameters;
}
public override bool Equals(object obj)
{
var other = obj as LocalFunctionMethod;
if (other == null)
if (!(obj is LocalFunctionMethod other))
return false;
return baseMethod.Equals(other.baseMethod);
return baseMethod.Equals(other.baseMethod)
&& NumberOfCompilerGeneratedParameters == other.NumberOfCompilerGeneratedParameters;
}
public override int GetHashCode()
{
unchecked {
return baseMethod.GetHashCode() + 1;
return baseMethod.GetHashCode() + NumberOfCompilerGeneratedParameters + 1;
}
}
@ -66,13 +67,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -66,13 +67,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
internal int NumberOfCompilerGeneratedParameters { get; }
public IMember MemberDefinition {
get {
if (baseMethod.MemberDefinition == baseMethod)
return this;
return new LocalFunctionMethod((IMethod)baseMethod.MemberDefinition, NumberOfCompilerGeneratedParameters);
}
}
public IMember MemberDefinition => this;
public IType ReturnType => baseMethod.ReturnType;
IEnumerable<IMember> IMember.ExplicitlyImplementedInterfaceMembers => baseMethod.ExplicitlyImplementedInterfaceMembers;
@ -122,6 +117,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -122,6 +117,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
IEnumerable<IAttribute> IEntity.GetAttributes() => baseMethod.GetAttributes();
IEnumerable<IAttribute> IMethod.GetReturnTypeAttributes() => baseMethod.GetReturnTypeAttributes();
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 IsAbstract => baseMethod.IsAbstract;
public bool IsSealed => baseMethod.IsSealed;

4
ICSharpCode.Decompiler/TypeSystem/VarArgInstanceMethod.cs

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

Loading…
Cancel
Save