Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/NuGetForUnity/Editor/Models/NugetPackageV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ internal sealed class NugetPackageV3 : NugetPackageIdentifier, INugetPackage, IS
[NotNull]
private NugetPackageSourceV3 packageSource;

[SerializeField]
[NotNull]
private string releaseNotes;

/// <summary>
/// Initializes a new instance of the <see cref="NugetPackageV3" /> class.
/// </summary>
Expand All @@ -75,6 +79,7 @@ internal sealed class NugetPackageV3 : NugetPackageIdentifier, INugetPackage, IS
/// <param name="summary">The short summary.</param>
/// <param name="title">The human readable title.</param>
/// <param name="iconUrl">The URL where the icon can be downloaded.</param>
/// <param name="releaseNotes">Release notes from the currently installed version.</param>
/// <param name="versions">All available versions.</param>
public NugetPackageV3(
[NotNull] string id,
Expand All @@ -88,6 +93,7 @@ public NugetPackageV3(
[CanBeNull] string summary,
[CanBeNull] string title,
[CanBeNull] string iconUrl,
string releaseNotes,
List<NugetPackageVersion> versions)
: base(id, version)
{
Expand All @@ -100,6 +106,7 @@ public NugetPackageV3(
Summary = summary;
Title = title;
this.iconUrl = iconUrl;
this.releaseNotes = releaseNotes;
Versions = versions;
}

Expand Down Expand Up @@ -178,7 +185,7 @@ public Task<Texture2D> IconTask
}

/// <inheritdoc />
public string ReleaseNotes => string.Empty;
public string ReleaseNotes => releaseNotes;

/// <inheritdoc />
public RepositoryType RepositoryType => RepositoryType.NotSpecified;
Expand Down
25 changes: 22 additions & 3 deletions src/NuGetForUnity/Editor/PackageSource/NugetApiClientV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,13 @@ public async Task DownloadNupkgToFileAsync(
/// </summary>
/// <param name="packageSource">The package source that owns this client.</param>
/// <param name="package">The package identifier to receive including the details.</param>
/// <param name="includePrerelease">True to include prerelease packages (alpha, beta, etc).</param>
/// <param name="cancellationToken">Token to cancel the HTTP request.</param>
/// <returns>The package or null if we didn't find it.</returns>
public async Task<NugetPackageV3> GetPackageWithAllVersionsAsync(
NugetPackageSourceV3 packageSource,
INugetPackageIdentifier package,
bool includePrerelease,
CancellationToken cancellationToken = default)
{
var registrationItems = await GetRegistrationPageItemsAsync(packageSource, package, cancellationToken);
Expand All @@ -262,13 +264,15 @@ public async Task<NugetPackageV3> GetPackageWithAllVersionsAsync(
var versions = new List<NugetPackageVersion>();
RegistrationLeafObject latestVersionItem = null;
NugetPackageVersion latestVersion = null;
var sb = new StringBuilder();
foreach (var item in registrationItems)
{
if (item.items is null || item.items.Count == 0)
{
item.items = await GetRegistrationPageLeafItems(packageSource, item, cancellationToken).ConfigureAwait(false);
}

var lastNote = string.Empty;
foreach (var leafObject in item.items)
{
var catalogEntry = leafObject.CatalogEntry;
Expand All @@ -280,19 +284,28 @@ public async Task<NugetPackageV3> GetPackageWithAllVersionsAsync(
}

var version = new NugetPackageVersion(catalogEntry.version);
versions.Add(version);
if (includePrerelease || !version.IsPrerelease)
{
versions.Add(version);
}

if (latestVersion != null && version <= latestVersion)
{
continue;
}

latestVersion = version;
latestVersionItem = leafObject;
if (!string.IsNullOrWhiteSpace(catalogEntry.releaseNotes) && lastNote != catalogEntry.releaseNotes && version > package.PackageVersion)
{
sb.Append(catalogEntry.releaseNotes).Append("\n");
lastNote = catalogEntry.releaseNotes;
}
}
}

versions.Sort((v1, v2) => v2.CompareTo(v1));
return CreatePackageFromRegistrationLeaf(packageSource, latestVersionItem, versions);
return CreatePackageFromRegistrationLeaf(packageSource, latestVersionItem, sb.ToString(), versions);
}

/// <summary>
Expand All @@ -314,7 +327,7 @@ public async Task<NugetPackageV3> GetPackageWithDetailsAsync(
return null;
}

return CreatePackageFromRegistrationLeaf(packageSource, leafItem);
return CreatePackageFromRegistrationLeaf(packageSource, leafItem, leafItem.CatalogEntry.releaseNotes);
}

/// <summary>
Expand Down Expand Up @@ -343,6 +356,7 @@ public async Task<List<NugetFrameworkGroup>> GetPackageDetailsAsync(
private static NugetPackageV3 CreatePackageFromRegistrationLeaf(
NugetPackageSourceV3 packageSource,
RegistrationLeafObject leafItem,
string releaseNotes,
List<NugetPackageVersion> allVersions = null)
{
var entry = leafItem.CatalogEntry;
Expand All @@ -368,6 +382,7 @@ private static NugetPackageV3 CreatePackageFromRegistrationLeaf(
entry.summary,
entry.title,
entry.iconUrl,
releaseNotes,
allVersions ?? new List<NugetPackageVersion> { new NugetPackageVersion(entry.version) })
{
DownloadUrl = leafItem.packageContent, Dependencies = ConvertDependencyGroups(entry),
Expand Down Expand Up @@ -443,6 +458,7 @@ private static List<INugetPackage> SearchResultToNugetPackages(List<SearchResult
item.summary,
item.title,
item.iconUrl,
string.Empty,
versions));
}

Expand Down Expand Up @@ -1017,6 +1033,9 @@ private sealed class CatalogEntry
[CanBeNull]
public string version;

[CanBeNull]
public string releaseNotes;

/// <summary>
/// The security vulnerabilities of the package.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public List<INugetPackage> GetUpdates(

var fetchedPackages = await Task.WhenAll(
packagesToFetch.Select(package =>
ApiClient.GetPackageWithAllVersionsAsync(this, package, CancellationToken.None)))
ApiClient.GetPackageWithAllVersionsAsync(this, package, includePrerelease, CancellationToken.None)))
.ConfigureAwait(false);
return fetchedPackages.Where(fetchedPackage => !(fetchedPackage is null)).ToList<INugetPackage>();
}
Expand Down
7 changes: 6 additions & 1 deletion src/NuGetForUnity/Editor/Ui/NugetWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ private void DrawUpdatesHeader()
{
showPrereleaseUpdates = showPrereleaseTemp;
UpdateUpdatePackages();
versionDropdownDataPerPackage.Clear();
}

var showDowngradesTemp = GUILayout.Toggle(
Expand Down Expand Up @@ -1290,7 +1291,11 @@ private void DrawPackage(INugetPackage package, GUIStyle backgroundStyle, bool c
if (!string.IsNullOrEmpty(package.ReleaseNotes))
{
EditorGUILayout.LabelField("Release Notes", EditorStyles.boldLabel);
EditorGUILayout.LabelField(package.ReleaseNotes);
var releaseNotesContent = new GUIContent(package.ReleaseNotes);
var releaseNotesRect = EditorGUILayout.GetControlRect(
true,
labelStyle.CalcHeight(releaseNotesContent, EditorGUIUtility.currentViewWidth - 20f) + 12f);
EditorGUI.LabelField(releaseNotesRect, releaseNotesContent, labelStyle);
GUILayout.Space(4f);
}

Expand Down
Loading