[windows] Searches for pre-release and 'all' Visual Studio installations#40011
[windows] Searches for pre-release and 'all' Visual Studio installations#40011franciscojma86 merged 3 commits intoflutter:masterfrom
Conversation
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
4a6d6b9 to
3e28019
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Codecov Report
@@ Coverage Diff @@
## master #40011 +/- ##
==========================================
+ Coverage 57.88% 58.02% +0.14%
==========================================
Files 194 194
Lines 18726 18768 +42
==========================================
+ Hits 10839 10891 +52
+ Misses 7887 7877 -10
Continue to review full report at Codecov.
|
28d830a to
8c87041
Compare
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Overall looks great, just a few small notes.
| _vswherePath, | ||
| '-format', 'json', | ||
| final List<String> defaultArguments = <String>[ | ||
| '-format', |
There was a problem hiding this comment.
Nit: since we're formatting manually anyway, I would prefer keeping 'json' on the same line with this to make it obvious that it's conceptually one argument.
There was a problem hiding this comment.
Done. I was wondering why it was indented like that, but makes sense.
| // If a stable version is not found, try searching for a pre-release version. | ||
| _cachedUsableVisualStudioDetails ??= _visualStudioDetails( | ||
| requiredComponents: _requiredComponents().keys, | ||
| additionalArguments: <String>['-prerelease']); |
There was a problem hiding this comment.
Nit: maybe make -prerelease an internal string constant since it's used twice.
| String get visualStudioNotLaunchable => | ||
| 'The current Visual Studio installation is not launchable. Please reinstall Visual Studio.'; | ||
| String get visualStudioIsIncomplete => 'The current Visual Studio installation is incomplete. Please reinstall Visual Studio'; | ||
| String get visualStudioRebootRequired => 'Visual Studio requires a reboot of your system to complete installation'; |
There was a problem hiding this comment.
Please give these strings trailing .s for consistency with the other messages.
| String get visualStudioMissing => | ||
| 'Visual Studio not installed; this is necessary for Windows development.\n' | ||
| 'Download at https://visualstudio.microsoft.com/downloads/.'; | ||
| String get visualStudioIsPrerelease => 'The current Visual Studio installation is a pre-release version'; |
There was a problem hiding this comment.
We should probably provide a bit more context about what effect this may have. Let's add another sentence: "It may not be supported by Flutter yet."
| } | ||
|
|
||
| // Messages for faulty installations. | ||
| if (!visualStudio.isComplete) { |
There was a problem hiding this comment.
We probably shouldn't add all of these, as I'm not sure how they combine in practice (e.g., it may be that when a reboot required it also reports as incomplete) and we don't want to overwhelm the user with potentially conflicting information. Let's do these three as:
if (...isRebootRequired) {
...
} else if (!...isComplete) {
...
} else if (!...isLaunchable) {
...
}
And actually, some of the issue reports we've had (see #39970) suggest that if the install isn't fully complete, the components checks don't necessarily work as we would expect which can cause confusion, so let's add the !...hasNecessaryComponents) check to the end of that chain as an else-if as well.
| ProcessManager: () => mockProcessManager, | ||
| }); | ||
|
|
||
| testUsingContext('vcvarsPath returns null when VS is present but missing components', () { |
There was a problem hiding this comment.
I don't know if it's possible for the components to show as present but the install to be unusable due to one of the flags we are checking. To err on the safe side, let's also test some cases where components are present but one of the bad flags (e.g., needs reboot) are true. That will require some code changes to pass I believe—maybe change the logic of how _usableVisualStudioDetails is computed internally so that if one of the checks there finds a version that has one of the problem flags set, it's assigned to _cachedAnyVisualStudioDetails instead of _cachedUsableVisualStudioDetails.
| if (_cachedUsableVisualStudioDetails != null) { | ||
| if (installationHasIssues(_cachedUsableVisualStudioDetails)) { | ||
| _cachedAnyVisualStudioDetails = _cachedUsableVisualStudioDetails; | ||
| return null; |
There was a problem hiding this comment.
It occurs to me reviewing this with more distance from having written it that the use of null to indicate both not having found anything usable and not having checked means we're going to run vswhere a bunch of extra times. It's a pre-existing problem which this change will make worse.
Could you do a follow-up PR to change the structure of these functions to use a sentinel value (maybe {}) for _cached* in cases where we have checked and not found anything?
Fixes a crash introduced on flutter#40011 due to an incorrect type in the vswhere search Fixes flutter#40238
Pre-release VS installations with the required components where not being found. There is now a new search for such installations, as well as any other type of installations:
along with a new user message for each of these cases.
#35350
#37831
I added tests for visual_studio_test.dart and visual_studio_validator_test.dart
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?