Skip to content

Commit dafea40

Browse files
nkolev92Copilot
andauthored
Fix telemetry property count assertion after concurrent PR merges (#7317)
PR #7213 added AnyPackageIdContainsNonAlphanumericDotDashOrUnderscoreCharacters telemetry and updated the count from 49 to 50, but PR #7307 had already added TargetFrameworks and TargetFrameworksCount, making the correct count 51. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: nkolev92 <2878341+nkolev92@users.noreply.github.com>
1 parent 45c2eb4 commit dafea40

1 file changed

Lines changed: 129 additions & 55 deletions

File tree

test/NuGet.Core.Tests/NuGet.Commands.Test/RestoreCommandTests/RestoreCommandTests.cs

Lines changed: 129 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,50 +3258,66 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
32583258

32593259
var projectInformationEvent = telemetryEvents.Single(e => e.Name.Equals("ProjectRestoreInformation"));
32603260

3261-
projectInformationEvent.Count.Should().Be(42);
3262-
3263-
projectInformationEvent["RestoreSuccess"].Should().Be(true);
3264-
projectInformationEvent["NoOpResult"].Should().Be(true);
3265-
projectInformationEvent["IsCentralVersionManagementEnabled"].Should().Be(false);
3266-
projectInformationEvent["NoOpCacheFileEvaluationResult"].Should().Be(true);
3267-
projectInformationEvent["NoOpRestoreOutputEvaluationResult"].Should().Be(true);
3268-
projectInformationEvent["NoOpDuration"].Should().NotBeNull();
3269-
projectInformationEvent["TotalUniquePackagesCount"].Should().Be(1);
3270-
projectInformationEvent["NewPackagesInstalledCount"].Should().Be(0);
3271-
projectInformationEvent["NoOpCacheFileEvaluateDuration"].Should().NotBeNull();
3272-
projectInformationEvent["StartTime"].Should().NotBeNull();
3273-
projectInformationEvent["EndTime"].Should().NotBeNull();
3274-
projectInformationEvent["OperationId"].Should().NotBeNull();
3275-
projectInformationEvent["Duration"].Should().NotBeNull();
3276-
projectInformationEvent["NoOpRestoreOutputEvaluationDuration"].Should().NotBeNull();
3277-
projectInformationEvent["NoOpReplayLogsDuration"].Should().NotBeNull();
3278-
projectInformationEvent["PackageSourceMapping.IsMappingEnabled"].Should().Be(false);
3279-
projectInformationEvent["SourcesCount"].Should().Be(1);
3280-
projectInformationEvent["HttpSourcesCount"].Should().Be(0);
3281-
projectInformationEvent["LocalSourcesCount"].Should().Be(1);
3282-
projectInformationEvent["FallbackFoldersCount"].Should().Be(0);
3283-
projectInformationEvent["IsLockFileEnabled"].Should().Be(false);
3284-
projectInformationEvent["NoOpCacheFileAgeDays"].Should().NotBeNull();
3285-
projectInformationEvent["UseLegacyDependencyResolver"].Should().BeOfType<bool>();
3286-
projectInformationEvent["UsedLegacyDependencyResolver"].Should().BeOfType<bool>();
3287-
projectInformationEvent["Audit.Enabled"].Should().BeOfType<string>();
3288-
projectInformationEvent["TargetFrameworks"].Should().Be("net472");
3289-
projectInformationEvent["TargetFrameworksCount"].Should().Be(1);
3290-
projectInformationEvent["RuntimeIdentifiersCount"].Should().Be(0);
3291-
projectInformationEvent["TreatWarningsAsErrors"].Should().Be(true);
3292-
projectInformationEvent["SDKAnalysisLevel"].Should().Be(NuGetVersion.Parse("9.0.100"));
3293-
projectInformationEvent["UsingMicrosoftNETSdk"].Should().Be(true);
3294-
projectInformationEvent["IsPackageInstallationTrigger"].Should().Be(false);
3295-
projectInformationEvent["ForceRestore"].Should().Be(false);
3296-
projectInformationEvent["UpdatedAssetsFile"].Should().Be(false);
3297-
projectInformationEvent["UpdatedMSBuildFiles"].Should().Be(false);
3298-
projectInformationEvent["NETSdkVersion"].Should().Be(NuGetVersion.Parse("10.0.100"));
3299-
projectInformationEvent["Pruning.FrameworksEnabled.Count"].Should().Be(0);
3300-
projectInformationEvent["Pruning.FrameworksDisabled.Count"].Should().Be(0);
3301-
projectInformationEvent["Pruning.FrameworksUnsupported.Count"].Should().Be(1);
3302-
projectInformationEvent["Pruning.DefaultEnabled"].Should().Be(false);
3303-
projectInformationEvent["UsesLegacyPackagesDirectory"].Should().Be(false);
3304-
projectInformationEvent["UsesLegacyAssetTargetFallback"].Should().Be(false);
3261+
var expectedProperties = new Dictionary<string, Action<object>>()
3262+
{
3263+
["RestoreSuccess"] = value => value.Should().Be(true),
3264+
["NoOpResult"] = value => value.Should().Be(true),
3265+
["IsCentralVersionManagementEnabled"] = value => value.Should().Be(false),
3266+
["NoOpCacheFileEvaluationResult"] = value => value.Should().Be(true),
3267+
["NoOpRestoreOutputEvaluationResult"] = value => value.Should().Be(true),
3268+
["NoOpDuration"] = value => value.Should().NotBeNull(),
3269+
["TotalUniquePackagesCount"] = value => value.Should().Be(1),
3270+
["NewPackagesInstalledCount"] = value => value.Should().Be(0),
3271+
["NoOpCacheFileEvaluateDuration"] = value => value.Should().NotBeNull(),
3272+
["StartTime"] = value => value.Should().NotBeNull(),
3273+
["EndTime"] = value => value.Should().NotBeNull(),
3274+
["OperationId"] = value => value.Should().NotBeNull(),
3275+
["Duration"] = value => value.Should().NotBeNull(),
3276+
["NoOpRestoreOutputEvaluationDuration"] = value => value.Should().NotBeNull(),
3277+
["NoOpReplayLogsDuration"] = value => value.Should().NotBeNull(),
3278+
["PackageSourceMapping.IsMappingEnabled"] = value => value.Should().Be(false),
3279+
["SourcesCount"] = value => value.Should().Be(1),
3280+
["HttpSourcesCount"] = value => value.Should().Be(0),
3281+
["LocalSourcesCount"] = value => value.Should().Be(1),
3282+
["FallbackFoldersCount"] = value => value.Should().Be(0),
3283+
["IsLockFileEnabled"] = value => value.Should().Be(false),
3284+
["NoOpCacheFileAgeDays"] = value => value.Should().NotBeNull(),
3285+
["UseLegacyDependencyResolver"] = value => value.Should().BeOfType<bool>(),
3286+
["UsedLegacyDependencyResolver"] = value => value.Should().BeOfType<bool>(),
3287+
["Audit.Enabled"] = value => value.Should().BeOfType<string>(),
3288+
["TargetFrameworks"] = value => value.Should().Be("net472"),
3289+
["TargetFrameworksCount"] = value => value.Should().Be(1),
3290+
["RuntimeIdentifiersCount"] = value => value.Should().Be(0),
3291+
["TreatWarningsAsErrors"] = value => value.Should().Be(true),
3292+
["SDKAnalysisLevel"] = value => value.Should().Be(NuGetVersion.Parse("9.0.100")),
3293+
["UsingMicrosoftNETSdk"] = value => value.Should().Be(true),
3294+
["IsPackageInstallationTrigger"] = value => value.Should().Be(false),
3295+
["ForceRestore"] = value => value.Should().Be(false),
3296+
["UpdatedAssetsFile"] = value => value.Should().Be(false),
3297+
["UpdatedMSBuildFiles"] = value => value.Should().Be(false),
3298+
["NETSdkVersion"] = value => value.Should().Be(NuGetVersion.Parse("10.0.100")),
3299+
["Pruning.FrameworksEnabled.Count"] = value => value.Should().Be(0),
3300+
["Pruning.FrameworksDisabled.Count"] = value => value.Should().Be(0),
3301+
["Pruning.FrameworksUnsupported.Count"] = value => value.Should().Be(1),
3302+
["Pruning.DefaultEnabled"] = value => value.Should().Be(false),
3303+
["UsesLegacyPackagesDirectory"] = value => value.Should().Be(false),
3304+
["UsesLegacyAssetTargetFallback"] = value => value.Should().Be(false),
3305+
};
3306+
3307+
HashSet<string> actualProperties = new();
3308+
foreach (var eventProperty in projectInformationEvent)
3309+
{
3310+
actualProperties.Add(eventProperty.Key);
3311+
}
3312+
3313+
expectedProperties.Keys.Except(actualProperties).Should().BeEmpty();
3314+
actualProperties.Except(expectedProperties.Keys).Should().BeEmpty();
3315+
3316+
foreach (var kvp in expectedProperties)
3317+
{
3318+
object value = projectInformationEvent[kvp.Key];
3319+
kvp.Value(value);
3320+
}
33053321
}
33063322

33073323
[Fact]
@@ -3359,17 +3375,75 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
33593375

33603376
var projectInformationEvent = telemetryEvents.Single(e => e.Name.Equals("ProjectRestoreInformation"));
33613377

3362-
projectInformationEvent.Count.Should().Be(50);
3363-
projectInformationEvent["RestoreSuccess"].Should().Be(true);
3364-
projectInformationEvent["NoOpResult"].Should().Be(false);
3365-
projectInformationEvent["TotalUniquePackagesCount"].Should().Be(2);
3366-
projectInformationEvent["NewPackagesInstalledCount"].Should().Be(1);
3367-
projectInformationEvent["TargetFrameworks"].Should().Be("net472");
3368-
projectInformationEvent["PackageSourceMapping.IsMappingEnabled"].Should().Be(false);
3369-
projectInformationEvent["UpdatedAssetsFile"].Should().Be(true);
3370-
projectInformationEvent["UpdatedMSBuildFiles"].Should().Be(true);
3371-
projectInformationEvent["IsPackageInstallationTrigger"].Should().Be(false);
3372-
projectInformationEvent["ForceRestore"].Should().Be(false);
3378+
var expectedProperties = new Dictionary<string, Action<object>>()
3379+
{
3380+
["RestoreSuccess"] = value => value.Should().Be(true),
3381+
["NoOpResult"] = value => value.Should().Be(false),
3382+
["IsCentralVersionManagementEnabled"] = value => value.Should().Be(false),
3383+
["NoOpCacheFileEvaluationResult"] = value => value.Should().Be(false),
3384+
["IsLockFileEnabled"] = value => value.Should().Be(false),
3385+
["IsLockFileValidForRestore"] = value => value.Should().Be(false),
3386+
["LockFileEvaluationResult"] = value => value.Should().Be(true),
3387+
["NoOpDuration"] = value => value.Should().NotBeNull(),
3388+
["TotalUniquePackagesCount"] = value => value.Should().Be(2),
3389+
["NewPackagesInstalledCount"] = value => value.Should().Be(1),
3390+
["AnyPackageIdContainsNonAlphanumericDotDashOrUnderscoreCharacters"] = value => value.Should().Be(false),
3391+
["EvaluateLockFileDuration"] = value => value.Should().NotBeNull(),
3392+
["CreateRestoreTargetGraphDuration"] = value => value.Should().NotBeNull(),
3393+
["GenerateRestoreGraphDuration"] = value => value.Should().NotBeNull(),
3394+
["CreateRestoreResultDuration"] = value => value.Should().NotBeNull(),
3395+
["WalkFrameworkDependencyDuration"] = value => value.Should().NotBeNull(),
3396+
["GenerateAssetsFileDuration"] = value => value.Should().NotBeNull(),
3397+
["ValidateRestoreGraphsDuration"] = value => value.Should().NotBeNull(),
3398+
["EvaluateDownloadDependenciesDuration"] = value => value.Should().NotBeNull(),
3399+
["NoOpCacheFileEvaluateDuration"] = value => value.Should().NotBeNull(),
3400+
["StartTime"] = value => value.Should().NotBeNull(),
3401+
["EndTime"] = value => value.Should().NotBeNull(),
3402+
["OperationId"] = value => value.Should().NotBeNull(),
3403+
["Duration"] = value => value.Should().NotBeNull(),
3404+
["PackageSourceMapping.IsMappingEnabled"] = value => value.Should().Be(false),
3405+
["SourcesCount"] = value => value.Should().Be(1),
3406+
["HttpSourcesCount"] = value => value.Should().Be(0),
3407+
["LocalSourcesCount"] = value => value.Should().Be(1),
3408+
["FallbackFoldersCount"] = value => value.Should().Be(0),
3409+
["Audit.Enabled"] = value => value.Should().BeOfType<string>(),
3410+
["UseLegacyDependencyResolver"] = value => value.Should().BeOfType<bool>(),
3411+
["UsedLegacyDependencyResolver"] = value => value.Should().BeOfType<bool>(),
3412+
["TargetFrameworks"] = value => value.Should().Be("net472"),
3413+
["TargetFrameworksCount"] = value => value.Should().Be(1),
3414+
["RuntimeIdentifiersCount"] = value => value.Should().Be(0),
3415+
["TreatWarningsAsErrors"] = value => value.Should().Be(false),
3416+
["SDKAnalysisLevel"] = value => value.Should().Be(null),
3417+
["UsingMicrosoftNETSdk"] = value => value.Should().Be(false),
3418+
["IsPackageInstallationTrigger"] = value => value.Should().Be(false),
3419+
["ForceRestore"] = value => value.Should().Be(false),
3420+
["UpdatedAssetsFile"] = value => value.Should().Be(true),
3421+
["UpdatedMSBuildFiles"] = value => value.Should().Be(true),
3422+
["NETSdkVersion"] = value => value.Should().Be(null),
3423+
["Pruning.FrameworksEnabled.Count"] = value => value.Should().BeOfType<int>(),
3424+
["Pruning.FrameworksDisabled.Count"] = value => value.Should().BeOfType<int>(),
3425+
["Pruning.FrameworksUnsupported.Count"] = value => value.Should().BeOfType<int>(),
3426+
["Pruning.DefaultEnabled"] = value => value.Should().BeOfType<bool>(),
3427+
["Pruning.RemovablePackages.Count"] = value => value.Should().BeOfType<int>(),
3428+
["Pruning.Pruned.Direct.Count"] = value => value.Should().BeOfType<int>(),
3429+
["UsesLegacyPackagesDirectory"] = value => value.Should().Be(false),
3430+
["UsesLegacyAssetTargetFallback"] = value => value.Should().Be(false),
3431+
};
3432+
3433+
HashSet<string> actualProperties = new();
3434+
foreach (var eventProperty in projectInformationEvent)
3435+
{
3436+
actualProperties.Add(eventProperty.Key);
3437+
}
3438+
3439+
expectedProperties.Keys.Except(actualProperties).Should().BeEmpty();
3440+
actualProperties.Except(expectedProperties.Keys).Should().BeEmpty();
3441+
3442+
foreach (var kvp in expectedProperties)
3443+
{
3444+
object value = projectInformationEvent[kvp.Key];
3445+
kvp.Value(value);
3446+
}
33733447
}
33743448

33753449
/// A 1.0.0 -> C 1.0.0 -> D 1.1.0

0 commit comments

Comments
 (0)