diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKAnalyzerCSharpTemplateWizard.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKAnalyzerCSharpTemplateWizard.cs
new file mode 100644
index 000000000..053b9b294
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKAnalyzerCSharpTemplateWizard.cs
@@ -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 RoslynSDKAnalyzerCSharpTemplateWizard : 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);
+ }
+ }
+}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKAnalyzerVisualBasicTemplateWizard.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKAnalyzerVisualBasicTemplateWizard.cs
new file mode 100644
index 000000000..91254ebdc
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKAnalyzerVisualBasicTemplateWizard.cs
@@ -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 RoslynSDKAnalyzerVisualBasicTemplateWizard : 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);
+ }
+ }
+}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKCodeFixCSharpTemplateWizard.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKCodeFixCSharpTemplateWizard.cs
new file mode 100644
index 000000000..434fdb53c
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKCodeFixCSharpTemplateWizard.cs
@@ -0,0 +1,24 @@
+// 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 RoslynSDKCodeFixCSharpTemplateWizard : 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
+ {
+ _ = vsProject.References.AddProject(RoslynSDKAnalyzerTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKAnalyzerCSharpTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKCodeFixTemplateWizard.Project);
+ }
+ }
+}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKCodeFixVisualBasicTemplateWizard.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKCodeFixVisualBasicTemplateWizard.cs
new file mode 100644
index 000000000..0e11091d6
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKCodeFixVisualBasicTemplateWizard.cs
@@ -0,0 +1,24 @@
+// 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 RoslynSDKCodeFixVisualBasicTemplateWizard : 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
+ {
+ _ = vsProject.References.AddProject(RoslynSDKAnalyzerTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKAnalyzerVisualBasicTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKCodeFixTemplateWizard.Project);
+ }
+ }
+}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKPackageTemplateWizard.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKPackageTemplateWizard.cs
index 6d3815b6b..297c0427d 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKPackageTemplateWizard.cs
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKPackageTemplateWizard.cs
@@ -13,7 +13,11 @@ public override void OnProjectFinishedGenerating(Project project)
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
{
_ = vsProject.References.AddProject(RoslynSDKAnalyzerTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKAnalyzerCSharpTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKAnalyzerVisualBasicTemplateWizard.Project);
_ = vsProject.References.AddProject(RoslynSDKCodeFixTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKCodeFixCSharpTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKCodeFixVisualBasicTemplateWizard.Project);
}
}
}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKTestTemplateWizard.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKTestTemplateWizard.cs
index 821b33101..4714e2bd7 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKTestTemplateWizard.cs
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK.Template.Wizard/RoslynSDKTestTemplateWizard.cs
@@ -13,7 +13,11 @@ public override void OnProjectFinishedGenerating(Project project)
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
{
_ = vsProject.References.AddProject(RoslynSDKAnalyzerTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKAnalyzerCSharpTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKAnalyzerVisualBasicTemplateWizard.Project);
_ = vsProject.References.AddProject(RoslynSDKCodeFixTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKCodeFixCSharpTemplateWizard.Project);
+ _ = vsProject.References.AddProject(RoslynSDKCodeFixVisualBasicTemplateWizard.Project);
}
}
}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/CSharpDiagnostic.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/CSharpDiagnostic.vstemplate
index 9cbb893ee..493cc71e9 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/CSharpDiagnostic.vstemplate
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/CSharpDiagnostic.vstemplate
@@ -31,9 +31,21 @@
ProjectTemplates\CSharp\Diagnostic\Analyzer\DiagnosticAnalyzer.vstemplate
+
+ ProjectTemplates\CSharp\Diagnostic\Analyzer.CS\CSAnalyzer.vstemplate
+
+
+ ProjectTemplates\CSharp\Diagnostic\Analyzer.VB\VBAnalyzer.vstemplate
+
ProjectTemplates\CSharp\Diagnostic\CodeFix\CodeFixProvider.vstemplate
+
+ ProjectTemplates\CSharp\Diagnostic\CodeFix.CS\CSCodeFix.vstemplate
+
+
+ ProjectTemplates\CSharp\Diagnostic\CodeFix.VB\VBCodeFix.vstemplate
+
ProjectTemplates\CSharp\Diagnostic\Package\Package.vstemplate
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.CS/CSAnalyzer.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.CS/CSAnalyzer.csproj
new file mode 100644
index 000000000..c2f135e30
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.CS/CSAnalyzer.csproj
@@ -0,0 +1,12 @@
+
+
+
+ netstandard2.0
+ false
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.CS/CSAnalyzer.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.CS/CSAnalyzer.vstemplate
new file mode 100644
index 000000000..64b44337c
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.CS/CSAnalyzer.vstemplate
@@ -0,0 +1,28 @@
+
+
+
+ DiagnosticAnalyzer.CSharp
+ <No description available>
+
+ CSharp
+ 2.0
+ 952
+ bb967cab-2ca5-4dac-8809-65b2b28a6350
+ true
+ true
+ DiagnosticAnalyzer.CSharp
+ true
+ true
+
+
+
+ Empty.txt
+
+
+
+ Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
+ RoslynSDKAnalyzerCSharpTemplateWizard
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.CS/Empty.txt b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.CS/Empty.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.VB/Empty.txt b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.VB/Empty.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.VB/VBAnalyzer.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.VB/VBAnalyzer.csproj
new file mode 100644
index 000000000..97f1e374f
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.VB/VBAnalyzer.csproj
@@ -0,0 +1,12 @@
+
+
+
+ netstandard2.0
+ false
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.VB/VBAnalyzer.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.VB/VBAnalyzer.vstemplate
new file mode 100644
index 000000000..c26fc278b
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer.VB/VBAnalyzer.vstemplate
@@ -0,0 +1,28 @@
+
+
+
+ DiagnosticAnalyzer.VisualBasic
+ <No description available>
+
+ CSharp
+ 2.0
+ 952
+ bb967cab-2ca5-4dac-8809-65b2b28a6350
+ true
+ true
+ DiagnosticAnalyzer.VisualBasic
+ true
+ true
+
+
+
+ Empty.txt
+
+
+
+ Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
+ RoslynSDKAnalyzerVisualBasicTemplateWizard
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.cs
index 9b3329cdf..89e301086 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.cs
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.cs
@@ -1,16 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
+using System.Collections.Immutable;
using System.Linq;
-using System.Threading;
using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace $saferootprojectname$
{
- [DiagnosticAnalyzer(LanguageNames.CSharp)]
+ [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
public class $saferootidentifiername$Analyzer : DiagnosticAnalyzer
{
public const string DiagnosticId = "$saferootidentifiername$";
@@ -28,6 +23,9 @@ public class $saferootidentifiername$Analyzer : DiagnosticAnalyzer
public override void Initialize(AnalysisContext context)
{
+ context.EnableConcurrentExecution();
+ context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
+
// TODO: Consider registering other actions that act on syntax instead of or in addition to symbols
// See https://github.com/dotnet/roslyn/blob/master/docs/analyzers/Analyzer%20Actions%20Semantics.md for more information
context.RegisterSymbolAction(AnalyzeSymbol, SymbolKind.NamedType);
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj
index b50f469c8..113b47bdf 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Analyzer/DiagnosticAnalyzer.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFix.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFix.csproj
new file mode 100644
index 000000000..0c4a821d3
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFix.csproj
@@ -0,0 +1,13 @@
+
+
+
+ netstandard2.0
+ false
+ $saferootprojectname$.CSharp
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFix.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFix.vstemplate
new file mode 100644
index 000000000..6cdd323f8
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFix.vstemplate
@@ -0,0 +1,28 @@
+
+
+
+ CodeFixProvider.CSharp
+ <No description available>
+
+ CSharp
+ 2.0
+ 952
+ bb967cab-2ca5-4dac-8809-65b2b28a6350
+ true
+ true
+ CodeFixProvider.CSharp
+ true
+ true
+
+
+
+ CSCodeFixProvider.cs
+
+
+
+ Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
+ RoslynSDKCodeFixCSharpTemplateWizard
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFixProvider.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFixProvider.cs
new file mode 100644
index 000000000..51eea4c36
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.CS/CSCodeFixProvider.cs
@@ -0,0 +1,34 @@
+using System.Composition;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Rename;
+
+namespace $saferootprojectname$
+{
+ [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CSharp$saferootidentifiername$CodeFixProvider)), Shared]
+ public class CSharp$saferootidentifiername$CodeFixProvider : Abstract$saferootidentifiername$CodeFixProvider
+ {
+ protected override async Task MakeUppercaseAsync(Document document, TypeDeclarationSyntax typeDeclaration, CancellationToken cancellationToken)
+ {
+ // Compute new uppercase name.
+ var identifierToken = typeDeclaration.Identifier;
+ var newName = identifierToken.Text.ToUpperInvariant();
+
+ // Get the symbol representing the type to be renamed.
+ var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
+ var typeSymbol = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken);
+
+ // Produce a new solution that has all references to that type renamed, including the declaration.
+ var originalSolution = document.Project.Solution;
+ var optionSet = originalSolution.Workspace.Options;
+ var newSolution = await Renamer.RenameSymbolAsync(document.Project.Solution, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(false);
+
+ // Return the new solution with the now-uppercase type name.
+ return newSolution;
+ }
+ }
+}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFix.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFix.csproj
new file mode 100644
index 000000000..55c08332e
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFix.csproj
@@ -0,0 +1,13 @@
+
+
+
+ netstandard2.0
+ false
+ $saferootprojectname$.VisualBasic
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFix.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFix.vstemplate
new file mode 100644
index 000000000..e472f5fbe
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFix.vstemplate
@@ -0,0 +1,28 @@
+
+
+
+ CodeFixProvider.VisualBasic
+ <No description available>
+
+ CSharp
+ 2.0
+ 952
+ bb967cab-2ca5-4dac-8809-65b2b28a6350
+ true
+ true
+ CodeFixProvider.VisualBasic
+ true
+ true
+
+
+
+ VBCodeFixProvider.cs
+
+
+
+ Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
+ RoslynSDKCodeFixVisualBasicTemplateWizard
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFixProvider.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFixProvider.cs
new file mode 100644
index 000000000..fba646034
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix.VB/VBCodeFixProvider.cs
@@ -0,0 +1,34 @@
+using System.Composition;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.Rename;
+using Microsoft.CodeAnalysis.VisualBasic;
+using Microsoft.CodeAnalysis.VisualBasic.Syntax;
+
+namespace $saferootprojectname$
+{
+ [ExportCodeFixProvider(LanguageNames.VisualBasic, Name = nameof(VisualBasic$saferootidentifiername$CodeFixProvider)), Shared]
+ public class VisualBasic$saferootidentifiername$CodeFixProvider : Abstract$saferootidentifiername$CodeFixProvider
+ {
+ protected override async Task MakeUppercaseAsync(Document document, TypeStatementSyntax typeDeclaration, CancellationToken cancellationToken)
+ {
+ // Compute new uppercase name.
+ var identifierToken = typeDeclaration.Identifier;
+ var newName = identifierToken.Text.ToUpperInvariant();
+
+ // Get the symbol representing the type to be renamed.
+ var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
+ var typeSymbol = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken);
+
+ // Produce a new solution that has all references to that type renamed, including the declaration.
+ var originalSolution = document.Project.Solution;
+ var optionSet = originalSolution.Workspace.Options;
+ var newSolution = await Renamer.RenameSymbolAsync(document.Project.Solution, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(false);
+
+ // Return the new solution with the now-uppercase type name.
+ return newSolution;
+ }
+ }
+}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/AbstractCodeFixProvider.cs
similarity index 51%
rename from src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.cs
rename to src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/AbstractCodeFixProvider.cs
index cee0d3181..14813d90f 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.cs
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/AbstractCodeFixProvider.cs
@@ -1,22 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
+using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Rename;
-using Microsoft.CodeAnalysis.Text;
namespace $saferootprojectname$
{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof($saferootidentifiername$CodeFixProvider)), Shared]
- public class $saferootidentifiername$CodeFixProvider : CodeFixProvider
+ public abstract class Abstract$saferootidentifiername$CodeFixProvider : CodeFixProvider
+ where TTypeDeclaration : SyntaxNode
{
public sealed override ImmutableArray FixableDiagnosticIds
{
@@ -38,7 +31,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
var diagnosticSpan = diagnostic.Location.SourceSpan;
// Find the type declaration identified by the diagnostic.
- var declaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType().First();
+ var declaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType().First();
// Register a code action that will invoke the fix.
context.RegisterCodeFix(
@@ -49,23 +42,6 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
diagnostic);
}
- private async Task MakeUppercaseAsync(Document document, TypeDeclarationSyntax typeDecl, CancellationToken cancellationToken)
- {
- // Compute new uppercase name.
- var identifierToken = typeDecl.Identifier;
- var newName = identifierToken.Text.ToUpperInvariant();
-
- // Get the symbol representing the type to be renamed.
- var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
- var typeSymbol = semanticModel.GetDeclaredSymbol(typeDecl, cancellationToken);
-
- // Produce a new solution that has all references to that type renamed, including the declaration.
- var originalSolution = document.Project.Solution;
- var optionSet = originalSolution.Workspace.Options;
- var newSolution = await Renamer.RenameSymbolAsync(document.Project.Solution, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(false);
-
- // Return the new solution with the now-uppercase type name.
- return newSolution;
- }
+ protected abstract Task MakeUppercaseAsync(Document document, TTypeDeclaration typeDeclaration, CancellationToken cancellationToken);
}
}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.csproj
index 1c091606e..50b190714 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.csproj
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.vstemplate
index 267bf2505..eb505696e 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.vstemplate
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/CodeFix/CodeFixProvider.vstemplate
@@ -18,7 +18,7 @@
- CodeFixProvider.cs
+ AbstractCodeFixProvider.cs
CodeFixResources.resx
CodeFixResources.Designer.cs
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Package/Package.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Package/Package.csproj
index b37b009b4..f9801b45c 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Package/Package.csproj
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Package/Package.csproj
@@ -32,7 +32,14 @@
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/Test.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/Test.csproj
index 5f886e29e..0d5a59cb7 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/Test.csproj
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/Test.csproj
@@ -14,6 +14,9 @@
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/UnitTests.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/UnitTests.cs
index 18ef56092..6851081e1 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/UnitTests.cs
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Test/UnitTests.cs
@@ -1,32 +1,37 @@
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;
-using $saferootprojectname$;
-using Verify = Microsoft.CodeAnalysis.CSharp.Testing.MSTest.CodeFixVerifier<
+using VerifyCS = Microsoft.CodeAnalysis.CSharp.Testing.MSTest.CodeFixVerifier<
$saferootprojectname$.$saferootidentifiername$Analyzer,
- $saferootprojectname$.$saferootidentifiername$CodeFixProvider>;
+ $saferootprojectname$.CSharp$saferootidentifiername$CodeFixProvider>;
+using VerifyVB = Microsoft.CodeAnalysis.VisualBasic.Testing.MSTest.CodeFixVerifier<
+ $saferootprojectname$.$saferootidentifiername$Analyzer,
+ $saferootprojectname$.VisualBasic$saferootidentifiername$CodeFixProvider>;
namespace $safeprojectname$
{
[TestClass]
- public class UnitTest
+ public class $saferootidentifiername$UnitTest
{
//No diagnostics expected to show up
[TestMethod]
- public async Task TestMethod1()
+ public async Task TestMethod1_CSharp()
{
var test = @"";
- await Verify.VerifyAnalyzerAsync(test);
+ await VerifyCS.VerifyAnalyzerAsync(test);
+ }
+
+ [TestMethod]
+ public async Task TestMethod1_VisualBasic()
+ {
+ var test = @"";
+
+ await VerifyVB.VerifyAnalyzerAsync(test);
}
//Diagnostic and CodeFix both triggered and checked for
[TestMethod]
- public async Task TestMethod2()
+ public async Task TestMethod2_CSharp()
{
var test = @"
using System;
@@ -38,7 +43,7 @@ public async Task TestMethod2()
namespace ConsoleApplication1
{
- class TypeName
+ class {|#0:TypeName|}
{
}
}";
@@ -58,8 +63,33 @@ class TYPENAME
}
}";
- var expected = Verify.Diagnostic("$saferootidentifiername$").WithLocation(11, 15).WithArguments("TypeName");
- await Verify.VerifyCodeFixAsync(test, expected, fixtest);
+ var expected = VerifyCS.Diagnostic("$saferootidentifiername$").WithLocation(0).WithArguments("TypeName");
+ await VerifyCS.VerifyCodeFixAsync(test, expected, fixtest);
+ }
+
+ [TestMethod]
+ public async Task TestMethod2_VisualBasic()
+ {
+ var test = @"
+Class {|#0:TypeName|}
+
+ Sub Main()
+
+ End Sub
+
+End Class";
+
+ var fixtest = @"
+Class TYPENAME
+
+ Sub Main()
+
+ End Sub
+
+End Class";
+
+ var expected = VerifyVB.Diagnostic("$saferootidentifiername$").WithLocation(0).WithArguments("TypeName");
+ await VerifyVB.VerifyCodeFixAsync(test, expected, fixtest);
}
}
}
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Vsix/source.extension.vsixmanifest b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Vsix/source.extension.vsixmanifest
index 5412f6779..bc3069d7c 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Vsix/source.extension.vsixmanifest
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/Diagnostic/Vsix/source.extension.vsixmanifest
@@ -14,8 +14,16 @@
+
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.CS/CSAnalyzer.vbproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.CS/CSAnalyzer.vbproj
new file mode 100644
index 000000000..a94a26cf0
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.CS/CSAnalyzer.vbproj
@@ -0,0 +1,12 @@
+
+
+
+ netstandard2.0
+ false
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.CS/CSAnalyzer.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.CS/CSAnalyzer.vstemplate
new file mode 100644
index 000000000..fff7621ea
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.CS/CSAnalyzer.vstemplate
@@ -0,0 +1,28 @@
+
+
+
+ DiagnosticAnalyzer.CSharp
+ <No description available>
+
+ VisualBasic
+ 2.0
+ 1000
+ bb967cab-2ca5-4dac-8809-65b2b28a6350
+ true
+ true
+ DiagnosticAnalyzer.CSharp
+ true
+ true
+
+
+
+ Empty.txt
+
+
+
+ Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
+ RoslynSDKAnalyzerCSharpTemplateWizard
+
+
\ No newline at end of file
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.CS/Empty.txt b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.CS/Empty.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.VB/Empty.txt b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.VB/Empty.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.VB/VBAnalyzer.vbproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.VB/VBAnalyzer.vbproj
new file mode 100644
index 000000000..4c6d07c5b
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.VB/VBAnalyzer.vbproj
@@ -0,0 +1,12 @@
+
+
+
+ netstandard2.0
+ false
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.VB/VBAnalyzer.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.VB/VBAnalyzer.vstemplate
new file mode 100644
index 000000000..936c52a7f
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer.VB/VBAnalyzer.vstemplate
@@ -0,0 +1,28 @@
+
+
+
+ DiagnosticAnalyzer.VisualBasic
+ <No description available>
+
+ VisualBasic
+ 2.0
+ 1000
+ bb967cab-2ca5-4dac-8809-65b2b28a6350
+ true
+ true
+ DiagnosticAnalyzer.VisualBasic
+ true
+ true
+
+
+
+ Empty.txt
+
+
+
+ Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
+ RoslynSDKAnalyzerVisualBasicTemplateWizard
+
+
\ No newline at end of file
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/Diagnostic.vbproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/Diagnostic.vbproj
index d151c678f..cf8a0d441 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/Diagnostic.vbproj
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/Diagnostic.vbproj
@@ -10,7 +10,7 @@
-
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/DiagnosticAnalyzer.vb b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/DiagnosticAnalyzer.vb
index 083fa2fe8..c654b30ab 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/DiagnosticAnalyzer.vb
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Analyzer/DiagnosticAnalyzer.vb
@@ -1,14 +1,8 @@
-Imports System
-Imports System.Collections.Generic
-Imports System.Collections.Immutable
-Imports System.Linq
-Imports System.Threading
+Imports System.Collections.Immutable
Imports Microsoft.CodeAnalysis
-Imports Microsoft.CodeAnalysis.VisualBasic
-Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.Diagnostics
-
+
Public Class $saferootidentifiername$Analyzer
Inherits DiagnosticAnalyzer
@@ -30,6 +24,9 @@ Public Class $saferootidentifiername$Analyzer
End Property
Public Overrides Sub Initialize(context As AnalysisContext)
+ context.EnableConcurrentExecution()
+ context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None)
+
' TODO: Consider registering other actions that act on syntax instead of or in addition to symbols
' See https://github.com/dotnet/roslyn/blob/master/docs/analyzers/Analyzer%20Actions%20Semantics.md for more information
context.RegisterSymbolAction(AddressOf AnalyzeSymbol, SymbolKind.NamedType)
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFix.vbproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFix.vbproj
new file mode 100644
index 000000000..34c9a190d
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFix.vbproj
@@ -0,0 +1,13 @@
+
+
+
+ netstandard2.0
+ false
+ $saferootprojectname$.CSharp
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFix.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFix.vstemplate
new file mode 100644
index 000000000..45830e419
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFix.vstemplate
@@ -0,0 +1,28 @@
+
+
+
+ CodeFixProvider.CSharp
+ <No description available>
+
+ VisualBasic
+ 2.0
+ 1000
+ bb967cab-2ca5-4dac-8809-65b2b28a6350
+ true
+ true
+ CodeFixProvider.CSharp
+ true
+ true
+
+
+
+ CSCodeFixProvider.vb
+
+
+
+ Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
+ RoslynSDKCodeFixCSharpTemplateWizard
+
+
\ No newline at end of file
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFixProvider.vb b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFixProvider.vb
new file mode 100644
index 000000000..dfbbbbbcd
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.CS/CSCodeFixProvider.vb
@@ -0,0 +1,30 @@
+Imports System.Composition
+Imports System.Threading
+Imports Microsoft.CodeAnalysis
+Imports Microsoft.CodeAnalysis.CodeFixes
+Imports Microsoft.CodeAnalysis.CSharp
+Imports Microsoft.CodeAnalysis.CSharp.Syntax
+Imports Microsoft.CodeAnalysis.Rename
+
+
+Public Class CSharp$saferootidentifiername$CodeFixProvider
+ Inherits Abstract$saferootidentifiername$CodeFixProvider(Of TypeDeclarationSyntax)
+
+ Protected Overrides Async Function MakeUppercaseAsync(document As Document, typeDeclaration As TypeDeclarationSyntax, cancellationToken As CancellationToken) As Task(Of Solution)
+ ' Compute new uppercase name.
+ Dim identifierToken = typeDeclaration.Identifier
+ Dim newName = identifierToken.Text.ToUpperInvariant()
+
+ ' Get the symbol representing the type to be renamed.
+ Dim semanticModel = Await document.GetSemanticModelAsync(cancellationToken)
+ Dim typeSymbol = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken)
+
+ ' Produce a new solution that has all references to that type renamed, including the declaration.
+ Dim originalSolution = document.Project.Solution
+ Dim optionSet = originalSolution.Workspace.Options
+ Dim newSolution = Await Renamer.RenameSymbolAsync(document.Project.Solution, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(False)
+
+ ' Return the new solution with the now-uppercase type name.
+ Return newSolution
+ End Function
+End Class
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFix.vbproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFix.vbproj
new file mode 100644
index 000000000..5a53feb23
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFix.vbproj
@@ -0,0 +1,13 @@
+
+
+
+ netstandard2.0
+ false
+ $saferootprojectname$.VisualBasic
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFix.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFix.vstemplate
new file mode 100644
index 000000000..45812b6bd
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFix.vstemplate
@@ -0,0 +1,28 @@
+
+
+
+ CodeFixProvider
+ <No description available>
+
+ VisualBasic
+ 2.0
+ 1000
+ bb967cab-2ca5-4dac-8809-65b2b28a6350
+ true
+ true
+ CodeFixProvider
+ true
+ true
+
+
+
+ VBCodeFixProvider.vb
+
+
+
+ Roslyn.SDK.Template.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
+ RoslynSDKCodeFixVisualBasicTemplateWizard
+
+
\ No newline at end of file
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFixProvider.vb b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFixProvider.vb
new file mode 100644
index 000000000..649174091
--- /dev/null
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix.VB/VBCodeFixProvider.vb
@@ -0,0 +1,30 @@
+Imports System.Composition
+Imports System.Threading
+Imports Microsoft.CodeAnalysis
+Imports Microsoft.CodeAnalysis.CodeFixes
+Imports Microsoft.CodeAnalysis.Rename
+Imports Microsoft.CodeAnalysis.VisualBasic
+Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
+
+
+Public Class VisualBasic$saferootidentifiername$CodeFixProvider
+ Inherits Abstract$saferootidentifiername$CodeFixProvider(Of TypeStatementSyntax)
+
+ Protected Overrides Async Function MakeUppercaseAsync(document As Document, typeDeclaration As TypeStatementSyntax, cancellationToken As CancellationToken) As Task(Of Solution)
+ ' Compute new uppercase name.
+ Dim identifierToken = typeDeclaration.Identifier
+ Dim newName = identifierToken.Text.ToUpperInvariant()
+
+ ' Get the symbol representing the type to be renamed.
+ Dim semanticModel = Await document.GetSemanticModelAsync(cancellationToken)
+ Dim typeSymbol = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken)
+
+ ' Produce a new solution that has all references to that type renamed, including the declaration.
+ Dim originalSolution = document.Project.Solution
+ Dim optionSet = originalSolution.Workspace.Options
+ Dim newSolution = Await Renamer.RenameSymbolAsync(document.Project.Solution, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(False)
+
+ ' Return the new solution with the now-uppercase type name.
+ Return newSolution
+ End Function
+End Class
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vb b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/AbstractCodeFixProvider.vb
similarity index 50%
rename from src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vb
rename to src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/AbstractCodeFixProvider.vb
index 0c722c566..be603cae9 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vb
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/AbstractCodeFixProvider.vb
@@ -1,20 +1,10 @@
-Imports System
-Imports System.Collections.Generic
-Imports System.Collections.Immutable
-Imports System.Composition
-Imports System.Linq
+Imports System.Collections.Immutable
Imports System.Threading
-Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.CodeActions
-Imports Microsoft.CodeAnalysis.VisualBasic
-Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
-Imports Microsoft.CodeAnalysis.Rename
-Imports Microsoft.CodeAnalysis.Text
-
-Public Class $saferootidentifiername$CodeFixProvider
+Public MustInherit Class Abstract$saferootidentifiername$CodeFixProvider(Of TTypeDeclaration As SyntaxNode)
Inherits CodeFixProvider
Public NotOverridable Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String)
@@ -37,7 +27,7 @@ Public Class $saferootidentifiername$CodeFixProvider
Dim diagnosticSpan = diagnostic.Location.SourceSpan
' Find the type statement identified by the diagnostic.
- Dim declaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType(Of TypeStatementSyntax)().First()
+ Dim declaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType(Of TTypeDeclaration)().First()
' Register a code action that will invoke the fix.
context.RegisterCodeFix(
@@ -48,21 +38,5 @@ Public Class $saferootidentifiername$CodeFixProvider
diagnostic)
End Function
- Private Async Function MakeUppercaseAsync(document As Document, typeStmt As TypeStatementSyntax, cancellationToken As CancellationToken) As Task(Of Solution)
- ' Compute new uppercase name.
- Dim identifierToken = typeStmt.Identifier
- Dim newName = identifierToken.Text.ToUpperInvariant()
-
- ' Get the symbol representing the type to be renamed.
- Dim semanticModel = Await document.GetSemanticModelAsync(cancellationToken)
- Dim typeSymbol = semanticModel.GetDeclaredSymbol(typeStmt, cancellationToken)
-
- ' Produce a new solution that has all references to that type renamed, including the declaration.
- Dim originalSolution = document.Project.Solution
- Dim optionSet = originalSolution.Workspace.Options
- Dim newSolution = Await Renamer.RenameSymbolAsync(document.Project.Solution, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(False)
-
- ' Return the new solution with the now-uppercase type name.
- Return newSolution
- End Function
+ Protected MustOverride Function MakeUppercaseAsync(document As Document, typeDeclaration As TTypeDeclaration, cancellationToken As CancellationToken) As Task(Of Solution)
End Class
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vbproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vbproj
index 448fff539..fdd0290ca 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vbproj
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vbproj
@@ -7,7 +7,7 @@
-
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vstemplate
index 113c0562c..1c0af8a73 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vstemplate
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/CodeFix/CodeFixProvider.vstemplate
@@ -18,7 +18,7 @@
- CodeFixProvider.vb
+ AbstractCodeFixProvider.vb
CodeFixResources.resx
CodeFixResources.Designer.vb
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Package/Package.vbproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Package/Package.vbproj
index 86005e455..ed17d762f 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Package/Package.vbproj
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Package/Package.vbproj
@@ -32,7 +32,14 @@
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTestProject.vbproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTestProject.vbproj
index e5f80410b..da8ab982d 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTestProject.vbproj
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTestProject.vbproj
@@ -11,6 +11,9 @@
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTests.vb b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTests.vb
index f8bb4e415..b679c2ab2 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTests.vb
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Test/UnitTests.vb
@@ -1,50 +1,89 @@
-Imports $saferootprojectname$
-Imports Microsoft.CodeAnalysis
-Imports Microsoft.CodeAnalysis.CodeFixes
-Imports Microsoft.CodeAnalysis.Diagnostics
-Imports Microsoft.VisualStudio.TestTools.UnitTesting
-Imports System.Threading
-Imports System.Threading.Tasks
-Imports Verify = Microsoft.CodeAnalysis.VisualBasic.Testing.MSTest.CodeFixVerifier(
+Imports Microsoft.VisualStudio.TestTools.UnitTesting
+Imports VerifyCS = Microsoft.CodeAnalysis.CSharp.Testing.MSTest.CodeFixVerifier(
Of $saferootprojectname$.$saferootidentifiername$Analyzer,
- $saferootprojectname$.$saferootidentifiername$CodeFixProvider)
+ $saferootprojectname$.CSharp.CSharp$saferootidentifiername$CodeFixProvider)
+Imports VerifyVB = Microsoft.CodeAnalysis.VisualBasic.Testing.MSTest.CodeFixVerifier(
+ Of $saferootprojectname$.$saferootidentifiername$Analyzer,
+ $saferootprojectname$.VisualBasic.VisualBasic$saferootidentifiername$CodeFixProvider)
Namespace $safeprojectname$
- Public Class UnitTest
+ Public Class $saferootidentifiername$UnitTest
'No diagnostics expected to show up
- Public Async Function TestMethod1() As Task
+ Public Async Function TestMethod1_CSharp() As Task
+ Dim test = ""
+ Await VerifyCS.VerifyAnalyzerAsync(test)
+ End Function
+
+
+ Public Async Function TestMethod1_VisualBasic() As Task
Dim test = ""
- Await Verify.VerifyAnalyzerAsync(test)
+ Await VerifyVB.VerifyAnalyzerAsync(test)
End Function
'Diagnostic And CodeFix both triggered And checked for
- Public Async Function TestMethod2() As Task
+ Public Async Function TestMethod2_CSharp() As Task
+
+ Dim test = "
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Threading.Tasks;
+ using System.Diagnostics;
+
+ namespace ConsoleApplication1
+ {
+ class {|#0:TypeName|}
+ {
+ }
+ }"
+
+ Dim fixtest = "
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Threading.Tasks;
+ using System.Diagnostics;
+
+ namespace ConsoleApplication1
+ {
+ class TYPENAME
+ {
+ }
+ }"
+
+ Dim expected = VerifyCS.Diagnostic("$saferootidentifiername$").WithLocation(0).WithArguments("TypeName")
+ Await VerifyCS.VerifyCodeFixAsync(test, expected, fixtest)
+ End Function
+
+
+ Public Async Function TestMethod2_VisualBasic() As Task
Dim test = "
-Module Module1
+Class {|#0:TypeName|}
Sub Main()
End Sub
-End Module"
+End Class"
Dim fixtest = "
-Module MODULE1
+Class TYPENAME
Sub Main()
End Sub
-End Module"
+End Class"
- Dim expected = Verify.Diagnostic("$saferootidentifiername$").WithLocation(2, 8).WithArguments("Module1")
- Await Verify.VerifyCodeFixAsync(test, expected, fixtest)
+ Dim expected = VerifyVB.Diagnostic("$saferootidentifiername$").WithLocation(0).WithArguments("TypeName")
+ Await VerifyVB.VerifyCodeFixAsync(test, expected, fixtest)
End Function
-
End Class
End Namespace
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Vsix/source.extension.vsixmanifest b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Vsix/source.extension.vsixmanifest
index b5d1aa844..1adb92802 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Vsix/source.extension.vsixmanifest
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/VisualBasic/Diagnostic/Vsix/source.extension.vsixmanifest
@@ -14,8 +14,16 @@
+
+
+
+
+
+
+
+
diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/VBDiagnostic.vstemplate b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/VBDiagnostic.vstemplate
index bf6f5d9a6..16d1005e0 100644
--- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/VBDiagnostic.vstemplate
+++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/VBDiagnostic.vstemplate
@@ -31,9 +31,21 @@
ProjectTemplates\VisualBasic\Diagnostic\Analyzer\DiagnosticAnalyzer.vstemplate
+
+ ProjectTemplates\VisualBasic\Diagnostic\Analyzer.CS\CSAnalyzer.vstemplate
+
+
+ ProjectTemplates\VisualBasic\Diagnostic\Analyzer.VB\VBAnalyzer.vstemplate
+
ProjectTemplates\VisualBasic\Diagnostic\CodeFix\CodeFixProvider.vstemplate
+
+ ProjectTemplates\VisualBasic\Diagnostic\CodeFix.CS\CSCodeFix.vstemplate
+
+
+ ProjectTemplates\VisualBasic\Diagnostic\CodeFix.VB\VBCodeFix.vstemplate
+
ProjectTemplates\VisualBasic\Diagnostic\Package\Package.vstemplate
diff --git a/tests/VisualStudio.Roslyn.SDK/Roslyn.SDK.IntegrationTests/CreateProjectTests.cs b/tests/VisualStudio.Roslyn.SDK/Roslyn.SDK.IntegrationTests/CreateProjectTests.cs
index cd3e0b6ee..5f349dc21 100644
--- a/tests/VisualStudio.Roslyn.SDK/Roslyn.SDK.IntegrationTests/CreateProjectTests.cs
+++ b/tests/VisualStudio.Roslyn.SDK/Roslyn.SDK.IntegrationTests/CreateProjectTests.cs
@@ -51,7 +51,7 @@ public async Task CreateAnalyzerFromCSharpTemplateAsync()
await TestServices.SolutionExplorer.RestoreNuGetPackagesAsync(HangMitigatingCancellationToken);
var buildSummary = await TestServices.SolutionExplorer.BuildSolutionAsync(waitForBuildToFinish: true);
- Assert.Equal("========== Build: 5 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========", buildSummary);
+ Assert.Equal("========== Build: 9 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========", buildSummary);
await TestServices.ErrorList.ShowBuildErrorsAsync();
@@ -61,10 +61,8 @@ public async Task CreateAnalyzerFromCSharpTemplateAsync()
// Currently have two analyzer warnings in the template.
var warnings = await TestServices.ErrorList.GetBuildErrorsAsync(__VSERRORCATEGORY.EC_WARNING);
- var expected = @"(Compiler) TestProjAnalyzer.cs(29, 57): warning RS1025: Configure generated code analysis
-(Compiler) TestProjAnalyzer.cs(29, 57): warning RS1026: Enable concurrent execution";
- new XUnitVerifier().EqualOrDiff(expected, string.Join(Environment.NewLine, warnings));
- Assert.Equal(2, await TestServices.ErrorList.GetErrorCountAsync(__VSERRORCATEGORY.EC_WARNING));
+ new XUnitVerifier().EqualOrDiff(string.Empty, string.Join(Environment.NewLine, warnings));
+ Assert.Equal(0, await TestServices.ErrorList.GetErrorCountAsync(__VSERRORCATEGORY.EC_WARNING));
}
[VsFact]
@@ -107,7 +105,7 @@ public async Task CreateAnalyzerFromVisualBasicTemplateAsync()
await TestServices.SolutionExplorer.RestoreNuGetPackagesAsync(HangMitigatingCancellationToken);
var buildSummary = await TestServices.SolutionExplorer.BuildSolutionAsync(waitForBuildToFinish: true);
- Assert.Equal("========== Build: 5 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========", buildSummary);
+ Assert.Equal("========== Build: 9 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========", buildSummary);
await TestServices.ErrorList.ShowBuildErrorsAsync();
@@ -117,10 +115,8 @@ public async Task CreateAnalyzerFromVisualBasicTemplateAsync()
// Currently have two analyzer warnings in the template.
var warnings = await TestServices.ErrorList.GetBuildErrorsAsync(__VSERRORCATEGORY.EC_WARNING);
- var expected = @"(Compiler) TestProjAnalyzer.vb(32, 37): warning RS1025: Configure generated code analysis
-(Compiler) TestProjAnalyzer.vb(32, 37): warning RS1026: Enable concurrent execution";
- new XUnitVerifier().EqualOrDiff(expected, string.Join(Environment.NewLine, warnings));
- Assert.Equal(2, await TestServices.ErrorList.GetErrorCountAsync(__VSERRORCATEGORY.EC_WARNING));
+ new XUnitVerifier().EqualOrDiff(string.Empty, string.Join(Environment.NewLine, warnings));
+ Assert.Equal(0, await TestServices.ErrorList.GetErrorCountAsync(__VSERRORCATEGORY.EC_WARNING));
}
[VsFact]