diff --git a/src/Features/CSharp/Portable/EncapsulateField/CSharpEncapsulateFieldService.cs b/src/Features/CSharp/Portable/EncapsulateField/CSharpEncapsulateFieldService.cs index 363b781a087e2e702ce869da426fab8b3682fb8d..0c7e1fb59dc69827979ce4e555ef077ad339144f 100644 --- a/src/Features/CSharp/Portable/EncapsulateField/CSharpEncapsulateFieldService.cs +++ b/src/Features/CSharp/Portable/EncapsulateField/CSharpEncapsulateFieldService.cs @@ -146,13 +146,13 @@ protected override async Task> GetFieldsAsync(Document private bool CanEncapsulate(FieldDeclarationSyntax field) => field.Parent is TypeDeclarationSyntax; - protected override Tuple GeneratePropertyAndFieldNames(IFieldSymbol field) + protected override (string fieldName, string propertyName) GenerateFieldAndPropertyNames(IFieldSymbol field) { // Special case: if the field is "new", we will preserve its original name and the new keyword. if (field.DeclaredAccessibility == Accessibility.Private || IsNew(field)) { // Create some capitalized version of the field name for the property - return Tuple.Create(field.Name, MakeUnique(GeneratePropertyName(field.Name), field.ContainingType)); + return (field.Name, MakeUnique(GeneratePropertyName(field.Name), field.ContainingType)); } else { @@ -162,7 +162,7 @@ private bool CanEncapsulate(FieldDeclarationSyntax field) if (newPropertyName == field.Name) { // If we wind up with the field's old name, give the field the unique version of its current name. - return Tuple.Create(MakeUnique(GenerateFieldName(field.Name), field.ContainingType), newPropertyName); + return (MakeUnique(GenerateFieldName(field.Name), field.ContainingType), newPropertyName); } // Otherwise, ensure the property's name is unique. @@ -172,11 +172,11 @@ private bool CanEncapsulate(FieldDeclarationSyntax field) // If converting the new property's name into a field name results in the old field name, we're done. if (newFieldName == field.Name) { - return Tuple.Create(newFieldName, newPropertyName); + return (newFieldName, newPropertyName); } // Otherwise, ensure the new field name is unique. - return Tuple.Create(MakeUnique(newFieldName, field.ContainingType), newPropertyName); + return (MakeUnique(newFieldName, field.ContainingType), newPropertyName); } } diff --git a/src/Features/Core/Portable/EncapsulateField/AbstractEncapsulateFieldService.cs b/src/Features/Core/Portable/EncapsulateField/AbstractEncapsulateFieldService.cs index cd96b7fc48d204c14e6fcf7de7184a93f5bec5ed..e93579171b5875d46aacccd1b3a41e65728f5868 100644 --- a/src/Features/Core/Portable/EncapsulateField/AbstractEncapsulateFieldService.cs +++ b/src/Features/Core/Portable/EncapsulateField/AbstractEncapsulateFieldService.cs @@ -150,9 +150,7 @@ private async Task EncapsulateFieldResultAsync(Document document, TextSp private async Task EncapsulateFieldAsync(IFieldSymbol field, Document document, bool updateReferences, CancellationToken cancellationToken) { var originalField = field; - var finalNames = GeneratePropertyAndFieldNames(field); - var finalFieldName = finalNames.Item1; - var generatedPropertyName = finalNames.Item2; + var (finalFieldName, generatedPropertyName) = GenerateFieldAndPropertyNames(field); // Annotate the field declarations so we can find it after rename. var fieldDeclaration = field.DeclaringSyntaxReferences.First(); @@ -352,7 +350,7 @@ protected async Task AddPropertyAsync(Document document, Solution dest Formatter.Annotation.AddAnnotationToSymbol(propertySymbol)); } - protected abstract Tuple GeneratePropertyAndFieldNames(IFieldSymbol field); + protected abstract (string fieldName, string propertyName) GenerateFieldAndPropertyNames(IFieldSymbol field); protected Accessibility ComputeAccessibility(Accessibility accessibility, ITypeSymbol type) { diff --git a/src/Features/VisualBasic/Portable/EncapsulateField/VisualBasicEncapsulateFieldService.vb b/src/Features/VisualBasic/Portable/EncapsulateField/VisualBasicEncapsulateFieldService.vb index a18c713114664a39dac74fb0e37f8d3230101612..0094a0a1204bfdcd085020920e76d6dd8abe501f 100644 --- a/src/Features/VisualBasic/Portable/EncapsulateField/VisualBasicEncapsulateFieldService.vb +++ b/src/Features/VisualBasic/Portable/EncapsulateField/VisualBasicEncapsulateFieldService.vb @@ -100,19 +100,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EncapsulateField End If End Function - Protected Overrides Function GeneratePropertyAndFieldNames(field As IFieldSymbol) As Tuple(Of String, String) + Protected Overrides Function GenerateFieldAndPropertyNames(field As IFieldSymbol) As (fieldName As String, propertyName As String) ' If the field is marked shadows, it will keep its name. If field.DeclaredAccessibility = Accessibility.Private OrElse IsShadows(field) Then Dim propertyName = GeneratePropertyName(field.Name) propertyName = MakeUnique(propertyName, field) - Return Tuple.Create(field.Name, propertyName) + Return (field.Name, propertyName) Else Dim propertyName = GeneratePropertyName(field.Name) Dim containingTypeMemberNames = field.ContainingType.GetAccessibleMembersInThisAndBaseTypes(Of ISymbol)(field.ContainingType).Select(Function(s) s.Name) propertyName = NameGenerator.GenerateUniqueName(propertyName, containingTypeMemberNames.Where(Function(m) m <> field.Name).ToSet(), StringComparer.OrdinalIgnoreCase) Dim newFieldName = MakeUnique("_" + Char.ToLower(propertyName(0)) + propertyName.Substring(1), field) - Return Tuple.Create(newFieldName, propertyName) + Return (newFieldName, propertyName) End If End Function