From f4b05f4ecefd1446f1a089beb93733d28fe02548 Mon Sep 17 00:00:00 2001 From: Evangelink Date: Fri, 3 Jul 2020 16:36:15 +0200 Subject: [PATCH] Fix broken tests --- .../MakeClassAbstractTests.cs | 4 +- .../MakeClassAbstractTests.vb | 71 ++++--------------- .../CSharpMakeClassAbstractCodeFixProvider.cs | 11 ++- ...bstractMakeClassAbstractCodeFixProvider.cs | 4 +- ...alBasicMakeClassAbstractCodeFixProvider.vb | 10 ++- 5 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/MakeClassAbstract/MakeClassAbstractTests.cs b/src/EditorFeatures/CSharpTest/MakeClassAbstract/MakeClassAbstractTests.cs index 28bd3a1bad7..a7701f81faf 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 6cbd155eb3e..4cfa4576bb4 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 02d9bcd9d16..a011ad271ba 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 e674c8c1bef..352789dded1 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 d73971b89cf..5c2f5578037 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" -- GitLab