提交 7682627b 编写于 作者: C CyrusNajmabadi

Move files.

上级 3d905b28
......@@ -277,10 +277,10 @@
<Compile Include="Diagnostics\GenerateType\GenerateTypeTests_Dialog.cs" />
<Compile Include="Diagnostics\GenerateVariable\GenerateVariableTests.cs" />
<Compile Include="Diagnostics\HideBase\HideBaseTests.cs" />
<Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests.cs" />
<Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.cs" />
<Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceTests_FixAllTests.cs" />
<Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceTests.cs" />
<Compile Include="ImplementAbstractClass\ImplementAbstractClassTests.cs" />
<Compile Include="ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.cs" />
<Compile Include="ImplementInterface\ImplementInterfaceTests_FixAllTests.cs" />
<Compile Include="ImplementInterface\ImplementInterfaceTests.cs" />
<Compile Include="Diagnostics\Iterator\AddYieldTests.cs" />
<Compile Include="Diagnostics\Iterator\ChangeToIEnumerableTests.cs" />
<Compile Include="Diagnostics\MockDiagnosticAnalyzerTests.cs" />
......
......@@ -2,26 +2,25 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeFixes.ImplementAbstractClass;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.ImplementAbstractClass;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Options;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.ImplementAbstractClass
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ImplementAbstractClass
{
public partial class ImplementAbstractClassTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override Tuple<DiagnosticAnalyzer, CodeFixProvider> CreateDiagnosticProviderAndFixer(Workspace workspace)
{
return new Tuple<DiagnosticAnalyzer, CodeFixProvider>(
null, new ImplementAbstractClassCodeFixProvider());
null, new CSharpImplementAbstractClassCodeFixProvider());
}
private static readonly Dictionary<OptionKey, object> AllOptionsOff =
new Dictionary<OptionKey, object>
......
// 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 System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.CodeFixes.ImplementAbstractClass;
using Microsoft.CodeAnalysis.CSharp.ImplementAbstractClass;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.ImplementAbstractClass
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ImplementAbstractClass
{
public partial class ImplementAbstractClassTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
public partial class ImplementAbstractClassTests
{
#region "Fix all occurrences tests"
......@@ -16,7 +16,7 @@ public partial class ImplementAbstractClassTests : AbstractCSharpDiagnosticProvi
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
public async Task TestFixAllInDocument()
{
var fixAllActionId = ImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "global::A1");
var fixAllActionId = CSharpImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "global::A1");
var input = @"
<Workspace>
......@@ -121,7 +121,7 @@ class C3 : A1, I1
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
public async Task TestFixAllInProject()
{
var fixAllActionId = ImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "global::A1");
var fixAllActionId = CSharpImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "global::A1");
var input = @"
<Workspace>
......@@ -237,7 +237,7 @@ class C3 : A1, I1
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
public async Task TestFixAllInSolution()
{
var fixAllActionId = ImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "global::A1");
var fixAllActionId = CSharpImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "global::A1");
var input = @"
<Workspace>
......@@ -366,7 +366,7 @@ public override void F1()
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
public async Task TestFixAllInSolution_DifferentAssemblyWithSameTypeName()
{
var fixAllActionId = ImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "global::A1");
var fixAllActionId = CSharpImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "global::A1");
var input = @"
<Workspace>
......
......@@ -6,21 +6,22 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.CodeFixes.ImplementInterface;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.ImplementInterface;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.ImplementType;
using Microsoft.CodeAnalysis.Options;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.ImplementInterface
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ImplementInterface
{
public partial class ImplementInterfaceTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override Tuple<DiagnosticAnalyzer, CodeFixProvider> CreateDiagnosticProviderAndFixer(Workspace workspace)
=> new Tuple<DiagnosticAnalyzer, CodeFixProvider>(null, new ImplementInterfaceCodeFixProvider());
=> new Tuple<DiagnosticAnalyzer, CodeFixProvider>(null, new CSharpImplementInterfaceCodeFixProvider());
private static readonly Dictionary<OptionKey, object> AllOptionsOff =
new Dictionary<OptionKey, object>
......
......@@ -5,9 +5,9 @@
using Xunit;
using ImplementInterfaceCodeAction = Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService.ImplementInterfaceCodeAction;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.ImplementInterface
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ImplementInterface
{
public partial class ImplementInterfaceTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
public partial class ImplementInterfaceTests
{
#region "Fix all occurrences tests"
......@@ -503,4 +503,4 @@ class C3 : I1, I2
#endregion
}
}
}
\ No newline at end of file
......@@ -209,8 +209,8 @@
<Compile Include="CodeLens\VisualBasicCodeLensTests.vb" />
<Compile Include="Completion\CompletionServiceTests.vb" />
<Compile Include="Diagnostics\AddImport\AddImportTests_NuGet.vb" />
<Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.vb" />
<Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceTests_FixAllTests.vb" />
<Compile Include="ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.vb" />
<Compile Include="ImplementInterface\ImplementInterfaceTests_FixAllTests.vb" />
<Compile Include="Diagnostics\Iterator\IteratorTests.vb" />
<Compile Include="CommentSelection\VisualBasicCommentSelectionTests.vb" />
<Compile Include="Completion\CompletionProviders\AbstractContextTests.vb" />
......@@ -249,10 +249,10 @@
<Compile Include="Diagnostics\GenerateType\GenerateTypeTests.vb" />
<Compile Include="Diagnostics\GenerateType\GenerateTypeTests_Dialog.vb" />
<Compile Include="Diagnostics\GenerateVariable\GenerateVariableTests.vb" />
<Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassCommandHandlerTests.vb" />
<Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests.vb" />
<Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceCommandHandlerTests.vb" />
<Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceTests.vb" />
<Compile Include="ImplementAbstractClass\ImplementAbstractClassCommandHandlerTests.vb" />
<Compile Include="ImplementAbstractClass\ImplementAbstractClassTests.vb" />
<Compile Include="ImplementInterface\ImplementInterfaceCommandHandlerTests.vb" />
<Compile Include="ImplementInterface\ImplementInterfaceTests.vb" />
<Compile Include="Diagnostics\InsertMissingCast\InsertMissingCastTests.vb" />
<Compile Include="Diagnostics\MakeMethodSynchronous\MakeMethodSynchronousTests.vb" />
<Compile Include="Diagnostics\MoveToTopOfFile\MoveToTopOfFileTests.vb" />
......
......@@ -9,7 +9,7 @@ Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.VisualStudio.Text
Imports Microsoft.VisualStudio.Text.Operations
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.ImplementAbstractClass
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ImplementAbstractClass
Public Class ImplementAbstractClassCommandHandlerTests
<WorkItem(530553, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530553")>
......
......@@ -2,15 +2,16 @@
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic.CodeFixes.ImplementAbstractClass
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic.ImplementAbstractClass
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.ImplementAbstractClass
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ImplementAbstractClass
Partial Public Class ImplementAbstractClassTests
Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest
Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace) As Tuple(Of DiagnosticAnalyzer, CodeFixProvider)
Return New Tuple(Of DiagnosticAnalyzer, CodeFixProvider)(
Nothing, New ImplementAbstractClassCodeFixProvider)
Nothing, New VisualBasicImplementAbstractClassCodeFixProvider)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Option Strict Off
Imports Microsoft.CodeAnalysis.VisualBasic.CodeFixes.ImplementAbstractClass
Imports Microsoft.CodeAnalysis.VisualBasic.ImplementAbstractClass
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.ImplementAbstractClass
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ImplementAbstractClass
Partial Public Class ImplementAbstractClassTests
Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest
<Fact>
<Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)>
<Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)>
Public Async Function TestFixAllInDocument() As Task
Dim fixAllActionId = ImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "Global.A1")
Dim fixAllActionId = VisualBasicImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "Global.A1")
Dim input = <Workspace>
<Project Language="Visual Basic" AssemblyName="Assembly1" CommonReferences="true">
......@@ -126,7 +124,7 @@ End Class]]>
<Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)>
<Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)>
Public Async Function TestFixAllInProject() As Task
Dim fixAllActionId = ImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "Global.A1")
Dim fixAllActionId = VisualBasicImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "Global.A1")
Dim input = <Workspace>
<Project Language="Visual Basic" AssemblyName="Assembly1" CommonReferences="true">
......@@ -249,7 +247,7 @@ End Class]]>
<Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)>
<Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)>
Public Async Function TestFixAllInSolution() As Task
Dim fixAllActionId = ImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "Global.A1")
Dim fixAllActionId = VisualBasicImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "Global.A1")
Dim input = <Workspace>
<Project Language="Visual Basic" AssemblyName="Assembly1" CommonReferences="true">
......@@ -380,7 +378,7 @@ End Class]]>
<Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)>
<Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)>
Public Async Function TestFixAllInSolution_DifferentAssemblyWithSameTypeName() As Task
Dim fixAllActionId = ImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "Global.A1")
Dim fixAllActionId = VisualBasicImplementAbstractClassCodeFixProvider.GetCodeActionId("Assembly1", "Global.A1")
Dim input = <Workspace>
<Project Language="Visual Basic" AssemblyName="Assembly1" CommonReferences="true">
......
......@@ -11,7 +11,7 @@ Imports Microsoft.VisualStudio.Text
Imports Microsoft.VisualStudio.Text.Editor
Imports Microsoft.VisualStudio.Text.Operations
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.ImplementInterface
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ImplementInterface
Public Class ImplementInterfaceCommandHandlerTests
Private Async Function TestAsync(code As XElement, expectedText As XElement, nextHandler As Action(Of IWpfTextView, TestWorkspace), assertion As Action(Of String, String, IWpfTextView)) As Threading.Tasks.Task
......
......@@ -2,14 +2,16 @@
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic.CodeFixes.ImplementInterface
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic.ImplementInterface
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.ImplementInterface
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ImplementInterface
Partial Public Class ImplementInterfaceTests
Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest
Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace) As Tuple(Of DiagnosticAnalyzer, CodeFixProvider)
Return New Tuple(Of DiagnosticAnalyzer, CodeFixProvider)(Nothing, New ImplementInterfaceCodeFixProvider)
Return New Tuple(Of DiagnosticAnalyzer, CodeFixProvider)(
Nothing, New VisualBasicImplementInterfaceCodeFixProvider)
End Function
<WorkItem(540085, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540085")>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Option Strict Off
Imports ImplementInterfaceCodeAction = Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService.ImplementInterfaceCodeAction
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.ImplementInterface
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ImplementInterface
Partial Public Class ImplementInterfaceTests
Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest
<Fact>
<Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)>
......
......@@ -57,6 +57,8 @@
<Link>InternalUtilities\LambdaUtilities.cs</Link>
</Compile>
<Compile Include="AddPackage\CSharpAddSpecificPackageCodeFixProvider.cs" />
<Compile Include="ImplementAbstractClass\CSharpImplementAbstractClassCodeFixProvider.cs" />
<Compile Include="ImplementInterface\CSharpImplementInterfaceCodeFixProvider.cs" />
<Compile Include="Structure\Providers\ArrowExpressionClauseStructureProvider.cs" />
<Compile Include="ConvertToInterpolatedString\CSharpConvertConcatenationToInterpolatedStringRefactoringProvider.cs" />
<Compile Include="RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsService.cs" />
......@@ -103,8 +105,6 @@
<Compile Include="CodeFixes\GenerateVariable\GenerateVariableCodeFixProvider.cs" />
<Compile Include="CodeFixes\HideBase\HideBaseCodeFixProvider.AddNewKeywordAction.cs" />
<Compile Include="CodeFixes\HideBase\HideBaseCodeFixProvider.cs" />
<Compile Include="CodeFixes\ImplementAbstractClass\ImplementAbstractClassCodeFixProvider.cs" />
<Compile Include="CodeFixes\ImplementInterface\ImplementInterfaceCodeFixProvider.cs" />
<Compile Include="CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs" />
<Compile Include="CodeFixes\Iterator\CSharpChangeToIEnumerableCodeFixProvider.cs" />
<Compile Include="QualifyMemberAccess\CSharpQualifyMemberAccessCodeFixProvider.cs" />
......
// 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeActions.Providers;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.ImplementAbstractClass;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.CodeActions.ImplementAbstractClass
{
[ExportCodeIssueProvider(PredefinedCodeActionProviderNames.ImplementAbstractClass, LanguageNames.CSharp)]
[ExtensionOrder(After = PredefinedCodeActionProviderNames.GenerateType)]
internal partial class ImplementAbstractClassCodeIssueProvider : AbstractCSharpCodeIssueProvider
{
public override IEnumerable<Type> SyntaxNodeTypes
{
get
{
yield return typeof(TypeSyntax);
}
}
protected override async Task<CodeIssue> GetIssueAsync(
Document document,
SyntaxNode node,
CancellationToken cancellationToken)
{
if (document.Project.Solution.Workspace.Kind == WorkspaceKind.MiscellaneousFiles)
{
return null;
}
var service = document.GetLanguageService<IImplementAbstractClassService>();
var result = await service.ImplementAbstractClassAsync(document, node, cancellationToken).ConfigureAwait(false);
var changes = await result.GetTextChangesAsync(document, cancellationToken).ConfigureAwait(false);
if (!changes.Any())
{
return null;
}
return new CodeIssue(
CodeIssueKind.Error,
node.Span,
SpecializedCollections.SingletonEnumerable(new CodeAction(result)));
}
}
}
// 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.ImplementInterface;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.ImplementInterface
{
[ExportDiagnosticProvider(PredefinedDiagnosticProviderNames.ImplementInterface, LanguageNames.CSharp)]
internal sealed class ImplementInterfaceDiagnosticProvider : DocumentDiagnosticProvider
{
internal const string DiagnosticId = "ImplementInterface";
internal static readonly DiagnosticDescriptor DiagnosticMD = new DiagnosticDescriptor(DiagnosticId,
DiagnosticKind.Hidden,
CSharpFeaturesResources.ImplementInterface,
CSharpFeaturesResources.ImplementInterface,
"Internal",
DiagnosticSeverity.None);
internal const string CS0535 = "CS0535"; // 'Program' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'
internal const string CS0737 = "CS0737"; // 'Class' does not implement interface member 'IInterface.M()'. 'Class.M()' cannot implement an interface member because it is not public.
internal const string CS0738 = "CS0738"; // 'C' does not implement interface member 'I.Method1()'. 'B.Method1()' cannot implement 'I.Method1()' because it does not have the matching return type of 'void'.
public override IEnumerable<DiagnosticDescriptor> GetSupportedDiagnostics()
{
return SpecializedCollections.SingletonEnumerable(DiagnosticMD);
}
protected override async Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync(Document document, CancellationToken cancellationToken)
{
if (!document.IsOpen())
{
return null;
}
var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var root = model.SyntaxTree.GetRoot(cancellationToken);
var infos = model.GetDeclarationDiagnostics(cancellationToken).Where(d =>
d.Id == CS0535 ||
d.Id == CS0737 ||
d.Id == CS0738).GroupBy(d => d.Location.SourceSpan).Select(g => g.First());
var service = document.GetLanguageService<IImplementInterfaceService>();
var diagnostics = new List<Diagnostic>();
foreach (var error in infos)
{
cancellationToken.ThrowIfCancellationRequested();
var espan = error.Location.SourceSpan;
var token = root.FindToken(espan.Start);
if (!token.Span.IntersectsWith(espan))
{
continue;
}
var typeNode = token.Parent as TypeDeclarationSyntax;
if (typeNode == null)
{
continue;
}
IEnumerable<TypeSyntax> baseListTypes = typeNode.GetAllBaseListTypes(model, cancellationToken);
foreach (var node in baseListTypes)
{
if (service.GetCodeActions(
document,
model,
node,
cancellationToken).Any())
{
diagnostics.Add(CreateUserDiagnostic(document, node, cancellationToken));
}
}
}
return diagnostics;
}
private Diagnostic CreateUserDiagnostic(Document document, TypeSyntax node, CancellationToken cancellationToken)
{
var span = node.Span;
var tree = node.SyntaxTree;
return Diagnostic.Create(DiagnosticMD, tree.GetLocation(span));
}
}
}
......@@ -5,16 +5,17 @@
using Microsoft.CodeAnalysis.CodeFixes.ImplementAbstractClass;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.ImplementAbstractClass
namespace Microsoft.CodeAnalysis.CSharp.ImplementAbstractClass
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ImplementAbstractClass), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateType)]
internal class ImplementAbstractClassCodeFixProvider :
internal class CSharpImplementAbstractClassCodeFixProvider :
AbstractImplementAbstractClassCodeFixProvider<ClassDeclarationSyntax>
{
private const string CS0534 = nameof(CS0534); // 'Program' does not implement inherited abstract member 'Foo.bar()'
public ImplementAbstractClassCodeFixProvider() : base(CS0534)
public CSharpImplementAbstractClassCodeFixProvider()
: base(CS0534)
{
}
}
......
......@@ -12,11 +12,11 @@
using Microsoft.CodeAnalysis.ImplementInterface;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.ImplementInterface
namespace Microsoft.CodeAnalysis.CSharp.ImplementInterface
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ImplementInterface), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.ImplementAbstractClass)]
internal class ImplementInterfaceCodeFixProvider : CodeFixProvider
internal class CSharpImplementInterfaceCodeFixProvider : CodeFixProvider
{
private readonly Func<TypeSyntax, bool> _interfaceName = n => n.Parent is BaseTypeSyntax && n.Parent.Parent is BaseListSyntax && ((BaseTypeSyntax)n.Parent).Type == n;
private readonly Func<IEnumerable<CodeAction>, bool> _codeActionAvailable = actions => actions != null && actions.Any();
......
......@@ -102,8 +102,7 @@
<Compile Include="CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb" />
<Compile Include="CodeFixes\GenerateType\GenerateTypeCodeFixProvider.vb" />
<Compile Include="CodeFixes\GenerateVariable\GenerateVariableCodeFixProvider.vb" />
<Compile Include="CodeFixes\ImplementAbstractClass\ImplementAbstractClassCodeFixProvider.vb" />
<Compile Include="CodeFixes\ImplementInterface\ImplementInterfaceCodeFixProvider.vb" />
<Compile Include="ImplementAbstractClass\VisualBasicImplementAbstractClassCodeFixProvider.vb" />
<Compile Include="CodeFixes\IncorrectExitContinue\IncorrectExitContinueCodeFixProvider.AddKeywordCodeAction.vb" />
<Compile Include="CodeFixes\IncorrectExitContinue\IncorrectExitContinueCodeFixProvider.ReplaceKeywordCodeAction.vb" />
<Compile Include="CodeFixes\IncorrectExitContinue\IncorrectExitContinueCodeFixProvider.ReplaceTokenKeywordCodeAction.vb" />
......@@ -113,6 +112,7 @@
<Compile Include="CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.vb" />
<Compile Include="CodeFixes\OverloadBase\OverloadBaseCodeFixProvider.AddOverloads.vb" />
<Compile Include="CodeFixes\OverloadBase\OverloadBaseCodeFixProvider.vb" />
<Compile Include="ImplementInterface\VisualBasicImplementInterfaceCodeFixProvider.vb" />
<Compile Include="Structure\Providers\CollectionInitializerStructureProvider.vb" />
<Compile Include="Structure\Providers\ObjectCreationInitializerStructureProvider.vb" />
<Compile Include="QualifyMemberAccess\VisualBasicQualifyMemberAccessCodeFixProvider.vb" />
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.CodeActions.Providers
Imports Microsoft.CodeAnalysis.ImplementAbstractClass
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeActions.ImplementAbstractClass
<ExportCodeIssueProvider(PredefinedCodeActionProviderNames.ImplementAbstractClass, LanguageNames.VisualBasic)>
<ExtensionOrder(After:=PredefinedCodeActionProviderNames.GenerateType)>
Partial Friend Class ImplementAbstractClassCodeIssueProvider
Inherits AbstractVisualBasicCodeIssueProvider
Public Overrides ReadOnly Property SyntaxNodeTypes As IEnumerable(Of Type)
Get
Return {GetType(TypeSyntax)}
End Get
End Property
Protected Overrides Async Function GetIssueAsync(document As Document, node As SyntaxNode, cancellationToken As CancellationToken) As Task(Of CodeIssue)
Dim workspace = document.Project.Solution.Workspace
If workspace.Kind = WorkspaceKind.MiscellaneousFiles Then
Return Nothing
End If
Dim service = document.GetLanguageService(Of IImplementAbstractClassService)()
Dim result = Await service.ImplementAbstractClassAsync(document, node, cancellationToken).ConfigureAwait(False)
Dim textChanges = Await result.GetTextChangesAsync(document, cancellationToken).ConfigureAwait(False)
If textChanges.Count = 0 Then
Return Nothing
End If
Return New CodeIssue(CodeIssueKind.Error, node.Span, {New CodeAction(result)})
End Function
End Class
End Namespace
......@@ -5,11 +5,11 @@ Imports Microsoft.CodeAnalysis.CodeFixes
Imports System.Composition
Imports Microsoft.CodeAnalysis.CodeFixes.ImplementAbstractClass
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.ImplementAbstractClass
Namespace Microsoft.CodeAnalysis.VisualBasic.ImplementAbstractClass
<ExportCodeFixProvider(LanguageNames.VisualBasic,
Name:=PredefinedCodeFixProviderNames.ImplementAbstractClass), [Shared]>
<ExtensionOrder(After:=PredefinedCodeFixProviderNames.GenerateType)>
Friend Class ImplementAbstractClassCodeFixProvider
Friend Class VisualBasicImplementAbstractClassCodeFixProvider
Inherits AbstractImplementAbstractClassCodeFixProvider(Of ClassBlockSyntax)
Friend Const BC30610 As String = "BC30610" ' Class 'foo' must either be declared 'MustInherit' or override the following inherited 'MustOverride' member(s):
......
......@@ -6,11 +6,11 @@ Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.ImplementInterface
Imports System.Composition
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.ImplementInterface
Namespace Microsoft.CodeAnalysis.VisualBasic.ImplementInterface
<ExportCodeFixProvider(LanguageNames.VisualBasic, Name:=PredefinedCodeFixProviderNames.ImplementInterface), [Shared]>
<ExtensionOrder(After:=PredefinedCodeFixProviderNames.ImplementAbstractClass)>
Friend Class ImplementInterfaceCodeFixProvider
Friend Class VisualBasicImplementInterfaceCodeFixProvider
Inherits CodeFixProvider
Friend Const BC30149 As String = "BC30149" ' Class 'bar' must implement 'Sub foo()' for interface 'ifoo'.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册