DelegateDecompiler icon indicating copy to clipboard operation
DelegateDecompiler copied to clipboard

Switch case and if-elseif conditional not supported

Open okomeiht opened this issue 9 years ago • 7 comments

Hi Alexander, I am working on a project where we use the Computed attribute on an enum. The enum depends on some condition that is in a switch case. Unfortunatelly the switch case is not supported and the default value is always returned when I apply the Decompile Method. We try to use If - elseif instead of the switch case but it does not work neither.

okomeiht avatar Feb 08 '16 16:02 okomeiht

@okomeiht thanks for reporting the issue. Can you please show some code?

hazzik avatar Feb 09 '16 13:02 hazzik

@okomeiht, ok, I understood what you mean. I will try to fix it, when I will have some time.

hazzik avatar Feb 09 '16 14:02 hazzik

Ok thanks. Great job on the library.

okomeiht avatar Feb 10 '16 10:02 okomeiht

I am encountering the same problem.

Thanks for looking into this^^

LandryDubus avatar Jul 08 '16 08:07 LandryDubus

Any fix or workaround for this as of now?

nawfalhasan avatar Dec 18 '17 10:12 nawfalhasan

AFAIK the ?: ternary operator is implemented, maybe you can give it a try. Eg.

[Computed]
public SomeEnum Prop
  get {
    return condition1
      ? SomeEnum.One
      : condition2
      ? SomeEnum.Two
      : condition3
      ...
      : SomeEnum.Hundred;
  }
}

gvas avatar Dec 18 '17 11:12 gvas

@gvas Thanks, yes that works. Even normal switch case worked for me when I tried. Didnt try with if-else yet. This library is awesome!

nawfalhasan avatar Dec 18 '17 13:12 nawfalhasan