Skip to content

Commit

Permalink
Merge pull request NuGet#21 from gep13/fix-title
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm authored Jan 18, 2023
2 parents f1e5db2 + dbcd487 commit 97fcd21
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 9 deletions.
35 changes: 32 additions & 3 deletions src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ public sealed partial class V2FeedParser : IV2FeedParser

// XNames used in the feed
private static readonly XName _xnameEntry = XName.Get("entry", W3Atom);
private static readonly XName _xnameTitle = XName.Get("title", W3Atom);

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

private static readonly XName _xnameAtomTitle = XName.Get("title", W3Atom);
private static readonly XName _xnameTitle = XName.Get("Title", DataServicesNS);

//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

private static readonly XName _xnameContent = XName.Get("content", W3Atom);
private static readonly XName _xnameLink = XName.Get("link", W3Atom);
private static readonly XName _xnameProperties = XName.Get("properties", MetadataNS);
Expand Down Expand Up @@ -356,7 +367,16 @@ private V2FeedPackageInfo ParsePackage(string id, XElement element, MetadataRefe
{
var properties = element.Element(_xnameProperties);
var idElement = properties.Element(_xnameId);
var titleElement = element.Element(_xnameTitle);

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

var titleElement = element.Element(_xnameAtomTitle);

//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

// If 'Id' element exist, use its value as accurate package Id
// Otherwise, use the value of 'title' if it exist
Expand All @@ -366,7 +386,16 @@ private V2FeedPackageInfo ParsePackage(string id, XElement element, MetadataRefe
var version = metadataCache.GetVersion(metadataCache.GetString(versionString));
var downloadUrl = metadataCache.GetString(element.Element(_xnameContent).Attribute("src").Value);

var title = metadataCache.GetString(titleElement?.Value);
//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

var title = metadataCache.GetString(GetString(properties, _xnameTitle));

//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

var summary = metadataCache.GetString(GetString(element, _xnameSummary));
var description = metadataCache.GetString(GetString(properties, _xnameDescription));
var iconUrl = metadataCache.GetString(GetString(properties, _xnameIconUrl));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ public async Task PackageMetadataResource_Basic()

Assert.Equal("WindowsAzure.Storage", latestPackage.Identity.Id);
Assert.Equal("6.2.2-preview", latestPackage.Identity.Version.ToNormalizedString());
Assert.Equal("WindowsAzure.Storage", latestPackage.Title);

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Windows Azure Storage", latestPackage.Title);

//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Microsoft", latestPackage.Authors);
Assert.Equal("", latestPackage.Owners);
Assert.True(latestPackage.Description.StartsWith("This client library enables"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ public async Task PackageSearchResourceV2Feed_Basic()

// Assert
Assert.Equal(1, searchResult.Count());
Assert.Equal("WindowsAzure.Storage", package.Title);

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Windows Azure Storage", package.Title);

//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Microsoft", package.Authors);
Assert.Equal("", package.Owners);
Assert.True(package.Description.StartsWith("This client library enables"));
Expand Down
38 changes: 34 additions & 4 deletions test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task V2FeedParser_FindPackagesByIdAsync()
// Assert
Assert.Equal("WindowsAzure.Storage", latest.Id);
Assert.Equal("6.2.2-preview", latest.Version.ToNormalizedString());
Assert.Equal("WindowsAzure.Storage", latest.Title);
Assert.Equal("Windows Azure Storage", latest.Title);
Assert.Equal("Microsoft", String.Join(",", latest.Authors));
Assert.Equal("", String.Join(",", latest.Owners));
Assert.True(latest.Description.StartsWith("This client library enables"));
Expand Down Expand Up @@ -208,7 +208,17 @@ public async Task V2FeedParser_Search()
// Assert
Assert.Equal("WindowsAzure.Storage", package.Id);
Assert.Equal("6.2.0", package.Version.ToNormalizedString());
Assert.Equal("WindowsAzure.Storage", package.Title);

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Windows Azure Storage", package.Title);

//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Microsoft", String.Join(",", package.Authors));
Assert.Equal("", String.Join(",", package.Owners));
Assert.True(package.Description.StartsWith("This client library enables"));
Expand Down Expand Up @@ -423,7 +433,17 @@ public async Task V2FeedParser_GetPackage()
// Assert
Assert.Equal("WindowsAzure.Storage", package.Id);
Assert.Equal("4.3.2-preview", package.Version.ToNormalizedString());
Assert.Equal("WindowsAzure.Storage", package.Title);

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Windows Azure Storage", package.Title);

//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Microsoft", String.Join(",", package.Authors));
Assert.Equal("", String.Join(",", package.Owners));
Assert.True(package.Description.StartsWith("This client library enables"));
Expand Down Expand Up @@ -492,7 +512,17 @@ public async Task V2FeedParser_GetPackage_NotFoundOnPackagesFoundOnFindPackagesB
// Assert
Assert.Equal("WindowsAzure.Storage", package.Id);
Assert.Equal("4.3.2-preview", package.Version.ToNormalizedString());
Assert.Equal("WindowsAzure.Storage", package.Title);

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Windows Azure Storage", package.Title);

//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

Assert.Equal("Microsoft", String.Join(",", package.Authors));
Assert.Equal("", String.Join(",", package.Owners));
Assert.True(package.Description.StartsWith("This client library enables"));
Expand Down

0 comments on commit 97fcd21

Please sign in to comment.