Skip to content

Commit a602ef8

Browse files
committed
Renames
1 parent d1e8aed commit a602ef8

21 files changed

+296
-307
lines changed

src/BuiltInTools/Watch/Process/LaunchSettingsProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal sealed class LaunchSettingsProfile
2525

2626
internal static LaunchSettingsProfile? ReadLaunchProfile(string projectPath, string? launchProfileName, ILogger logger)
2727
{
28-
var launchSettingsPath = LaunchSettingsLocator.TryFindLaunchSettings(projectPath, launchProfileName, (message, isError) =>
28+
var launchSettingsPath = LaunchSettings.TryFindLaunchSettingsFile(projectPath, launchProfileName, (message, isError) =>
2929
{
3030
if (isError)
3131
{

src/Cli/dotnet/Commands/Run/Api/RunApiCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public override RunApiOutput Execute()
112112
msbuildRestoreProperties: ReadOnlyDictionary<string, string>.Empty);
113113

114114
var result = runCommand.ReadLaunchProfileSettings();
115-
var targetCommand = (Utils.Command)runCommand.GetTargetCommand(result.Model, buildCommand.CreateProjectInstance, cachedRunProperties: null);
115+
var targetCommand = (Utils.Command)runCommand.GetTargetCommand(result.Profile, buildCommand.CreateProjectInstance, cachedRunProperties: null);
116116

117117
return new RunApiOutput.RunCommand
118118
{

src/Cli/dotnet/Commands/Run/RunCommand.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,25 @@ public int Execute()
142142
return 1;
143143
}
144144

145-
var launchProfileSettings = ReadLaunchProfileSettings();
146-
if (launchProfileSettings.FailureReason != null)
145+
var launchProfileParseResult = ReadLaunchProfileSettings();
146+
if (launchProfileParseResult.FailureReason != null)
147147
{
148-
Reporter.Error.WriteLine(string.Format(CliCommandStrings.RunCommandExceptionCouldNotApplyLaunchSettings, LaunchProfileParser.GetLaunchProfileDisplayName(LaunchProfile), launchProfileSettings.FailureReason).Bold().Red());
148+
Reporter.Error.WriteLine(string.Format(CliCommandStrings.RunCommandExceptionCouldNotApplyLaunchSettings, LaunchProfileParser.GetLaunchProfileDisplayName(LaunchProfile), launchProfileParseResult.FailureReason).Bold().Red());
149149
}
150150

151151
Func<ProjectCollection, ProjectInstance>? projectFactory = null;
152152
RunProperties? cachedRunProperties = null;
153153
VirtualProjectBuildingCommand? projectBuilder = null;
154154
if (ShouldBuild)
155155
{
156-
if (launchProfileSettings.Model?.DotNetRunMessages == true)
156+
if (launchProfileParseResult.Profile?.DotNetRunMessages == true)
157157
{
158158
Reporter.Output.WriteLine(CliCommandStrings.RunCommandBuilding);
159159
}
160160

161161
EnsureProjectIsBuilt(out projectFactory, out cachedRunProperties, out projectBuilder);
162162
}
163-
else if (EntryPointFileFullPath is not null && launchProfileSettings.Model is not ExecutableLaunchSettings)
163+
else if (EntryPointFileFullPath is not null && launchProfileParseResult.Profile is not ExecutableLaunchProfile)
164164
{
165165
// The entry-point is not used to run the application if the launch profile specifies Executable command.
166166

@@ -173,23 +173,23 @@ public int Execute()
173173
cachedRunProperties = cacheEntry?.Run;
174174
}
175175

176-
var targetCommand = GetTargetCommand(launchProfileSettings.Model, projectFactory, cachedRunProperties);
176+
var targetCommand = GetTargetCommand(launchProfileParseResult.Profile, projectFactory, cachedRunProperties);
177177

178178
// Send telemetry about the run operation
179-
SendRunTelemetry(launchProfileSettings.Model, projectBuilder);
179+
SendRunTelemetry(launchProfileParseResult.Profile, projectBuilder);
180180

181181
// Ignore Ctrl-C for the remainder of the command's execution
182182
Console.CancelKeyPress += (sender, e) => { e.Cancel = true; };
183183

184184
return targetCommand.Execute().ExitCode;
185185
}
186186

187-
internal ICommand GetTargetCommand(LaunchSettings? launchSettings, Func<ProjectCollection, ProjectInstance>? projectFactory, RunProperties? cachedRunProperties)
187+
internal ICommand GetTargetCommand(LaunchProfile? launchSettings, Func<ProjectCollection, ProjectInstance>? projectFactory, RunProperties? cachedRunProperties)
188188
=> launchSettings switch
189189
{
190190
null => GetTargetCommandForProject(launchSettings: null, projectFactory, cachedRunProperties),
191-
ProjectLaunchSettings projectSettings => GetTargetCommandForProject(projectSettings, projectFactory, cachedRunProperties),
192-
ExecutableLaunchSettings executableSettings => GetTargetCommandForExecutable(executableSettings),
191+
ProjectLaunchProfile projectSettings => GetTargetCommandForProject(projectSettings, projectFactory, cachedRunProperties),
192+
ExecutableLaunchProfile executableSettings => GetTargetCommandForExecutable(executableSettings),
193193
_ => throw new InvalidOperationException()
194194
};
195195

@@ -287,7 +287,7 @@ private void ApplySelectedFramework(string? selectedFramework)
287287
}
288288
}
289289

290-
private ICommand GetTargetCommandForExecutable(ExecutableLaunchSettings launchSettings)
290+
private ICommand GetTargetCommandForExecutable(ExecutableLaunchProfile launchSettings)
291291
{
292292
var workingDirectory = launchSettings.WorkingDirectory ?? Path.GetDirectoryName(ProjectOrEntryPointPath);
293293

@@ -304,10 +304,10 @@ private ICommand GetTargetCommandForExecutable(ExecutableLaunchSettings launchSe
304304
return command;
305305
}
306306

307-
private void SetEnvironmentVariables(ICommand command, LaunchSettings? launchSettings)
307+
private void SetEnvironmentVariables(ICommand command, LaunchProfile? launchSettings)
308308
{
309309
// Handle Project-specific settings
310-
if (launchSettings is ProjectLaunchSettings projectSettings)
310+
if (launchSettings is ProjectLaunchProfile projectSettings)
311311
{
312312
if (!string.IsNullOrEmpty(projectSettings.ApplicationUrl))
313313
{
@@ -332,31 +332,31 @@ private void SetEnvironmentVariables(ICommand command, LaunchSettings? launchSet
332332
}
333333
}
334334

335-
internal LaunchProfileSettings ReadLaunchProfileSettings()
335+
internal LaunchProfileParseResult ReadLaunchProfileSettings()
336336
{
337337
if (NoLaunchProfile)
338338
{
339-
return LaunchProfileSettings.Success(model: null);
339+
return LaunchProfileParseResult.Success(model: null);
340340
}
341341

342342
var launchSettingsPath = ReadCodeFromStdin
343343
? null
344-
: LaunchSettingsLocator.TryFindLaunchSettings(
344+
: LaunchSettings.TryFindLaunchSettingsFile(
345345
projectOrEntryPointFilePath: ProjectFileFullPath ?? EntryPointFileFullPath!,
346346
launchProfile: LaunchProfile,
347347
static (message, isError) => (isError ? Reporter.Error : Reporter.Output).WriteLine(message));
348348

349349
if (launchSettingsPath is null)
350350
{
351-
return LaunchProfileSettings.Success(model: null);
351+
return LaunchProfileParseResult.Success(model: null);
352352
}
353353

354354
if (!RunCommandVerbosity.IsQuiet())
355355
{
356356
Reporter.Output.WriteLine(string.Format(CliCommandStrings.UsingLaunchSettingsFromMessage, launchSettingsPath));
357357
}
358358

359-
return LaunchSettingsManager.ReadProfileSettingsFromFile(launchSettingsPath, LaunchProfile);
359+
return LaunchSettings.ReadProfileSettingsFromFile(launchSettingsPath, LaunchProfile);
360360
}
361361

362362
private void EnsureProjectIsBuilt(out Func<ProjectCollection, ProjectInstance>? projectFactory, out RunProperties? cachedRunProperties, out VirtualProjectBuildingCommand? projectBuilder)
@@ -438,7 +438,7 @@ private MSBuildArgs SetupSilentBuildArgs(MSBuildArgs msbuildArgs)
438438
}
439439
}
440440

441-
private ICommand GetTargetCommandForProject(ProjectLaunchSettings? launchSettings, Func<ProjectCollection, ProjectInstance>? projectFactory, RunProperties? cachedRunProperties)
441+
private ICommand GetTargetCommandForProject(ProjectLaunchProfile? launchSettings, Func<ProjectCollection, ProjectInstance>? projectFactory, RunProperties? cachedRunProperties)
442442
{
443443
ICommand command;
444444
if (cachedRunProperties != null)
@@ -844,7 +844,7 @@ public static ParseResult ModifyParseResultForShorthandProjectOption(ParseResult
844844
/// Sends telemetry about the run operation.
845845
/// </summary>
846846
private void SendRunTelemetry(
847-
LaunchSettings? launchSettings,
847+
LaunchProfile? launchSettings,
848848
VirtualProjectBuildingCommand? projectBuilder)
849849
{
850850
try
@@ -872,7 +872,7 @@ private void SendRunTelemetry(
872872
/// Builds and sends telemetry data for file-based app runs.
873873
/// </summary>
874874
private void SendFileBasedTelemetry(
875-
LaunchSettings? launchSettings,
875+
LaunchProfile? launchSettings,
876876
VirtualProjectBuildingCommand projectBuilder)
877877
{
878878
Debug.Assert(EntryPointFileFullPath != null);
@@ -901,7 +901,7 @@ private void SendFileBasedTelemetry(
901901
/// <summary>
902902
/// Builds and sends telemetry data for project-based app runs.
903903
/// </summary>
904-
private void SendProjectBasedTelemetry(LaunchSettings? launchSettings)
904+
private void SendProjectBasedTelemetry(LaunchProfile? launchSettings)
905905
{
906906
Debug.Assert(ProjectFileFullPath != null);
907907
var projectIdentifier = RunTelemetry.GetProjectBasedIdentifier(ProjectFileFullPath, GetRepositoryRoot(), Sha256Hasher.Hash);

src/Cli/dotnet/Commands/Run/RunTelemetry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void TrackRunEvent(
3535
string projectIdentifier,
3636
string? launchProfile = null,
3737
bool noLaunchProfile = false,
38-
LaunchSettings? launchSettings = null,
38+
LaunchProfile? launchSettings = null,
3939
int sdkCount = 1,
4040
int packageReferenceCount = 0,
4141
int projectReferenceCount = 0,

src/Cli/dotnet/Commands/Test/MTP/Models.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ public bool MoveNext()
111111
}
112112
}
113113

114-
internal sealed record TestModule(RunProperties RunProperties, string? ProjectFullPath, string? TargetFramework, bool IsTestingPlatformApplication, LaunchSettings? LaunchSettings, string TargetPath, string? DotnetRootArchVariableName);
114+
internal sealed record TestModule(RunProperties RunProperties, string? ProjectFullPath, string? TargetFramework, bool IsTestingPlatformApplication, LaunchProfile? LaunchSettings, string TargetPath, string? DotnetRootArchVariableName);

src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,17 @@ static RunProperties GetRunProperties(ProjectInstance project)
371371
}
372372
}
373373

374-
private static LaunchSettings? TryGetLaunchProfileSettings(string projectDirectory, string projectNameWithoutExtension, string appDesignerFolder, BuildOptions buildOptions, string? profileName)
374+
private static LaunchProfile? TryGetLaunchProfileSettings(string projectDirectory, string projectNameWithoutExtension, string appDesignerFolder, BuildOptions buildOptions, string? profileName)
375375
{
376376
if (buildOptions.NoLaunchProfile)
377377
{
378378
return null;
379379
}
380380

381-
var launchSettingsPath = LaunchSettingsLocator.GetPropertiesLaunchSettingsPath(projectDirectory, appDesignerFolder);
381+
var launchSettingsPath = LaunchSettings.GetPropertiesLaunchSettingsPath(projectDirectory, appDesignerFolder);
382382
bool hasLaunchSettings = File.Exists(launchSettingsPath);
383383

384-
var runJsonPath = LaunchSettingsLocator.GetFlatLaunchSettingsPath(projectDirectory, projectNameWithoutExtension);
384+
var runJsonPath = LaunchSettings.GetFlatLaunchSettingsPath(projectDirectory, projectNameWithoutExtension);
385385
bool hasRunJson = File.Exists(runJsonPath);
386386

387387
if (hasLaunchSettings)
@@ -406,13 +406,13 @@ static RunProperties GetRunProperties(ProjectInstance project)
406406
Reporter.Output.WriteLine(string.Format(CliCommandStrings.UsingLaunchSettingsFromMessage, launchSettingsPath));
407407
}
408408

409-
var result = LaunchSettingsManager.ReadProfileSettingsFromFile(launchSettingsPath, profileName);
409+
var result = LaunchSettings.ReadProfileSettingsFromFile(launchSettingsPath, profileName);
410410
if (!result.Successful)
411411
{
412412
Reporter.Error.WriteLine(string.Format(CliCommandStrings.RunCommandExceptionCouldNotApplyLaunchSettings, profileName, result.FailureReason).Bold().Red());
413413
return null;
414414
}
415415

416-
return result.Model;
416+
return result.Profile;
417417
}
418418
}

src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private ProcessStartInfo CreateProcessStartInfo()
104104
processStartInfo.WorkingDirectory = Module.RunProperties.WorkingDirectory;
105105
}
106106

107-
if (Module.LaunchSettings is ProjectLaunchSettings)
107+
if (Module.LaunchSettings is ProjectLaunchProfile)
108108
{
109109
foreach (var entry in Module.LaunchSettings.EnvironmentVariables)
110110
{

src/Microsoft.DotNet.ProjectTools/LaunchSettings/ExecutableLaunchSettings.cs renamed to src/Microsoft.DotNet.ProjectTools/LaunchSettings/ExecutableLaunchProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Microsoft.DotNet.ProjectTools;
55

6-
public sealed class ExecutableLaunchSettings : LaunchSettings
6+
public sealed class ExecutableLaunchProfile : LaunchProfile
77
{
88
public const string WorkingDirectoryPropertyName = "workingDirectory";
99
public const string ExecutablePathPropertyName = "executablePath";

src/Microsoft.DotNet.ProjectTools/LaunchSettings/ExecutableLaunchSettingsParser.cs renamed to src/Microsoft.DotNet.ProjectTools/LaunchSettings/ExecutableLaunchProfileParser.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Microsoft.DotNet.ProjectTools;
99

10-
internal sealed class ExecutableLaunchSettingsParser : LaunchProfileParser
10+
internal sealed class ExecutableLaunchProfileParser : LaunchProfileParser
1111
{
1212
private sealed class Json
1313
{
@@ -32,35 +32,35 @@ private sealed class Json
3232

3333
public const string CommandName = "Executable";
3434

35-
public static readonly ExecutableLaunchSettingsParser Instance = new();
35+
public static readonly ExecutableLaunchProfileParser Instance = new();
3636

37-
private ExecutableLaunchSettingsParser()
37+
private ExecutableLaunchProfileParser()
3838
{
3939
}
4040

41-
public override LaunchProfileSettings ParseProfile(string launchSettingsPath, string? launchProfileName, string json)
41+
public override LaunchProfileParseResult ParseProfile(string launchSettingsPath, string? launchProfileName, string json)
4242
{
4343
var profile = JsonSerializer.Deserialize<Json>(json);
4444
if (profile == null)
4545
{
46-
return LaunchProfileSettings.Failure(Resources.LaunchProfileIsNotAJsonObject);
46+
return LaunchProfileParseResult.Failure(Resources.LaunchProfileIsNotAJsonObject);
4747
}
4848

4949
if (profile.ExecutablePath == null)
5050
{
51-
return LaunchProfileSettings.Failure(
51+
return LaunchProfileParseResult.Failure(
5252
string.Format(
5353
Resources.LaunchProfile0IsMissingProperty1,
5454
LaunchProfileParser.GetLaunchProfileDisplayName(launchProfileName),
55-
ExecutableLaunchSettings.ExecutablePathPropertyName));
55+
ExecutableLaunchProfile.ExecutablePathPropertyName));
5656
}
5757

5858
if (!TryParseWorkingDirectory(launchSettingsPath, profile.WorkingDirectory, out var workingDirectory, out var error))
5959
{
60-
return LaunchProfileSettings.Failure(error);
60+
return LaunchProfileParseResult.Failure(error);
6161
}
6262

63-
return LaunchProfileSettings.Success(new ExecutableLaunchSettings
63+
return LaunchProfileParseResult.Success(new ExecutableLaunchProfile
6464
{
6565
LaunchProfileName = launchProfileName,
6666
ExecutablePath = ExpandVariables(profile.ExecutablePath),
@@ -91,7 +91,7 @@ private static bool TryParseWorkingDirectory(string launchSettingsPath, string?
9191
catch
9292
{
9393
workingDirectory = null;
94-
error = string.Format(Resources.Path0SpecifiedIn1IsInvalid, expandedValue, ExecutableLaunchSettings.WorkingDirectoryPropertyName);
94+
error = string.Format(Resources.Path0SpecifiedIn1IsInvalid, expandedValue, ExecutableLaunchProfile.WorkingDirectoryPropertyName);
9595
return false;
9696
}
9797
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Collections.Immutable;
5+
6+
namespace Microsoft.DotNet.ProjectTools;
7+
8+
public abstract class LaunchProfile
9+
{
10+
public string? LaunchProfileName { get; init; }
11+
12+
public bool DotNetRunMessages { get; init; }
13+
14+
public string? CommandLineArgs { get; init; }
15+
16+
public required ImmutableDictionary<string, string> EnvironmentVariables { get; init; }
17+
}

0 commit comments

Comments
 (0)