473,795 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.Net 2.0 classes very buggy?

Hi all,

I'm playing with Lutz Roeders Reflector and have found several areas
where I think there are issues in the framework libraries. I can't see
how the following should work as expected and the compiler gives me an
error on the 'text1 = text1...' line. Is it really this buggy (this
particular bug is in several places) or am I missing something? You can
see that that code has a possibility of crashing if the property has a
.. in it. I think the line should read 'text1 = property.Name.. ..'.

The code is from the ProfileBuilder class in the System.Web.Comp ilation
class.

private void CreateCodeForPr operty(Assembly Builder assemblyBuilder ,
CodeTypeDeclara tion type, ProfileNameType Struct property)
{
string text1;
int num1 = property.Name.I ndexOf('.');
if (num1 > 0)
{
text1 = text1.Substring (num1 + 1);
}
if (!assemblyBuild er.CodeDomProvi der.IsValidIden tifier(text1))
{
throw new
ConfigurationEr rorsException(S R.GetString("Pr ofile_bad_name" ),
property.FileNa me, property.LineNu mber);
}
CodeMemberPrope rty property1 = new CodeMemberPrope rty();
property1.Name = text1;
property1.Attri butes = MemberAttribute s.Public;
property1.HasGe t = true;
property1.Type = property.Proper tyCodeRefType;
CodeMethodInvok eExpression expression1 = new
CodeMethodInvok eExpression();
expression1.Met hod.TargetObjec t = new
CodeThisReferen ceExpression();
expression1.Met hod.MethodName = "GetPropertyVal ue";
expression1.Par ameters.Add(new CodePrimitiveEx pression(text1) );
CodeMethodRetur nStatement statement1 = new
CodeMethodRetur nStatement(new CodeCastExpress ion(property1.T ype,
expression1));
property1.GetSt atements.Add(st atement1);
if (!property.IsRe adOnly)
{
CodeMethodInvok eExpression expression2 = new
CodeMethodInvok eExpression();
expression2.Met hod.TargetObjec t = new
CodeThisReferen ceExpression();
expression2.Met hod.MethodName = "SetPropertyVal ue";
expression2.Par ameters.Add(new
CodePrimitiveEx pression(text1) );
expression2.Par ameters.Add(new
CodePropertySet ValueReferenceE xpression());
property1.HasSe t = true;
property1.SetSt atements.Add(ex pression2);
}
type.Members.Ad d(property1);
}

Your thoughts would be welcome.

Ryan

Jun 12 '06 #1
9 1344
"Ryan" <ry***@lightsdo wn.com> wrote in message
news:11******** **************@ j55g2000cwa.goo glegroups.com.. .
Hi all,

I'm playing with Lutz Roeders Reflector and have found several areas
where I think there are issues in the framework libraries. I can't see
how the following should work as expected and the compiler gives me an
error on the 'text1 = text1...' line. Is it really this buggy (this
particular bug is in several places) or am I missing something? You can
see that that code has a possibility of crashing if the property has a
. in it. I think the line should read 'text1 = property.Name.. ..'.

The code is from the ProfileBuilder class in the System.Web.Comp ilation
class.

private void CreateCodeForPr operty(Assembly Builder assemblyBuilder ,
CodeTypeDeclara tion type, ProfileNameType Struct property)
{
string text1;
int num1 = property.Name.I ndexOf('.');
if (num1 > 0)
{
text1 = text1.Substring (num1 + 1);
} ....
<snip>
.... Your thoughts would be welcome.


When I look at that method with Reflector the first line is:
string text1 = property.Name;
which means that all is well. If it's any help I'm using Reflector
v4.2.27.0.

Chris Jobson
Jun 12 '06 #2

Chris Jobson wrote:
"Ryan" <ry***@lightsdo wn.com> wrote in message
news:11******** **************@ j55g2000cwa.goo glegroups.com.. .
Hi all,

I'm playing with Lutz Roeders Reflector and have found several areas
where I think there are issues in the framework libraries. I can't see
how the following should work as expected and the compiler gives me an
error on the 'text1 = text1...' line. Is it really this buggy (this
particular bug is in several places) or am I missing something? You can
see that that code has a possibility of crashing if the property has a
. in it. I think the line should read 'text1 = property.Name.. ..'.

The code is from the ProfileBuilder class in the System.Web.Comp ilation
class.

private void CreateCodeForPr operty(Assembly Builder assemblyBuilder ,
CodeTypeDeclara tion type, ProfileNameType Struct property)
{
string text1;
int num1 = property.Name.I ndexOf('.');
if (num1 > 0)
{
text1 = text1.Substring (num1 + 1);
}

...
<snip>
...
Your thoughts would be welcome.


When I look at that method with Reflector the first line is:
string text1 = property.Name;
which means that all is well. If it's any help I'm using Reflector
v4.2.27.0.

Chris Jobson


V4.2.43.0 seems to have bugs then, thanks for checking it out.

Ryan

Jun 12 '06 #3
What makes you think this class is buggy? What exactly do you mean with
crashing? Any exception would be helpfull. Also, keep in mind that you are
reverse engineering a private non documented class.

Willy.
"Ryan" <ry***@lightsdo wn.com> wrote in message
news:11******** **************@ j55g2000cwa.goo glegroups.com.. .
| Hi all,
|
| I'm playing with Lutz Roeders Reflector and have found several areas
| where I think there are issues in the framework libraries. I can't see
| how the following should work as expected and the compiler gives me an
| error on the 'text1 = text1...' line. Is it really this buggy (this
| particular bug is in several places) or am I missing something? You can
| see that that code has a possibility of crashing if the property has a
| . in it. I think the line should read 'text1 = property.Name.. ..'.
|
| The code is from the ProfileBuilder class in the System.Web.Comp ilation
| class.
|
| private void CreateCodeForPr operty(Assembly Builder assemblyBuilder ,
| CodeTypeDeclara tion type, ProfileNameType Struct property)
| {
| string text1;
| int num1 = property.Name.I ndexOf('.');
| if (num1 > 0)
| {
| text1 = text1.Substring (num1 + 1);
| }
| if (!assemblyBuild er.CodeDomProvi der.IsValidIden tifier(text1))
| {
| throw new
| ConfigurationEr rorsException(S R.GetString("Pr ofile_bad_name" ),
| property.FileNa me, property.LineNu mber);
| }
| CodeMemberPrope rty property1 = new CodeMemberPrope rty();
| property1.Name = text1;
| property1.Attri butes = MemberAttribute s.Public;
| property1.HasGe t = true;
| property1.Type = property.Proper tyCodeRefType;
| CodeMethodInvok eExpression expression1 = new
| CodeMethodInvok eExpression();
| expression1.Met hod.TargetObjec t = new
| CodeThisReferen ceExpression();
| expression1.Met hod.MethodName = "GetPropertyVal ue";
| expression1.Par ameters.Add(new CodePrimitiveEx pression(text1) );
| CodeMethodRetur nStatement statement1 = new
| CodeMethodRetur nStatement(new CodeCastExpress ion(property1.T ype,
| expression1));
| property1.GetSt atements.Add(st atement1);
| if (!property.IsRe adOnly)
| {
| CodeMethodInvok eExpression expression2 = new
| CodeMethodInvok eExpression();
| expression2.Met hod.TargetObjec t = new
| CodeThisReferen ceExpression();
| expression2.Met hod.MethodName = "SetPropertyVal ue";
| expression2.Par ameters.Add(new
| CodePrimitiveEx pression(text1) );
| expression2.Par ameters.Add(new
| CodePropertySet ValueReferenceE xpression());
| property1.HasSe t = true;
| property1.SetSt atements.Add(ex pression2);
| }
| type.Members.Ad d(property1);
| }
|
| Your thoughts would be welcome.
|
| Ryan
|
Jun 12 '06 #4

Ryan wrote:
Hi all,

I'm playing with Lutz Roeders Reflector and have found several areas
where I think there are issues in the framework libraries. I can't see
how the following should work as expected and the compiler gives me an
error on the 'text1 = text1...' line.
What's the error?
Is it really this buggy (this
particular bug is in several places) or am I missing something? You can
see that that code has a possibility of crashing if the property has a
. in it.


OK. Can you show us the code that would make this crash?

--
Larry Lard
Replies to group please

Jun 12 '06 #5
You are too quick to consider things to be buggy.
Reflector is right, if you are not sure check the IL..

IL_0015: ldloc.1
IL_0016: ldc.i4.1
IL_0017: add
IL_0018: callvirt instance string [mscorlib]System.String:: Substring(int32 )

which turns into...

text1 = text1.Substring (num1 + 1);
in C#

Willy.
"Ryan" <ry***@lightsdo wn.com> wrote in message
news:11******** **************@ j55g2000cwa.goo glegroups.com.. .
|
| Chris Jobson wrote:
| > "Ryan" <ry***@lightsdo wn.com> wrote in message
| > news:11******** **************@ j55g2000cwa.goo glegroups.com.. .
| > > Hi all,
| > >
| > > I'm playing with Lutz Roeders Reflector and have found several areas
| > > where I think there are issues in the framework libraries. I can't see
| > > how the following should work as expected and the compiler gives me an
| > > error on the 'text1 = text1...' line. Is it really this buggy (this
| > > particular bug is in several places) or am I missing something? You
can
| > > see that that code has a possibility of crashing if the property has a
| > > . in it. I think the line should read 'text1 = property.Name.. ..'.
| > >
| > > The code is from the ProfileBuilder class in the
System.Web.Comp ilation
| > > class.
| > >
| > > private void CreateCodeForPr operty(Assembly Builder assemblyBuilder ,
| > > CodeTypeDeclara tion type, ProfileNameType Struct property)
| > > {
| > > string text1;
| > > int num1 = property.Name.I ndexOf('.');
| > > if (num1 > 0)
| > > {
| > > text1 = text1.Substring (num1 + 1);
| > > }
| > ...
| > <snip>
| > ...
| > > Your thoughts would be welcome.
| >
| > When I look at that method with Reflector the first line is:
| > string text1 = property.Name;
| > which means that all is well. If it's any help I'm using Reflector
| > v4.2.27.0.
| >
| > Chris Jobson
|
| V4.2.43.0 seems to have bugs then, thanks for checking it out.
|
| Ryan
|
Jun 12 '06 #6

Larry Lard wrote:
Ryan wrote:
Hi all,

I'm playing with Lutz Roeders Reflector and have found several areas
where I think there are issues in the framework libraries. I can't see
how the following should work as expected and the compiler gives me an
error on the 'text1 = text1...' line.


What's the error?
Is it really this buggy (this
particular bug is in several places) or am I missing something? You can
see that that code has a possibility of crashing if the property has a
. in it.


OK. Can you show us the code that would make this crash?

--
Larry Lard
Replies to group please


Well, I think the issue is with the later versions of reflector. The IL
may be correct but it is not easy to read so I am going on VB/C#
output. As Chris Jobson pointed out, it looks like my particular
version of reflector (or a conflict with the add ins).

I did not assume that the .Net classes were buggy, I was just asking as
I was not certain what was going on.

It looks like inline initialisation is not being output correctly. The
following;
private void CreateCodeForPr operty(Assembly Builder assemblyBuilder ,
CodeTypeDeclara tion type, ProfileNameType Struct property)
{
string text1;
int num1 = property.Name.I ndexOf('.');
if (num1 > 0)
{
text1 = text1.Substring (num1 + 1);

Should read (according to Chris);
private void CreateCodeForPr operty(Assembly Builder assemblyBuilder ,
CodeTypeDeclara tion type, ProfileNameType Struct property)
{
string text1 = property.Name;
int num1 = property.Name.I ndexOf('.');
if (num1 > 0)
{
text1 = text1.Substring (num1 + 1);

So you get text1 manipulation of an empty string and the compiler
complains.

Ryan

Jun 12 '06 #7
Sorry, I misread Chris post, he is right the first line should look like ...

string text1 = property.Name;

this is not the only bug in reflector (all versions), I for one never trust
the output generated by reflector.

Willy.

"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:O0******** ******@TK2MSFTN GP02.phx.gbl...
| You are too quick to consider things to be buggy.
| Reflector is right, if you are not sure check the IL..
|
| IL_0015: ldloc.1
| IL_0016: ldc.i4.1
| IL_0017: add
| IL_0018: callvirt instance string
[mscorlib]System.String:: Substring(int32 )
|
| which turns into...
|
| text1 = text1.Substring (num1 + 1);
| in C#
|
| Willy.
|
|
| "Ryan" <ry***@lightsdo wn.com> wrote in message
| news:11******** **************@ j55g2000cwa.goo glegroups.com.. .
||
|| Chris Jobson wrote:
|| > "Ryan" <ry***@lightsdo wn.com> wrote in message
|| > news:11******** **************@ j55g2000cwa.goo glegroups.com.. .
|| > > Hi all,
|| > >
|| > > I'm playing with Lutz Roeders Reflector and have found several areas
|| > > where I think there are issues in the framework libraries. I can't
see
|| > > how the following should work as expected and the compiler gives me
an
|| > > error on the 'text1 = text1...' line. Is it really this buggy (this
|| > > particular bug is in several places) or am I missing something? You
| can
|| > > see that that code has a possibility of crashing if the property has
a
|| > > . in it. I think the line should read 'text1 = property.Name.. ..'.
|| > >
|| > > The code is from the ProfileBuilder class in the
| System.Web.Comp ilation
|| > > class.
|| > >
|| > > private void CreateCodeForPr operty(Assembly Builder assemblyBuilder ,
|| > > CodeTypeDeclara tion type, ProfileNameType Struct property)
|| > > {
|| > > string text1;
|| > > int num1 = property.Name.I ndexOf('.');
|| > > if (num1 > 0)
|| > > {
|| > > text1 = text1.Substring (num1 + 1);
|| > > }
|| > ...
|| > <snip>
|| > ...
|| > > Your thoughts would be welcome.
|| >
|| > When I look at that method with Reflector the first line is:
|| > string text1 = property.Name;
|| > which means that all is well. If it's any help I'm using Reflector
|| > v4.2.27.0.
|| >
|| > Chris Jobson
||
|| V4.2.43.0 seems to have bugs then, thanks for checking it out.
||
|| Ryan
||
|
|
Jun 12 '06 #8
On 12 Jun 2006 06:51:36 -0700, "Ryan" <ry***@lightsdo wn.com> wrote:

I did not assume that the .Net classes were buggy, I was just asking as
I was not certain what was going on.

Ryan


Ryan,

I think you should look again at the title that you gave this thread:
".NET 2.0 classes very buggy?"

Sorry, but it is a pet peeve of mine to check these technical
newsgroups and see dozens of posts implying that there is a bug with
such-and-such class or method in the framework.

For me personally, if I hit a problem with the framework, the order
that I follow in diagnosing it is:

1. Have I made a simple typo?
2. Do I have a misunderstandin g with how the method/class is supposed
to function?
3. Re-read the MSDN Library docs.
4. Is this a common misunderstandin g? (search the newsgroups)
5. Check books on my bookshelf.
6. Look at the internals of the framework with Reflector to get a
better understanding of what is going on under the covers.

etc.

Claiming to have found a bug in the .NET Framework would probably be
the last step in my search, yet for so, so many people, it seems to be
step #1.

Rant-mode off.

Chuck

Jun 21 '06 #9

Chuck Heatherly wrote:
On 12 Jun 2006 06:51:36 -0700, "Ryan" <ry***@lightsdo wn.com> wrote:

I did not assume that the .Net classes were buggy, I was just asking as
I was not certain what was going on.

Ryan


Ryan,

I think you should look again at the title that you gave this thread:
".NET 2.0 classes very buggy?"

Sorry, but it is a pet peeve of mine to check these technical
newsgroups and see dozens of posts implying that there is a bug with
such-and-such class or method in the framework.

For me personally, if I hit a problem with the framework, the order
that I follow in diagnosing it is:

1. Have I made a simple typo?
2. Do I have a misunderstandin g with how the method/class is supposed
to function?
3. Re-read the MSDN Library docs.
4. Is this a common misunderstandin g? (search the newsgroups)
5. Check books on my bookshelf.
6. Look at the internals of the framework with Reflector to get a
better understanding of what is going on under the covers.

etc.

Claiming to have found a bug in the .NET Framework would probably be
the last step in my search, yet for so, so many people, it seems to be
step #1.

Rant-mode off.

Chuck


Hey, I understand, that'll be why I put a question mark there at the
end of the title. I was after some input from more knowledgable people
because I did not take at face value what I was seeing.

Jun 21 '06 #10

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

Similar topics

1
1338
by: Michal Vitecek | last post by:
hello, does the type() command work correctly for new style classes? i guess it does not, unfortunately. for example, for a new style class' instance it returns <class '__main__.ClassName'>, but for old style class' instance it returns <type 'instance'>. >>> import types >>> class A(object): pass
10
6583
by: Frances Del Rio | last post by:
I've been wondering for a while whether you can do this... let's say I define a class thus: ..myClass {font-family:verdana,sans-serif; font-size:11px; color:#006699; text-decoration:underline} then I want to define a SUB-CLASS of this one.. i.e., I want to define a new class just like this one but w/only one attr set differently, and I don't want to repeat all attr's.. so how do I say
17
1571
by: rkusenet | last post by:
This sure looks like a troll, but IBM folks should go there and defend DB2 http://groups-beta.google.com/group/comp.databases.oracle.server/browse_frm/thread/85c5a5d965f95741/552708de1c07fd61#552708de1c07fd61 " We're almost ready to give up on DB2 v8 and consider migration to Oracle (the reason is DB2 v8 being unstable). The main question is - how good and stable properly configured Oracle is under heavy OLTP load (10M+...
11
1631
by: Zoury | last post by:
Hi there! :O) I've noticed some strange behavior with the VS IDE. Here's two a can think of right now... but those are most fusstrating i've encountered. 1. Every now and then, I haven't noticed what we did for it to happen, it appears that the events that were linked to a control are lost. The code is still there but we have to reset the "handlers".
11
1446
by: unwantedspam | last post by:
I am getting an "Object Expected" error on line 0. Do you see anything wrong with the following code: var iTest = 60 function test(msg) { var NewMessage = msg;
173
5736
by: Zytan | last post by:
I've read the docs on this, but one thing was left unclear. It seems as though a Module does not have to be fully qualified. Is this the case? I have source that apparently shows this. Are modules left-over from VB6, and not much used anymore? It seems that it is better to require Imports or use fully qualified names for functions in other classes/modules, but a Module doesn't require this, cluttering the global namespace. It seems...
5
1749
by: lobequadrat | last post by:
Hello, I am trying to get the following code work (unfortunately not mine ... :( ) template <class Tclass Test { public: class ELEM;
3
1535
by: juro | last post by:
Hi, I have a small problem: I'd like to call static variables from different classes - their names are stored in an array. Example of a class: class MyClass1{ public static $mysql_table = "table1"; } Now I would like to do something like this: $classes=array("MyClass1","MyClass2","MyClass3"); foreach ($classes as $item)
10
1957
by: Phat G5 (G3) | last post by:
I was toying around with adding a new method to the Array class. It works fine in FF but not in Safari. I have no idea in IE. I have not gotten that far yet. Array.prototype.find = function(item) { for(var i in this ) if( item == this(i) ) return( true ) return( false ); };
0
9519
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
10213
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
10000
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
9040
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...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.