3

I am trying to compile some code which has incorrect syntax using the Roslyn Emit Api. The thread compiling the code has Culture set to "fr-Fr" but the diagnostic messages I obtain from the Roslyn api are in English. e.g.

error BC30037: Character is not valid.

I am wondering if there is a way to get the error messages in the thread specific culture. Same happens with codeDom too.

Anoop
  • 101
  • 1
  • 10
  • Could you provide a tiny example of the code you're using? Given the error number, it sounds like you're using the VB compiler rather than C#. (More importantly, if we have an example we can experiment with, we can be more confident if we think we have a solution.) – Jon Skeet Apr 03 '18 at 06:18

1 Answers1

1

This is probably not a viable answer, but I'll post it anyway in case it's of interest.

The Roslyn compiler is open source, so it can be modified, and in this way the error messages can be changed from English to French, or whatever. Just be aware that Roslyn is a huge program, and rebuilding it is not all that easy, at least in my experience.

I've written a few blog articles about my experiences with modifying Roslyn. My latest modification included adding a new error message - that's how I happened to find this question.

https://renniestechblog.com/information/33-modifying-roslyn-step-1-initial-test

https://renniestechblog.com/information/39-modifying-roslyn-step-6-fake-attribute-yacksserialization

It may even be possible to make Roslyn multilingual, by adding an additional CSharpResources.fr-FR.resx file to the project, and letting ResourceManager automatically choose the correct .resx file. This definitely works with .Net Framework WinForms projects, but I don't know if this functionality has been preserved in the new .Net Standard format.

RenniePet
  • 11,420
  • 7
  • 80
  • 106