Localization test failures 1#24407
Conversation
| > | ||
| ", result.Output); | ||
| "; | ||
| expected = expected.Replace((char)0x2013, (char)0x002d); // EN DASH -> HYPHEN-MINUS |
There was a problem hiding this comment.
csi.exe outputs the en dash in Microsoft (R) Visual C# - interaktive Compilerversion 42.42.42.42424 as hyphen-minus. There might be a more reliable way to fix this.
There was a problem hiding this comment.
💭 Seems weird to have an en dash in a resource string.
There was a problem hiding this comment.
@MaStr11 Please add a more detailed comment explaining why the replacement is necessary. Something like:
The German translation (and possibly others) contains an en dash (0x2013), but csi.exe outputs it as a hyphen-minus (0x002d). We need to fix up the expected string before we can compare it to the actual output.
…g for VB but I corrected the corresponding test in C#. Changes in C# are partially reverted (test is sipped again) and VB is fixed.
| > | ||
| ", result.Output); | ||
| "; | ||
| expected = expected.Replace((char)0x2013, (char)0x002d); // EN DASH -> HYPHEN-MINUS |
There was a problem hiding this comment.
💭 Seems weird to have an en dash in a resource string.
| Microsoft (R) Visual C# Interactive Compiler version {s_compilerVersion} | ||
| Copyright (C) Microsoft Corporation. All rights reserved. | ||
| var expected = $@" | ||
| { string.Format(CSharpScriptingResources.LogoLine1, s_compilerVersion) } |
There was a problem hiding this comment.
💡 No spaces inside the braces for interpolated strings.
There was a problem hiding this comment.
@MaStr11 I should be able to clean this up in the future for all of this repository using automated tools. This feedback is more for future work.
|
@MaStr11 Can you update the original comment to replace the TODO text with the current status? |
I gave it a try and I can confirm that it indeed works as intended. Ironically it didn't help in this particular case because the test did a |
|
Requesting reviews from @dotnet/roslyn-compiler and @dotnet/roslyn-interactive |
| var logoOutput = $@"{ string.Format(CSharpScriptingResources.LogoLine1, s_compilerVersion) } | ||
| { CSharpScriptingResources.LogoLine2} | ||
|
|
||
| { ScriptingResources.HelpPrompt}"; |
There was a problem hiding this comment.
Could you extract to a static field (similar to s_compilerVersion) and then use the field in all test cases?
|
Sure I could. But there are cases where you want your tests to run in a particular culture using the [UseCulture] attribute. So there is a benefit in keeping the tests self contained. |
| VBScriptingResources.LogoLine2 + " | ||
|
|
||
| Type ""#help"" for more information. | ||
| " + ScriptingResources.HelpPrompt + " |
|
🕐 |
|
There are perhaps a few of such tests that use a different culture. They would not use this field then. Majority tests do not care about the "logo" lines and it would make them more readable. Also authoring a new test would be easier. |
|
💭 I tend to prefer self-contained tests, and don't see the issue with having the string inlined in multiple tests. However, /src/Scripting/ is not one of the paths where I'm in the code owner group so we tend to defer to the preference of the code owner in these cases. |
|
@sharwell The tests are already not self-contained anyways -- they use |
|
@tmat I'm currently changing the tests. I also facing a problem with the tests that change the Culture during the test (It seems the culture is persisted. So half of the tests run in de-DE while the other run in en-GB). I will need some more time to fix this. |
…that swallowed the assert before.
…ulture2 that swallowed the assert before." This reverts commit f3270f6.
…o restore the culture at the end of the test.
|
I'm done with the changes now (Sorry for the messy commit history). |
|
|
||
| " + ScriptingResources.HelpPrompt | ||
| Dim runner = CreateRunner(args:={}, input:="Imports System.Globalization | ||
| ' Save the current thread culture as it is changed in the test. |
There was a problem hiding this comment.
❓ The UseCulture attribute should restore the culture at the end of the test. Is it possible to use it here?
There was a problem hiding this comment.
There are two differences.
- UseCulture sets Current thread.Culture while this test sets CultureInfo.DefaultThreadCulture.
- UseCulture also sets the culture at the beginning of the test
I think it is better the way it is but haven't tried UseCulture.
…e1 to use three different cultures. Test shows unexpected results.
…UICulture1 to use three different cultures. Test shows unexpected results." This reverts commit 8e05074.
@sharwell I gave it a try in commit 8e05074. I changed UseCultureAttribute to also set @tmat I found two problems with vbi.exe during my tests:
|
| <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.Scripting.Destkop.UnitTests" /> | ||
| <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests" /> | ||
| <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests" /> | ||
| <InternalsVisibleToTest Include="Roslyn.InteractiveHost.UnitTests" /> |
There was a problem hiding this comment.
👍 This one should be covered under the umbrella of the review from @jaredpar.
|
@sharwell This PR was merged without getting required sign-offs from the compiler team and it doesn't deal with localization issues in the manner that other compiler tests do. I think it should be reverted and different fixes should be made. |
|
@AlekseyTs This pull request did not touch compiler code. |
|
This PR made changes to CSharpCodeAnalysis.csproj, it also touched Scripting and Csi tests, even though they are not under Compilers folder, they used to be owned by Compiler team at some point. @jaredpar To clarify the current ownership for the tests. |
Fix for #23837.
This is the first of a series of PRs meant to resolve the unit test failures caused by missing localizations.
This PR includes test related to csi.exe and interactive scripting:
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests
Done. Tested local (de-DE) and CI (en-US).
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests
Done. Tested local (de-DE) and CI (en-US).
Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests
Done. Tested local (de-DE) and CI (en-US).
Roslyn.InteractiveHost.UnitTests
Done. Tested local (de-DE) and CI (en-US).