Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @choyy, 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 refines the handling of Visual Studio versions within the CMake generator logic for MSVC. It removes a specific assertion that previously validated the Visual Studio version against a known list. The primary goal is to enhance the system's robustness by preventing crashes when encountering undefined or unexpected Visual Studio configurations, thereby allowing for more flexible or deferred error handling.
Highlights
- Removed Visual Studio Version Assertion: The explicit assertion that checked for the validity of Visual Studio versions (
vsvers[vs]) has been removed from the_get_cmake_generator_for_msvcfunction in both affected files. - Improved Robustness: This change prevents immediate crashes or assertion failures when an unknown or undefined Visual Studio version is encountered, allowing the system to proceed more gracefully.
Using Gemini Code Assist
The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request correctly removes assertions that use an undefined vsvers variable, which fixes a potential crash. However, this change leads to less informative error messages when an unknown Visual Studio version is used. The new error message from toolchain_utils.get_vsver is generic ("unknown msvc version!"), whereas the old one specified which version was unknown. I've provided suggestions in the comments to restore the more detailed error messages by wrapping the call in pcall and using a custom assertion.
| function _get_cmake_generator_for_msvc(package) | ||
| local vs = _get_msvc(package):config("vs") or config.get("vs") | ||
| assert(vsvers[vs], "Unknown Visual Studio version: '" .. tostring(vs) .. "' set in project.") | ||
| return "Visual Studio " .. toolchain_utils.get_vsver(vs) .. " " .. vs |
There was a problem hiding this comment.
While removing the assertion that uses the undefined vsvers variable is correct, it results in a less specific error message if an invalid Visual Studio version is provided. The original assertion provided a more helpful message, including the invalid version string. We can restore this improved error reporting by using pcall to catch the error from toolchain_utils.get_vsver and then assert with a more informative message.
local ok, vs_ver = pcall(toolchain_utils.get_vsver, vs)
assert(ok, ("Unknown Visual Studio version: '%s' set in project."):format(tostring(vs)))
return "Visual Studio " .. vs_ver .. " " .. vs
| function _get_cmake_generator_for_msvc() | ||
| local vs = _get_msvc():config("vs") or config.get("vs") | ||
| assert(vsvers[vs], "Unknown Visual Studio version: '" .. tostring(vs) .. "' set in project.") | ||
| return "Visual Studio " .. toolchain_utils.get_vsver(vs) .. " " .. vs |
There was a problem hiding this comment.
Similar to the other file, removing the assertion is correct but degrades the error message for unknown Visual Studio versions. Let's restore the more informative error message using pcall to provide better feedback to the user when a configuration is incorrect.
local ok, vs_ver = pcall(toolchain_utils.get_vsver, vs)
assert(ok, ("Unknown Visual Studio version: '%s' set in project."):format(tostring(vs)))
return "Visual Studio " .. vs_ver .. " " .. vs
No description provided.