awesome-inc / FontAwesome.Sharp

A library for using Font Awesome in WPF & Windows Forms applications
Apache License 2.0
384 stars 89 forks source link

ToChar().Single Issue #32

Closed garno-fc closed 4 years ago

garno-fc commented 4 years ago

I'm using markdown icons with your guys' library- first of all, great job! It's great to have something like this that supports WinForms.

I'm running into an issue where getting a bitmap of the icon is throwing a 'Sequence contains multiple elements' exception. Since your project is open source, I looked into the method and troubleshooted (troubleshot? idk..) the issue down to the ToChar() method. It uses the .Single() instead of the .First() linq command (which is arguably more correct).

I'd love your guys' input! Thanks! Greg

mkoertgen commented 4 years ago

Hi @garno-fc, thanks for reaching out.

Did you narrow it down to this line?

Yes, technically there could be returned a string with multiple chars, cf.:

So, using First() instead of Single() would be the right way to go.

Since we have a unit test checking all possible fontawesome icons

let me ask out of curiosity which utf8-codes did you use?

Would you mind adding/changing tests & preparing a PR?

garno-fc commented 4 years ago

Hello- Yes, I narrowed it down to that line (because I was able to write that line in my code outside of fontawesome.sharp). I temporarily solved my problem by not drawing those icons in my icon chooser dialog.

I'm not sure which utf8-code I used, but I'm using basically your guys' MaterialDesignIcons test example and trying to display any of the icons in the screenshot.

image

I looked up the one selected and it has a hex code in the enum file as 0xF0127, so 983335?? I'm really not sure how all of that works.

As far as adding/changing tests and preparing a pull request- I currently don't actually have FontAwesome.Sharp building/working on my machine (for whatever reason- I tried extensively yesterday). Additionally, I'm assuming you don't have unit tests working for third party icon fonts- so I don't know what I'd be able to contribute there.

mkoertgen commented 4 years ago

Ok, no problem. It makes sense that this occurs with MaterialDesign (much more icons). I will apply the change this evening. Meanwhile fontawesome update 5.12.1 is available so good timing to publish an update.

mkoertgen commented 4 years ago

After upgrading lately i noticed this bug coming back. Actually we need to cope with more than 1 character.