autocomplete preferences for properties with same name as declared type
Edit for info:
Resharper 5.1.3000.12
Visual Studio 2010
Hi,
I'm trying to understand (and control) the autocompletion preferences for properties that are named the same as their Type (ie public Bar Bar { get; set; }).
public class X
{
}
public class F
{
}
public class Test
{
public X X { get; private set; }
public F F { get; private set; }
public Test()
{
_
}
}
When the caret is in _
If I type X, autocomplete gives me the option of
- X - the type
- X - the property - the preferred/auto-selected option
If I type F, autocomplete gives me the option of
- F - the type - the preferred/auto-selected option
- F - the property
- A bunch of other completions relating to other types
I guess this seeming inconsistency is due to other the other types/declarations that could begin with F, but I find it a little offputting.
I'd like to know:
- What are the specific rules that dictate which autocomplete option will be automatically selected?
- Is there a way to make ti default to the property? I find it kind of annoying to constantly have to add a <DownArrow><Tab> to select the property, when this is usually my preferred option.
Please sign in to leave a comment.
Hello,
Regarding your questions:
1. ReSharper selects the most frequently completed item among items having
the same prefix, so you should manually complete a property a couple of times
in order to increase its priority.
2. We will try tuning the heuristics regarding properties for the upcoming
ReSharper 6.
Thank you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
The more annoying aspect of this for me is that ReSharper inserts redundant
namespace qualifiers and I just discovered last week in certain instances
changes X to this.X or global::X resulting in broken code. One example:
public enum TestType
{
A = 1,
B = 2,
C = 3
}
public class SomeClass
{
public TestType TestType { get; set; }
public TestType GetTestType()
{
return ConsoleApplication.TestType.A;
}
}
What I actually typed is return TestType.A but ReSharper inserted the
redundant namespace.
A second test that results breaks the code:
namespace TestNamespace
{
public enum TestType
{
A = 1,
B = 2,
C = 3
}
}
namespace ConsoleApplication1
{
public class SomeClass
{
public TestType TestType { get; set; }
public TestType GetTestType()
{
TestType type = TestType.A;
if(type == TestType.B)
type = TestType.C;
return type;
}
}
}
Highlight TestNamespace and rename it to AnotherNamespace. The resulting
code:
public TestType GetTestType()
{
TestType type = this.TestType.A;
if(type == this.TestType.B)
type = this.TestType.C;
return type;
}
If the TestType enumeration is not contained in a namespace, ReSharper
changes every instance to global::TestType. I think this also happens if you
rename the ConsoleApplication1 namespace or if you use ReSharper to insert a
namespace in a file that doesn't have a namespace.
"fostandy" wrote in message
news:11915751.85171303348612680.JavaMail.devnet@domU-12-31-39-18-36-57.compute-1.internal...
Hi,
I'm trying to understand (and control) the autocompletion preferences for
properties that are named the same as their Type (ie public Bar Bar { get;
set; }).
public class X
{
}
public class F
{
}
public class Test
{
public X X { get; private set; }
public F F { get; private set; }
public Test()
}
When the caret is in _
If I type X, autocomplete gives me the option of
X - the type
X - the property - the preferred/auto-selected option
If I type F, autocomplete gives me the option of
F - the type - the preferred/auto-selected option
F - the property
A bunch of other completions relating to other types
I guess this seeming inconsistency is due to other the other
types/declarations that could begin with F, but I find it a little
offputting.
I'd like to know:
1. What are the specific rules that dictate which autocomplete option will
be automatically selected?
2. Is there a way to make ti default to the property? I find it kind of
annoying to constantly have to add a to select the
property, when this is usually my preferred option.
---
Original message URL: http://devnet.jetbrains.net/message/5301118#5301118