Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XP: Re-create projects and tests with latest templates #13

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions AssignAll/AssignAll.Vsix/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<Metadata>
<Identity Id="AssignAll.74bc95d8-2e09-485a-a68e-b4f03bece09f" Version="1.0" Language="en-US" Publisher="Andreas"/>
<Identity Id="AssignAll.74bc95d8-2e09-485a-a68e-b4f03bece09f" Version="1.0" Language="en-US" Publisher="Andreas Gullberg Larsen"/>
<DisplayName>AssignAll</DisplayName>
<Description xml:space="preserve">This is a sample diagnostic extension for the .NET Compiler Platform ("Roslyn").</Description>
<Description xml:space="preserve">Diagnostic error if there are unassigned members in an object initializer and a code fix to add the missing ones.</Description>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0,)" />
Expand All @@ -16,7 +16,7 @@
<Asset Type="Microsoft.VisualStudio.Analyzer" d:Source="Project" d:ProjectName="AssignAll" Path="|AssignAll|"/>
</Assets>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,16.0)" DisplayName="Visual Studio core editor" />
<Prerequisite Id="Microsoft.VisualStudio.Component.Roslyn.LanguageServices" Version="[15.0,16.0)" DisplayName="Roslyn Language Services" />
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" DisplayName="Visual Studio core editor" />
<Prerequisite Id="Microsoft.VisualStudio.Component.Roslyn.LanguageServices" Version="[15.0,)" DisplayName="Roslyn Language Services" />
</Prerequisites>
</PackageManifest>
58 changes: 44 additions & 14 deletions RoslynAnalyzers.sln
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssignAll", "AssignAll\AssignAll\AssignAll.csproj", "{0D09FF78-4E40-4B3A-A8A5-228248C57B0A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssignAll", "AssignAll\AssignAll\AssignAll.csproj", "{0D09FF78-4E40-4B3A-A8A5-228248C57B0A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssignAll.Test", "AssignAll\AssignAll.Test\AssignAll.Test.csproj", "{A688797A-94FA-428C-9815-DCC927C1293A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssignAll.Test", "AssignAll\AssignAll.Test\AssignAll.Test.csproj", "{A688797A-94FA-428C-9815-DCC927C1293A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssignAll.Vsix", "AssignAll\AssignAll.Vsix\AssignAll.Vsix.csproj", "{B176E12E-F1EB-4776-9D13-3F4E9064E08D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssignAll.Vsix", "AssignAll\AssignAll.Vsix\AssignAll.Vsix.csproj", "{076FA7EA-CC46-44B4-B24E-19FAF20DF1FB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Files", "Files", "{D4A0A564-543B-4220-8194-F1E7447A4E2D}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
README.md = README.md
EndProjectSection
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.ConsoleNet6", "Samples.ConsoleNet6\Samples.ConsoleNet6.csproj", "{4A5DE914-8128-4CA6-87CE-0B9A9F2B91FE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.ConsoleNet6", "Samples.ConsoleNet6\Samples.ConsoleNet6.csproj", "{4A5DE914-8128-4CA6-87CE-0B9A9F2B91FE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analyzer1", "temp\Analyzer1\Analyzer1\Analyzer1.csproj", "{39E394EC-FEBB-4EDF-BF92-16E94B18112E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analyzer1.CodeFixes", "temp\Analyzer1\Analyzer1.CodeFixes\Analyzer1.CodeFixes.csproj", "{A471C930-FBCA-4C5A-8366-06BD2E8BB3BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analyzer1.Package", "temp\Analyzer1\Analyzer1.Package\Analyzer1.Package.csproj", "{8E03FEA6-0C0D-488C-B134-63D58D53BC81}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analyzer1.Test", "temp\Analyzer1\Analyzer1.Test\Analyzer1.Test.csproj", "{45346443-A863-44C1-9CDF-2E8170423FA3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analyzer1.Vsix", "temp\Analyzer1\Analyzer1.Vsix\Analyzer1.Vsix.csproj", "{B643EE38-6D03-4CD4-BD33-5689C869AF9E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -31,14 +41,34 @@ Global
{A688797A-94FA-428C-9815-DCC927C1293A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A688797A-94FA-428C-9815-DCC927C1293A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A688797A-94FA-428C-9815-DCC927C1293A}.Release|Any CPU.Build.0 = Release|Any CPU
{B176E12E-F1EB-4776-9D13-3F4E9064E08D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B176E12E-F1EB-4776-9D13-3F4E9064E08D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B176E12E-F1EB-4776-9D13-3F4E9064E08D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B176E12E-F1EB-4776-9D13-3F4E9064E08D}.Release|Any CPU.Build.0 = Release|Any CPU
{076FA7EA-CC46-44B4-B24E-19FAF20DF1FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{076FA7EA-CC46-44B4-B24E-19FAF20DF1FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{076FA7EA-CC46-44B4-B24E-19FAF20DF1FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{076FA7EA-CC46-44B4-B24E-19FAF20DF1FB}.Release|Any CPU.Build.0 = Release|Any CPU
{4A5DE914-8128-4CA6-87CE-0B9A9F2B91FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A5DE914-8128-4CA6-87CE-0B9A9F2B91FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A5DE914-8128-4CA6-87CE-0B9A9F2B91FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A5DE914-8128-4CA6-87CE-0B9A9F2B91FE}.Release|Any CPU.Build.0 = Release|Any CPU
{39E394EC-FEBB-4EDF-BF92-16E94B18112E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39E394EC-FEBB-4EDF-BF92-16E94B18112E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39E394EC-FEBB-4EDF-BF92-16E94B18112E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39E394EC-FEBB-4EDF-BF92-16E94B18112E}.Release|Any CPU.Build.0 = Release|Any CPU
{A471C930-FBCA-4C5A-8366-06BD2E8BB3BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A471C930-FBCA-4C5A-8366-06BD2E8BB3BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A471C930-FBCA-4C5A-8366-06BD2E8BB3BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A471C930-FBCA-4C5A-8366-06BD2E8BB3BB}.Release|Any CPU.Build.0 = Release|Any CPU
{8E03FEA6-0C0D-488C-B134-63D58D53BC81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E03FEA6-0C0D-488C-B134-63D58D53BC81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E03FEA6-0C0D-488C-B134-63D58D53BC81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E03FEA6-0C0D-488C-B134-63D58D53BC81}.Release|Any CPU.Build.0 = Release|Any CPU
{45346443-A863-44C1-9CDF-2E8170423FA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45346443-A863-44C1-9CDF-2E8170423FA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45346443-A863-44C1-9CDF-2E8170423FA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45346443-A863-44C1-9CDF-2E8170423FA3}.Release|Any CPU.Build.0 = Release|Any CPU
{B643EE38-6D03-4CD4-BD33-5689C869AF9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B643EE38-6D03-4CD4-BD33-5689C869AF9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B643EE38-6D03-4CD4-BD33-5689C869AF9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B643EE38-6D03-4CD4-BD33-5689C869AF9E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
22 changes: 22 additions & 0 deletions temp/Analyzer1/Analyzer1.CodeFixes/Analyzer1.CodeFixes.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>Analyzer1</RootNamespace>
</PropertyGroup>

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

<ItemGroup>
<ProjectReference Include="..\Analyzer1\Analyzer1.csproj" />
</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>
71 changes: 71 additions & 0 deletions temp/Analyzer1/Analyzer1.CodeFixes/Analyzer1CodeFixProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Rename;
using Microsoft.CodeAnalysis.Text;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Analyzer1
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(Analyzer1CodeFixProvider)), Shared]
public class Analyzer1CodeFixProvider : CodeFixProvider
{
public sealed override ImmutableArray<string> FixableDiagnosticIds
{
get { return ImmutableArray.Create(Analyzer1Analyzer.DiagnosticId); }
}

public sealed override FixAllProvider GetFixAllProvider()
{
// See https://github.com/dotnet/roslyn/blob/main/docs/analyzers/FixAllProvider.md for more information on Fix All Providers
return WellKnownFixAllProviders.BatchFixer;
}

public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

// TODO: Replace the following code with your own analysis, generating a CodeAction for each fix to suggest
var diagnostic = context.Diagnostics.First();
var diagnosticSpan = diagnostic.Location.SourceSpan;

// Find the type declaration identified by the diagnostic.
var declaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType<TypeDeclarationSyntax>().First();

// Register a code action that will invoke the fix.
context.RegisterCodeFix(
CodeAction.Create(
title: CodeFixResources.CodeFixTitle,
createChangedSolution: c => MakeUppercaseAsync(context.Document, declaration, c),
equivalenceKey: nameof(CodeFixResources.CodeFixTitle)),
diagnostic);
}

private async Task<Solution> 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;
}
}
}
83 changes: 83 additions & 0 deletions temp/Analyzer1/Analyzer1.CodeFixes/CodeFixResources.Designer.cs

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

Loading