-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace typeof(X).Name with nameof(X) #1077 #1091
Replace typeof(X).Name with nameof(X) #1077 #1091
Conversation
* Replaced all occurrences of typeof(X).Name with nameof(X) * Improved code readability and compile-time safety
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! It mostly looks good. There are a couple cases we'll have to revert that I didn't consider until now, where we can't use this on generic type parameters. The rest of the comments are about string interpolation and some const conversions. Should be pretty quick to fix. If you are unable to make the changes, let me know and I'd be happy to do them.
src/Lucene.Net.Analysis.Common/Analysis/NGram/EdgeNGramTokenizerFactory.cs
Outdated
Show resolved
Hide resolved
src/Lucene.Net.Analysis.Common/Analysis/Util/AnalysisSPILoader.cs
Outdated
Show resolved
Hide resolved
… and change static readonly to const, apache#1077
Thank you for reviewing my PR! I've taken your comments into consideration and made the required changes, hopefully the code looks good now. The cases where I had to revert were very interesting and I appreciated the insights into why each change was requested as it gave me more context into the workings of runtime behaviour for those specific functionalities. Open to making more changes if required! |
Replaced all occurrences of
typeof(X).Name
withnameof(X)
Fixes (#1077)
Description
Replaced usages of
typeof(X).Name
withnameof(X)
across the codebase to improve compile-time safety and readability.The
nameof(X)
expression ensures the type name is determined at compile time rather than runtime, preventing runtime-related issues and potentially improving performance. This change aligns with modern C# practices and simplifies future maintenance by eliminating unnecessary runtime operations.