Skip to content

Commit d38980a

Browse files
committed
Added tests to confirm that the NuGet package works.
1 parent a50a875 commit d38980a

21 files changed

+612
-3
lines changed

Community.VisualStudio.SourceGenerators.sln

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ VisualStudioVersion = 17.1.31911.260
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2E0ADDC4-4AA5-4D57-B309-DAF502E7555C}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Community.VisualStudio.Generators", "src\Community.VisualStudio.SourceGenerators\Community.VisualStudio.SourceGenerators.csproj", "{3B743A03-8B3A-4DB3-8C20-D65DE25DF537}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Community.VisualStudio.SourceGenerators", "src\Community.VisualStudio.SourceGenerators\Community.VisualStudio.SourceGenerators.csproj", "{3B743A03-8B3A-4DB3-8C20-D65DE25DF537}"
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9B796B64-A789-44CD-8B82-8EFC6784FF71}"
1111
ProjectSection(SolutionItems) = preProject
@@ -17,7 +17,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1717
EndProject
1818
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{589EC942-90CD-4CBF-AEBF-1F21C7EEE3B0}"
1919
EndProject
20-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Community.VisualStudio.Generators.UnitTests", "test\Community.VisualStudio.SourceGenerators.UnitTests\Community.VisualStudio.SourceGenerators.UnitTests.csproj", "{9D7B8767-CF76-4A59-A5A3-3F0B1053DE5F}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Community.VisualStudio.SourceGenerators.UnitTests", "test\Community.VisualStudio.SourceGenerators.UnitTests\Community.VisualStudio.SourceGenerators.UnitTests.csproj", "{9D7B8767-CF76-4A59-A5A3-3F0B1053DE5F}"
21+
EndProject
22+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Community.VisualStudio.SourceGenerators.EndToEndTests", "test\Community.VisualStudio.SourceGenerators.EndToEndTests\Community.VisualStudio.SourceGenerators.EndToEndTests.csproj", "{6C0DC0B8-45EB-4100-B2D1-A691C1ADA474}"
2123
EndProject
2224
Global
2325
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -33,13 +35,18 @@ Global
3335
{9D7B8767-CF76-4A59-A5A3-3F0B1053DE5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
3436
{9D7B8767-CF76-4A59-A5A3-3F0B1053DE5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
3537
{9D7B8767-CF76-4A59-A5A3-3F0B1053DE5F}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{6C0DC0B8-45EB-4100-B2D1-A691C1ADA474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{6C0DC0B8-45EB-4100-B2D1-A691C1ADA474}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{6C0DC0B8-45EB-4100-B2D1-A691C1ADA474}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{6C0DC0B8-45EB-4100-B2D1-A691C1ADA474}.Release|Any CPU.Build.0 = Release|Any CPU
3642
EndGlobalSection
3743
GlobalSection(SolutionProperties) = preSolution
3844
HideSolutionNode = FALSE
3945
EndGlobalSection
4046
GlobalSection(NestedProjects) = preSolution
4147
{3B743A03-8B3A-4DB3-8C20-D65DE25DF537} = {2E0ADDC4-4AA5-4D57-B309-DAF502E7555C}
4248
{9D7B8767-CF76-4A59-A5A3-3F0B1053DE5F} = {589EC942-90CD-4CBF-AEBF-1F21C7EEE3B0}
49+
{6C0DC0B8-45EB-4100-B2D1-A691C1ADA474} = {589EC942-90CD-4CBF-AEBF-1F21C7EEE3B0}
4350
EndGlobalSection
4451
GlobalSection(ExtensibilityGlobals) = postSolution
4552
SolutionGuid = {10D68B3E-E09C-4ECE-ADD5-FE2B654434D8}

global.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sdk": {
3+
"version": "6.0.101",
4+
"rollForward" :"latestMinor",
5+
"allowPrerelease": false
6+
}
7+
}

src/Community.VisualStudio.SourceGenerators/CommandTable/CommandTableGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static void GeneratePackageGuids(CommandTable commandTable, string conta
7070
foreach (GUIDSymbol symbol in commandTable.GUIDSymbols.OrderBy((x) => x.Name))
7171
{
7272
string guidName = GetGuidName(symbol.Name);
73-
builder.AppendLine($" public const string {guidName}String = \"{symbol.Value:B}\";");
73+
builder.AppendLine($" public const string {guidName}String = \"{symbol.Value:D}\";");
7474
builder.AppendLine($" public static readonly System.Guid {guidName} = new System.Guid({guidName}String);");
7575
}
7676

src/Community.VisualStudio.SourceGenerators/Community.VisualStudio.SourceGenerators.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
</PropertyGroup>
66

7+
<PropertyGroup>
8+
<PatchVersion Condition="'$(PatchVersion)' == ''">0</PatchVersion>
9+
<Version Condition="'$(Version)' == ''">1.0.$(PatchVersion)</Version>
10+
</PropertyGroup>
11+
712
<PropertyGroup>
813
<PackageDescription>C# source generators for Visual Studio extension development.</PackageDescription>
914
<PackageTags>VisualStudio, VSSDK, SDK</PackageTags>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*Tests.cs]
2+
3+
# CA1034: Nested types should not be visible
4+
dotnet_diagnostic.CA1034.severity = none
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<!--
5+
Target .NET Framework so that we can find and run the version of MSBuild that comes
6+
with Visual Studio. If we target .NET 5+, then the version of `Microsoft.Build.Locator`
7+
that is used will never look for Visual Studio installations.
8+
-->
9+
<TargetFramework>net48</TargetFramework>
10+
<IsPackable>false</IsPackable>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<Compile Remove="EndToEndSolution\**" />
15+
<EmbeddedResource Remove="EndToEndSolution\**" />
16+
<None Remove="EndToEndSolution\**" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Using Include="Xunit" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" />
25+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
26+
<PackageReference Include="xunit" Version="2.4.1" />
27+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
28+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
29+
<PrivateAssets>all</PrivateAssets>
30+
</PackageReference>
31+
<PackageReference Include="coverlet.collector" Version="3.1.0">
32+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
33+
<PrivateAssets>all</PrivateAssets>
34+
</PackageReference>
35+
</ItemGroup>
36+
37+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nuget.config
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32113.165
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Legacy", "Legacy\Legacy.csproj", "{28B920FF-8A16-4FEB-B703-E3D668D2FAED}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wpf", "Wpf\Wpf.csproj", "{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|x86 = Debug|x86
14+
Release|Any CPU = Release|Any CPU
15+
Release|x86 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{28B920FF-8A16-4FEB-B703-E3D668D2FAED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{28B920FF-8A16-4FEB-B703-E3D668D2FAED}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{28B920FF-8A16-4FEB-B703-E3D668D2FAED}.Debug|x86.ActiveCfg = Debug|x86
21+
{28B920FF-8A16-4FEB-B703-E3D668D2FAED}.Debug|x86.Build.0 = Debug|x86
22+
{28B920FF-8A16-4FEB-B703-E3D668D2FAED}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{28B920FF-8A16-4FEB-B703-E3D668D2FAED}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{28B920FF-8A16-4FEB-B703-E3D668D2FAED}.Release|x86.ActiveCfg = Release|x86
25+
{28B920FF-8A16-4FEB-B703-E3D668D2FAED}.Release|x86.Build.0 = Release|x86
26+
{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}.Debug|x86.ActiveCfg = Debug|x86
29+
{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}.Debug|x86.Build.0 = Debug|x86
30+
{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}.Release|x86.ActiveCfg = Release|x86
33+
{F65C5BB7-D47D-4C5C-9790-E84C4CA4EA78}.Release|x86.Build.0 = Release|x86
34+
EndGlobalSection
35+
GlobalSection(SolutionProperties) = preSolution
36+
HideSolutionNode = FALSE
37+
EndGlobalSection
38+
GlobalSection(ExtensibilityGlobals) = postSolution
39+
SolutionGuid = {75889317-B66D-4E1D-8407-3839A4CDEB11}
40+
EndGlobalSection
41+
EndGlobal
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
8+
<PropertyGroup>
9+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
10+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
11+
<SchemaVersion>2.0</SchemaVersion>
12+
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
13+
<ProjectGuid>{28B920FF-8A16-4FEB-B703-E3D668D2FAED}</ProjectGuid>
14+
<OutputType>Library</OutputType>
15+
<AppDesignerFolder>Properties</AppDesignerFolder>
16+
<RootNamespace>Legacy</RootNamespace>
17+
<AssemblyName>Legacy</AssemblyName>
18+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
19+
<GeneratePkgDefFile>true</GeneratePkgDefFile>
20+
<UseCodebase>true</UseCodebase>
21+
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
22+
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer>
23+
<IncludeDebugSymbolsInLocalVSIXDeployment>false</IncludeDebugSymbolsInLocalVSIXDeployment>
24+
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
25+
<CopyOutputSymbolsToOutputDirectory>true</CopyOutputSymbolsToOutputDirectory>
26+
<StartAction>Program</StartAction>
27+
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram>
28+
<StartArguments>/rootsuffix Exp</StartArguments>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
31+
<DebugSymbols>true</DebugSymbols>
32+
<DebugType>full</DebugType>
33+
<Optimize>false</Optimize>
34+
<OutputPath>bin\Debug\</OutputPath>
35+
<DefineConstants>DEBUG;TRACE</DefineConstants>
36+
<ErrorReport>prompt</ErrorReport>
37+
<WarningLevel>4</WarningLevel>
38+
<CreateVsixContainer>False</CreateVsixContainer>
39+
<DeployExtension>False</DeployExtension>
40+
</PropertyGroup>
41+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
42+
<DebugType>pdbonly</DebugType>
43+
<Optimize>true</Optimize>
44+
<OutputPath>bin\Release\</OutputPath>
45+
<DefineConstants>TRACE</DefineConstants>
46+
<ErrorReport>prompt</ErrorReport>
47+
<WarningLevel>4</WarningLevel>
48+
<CreateVsixContainer>False</CreateVsixContainer>
49+
<DeployExtension>False</DeployExtension>
50+
</PropertyGroup>
51+
<ItemGroup>
52+
<Compile Include="Properties\AssemblyInfo.cs" />
53+
<Compile Include="LegacyPackage.cs" />
54+
</ItemGroup>
55+
<ItemGroup>
56+
<None Include="source.extension.vsixmanifest">
57+
<SubType>Designer</SubType>
58+
</None>
59+
</ItemGroup>
60+
<ItemGroup>
61+
<Reference Include="Microsoft.CSharp" />
62+
<Reference Include="System" />
63+
<Reference Include="System.Data" />
64+
<Reference Include="System.Design" />
65+
<Reference Include="System.Drawing" />
66+
<Reference Include="System.Windows.Forms" />
67+
<Reference Include="System.Xml" />
68+
</ItemGroup>
69+
<ItemGroup Condition="'$(SourceGeneratorsVersion)' != ''">
70+
<PackageReference Include="Community.VisualStudio.SourceGenerators" Version="$(SourceGeneratorsVersion)" />
71+
</ItemGroup>
72+
<ItemGroup>
73+
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.0.31902.203" ExcludeAssets="runtime" />
74+
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.1.4054" />
75+
</ItemGroup>
76+
<ItemGroup>
77+
<VSCTCompile Include="VSCommandTable.vsct">
78+
<ResourceName>Menus.ctmenu</ResourceName>
79+
</VSCTCompile>
80+
</ItemGroup>
81+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82+
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
83+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
using Microsoft.VisualStudio.Shell;
4+
5+
namespace Legacy
6+
{
7+
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
8+
[Guid(PackageGuids.LegacyPackageString)]
9+
[ProvideMenuResource("Menus.ctmenu", 1)]
10+
public sealed class LegacyPackage : AsyncPackage
11+
{
12+
public override string ToString()
13+
{
14+
return $"{Vsix.Name}, MyCommand={PackageIds.MyCommand}";
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyTitle("Legacy")]
5+
[assembly: AssemblyDescription("")]
6+
[assembly: AssemblyConfiguration("")]
7+
[assembly: AssemblyCompany("")]
8+
[assembly: AssemblyProduct("Legacy")]
9+
[assembly: AssemblyCopyright("")]
10+
[assembly: AssemblyTrademark("")]
11+
[assembly: AssemblyCulture("")]
12+
[assembly: ComVisible(false)]
13+
[assembly: AssemblyVersion("1.0.0.0")]
14+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<Extern href="stdidcmd.h"/>
4+
<Extern href="vsshlids.h"/>
5+
6+
<Symbols>
7+
<GuidSymbol name="LegacyPackage" value="{73300c48-32e9-43fd-a29a-b1144f5c84a4}">
8+
<IDSymbol name="MyCommand" value="0x0100" />
9+
</GuidSymbol>
10+
</Symbols>
11+
</CommandTable>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
3+
<Metadata>
4+
<Identity Id="Legacy.a017837c-00ee-4dec-ba28-d7d69f2e943b" Version="1.0" Language="en-US" Publisher="VSIX Community" />
5+
<DisplayName>Legacy</DisplayName>
6+
<Description xml:space="preserve">Empty VSIX Project.</Description>
7+
</Metadata>
8+
<Installation>
9+
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0, 18.0)">
10+
<ProductArchitecture>amd64</ProductArchitecture>
11+
</InstallationTarget>
12+
</Installation>
13+
<Dependencies>
14+
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
15+
<Dependency Id="Microsoft.VisualStudio.MPF.16.0" DisplayName="Visual Studio MPF 16.0" d:Source="Installed" Version="[16.0,17.0)" />
16+
</Dependencies>
17+
<Prerequisites>
18+
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,18.0)" DisplayName="Visual Studio core editor" />
19+
</Prerequisites>
20+
<Assets>
21+
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
22+
</Assets>
23+
</PackageManifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyTitle("Wpf")]
5+
[assembly: AssemblyDescription("")]
6+
[assembly: AssemblyConfiguration("")]
7+
[assembly: AssemblyCompany("")]
8+
[assembly: AssemblyProduct("Wpf")]
9+
[assembly: AssemblyCopyright("")]
10+
[assembly: AssemblyTrademark("")]
11+
[assembly: AssemblyCulture("")]
12+
[assembly: ComVisible(false)]
13+
[assembly: AssemblyVersion("1.0.0.0")]
14+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<Extern href="stdidcmd.h"/>
4+
<Extern href="vsshlids.h"/>
5+
6+
<Symbols>
7+
<GuidSymbol name="WpfPackage" value="{0a316f7b-cd90-4031-8bb8-5a81ba521f92}">
8+
<IDSymbol name="MyCommand" value="0x0100" />
9+
</GuidSymbol>
10+
</Symbols>
11+
</CommandTable>

0 commit comments

Comments
 (0)