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

Port few IDE analyzers/fixers to shared layer to be enabled in CodeStyle NuGet package #41363

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f18cea7
Analyzer and code fixes refactoring
mavasani Jan 29, 2020
c3ecec5
Port CSharpMakeStructFieldsWritableDiagnosticAnalyzer and fixer
mavasani Jan 31, 2020
2e32204
Port ConvertSwitchStatementToExpression to CodeStyle layer
mavasani Feb 1, 2020
df116e9
Port C# type style analyzers (UseImplicitOrExplicitType) to code styl…
mavasani Feb 2, 2020
a6579cc
Port RemoveUnnecessaryImports analyzer/fixer to code style layer
mavasani Feb 2, 2020
2750a86
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 3, 2020
09e77dc
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 4, 2020
493b727
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 4, 2020
2046dbb
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 6, 2020
9297c51
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 6, 2020
c4ebb30
Refactor remove unncessary imports service
mavasani Feb 7, 2020
46ef3bb
Disable some nullable related unit tests for CodeStyle layer as they …
mavasani Feb 7, 2020
53fdfe0
Add clarification comment
mavasani Feb 7, 2020
68c74bf
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 7, 2020
cc3910c
Remove the last remaining extern alias.
mavasani Feb 7, 2020
677d292
Remove stale xlf files.
mavasani Feb 7, 2020
3e69af5
Revert changes to DocumentBasedFixAllProvider and AbstractFormattingC…
mavasani Feb 7, 2020
1e8b5d0
Remove CodeStyle layer from Compiler.sln due to dependencies on proje…
mavasani Feb 7, 2020
f1c5abe
Revert unnecessary code changes
mavasani Feb 7, 2020
26540d4
Project changes to avoid C# and VB CodeStyle unit test projects depen…
mavasani Feb 7, 2020
3050f34
Mark CodeStyle test projects as non-Shipping.
mavasani Feb 7, 2020
868886a
Test code refactoring to avoid C# and VB EditorFeatures UnitTests pro…
mavasani Feb 7, 2020
23dc0c0
Add direct project references in UnitTest projects to please BuildBoss
mavasani Feb 7, 2020
f70503d
Fix some more test project references
mavasani Feb 7, 2020
216ab58
Change signature for IncludeDiagnosticDuringFixAll
mavasani Feb 7, 2020
fb1940f
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 8, 2020
c7a3026
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 10, 2020
86304ff
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 10, 2020
7d7bfc8
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 10, 2020
f1b4a01
Delete duplicate file added by automatic merge conflict resolution
mavasani Feb 10, 2020
f0ed15e
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 10, 2020
6f9b2ce
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 11, 2020
f2f18c0
Fixes from conflicts
mavasani Feb 12, 2020
8e0fe0d
Revert unwanted changes and remove usage of extern aliases
mavasani Feb 12, 2020
7f9d9e1
Use shared resource files in shared projects.
mavasani Feb 12, 2020
1e1b9a7
Revert some unrelated changes
mavasani Feb 12, 2020
fee840f
Make analyzer diagnostics in CodeStyle layer be warnings by default.
mavasani Feb 12, 2020
d22e50c
Add comment
mavasani Feb 12, 2020
870fa85
Merge remote-tracking branch 'upstream/master' into RefactorAnalyzerA…
mavasani Feb 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
102 changes: 102 additions & 0 deletions Roslyn.sln

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>ec946164-1e17-410b-b7d9-7de7e6268d63</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.CodeAnalysis.CSharp.Analyzers</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{EAFFCA55-335B-4860-BB99-EFCEAD123199}</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="CSharpAnalyzers.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
14 changes: 14 additions & 0 deletions src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>ec946164-1e17-410b-b7d9-7de7e6268d63</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.CodeAnalysis.CSharp.CodeFixes</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\CSharpRemoveUnusedMembersCodeFixProvider.cs" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{DA973826-C985-4128-9948-0B445E638BDB}</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="CSharpCodeFixes.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
14 changes: 14 additions & 0 deletions src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>ec946164-1e17-410b-b7d9-7de7e6268d63</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\RemoveUnusedMembersTests.cs" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{58969243-7F59-4236-93D0-C93B81F569B3}</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="CSharpAnalyzers.UnitTests.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.RemoveUnusedMembers
{
#if CODE_STYLE
using AnalyzerResources = CodeStyleResources;
#else
using AnalyzerResources = FeaturesResources;
#endif

public class RemoveUnusedMembersTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
Expand Down Expand Up @@ -1096,7 +1102,7 @@ public void M()
using var workspace = CreateWorkspaceFromOptions(source, testParameters);
var diagnostics = await GetDiagnosticsAsync(workspace, testParameters).ConfigureAwait(false);
diagnostics.Verify(Diagnostic("IDE0052", "P").WithLocation(3, 17));
var expectedMessage = string.Format(FeaturesResources.Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked, "MyClass.P");
var expectedMessage = string.Format(AnalyzerResources.Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked, "MyClass.P");
Assert.Equal(expectedMessage, diagnostics.Single().GetMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

namespace Microsoft.CodeAnalysis.CodeStyle
{
#if CODE_STYLE
using OptionSet = AnalyzerConfigOptions;
#else
using OptionSet = Options.OptionSet;
#endif
mavasani marked this conversation as resolved.
Show resolved Hide resolved

internal abstract class AbstractBuiltInCodeStyleDiagnosticAnalyzer : AbstractCodeStyleDiagnosticAnalyzer, IBuiltInAnalyzer
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.CodeQuality
{
#if CODE_STYLE
using OptionSet = AnalyzerConfigOptions;
#else
using OptionSet = Options.OptionSet;
#endif

internal abstract class AbstractCodeQualityDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer
{
private readonly GeneratedCodeAnalysisFlags _generatedCodeAnalysisFlags;
Expand Down
28 changes: 28 additions & 0 deletions src/Analyzers/Core/Analyzers/Analyzers.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>ec946164-1e17-410b-b7d9-7de7e6268d63</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.CodeAnalysis.Analyzers</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AbstractCodeQualityDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AbstractCodeStyleDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DiagnosticAnalyzerCategory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DiagnosticCategory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DiagnosticCustomTags.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\DeserializationConstructorCheck.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\DiagnosticHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IBuiltInAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IDEDiagnosticIds.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IDEDiagnosticIdToOptionMappingHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/Analyzers/Core/Analyzers/Analyzers.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{76E96966-4780-4040-8197-BDE2879516F4}</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Analyzers.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Runtime.Serialization.Json;
using System.Text;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.RemoveUnnecessaryParentheses;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Diagnostics
Expand Down Expand Up @@ -74,7 +73,7 @@ public static Diagnostic Create(
/// </param>
/// <param name="tagIndices">
/// a map of location tag to index in additional locations.
/// <see cref="AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer{TLanguageKindEnum, TParenthesizedExpressionSyntax}"/> for an example of usage.
/// see AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer for an example of usage.
/// </param>
/// <param name="messageArgs">Arguments to the message of the diagnostic.</param>
/// <returns>The <see cref="Diagnostic"/> instance.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Diagnostics
{
#if CODE_STYLE
Copy link
Contributor Author

@mavasani mavasani Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any code accessing OptionSet in our shared projects is going to need such #if until we can move all our analyzer/fixers linked into Features.dll to also move to AnalyzerConfigOptions (tracked by #41462). Even then we might have cases where we need these when a helper method in Workspace layer needs to be invoked outside the analyzer/fixer context and needs to operate on OptionSet, while the same helper is required by some analyzer/fixer and must operate on AnalyzerConfigOptions

using OptionSet = AnalyzerConfigOptions;
#else
using OptionSet = Options.OptionSet;
#endif

/// <summary>
/// This interface is a marker for all the analyzers that are built in.
/// We will record non-fatal-watson if any analyzer with this interface throws an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

namespace Microsoft.CodeAnalysis.RemoveUnusedMembers
{
#if CODE_STYLE
using Resources = CodeStyleResources;
#else
using Resources = FeaturesResources;
#endif

internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer<TDocumentationCommentTriviaSyntax, TIdentifierNameSyntax>
: AbstractCodeQualityDiagnosticAnalyzer
where TDocumentationCommentTriviaSyntax : SyntaxNode
Expand All @@ -25,15 +31,15 @@ internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer<TDocumenta
// IDE0051: "Remove unused members" (Symbol is declared but never referenced)
private static readonly DiagnosticDescriptor s_removeUnusedMembersRule = CreateDescriptor(
IDEDiagnosticIds.RemoveUnusedMembersDiagnosticId,
new LocalizableResourceString(nameof(FeaturesResources.Remove_unused_private_members), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
new LocalizableResourceString(nameof(FeaturesResources.Private_member_0_is_unused), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
new LocalizableResourceString(nameof(Resources.Remove_unused_private_members), Resources.ResourceManager, typeof(Resources)),
new LocalizableResourceString(nameof(Resources.Private_member_0_is_unused), Resources.ResourceManager, typeof(Resources)),
isUnneccessary: true);

// IDE0052: "Remove unread members" (Value is written and/or symbol is referenced, but the assigned value is never read)
private static readonly DiagnosticDescriptor s_removeUnreadMembersRule = CreateDescriptor(
IDEDiagnosticIds.RemoveUnreadMembersDiagnosticId,
new LocalizableResourceString(nameof(FeaturesResources.Remove_unread_private_members), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
new LocalizableResourceString(nameof(FeaturesResources.Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
new LocalizableResourceString(nameof(Resources.Remove_unread_private_members), Resources.ResourceManager, typeof(Resources)),
new LocalizableResourceString(nameof(Resources.Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read), Resources.ResourceManager, typeof(Resources)),
isUnneccessary: true);

protected AbstractRemoveUnusedMembersDiagnosticAnalyzer()
Expand Down Expand Up @@ -471,13 +477,13 @@ private static LocalizableString GetMessage(
switch (member)
{
case IMethodSymbol _:
messageFormat = FeaturesResources.Private_method_0_can_be_removed_as_it_is_never_invoked;
messageFormat = Resources.Private_method_0_can_be_removed_as_it_is_never_invoked;
break;

case IPropertySymbol property:
if (property.GetMethod != null && property.SetMethod != null)
{
messageFormat = FeaturesResources.Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked;
messageFormat = Resources.Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked;
}

break;
Expand Down
15 changes: 15 additions & 0 deletions src/Analyzers/Core/CodeFixes/CodeFixes.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>ec946164-1e17-410b-b7d9-7de7e6268d63</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.CodeAnalysis.CodeFixes</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)PredefinedCodeFixProviderNames.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\AbstractRemoveUnusedMembersCodeFixProvider.cs" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/Analyzers/Core/CodeFixes/CodeFixes.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
sharwell marked this conversation as resolved.
Show resolved Hide resolved
<PropertyGroup Label="Globals">
<ProjectGuid>{1B6C4A1A-413B-41FB-9F85-5C09118E541B}</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="CodeFixes.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

namespace Microsoft.CodeAnalysis.RemoveUnusedMembers
{
#if CODE_STYLE
using Resources = CodeStyleFixesResources;
#else
using Resources = FeaturesResources;
#endif

internal abstract class AbstractRemoveUnusedMembersCodeFixProvider<TFieldDeclarationSyntax> : SyntaxEditorBasedCodeFixProvider
where TFieldDeclarationSyntax : SyntaxNode
{
Expand Down Expand Up @@ -123,12 +129,13 @@ protected static void AdjustAndAddAppropriateDeclaratorsToRemove(SyntaxNode pare
}
}

private class MyCodeAction : CodeAction.DocumentChangeAction
private class MyCodeAction : CustomCodeActions.DocumentChangeAction
{
public MyCodeAction(Func<CancellationToken, Task<Document>> createChangedDocument)
: base(FeaturesResources.Remove_unused_member, createChangedDocument)
: base(Resources.Remove_unused_member, createChangedDocument)
{
}
}
}
}

11 changes: 11 additions & 0 deletions src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>ec946164-1e17-410b-b7d9-7de7e6268d63</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.CodeAnalysis.Analyzers.UnitTests</Import_RootNamespace>
</PropertyGroup>
</Project>
13 changes: 13 additions & 0 deletions src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{0C9A3C46-C74B-4528-AF62-7288AE131AF3}</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Analyzers.UnitTests.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
Loading