-
Notifications
You must be signed in to change notification settings - Fork 645
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
IconUrl deprecation message. #7556
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace NuGetGallery | ||
{ | ||
/// <summary> | ||
/// IconUrl element deprecation message. | ||
/// </summary> | ||
public class IconUrlDeprecationValidationMessage : IValidationMessage | ||
{ | ||
public string PlainTextMessage => $"{Strings.UploadPackage_IconUrlDeprecated} https://aka.ms/deprecateIconUrl"; | ||
|
||
public bool HasRawHtmlRepresentation => true; | ||
|
||
public string RawHtmlMessage => $"{Strings.UploadPackage_IconUrlDeprecated.Replace("<", "<").Replace(">", ">")} <a href=\"https://aka.ms/deprecateIconUrl\">{Strings.UploadPackage_LearnMore}</a>."; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1150,4 +1150,7 @@ The {1} Team</value> | |||||
<data name="SiteAdminNotLoggedInWithRequiredTenant" xml:space="preserve"> | ||||||
<value>The site admins are required to sign in with the '{0}' tenant only.</value> | ||||||
</data> | ||||||
<data name="UploadPackage_IconUrlDeprecated" xml:space="preserve"> | ||||||
<value><iconUrl> element will be deprecated, please consider switching to specifying the icon in the package.</value> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Considering that we're warning on icon URLs already, isn't it already deprecated? What do you think of this messaging?
Suggested change
This is message doesn't mirror the client's message, but I would prefer a clearer message if possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message that client currently produces is:
And for
|
||||||
</data> | ||||||
</root> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1141,6 +1141,53 @@ public async Task AcceptsPackagesWithEmbeddedIconForFlightedUsers() | |
Assert.Empty(result.Warnings); | ||
} | ||
|
||
[Fact] | ||
public async Task WarnsAboutPackagesWithIconUrlForFlightedUsers() | ||
{ | ||
_nuGetPackage = GeneratePackageWithUserContent( | ||
iconUrl: new Uri("https://nuget.test/icon"), | ||
iconFilename: null, | ||
licenseExpression: "MIT", | ||
licenseUrl: new Uri("https://licenses.nuget.org/MIT")); | ||
_featureFlagService | ||
.Setup(ffs => ffs.AreEmbeddedIconsEnabled(_currentUser)) | ||
.Returns(true); | ||
|
||
var result = await _target.ValidateBeforeGeneratePackageAsync( | ||
_nuGetPackage.Object, | ||
GetPackageMetadata(_nuGetPackage), | ||
_currentUser); | ||
|
||
Assert.Equal(PackageValidationResultType.Accepted, result.Type); | ||
Assert.Null(result.Message); | ||
var warning = Assert.Single(result.Warnings); | ||
Assert.IsType<IconUrlDeprecationValidationMessage>(warning); | ||
Assert.StartsWith("<iconUrl> element will be deprecated, please consider switching to specifying the icon in the package.", warning.PlainTextMessage); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks easy to break this test if we use the hard coded string. Maybe directly using the "Strings.UploadPackage_IconUrlDeprecated" is better for future maintenances. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the point of this check. To break if text changes. Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@agr Do you need to update your tests? |
||
Assert.StartsWith("<iconUrl> element will be deprecated, please consider switching to specifying the icon in the package.", warning.RawHtmlMessage); | ||
} | ||
|
||
[Fact] | ||
public async Task DoesntWarnAboutPackagesWithIconUrl() | ||
{ | ||
_nuGetPackage = GeneratePackageWithUserContent( | ||
iconUrl: new Uri("https://nuget.test/icon"), | ||
iconFilename: null, | ||
licenseExpression: "MIT", | ||
licenseUrl: new Uri("https://licenses.nuget.org/MIT")); | ||
_featureFlagService | ||
.Setup(ffs => ffs.AreEmbeddedIconsEnabled(_currentUser)) | ||
.Returns(false); | ||
|
||
var result = await _target.ValidateBeforeGeneratePackageAsync( | ||
_nuGetPackage.Object, | ||
GetPackageMetadata(_nuGetPackage), | ||
_currentUser); | ||
|
||
Assert.Equal(PackageValidationResultType.Accepted, result.Type); | ||
Assert.Null(result.Message); | ||
Assert.Empty(result.Warnings); | ||
} | ||
|
||
[Theory] | ||
[InlineData("<icon><something/></icon>")] | ||
[InlineData("<icon><something>icon.png</something></icon>")] | ||
|
@@ -2218,6 +2265,7 @@ protected static Mock<TestPackageReader> GeneratePackageWithUserContent( | |
bool isSigned = true, | ||
int? desiredTotalEntryCount = null, | ||
Func<string> getCustomNuspecNodes = null, | ||
Uri iconUrl = null, | ||
Uri licenseUrl = null, | ||
string licenseExpression = null, | ||
string licenseFilename = null, | ||
|
@@ -2232,6 +2280,7 @@ protected static Mock<TestPackageReader> GeneratePackageWithUserContent( | |
isSigned: isSigned, | ||
desiredTotalEntryCount: desiredTotalEntryCount, | ||
getCustomNuspecNodes: getCustomNuspecNodes, | ||
iconUrl: iconUrl, | ||
licenseUrl: licenseUrl, | ||
licenseExpression: licenseExpression, | ||
licenseFilename: licenseFilename, | ||
|
@@ -2249,6 +2298,7 @@ protected static MemoryStream GeneratePackageStream( | |
bool isSigned = true, | ||
int? desiredTotalEntryCount = null, | ||
Func<string> getCustomNuspecNodes = null, | ||
Uri iconUrl = null, | ||
Uri licenseUrl = null, | ||
string licenseExpression = null, | ||
string licenseFilename = null, | ||
|
@@ -2265,6 +2315,7 @@ protected static MemoryStream GeneratePackageStream( | |
desiredTotalEntryCount: desiredTotalEntryCount, | ||
getCustomNuspecNodes: getCustomNuspecNodes, | ||
licenseUrl: licenseUrl, | ||
iconUrl: iconUrl, | ||
licenseExpression: licenseExpression, | ||
licenseFilename: licenseFilename, | ||
licenseFileContents: GetBinaryLicenseFileContents(licenseFileBinaryContents, licenseFileContents), | ||
|
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.
nit: Not a very useful comment, as it just restates the name of the class. I would prefer either getting rid of this comment or saying more about IconUrl and its deprecation.