-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
NoWarn property is not set correct when using Turkish OS Language #7154
Comments
What a great bug report! Thanks for the detail I thought it might be a Roslyn bug but it is in fact in MSBuild. This code that decides if we should quote a part of a string is going wrong: msbuild/src/Utilities/CommandLineBuilder.cs Lines 194 to 204 in 386a830
I suspect the Turkish This is exactly the situation described in this Regex doc about using invariant culture comparison and I suspect that's the fix here. |
@rainersigwald I think you are right about |
Noticed this because we've been doing thinking about case insensitivity in regex recently. I think this is the only instance of the bug in MSBuild, but a perf note: the regex engine had/has some inefficiencies when using RegexOptions.IgnoreCase. In older versions, it makes no attempt to determine apriori that casing is irrelevant to the pattern. So even if my pattern is In MSBuild I'm guessing the hottest regexes are the warning/error matchers -- which could probably be RegexOptions.InvariantCulture, since the text that matches In .NET 7 we expect all this to be taken care of automatically, and will also change to change to consistently use the culture at construction time (if ignore case is applied) -- this is tracked by dotnet/runtime#61048. BTW, if and when MSBuild builds against net7.0, you will likely want to switch over to the regex source generator for patterns that are statically constructed instead of compiling them at runtime. |
I'm not sure if it's the same issue or not, but I ran
|
I think that's the same bug. BTW, our shipping product is containing strings like this ( |
I seem to get a passed build if I use a bootstrap build of current main but not if I use the msbuild from VS 17.0.5; not sure what the difference is. |
Fixes #7154. The CSC compiler does not unquote disabled warnings eg `/nowarn:1701,1702,1705,NETSDK1138,CS8969,"IDE0161",NU5105,RS0041,CA1416,1701,1702` will not disable `IDE0161`. MSBuild has logic to quote strings that it believes must be quoted to be passed on a command line. It has a bug causing it to do this over eagerly in the tr-TR culture, which exposes this compiler limitation. To fix this Regex should use RegexOptions.CultureInvariant unless they are specifically intended to have culture specific behavior. In this case the purpose is simply to determine whether a string needs to be quoted on a command line. An example is "SYSLIB0003". The `I` does not match `[a-z]` case insensitively in tr-TR culture because lower casing `I` does not produce `i` in this culture, it produces `ı`, which does not match the pattern. Assuming that it is safe to pass `I` on a command line in an OS set to Turkish culture -- I assume this is the case, but if it isn't, quoting will not help -- we can change the pattern to match in a culture invariant way. This causes the regex engine to operate more-or-less with en-US casing rules, so `I` and `i` are allowed. (Turkish `ı` or `İ` will still be quoted, see below.) Added the option to the regex. Also added it to the other related one, even though it has no relevant parts in the pattern, for consistency. I did not add it to the place where MSBuild looks for "error" or "warning" -- it probably should be there, but as they don't include "i", it doesn't matter and can be changed separately. Note: this does not address the issue that a quoted warning is not unquoted by the compiler. The code will still add quotes if eg., the string has a space in, and most likely this will then fail to be unquoted by the compiler. If htis is an issue then we should have a separate issue for it against the compiler. This change makes things strictly better and solves the reported issue.
Issue Description
When building the project Mvc.Api.Analyzers.Test.csproj that contains a
NoWarn
property configured to<NoWarn>$(NoWarn);IDE0161</NoWarn>
on a Windows machine (Turkish language) fails with the following error.aspnetcore\src\Mvc\Mvc.Api.Analyzers\test\TestFiles\ActualApiResponseMetadataFactoryTest\GetDefaultStatusCodeTest.cs(8,1): error IDE0161: Dosya kapsamlı namespace öğesine dönüştür [aspnetcore\src\Mvc\Mvc.Api.Analyzers\test\Mvc.Api.Analyzers.Test.csproj]
Steps to Reproduce
cd Repros/AspNetCore
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
, TypeY
.\restore.cmd
, then change into thesrc/Mvc/Mvc.Api.Analyzers/test
directory and rundotnet build
Expected Behavior
Actual Behavior
Versions & Configurations
OS: Win10 x64 20H2 TRK
Attach a binlog
BinLogs.zip
The text was updated successfully, but these errors were encountered: