Skip to content

Commit

Permalink
Update samples for VS 17.9 GA (#315)
Browse files Browse the repository at this point in the history
* Update samples for VS 17.9 GA

---------

Co-authored-by: Jasmine Woon <[email protected]>
Co-authored-by: Matteo Prosperi <[email protected]>
Co-authored-by: Maia Kelner <[email protected]>
Co-authored-by: Maia Kelner <[email protected]>
  • Loading branch information
5 people authored Feb 7, 2024
1 parent c82aef9 commit cfde219
Show file tree
Hide file tree
Showing 34 changed files with 643 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
46 changes: 21 additions & 25 deletions New_Extensibility_Model/Samples/ExtensionPublisher/DataBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -360,34 +356,34 @@ private async Task<PublishManifestModel> BuildModelForPublishManifestAsync(
return null!;
}
}
}

[DataContract]
public class MyCategory
{
public MyCategory(string description)
{
this.Description = description;
this.IsSelected = false;
}

public MyCategory(string description, List<string> savedCategories)
[DataContract]
public class MyCategory
{
this.Description = description;
this.IsSelected = false;
public MyCategory(string description)
{
this.Description = description;
this.IsSelected = false;
}

foreach (string category in savedCategories)
public MyCategory(string description, List<string> savedCategories)
{
if (description == category)
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 string Description { get; }

[DataMember]
public bool IsSelected { get; set; }
[DataMember]
public bool IsSelected { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@
<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>
<None Remove="MyToolWindowContent.xaml" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="MyToolWindowContent.xaml">
</EmbeddedResource>
<EmbeddedResource Include="MyToolWindowContent.xaml">
</EmbeddedResource>
</ItemGroup>

<Target Name="CopyOutputToVsixPackageFolder" AfterTargets="Build">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 0 additions & 3 deletions New_Extensibility_Model/Samples/InsertGuid/InsertGuid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit cfde219

Please sign in to comment.