Closed 0Lucifer0 closed 5 years ago
This won't be possible with the string.Format
analyzer since it requires a constant value (i.e. a string
) to inspect the format pattern.
It is obviously out of the scope of this project but what you could do yourself is write an analyzer that reads a projects AdditionalFiles
, finds your translation file and then parses the XML inside of it. You can then do something like a simple string.Contains("{0}")
check and report an error if it finds one. Alternatively you could write a github hook that does a similar same thing and reports that the PR can't be merged.
Thank you for this answer :) It is exactly what i though. Was also thinking about doing a specific tools for those. The github hook is actually a really good idea!
Hi,
People who are doing the translation in resx files on my project are not developers and sometime it happen they put an argument like {0} in the text. Which make a runtime exception on my app. Is there anyway to prevent this to tell the developer to update the code to match the text ? or would it be too difficult to add on string.Format analyzer ?
i wonder if diagnostic is able to check string in a ressources files.
example of my code: