예제 #1
0
 public override Task <ShouldRunTestResult> ShouldRunLeafAsync(
     ValidationContext context,
     PackageRegistrationLeafMetadata database,
     PackageRegistrationLeafMetadata v3)
 {
     return(Task.FromResult(database != null && v3 != null ? ShouldRunTestResult.Yes : ShouldRunTestResult.No));
 }
 public override Task <bool> ShouldRunLeafAsync(
     ValidationContext context,
     PackageRegistrationLeafMetadata v2,
     PackageRegistrationLeafMetadata v3)
 {
     return(Task.FromResult(v2 != null && v3 != null));
 }
        public override Task CompareLeafAsync(
            ValidationContext context,
            PackageRegistrationLeafMetadata database,
            PackageRegistrationLeafMetadata v3)
        {
            var databaseExists = database != null;
            var v3Exists       = v3 != null;
            var completedTask  = Task.FromResult(0);

            if (databaseExists != v3Exists)
            {
                // Currently, leaf nodes are not deleted after a package is deleted.
                // This is a known bug. Do not fail validations because of it.
                // See https://github.com/NuGet/NuGetGallery/issues/4475
                if (v3Exists && !(v3 is PackageRegistrationIndexMetadata))
                {
                    Logger.LogInformation("{PackageId} {PackageVersion} doesn't exist in the database but has a leaf node in V3!", context.Package.Id, context.Package.Version);
                    return(completedTask);
                }

                const string existsString       = "exists";
                const string doesNotExistString = "doesn't exist";

                throw new MetadataInconsistencyException <PackageRegistrationLeafMetadata>(
                          database,
                          v3,
                          $"Database {(databaseExists ? existsString : doesNotExistString)} but V3 {(v3Exists ? existsString : doesNotExistString)}!");
            }

            return(completedTask);
        }
예제 #4
0
        public override Task CompareLeafAsync(
            ValidationContext context,
            PackageRegistrationLeafMetadata database,
            PackageRegistrationLeafMetadata v3)
        {
            if (database.Listed != v3.Listed)
            {
                throw new MetadataFieldInconsistencyException <PackageRegistrationLeafMetadata>(
                          database, v3,
                          nameof(PackageRegistrationLeafMetadata.Listed),
                          m => m.Listed);
            }

            return(Task.FromResult(0));
        }
예제 #5
0
 public abstract Task CompareLeafAsync(
     ValidationContext context,
     PackageRegistrationLeafMetadata database,
     PackageRegistrationLeafMetadata v3);
예제 #6
0
 public abstract Task <ShouldRunTestResult> ShouldRunLeafAsync(
     ValidationContext context,
     PackageRegistrationLeafMetadata database,
     PackageRegistrationLeafMetadata v3);
 public abstract Task <bool> ShouldRunLeafAsync(
     ValidationContext context,
     PackageRegistrationLeafMetadata v2,
     PackageRegistrationLeafMetadata v3);