Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Discussion on a custom rule, OverrideToStringMethodRule
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lex Li  
View profile  
 More options Nov 18 2010, 8:27 am
From: Lex Li <lextu...@gmail.com>
Date: Thu, 18 Nov 2010 21:27:11 +0800
Local: Thurs, Nov 18 2010 8:27 am
Subject: Discussion on a custom rule, OverrideToStringMethodRule

Hi guys,

I have been using this custom rule for my open source projects for a few
months, and started to maintain it in a fork after Mono moved to GitHub.

https://github.com/lextm/mono-tools/commit/261ec39bb6d1ac72da7bb1d349...

Like spouliot commented, this rule is still far from mature. Any feedback is
welcome.

Thanks,

Lex Li
http://www.lextm.com
"My King of Pop is dead"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Antoine V  
View profile  
 More options Nov 18 2010, 3:20 pm
From: Antoine V <ant.v...@gmail.com>
Date: Thu, 18 Nov 2010 12:20:12 -0800 (PST)
Local: Thurs, Nov 18 2010 3:20 pm
Subject: Re: Discussion on a custom rule, OverrideToStringMethodRule
Hello,

Maybe we can add a check for internal/private class to not apply the
rule if there is never a call to ToString (or parameter of
string.Format, Console.WriteLine).
The same way, if a call to ToString is detected, we can increase the
severity.

Antoine


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bevan Arps  
View profile  
 More options Nov 18 2010, 10:55 pm
From: Bevan Arps <bevan.a...@gmail.com>
Date: Fri, 19 Nov 2010 16:55:18 +1300
Local: Thurs, Nov 18 2010 10:55 pm
Subject: Re: [gendarme] Re: Discussion on a custom rule, OverrideToStringMethodRule

On 19/11/2010 9:20 a.m., Antoine V wrote:

> Maybe we can add a check for internal/private class to not apply the
> rule if there is never a call to ToString (or parameter of
> string.Format, Console.WriteLine).
> The same way, if a call to ToString is detected, we can increase the
> severity.

I like the idea of a rule that promotes classes that "play well" in the
debugger.

However, many of my own classes use the attribute [DebuggerDisplay] to
control the string that is displayed by the debugger.

See
http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerdi...

I'd suggest this rule shouldn't fire if the class has a
[DebuggerDisplay] attribute defined.

Just my 2c,
Bevan.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastien Pouliot  
View profile  
 More options Nov 22 2010, 9:44 pm
From: Sebastien Pouliot <sebastien.poul...@gmail.com>
Date: Mon, 22 Nov 2010 18:44:04 -0800 (PST)
Local: Mon, Nov 22 2010 9:44 pm
Subject: Re: Discussion on a custom rule, OverrideToStringMethodRule
Hello Lex,

Thanks for bringing this up the mailing-list.

I think the rule has potential since I had a similar idea a while
ago ;-) What stopped me earlier was a feeling that it would bring a
lot of defects, quite a few of them not very important. For example:

a) in Gendarme most rules do not have any state so the best "ToString"
is still, IMO, the type name. That could be fixed easily by skipping
types without any fields (since most interesting properties will have
a, manual or automatic, backing field).

b) Abstract types do not really need a ToString since it won't be used
(assuming all inheritors provide their own). Now this does not play
well with (a) because the abstract type could have fields where the
concrete have none (not a very big issue and a parent-check could be
done too);

c) Bevan's comment about [DebuggerDisplay] is another case (but again
not perfect considering non-VS.NET users ;-)

I don't have more ideas right now but I'd be happy if those suggestion
(more feedback welcome) could be added to the rule. I think that would
make it something I like to fix for Gendarme.

Sebastien

p.s. one last thing let's move the rule from .Design
to .Maintainability

On Nov 18, 8:27 am, Lex Li <lextu...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastien Pouliot  
View profile  
 More options Nov 22 2010, 9:46 pm
From: Sebastien Pouliot <sebastien.poul...@gmail.com>
Date: Mon, 22 Nov 2010 18:46:51 -0800 (PST)
Local: Mon, Nov 22 2010 9:46 pm
Subject: Re: Discussion on a custom rule, OverrideToStringMethodRule
On Nov 18, 3:20 pm, Antoine V <ant.v...@gmail.com> wrote:

> Hello,

> Maybe we can add a check for internal/private class to not apply the
> rule if there is never a call to ToString (or parameter of
> string.Format, Console.WriteLine).
> The same way, if a call to ToString is detected, we can increase the
> severity.

That's a bit complicated and would miss some "honest" cases ;-)
e.g. list.Add (obj); foreach (object o in list) Console.WriteLine (o);

ToString are also very useful when debugging (in or out a debugger)
where the extra debugging code won't be present at analysis time.

Sebastien


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »