-
-
Notifications
You must be signed in to change notification settings - Fork 481
Minor optimizations and cleaning #1484
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
base: main
Are you sure you want to change the base?
Conversation
|
CLA Assistant Lite bot: I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request |
Summary of ChangesHello @jobzteve, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on enhancing code quality through a series of minor optimizations and cleaning efforts. The changes aim to improve readability, maintainability, and leverage modern C# features, without altering the core functionality of the application. Key improvements include streamlining Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Summary of ChangesHello @jobzteve, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the codebase through a series of minor optimizations and significant cleaning efforts. The changes primarily involve streamlining 'using' directives, modernizing enum value retrieval, refining internal synchronization patterns, and applying consistent code formatting. The aim is to create a cleaner, more maintainable, and slightly more efficient application. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Summary of ChangesHello @jobzteve, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on a comprehensive code hygiene effort, implementing minor optimizations and cleaning throughout the codebase. The changes primarily involve removing redundant Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces several minor optimizations and code cleanup, primarily by removing unused using directives and improving code formatting. While many of these changes enhance code hygiene, there are a couple of critical issues that will lead to compilation errors. Specifically, the use of an undefined Lock type in InMemoryStorage.cs and HardwareHelper.cs will break the build. Additionally, there's an opportunity to further simplify the code in EnumHelpers.cs by removing redundant .Cast<T>() calls. My review provides suggestions to address these points.
|
|
||
| private int _maxItemCount; | ||
| private object _settingMaxItemCountLocker = new(); | ||
| private readonly Lock _settingMaxItemCountLocker = new(); |
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.
The type of _settingMaxItemCountLocker has been changed from object to Lock. However, the Lock type is not defined or imported in this file. The using KGySoft.CoreLibraries; statement, which likely contains this type, was removed in this pull request. This will cause a compilation error. Please revert this to use object or ensure the Lock type is correctly referenced.
private readonly object _settingMaxItemCountLocker = new();|
|
||
| private static IReadOnlyList<GpuInfo>? cachedGpuInfos; | ||
| private static readonly object cachedGpuInfosLock = new(); | ||
| private static readonly Lock cachedGpuInfosLock = new(); |
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.
The type of cachedGpuInfosLock has been changed from object to Lock. However, the Lock type does not appear to be defined or imported within the project's scope, which will cause a compilation error. Please use a valid and available type for locking, such as object.
private static readonly object cachedGpuInfosLock = new();|
|
||
| using System; | ||
| using System.Collections.Concurrent; | ||
| using System.Collections.Generic; |
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.
The using System.Collections.Generic; statement was removed, but this file uses Dictionary<TKey, TValue> and LinkedList<T>, which are defined in that namespace. This will likely cause a compilation error unless System.Collections.Generic is included as a global using for the project. If it's not a global using, this statement should be restored.
| public static IEnumerable<CivitPeriod> AllCivitPeriods { get; } = | ||
| Enum.GetValues(typeof(CivitPeriod)).Cast<CivitPeriod>(); | ||
| Enum.GetValues<CivitPeriod>().Cast<CivitPeriod>(); | ||
|
|
||
| public static IEnumerable<CivitSortMode> AllSortModes { get; } = | ||
| Enum.GetValues(typeof(CivitSortMode)).Cast<CivitSortMode>(); | ||
| Enum.GetValues<CivitSortMode>().Cast<CivitSortMode>(); | ||
|
|
||
| public static IEnumerable<CivitModelType> AllCivitModelTypes { get; } = | ||
| Enum.GetValues(typeof(CivitModelType)) | ||
| Enum.GetValues<CivitModelType>() | ||
| .Cast<CivitModelType>() | ||
| .Where(t => t == CivitModelType.All || t.ConvertTo<SharedFolderType>() > 0) | ||
| .OrderBy(t => t.ToString()); | ||
|
|
||
| public static IEnumerable<CivitModelType> MetadataEditorCivitModelTypes { get; } = | ||
| Enum.GetValues(typeof(CivitModelType)).Cast<CivitModelType>().OrderBy(t => t.ToString()); | ||
| Enum.GetValues<CivitModelType>().Cast<CivitModelType>().OrderBy(t => t.ToString()); | ||
|
|
||
| public static IEnumerable<CivitBaseModelType> AllCivitBaseModelTypes { get; } = | ||
| Enum.GetValues(typeof(CivitBaseModelType)).Cast<CivitBaseModelType>(); | ||
| Enum.GetValues<CivitBaseModelType>().Cast<CivitBaseModelType>(); |
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.
The Enum.GetValues<T>() method already returns an array of the enum type (T[]), which is implicitly convertible to IEnumerable<T>. Therefore, the subsequent calls to .Cast<T>() are redundant and can be removed for cleaner code. This applies to AllCivitPeriods, AllSortModes, AllCivitModelTypes, MetadataEditorCivitModelTypes, and AllCivitBaseModelTypes.
public static IEnumerable<CivitPeriod> AllCivitPeriods { get; } =
Enum.GetValues<CivitPeriod>();
public static IEnumerable<CivitSortMode> AllSortModes { get; } =
Enum.GetValues<CivitSortMode>();
public static IEnumerable<CivitModelType> AllCivitModelTypes { get; } =
Enum.GetValues<CivitModelType>()
.Where(t => t == CivitModelType.All || t.ConvertTo<SharedFolderType>() > 0)
.OrderBy(t => t.ToString());
public static IEnumerable<CivitModelType> MetadataEditorCivitModelTypes { get; } =
Enum.GetValues<CivitModelType>().OrderBy(t => t.ToString());
public static IEnumerable<CivitBaseModelType> AllCivitBaseModelTypes { get; } =
Enum.GetValues<CivitBaseModelType>();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.
Code Review
This pull request primarily focuses on code cleanup and modernization across several files. Key changes include the removal of numerous unused using statements (System.* and others) to streamline code. The EnumHelpers.cs file was updated to use the more modern Enum.GetValues<T>() method, with review comments highlighting that the subsequent .Cast<T>() calls are redundant and should be removed for cleaner code. Locking mechanisms in InMemoryStorage.cs and HardwareHelper.cs were updated from generic object locks to a custom Lock type, and RunningPackageService.cs adopted using var _ for unused lock variables. Additionally, various files received minor formatting adjustments to improve code conciseness and readability, such as refactoring multi-line expressions and adding trailing commas in initializers.
| { | ||
| public static IEnumerable<CivitPeriod> AllCivitPeriods { get; } = | ||
| Enum.GetValues(typeof(CivitPeriod)).Cast<CivitPeriod>(); | ||
| Enum.GetValues<CivitPeriod>().Cast<CivitPeriod>(); |
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.
|
|
||
| public static IEnumerable<CivitSortMode> AllSortModes { get; } = | ||
| Enum.GetValues(typeof(CivitSortMode)).Cast<CivitSortMode>(); | ||
| Enum.GetValues<CivitSortMode>().Cast<CivitSortMode>(); |
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.
|
|
||
| public static IEnumerable<CivitModelType> MetadataEditorCivitModelTypes { get; } = | ||
| Enum.GetValues(typeof(CivitModelType)).Cast<CivitModelType>().OrderBy(t => t.ToString()); | ||
| Enum.GetValues<CivitModelType>().Cast<CivitModelType>().OrderBy(t => t.ToString()); |
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.
|
|
||
| public static IEnumerable<CivitBaseModelType> AllCivitBaseModelTypes { get; } = | ||
| Enum.GetValues(typeof(CivitBaseModelType)).Cast<CivitBaseModelType>(); | ||
| Enum.GetValues<CivitBaseModelType>().Cast<CivitBaseModelType>(); |
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.
No description provided.