Skip to content

Conversation

Youssef1313
Copy link
Member

Fixes #48129


Namespace Microsoft.CodeAnalysis.VisualBasic.MakeClassAbstract
<ExportCodeFixProvider(LanguageNames.VisualBasic, Name:=NameOf(VisualBasicMakeClassAbstractCodeFixProvider)), [Shared]>
Friend NotInheritable Class VisualBasicMakeClassAbstractCodeFixProvider
Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

@davidwengier davidwengier left a 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 :)

@Youssef1313
Copy link
Member Author

@davidwengier Thanks for review. I addressed your feedback. (Sorry for having much commits, working from web browser currently 😄)

editor.ReplaceNode(classDeclaration,
(currentClassDeclaration, generator) => generator.WithModifiers(currentClassDeclaration, DeclarationModifiers.Abstract));
editor.ReplaceNode(typeDeclaration,
(currentTypeDeclaration, generator) => generator.WithModifiers(currentTypeDeclaration, DeclarationModifiers.Abstract));
Copy link
Member Author

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

@jinujoseph jinujoseph added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Oct 3, 2020
typeDeclaration = null;

switch (node?.Kind())
switch (node)
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if we care about it but switching over the enum shall be "faster" than switching over the casted expressions.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Evangelink I'd let @CyrusNajmabadi or @davidwengier decide on this.

Copy link
Member

Choose a reason for hiding this comment

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

for smal switches this is fine.


Namespace Microsoft.CodeAnalysis.VisualBasic.MakeClassAbstract
<ExportCodeFixProvider(LanguageNames.VisualBasic, Name:=NameOf(VisualBasicMakeClassAbstractCodeFixProvider)), [Shared]>
Friend NotInheritable Class VisualBasicMakeClassAbstractCodeFixProvider
Copy link
Member

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.

public override ImmutableArray<string> FixableDiagnosticIds { get; } =
ImmutableArray.Create(
"CS0513" // 'C.M()' is abstract but it is contained in non-abstract class 'C'
"CS0513" // 'C.M()' is abstract but it is contained in non-abstract type 'C'
Copy link
Member

Choose a reason for hiding this comment

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

I am assuming the analyzer was updated for this and the message updated, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Evangelink Yes the message for CS0513 was updated.


var enclosingType = node.FirstAncestorOrSelf<TypeDeclarationSyntax>();
if (!enclosingType.IsKind(SyntaxKind.ClassDeclaration))
typeDeclaration = node.FirstAncestorOrSelf<TypeDeclarationSyntax>();
Copy link
Member

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)
Copy link
Member

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.

@davidwengier
Copy link
Member

@Youssef1313 is this blocked on anything still?

@Youssef1313 Youssef1313 requested a review from a team as a code owner November 5, 2020 10:59
@Youssef1313
Copy link
Member Author

Youssef1313 commented Nov 5, 2020

@Youssef1313 is this blocked on anything still?

@davidwengier I don't think. Let's see if the tests will pass.

@Youssef1313
Copy link
Member Author

@davidwengier Can you re-run the failed job? The failure is an unrelated test timeout:

Roslyn Error: test timeout exceeded, dumping remaining processes
Dumping dotnet 5320 to F:\workspace\_work\1\s\artifacts\log\Debug\dotnet-1.dmp ... succeeded (129216285 bytes)
Dumping dotnet 5668 to F:\workspace\_work\1\s\artifacts\log\Debug\dotnet-2.dmp ... succeeded (109926677 bytes)
Dumping testhost.net472.x86 5612 to F:\workspace\_work\1\s\artifacts\log\Debug\testhost.net472.x86-3.dmp ... succeeded (701572436 bytes)
##[error](NETCORE_ENGINEERING_TELEMETRY=Test) Tests failed

@jcouv jcouv added the Feature - Records Records label Nov 5, 2020
@davidwengier
Copy link
Member

Thanks @Youssef1313

@davidwengier davidwengier merged commit c73027c into dotnet:master Nov 5, 2020
@ghost ghost added this to the Next milestone Nov 5, 2020
@Youssef1313 Youssef1313 deleted the patch-38 branch November 6, 2020 02:39
333fred added a commit to 333fred/roslyn that referenced this pull request Nov 9, 2020
* 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
  ...
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
@Youssef1313 Youssef1313 mentioned this pull request Feb 18, 2021
92 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. Feature - Records Records
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSharpMakeClassAbstractCodeFixProvider needs to be updated for records
7 participants