diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.cs index 7e1c3ed6bac24b054a173313fe3f94302121f8e5..94e4e9564b9bddb37848651fc3e4a8887bb0a372 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.cs @@ -409,6 +409,15 @@ public void TestWithPartialClasses() Test( @"partial class C { int [||]GetFoo() { } } partial class C { void SetFoo(int i) { } }", @"partial class C { int Foo { get { } set { } } } partial class C { }", +index: 1); + } + + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)] + public void TestUpdateGetSetCaseInsensitive() + { + Test( +@"using System; class C { int [||]getFoo() { } void setFoo(int i) { } }", +@"using System; class C { int Foo { get { } set { } } }", index: 1); } } diff --git a/src/Features/Core/Portable/ReplaceMethodWithProperty/ReplaceMethodWithPropertyCodeRefactoringProvider.cs b/src/Features/Core/Portable/ReplaceMethodWithProperty/ReplaceMethodWithPropertyCodeRefactoringProvider.cs index b5ec421eb48f30e7167ffd2e076fa66214cd9ff8..ff81eb4d16a9762026bb543fe5c2b29d51c5b208 100644 --- a/src/Features/Core/Portable/ReplaceMethodWithProperty/ReplaceMethodWithPropertyCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/ReplaceMethodWithProperty/ReplaceMethodWithPropertyCodeRefactoringProvider.cs @@ -95,14 +95,20 @@ private static bool HasGetPrefix(SyntaxToken identifier) private static bool HasGetPrefix(string text) { - return text.StartsWith(GetPrefix) && text.Length > GetPrefix.Length && !char.IsLower(text[GetPrefix.Length]); + return HasPrefix(text, GetPrefix); + } + private static bool HasPrefix(string text, string prefix) + { + return text.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && text.Length > prefix.Length && !char.IsLower(text[prefix.Length]); } private IMethodSymbol FindSetMethod(IMethodSymbol getMethod) { var containingType = getMethod.ContainingType; - var setMethod = containingType.GetMembers("Set" + getMethod.Name.Substring(GetPrefix.Length)) + var setMethodName = "Set" + getMethod.Name.Substring(GetPrefix.Length); + var setMethod = containingType.GetMembers() .OfType() + .Where(m => setMethodName.Equals(m.Name, StringComparison.OrdinalIgnoreCase)) .Where(m => IsValidSetMethod(m, getMethod)) .FirstOrDefault();