提交 d01fcb66 编写于 作者: J Jason Malinowski

Merge pull request #5585 from jasonmalinowski/fix-endconstruct-with-broken-property

Unbreak End Construct around an broken code scenario
......@@ -41,6 +41,12 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration
lines.AddRange(GenerateSetAccessor(node, _subjectBuffer.CurrentSnapshot))
End If
' If we didn't need any accessors, that already means there's some accessor after us. Spitting
' End Property (if we have to) after that point would just make more broken code, so just bail
If lines.Count = 0 Then
Return Nothing
End If
' If we are missing a End Property, then spit it
If propertyBlock Is Nothing OrElse propertyBlock.EndPropertyStatement.IsMissing Then
Dim aligningWhitespace = _subjectBuffer.CurrentSnapshot.GetAligningWhitespace(node.SpanStart)
......
......@@ -146,6 +146,16 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera
afterCaret:={3, -1})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.EndConstructGeneration)>
Public Sub DontApplyForReadOnlyPropertyIfEndPropertyMissingWhenInvokedAfterProperty()
VerifyStatementEndConstructNotApplied(
text:={"Class c1",
" ReadOnly Property foo As Integer",
" Get",
"End Class"},
caret:={1, -1})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.EndConstructGeneration)>
Public Sub TestApplyOnGetForRegularPropertyWithSetPresent()
VerifyStatementEndConstructApplied(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册