Skip to content

Commit

Permalink
Merge pull request #532 from sharwell/integration-tests
Browse files Browse the repository at this point in the history
Add integration tests for successful project creation from templates
  • Loading branch information
sharwell authored Jun 4, 2020
2 parents 3e6b1b5 + 797e180 commit 8647b80
Show file tree
Hide file tree
Showing 43 changed files with 2,055 additions and 67 deletions.
7 changes: 7 additions & 0 deletions Roslyn-SDK.sln
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.Visu
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualStudio.Roslyn.SDK", "VisualStudio.Roslyn.SDK", "{A3AF556C-276C-49BA-A9ED-E7D42FECAA46}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.SDK.IntegrationTests", "tests\VisualStudio.Roslyn.SDK\Roslyn.SDK.IntegrationTests\Roslyn.SDK.IntegrationTests.csproj", "{6DBBFF7B-2C28-47D7-8618-B6085044E38D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.SDK.UnitTests", "tests\VisualStudio.Roslyn.SDK\Roslyn.SDK.UnitTests\Roslyn.SDK.UnitTests.csproj", "{11B1F856-9025-4A4C-B90D-B1237743B672}"
EndProject
Global
Expand Down Expand Up @@ -421,6 +423,10 @@ Global
{023B21F8-09EC-4A67-8AAA-3D110231E7EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{023B21F8-09EC-4A67-8AAA-3D110231E7EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{023B21F8-09EC-4A67-8AAA-3D110231E7EB}.Release|Any CPU.Build.0 = Release|Any CPU
{6DBBFF7B-2C28-47D7-8618-B6085044E38D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DBBFF7B-2C28-47D7-8618-B6085044E38D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DBBFF7B-2C28-47D7-8618-B6085044E38D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DBBFF7B-2C28-47D7-8618-B6085044E38D}.Release|Any CPU.Build.0 = Release|Any CPU
{11B1F856-9025-4A4C-B90D-B1237743B672}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11B1F856-9025-4A4C-B90D-B1237743B672}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11B1F856-9025-4A4C-B90D-B1237743B672}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -501,6 +507,7 @@ Global
{4617ED77-9564-4A06-8F9B-92E5C5523FE1} = {9905147E-CC1F-42A0-BD27-05586C583DF7}
{023B21F8-09EC-4A67-8AAA-3D110231E7EB} = {9905147E-CC1F-42A0-BD27-05586C583DF7}
{A3AF556C-276C-49BA-A9ED-E7D42FECAA46} = {8C343846-5F9F-4033-9B52-B44C61962449}
{6DBBFF7B-2C28-47D7-8618-B6085044E38D} = {A3AF556C-276C-49BA-A9ED-E7D42FECAA46}
{11B1F856-9025-4A4C-B90D-B1237743B672} = {A3AF556C-276C-49BA-A9ED-E7D42FECAA46}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
6 changes: 6 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@
<MicrosoftVisualStudioLanguageStandardClassificationVersion>16.4.280</MicrosoftVisualStudioLanguageStandardClassificationVersion>
<MicrosoftVisualStudioOLEInteropVersion>7.10.6071</MicrosoftVisualStudioOLEInteropVersion>
<MicrosoftVisualStudioShell150Version>16.5.29911.84</MicrosoftVisualStudioShell150Version>
<MicrosoftVisualStudioShellFrameworkVersion>16.5.29911.84</MicrosoftVisualStudioShellFrameworkVersion>
<MicrosoftVisualStudioShellInteropVersion>7.10.6072</MicrosoftVisualStudioShellInteropVersion>
<MicrosoftVisualStudioShellInterop80Version>8.0.50728</MicrosoftVisualStudioShellInterop80Version>
<MicrosoftVisualStudioShellInterop90Version>9.0.30730</MicrosoftVisualStudioShellInterop90Version>
<MicrosoftVisualStudioShellInterop100Version>10.0.30320</MicrosoftVisualStudioShellInterop100Version>
<MicrosoftVisualStudioShellInterop110Version>11.0.61031</MicrosoftVisualStudioShellInterop110Version>
<MicrosoftVisualStudioShellInterop121DesignTimeVersion>12.1.30329</MicrosoftVisualStudioShellInterop121DesignTimeVersion>
<MicrosoftVisualStudioShellInterop140DesignTimeVersion>14.3.26929</MicrosoftVisualStudioShellInterop140DesignTimeVersion>
<MicrosoftVisualStudioShellInterop157DesignTimeVersion>15.7.1</MicrosoftVisualStudioShellInterop157DesignTimeVersion>
<MicrosoftVisualStudioTextDataVersion>16.4.280</MicrosoftVisualStudioTextDataVersion>
<MicrosoftVisualStudioTextLogicVersion>16.4.280</MicrosoftVisualStudioTextLogicVersion>
<MicrosoftVisualStudioTextManagerInteropVersion>7.10.6071</MicrosoftVisualStudioTextManagerInteropVersion>
<MicrosoftVisualStudioTextUIVersion>16.4.280</MicrosoftVisualStudioTextUIVersion>
<MicrosoftVisualStudioTextUIWpfVersion>16.4.280</MicrosoftVisualStudioTextUIWpfVersion>
<MicrosoftVisualStudioUtilitiesVersion>16.5.29903.186</MicrosoftVisualStudioUtilitiesVersion>
<MicrosoftVisualStudioThreadingVersion>16.5.132</MicrosoftVisualStudioThreadingVersion>
<NuGetSolutionRestoreManagerInteropVersion>5.6.0</NuGetSolutionRestoreManagerInteropVersion>
<StreamJsonRpcVersion>2.3.99</StreamJsonRpcVersion>
<!-- Libs -->
<SystemCollectionsImmutableVersion>1.3.1</SystemCollectionsImmutableVersion>
Expand All @@ -55,6 +60,7 @@
<MicrosoftCodeAnalysis2PrimaryTestVersion>2.6.1</MicrosoftCodeAnalysis2PrimaryTestVersion>
<MicrosoftCodeAnalysis3PrimaryTestVersion>3.3.1</MicrosoftCodeAnalysis3PrimaryTestVersion>
<XunitCombinatorialVersion>1.2.7</XunitCombinatorialVersion>
<VsixTestingXunitVersion>0.1.49-beta</VsixTestingXunitVersion>
<!-- Analyzers -->
<RoslynDiagnosticsAnalyzersVersion>2.9.8</RoslynDiagnosticsAnalyzersVersion>
<StyleCopAnalyzersVersion>1.2.0-beta.164</StyleCopAnalyzersVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using EnvDTE;
using VSLangProj;

public class RoslynSDKCodeFixTemplateWizard : RoslynSDKChildTemplateWizard
{
public static Project Project { get; private set; }

public override void OnProjectFinishedGenerating(Project project)
{
Project = project;

// There is no good way for the test project to reference the main project, so we will use the wizard.
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
if (project.Object is VSProject vsProject)
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
{
var referenceProject = vsProject.References.AddProject(RoslynSDKAnalyzerTemplateWizard.Project);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using EnvDTE;
using VSLangProj;

public class RoslynSDKPackageTemplateWizard : RoslynSDKChildTemplateWizard
{
public override void OnProjectFinishedGenerating(Project project)
{
// There is no good way for the test project to reference the main project, so we will use the wizard.
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
if (project.Object is VSProject vsProject)
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
{
_ = vsProject.References.AddProject(RoslynSDKAnalyzerTemplateWizard.Project);
_ = vsProject.References.AddProject(RoslynSDKCodeFixTemplateWizard.Project);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public override void OnProjectFinishedGenerating(Project project)
if (project.Object is VSProject vsProject)
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
{
var referenceProject = vsProject.References.AddProject(RoslynSDKAnalyzerTemplateWizard.Project);
_ = vsProject.References.AddProject(RoslynSDKAnalyzerTemplateWizard.Project);
_ = vsProject.References.AddProject(RoslynSDKCodeFixTemplateWizard.Project);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
Modifying it requires changes to the wizard code.-->
<ProjectCollection>
<ProjectTemplateLink ProjectName="$safeprojectname$">
ProjectTemplates\CSharp\Diagnostic\Analyzer\DiagnosticAnalyzer.vstemplate
ProjectTemplates\CSharp\Diagnostic\Analyzer\DiagnosticAnalyzer.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.CodeFixes">
ProjectTemplates\CSharp\Diagnostic\CodeFix\CodeFixProvider.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.Package">
ProjectTemplates\CSharp\Diagnostic\Package\Package.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.Test">
ProjectTemplates\CSharp\Diagnostic\Test\Test.vstemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,20 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<IsPackable>false</IsPackable>

<PropertyGroup>
<PackageId>$safeprojectname$</PackageId>
<PackageVersion>1.0.0.0</PackageVersion>
<Authors>$username$</Authors>
<PackageLicenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</PackageLicenseUrl>
<PackageProjectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</PackageProjectUrl>
<PackageIconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</PackageIconUrl>
<RepositoryUrl>http://REPOSITORY_URL_HERE_OR_DELETE_THIS_LINE</RepositoryUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>$safeprojectname$</Description>
<PackageReleaseNotes>Summary of changes made in this release of the package.</PackageReleaseNotes>
<Copyright>Copyright</Copyright>
<PackageTags>$safeprojectname$, analyzers</PackageTags>
<NoPackageAnalysis>true</NoPackageAnalysis>
<!-- Avoid ID conflicts with the package project. -->
<PackageId>*$(MSBuildProjectFullPath)*</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="2.9.8" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.3.1" />
</ItemGroup>

<ItemGroup>
<Compile Update="Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
<EmbeddedResource Update="Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
</ItemGroup>

<ItemGroup>
<None Update="tools\*.ps1" CopyToOutputDirectory="Always" Pack="true" PackagePath="" />
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
<TemplateContent>
<Project TargetFileName="$projectname$.csproj" File="DiagnosticAnalyzer.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="true" TargetFileName="$saferootidentifiername$Analyzer.cs" OpenInEditor="true" OpenOrder="2">DiagnosticAnalyzer.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="$saferootidentifiername$CodeFixProvider.cs" OpenInEditor="true" OpenOrder="3" >CodeFixProvider.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Resources.resx">Resources.resx</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Resources.Designer.cs">Resources.Designer.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="tools\install.ps1">install.ps1</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="tools\uninstall.ps1">uninstall.ps1</ProjectItem>
</Project>
</TemplateContent>
<WizardExtension>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
Expand All @@ -18,8 +18,6 @@ namespace $saferootprojectname$
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof($saferootidentifiername$CodeFixProvider)), Shared]
public class $saferootidentifiername$CodeFixProvider : CodeFixProvider
{
private const string title = "Make uppercase";

public sealed override ImmutableArray<string> FixableDiagnosticIds
{
get { return ImmutableArray.Create($saferootidentifiername$Analyzer.DiagnosticId); }
Expand All @@ -45,9 +43,9 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
// Register a code action that will invoke the fix.
context.RegisterCodeFix(
CodeAction.Create(
title: title,
title: CodeFixResources.CodeFixTitle,
createChangedSolution: c => MakeUppercaseAsync(context.Document, declaration, c),
equivalenceKey: title),
equivalenceKey: nameof(CodeFixResources.CodeFixTitle)),
diagnostic);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>$saferootprojectname$</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.3.1" />
</ItemGroup>

<ItemGroup>
<Compile Update="CodeFixResources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="CodeFixResources.resx" />
<EmbeddedResource Update="CodeFixResources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="CodeFixResources.Designer.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0"
Type="Project"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>CodeFixProvider</Name>
<Description>&lt;No description available&gt;</Description>
<Icon></Icon>
<ProjectType>CSharp</ProjectType>
<RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
<SortOrder>952</SortOrder>
<TemplateID>bb967cab-2ca5-4dac-8809-65b2b28a6350</TemplateID>
<CreateNewFolder>true</CreateNewFolder>
<CreateInPlace>true</CreateInPlace>
<DefaultName>CodeFixProvider</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<PromptForSaveOnCreation>true</PromptForSaveOnCreation>
</TemplateData>
<TemplateContent>
<Project TargetFileName="$projectname$.csproj" File="CodeFixProvider.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="true" TargetFileName="$saferootidentifiername$CodeFixProvider.cs" OpenInEditor="true" OpenOrder="3" >CodeFixProvider.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="CodeFixResources.resx">CodeFixResources.resx</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="CodeFixResources.Designer.cs">CodeFixResources.Designer.cs</ProjectItem>
</Project>
</TemplateContent>
<WizardExtension>
<Assembly>Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Assembly>
<FullClassName>RoslynSDKCodeFixTemplateWizard</FullClassName>
</WizardExtension>
</VSTemplate>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8647b80

Please sign in to comment.