473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C# language wish list

JS
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.

Aug 26 '08 #1
5 1265
"JS" <jn*********@gmail.comwrote in message
news:33**********************************@q5g2000p rf.googlegroups.com...
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.
Thats somewhat esoteric. Reflection is a useful feature of .NET but it I
wouldn't have thought it to be a common day to day thing that many C#ers
would be doing. I wouldn't want the language cluttered with keywords that
have marginal use.
>
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.
Such a syntax would save two extra lines:-

class Panel
{
private AppearanceType myAppearance = new AppearanceType();

internal AppearanceType Appearance { get { return myAppearance; } }

internal class AppearanceType
{
public Color BackGroundColor{ get; set; }
}
}

Again its a little out there. If I found I had so many proprties that I
needed this sort of solution I would be questioning my design. Perhaps
Appearance may be worth promoting to a sibling class rather than a nested
one.
--
Anthony Jones - MVP ASP/ASP.NET
Aug 26 '08 #2
JS
The reflection keyword idea is to deal with things like data binding,
which is used by lots of C# developers.

I know the class namespace idea can already be donebut I find myself
using that internal class quite a bit. I also find that my internal
class often needs a reference to the class that owns it.
Aug 26 '08 #3
The first is discussed regularly - a "nameof" or "infoof" operator. I
agree with the usefulness in particular of the simple "nameof", but we
shall have to see if anything ever materialises. However, note that
with .NET 3.5 you can create a method to do this using Expression and
lambda

http://groups.google.co.uk/group/mic...05324df6b30218
http://groups.google.co.uk/group/mic...f914f92ef43047

I'll let you decide if it is worth it or not...

Marc
Aug 26 '08 #4
JS wrote:
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.
I think the use of reflection and reference to field by itself and
not by name is a contradiction.
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.
Namespaces is a well defined concept in other languages - you
can not change the meaning of that term.

Besides I think VS region is providing some of the functionality
you want.

Arne
Aug 27 '08 #5
JS wrote:
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.
The first request is pretty normal.
The second suggests poor seperation of concerns.

It's rare that a class should be over 100 lines of code (unless it's not
actually a class but a big horrible blob of nasty code).

Alun Harford
Aug 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville...
134
by: Joseph Garvin | last post by:
As someone who learned C first, when I came to Python everytime I read about a new feature it was like, "Whoa! I can do that?!" Slicing, dir(), getattr/setattr, the % operator, all of this was very...
22
by: lechequier | last post by:
Let's say I define a list of pairs as follows: >>l = Can anyone explain why this does not work? >>h = {}.update(l) and instead I have to go: >>h = {} >>h.update(l) to initialize a...
2
by: beliavsky | last post by:
Linux Journal annually polls its readers on questions such as their favorite programming language. In the 2005 poll, Python is 2nd, its highest ranking ever. Below are the results by year. I wish...
8
by: codymanix | last post by:
Often you don't wish that clientcode does not depend on a certain implementation of your methods: class MyClass { public IList DoIt(){return new ArrayList();} } clientcode could now cast...
106
by: cfmortgagepro | last post by:
Hi, I know that I'm an extreme newb by asking this overly beaten question, but I am leaning toward C#, becuase the perception is that it is better to learn than VB.Net. I guess it makes you...
14
by: Magius | last post by:
Hello, I have a question about the correctness of the language grammar for the C# 2.0 specification. I am working with the grammar specified in the June 2005 ECMA-334 standard. Basically, a...
15
by: cody | last post by:
currently when trying to change a struct returned by a property, the compiler generates an error. so if you try someControl.Location.Y = 10; you get an error which is logical if one...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
14
by: deko | last post by:
For building Windows desktop apps, the clear favorite is C#. But my clients can't afford to buy Microsoft products. So I need to develop software for Linux users and web applications. In the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.