Move to resource - ArgumentNullException
Hi,
Move to resources shows an action and a warning that "throw new ArgumentNullException("myProperty")" can be localized.
I assume this doesn't make any sense for this case since the method property is never localized.
In general I would be happy if there is an option where I can define that System Exceptions (Namspace System) are excluded from the validation since we never translate them in our case .
Also Log4net is something we never translate. So it would be helpfull if there is a mecanisme like Annotations (base on attributes or xml) can define rules to exlude things from localization.
I know that a method itself can be excluded from the validation but if I add a new string I would not be warned , would I?
Regards
Martyn
Please sign in to leave a comment.
We will use our external annotations with the LocalizableAttribute for this cases.
R# will provide annotations for .NET Framework assemblies, but you could provide annotations for other assemblies.
Any chance to get an example for the external annotation.. I'm not so familiar with the xml. Especialy I would like to know how to declare correctly the LocaizationAttribute(false).
Is this example correct?
BTW: Is this file also located in the user settings somewhere since it is not that easy to extend it in Vista.
1. Please download last nightly build and looking for file mscorlib.I18n.xml at the folder %ProgrammFiles%\JetBrains\ReSharper\v5.0\Bin\ExternalAnnotations\mscorlib
2. You should use JetBrains.Annotations.LocalizableAttribute instead of System.ComponentModel.LocalizableAttribute in the external annotations.
This annotation from mscorlib.18n.xml for the System.ArgumentException
I assume there is no way to have a Annotation to exlude this construct?
The next expression is value for the parameter message, and IMHO it will be translated.
string.Format("Profile {0} not found", profileName)I just found another issue.
Resharper also shows issues for strings like "{0} \ -1" or "^" or " ". But there is no reason to localize a string like this.
I would suggest a new option for the localization feature.
The developer could specify an regular expression to define text which shouldn't be localized.
Default: "[^A-za-z]"
Remove all matches from the string and if there is any char left, then the string must be localized
or a regex for strings which should be localized. If the regex matches, then the string should be localized. But i think this is not so usefull.
Default would then be: "[A-za-z]"
also a new option in the alt+enter would make sense: (I assume this takes longer to actualize)
add string to "localize ignore list".
Just some ideas.
Regards
Martyn