Skip to content
Open
Prev Previous commit
Next Next commit
Renames and moves
  • Loading branch information
tmat committed Dec 11, 2025
commit 6eece51fc5fa10bb064267bada599b6a1ea12e9c
22 changes: 11 additions & 11 deletions src/Cli/dotnet/Commands/Run/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public int Execute()

EnsureProjectIsBuilt(out projectFactory, out cachedRunProperties, out projectBuilder);
}
else if (EntryPointFileFullPath is not null && launchProfileSettings.Model is not ExecutableLaunchSettingsModel)
else if (EntryPointFileFullPath is not null && launchProfileSettings.Model is not ExecutableLaunchSettings)
{
// The entry-point is not used to run the application if the launch profile specifies Executable command.

Expand All @@ -184,12 +184,12 @@ public int Execute()
return targetCommand.Execute().ExitCode;
}

internal ICommand GetTargetCommand(LaunchSettingsModel? launchSettings, Func<ProjectCollection, ProjectInstance>? projectFactory, RunProperties? cachedRunProperties)
internal ICommand GetTargetCommand(LaunchSettings? launchSettings, Func<ProjectCollection, ProjectInstance>? projectFactory, RunProperties? cachedRunProperties)
=> launchSettings switch
{
null => GetTargetCommandForProject(launchSettings: null, projectFactory, cachedRunProperties),
ProjectLaunchSettingsModel projectSettings => GetTargetCommandForProject(projectSettings, projectFactory, cachedRunProperties),
ExecutableLaunchSettingsModel executableSettings => GetTargetCommandForExecutable(executableSettings),
ProjectLaunchSettings projectSettings => GetTargetCommandForProject(projectSettings, projectFactory, cachedRunProperties),
ExecutableLaunchSettings executableSettings => GetTargetCommandForExecutable(executableSettings),
_ => throw new InvalidOperationException()
};

Expand Down Expand Up @@ -287,7 +287,7 @@ private void ApplySelectedFramework(string? selectedFramework)
}
}

private ICommand GetTargetCommandForExecutable(ExecutableLaunchSettingsModel launchSettings)
private ICommand GetTargetCommandForExecutable(ExecutableLaunchSettings launchSettings)
{
var workingDirectory = launchSettings.WorkingDirectory ?? Path.GetDirectoryName(ProjectOrEntryPointPath);

Expand All @@ -304,10 +304,10 @@ private ICommand GetTargetCommandForExecutable(ExecutableLaunchSettingsModel lau
return command;
}

private void SetEnvironmentVariables(ICommand command, LaunchSettingsModel? launchSettings)
private void SetEnvironmentVariables(ICommand command, LaunchSettings? launchSettings)
{
// Handle Project-specific settings
if (launchSettings is ProjectLaunchSettingsModel projectSettings)
if (launchSettings is ProjectLaunchSettings projectSettings)
{
if (!string.IsNullOrEmpty(projectSettings.ApplicationUrl))
{
Expand Down Expand Up @@ -438,7 +438,7 @@ private MSBuildArgs SetupSilentBuildArgs(MSBuildArgs msbuildArgs)
}
}

private ICommand GetTargetCommandForProject(ProjectLaunchSettingsModel? launchSettings, Func<ProjectCollection, ProjectInstance>? projectFactory, RunProperties? cachedRunProperties)
private ICommand GetTargetCommandForProject(ProjectLaunchSettings? launchSettings, Func<ProjectCollection, ProjectInstance>? projectFactory, RunProperties? cachedRunProperties)
{
ICommand command;
if (cachedRunProperties != null)
Expand Down Expand Up @@ -844,7 +844,7 @@ public static ParseResult ModifyParseResultForShorthandProjectOption(ParseResult
/// Sends telemetry about the run operation.
/// </summary>
private void SendRunTelemetry(
LaunchSettingsModel? launchSettings,
LaunchSettings? launchSettings,
VirtualProjectBuildingCommand? projectBuilder)
{
try
Expand Down Expand Up @@ -872,7 +872,7 @@ private void SendRunTelemetry(
/// Builds and sends telemetry data for file-based app runs.
/// </summary>
private void SendFileBasedTelemetry(
LaunchSettingsModel? launchSettings,
LaunchSettings? launchSettings,
VirtualProjectBuildingCommand projectBuilder)
{
Debug.Assert(EntryPointFileFullPath != null);
Expand Down Expand Up @@ -901,7 +901,7 @@ private void SendFileBasedTelemetry(
/// <summary>
/// Builds and sends telemetry data for project-based app runs.
/// </summary>
private void SendProjectBasedTelemetry(LaunchSettingsModel? launchSettings)
private void SendProjectBasedTelemetry(LaunchSettings? launchSettings)
{
Debug.Assert(ProjectFileFullPath != null);
var projectIdentifier = RunTelemetry.GetProjectBasedIdentifier(ProjectFileFullPath, GetRepositoryRoot(), Sha256Hasher.Hash);
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Run/RunTelemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void TrackRunEvent(
string projectIdentifier,
string? launchProfile = null,
bool noLaunchProfile = false,
LaunchSettingsModel? launchSettings = null,
LaunchSettings? launchSettings = null,
int sdkCount = 1,
int packageReferenceCount = 0,
int projectReferenceCount = 0,
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Test/MTP/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ public bool MoveNext()
}
}

internal sealed record TestModule(RunProperties RunProperties, string? ProjectFullPath, string? TargetFramework, bool IsTestingPlatformApplication, LaunchSettingsModel? LaunchSettings, string TargetPath, string? DotnetRootArchVariableName);
internal sealed record TestModule(RunProperties RunProperties, string? ProjectFullPath, string? TargetFramework, bool IsTestingPlatformApplication, LaunchSettings? LaunchSettings, string TargetPath, string? DotnetRootArchVariableName);
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ static RunProperties GetRunProperties(ProjectInstance project)
}
}

private static LaunchSettingsModel? TryGetLaunchProfileSettings(string projectDirectory, string projectNameWithoutExtension, string appDesignerFolder, BuildOptions buildOptions, string? profileName)
private static LaunchSettings? TryGetLaunchProfileSettings(string projectDirectory, string projectNameWithoutExtension, string appDesignerFolder, BuildOptions buildOptions, string? profileName)
{
if (buildOptions.NoLaunchProfile)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private ProcessStartInfo CreateProcessStartInfo()
processStartInfo.WorkingDirectory = Module.RunProperties.WorkingDirectory;
}

if (Module.LaunchSettings is ProjectLaunchSettingsModel)
if (Module.LaunchSettings is ProjectLaunchSettings)
{
foreach (var entry in Module.LaunchSettings.EnvironmentVariables)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.DotNet.ProjectTools;

public sealed class ExecutableLaunchSettingsModel : LaunchSettingsModel
public sealed class ExecutableLaunchSettings : LaunchSettings
{
public const string WorkingDirectoryPropertyName = "workingDirectory";
public const string ExecutablePathPropertyName = "executablePath";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@

using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Microsoft.DotNet.ProjectTools;

internal sealed class ExecutableLaunchSettingsParser : LaunchProfileParser
{
private sealed class Json
{
[JsonPropertyName("commandName")]
public string? CommandName { get; set; }

[JsonPropertyName("executablePath")]
public string? ExecutablePath { get; set; }

[JsonPropertyName("commandLineArgs")]
public string? CommandLineArgs { get; set; }

[JsonPropertyName("workingDirectory")]
public string? WorkingDirectory { get; set; }

[JsonPropertyName("dotnetRunMessages")]
public bool DotNetRunMessages { get; set; }

[JsonPropertyName("environmentVariables")]
public Dictionary<string, string>? EnvironmentVariables { get; set; }
}

public const string CommandName = "Executable";

public static readonly ExecutableLaunchSettingsParser Instance = new();
Expand All @@ -18,7 +40,7 @@ private ExecutableLaunchSettingsParser()

public override LaunchProfileSettings ParseProfile(string launchSettingsPath, string? launchProfileName, string json)
{
var profile = JsonSerializer.Deserialize<ExecutableLaunchProfileJson>(json);
var profile = JsonSerializer.Deserialize<Json>(json);
if (profile == null)
{
return LaunchProfileSettings.Failure(Resources.LaunchProfileIsNotAJsonObject);
Expand All @@ -30,15 +52,15 @@ public override LaunchProfileSettings ParseProfile(string launchSettingsPath, st
string.Format(
Resources.LaunchProfile0IsMissingProperty1,
LaunchProfileParser.GetLaunchProfileDisplayName(launchProfileName),
ExecutableLaunchSettingsModel.ExecutablePathPropertyName));
ExecutableLaunchSettings.ExecutablePathPropertyName));
}

if (!TryParseWorkingDirectory(launchSettingsPath, profile.WorkingDirectory, out var workingDirectory, out var error))
{
return LaunchProfileSettings.Failure(error);
}

return LaunchProfileSettings.Success(new ExecutableLaunchSettingsModel
return LaunchProfileSettings.Success(new ExecutableLaunchSettings
{
LaunchProfileName = launchProfileName,
ExecutablePath = ExpandVariables(profile.ExecutablePath),
Expand Down Expand Up @@ -69,7 +91,7 @@ private static bool TryParseWorkingDirectory(string launchSettingsPath, string?
catch
{
workingDirectory = null;
error = string.Format(Resources.Path0SpecifiedIn1IsInvalid, expandedValue, ExecutableLaunchSettingsModel.WorkingDirectoryPropertyName);
error = string.Format(Resources.Path0SpecifiedIn1IsInvalid, expandedValue, ExecutableLaunchSettings.WorkingDirectoryPropertyName);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public sealed class LaunchProfileSettings
{
public string? FailureReason { get; }

public LaunchSettingsModel? Model { get; }
public LaunchSettings? Model { get; }

private LaunchProfileSettings(string? failureReason, LaunchSettingsModel? launchSettings)
private LaunchProfileSettings(string? failureReason, LaunchSettings? launchSettings)
{
FailureReason = failureReason;
Model = launchSettings;
Expand All @@ -24,6 +24,6 @@ public bool Successful
public static LaunchProfileSettings Failure(string reason)
=> new(reason, launchSettings: null);

public static LaunchProfileSettings Success(LaunchSettingsModel? model)
public static LaunchProfileSettings Success(LaunchSettings? model)
=> new(failureReason: null, launchSettings: model);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.DotNet.ProjectTools;

public abstract class LaunchSettingsModel
public abstract class LaunchSettings
{
public string? LaunchProfileName { get; init; }

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.DotNet.ProjectTools;

public sealed class ProjectLaunchSettingsModel : LaunchSettingsModel
public sealed class ProjectLaunchSettings : LaunchSettings
{
public bool LaunchBrowser { get; init; }
public string? LaunchUrl { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,36 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json;
using System.Text.Json.Serialization;

namespace Microsoft.DotNet.ProjectTools;

internal sealed class ProjectLaunchSettingsParser : LaunchProfileParser
{
internal sealed class Json
{
[JsonPropertyName("commandName")]
public string? CommandName { get; set; }

[JsonPropertyName("commandLineArgs")]
public string? CommandLineArgs { get; set; }

[JsonPropertyName("launchBrowser")]
public bool LaunchBrowser { get; set; }

[JsonPropertyName("launchUrl")]
public string? LaunchUrl { get; set; }

[JsonPropertyName("applicationUrl")]
public string? ApplicationUrl { get; set; }

[JsonPropertyName("dotnetRunMessages")]
public bool DotNetRunMessages { get; set; }

[JsonPropertyName("environmentVariables")]
public Dictionary<string, string>? EnvironmentVariables { get; set; }
}

public const string CommandName = "Project";

public static readonly ProjectLaunchSettingsParser Instance = new();
Expand All @@ -17,13 +42,13 @@ private ProjectLaunchSettingsParser()

public override LaunchProfileSettings ParseProfile(string launchSettingsPath, string? launchProfileName, string json)
{
var profile = JsonSerializer.Deserialize<ProjectLaunchProfileJson>(json);
var profile = JsonSerializer.Deserialize<Json>(json);
if (profile == null)
{
return LaunchProfileSettings.Failure(Resources.LaunchProfileIsNotAJsonObject);
}

return LaunchProfileSettings.Success(new ProjectLaunchSettingsModel
return LaunchProfileSettings.Success(new ProjectLaunchSettings
{
LaunchProfileName = launchProfileName,
CommandLineArgs = ParseCommandLineArgs(profile.CommandLineArgs),
Expand Down
6 changes: 3 additions & 3 deletions test/dotnet.Tests/CommandTests/Run/RunCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void Executable_DefaultWorkingDirectory()
var launchSettingsPath = Path.Combine(dir, "launchSettings.json");
var projectPath = Path.Combine(dir, "myproj.csproj");

var model = new ExecutableLaunchSettingsModel()
var model = new ExecutableLaunchSettings()
{
LaunchProfileName = "MyProfile",
ExecutablePath = "executable",
Expand All @@ -103,7 +103,7 @@ public void Executable_NoLaunchProfileArguments()
var launchSettingsPath = Path.Combine(dir, "launchSettings.json");
var projectPath = Path.Combine(dir, "myproj.csproj");

var model = new ExecutableLaunchSettingsModel()
var model = new ExecutableLaunchSettings()
{
LaunchProfileName = "MyProfile",
CommandLineArgs = "arg1 arg2",
Expand All @@ -126,7 +126,7 @@ public void Executable_ApplicationArguments()
var launchSettingsPath = Path.Combine(dir, "launchSettings.json");
var projectPath = Path.Combine(dir, "myproj.csproj");

var model = new ExecutableLaunchSettingsModel()
var model = new ExecutableLaunchSettings()
{
LaunchProfileName = "MyProfile",
CommandLineArgs = "arg1 arg2",
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet.Tests/CommandTests/Run/RunTelemetryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void TrackRunEvent_WithDefaultLaunchProfile_MarksTelemetryCorrectly()

TelemetryEventEntry.EntryPosted += handler;

var launchSettings = new ProjectLaunchSettingsModel
var launchSettings = new ProjectLaunchSettings
{
LaunchProfileName = "(Default)",
EnvironmentVariables = [],
Expand Down
4 changes: 2 additions & 2 deletions test/dotnet.Tests/ProjectTools/LaunchSettingsParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void EnvironmentVariableExpansion_Executable()
}
""");

var model = Assert.IsType<ExecutableLaunchSettingsModel>(settings.Model);
var model = Assert.IsType<ExecutableLaunchSettings>(settings.Model);

Assert.Equal("../path/ENV_VALUE1/executable", model.ExecutablePath);
Assert.Equal(Path.Combine(root, "ENV_VALUE1"), model.WorkingDirectory);
Expand Down Expand Up @@ -143,7 +143,7 @@ public void EnvironmentVariableExpansion_Project()
}
""");

var model = Assert.IsType<ProjectLaunchSettingsModel>(settings.Model);
var model = Assert.IsType<ProjectLaunchSettings>(settings.Model);

Assert.Equal("arg1 ENV_VALUE1 arg3", model.CommandLineArgs);
Assert.Equal(
Expand Down