Add analyzer and code fix for floating point string formatting#9
Add analyzer and code fix for floating point string formatting#9NightOwl888 merged 5 commits intoapache:mainfrom
Conversation
Introduces LuceneDev1006 analyzer to detect floating point values embedded in strings via concatenation or interpolation, and updates the code fix provider to suggest using J2N.Numerics Single/Double.ToString methods. Adds supporting resources, descriptors, utility methods, sample usage, and comprehensive tests for both analyzer and code fix behaviors.
…ed the sample not to compile.
NightOwl888
left a comment
There was a problem hiding this comment.
Thanks for the PR.
Overall, the changes look really good. There is just one issue I found, more details inline.
NOTE: In hindsight, we will probably not be able to make use of this code fix, as-is. But that is not a problem with the implementation, it is a problem with the requirements we provided. The solution should be to create our own interpolation handler to do the formatting rather than insert the
J2N.Numerics.*.ToString()method calls. Adding these extra method calls will cause additional temporary allocations which will harm performance.So, we should probably disable
LuceneDev1006until we have our own J2N interpolation handler in place. At least now we have a simple way to detect these issues to fix them, though.
Ensures that the alignment clause is retained when replacing interpolation expressions in LuceneDev1001_FloatingPointFormattingCSCodeFixProvider. Also fixes string formatting in LuceneDev1006Sample to use correct quotes and spacing.
Introduces LuceneDev1006 analyzer to detect floating point values embedded in strings via concatenation or interpolation, and updates the code fix provider to suggest using J2N.Numerics Single/Double.ToString methods. Adds supporting resources, descriptors, utility methods, sample usage, and comprehensive tests for both analyzer and code fix behaviors.