-
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
Remove code for generating constructors from class-decl, it will be provided by another refactoring. #19481
Remove code for generating constructors from class-decl, it will be provided by another refactoring. #19481
Changes from all commits
54d97dd
4c2862c
c81dfd3
5865073
a315a64
82373c8
62705b3
fac36fe
c46b37e
9e95f3c
23fa444
cddbd90
9781c81
9437cf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,12 @@ | |
|
||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.CodeRefactorings; | ||
using Microsoft.CodeAnalysis.CodeRefactorings.GenerateDefaultConstructors; | ||
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings; | ||
using Microsoft.CodeAnalysis.GenerateDefaultConstructors; | ||
using Roslyn.Test.Utilities; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings.GenerateDefaultConstructors | ||
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.GenerateDefaultConstructors | ||
{ | ||
public class GenerateDefaultConstructorsTests : AbstractCSharpCodeActionTest | ||
{ | ||
|
@@ -590,7 +591,7 @@ protected Program(SerializationInfo info, StreamingContext context) : base(info, | |
{ | ||
} | ||
}", | ||
index: 3, | ||
index: 4, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because GenrateDefaultConstructors now offers to generate the no arg constructor, the indices increased here. |
||
ignoreTrivia: false); | ||
} | ||
|
||
|
@@ -728,10 +729,6 @@ public Program() | |
{ | ||
} | ||
|
||
public Program() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is good. If you expand the code above htis, you'll see we were generating the default constructor twice. |
||
{ | ||
} | ||
|
||
public Program(string message) : base(message) | ||
{ | ||
} | ||
|
@@ -806,6 +803,66 @@ class B | |
public B((int a, string b) x) | ||
{ | ||
} | ||
}"); | ||
} | ||
|
||
[WorkItem(6541, "https://github.com/dotnet/Roslyn/issues/6541")] | ||
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)] | ||
public async Task TestGenerateFromDerivedClass() | ||
{ | ||
await TestInRegularAndScriptAsync( | ||
@"class Base | ||
{ | ||
public Base(string value) | ||
{ | ||
} | ||
} | ||
|
||
class [||]Derived : Base | ||
{ | ||
}", | ||
@"class Base | ||
{ | ||
public Base(string value) | ||
{ | ||
} | ||
} | ||
|
||
class Derived : Base | ||
{ | ||
public Derived(string value) : base(value) | ||
{ | ||
} | ||
}"); | ||
} | ||
|
||
[WorkItem(6541, "https://github.com/dotnet/Roslyn/issues/6541")] | ||
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)] | ||
public async Task TestGenerateFromDerivedClass2() | ||
{ | ||
await TestInRegularAndScriptAsync( | ||
@"class Base | ||
{ | ||
public Base(int a, string value = null) | ||
{ | ||
} | ||
} | ||
|
||
class [||]Derived : Base | ||
{ | ||
}", | ||
@"class Base | ||
{ | ||
public Base(int a, string value = null) | ||
{ | ||
} | ||
} | ||
|
||
class Derived : Base | ||
{ | ||
public Derived(int a, string value = null) : base(a, value) | ||
{ | ||
} | ||
}"); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,11 @@ | |
|
||
Imports Microsoft.CodeAnalysis.CodeFixes | ||
Imports Microsoft.CodeAnalysis.Diagnostics | ||
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics | ||
Imports Microsoft.CodeAnalysis.VisualBasic.Diagnostics | ||
Imports Microsoft.CodeAnalysis.VisualBasic.GenerateConstructor | ||
|
||
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.GenerateConstructor | ||
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.GenerateConstructor | ||
Public Class GenerateConstructorTests | ||
Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest | ||
|
||
|
@@ -1528,98 +1529,6 @@ End Class") | |
End Function | ||
End Class | ||
|
||
<WorkItem(6541, "https://github.com/dotnet/Roslyn/issues/6541")> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests moved. |
||
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)> | ||
Public Async Function TestGenerateInDerivedType1() As Task | ||
Await TestInRegularAndScriptAsync( | ||
" | ||
Public Class Base | ||
Public Sub New(a As String) | ||
|
||
End Sub | ||
End Class | ||
|
||
Public Class [||]Derived | ||
Inherits Base | ||
|
||
End Class", | ||
" | ||
Public Class Base | ||
Public Sub New(a As String) | ||
|
||
End Sub | ||
End Class | ||
|
||
Public Class Derived | ||
Inherits Base | ||
|
||
Public Sub New(a As String) | ||
MyBase.New(a) | ||
End Sub | ||
End Class") | ||
End Function | ||
|
||
<WorkItem(6541, "https://github.com/dotnet/Roslyn/issues/6541")> | ||
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)> | ||
Public Async Function TestGenerateInDerivedType2() As Task | ||
Await TestInRegularAndScriptAsync( | ||
" | ||
Public Class Base | ||
Public Sub New(a As Integer, Optional b As String = Nothing) | ||
|
||
End Sub | ||
End Class | ||
|
||
Public Class [||]Derived | ||
Inherits Base | ||
|
||
End Class", | ||
" | ||
Public Class Base | ||
Public Sub New(a As Integer, Optional b As String = Nothing) | ||
|
||
End Sub | ||
End Class | ||
|
||
Public Class Derived | ||
Inherits Base | ||
|
||
Public Sub New(a As Integer, Optional b As String = Nothing) | ||
MyBase.New(a, b) | ||
End Sub | ||
End Class") | ||
End Function | ||
|
||
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)> | ||
Public Async Function TestGenerateInDerivedType_InvalidClassStatement() As Task | ||
Await TestInRegularAndScriptAsync( | ||
" | ||
Public Class Base | ||
Public Sub New(a As Integer, Optional b As String = Nothing) | ||
|
||
End Sub | ||
End Class | ||
|
||
Public Class [|;;|]Derived | ||
Inherits Base | ||
|
||
End Class", | ||
" | ||
Public Class Base | ||
Public Sub New(a As Integer, Optional b As String = Nothing) | ||
|
||
End Sub | ||
End Class | ||
|
||
Public Class ;;Derived | ||
Inherits Base | ||
|
||
Public Sub New(a As Integer, Optional b As String = Nothing) | ||
MyBase.New(a, b) | ||
End Sub | ||
End Class") | ||
End Function | ||
|
||
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)> | ||
Public Async Function TestGenerateConstructorNotOfferedForDuplicate() As Task | ||
Await TestMissingInRegularAndScriptAsync( | ||
|
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.
These tests moved.