提交 38f32023 编写于 作者: J Jason Malinowski

Unbreak End Construct around an broken code scenario

If you hit enter after a Property statement that already had accessors,
but was missing an End Property, we'd get confused of what to do and
not let you do anything at all. That's bad, so now we just do nothing
special and pass it through as an enter. In this case spitting anything
just makes more broken code for the user, so we're best off avoiding
any fanciness.

Fixes #5208.
上级 a550f7b0
......@@ -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.
先完成此消息的编辑!
想要评论请 注册