Browse Source

Fix #3089: Add comment regarding .constraint prefix expressed as cast in C#

pull/3307/head
Siegfried Pammer 7 months ago
parent
commit
c6e3752977
  1. 4
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.cs
  2. 4
      ICSharpCode.Decompiler/CSharp/CallBuilder.cs

4
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstructorInitializers.cs

@ -60,7 +60,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -60,7 +60,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public class MethodCallInCtorInit
{
public MethodCallInCtorInit(ConsoleKey key)
#if MCS5
: this(((int)key/*cast due to .constrained prefix*/).ToString())
#else
: this(((int)key).ToString())
#endif
{
}

4
ICSharpCode.Decompiler/CSharp/CallBuilder.cs

@ -507,6 +507,10 @@ namespace ICSharpCode.Decompiler.CSharp @@ -507,6 +507,10 @@ namespace ICSharpCode.Decompiler.CSharp
targetExpr = new MemberReferenceExpression(castExpression, methodName);
typeArgumentList = ((MemberReferenceExpression)targetExpr).TypeArguments;
}
if (constrainedTo != null && targetExpr is MemberReferenceExpression { Target: CastExpression cast })
{
cast.AddChild(new Comment("cast due to .constrained prefix", CommentType.MultiLine), Roles.Comment);
}
}
else
{

Loading…
Cancel
Save