简体   繁体   中英

CA1304 on Boilerplate

We have a reasonably large project written in .NET Core 2.2, updated to Abp 4.10.1, that we started through Abp's template.

Recently I added Roslyn analyzers to the project, and now we have hundreds of warnings, on every instance of the L method .

Example:

case AbpLoginResultType.InvalidPassword:
    return new UserFriendlyException(L("LoginFailed"), L("InvalidUserNameOrPassword"));

Gives us:

Warning CA1304 The behavior of 'AbpServiceBase.L(string)' could vary based on the current user's locale settings. Replace this call in 'AbpLoginResultTypeHelper.CreateExceptionForFailedLoginAttempt(AbpLoginResultType, string, string)' with a call to 'AbpServiceBase.L(string, CultureInfo)'.

As I understand from the documentation, the L method is meant to simplify localization calls and already considers culture , but adding CultureInfo information to every call in order to satisfy the Roslyn analyzers would defeat its purpose.

I wouldn't like to suppress this warning at a project level, and the other options we considered seem very time consuming.

So, would there be an effective way to deal with this?

The documentation shows the reasons and motivations behind this rule.

It's up to you to decide it this is important to you or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM