There are 2 features that I keep wishing C# had. These are not
groundbreaking ideas, and I haven't given these too much thought, but
I wonder if others have also wanted these types of language features.
1. C# Keywords for reflection. The idea here is that we can access
PropertyInfo through a keyword. An example might be: PropertyInfo
pinfo = propertyInfo(MyClass.TestProperty);
Where "propertyInfo" is the new keyword. My motivation for this is
that now I can change the name of "TestProperty" to something else and
VS refactoring will be able to find this reference to the property.
This could extend to other reflection types like MethodInfo as well.
2. Namespaces inside classes. Some classes can get quite large and it
would be useful to break down methods and properties into categories.
Look at all the methods, properties, and events inside any WinForms
control for instance and there are just too many. Here's an example
of a class using my proposed namespace idea:
class Panel
{
namespace Appearance
{
public Color BackgroundColor { get; set; }
}
}
Then you'd use an instance of Panel like this:
panel.Appearance.BackgroundColor = Color.Blue;
I guess class namespaces could be labeled as sealed, public, private,
protected as well, although I haven't thought about this too much. In
addition to just being able to categorize methods, properties and
events, there are some repercussions which come from this. For
example, you could now have 2 methods in a class with the same
arguments but different return types, as long as they are in different
namespaces.