-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Extend make type abstract to include records #48227
Conversation
…stractCodeFixProvider
…ctCodeFixProvider
src/EditorFeatures/CSharpTest/MakeTypeAbstract/MakeTypeAbstractTests.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/MakeClassAbstract/CSharpMakeTypeAbstractCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/MakeClassAbstract/AbstractMakeTypeAbstractCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/MakeClassAbstract/CSharpMakeTypeAbstractCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/MakeClassAbstract/AbstractMakeTypeAbstractCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
@@ -6,13 +6,13 @@ Imports System.Collections.Immutable | |||
Imports System.Composition | |||
Imports System.Diagnostics.CodeAnalysis | |||
Imports Microsoft.CodeAnalysis.CodeFixes | |||
Imports Microsoft.CodeAnalysis.MakeClassAbstract | |||
Imports Microsoft.CodeAnalysis.MakeTypeAbstract | |||
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax | |||
|
|||
Namespace Microsoft.CodeAnalysis.VisualBasic.MakeClassAbstract | |||
<ExportCodeFixProvider(LanguageNames.VisualBasic, Name:=NameOf(VisualBasicMakeClassAbstractCodeFixProvider)), [Shared]> | |||
Friend NotInheritable Class VisualBasicMakeClassAbstractCodeFixProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to update the VB class name as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say yes for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor test comments, but LGTM in general.
If you're bored, a test for a record with a primary constructor might be nice to ensure no regressions, but I'd be very surprised if it caught anything :)
src/EditorFeatures/CSharpTest/MakeTypeAbstract/MakeTypeAbstractTests.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/MakeTypeAbstract/MakeTypeAbstractTests.cs
Outdated
Show resolved
Hide resolved
@davidwengier Thanks for review. I addressed your feedback. (Sorry for having much commits, working from web browser currently 😄) |
src/Features/CSharp/Portable/MakeTypeAbstract/CSharpMakeTypeAbstractCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/MakeTypeAbstract/MakeTypeAbstractTests.cs
Outdated
Show resolved
Hide resolved
editor.ReplaceNode(classDeclaration, | ||
(currentClassDeclaration, generator) => generator.WithModifiers(currentClassDeclaration, DeclarationModifiers.Abstract)); | ||
editor.ReplaceNode(typeDeclaration, | ||
(currentTypeDeclaration, generator) => generator.WithModifiers(currentTypeDeclaration, DeclarationModifiers.Abstract)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not working due to lack of support for records in syntax generator.
Being fixed in #48096
@@ -53,15 +50,13 @@ protected override bool IsValidRefactoringContext(SyntaxNode? node, [NotNullWhen | |||
return false; | |||
} | |||
|
|||
var enclosingType = node.FirstAncestorOrSelf<TypeDeclarationSyntax>(); | |||
if (!enclosingType.IsKind(SyntaxKind.ClassDeclaration)) | |||
typeDeclaration = node.FirstAncestorOrSelf<TypeDeclarationSyntax>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't do this. you will assign the value, even when returning false. it would be far cleaner to keep the out-value 'null' when 'false' is returned.
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsMakeTypeAbstract)] | ||
[InlineData("class")] | ||
[InlineData("record")] | ||
public async Task TestMethod(string typeKind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you revert all of this add only new tests for records. parameterizing here seems to provide no value and doubles the amount of tests without need.
@Youssef1313 is this blocked on anything still? |
@davidwengier I don't think. Let's see if the tests will pass. |
src/Features/CSharp/Portable/MakeTypeAbstract/CSharpMakeTypeAbstractCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
@davidwengier Can you re-run the failed job? The failure is an unrelated test timeout:
|
Thanks @Youssef1313 |
* upstream/master: (519 commits) Remove workaround in PEMethodSymbol.ExplicitInterfaceImplementations (dotnet#49246) Enable LSP pull model diagnostic for XAML. (dotnet#49145) Update dependencies from https://github.com/dotnet/roslyn build 20201109.8 (dotnet#49240) Add test for with expression in F1 help service (dotnet#49236) Cache RegexPatternDetector per compilation Fix RazorRemoteHostClient to maintain binary back-compat Further tweak inline hints Fix MemberNames API for records (dotnet#49138) Minor cleanups (dotnet#49204) Report warning for assignment or explicit cast of possibly null value of unconstrained type parameter type (dotnet#48803) Clean up of EditorFeatures.Cocoa.Snippets (dotnet#49188) Fix OK button state handling. Make relation between viewmodels more tightly coupled Extend make type abstract to include records (dotnet#48227) Remove duplicated implementations of C# event hookup Add select all/deselect all buttons Consolidate conditional compilation (dotnet#49150) Implement IEquatable on Microsoft.Cci.DefinitionWithLocation structure (dotnet#49162) Add new document extensions file Unify implementations Only disable structure tagger provider in LSP scenario ...
Fixes #48129