Skip to content

Add analyzer and code fix for floating point string formatting#9

Merged
NightOwl888 merged 5 commits intoapache:mainfrom
ksanjeev284:main
Oct 5, 2025
Merged

Add analyzer and code fix for floating point string formatting#9
NightOwl888 merged 5 commits intoapache:mainfrom
ksanjeev284:main

Conversation

@ksanjeev284
Copy link
Copy Markdown
Contributor

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.

ksanjeev284 and others added 2 commits October 5, 2025 03:48
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.
@NightOwl888 NightOwl888 self-requested a review October 5, 2025 11:53
Copy link
Copy Markdown
Contributor

@NightOwl888 NightOwl888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LuceneDev1006 until 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.

@NightOwl888 NightOwl888 added the notes:new-feature A new feature label Oct 5, 2025
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.
@NightOwl888 NightOwl888 added the hacktoberfest-accepted Use this label to approve a pull request for Hacktoberfest. label Oct 5, 2025
@NightOwl888 NightOwl888 merged commit ba3ba01 into apache:main Oct 5, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Use this label to approve a pull request for Hacktoberfest. notes:new-feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants