Update samples for VS 17.9 GA (#315)
* Update samples for VS 17.9 GA --------- Co-authored-by: Jasmine Woon <jasminewoon@microsoft.com> Co-authored-by: Matteo Prosperi <maprospe@microsoft.com> Co-authored-by: Maia Kelner <maiak@microsoft.com> Co-authored-by: Maia Kelner <10425701+maiak@users.noreply.github.com>
This commit is contained in:
Родитель
c82aef9825
Коммит
cfde219c84
|
@ -7,9 +7,6 @@
|
|||
<LangVersion>12</LangVersion>
|
||||
<NoWarn>$(NoWarn);SA1633</NoWarn>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
|
||||
<VssdkCompatibleExtension>true</VssdkCompatibleExtension>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -6,15 +6,11 @@ namespace ExtensionPublisher;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Policy;
|
||||
using System.Security.RightsManagement;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using ExtensionPublisher.Processor;
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
|
@ -360,34 +356,34 @@ public class DataBinding : INotifyPropertyChanged
|
|||
return null!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class MyCategory
|
||||
{
|
||||
public MyCategory(string description)
|
||||
[DataContract]
|
||||
public class MyCategory
|
||||
{
|
||||
this.Description = description;
|
||||
this.IsSelected = false;
|
||||
}
|
||||
|
||||
public MyCategory(string description, List<string> savedCategories)
|
||||
{
|
||||
this.Description = description;
|
||||
this.IsSelected = false;
|
||||
|
||||
foreach (string category in savedCategories)
|
||||
public MyCategory(string description)
|
||||
{
|
||||
if (description == category)
|
||||
this.Description = description;
|
||||
this.IsSelected = false;
|
||||
}
|
||||
|
||||
public MyCategory(string description, List<string> savedCategories)
|
||||
{
|
||||
this.Description = description;
|
||||
this.IsSelected = false;
|
||||
|
||||
foreach (string category in savedCategories)
|
||||
{
|
||||
this.IsSelected = true;
|
||||
if (description == category)
|
||||
{
|
||||
this.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string Description { get; }
|
||||
|
||||
[DataMember]
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string Description { get; }
|
||||
|
||||
[DataMember]
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
|
|
|
@ -3,15 +3,11 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<NoWarn>$(NoWarn);SA1600</NoWarn>
|
||||
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.2092" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.2092" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.2092" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.2092" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -19,8 +15,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="MyToolWindowContent.xaml">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MyToolWindowContent.xaml">
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyOutputToVsixPackageFolder" AfterTargets="Build">
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.2092" />
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
|
||||
<VssdkCompatibleExtension>true</VssdkCompatibleExtension>
|
||||
<DefineConstants>$(DefineConstants);INPROC</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
<LangVersion>12</LangVersion>
|
||||
<RootNamespace>RegexMatchVisualizer</RootNamespace>
|
||||
<DefineConstants>$(DefineConstants);VISUALIZER</DefineConstants>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<NoWarn>$(NoWarn);CS1591;IDE0008;CA1812</NoWarn>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command adding solution configurations.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class AddSolutionConfigurationCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.AddSolutionConfigurationCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
const string solutionName = "ConsoleApp32";
|
||||
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.AddSolutionConfiguration("Foo", "Debug", false),
|
||||
cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync($"Adding solution configuration called 'Foo'.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command deleting a solution configurations.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class DeleteSolutionConfigurationCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.DeleteSolutionConfigurationCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
const string solutionName = "ConsoleApp32";
|
||||
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.DeleteSolutionConfiguration("Foo"),
|
||||
cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync($"Deleting a solution configuration called 'Foo'.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command for building a project.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class ProjectBuildCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.ProjectBuildCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
const string projectName = "ConsoleApp1";
|
||||
|
||||
var result = await this.Extensibility.Workspaces().QueryProjectsAsync(
|
||||
project => project.Where(p => p.Name == projectName),
|
||||
cancellationToken);
|
||||
|
||||
await result.First().BuildAsync(cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync($"Building project {projectName}.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ In our example, we call the `ExecuteQueryAsync` method to get information from t
|
|||
|
||||
Instead of writing queries, users may use the API Metadata tree located on the left panel of the Project Query API Browser. Users may select/deselect the information that they would like to receive from the query. As users select and deselect items in the tree view, the editor will dynamically change its query.
|
||||
|
||||
![APIMetadata](Images/TemplateQueries.png)
|
||||
![APIMetadata](Images/APIMetaData.png)
|
||||
*Figure 3: Tree View of API Metadata*
|
||||
|
||||
## Template Queries
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command for querying solution configurations.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class QuerySolutionConfigurations : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.QuerySolutionConfigurations.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var results = await this.Extensibility.Workspaces().QuerySolutionAsync(
|
||||
solution => solution.With(solution => solution.SolutionConfigurations
|
||||
.With(c => c.Name)),
|
||||
cancellationToken);
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
message.Append($"\n \n === Querying Solution Configurations === \n");
|
||||
|
||||
foreach (var solution in results)
|
||||
{
|
||||
foreach (var solutionConfiguration in solution.SolutionConfigurations)
|
||||
{
|
||||
message.Append(CultureInfo.CurrentCulture, $"\t \t {solutionConfiguration.Name}\n");
|
||||
}
|
||||
}
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync(message.ToString(), PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
title: VS Project Query API Extension reference
|
||||
description: A reference for VS Project Query API Extension reference
|
||||
date: 2022-1-20
|
||||
date: 2024-1-11
|
||||
---
|
||||
|
||||
# Walkthrough: VS Project Query API Extension
|
||||
|
@ -89,7 +89,7 @@ var result = await this.Extensibility.Workspaces().QueryProjectsAsync(
|
|||
|
||||
### Querying By Id
|
||||
|
||||
As usuages for project query becomes more complex, you may realize that the require more information from their query.
|
||||
As usages for project query becomes more complex, you may realize that the require more information from their query.
|
||||
|
||||
In our example, let's say we already queried information about Output Groups.
|
||||
|
||||
|
@ -123,3 +123,103 @@ await foreach (var project in result)
|
|||
```
|
||||
|
||||
Now `newResult` will contain information about OutputGroups' names.
|
||||
|
||||
## Sample Queries
|
||||
|
||||
Below is a showcase of queries that are available in the Project Query API
|
||||
|
||||
### Solution Level Queries
|
||||
|
||||
### Solution Build Actions
|
||||
|
||||
In project query, you also have the ability to invoke build actions on the solution level. These build actions include: `BuildAsync`, `RebuildAsync`, `CleanAsync`, `DebugLaunchAsync`, and `LaunchAsync`.
|
||||
|
||||
```csharp
|
||||
var result = await querySpace.Solutions
|
||||
.BuildAsync(cancellationToken);
|
||||
```
|
||||
|
||||
### Loading/Unloading a Project
|
||||
|
||||
In the snippet below, we specify the solution we would like to unload the project from and pass in the project path when we make our `UnloadProject` call.
|
||||
|
||||
```csharp
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.UnloadProject(projectPath),
|
||||
cancellationToken);
|
||||
```
|
||||
|
||||
Similarly, we can load the project by calling the `ReloadProject` API.
|
||||
|
||||
```csharp
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.ReloadProject(projectPath),
|
||||
cancellationToken);
|
||||
```
|
||||
|
||||
|
||||
### Saving a Solution
|
||||
|
||||
`SaveAsync` is an API call that can be used on the solution level.
|
||||
|
||||
```csharp
|
||||
var result = await querySpace.Solutions.SaveAsync(cancellationToken);
|
||||
```
|
||||
|
||||
|
||||
### Actions for Startup Projects
|
||||
|
||||
Using the Project Query API, you also can select which projects get executed. In the sample below, we added two project paths to be set as the startup project.
|
||||
|
||||
```csharp
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.SetStartupProjects(projectPath1, projectPath2),
|
||||
cancellationToken);
|
||||
```
|
||||
|
||||
### Actions for Solution Configurations
|
||||
|
||||
`AddSolutionConfiguration` is an API call that takes in three parameters. The first parameter is the new name we want to give our new solution configuration. In this scenario, we will call our new solution configuration `Foo`. The next parameter is the configuration to base our new configuration. Below, we based our new solution configuration on the existing solution configuration, `Debug`. Lastly, the boolean represents if the solution configuration should be propagated.
|
||||
|
||||
```csharp
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.AddSolutionConfiguration("Foo", "Debug", false),
|
||||
cancellationToken);
|
||||
```
|
||||
|
||||
`DeleteSolutionConfiguration` is an API call that removes the solution configuration. In the example below, we removed the solution configuration called `Foo`.
|
||||
|
||||
```csharp
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.DeleteSolutionConfiguration("Foo"),
|
||||
cancellationToken);
|
||||
```
|
||||
|
||||
|
||||
### Project Level Queries
|
||||
|
||||
### Project Build Actions
|
||||
|
||||
On the project level, you many invoke these build actions: `BuildAsync`, `RebuildAsync`, `CleanAsync`, `DebugLaunchAsync`, and `LaunchAsync`.
|
||||
While building on the project level, determine the selected project you want to build. In the example below, `result.First()` is an `IProjectSnapshot` that will be built.
|
||||
|
||||
```csharp
|
||||
await result.First().BuildAsync(cancellationToken);
|
||||
```
|
||||
|
||||
### Rename Project
|
||||
|
||||
In the example below, we specify the name of the project we would like to update. We then call `Rename` while passing in the new name of the project.
|
||||
|
||||
```csharp
|
||||
var result = await querySpace.Projects
|
||||
.Where(p => p.Name == "ConsoleApp1")
|
||||
.AsUpdatable()
|
||||
.Rename("NewProjectName")
|
||||
.ExecuteAsync(cancellationToken);
|
||||
```
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command for reloading a project.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class ReloadProjectCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.ReloadProjectCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
const string solutionName = "ConsoleApp32";
|
||||
const string projectPath = "ConsoleApp1\\\\ConsoleApp1.csproj";
|
||||
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.ReloadProject(projectPath),
|
||||
cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync($"Reloaded a project called {projectPath} in solution {solutionName}.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command for renaming a project.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class RenameProjectCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.RenameProjectCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var serviceBroker = context.Extensibility.ServiceBroker;
|
||||
ProjectQueryableSpace querySpace = new ProjectQueryableSpace(serviceBroker: serviceBroker, joinableTaskContext: null);
|
||||
var result = await querySpace.Projects
|
||||
.Where(p => p.Name == "ConsoleApp1")
|
||||
.AsUpdatable()
|
||||
.Rename("NewProjectName")
|
||||
.ExecuteAsync(cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync("Renamed Project to NewProjectName.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command for setting startup projects.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class SetStartupProjectsCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.SetStartupProjectsCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
const string solutionName = "ConsoleApp32";
|
||||
const string projectPath1 = "ConsoleApp1\\\\ConsoleApp1.csproj";
|
||||
const string projectPath2 = "ConsoleApp2\\\\ConsoleApp2.csproj";
|
||||
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.SetStartupProjects(projectPath1, projectPath2),
|
||||
cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync($"Setting startup projects.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command for building the solution.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class SolutionBuildCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.SolutionBuildCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var serviceBroker = context.Extensibility.ServiceBroker;
|
||||
ProjectQueryableSpace querySpace = new ProjectQueryableSpace(serviceBroker: serviceBroker, joinableTaskContext: null);
|
||||
var result = await querySpace.Solutions
|
||||
.BuildAsync(cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync($"Building the solution.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command for saving the solution.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class SolutionSaveCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.SolutionSaveCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var serviceBroker = context.Extensibility.ServiceBroker;
|
||||
ProjectQueryableSpace querySpace = new ProjectQueryableSpace(serviceBroker: serviceBroker, joinableTaskContext: null);
|
||||
var result = await querySpace.Solutions.SaveAsync(cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync($"Saving the solution.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace VSProjectQueryAPISample;
|
||||
|
||||
using Microsoft.VisualStudio.Extensibility;
|
||||
using Microsoft.VisualStudio.Extensibility.Commands;
|
||||
using Microsoft.VisualStudio.Extensibility.Shell;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Query;
|
||||
|
||||
/// <summary>
|
||||
/// A sample command for unloading a project.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
public class UnloadProjectCommand : Command
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override CommandConfiguration CommandConfiguration => new("%VSProjectQueryAPISample.UnloadProjectCommand.DisplayName%")
|
||||
{
|
||||
Placements = new[] { CommandPlacement.KnownPlacements.ToolsMenu },
|
||||
Icon = new(ImageMoniker.KnownValues.Extension, IconSettings.IconAndText),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
const string solutionName = "ConsoleApp32";
|
||||
const string projectPath = "ConsoleApp1\\\\ConsoleApp1.csproj";
|
||||
|
||||
await this.Extensibility.Workspaces().UpdateSolutionAsync(
|
||||
solution => solution.Where(solution => solution.BaseName == solutionName),
|
||||
solution => solution.UnloadProject(projectPath),
|
||||
cancellationToken);
|
||||
|
||||
await this.Extensibility.Shell().ShowPromptAsync($"Unloaded a project called {projectPath} in solution {solutionName}.", PromptOptions.OK, cancellationToken);
|
||||
}
|
||||
}
|
|
@ -5,9 +5,6 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
|
||||
<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
|
||||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -6,9 +6,9 @@ date: 2021-8-19
|
|||
|
||||
# Welcome to VisualStudio.Extensibility
|
||||
|
||||
VisualStudio.Extensibility is a new framework for developing Visual Studio extensions. The new framework focuses primarily on extensions that run out-of-process from the IDE for improved performance and reliability, and it features a modern, asynchronous API that has been streamlined and carefully engineered to maximize developer productivity. VisualStudio.Extensibility is in active development and is available as a preview.
|
||||
VisualStudio.Extensibility is a new framework for developing Visual Studio extensions. The new framework focuses primarily on extensions that run out-of-process from the IDE for improved performance and reliability, and it features a modern, asynchronous API that has been streamlined and carefully engineered to maximize developer productivity. VisualStudio.Extensibility is in active development.
|
||||
|
||||
With the current preview, you can develop a wide range of extensions to Visual Studio, including creating commands, working with code or text in the editor, displaying prompts or dialogs to the user, creating debugger visualizers, and more!
|
||||
With the current version, you can develop a wide range of extensions to Visual Studio, including creating commands, working with code or text in the editor, displaying prompts or dialogs to the user, creating debugger visualizers, and more!
|
||||
|
||||
VisualStudio.Extensibility aims to address many of the problems developers experience when using and writing extensions in Visual Studio. Writing extensions using VisualStudio.Extensibility provides the following benefits:
|
||||
|
||||
|
@ -28,7 +28,7 @@ Documentation is currently available for the following:
|
|||
|
||||
| Article | Description|
|
||||
|-|-|
|
||||
| [Install VisualStudio.Extensibility](#install-visualstudioextensibility) | Download and install the latest preview of VisualStudio.Extensibility. |
|
||||
| [Install VisualStudio.Extensibility](#install-visualstudioextensibility) | Download and install VisualStudio.Extensibility. |
|
||||
| [Get started](#get-started) | Start with beginner quickstarts and introductory tutorials if you've never developed an extension before. |
|
||||
| [Concepts](#concepts) | Build your mental model of how the SDK and extensions work. |
|
||||
| [Overviews](#overviews) | Learn more by reading overviews of each major area of functionality. |
|
||||
|
@ -38,7 +38,8 @@ Documentation is currently available for the following:
|
|||
|
||||
## Install VisualStudio.Extensibility
|
||||
|
||||
The current VisualStudio.Extensibility preview works with Visual Studio 2022 version 17.9 Preview 3 or higher with the `Visual Studio extension development` workload to be installed. VisualStudio.Extensibility extensions can be installed on Visual Studio 2022 version 17.9 Preview 3 and above.
|
||||
VisualStudio.Extensibility works with Visual Studio 2022 version 17.9 or higher with the `Visual Studio extension development` workload to be installed. VisualStudio.Extensibility extensions can be installed on Visual Studio 2022 version 17.9 and above.
|
||||
VisualStudio.Extensibility packages having a version higher than 17.9 provide additional functionalities and can be used when targeting the corresponding version of Visual Studio. For example, when building an extension with VisualStudio.Extensibility packages version 17.10, the resulting extension will be compatible with Visual Studio 17.10 and above.
|
||||
|
||||
## Get Started
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
---
|
||||
title: Breaking Changes
|
||||
description: Breaking changes for VisualStudio.Extensibility
|
||||
date: 2024-01-30
|
||||
---
|
||||
|
||||
# Breaking Changes
|
||||
|
||||
We work hard to minimize breaking changes between versions to help minimize disruptions to your extension development, especially as VisualStudio.Extensibility matures. Some breaking changes are necessary, however, in order to add support for new features or in response to user feedback. Those changes are listed here.
|
||||
|
||||
# Breaking Changes for Visual Studio 2022 17.9
|
||||
|
||||
The following breaking changes apply to Visual Studio 2022 17.9.
|
||||
|
||||
## Client Contexts
|
||||
|
||||
We've changed the type of the `ClientContexts` property of `Microsft.VisualStudio.Extensibility.Commands.BaseCommandConfiguration` from `string[]?` to `ClientContextCategory[]?`.
|
||||
|
||||
```diff
|
||||
/// <summary>
|
||||
/// Gets or sets the client context categories requested by the command.
|
||||
/// </summary>
|
||||
- public string[]? ClientContexts { get; set; }
|
||||
+ public ClientContextCategory[]? ClientContexts { get; set; }
|
||||
```
|
||||
|
||||
### Fix
|
||||
The simplest fix to address this change is to not manually set the `ClientContexts` property. The default value provides the `Editor` and `Shell` contexts, which should be adequate for all commands. If you need to set the property manually, you can update your code to use the new `ClientContextCategory` type and recompile, fixing any compilation errors that may occur.
|
||||
|
||||
## Editor APIs
|
||||
|
||||
In order to simplify the process of working with documents and views, we've updated some of our editor APIs:
|
||||
1. The `ITextViewSnapshot.GetTextDocumentAsync()` method has been **removed**. Instead, you can use the `ITextViewSnapshot.Document` property.
|
||||
1. The `ITextViewSnapshot.GetOptionValueAsync()` and `ITextDocumentSnapshot.GetOptionValueAsync()` methods now return an instance of the `EditorOptionValue` class instead of a raw option value.
|
||||
|
||||
### Fix
|
||||
|
||||
1. Use the `ITextViewSnapshot.Document` property instead of the `ITextViewSnapshot.GetTextDocumentAsync()` method to get the document from a TextView snapshot.
|
||||
1. Use one of the following patterns to obtain editor option values:
|
||||
|
||||
```cs
|
||||
// Potentially throws
|
||||
bool useSpaces = (await textView.GetOptionValueAsync(KnownDocumentOptions.ConvertTabsToSpacesOption, cancellationToken)).Value;
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```cs
|
||||
// Never throws
|
||||
bool useSpaces = (await textView.GetOptionValueAsync(KnownDocumentOptions.ConvertTabsToSpacesOption, cancellationToken)).ValueOrDefault(defaultValue: false);
|
||||
```
|
||||
|
||||
## Command Implementation
|
||||
|
||||
We've updated the implementation for commands to make improvements and add features. If your extension was built against pre-17.9 version of the Microsoft.VisualStudio.Extensibility.Sdk and Microsoft.VisualStudio.Extensibility.Build packages, your commands will not work on Visual Studio 2022 17.9+.
|
||||
|
||||
### Fix
|
||||
|
||||
To fix your commands, make sure you've updated your package references for the Microsoft.VisualStudio.Extensibility.Sdk and Microsoft.VisualStudio.Extensibility.Build packages to be the latest 17.9+ version. Then, make sure you've updated your version of Visual Studio to 17.9 or higher.
|
||||
|
||||
## Extension Manifest
|
||||
|
||||
As part of our work to enable you to create VSIX packages for your extensions, we've made some changes to the extension manifest file. You don't need to manually edit the manifest file, but you will need to update your project to keep your extension working as expected.
|
||||
|
||||
### Fix
|
||||
|
||||
The fix will depend on whether your extensions are out-of-process or in-process (VSSDK-compatible).
|
||||
|
||||
#### Out-of-process extensions
|
||||
|
||||
All you need to do for out-of-process extensions is to update the package references for the Microsoft.VisualStudio.Extensibility.Sdk and Microsoft.VisualStudio.Extensibility.Build packages to be the latest 17.9+ version. Rebuild your extension project, fix any compilation errors associated with the other breaking changes on this page, and your extension should work as expected.
|
||||
|
||||
#### In-process (VSSDK-compatible) extensions
|
||||
|
||||
In order to better support creating VSIX packages for your extensions, we've made some changes to the layout of VSSDK-compatible extension projects. The simplest thing to do would be to create a new in-process extension project, which will have the correct behavior.
|
||||
|
||||
Make sure you've updated to the latest Visual Studio 2022 17.9+ version and create a new in-process project, called "VisualStudio.Extensibility Extension with VSSDK Compatibility" in the New Project dialog. Copy your extension code into the new project and fix any compilation errors associated with the updated package references. Once you've rebuilt, your manifest file should have the correct value set automatically.
|
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
title: Experimental APIs
|
||||
description: How Experimental APIs are used in VisualStudio.Extensibility
|
||||
date: 2024-01-30
|
||||
---
|
||||
|
||||
# Experimental APIs
|
||||
|
||||
While we work hard to ensure stability and minimize breaking changes, VisualStudio.Extensibility is a growing library, with additional features and updates coming with every new version. When a breaking change to a mature part of the library must be made, we list it on our [Breaking Changes page](breaking_changes.md). However, for parts of the API that are likely to be modified in the future, we may add the `[Experimental]` attribute to any associated types and members to indicate to extension authors that they can expect changes in subsequent versions.
|
||||
|
||||
Here are some examples of the situations in which we would use the `[Experimental]` attribute:
|
||||
* We've added a new feature area, and we want to monitor for issues and user feedback.
|
||||
* We're working on a large feature area, but we want to make a finished portion available before the rest of the area is completed.
|
||||
* We've received user feedback on some of our existing APIs, and we're planning on making future changes to respond to that feedback.
|
||||
|
||||
## Using experimental APIs
|
||||
|
||||
Using an experimental API in your extension will result in a build error, which is designed to prevent developers from unintentionally using code that is likely to change in future versions.
|
||||
|
||||
### Build errors
|
||||
The error begins with `VSEXTPREVIEW_` and includes the specific experimental feature being used. For example, if you use the experimental output window feature, you will see `VSEXTPREVIEW_OUTPUTWINDOW`:
|
||||
|
||||
![Localization directory structure](./media/experimental_api_error.png)
|
||||
|
||||
### Disable experimental API build errors
|
||||
|
||||
You can disable the build errors either in your source code for the files where you use the experimental APIs or in the project file for your extension.
|
||||
|
||||
#### In source code
|
||||
|
||||
Place the following `#pragma` statement in your source code where you use the experimental APIs:
|
||||
|
||||
```csharp
|
||||
#pragma warning disable VSEXTPREVIEW_OUTPUTWINDOW // Type is for evaluation purposes only and is subject to change or removal in future updates.
|
||||
```
|
||||
|
||||
#### In project file
|
||||
|
||||
To disable the build error for all uses of each experimental API across all files in your project, you can add a `<NoWarn>` element to your `.csproj` file. For example, to disable the build error for all uses of the output window experimental API in your project, add this statement to your project file:
|
||||
|
||||
```xml
|
||||
<NoWarn>$(NoWarn);VSEXTPREVIEW_OUTPUTWINDOW</NoWarn>
|
||||
```
|
||||
|
||||
## Current experimental APIs
|
||||
|
||||
You can find a class that contains each of our current experimental APIs called [`ExperimentalFeatures`](https://learn.microsoft.com/dotnet/api/microsoft.visualstudio.extensibility.experimentalfeatures) in our [API Reference](https://learn.microsoft.com/dotnet/api/microsoft.visualstudio.extensibility).
|
||||
|
||||
As of our 17.9 release, there are three experimental features:
|
||||
|
||||
| Feature | Label | Description |
|
||||
|---------|-------|-------------|
|
||||
| LSP | VSEXTPREVIEW_LSP | LSP support was added with our 17.9 release and we want user feedback to make sure we've got the features needed by extension authors.|
|
||||
| Output Window | VSEXTPREVIEW_OUTPUTWINDOW | We're updating our output window APIs based on user feedback to provide a simplified way to write to the output window. |
|
||||
| Project Query Tracking | VSEXTPREVIEW_PROJECTQUERY_TRACKING | We're continuing to update our project query API to add new features|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 109 KiB |
Загрузка…
Ссылка в новой задаче