Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename types/variables in the product/test code to reflect package source mapping #4281

Merged
merged 16 commits into from
Sep 28, 2021
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ private async Task PerformV2RestoreAsync(string packagesConfigFilePath, string i
Console)
};

PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(Settings);
PackageSourceMappingConfiguration packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(Settings);

var downloadContext = new PackageDownloadContext(cacheContext, installPath, DirectDownload, packageNamespacesConfiguration)
var downloadContext = new PackageDownloadContext(cacheContext, installPath, DirectDownload, packageSourceMappingConfiguration)
{
ClientPolicyContext = clientPolicyContext
};
Expand Down Expand Up @@ -371,9 +371,9 @@ private async Task InstallPackageAsync(
resolutionContext.SourceCacheContext.NoCache = NoCache;
resolutionContext.SourceCacheContext.DirectDownload = DirectDownload;

PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(Settings);
PackageSourceMappingConfiguration packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(Settings);

var downloadContext = new PackageDownloadContext(resolutionContext.SourceCacheContext, installPath, DirectDownload, packageNamespacesConfiguration)
var downloadContext = new PackageDownloadContext(resolutionContext.SourceCacheContext, installPath, DirectDownload, packageSourceMappingConfiguration)
{
ClientPolicyContext = clientPolicyContext
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ private async Task<IReadOnlyList<RestoreSummary>> PerformNuGetV2RestoreAsync(Pac
cacheContext.NoCache = NoCache;
cacheContext.DirectDownload = DirectDownload;

PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(Settings);
PackageSourceMappingConfiguration packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(Settings);

var downloadContext = new PackageDownloadContext(cacheContext, packagesFolderPath, DirectDownload, packageNamespacesConfiguration)
var downloadContext = new PackageDownloadContext(cacheContext, packagesFolderPath, DirectDownload, packageSourceMappingConfiguration)
{
ClientPolicyContext = clientPolicyContext
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ internal static class PackageSourceMappingUtility
{
public static bool IsMappingEnabled(ISettings settings)
{
var packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(settings);
bool isMappingEnabled = packageNamespacesConfiguration?.AreNamespacesEnabled ?? false;
var packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(settings);
bool isMappingEnabled = packageSourceMappingConfiguration?.IsEnabled ?? false;
return isMappingEnabled;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ await projectManagerService.ExecuteActionsAsync(
uiService.Projects,
cancellationToken)).ToArray();

var packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(uiService.Settings);
bool isPackageSourceMappingEnabled = packageNamespacesConfiguration?.AreNamespacesEnabled ?? false;
var packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(uiService.Settings);
bool isPackageSourceMappingEnabled = packageSourceMappingConfiguration?.IsEnabled ?? false;
var actionTelemetryEvent = new VSActionsTelemetryEvent(
uiService.ProjectContext.OperationId.ToString(),
projectIds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ private async Task RestoreAsync(bool forceRestore, RestoreOperationSource restor
_packageRestoreManager.PackageRestoreFailedEvent += PackageRestoreManager_PackageRestoreFailedEvent;

var sources = _sourceRepositoryProvider.GetRepositories();
PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(_settings);
PackageSourceMappingConfiguration packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(_settings);

using (var packageSourceTelemetry = new PackageSourceTelemetry(sources, _nuGetProjectContext.OperationId, PackageSourceTelemetry.TelemetryAction.Restore, packageNamespacesConfiguration))
using (var packageSourceTelemetry = new PackageSourceTelemetry(sources, _nuGetProjectContext.OperationId, PackageSourceTelemetry.TelemetryAction.Restore, packageSourceMappingConfiguration))
{
try
{
Expand Down Expand Up @@ -304,8 +304,8 @@ private void EmitRestoreTelemetryEvent(IEnumerable<NuGetProject> projects,
.GroupBy(x => x.ProjectStyle)
.ToDictionary(x => x.Key, y => y.Count());

PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(_settings);
bool isPackageSourceMappingEnabled = packageNamespacesConfiguration?.AreNamespacesEnabled ?? false;
PackageSourceMappingConfiguration packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(_settings);
bool isPackageSourceMappingEnabled = packageSourceMappingConfiguration?.IsEnabled ?? false;

var restoreTelemetryEvent = new RestoreTelemetryEvent(
_nuGetProjectContext.OperationId.ToString(),
Expand Down Expand Up @@ -706,9 +706,9 @@ private async Task RestoreMissingPackagesInSolutionAsync(

using (var cacheContext = new SourceCacheContext())
{
PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(_settings);
PackageSourceMappingConfiguration packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(_settings);

var downloadContext = new PackageDownloadContext(cacheContext, directDownloadDirectory: null, directDownload: false, packageNamespacesConfiguration)
var downloadContext = new PackageDownloadContext(cacheContext, directDownloadDirectory: null, directDownload: false, packageSourceMappingConfiguration)
{
ParentId = _nuGetProjectContext.OperationId,
ClientPolicyContext = ClientPolicyContext.GetClientPolicy(_settings, logger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class PackageSourceTelemetry : IDisposable
private readonly Guid _parentId;
private readonly ConcurrentDictionary<string, ConcurrentDictionary<string, string>> _resourceStringTable;
private readonly string _actionName;
private readonly PackageNamespacesConfiguration _packageNamespacesConfiguration;
private readonly PackageSourceMappingConfiguration _packageSourceMappingConfiguration;

internal const string EventName = "PackageSourceDiagnostics";

Expand All @@ -33,10 +33,10 @@ public enum TelemetryAction
Search
}

public PackageSourceTelemetry(IEnumerable<SourceRepository> sources, Guid parentId, TelemetryAction action, PackageNamespacesConfiguration packageNamespacesConfiguration)
public PackageSourceTelemetry(IEnumerable<SourceRepository> sources, Guid parentId, TelemetryAction action, PackageSourceMappingConfiguration packageSourceMappingConfiguration)
: this(sources, parentId, action)
{
_packageNamespacesConfiguration = packageNamespacesConfiguration;
_packageSourceMappingConfiguration = packageSourceMappingConfiguration;
}

public PackageSourceTelemetry(IEnumerable<SourceRepository> sources, Guid parentId, TelemetryAction action)
Expand Down Expand Up @@ -208,7 +208,7 @@ public async Task SendTelemetryAsync()
sourceRepository = new SourceRepository(new PackageSource(source), Repository.Provider.GetCoreV3());
}

var telemetry = await ToTelemetryAsync(data, sourceRepository, parentId, _actionName, _packageNamespacesConfiguration);
var telemetry = await ToTelemetryAsync(data, sourceRepository, parentId, _actionName, _packageSourceMappingConfiguration);

if (telemetry != null)
{
Expand All @@ -217,7 +217,7 @@ public async Task SendTelemetryAsync()
}
}

internal static async Task<TelemetryEvent> ToTelemetryAsync(Data data, SourceRepository sourceRepository, string parentId, string actionName, PackageNamespacesConfiguration packageNamespacesConfiguration)
internal static async Task<TelemetryEvent> ToTelemetryAsync(Data data, SourceRepository sourceRepository, string parentId, string actionName, PackageSourceMappingConfiguration packageSourceMappingConfiguration)
{
if (data.Resources.Count == 0)
{
Expand All @@ -229,7 +229,7 @@ internal static async Task<TelemetryEvent> ToTelemetryAsync(Data data, SourceRep
TelemetryEvent telemetry;
lock (data._lock)
{
bool isPackageSourceMappingEnabled = packageNamespacesConfiguration?.AreNamespacesEnabled ?? false;
bool isPackageSourceMappingEnabled = packageSourceMappingConfiguration?.IsEnabled ?? false;

telemetry = new TelemetryEvent(EventName,
new Dictionary<string, object>()
Expand Down
4 changes: 2 additions & 2 deletions src/NuGet.Core/NuGet.Build.Tasks/BuildTasksUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,9 @@ private static async Task<RestoreSummary> PerformNuGetV2RestoreAsync(Common.ILog
{
cacheContext.NoCache = noCache;

PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(settings);
PackageSourceMappingConfiguration packageSourceMappingConfiguration = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(settings);

var downloadContext = new PackageDownloadContext(cacheContext, repositoryPath, directDownload: false, packageNamespacesConfiguration)
var downloadContext = new PackageDownloadContext(cacheContext, repositoryPath, directDownload: false, packageSourceMappingConfiguration)
{
ClientPolicyContext = clientPolicyContext
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NuGet.Commands.LockFileBuilder.CreateLockFile(NuGet.ProjectModel.LockFile previousLockFile, NuGet.ProjectModel.PackageSpec project, System.Collections.Generic.IEnumerable<NuGet.Commands.RestoreTargetGraph> targetGraphs, System.Collections.Generic.IReadOnlyList<NuGet.Repositories.NuGetv3LocalRepository> localRepositories, NuGet.DependencyResolver.RemoteWalkContext context, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> NuGet.ProjectModel.LockFile
NuGet.Commands.RestoreRequest.PackageNameSpaces.get -> NuGet.Configuration.PackageNamespacesConfiguration
NuGet.Commands.RestoreRequest.RestoreRequest(NuGet.ProjectModel.PackageSpec project, NuGet.Commands.RestoreCommandProviders dependencyProviders, NuGet.Protocol.Core.Types.SourceCacheContext cacheContext, NuGet.Packaging.Signing.ClientPolicyContext clientPolicyContext, NuGet.Configuration.PackageNamespacesConfiguration packageNamespaces, NuGet.Common.ILogger log, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> void
NuGet.Commands.RestoreRequest.PackageSourceMapping.get -> NuGet.Configuration.PackageSourceMappingConfiguration
NuGet.Commands.RestoreRequest.RestoreRequest(NuGet.ProjectModel.PackageSpec project, NuGet.Commands.RestoreCommandProviders dependencyProviders, NuGet.Protocol.Core.Types.SourceCacheContext cacheContext, NuGet.Packaging.Signing.ClientPolicyContext clientPolicyContext, NuGet.Configuration.PackageSourceMappingConfiguration packageSourceMapping, NuGet.Common.ILogger log, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> void
NuGet.Commands.SignArgs.PackagePaths.get -> System.Collections.Generic.IReadOnlyList<string>
NuGet.Commands.SignArgs.PackagePaths.set -> void
static NuGet.Commands.MSBuildProjectFrameworkUtility.GetProjectFramework(string projectFilePath, string targetFrameworkMoniker, string targetPlatformMoniker, string targetPlatformMinVersion, string clrSupport) -> NuGet.Frameworks.NuGetFramework
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NuGet.Commands.LockFileBuilder.CreateLockFile(NuGet.ProjectModel.LockFile previousLockFile, NuGet.ProjectModel.PackageSpec project, System.Collections.Generic.IEnumerable<NuGet.Commands.RestoreTargetGraph> targetGraphs, System.Collections.Generic.IReadOnlyList<NuGet.Repositories.NuGetv3LocalRepository> localRepositories, NuGet.DependencyResolver.RemoteWalkContext context, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> NuGet.ProjectModel.LockFile
NuGet.Commands.RestoreRequest.PackageNameSpaces.get -> NuGet.Configuration.PackageNamespacesConfiguration
NuGet.Commands.RestoreRequest.RestoreRequest(NuGet.ProjectModel.PackageSpec project, NuGet.Commands.RestoreCommandProviders dependencyProviders, NuGet.Protocol.Core.Types.SourceCacheContext cacheContext, NuGet.Packaging.Signing.ClientPolicyContext clientPolicyContext, NuGet.Configuration.PackageNamespacesConfiguration packageNamespaces, NuGet.Common.ILogger log, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> void
NuGet.Commands.RestoreRequest.PackageSourceMapping.get -> NuGet.Configuration.PackageSourceMappingConfiguration
NuGet.Commands.RestoreRequest.RestoreRequest(NuGet.ProjectModel.PackageSpec project, NuGet.Commands.RestoreCommandProviders dependencyProviders, NuGet.Protocol.Core.Types.SourceCacheContext cacheContext, NuGet.Packaging.Signing.ClientPolicyContext clientPolicyContext, NuGet.Configuration.PackageSourceMappingConfiguration packageSourceMapping, NuGet.Common.ILogger log, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> void
NuGet.Commands.SignArgs.PackagePaths.get -> System.Collections.Generic.IReadOnlyList<string>
NuGet.Commands.SignArgs.PackagePaths.set -> void
static NuGet.Commands.MSBuildProjectFrameworkUtility.GetProjectFramework(string projectFilePath, string targetFrameworkMoniker, string targetPlatformMoniker, string targetPlatformMinVersion, string clrSupport) -> NuGet.Frameworks.NuGetFramework
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NuGet.Commands.LockFileBuilder.CreateLockFile(NuGet.ProjectModel.LockFile previousLockFile, NuGet.ProjectModel.PackageSpec project, System.Collections.Generic.IEnumerable<NuGet.Commands.RestoreTargetGraph> targetGraphs, System.Collections.Generic.IReadOnlyList<NuGet.Repositories.NuGetv3LocalRepository> localRepositories, NuGet.DependencyResolver.RemoteWalkContext context, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> NuGet.ProjectModel.LockFile
NuGet.Commands.RestoreRequest.PackageNameSpaces.get -> NuGet.Configuration.PackageNamespacesConfiguration
NuGet.Commands.RestoreRequest.RestoreRequest(NuGet.ProjectModel.PackageSpec project, NuGet.Commands.RestoreCommandProviders dependencyProviders, NuGet.Protocol.Core.Types.SourceCacheContext cacheContext, NuGet.Packaging.Signing.ClientPolicyContext clientPolicyContext, NuGet.Configuration.PackageNamespacesConfiguration packageNamespaces, NuGet.Common.ILogger log, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> void
NuGet.Commands.RestoreRequest.PackageSourceMapping.get -> NuGet.Configuration.PackageSourceMappingConfiguration
NuGet.Commands.RestoreRequest.RestoreRequest(NuGet.ProjectModel.PackageSpec project, NuGet.Commands.RestoreCommandProviders dependencyProviders, NuGet.Protocol.Core.Types.SourceCacheContext cacheContext, NuGet.Packaging.Signing.ClientPolicyContext clientPolicyContext, NuGet.Configuration.PackageSourceMappingConfiguration packageSourceMapping, NuGet.Common.ILogger log, NuGet.Commands.LockFileBuilderCache lockFileBuilderCache) -> void
NuGet.Commands.SignArgs.PackagePaths.get -> System.Collections.Generic.IReadOnlyList<string>
NuGet.Commands.SignArgs.PackagePaths.set -> void
static NuGet.Commands.MSBuildProjectFrameworkUtility.GetProjectFramework(string projectFilePath, string targetFrameworkMoniker, string targetPlatformMoniker, string targetPlatformMinVersion, string clrSupport) -> NuGet.Frameworks.NuGetFramework
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private RestoreSummaryRequest Create(
var settings = Settings.LoadImmutableSettingsGivenConfigPaths(projectPackageSpec.RestoreMetadata.ConfigFilePaths, settingsLoadingContext);
var sources = restoreArgs.GetEffectiveSources(settings, projectPackageSpec.RestoreMetadata.Sources);
var clientPolicyContext = ClientPolicyContext.GetClientPolicy(settings, restoreArgs.Log);
PackageNamespacesConfiguration namespaces = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(settings);
PackageSourceMappingConfiguration packageSourceMapping = PackageSourceMappingConfiguration.GetPackageSourceMappingConfiguration(settings);

var sharedCache = _providerCache.GetOrCreate(
globalPath,
Expand All @@ -178,7 +178,7 @@ private RestoreSummaryRequest Create(
sharedCache,
restoreArgs.CacheContext,
clientPolicyContext,
namespaces,
packageSourceMapping,
restoreArgs.Log,
_lockFileBuilderCache)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public async Task<RestoreResult> ExecuteAsync(CancellationToken token)
{
telemetry.TelemetryEvent.AddPiiData(ProjectFilePath, _request.Project.FilePath);

bool isPackageSourceMappingEnabled = _request?.PackageNameSpaces.AreNamespacesEnabled ?? false;
bool isPackageSourceMappingEnabled = _request?.PackageSourceMapping.IsEnabled ?? false;
telemetry.TelemetryEvent[PackageSourceMappingIsMappingEnabled] = isPackageSourceMappingEnabled;

_operationId = telemetry.OperationId;
Expand Down Expand Up @@ -1171,7 +1171,7 @@ private static RemoteWalkContext CreateRemoteWalkContext(RestoreRequest request,
{
var context = new RemoteWalkContext(
request.CacheContext,
request.PackageNameSpaces,
request.PackageSourceMapping,
logger);

foreach (var provider in request.DependencyProviders.LocalProviders)
Expand Down
Loading