Skip to content

Conversation

@paulirwin
Copy link
Contributor

@paulirwin paulirwin commented Mar 8, 2025

NOTE: This requires #1 to be merged first, as it is a stacked PR on top of that one, so it shows all changes from that PR as well. I will rebase it against main once #1 is merged.

This adds a diagnostic and code fix for detecting public types in the Lucene.Net.Support namespace.

Partial apache/lucenenet#1100 (Will still need to add these analyzers to Lucene.NET in order to close that issue)

@paulirwin paulirwin marked this pull request as ready for review September 28, 2025 03:49
Copy link
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. This looks pretty good.

However, we are still figuring things out, so I left some comments on some of these issues. Do note that some of them are not directly related to this PR, so they could be made into new issues.

I noticed that we are getting build warnings for the AnalyzerReleases.Shippped.md file containing invalid version numbers. Apparently, the tool doesn't support pre-release numbers.

https://chatgpt.com/share/68d915a1-9d28-8005-8ee4-b0934776fdaf

So, for sure we need to change the Git commit hook to only put the major and minor components of the version into the file. We may also consder moving these back into "Unshipped" state until the official 1.0 release. It sounds like we should only be updating that doc when the production version number changes or alternatively, migrate all new rules into the 1.0 release as each pre-release is shipped and create a new section only for the next production release.

Whatever direction we go, we will need to update the make-release.md document with the new info.

Copy link
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.

Let's also fix the Git commit hook so it only uses the major and minor version to match the expectations of the AnalyzerReleases spec. It is located at:

version=$(nbgv get-version -v NuGetPackageVersion)

The nbgv command to use to get the major and minor version and ignore the rest is:

nbgv get-version -v MajorMinorVersion

Also, we should update the make-release.md file to reflect that change in the example.

@NightOwl888
Copy link
Contributor

I gave it a try to see if it works in Lucene.NET using the latest build from CI. It didn't update automatically until I restarted Visual Studio to reload the cache. Most likely because we didn't bump to 1.1 yet.

The analyzer seems to be working well, but when I try the code fix, it strips the license header from the file.

image

The comments are stored in the LeadingTrivia of the code element (which returns a SyntaxTriviaList). That list needs to be carried over into the updated node unchanged.

@NightOwl888
Copy link
Contributor

Come to think of it, there is also a TrailingTrivia element. But, I have no idea what the effect of removing it would be or even if changing the modifiers of a class would remove it.

The code fix was stripping leading trivia (license headers, comments) when changing public to internal. The fix now preserves both leading trivia from the first modifier and trailing trivia from the accessibility modifier being replaced.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@paulirwin
Copy link
Contributor Author

Fixed issue with leading/trailing trivia including added unit test coverage.

@paulirwin paulirwin merged commit 445a08b into apache:main Oct 4, 2025
9 checks passed
@paulirwin paulirwin deleted the issue/1100 branch October 4, 2025 21:02
@paulirwin paulirwin added the notes:new-feature A new feature label Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:new-feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants