Skip to content

Commit

Permalink
Remove NuGetOperationType (#5394)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolev92 authored Sep 5, 2023
1 parent f5a29ef commit 4b4255d
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ await _lockService.ExecuteNuGetOperationAsync(() =>
var actionTelemetryEvent = VSTelemetryServiceUtility.GetActionTelemetryEvent(
OperationId.ToString(),
new[] { Project },
NuGetOperationType.Install,
NuGetProjectActionType.Install,
OperationSource.PMC,
startTime,
_status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ await _lockService.ExecuteNuGetOperationAsync(() =>
var actionTelemetryEvent = VSTelemetryServiceUtility.GetActionTelemetryEvent(
OperationId.ToString(),
new[] { Project },
NuGetOperationType.Uninstall,
NuGetProjectActionType.Uninstall,
OperationSource.PMC,
startTime,
_status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ await _lockService.ExecuteNuGetOperationAsync(() =>
var actionTelemetryEvent = VSTelemetryServiceUtility.GetActionTelemetryEvent(
OperationId.ToString(),
new[] { Project },
NuGetOperationType.Update,
NuGetProjectActionType.Update,
OperationSource.PMC,
startTime,
_status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,10 @@ public async Task PerformInstallOrUninstallAsync(
UserAction userAction,
CancellationToken cancellationToken)
{
var operationType = NuGetOperationType.Install;
if (userAction.Action == NuGetProjectActionType.Uninstall)
{
operationType = NuGetOperationType.Uninstall;
}

await PerformActionAsync(
uiService,
userAction,
operationType,
userAction.Action,
(projectManagerService) => GetActionsAsync(
projectManagerService,
uiService,
Expand Down Expand Up @@ -215,7 +209,7 @@ public async Task PerformUpdateAsync(
await PerformActionAsync(
uiService,
userAction: null,
NuGetOperationType.Update,
NuGetProjectActionType.Update,
(projectManagerService) =>
ResolveActionsForUpdateAsync(projectManagerService, uiService, packagesToUpdate, cancellationToken),
cancellationToken);
Expand Down Expand Up @@ -251,7 +245,7 @@ private async Task<IReadOnlyList<ProjectAction>> ResolveActionsForUpdateAsync(
private async Task PerformActionAsync(
INuGetUI uiService,
UserAction? userAction,
NuGetOperationType operationType,
NuGetProjectActionType operationType,
ResolveActionsAsync resolveActionsAsync,
CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -294,7 +288,7 @@ private async Task PerformActionImplAsync(
INuGetProjectManagerService projectManagerService,
INuGetUI uiService,
ResolveActionsAsync resolveActionsAsync,
NuGetOperationType operationType,
NuGetProjectActionType operationType,
UserAction? userAction,
CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -388,7 +382,7 @@ await _lockService.ExecuteNuGetOperationAsync(async () =>
IReadOnlyList<ProjectAction> actions = await resolveActionsAsync(projectManagerService);
IReadOnlyList<PreviewResult> results = await GetPreviewResultsAsync(projectManagerService, actions, userAction, uiService, cancellationToken);

if (operationType == NuGetOperationType.Uninstall)
if (operationType == NuGetProjectActionType.Uninstall)
{
// removed packages don't have version info
removedPackages = results.SelectMany(result => result.Deleted)
Expand Down Expand Up @@ -423,7 +417,7 @@ await _lockService.ExecuteNuGetOperationAsync(async () =>
if (updateCount > 0)
{
// set operation type to update when there are packages being updated
operationType = NuGetOperationType.Update;
operationType = NuGetProjectActionType.Update;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static readonly Lazy<string> NuGetVersion
public static VSActionsTelemetryEvent GetActionTelemetryEvent(
string operationId,
IEnumerable<NuGetProject> projects,
NuGetOperationType operationType,
NuGetProjectActionType operationType,
OperationSource source,
DateTimeOffset startTime,
NuGetOperationStatus status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class VSActionsTelemetryEvent : ActionsTelemetryEvent
public VSActionsTelemetryEvent(
string operationId,
string[] projectIds,
NuGetOperationType operationType,
NuGetProjectActionType operationType,
OperationSource source,
DateTimeOffset startTime,
NuGetOperationStatus status,
Expand Down
16 changes: 0 additions & 16 deletions src/NuGet.Core/NuGet.PackageManagement/NuGetProjectAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@

namespace NuGet.PackageManagement
{
/// <summary>
/// Enum for the type of NuGetProjectAction
/// </summary>
public enum NuGetProjectActionType
{
/// <summary>
/// Install
/// </summary>
Install,

/// <summary>
/// Uninstall
/// </summary>
Uninstall
}

/// <summary>
/// NuGetProjectAction
/// </summary>
Expand Down
26 changes: 26 additions & 0 deletions src/NuGet.Core/NuGet.PackageManagement/NuGetProjectActionType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace NuGet.PackageManagement
{
/// <summary>
/// Enum for the type of NuGetProjectAction
/// </summary>
public enum NuGetProjectActionType
{
/// <summary>
/// Install
/// </summary>
Install,

/// <summary>
/// Uninstall
/// </summary>
Uninstall,

/// <summary>
/// Update
/// </summary>
Update
}
}
6 changes: 0 additions & 6 deletions src/NuGet.Core/NuGet.PackageManagement/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ NuGet.PackageManagement.ActionsExecutedEventArgs
~NuGet.PackageManagement.ActionsExecutedEventArgs.Actions.get -> System.Collections.Generic.IEnumerable<NuGet.PackageManagement.ResolvedAction>
~NuGet.PackageManagement.ActionsExecutedEventArgs.ActionsExecutedEventArgs(System.Collections.Generic.IEnumerable<NuGet.PackageManagement.ResolvedAction> actions) -> void
NuGet.PackageManagement.ActionsTelemetryEvent
~NuGet.PackageManagement.ActionsTelemetryEvent.ActionsTelemetryEvent(string operationId, string[] projectIds, NuGet.PackageManagement.NuGetOperationType operationType, System.DateTimeOffset startTime, NuGet.Common.NuGetOperationStatus status, int packageCount, System.DateTimeOffset endTime, double duration) -> void
NuGet.PackageManagement.ActionsTelemetryEvent.OperationType.get -> NuGet.PackageManagement.NuGetOperationType
NuGet.PackageManagement.AssetsFileMissingStatusChanged
NuGet.PackageManagement.BuildIntegratedProjectAction
~NuGet.PackageManagement.BuildIntegratedProjectAction.BuildIntegratedProjectAction(NuGet.ProjectManagement.NuGetProject project, NuGet.Packaging.Core.PackageIdentity packageIdentity, NuGet.PackageManagement.NuGetProjectActionType nuGetProjectActionType, NuGet.ProjectModel.LockFile originalLockFile, NuGet.Commands.RestoreResultPair restoreResultPair, System.Collections.Generic.IReadOnlyList<NuGet.Protocol.Core.Types.SourceRepository> sources, System.Collections.Generic.IReadOnlyList<NuGet.PackageManagement.NuGetProjectAction> originalActions, NuGet.ProjectManagement.BuildIntegratedInstallationContext installationContext) -> void
Expand Down Expand Up @@ -143,10 +141,6 @@ NuGet.PackageManagement.LogUtility
~NuGet.PackageManagement.NuGetEventArgs<T>
~NuGet.PackageManagement.NuGetEventArgs<T>.Arg.get -> T
~NuGet.PackageManagement.NuGetEventArgs<T>.NuGetEventArgs(T arg) -> void
NuGet.PackageManagement.NuGetOperationType
NuGet.PackageManagement.NuGetOperationType.Install = 0 -> NuGet.PackageManagement.NuGetOperationType
NuGet.PackageManagement.NuGetOperationType.Uninstall = 2 -> NuGet.PackageManagement.NuGetOperationType
NuGet.PackageManagement.NuGetOperationType.Update = 1 -> NuGet.PackageManagement.NuGetOperationType
NuGet.PackageManagement.NuGetPackageManager
NuGet.PackageManagement.NuGetPackageManager.BatchEnd -> System.EventHandler<NuGet.PackageManagement.PackageProjectEventArgs>
NuGet.PackageManagement.NuGetPackageManager.BatchStart -> System.EventHandler<NuGet.PackageManagement.PackageProjectEventArgs>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#nullable enable
NuGet.PackageManagement.ActionsTelemetryEvent.OperationType.get -> NuGet.PackageManagement.NuGetProjectActionType
NuGet.PackageManagement.NuGetProjectActionType.Update = 2 -> NuGet.PackageManagement.NuGetProjectActionType
~NuGet.PackageManagement.ActionsTelemetryEvent.ActionsTelemetryEvent(string operationId, string[] projectIds, NuGet.PackageManagement.NuGetProjectActionType operationType, System.DateTimeOffset startTime, NuGet.Common.NuGetOperationStatus status, int packageCount, System.DateTimeOffset endTime, double duration) -> void
~static NuGet.PackageManagement.PackageReferenceComparer.Instance.get -> NuGet.PackageManagement.PackageReferenceComparer
~static NuGet.PackageManagement.SourceRepositoryComparer.Instance.get -> NuGet.PackageManagement.SourceRepositoryComparer
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ActionsTelemetryEvent : ActionEventBase
public ActionsTelemetryEvent(
string operationId,
string[] projectIds,
NuGetOperationType operationType,
NuGetProjectActionType operationType,
DateTimeOffset startTime,
NuGetOperationStatus status,
int packageCount,
Expand All @@ -26,27 +26,6 @@ public ActionsTelemetryEvent(

public const string NugetActionEventName = "NugetAction";

public NuGetOperationType OperationType => (NuGetOperationType)base[nameof(OperationType)];
}

/// <summary>
/// Define nuget operation type values.
/// </summary>
public enum NuGetOperationType
{
/// <summary>
/// Install package action.
/// </summary>
Install = 0,

/// <summary>
/// Update package action.
/// </summary>
Update = 1,

/// <summary>
/// Uninstall package action.
/// </summary>
Uninstall = 2,
public NuGetProjectActionType OperationType => (NuGetProjectActionType)base[nameof(OperationType)];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public async Task CreateInstallAction_OnInstallingProject_WithNewSourceMapping_D
Assert.NotNull(lastTelemetryEvent);
// expect cancelled action because we mocked just enough objects to emit telemetry
Assert.Equal(NuGetOperationStatus.Cancelled, lastTelemetryEvent[nameof(ActionEventBase.Status)]);
Assert.Equal(NuGetOperationType.Install, lastTelemetryEvent[nameof(ActionsTelemetryEvent.OperationType)]);
Assert.Equal(NuGetProjectActionType.Install, lastTelemetryEvent[nameof(ActionsTelemetryEvent.OperationType)]);
Assert.Equal(isSolutionLevel, lastTelemetryEvent[nameof(VSActionsTelemetryEvent.IsSolutionLevel)]);
Assert.Equal(activeTab, lastTelemetryEvent[nameof(VSActionsTelemetryEvent.Tab)]);
Assert.Equal(expectedPackageWasTransitive, lastTelemetryEvent[nameof(VSActionsTelemetryEvent.PackageToInstallWasTransitive)]);
Expand All @@ -248,7 +248,7 @@ public void AddUiActionEngineTelemetryProperties_AddsVulnerabilityInfo_Succeeds(
var actionTelemetryData = new VSActionsTelemetryEvent(
operationId,
projectIds: new[] { Guid.NewGuid().ToString() },
operationType: NuGetOperationType.Install,
operationType: NuGetProjectActionType.Install,
source: OperationSource.PMC,
startTime: DateTimeOffset.Now.AddSeconds(-1),
status: NuGetOperationStatus.NoOp,
Expand Down Expand Up @@ -323,7 +323,7 @@ public void ActionCreatingSourceMappings_TopLevelCountAndTransitiveCount_AddsVal
var actionTelemetryData = new VSActionsTelemetryEvent(
operationId,
projectIds: new[] { Guid.NewGuid().ToString() },
operationType: NuGetOperationType.Install,
operationType: NuGetProjectActionType.Install,
source: OperationSource.PMC,
startTime: DateTimeOffset.Now.AddSeconds(-1),
status: NuGetOperationStatus.NoOp,
Expand Down Expand Up @@ -483,7 +483,7 @@ public async Task CreateInstallAction_OnInstallingProject_EmitsPkgWasTransitiveT
Assert.NotNull(lastTelemetryEvent);
// expect cancelled action because we mocked just enough objects to emit telemetry
Assert.Equal(NuGetOperationStatus.Cancelled, lastTelemetryEvent[nameof(ActionEventBase.Status)]);
Assert.Equal(NuGetOperationType.Install, lastTelemetryEvent[nameof(ActionsTelemetryEvent.OperationType)]);
Assert.Equal(NuGetProjectActionType.Install, lastTelemetryEvent[nameof(ActionsTelemetryEvent.OperationType)]);
Assert.Equal(isSolutionLevel, lastTelemetryEvent[nameof(VSActionsTelemetryEvent.IsSolutionLevel)]);
Assert.Equal(activeTab, lastTelemetryEvent[nameof(VSActionsTelemetryEvent.Tab)]);
Assert.Equal(expectedPackageWasTransitive, lastTelemetryEvent[nameof(VSActionsTelemetryEvent.PackageToInstallWasTransitive)]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ namespace NuGet.PackageManagement.VisualStudio.Test
public class ActionsTelemetryServiceTests
{
[Theory]
[InlineData(NuGetOperationType.Install, OperationSource.UI)]
[InlineData(NuGetOperationType.Update, OperationSource.UI)]
[InlineData(NuGetOperationType.Uninstall, OperationSource.UI)]
[InlineData(NuGetOperationType.Install, OperationSource.PMC)]
[InlineData(NuGetOperationType.Update, OperationSource.PMC)]
[InlineData(NuGetOperationType.Uninstall, OperationSource.PMC)]
public void ActionsTelemetryService_EmitActionEvent_OperationSucceed(NuGetOperationType operationType, OperationSource source)
[InlineData(NuGetProjectActionType.Install, OperationSource.UI)]
[InlineData(NuGetProjectActionType.Update, OperationSource.UI)]
[InlineData(NuGetProjectActionType.Uninstall, OperationSource.UI)]
[InlineData(NuGetProjectActionType.Install, OperationSource.PMC)]
[InlineData(NuGetProjectActionType.Update, OperationSource.PMC)]
[InlineData(NuGetProjectActionType.Uninstall, OperationSource.PMC)]
public void ActionsTelemetryService_EmitActionEvent_OperationSucceed(NuGetProjectActionType operationType, OperationSource source)
{
// Arrange
var telemetrySession = new Mock<ITelemetrySession>();
Expand Down Expand Up @@ -52,13 +52,13 @@ public void ActionsTelemetryService_EmitActionEvent_OperationSucceed(NuGetOperat
}

[Theory]
[InlineData(NuGetOperationType.Install, OperationSource.UI)]
[InlineData(NuGetOperationType.Update, OperationSource.UI)]
[InlineData(NuGetOperationType.Uninstall, OperationSource.UI)]
[InlineData(NuGetOperationType.Install, OperationSource.PMC)]
[InlineData(NuGetOperationType.Update, OperationSource.PMC)]
[InlineData(NuGetOperationType.Uninstall, OperationSource.PMC)]
public void ActionsTelemetryService_EmitActionEvent_OperationFailed(NuGetOperationType operationType, OperationSource source)
[InlineData(NuGetProjectActionType.Install, OperationSource.UI)]
[InlineData(NuGetProjectActionType.Update, OperationSource.UI)]
[InlineData(NuGetProjectActionType.Uninstall, OperationSource.UI)]
[InlineData(NuGetProjectActionType.Install, OperationSource.PMC)]
[InlineData(NuGetProjectActionType.Update, OperationSource.PMC)]
[InlineData(NuGetProjectActionType.Uninstall, OperationSource.PMC)]
public void ActionsTelemetryService_EmitActionEvent_OperationFailed(NuGetProjectActionType operationType, OperationSource source)
{
// Arrange
var telemetrySession = new Mock<ITelemetrySession>();
Expand Down Expand Up @@ -91,10 +91,10 @@ public void ActionsTelemetryService_EmitActionEvent_OperationFailed(NuGetOperati
}

[Theory]
[InlineData(NuGetOperationType.Install)]
[InlineData(NuGetOperationType.Update)]
[InlineData(NuGetOperationType.Uninstall)]
public void ActionsTelemetryService_EmitActionEvent_OperationNoOp(NuGetOperationType operationType)
[InlineData(NuGetProjectActionType.Install)]
[InlineData(NuGetProjectActionType.Update)]
[InlineData(NuGetProjectActionType.Uninstall)]
public void ActionsTelemetryService_EmitActionEvent_OperationNoOp(NuGetProjectActionType operationType)
{
// Arrange
var telemetrySession = new Mock<ITelemetrySession>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void CreateWithAlternatePackageNavigation_CorrelatesSearchSelectionAndAct
var evtActions = new VSActionsTelemetryEvent(
operationId: It.IsAny<string>(),
projectIds: new[] { Guid.NewGuid().ToString() },
operationType: NuGetOperationType.Install,
operationType: NuGetProjectActionType.Install,
source: OperationSource.PMC,
startTime: DateTimeOffset.Now.AddSeconds(-1),
status: NuGetOperationStatus.NoOp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void VsTelemetrySession_ToVsTelemetryEvent()
var actionTelemetryData = new VSActionsTelemetryEvent(
Guid.NewGuid().ToString(),
projectIds: new[] { Guid.NewGuid().ToString() },
operationType: NuGetOperationType.Install,
operationType: NuGetProjectActionType.Install,
source: OperationSource.UI,
startTime: DateTimeOffset.Now.AddSeconds(-2),
status: NuGetOperationStatus.Failed,
Expand Down

0 comments on commit 4b4255d

Please sign in to comment.