-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathCacheContext.cs
More file actions
58 lines (53 loc) · 2.7 KB
/
CacheContext.cs
File metadata and controls
58 lines (53 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using Microsoft.Build.FileSystem;
using Microsoft.Build.Graph;
using Microsoft.Build.Shared;
namespace Microsoft.Build.Experimental.ProjectCache
{
/// <summary>
/// Holds various information about the current msbuild execution that the cache might use.
/// The cache may need to know about the top level projects or the entire project graph, so MSBuild
/// provides a graph when one is available. When it isn't available, MSBuild provides the top level projects
/// and the plugin can construct its own graph based on those.
/// So either <see cref="Graph" />is null, or <see cref="GraphEntryPoints" /> is null. But not both.
/// </summary>
[Obsolete("This class was moved to Microsoft.Build.ProjectCache namespace")]
public class CacheContext
{
public IReadOnlyDictionary<string, string> PluginSettings { get; }
public ProjectGraph? Graph { get; }
public IReadOnlyCollection<ProjectGraphEntryPoint>? GraphEntryPoints { get; }
public string? MSBuildExePath { get; }
public MSBuildFileSystemBase FileSystem { get; }
public IReadOnlyCollection<string> RequestedTargets { get; }
public CacheContext(
IReadOnlyDictionary<string, string> pluginSettings,
MSBuildFileSystemBase fileSystem,
ProjectGraph? graph = null,
IReadOnlyCollection<ProjectGraphEntryPoint>? graphEntryPoints = null)
: this(pluginSettings, fileSystem, requestedTargets: [], graph, graphEntryPoints)
{
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Already shipped")]
public CacheContext(
IReadOnlyDictionary<string, string> pluginSettings,
MSBuildFileSystemBase fileSystem,
IReadOnlyCollection<string> requestedTargets,
ProjectGraph? graph = null,
IReadOnlyCollection<ProjectGraphEntryPoint>? graphEntryPoints = null)
{
ErrorUtilities.VerifyThrow(
(graph != null) ^ (graphEntryPoints != null),
"Either Graph is specified, or GraphEntryPoints is specified. Not both.");
PluginSettings = pluginSettings;
Graph = graph;
GraphEntryPoints = graphEntryPoints;
MSBuildExePath = BuildEnvironmentHelper.Instance.CurrentMSBuildExePath;
FileSystem = fileSystem;
RequestedTargets = requestedTargets;
}
}
}