Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"VSProjectQueryAPISample.AddFileCommand.DisplayName": "Add File",
"VSProjectQueryAPISample.CreateFileCommand.DisplayName": "Create File",
"VSProjectQueryAPISample.AddSolutionConfigurationCommand.DisplayName": "Add Solution Configuration",
"VSProjectQueryAPISample.DeleteSolutionConfigurationCommand.DisplayName": "Delete Solution Configuration",
"VSProjectQueryAPISample.MoveFileCommand.DisplayName": "Move File",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ public class AddSolutionConfigurationCommand : Command
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
{
WorkspacesExtensibility querySpace = this.Extensibility.Workspaces();
const string solutionName = "ConsoleApp32";

var queryResults = await querySpace.QuerySolutionAsync(
solution => solution.With(solution => solution.BaseName),
cancellationToken);

var solutionName = queryResults.First().BaseName;

await querySpace.UpdateSolutionAsync(
solution => solution.Where(solution => solution.BaseName == solutionName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace VSProjectQueryAPISample;
/// A sample command for adding a file.
/// </summary>
[VisualStudioContribution]
public class AddFileCommand : Command
public class CreateFileCommand : Command
{
/// <inheritdoc />
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.AddFileCommand.DisplayName%")
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.CreateFileCommand.DisplayName%")
{
Placements = [CommandPlacement.KnownPlacements.ToolsMenu],
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
Expand All @@ -28,7 +28,7 @@ public override async Task ExecuteCommandAsync(IClientContext context, Cancellat

await querySpace.UpdateProjectsAsync(
project => project.Where(project => project.Name == "ConsoleApp1"),
project => project.AddFile("CreatedFile.txt"),
project => project.CreateFile("CreatedFile.txt"),
cancellationToken);

await this.Extensibility.Shell().ShowPromptAsync("Created new file in ConsoleApp1.", PromptOptions.OK, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ public class DeleteSolutionConfigurationCommand : Command
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
{
WorkspacesExtensibility querySpace = this.Extensibility.Workspaces();
const string solutionName = "ConsoleApp32";

var queryResults = await querySpace.QuerySolutionAsync(
solution => solution.With(solution => solution.BaseName),
cancellationToken);

var solutionName = queryResults.First().BaseName;

await querySpace.UpdateSolutionAsync(
solution => solution.Where(solution => solution.BaseName == solutionName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public MoveFileCommand(TraceSource traceSource)
// Use this object initializer to set optional parameters for the command. The required parameter,
// displayName, is set above. To localize the displayName, add an entry in .vsextension\string-resources.json
// and reference it here by passing "%VSProjectQueryAPISample.MoveFile.DisplayName%" as a constructor parameter.
Placements = [CommandPlacement.KnownPlacements.ExtensionsMenu],
Placements = [CommandPlacement.KnownPlacements.ToolsMenu],
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ public override async Task ExecuteCommandAsync(IClientContext context, Cancellat
{
WorkspacesExtensibility querySpace = this.Extensibility.Workspaces();

const string solutionName = "ConsoleApp32";
const string projectPath = "ConsoleApp1\\\\ConsoleApp1.csproj";

var solutionQueryResults = await querySpace.QuerySolutionAsync(
solution => solution.With(solution => solution.BaseName),
cancellationToken);

var solutionName = solutionQueryResults.First().BaseName;

await querySpace.UpdateSolutionAsync(
solution => solution.Where(solution => solution.BaseName == solutionName),
solution => solution.ReloadProject(projectPath),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public RenameFileCommand(TraceSource traceSource)
// Use this object initializer to set optional parameters for the command. The required parameter,
// displayName, is set above. To localize the displayName, add an entry in .vsextension\string-resources.json
// and reference it here by passing "%VSProjectQueryAPISample.RenameFile.DisplayName%" as a constructor parameter.
Placements = [CommandPlacement.KnownPlacements.ExtensionsMenu],
Placements = [CommandPlacement.KnownPlacements.ToolsMenu],
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ShowActiveProjectCommand(TraceSource traceSource)
// Use this object initializer to set optional parameters for the command. The required parameter,
// displayName, is set above. To localize the displayName, add an entry in .vsextension\string-resources.json
// and reference it here by passing "%VSProjectQueryAPISample.Command1.DisplayName%" as a constructor parameter.
Placements = [CommandPlacement.KnownPlacements.ExtensionsMenu],
Placements = [CommandPlacement.KnownPlacements.ToolsMenu],
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public SkipOfNCommand(TraceSource traceSource)
// Use this object initializer to set optional parameters for the command. The required parameter,
// displayName, is set above. To localize the displayName, add an entry in .vsextension\string-resources.json
// and reference it here by passing "%VSProjectQueryAPISample.SkipOfNCommand.DisplayName%" as a constructor parameter.
Placements = [CommandPlacement.KnownPlacements.ExtensionsMenu],
Placements = [CommandPlacement.KnownPlacements.ToolsMenu],
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TrackProjectQueryCommand(TraceSource traceSource)
// Use this object initializer to set optional parameters for the command. The required parameter,
// displayName, is set above. To localize the displayName, add an entry in .vsextension\string-resources.json
// and reference it here by passing "%VSProjectQueryAPISample.TrackProjectQueryCommand.DisplayName%" as a constructor parameter.
Placements = [CommandPlacement.KnownPlacements.ExtensionsMenu],
Placements = [CommandPlacement.KnownPlacements.ToolsMenu],
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ public override async Task ExecuteCommandAsync(IClientContext context, Cancellat
{
WorkspacesExtensibility querySpace = this.Extensibility.Workspaces();

const string solutionName = "ConsoleApp32";
const string projectPath = "ConsoleApp1\\\\ConsoleApp1.csproj";

var solutionQueryResults = await querySpace.QuerySolutionAsync(
solution => solution.With(solution => solution.BaseName),
cancellationToken);

var solutionName = solutionQueryResults.First().BaseName;

await querySpace.UpdateSolutionAsync(
solution => solution.Where(solution => solution.BaseName == solutionName),
solution => solution.UnloadProject(projectPath),
Expand Down