提交 458bd803 编写于 作者: C CyrusNajmabadi

Share more code.

上级 e96ea199
......@@ -57,12 +57,6 @@ public SyntaxNode GetPropertyDeclaration(SyntaxToken token)
propertyDeclaration, propertyBackingField,
desiredGetMethodName, desiredSetMethodName);
if (property.ContainingType.TypeKind == TypeKind.Interface)
{
members = members.OfType<MethodDeclarationSyntax>()
.Select(generator.AsInterfaceMember).ToList();
}
return members;
}
......
......@@ -335,6 +335,15 @@ private string GetDefinitionIssues(IEnumerable<ReferencedSymbol> getMethodRefere
definitionToBackingField.GetValueOrDefault(propertyDefinition),
desiredGetMethodName, desiredSetMethodName);
// Properly make the members fit within an interface if that's what
// we're generating into.
if (propertyDefinition.ContainingType.TypeKind == TypeKind.Interface)
{
members = members.Select(editor.Generator.AsInterfaceMember)
.WhereNotNull()
.ToList();
}
var nodeToReplace = service.GetPropertyNodeToReplace(propertyDeclaration);
editor.InsertAfter(nodeToReplace, members);
editor.RemoveNode(nodeToReplace);
......
......@@ -44,7 +44,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ReplaceMethodWithP
propertyBackingField As IFieldSymbol,
desiredGetMethodName As String,
desiredSetMethodName As String) As IEnumerable(Of SyntaxNode) Implements IReplacePropertyWithMethodsService.GetReplacementMembers
Throw New NotImplementedException()
Dim propertyStatement = TryCast(propertyDeclarationNode, PropertyStatementSyntax)
If propertyStatement Is Nothing Then
Return SpecializedCollections.EmptyEnumerable(Of SyntaxNode)
End If
End Function
Public Sub ReplaceReference(editor As SyntaxEditor,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册