postsharp / Metalama

Metalama is a Roslyn-based meta-programming framework. Use this repo to report bugs or ask questions.
181 stars 6 forks source link

Trim('"') does not build in OverrideMethod #383

Closed ekmedinet closed 1 week ago

ekmedinet commented 1 week ago

Hello,

We are trying to strip double quotes from method return value, but getting metalama build error. Sometimes it shows

image

And sometimes just reports some error:

image

Using just Trim() works fine, be we need to strip double quotes. We have resorted to using Starts/EndsWith and Substring, but the code is clunky, also curious how come Trim(char) is not supported?

Thanks!

Tested with the latest version 2024.2.30

svick commented 1 week ago

Thanks for the report. Metalama has a bug when processing character literals (like '"'). You can work around it by expressing the same code differently: return returnString.Trim((char)0x22);

I will work on a proper fix and will notify you here when it's released, which should be soon.

ekmedinet commented 1 week ago

Thank you for the response and workaround!