Browse Source

[CodeAction] Fixed bug in create property code action.

newNRvisualizers
Mike Krüger 13 years ago
parent
commit
e1760a55d0
  1. 4
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs
  2. 22
      ICSharpCode.NRefactory.Tests/CSharp/CodeActions/CreatePropertyTests.cs

4
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs

@ -75,7 +75,9 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
} else { } else {
if (state.CurrentMember == null) if (state.CurrentMember == null)
yield break; yield break;
isStatic |= state.CurrentMember.IsStatic || state.CurrentTypeDefinition.IsStatic; isStatic |= state.CurrentTypeDefinition.IsStatic;
if (targetResolveResult == null)
isStatic |= state.CurrentMember.IsStatic;
} }
// var service = (NamingConventionService)context.GetService(typeof(NamingConventionService)); // var service = (NamingConventionService)context.GetService(typeof(NamingConventionService));

22
ICSharpCode.NRefactory.Tests/CSharp/CodeActions/CreatePropertyTests.cs

@ -307,5 +307,27 @@ class Foo
} }
"); ");
} }
[Test()]
public void TestNonStaticPropertyInStaticMethod ()
{
TestCreateProperty (@"class TestClass
{
static void Foo ()
{
new TestClass ().$NonExistantProperty = 5;
}
}", @"class TestClass
{
int NonExistantProperty {
get;
set;
}
static void Foo ()
{
new TestClass ().NonExistantProperty = 5;
}
}");
}
} }
} }
Loading…
Cancel
Save