473,698 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(My Class.TestPrope rty);
Where "propertyIn fo" is the new keyword. My motivation for this is
that now I can change the name of "TestProper ty" 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.Appearanc e.BackgroundCol or = 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 1275
"JS" <jn*********@gm ail.comwrote in message
news:33******** *************** ***********@q5g 2000prf.googleg roups.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(My Class.TestPrope rty);
Where "propertyIn fo" is the new keyword. My motivation for this is
that now I can change the name of "TestProper ty" 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.Appearanc e.BackgroundCol or = 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(My Class.TestPrope rty);
Where "propertyIn fo" is the new keyword. My motivation for this is
that now I can change the name of "TestProper ty" 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
2844
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 Vainio http://www.students.tut.fi/~vainio24
134
6083
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 different from C. I'm curious -- what is everyone's favorite trick from a non-python language? And -- why isn't it in Python? Here's my current candidate: So the other day I was looking at the language Lua. In Lua, you make a
22
1754
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 dictionary with the given list of pairs?
2
1803
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 that rankings beyond the first 3 were available and that the number of votes were shown. Nerds like numbers, not journalist blather :). I found this data for earlier years by Googling "linux journal <yyyy> readers choice awards". 2005
8
1419
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 the return value in Arraylist. In a later version you may find it more effective that your method returns an Array. This
106
5211
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 cooler.:-) Anyhow, I am a novice programmer, and I will remain one as well...I have no plans to make programming my life ambition, but I think that it would be fun to make my databases do some cool tricks and maybe write a simplistic client to...
14
2029
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 using-namespace-directive is defined as follows: using-namespace-directive: using namespace-name ;
15
1572
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 understands how value types work. but wouldn't it be an good idea to allow such a construct and let the compiler generate code like that in such a case:
669
25951
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 paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
14
3292
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 open source world, what is the programmer's language of choice? Judging by the number of members in each of these http://www.google.com/Top/Computers/Programming/Languages/Open_Source/ user groups, it looks like the top 3 open source languages...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.