Skip to content

Commit

Permalink
Merge pull request #4749 from NuGet/dev
Browse files Browse the repository at this point in the history
Deployment 170927: RI dev->master
  • Loading branch information
chenriksson authored Sep 29, 2017
2 parents f0d0066 + 5c85f10 commit c69bf0e
Show file tree
Hide file tree
Showing 159 changed files with 6,389 additions and 2,665 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class AuditedPackage
public int? UserKey { get; private set; }
public bool Deleted { get; private set; }
public bool HasReadMe { get; private set; }
public int PackageStatusKey { get; private set; }

public static AuditedPackage CreateFrom(Package package)
{
Expand Down Expand Up @@ -83,8 +84,11 @@ public static AuditedPackage CreateFrom(Package package)
Key = package.Key,
MinClientVersion = package.MinClientVersion,
UserKey = package.UserKey,
#pragma warning disable CS0612 // Type or member is obsolete
Deleted = package.Deleted,
HasReadMe = package.HasReadMe
#pragma warning restore CS0612 // Type or member is obsolete
HasReadMe = package.HasReadMe,
PackageStatusKey = (int)package.PackageStatusKey,
};
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/NuGetGallery.Core/CoreConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,21 @@ namespace NuGetGallery
public static class CoreConstants
{
public const int MaxPackageIdLength = 128;

public const string PackageFileSavePathTemplate = "{0}.{1}{2}";

public const string NuGetPackageFileExtension = ".nupkg";

public const string PackageContentType = "binary/octet-stream";
public const string OctetStreamContentType = "application/octet-stream";
public const string TextContentType = "text/plain";

public const string ContentFolderName = "content";
public const string DownloadsFolderName = "downloads";
public const string PackageBackupsFolderName = "package-backups";
public const string PackageReadMesFolderName = "readmes";
public const string PackagesFolderName = "packages";
public const string UploadsFolderName = "uploads";
public const string ValidationFolderName = "validation";
}
}
9 changes: 9 additions & 0 deletions src/NuGetGallery.Core/CoreStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/NuGetGallery.Core/CoreStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,7 @@
<data name="CookieComplianceServiceAlreadyInitialized" xml:space="preserve">
<value>The cookie compliance service is already initialized.</value>
</data>
<data name="PackageIsMissingRequiredData" xml:space="preserve">
<value>The package is missing required data.</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/NuGetGallery.Core/Entities/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public bool HasReadMe {
/// </summary>
public virtual ICollection<PackageHistory> PackageHistories { get; set; }

[Obsolete]
public bool Deleted { get; set; }

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions src/NuGetGallery.Core/Entities/PackageOwnerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ public class PackageOwnerRequest
: IEntity
{
public int PackageRegistrationKey { get; set; }
public virtual PackageRegistration PackageRegistration { get; set; }
public int NewOwnerKey { get; set; }
public User NewOwner { get; set; }
public User RequestingOwner { get; set; }
public virtual User NewOwner { get; set; }
public virtual User RequestingOwner { get; set; }
public int RequestingOwnerKey { get; set; }
public string ConfirmationCode { get; set; }
public DateTime RequestDate { get; set; }
Expand Down
12 changes: 12 additions & 0 deletions src/NuGetGallery.Core/NuGetGallery.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@
<Compile Include="Properties\AssemblyInfo.*.cs" />
<Compile Include="NuGetVersionExtensions.cs" />
<Compile Include="SemVerLevelKey.cs" />
<Compile Include="Services\CloudBlobCoreFileStorageService.cs" />
<Compile Include="Services\CloudFileReference.cs" />
<Compile Include="Services\CorePackageFileService.cs" />
<Compile Include="Services\CorePackageService.cs" />
<Compile Include="Services\ICloudBlobClient.cs" />
<Compile Include="Services\ICloudBlobContainer.cs" />
<Compile Include="Services\ICorePackageFileService.cs" />
<Compile Include="Services\ICorePackageService.cs" />
<Compile Include="Services\IFileReference.cs" />
<Compile Include="Services\ICoreFileStorageService.cs" />
<Compile Include="Services\ISimpleCloudBlob.cs" />
<Compile Include="Services\TestableStorageClientException.cs" />
<Compile Include="StreamExtensions.cs" />
<Compile Include="CoreStrings.Designer.cs">
<AutoGen>True</AutoGen>
Expand Down
14 changes: 14 additions & 0 deletions src/NuGetGallery.Core/PackageStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,19 @@ public enum PackageStatus
/// version are still reserved.
/// </summary>
Deleted = 1,

/// <summary>
/// The package is in the process of being validated. The validation is being done asynchronously. When the
/// validation is complete it will move to the <see cref="Available"/>, <see cref="Deleted"/>, or
/// <see cref="FailedValidation"/> state. When packages are in this state, they are not available but the
/// package ID and version are still reserved.
/// </summary>
Validating = 2,

/// <summary>
/// The package has completed validation and the result has come back as a failure. When packages are in this
/// state, they are not available but the package ID and version are still reserved.
/// </summary>
FailedValidation = 3,
}
}
57 changes: 49 additions & 8 deletions src/NuGetGallery.Core/SemVerLevelKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,48 @@

namespace NuGetGallery
{
// Hard-coded for now, but we can easily expand to use an additional Sql table to join with
// when supporting additional semVerLevel's is needed.

/// <summary>
/// Helper class to use to determine the SemVer level of a package version.
/// </summary>
public static class SemVerLevelKey
{
public static readonly string SemVerLevel2 = "2.0.0";
public const string SemVerLevel2 = "2.0.0";
private static readonly NuGetVersion _semVer2Version = NuGetVersion.Parse(SemVerLevel2);

/// <summary>
/// Since <see cref="Unknown"/> is not a constant, we must explicitly construct the expression to force
/// that value to be considered a constant. If <see cref="Unknown"/> is not considered a constant, the
/// expression that is converted to SQL by Entity Framework is less efficient.
/// </summary>
private static readonly Lazy<Expression<Func<Package, bool>>> _isUnknown = new Lazy<Expression<Func<Package, bool>>>(() =>
{
var parameter = Expression.Parameter(typeof(Package), "p");
var property = Expression.Property(parameter, nameof(Package.SemVerLevelKey));
return Expression.Lambda<Func<Package, bool>>(
Expression.Equal(
property,
Expression.Constant(Unknown)),
parameter);
});

private static readonly Lazy<Expression<Func<Package, bool>>> _isSemVer2 = new Lazy<Expression<Func<Package, bool>>>(() =>
{
/// Since <see cref="Unknown"/> is not a constant, we must explicitly construct the expression to force
/// that value to be considered a constant. If <see cref="Unknown"/> is not considered a constant, the
/// expression that is converted to SQL by Entity Framework is less efficient.
var parameter = Expression.Parameter(typeof(Package), "p");
var property = Expression.Property(parameter, nameof(Package.SemVerLevelKey));
return Expression.Lambda<Func<Package, bool>>(
Expression.Or(
Expression.Equal(
property,
Expression.Constant(Unknown)),
Expression.Equal(
property,
Expression.Constant(SemVer2, typeof(int?)))),
parameter);
});

/// <summary>
/// This could either indicate being SemVer1-compliant, or non-SemVer-compliant at all (e.g. System.Versioning pattern).
/// </summary>
Expand All @@ -28,7 +59,7 @@ public static class SemVerLevelKey
/// Indicates being SemVer2-compliant, but not SemVer1-compliant.
/// This key corresponds to semVerLevel=2.0.0
/// </summary>
public static readonly int SemVer2 = 2;
public const int SemVer2 = 2;

/// <summary>
/// Identifies the SemVer-level of a package based on original version string and dependency versions.
Expand Down Expand Up @@ -106,17 +137,27 @@ public static class SemVerLevelKey
/// </summary>
/// <param name="semVerLevel">The SemVer-level string indicating the SemVer-level to comply with.</param>
/// <returns><c>True</c> if compliant; otherwise <c>false</c>.</returns>
public static Expression<Func<Package, bool>> IsPackageCompliantWithSemVerLevel(string semVerLevel)
public static Expression<Func<Package, bool>> IsPackageCompliantWithSemVerLevelPredicate(string semVerLevel)
{
// Note: we must return an expression that Linq to Entities is able to translate to SQL
var parsedSemVerLevelKey = ForSemVerLevel(semVerLevel);

if (parsedSemVerLevelKey == SemVer2)
{
return p => p.SemVerLevelKey == Unknown || p.SemVerLevelKey == parsedSemVerLevelKey;
return IsSemVer2Predicate();
}

return p => p.SemVerLevelKey == Unknown;
return IsUnknownPredicate();
}

public static Expression<Func<Package, bool>> IsSemVer2Predicate()
{
return _isSemVer2.Value;
}

public static Expression<Func<Package, bool>> IsUnknownPredicate()
{
return _isUnknown.Value;
}
}
}
Loading

0 comments on commit c69bf0e

Please sign in to comment.