473,765 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compiler Error Request.

I have a request for the c# compiler one that is an obvious oversight in
my opinion. I'm not sure if this is already being implemented in
Whidebey, bu i would hope to find it in there, or in the next version.

Working with properties, and the neaming convention that Microsoft has
recommended for developing in C#, it is easy for one to have a circular
reference. This reference could easily be prevented by a Compiler error,
but as of 1.1 frameworks, it does not.

take the following code for example:

public class Foo
{
private int bar;

public int Bar
{
get{ return this.Bar; } // <-- this should be a
// compiler error.
}
}

This problem is further exaserbated by the fact that the VS.NET IDE's
Intellisense often chooses the Public version of a member before a
private as you are typing.

Another situation arises in which you are trying to access a private
member withing a class while using a property or method and end up using
a public Property. This is a problem because when you meant to access
the private member field, you access the Public Property method and
incur a performance penalty. Teh compiler should thorw warnings if it
detects such behavior.

Take this code for example:

public class Foo
{
private int bar;

public int Bar
{
get{ return this.bar; }
}

public int FooBar(int param)
{
// The following line should throw a warning.
return (this.Bar + param);
}
}
These are common mistakes i see happen in a development team using C#.
They are such subtle mistakes. Ones that a Compiler could pick up
easily. While i really enjoy proramming in this language, and developing
with it. i fear that this is one of the kinds of issues that come up
that makes C# often criticized for not being a language that is useable
in large development projects and teams.

I often feel this is not true, because I feel with some best practices
C# can be a great productivity enhancer. That is from experience in
developing large applicaitions in a team. But these subtle littpe
problems point to otherwise. Please fix this.

Sean
Nov 15 '05 #1
5 1321
On request 1, I agree, it would be nice if the compiler could determine
recursive calls like this. On the other hand, you will find this error
immediately the first time you access this property and you get a
stackoverflowex ception.

As for #2, I disagree. Often you do want to use the property and not the
underlying variable. Perhaps you are doing something in the property that
is more then just retreiving a private member, and your function code would
want to use the property to have that code execute. But then there are
times when you want the raw variable data.

There is no way for the compiler to tell which situation it is, and it is
your job as the developer to make sure you are accessing the correct one.
You can make this easier, by not differing the property and the private
member by case only - but actually make them more different then that, so
you are always consciously picking the correct one.

You can't have the compiler do everything for you. It's not unreasonable to
expect people to be aware of these things - and this is no way reflects on
how useful the language is. If these small issues make the language
unusable for your team for large projects, then I think there is a bigger
problem at hand.

But in either case, after you make this mistake once or twice, you will just
become aware of it, and you won't need the compiler to catch it.

"Sean Wolfe" <no*****@please .com> wrote in message
news:eF******** ******@TK2MSFTN GP09.phx.gbl...
I have a request for the c# compiler one that is an obvious oversight in
my opinion. I'm not sure if this is already being implemented in
Whidebey, bu i would hope to find it in there, or in the next version.

Working with properties, and the neaming convention that Microsoft has
recommended for developing in C#, it is easy for one to have a circular
reference. This reference could easily be prevented by a Compiler error,
but as of 1.1 frameworks, it does not.

take the following code for example:

public class Foo
{
private int bar;

public int Bar
{
get{ return this.Bar; } // <-- this should be a
// compiler error.
}
}

This problem is further exaserbated by the fact that the VS.NET IDE's
Intellisense often chooses the Public version of a member before a
private as you are typing.

Another situation arises in which you are trying to access a private
member withing a class while using a property or method and end up using
a public Property. This is a problem because when you meant to access
the private member field, you access the Public Property method and
incur a performance penalty. Teh compiler should thorw warnings if it
detects such behavior.

Take this code for example:

public class Foo
{
private int bar;

public int Bar
{
get{ return this.bar; }
}

public int FooBar(int param)
{
// The following line should throw a warning.
return (this.Bar + param);
}
}
These are common mistakes i see happen in a development team using C#.
They are such subtle mistakes. Ones that a Compiler could pick up
easily. While i really enjoy proramming in this language, and developing
with it. i fear that this is one of the kinds of issues that come up
that makes C# often criticized for not being a language that is useable
in large development projects and teams.

I often feel this is not true, because I feel with some best practices
C# can be a great productivity enhancer. That is from experience in
developing large applicaitions in a team. But these subtle littpe
problems point to otherwise. Please fix this.

Sean

Nov 15 '05 #2
Sean Wolfe <no*****@please .com> wrote:

I agree with your first suggestion but not with your second...
Take this code for example:

public class Foo
{
private int bar;

public int Bar
{
get{ return this.bar; }
}

public int FooBar(int param)
{
// The following line should throw a warning.
return (this.Bar + param);
}
}


What if Bar was implemented like this:

public int Bar
{
get { return someFlagIsSet ? bar : 0; }
}
Nov 15 '05 #3
C# Learner wrote:
Sean Wolfe <no*****@please .com> wrote:

I agree with your first suggestion but not with your second...

Take this code for example:

public class Foo
{
private int bar;

public int Bar
{
get{ return this.bar; }
}

public int FooBar(int param)
{
// The following line should throw a warning.
return (this.Bar + param);
}
}

What if Bar was implemented like this:

public int Bar
{
get { return someFlagIsSet ? bar : 0; }
}


I guess I do agree with you guys on the Second issue that this can
clearly be a best practices issue. But the first one is just an
oversight by the compiler. Whether or not it gets caught the first time
that it's run, or get a stack overflow, the call clearly shouldn't
compile. Compilers these days are smart enough to know such things.
Also having Intellisense choosing the Public item first doesn't help.

Sean
Nov 15 '05 #4

Hi Sean,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you have tabled 2 proposals for C# compiler
error checking.
=============== =============== =============== ==
For your #2, I agree with what Marina said, the compiler gives you the
flexibility to use Property validation, etc, so I think it is by the design
goal.

For your #1, I think C# is a case-sensitive language, and the case type
error is a use error in your code, so I think you should be careful of this
issue in your programming work.

But I also know your concern, you feel that C# compiler should be more
convinient for the developers and reduce more fallible possibility. I think
your concern also makes sense, so I suggest you provide your suggestion and
concern to Microsoft at:
http://register.microsoft.com/mswish/suggestion.asp
you also can email to: ms****@microsof t.com

=============== =============== =============== =
Thank you for your patience and cooperation. If you have any further
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

Hi Sean,

Does my reply makes sense to you?
Do you still have concern? Please feel free to feedback to me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6

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

Similar topics

2
17572
by: Mike Fisher | last post by:
I'm seeing an error when I try to run/debug a web service. Although it doesn't happen every time, it does occur more than half of the times I hit F5. It appears to be returned by the the JIT compiler as the page is requested by the browser. The result is that the "compiler failed with error code 2000". I have tested the same code on another workstation with VS.NET and it works fine EVERY time. I'm convinced it's not the code and I...
8
1901
by: jon morgan | last post by:
OK, I'm going to be brave. There is a bug in VS.Net 1.1 that causes random compiler errors. I have raised this issue in posts at least three time in the past couple of months without attracting much interest. But it's driving me nuts. Here's what happens. I'm working on a multi project VB app. happily writing nice inoffensive code - go to compile and the compiler tells me there's a problem in a project I'm not working on. But really...
1
2052
by: JTrigger | last post by:
When I compile my project using the IDE on a development machine it works just fine. When I compile it on the server using csc.exe, I get the following error when I try to bring it up in the web browser. What is the issue? Thanks, Jim Server Error in '/psnRequest' Application. ----------------------------------------------------------------------------
3
5133
by: Robert | last post by:
Every time I navigate to any .aspx file on my computer, I get the error below. According to MSDN this indicates that my CLR is corrupt, but I've re-installed the .NET framework with no help. Also reinstalled VS.NET; still nothing. Any ideas? Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code...
3
544
by: Hamilton | last post by:
Hi there, I've seen this error appear a few times in newsgroups but unfortunately I haven't found one that actually provides a solution. I'm basically deploying a new website into an area at a web hosting company and when I try to run the site (which runs in our local IIS server), I get the following error: Server Error in '/New' Application. Compilation Error Description: An error occurred during the compilation of a resource...
2
7039
by: mudge | last post by:
Hi, I'm getting some very strange problems with some C# code. We're running an ASP.NET application on a local server in a DMZ. If I access it using the internal address, the application works fine, every time. But, if I access on it's public IP, from my office workstation, from home, over the VPN, a test machine on ADSL, or whatever else you please, it fails. But only about 60% of the time. I have tried everything to pin this down....
7
6648
by: Mark Carrington | last post by:
I'm developing a web app in .NET 2 using C#, and occasionally see this error, apparently something to do with the theme used on the site: Compiler Error Message: The compiler failed with error code 1. Clicking the "Show Detailed Compiler Output" link on the error page shows a large command line that looks like it's using the vbc compiler to build the auto-generated theme code, but doesn't display any useful error messages. Executing...
0
1350
by: Ken | last post by:
Anyone know how to fix this error? Server Error in '/' Application. -------------------------------------------------------------------------------- Failed to load JIT compiler Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
3
2252
by: dancer | last post by:
I am using Framework 1.1.4322. Who can tell me why I'm getting this error? My code follows Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30456: 'Text' is not a member of 'System.Web.UI.WebControls.CheckBoxList'.
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
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
10007
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
9832
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
8831
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 project—planning, coding, testing, and deployment—without 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
7378
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
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2805
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.