diff --git a/src/EditorFeatures/CSharpTest/MakeClassAbstract/MakeClassAbstractTests.cs b/src/EditorFeatures/CSharpTest/MakeClassAbstract/MakeClassAbstractTests.cs index 28bd3a1bad78399ef900f56646a7e117b4e89a6f..a7701f81faf9227ec334db092d189f085298c24b 100644 --- a/src/EditorFeatures/CSharpTest/MakeClassAbstract/MakeClassAbstractTests.cs +++ b/src/EditorFeatures/CSharpTest/MakeClassAbstract/MakeClassAbstractTests.cs @@ -1,4 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/EditorFeatures/VisualBasicTest/MakeClassAbstract/MakeClassAbstractTests.vb b/src/EditorFeatures/VisualBasicTest/MakeClassAbstract/MakeClassAbstractTests.vb index 6cbd155eb3e5205440a9d7fc92276c0abc2b02ec..4cfa4576bb4c5ee11c1d6abb592f9d267ed8a662 100644 --- a/src/EditorFeatures/VisualBasicTest/MakeClassAbstract/MakeClassAbstractTests.vb +++ b/src/EditorFeatures/VisualBasicTest/MakeClassAbstract/MakeClassAbstractTests.vb @@ -1,4 +1,6 @@ -' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis.CodeFixes Imports Microsoft.CodeAnalysis.Diagnostics @@ -14,80 +16,55 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.MakeClassAbstract End Function - Public Async Function TestMethod() As Task - Await TestInRegularAndScript1Async( -" + Public Async Function TestMethod_CodeFix() As Task + Await TestInRegularAndScript1Async(" Public Class [|Foo|] Public MustOverride Sub M() End Class", " -Public MustInherit Class Foo +Public MustOverride Class Foo Public MustOverride Sub M() End Class") End Function - Public Async Function TestMethodEnclosingClassWithoutAccessibility() As Task - Await TestInRegularAndScript1Async( -" + Public Async Function TestMethodEnclosingClassWithoutAccessibility_NoCodeFix() As Task + Await TestMissingInRegularAndScriptAsync(" Class Foo Public MustOverride Sub [|M|]() -End Class", -" -MustInherit Class Foo - Public MustOverride Sub M() End Class") End Function Public Async Function TestMethodEnclosingClassDocumentationComment() As Task - Await TestInRegularAndScript1Async( -" + Await TestMissingInRegularAndScriptAsync(" ''' ''' Some class comment. ''' Public Class Foo Public MustOverride Sub [|M|]() -End Class", -" -''' -''' Some class comment. -''' -Public MustInherit Class Foo - Public MustOverride Sub M() End Class") End Function Public Async Function TestProperty() As Task - Await TestInRegularAndScript1Async( -" + Await TestMissingInRegularAndScriptAsync(" Public Class Foo Public MustOverride Property [|P|] As Object -End Class", -" -Public MustInherit Class Foo - Public MustOverride Property P As Object End Class") End Function Public Async Function TestIndexer() As Task - Await TestInRegularAndScript1Async( -" + Await TestMissingInRegularAndScriptAsync(" Public Class Foo Default Public MustOverride Property [|Item|](ByVal o As Object) As Object -End Class", -" -Public MustInherit Class Foo - Default Public MustOverride Property Item(ByVal o As Object) As Object End Class") End Function Public Async Function TestEvent() As Task - Await TestMissingInRegularAndScriptAsync( -" + Await TestMissingInRegularAndScriptAsync(" Public Class Foo Public MustOverride Custom Event [|E|] As EventHandler End Class") @@ -95,8 +72,7 @@ End Class") Public Async Function TestMethodWithBody() As Task - Await TestMissingInRegularAndScriptAsync( -" + Await TestMissingInRegularAndScriptAsync(" Public Class Foo Public MustOverride Function [|M|]() As Integer Return 3 @@ -139,8 +115,7 @@ End Class") Public Async Function FixAll() As Task - Await TestInRegularAndScript1Async( -" + Await TestMissingInRegularAndScriptAsync(" Namespace NS Public Class C1 Public MustOverride Sub {|FixAllInDocument:M|}() @@ -157,24 +132,6 @@ Namespace NS Public MustOverride Sub M() End Class End Class -End Namespace", -" -Namespace NS - Public MustInherit Class C1 - Public MustOverride Sub M() - Public MustOverride Property P As Object - Default Public MustOverride Property Item(ByVal o As Object) As Object - End Class - - Public MustInherit Class C2 - Public MustOverride Sub M() - End Class - - Public Class C3 - Public MustInherit Class InnerClass - Public MustOverride Sub M() - End Class - End Class End Namespace") End Function End Class diff --git a/src/Features/CSharp/Portable/MakeClassAbstract/CSharpMakeClassAbstractCodeFixProvider.cs b/src/Features/CSharp/Portable/MakeClassAbstract/CSharpMakeClassAbstractCodeFixProvider.cs index 02d9bcd9d167442eabdfb5616246b0f78e22b1d4..a011ad271ba0a20b9c75b3d59c6a0c7831286987 100644 --- a/src/Features/CSharp/Portable/MakeClassAbstract/CSharpMakeClassAbstractCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/MakeClassAbstract/CSharpMakeClassAbstractCodeFixProvider.cs @@ -1,7 +1,10 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. #nullable enable +using System; using System.Collections.Immutable; using System.Composition; using System.Diagnostics.CodeAnalysis; @@ -14,6 +17,12 @@ namespace Microsoft.CodeAnalysis.CSharp.MakeClassAbstract [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CSharpMakeClassAbstractCodeFixProvider)), Shared] internal sealed class CSharpMakeClassAbstractCodeFixProvider : AbstractMakeClassAbstractCodeFixProvider { + [ImportingConstructor] + [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] + public CSharpMakeClassAbstractCodeFixProvider() + { + } + public override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Create( "CS0513" // 'C.M()' is abstract but it is contained in non-abstract class 'C' diff --git a/src/Features/Core/Portable/MakeClassAbstract/AbstractMakeClassAbstractCodeFixProvider.cs b/src/Features/Core/Portable/MakeClassAbstract/AbstractMakeClassAbstractCodeFixProvider.cs index e674c8c1bef804aa51897b24b14b7c116427aed7..352789dded19dbb3ed70eca0bb137312d7cad12c 100644 --- a/src/Features/Core/Portable/MakeClassAbstract/AbstractMakeClassAbstractCodeFixProvider.cs +++ b/src/Features/Core/Portable/MakeClassAbstract/AbstractMakeClassAbstractCodeFixProvider.cs @@ -1,4 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/Features/VisualBasic/Portable/MakeClassAbstract/VisualBasicMakeClassAbstractCodeFixProvider.vb b/src/Features/VisualBasic/Portable/MakeClassAbstract/VisualBasicMakeClassAbstractCodeFixProvider.vb index d73971b89cf4ae847249dd1bbf627351a2c224f2..5c2f55780379bb806be1b74a09813f602bcefd4a 100644 --- a/src/Features/VisualBasic/Portable/MakeClassAbstract/VisualBasicMakeClassAbstractCodeFixProvider.vb +++ b/src/Features/VisualBasic/Portable/MakeClassAbstract/VisualBasicMakeClassAbstractCodeFixProvider.vb @@ -1,7 +1,10 @@ -' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. Imports System.Collections.Immutable Imports System.Composition +Imports System.Diagnostics.CodeAnalysis Imports Microsoft.CodeAnalysis.CodeRefactorings Imports Microsoft.CodeAnalysis.MakeClassAbstract Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -11,6 +14,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.MakeClassAbstract Friend NotInheritable Class VisualBasicMakeClassAbstractCodeFixProvider Inherits AbstractMakeClassAbstractCodeFixProvider(Of ClassStatementSyntax) + + + Public Sub New() + End Sub + Public Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String) = ImmutableArray.Create( "BC31411"