Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion ICSharpCode.Decompiler.Tests/TestCases/Pretty/EnumTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// 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
Expand Down Expand Up @@ -28,6 +28,12 @@ public enum SimpleEnum
Item2
}

public enum NoZero
{
Item1 = 1,
Item2
}

public enum OutOfOrderMembers
{
Item1 = 1,
Expand Down Expand Up @@ -135,5 +141,18 @@ public object PreservingTypeWhenBoxedTwoEnum()
{
return AttributeTargets.Class | AttributeTargets.Delegate;
}

public void EnumInNotZeroCheck(SimpleEnum value, NoZero value2)
{
if (value != SimpleEnum.Item1)
{
Console.WriteLine();
}

if (value2 != (NoZero)0)
{
Console.WriteLine();
}
}
}
}
7 changes: 3 additions & 4 deletions ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2014 Daniel Grunwald
// 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
Expand Down Expand Up @@ -733,9 +733,8 @@ public TranslatedExpression ConvertToBoolean(ExpressionBuilder expressionBuilder
}
else
{
var zero = new PrimitiveExpression(0)
.WithoutILInstruction()
.WithRR(new ConstantResolveResult(expressionBuilder.compilation.FindType(KnownTypeCode.Int32), 0));
var zero = expressionBuilder
.ConvertConstantValue(new ConstantResolveResult(Type, 0), allowImplicitConversion: true);
var op = negate ? BinaryOperatorType.Equality : BinaryOperatorType.InEquality;
return new BinaryOperatorExpression(Expression, op, zero.Expression)
.WithoutILInstruction()
Expand Down
Loading