waf / CSharpRepl

A command line C# REPL with syntax highlighting – explore the language, libraries and nuget packages interactively.
https://fuqua.io/CSharpRepl/
Mozilla Public License 2.0
2.95k stars 112 forks source link

Syntax & execution CSharpRepl exceptions shouldn't be translated #312

Closed marcinsmialek closed 1 year ago

marcinsmialek commented 1 year ago

Version

0.6.5

What happened?

Exceptions from CSharpRepl are translated, and they shouldn't be. This happens when you try running code, which wouldn't be compiled, for example missing semicolon, no such variable.

Exceptions from the code itself aren't translated, which is expected.

Example:

> System.Threading.Thread.CurrentThread.CurrentCulture
pl-PL
> System.Threading.Thread.CurrentThread.CurrentUICulture
en-US
> throw new Exception();
┌────────────────────Exception─────────────────────┐
│ Exception of type 'System.Exception' was thrown. │
└──────────────────────────────────────────────────┘

> AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName
".NETCoreApp,Version=v7.0"
> show translation issue
┌───────────────────Exception───────────────────┐
│ (1,18): error CS1002: Oczekiwano średnika (;) │
└───────────────────────────────────────────────┘

When I have the same code in a .cs file, and try compiling it either with Visual Studio 2022, or via dotnet build / dotnet run, I'm getting this message in English:

C:\Dev\TestApp\TestApp\Program.cs(7,38): error CS1002: ; expected [C:\Dev\TestApp\TestApp\TestApp.csproj]

The proper native .cs code, when run, shows the same culture values - pl-PL / en-US.

Running Windows 11, English United States with Polish language pack added. Windows Display Language is set to English. Preferred languages are English (United States), Polish. Country or region: United States Regional format: Polish (Poland) Even the keyboard language was set to English (United States), with Polish Programmer's layout

.cs files tested with both .NET 7.0.12 / 7.0.402 and 8.0.0-rc.1.23419.4 / 8.0.100-rc.1.23455.8

I haven't tested CSharpRepl with #241 / #296 fix.

waf commented 1 year ago

Thanks for well-put-together bug report. This should be fixed in #324 and will be available in the next release.