-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6167 from NuGet/dev
[ReleasePrep][2018.07.16]RI of dev into master
- Loading branch information
Showing
82 changed files
with
1,161 additions
and
20,102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/NuGetGallery.Core/Extensions/PackageValidationSetExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using NuGet.Services.Validation; | ||
using NuGet.Services.Validation.Issues; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace NuGetGallery | ||
{ | ||
public static class PackageValidationSetExtensions | ||
{ | ||
public static IReadOnlyList<ValidationIssue> GetValidationIssues(this PackageValidationSet validationSet) | ||
{ | ||
IReadOnlyList<ValidationIssue> issues = null; | ||
|
||
if (validationSet != null) | ||
{ | ||
// Get the failed validation set's validation issues. The issues are ordered by their | ||
// key so that it appears that issues are appended as more validations fail. | ||
issues = validationSet | ||
.PackageValidations | ||
.SelectMany(v => v.PackageValidationIssues) | ||
.OrderBy(i => i.Key) | ||
.Select(i => ValidationIssue.Deserialize(i.IssueCode, i.Data)) | ||
.ToList(); | ||
|
||
// Filter out unknown issues and deduplicate the issues by code and data. This also deduplicates cases | ||
// where there is extraneous data in the serialized data field or if the issue code is unknown. | ||
issues = issues | ||
.GroupBy(x => new { x.IssueCode, Data = x.Serialize() }) | ||
.Select(x => x.First()) | ||
.ToList(); | ||
} | ||
|
||
// If the package failed validation but we could not find an issue that explains why, use a generic error message. | ||
if (issues == null || !issues.Any()) | ||
{ | ||
issues = new[] { ValidationIssue.Unknown }; | ||
} | ||
|
||
return issues; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.