Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BuildMetadataBin.cmd fails if the display language is not English #315

Closed
krzysdz opened this issue Mar 8, 2021 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@krzysdz
Copy link

krzysdz commented Mar 8, 2021

When looking for errors, if the Id is "CS0246" the diagnostic message is checked using a regular expression:

// Symbol not found. See if it's in the type import list
if (diag.Id == "CS0246")
{
var symbolNameRegx = new System.Text.RegularExpressions.Regex(@"The type or namespace name '(\w+)'");
var match = symbolNameRegx.Match(diag.GetMessage());
if (match.Success)
{
var symbolName = match.Groups[1].Value;
if (this.typeImports.ContainsKey(symbolName) || typeImports.ContainsKey($"{symbolName}(interface)"))
{
continue;
}
}
}

The GetMessage function returns a localised message, so there is no match if language other than English is used and the command fails with multiple errors.

.\BuildMetadataBin.cmd output with many CS0246 errors "Nie można znaleźć nazwy typu lub przestrzeni nazw..."

Hopefully, this problem should be easy to fix, because an IFormatProvider can be passed as an argument to use the appropriate language - see https://github.com/krzysdz/win32metadata/commit/5b142922ebe17c8e6587a33471b2e1892308789b:

                    var symbolNameRegx = new System.Text.RegularExpressions.Regex(@"The type or namespace name '(\w+)'");
                    var culture = new System.Globalization.CultureInfo("en-US");
                    var match = symbolNameRegx.Match(diag.GetMessage(culture));
@mikebattista mikebattista added the bug Something isn't working label Mar 9, 2021
@sotteson1
Copy link
Contributor

Thanks @krzysdz for the advice on the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants