Added warning icons to HTTP sources in VS Options NuGet Package Manager#4647
Added warning icons to HTTP sources in VS Options NuGet Package Manager#4647
Conversation
5a93c5b to
c99c609
Compare
| }; | ||
|
|
||
| IVsImageService2 vsImageService = (IVsImageService2)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsImageService)); | ||
| IVsUIObject uIObj = vsImageService.GetImage(KnownMonikers.StatusWarning, attributes); |
There was a problem hiding this comment.
I was wondering if we should get the warning icon image only if the package source is HTTP. It is possible that I don't understand the whole context of how it works currently because I don't know much about WinForms or WPF.
Another option is to get the image only once and use it as and when needed.
There was a problem hiding this comment.
I'd go further and say we should store the image in a static variable. This method, OnDrawItem, is called once per package source. There's no need to 1. get the image service instance since Visual Studio services are singletons, and 2. get the known image, which I'm reasonable confident is also a singleton. Admittedly customers don't open the dialog box very often, but this is an easy perf improvement, and this is happening on the UI thread after all.
| }; | ||
|
|
||
| IVsImageService2 vsImageService = (IVsImageService2)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsImageService)); | ||
| IVsUIObject uIObj = vsImageService.GetImage(KnownMonikers.StatusWarning, attributes); |
There was a problem hiding this comment.
I'd go further and say we should store the image in a static variable. This method, OnDrawItem, is called once per package source. There's no need to 1. get the image service instance since Visual Studio services are singletons, and 2. get the known image, which I'm reasonable confident is also a singleton. Admittedly customers don't open the dialog box very often, but this is an easy perf improvement, and this is happening on the UI thread after all.
src/NuGet.Clients/NuGet.PackageManagement.UI/NuGet.PackageManagement.UI.csproj
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourcesOptionsControl.cs
Outdated
Show resolved
Hide resolved
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
|
Chatted offline yesterday, so waiting on some changes before I review this one. |
c99c609 to
7a169e0
Compare
|
@donnie-msft I pushes new changed related to accessibility and deleted the warning PNG. |
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/CheckedListBoxAccessibleObject.cs
Show resolved
Hide resolved
45c7715 to
c43aafe
Compare
8bc78dc to
eb1fd7f
Compare
donnie-msft
left a comment
There was a problem hiding this comment.
Looks good. Think there may be a tiny layout edit needed.
Can we remove the PNG?
src/NuGet.Clients/NuGet.PackageManagement.UI/NuGet.PackageManagement.UI.csproj
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourcesOptionsControl.Designer.cs
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/CheckedListBoxAccessibleObject.cs
Show resolved
Hide resolved
| } | ||
| } | ||
|
|
||
| public static Icon WarningIcon |
There was a problem hiding this comment.
Properties are just methods with some syntactic sugar, and static methods are just methods that don't have a this "variable". In order to use a static for caching, it must be a static field.
Also, some people (myself included) believe that properties should not have "business logic", although I don't think this is in our team coding guidelines. It's much easier to understand and optimize for both correctness and performance when we can assume that fields and properties will return values already in memory (and don't change state), and methods are called when internal state is changed or when potentially expensive calculations need to be made.
So, I suggest removing these two static properties, add a private static Icon _warningIcon;, and a private Icon GetWarningIcon() that returns _warningIcon when it's not null, and gets the icon from the image service when it is null.
| if (packageSource.IsHttp && !packageSource.IsHttps) | ||
| { | ||
| var sourceMessage = string.Concat( | ||
| "Warning: Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.", |
There was a problem hiding this comment.
This needs to be in a string resource, so it can be localized for the customer's language.
2e16d73 to
855e7a7
Compare



Bug
Fixes: https://github.com/NuGet/Client.Engineering/issues/1154
Regression? Last working version:
Description
Added warning icons to the VS Options Windows for HTTP sources

PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation