Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch case and if-elseif conditional not supported #77

Open
okomeiht opened this issue Feb 8, 2016 · 7 comments
Open

Switch case and if-elseif conditional not supported #77

okomeiht opened this issue Feb 8, 2016 · 7 comments

Comments

@okomeiht
Copy link

okomeiht commented Feb 8, 2016

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.

@hazzik
Copy link
Owner

hazzik commented Feb 9, 2016

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

@hazzik
Copy link
Owner

hazzik commented Feb 9, 2016

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

@okomeiht
Copy link
Author

Ok thanks. Great job on the library.

@LandryDubus
Copy link

I am encountering the same problem.

Thanks for looking into this^^

@nawfalhasan
Copy link

Any fix or workaround for this as of now?

@gvas
Copy link
Contributor

gvas commented Dec 18, 2017

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;
  }
}

@nawfalhasan
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants