NERPA plugin, build NRP-2006-01-06

Greetings everybody,

New version of previously released Netix Resharper Plugin is available. I'd
even say it is new plugin, so much has changed, so I gave it codename "NERPA".
General direction of the plugin would be "Suggest code improvemens", using
MS design guidelines, FxCop rules, common sense and your ideas. Another rationale
is to provide other plugin developers with some real examples.

It works for me under VS2003, but it has been told it will not work under
VS2005 due to API differences between .NET 1.1 and 2.0 versions. Since I
don't have VS2005, I can't make version for it. Also, plugin does not target
FW2.0 specific features yet. Finally, I'm too lazy to establish versioning
while so much changes every day, so I will use dates to number builds for
a while :)

FEATURES

  • Adds a number of suggestions to improve the code. They are displayed in

different color ("Resharper Suggestion" in font/color options, name subject
to change), but otherwise behave like warnings. I hope it can be fixed soon,
see "Controlling custom highlightes" topic in this newsgroup.
--- Suggestions to rename fields, parameters and variables to conform to
coding style. Quick fix included.
--- Suggestion to rename parameters that are not named the same as parameter
from base class/interface. Quick fix included. Planned to include the opposite
quick fix (rename base parameter)
--- Avoid empty interfaces
--- Do not use general catch clause, do not catch general type 'Exception'.
Currently it doesn't check for rethrowing exception (using "throw;") which
is not a problem.
--- Types that own disposable fields should be disposable. Planned quick
fix to add IDisposable on the class and implement it.
--- Constructor of abstract type should be protected. Planned quick fix to
change constructor access.
--- Types with no externally visible constructors should not be abstract.
Planned quick fix to remove abstract and add sealed.
--- Types with no externally visible constructors should be sealed. Planned
quick fix to add sealed.
--- Static holder types should be sealed. Planned quick fix to add sealed.
--- Static holder types should not have externally visible constructors.
Planned quick fix to change constructor access.

  • Menu action to fix all naming problems in current file (main menu and code

window context menu).
Note, that guessing correct names is a kind of magic, so it may not work
for you code style settings. If it doesn't, please drop me a note along with
your prefix/suffix list.
Also note, that it doesn't yet check for correct casing on types and members.
Planned for future.

  • Options page in Resharper options to switch on/off suggestions, though

it has incorrect label "Verify naming style". It actually controls all suggestions.
Later I will separate them much like Resharper's own warnings configuration.

  • Adds quickfixes to create empty class from unresolved reference. Two options

are given - create in same file and create as new file. Quickfix is available
in declarations and typeof expressions.

  • Context action to swap assignment expression source and destionation parts

(i.e. left and right). Works on assignment '=' sign. Checks for left side
to be readable (e.g. not a property with setter only) and right side to be
writable (e.g. not readonly field outside of constructor). However, this
feature was not yet tested extensively.

DOWNLOAD
http://users.netix.ru/orangy/resharper/NRP-2006-01-06.ZIP
Zip file contains dll and source code, size is 64kb.

INSTALLATION
1. Close all instances of VS
2. Copy Netix.Resharper.Plugin.dll so it is located in the folder "C:\Program
Files\JetBrains\ReSharper\VS2003\Plugins\Netix Resharper Plugin\"
3. Import highlighter.reg into registry
4. Start VS
5. Verify plugin listed using menu Resharper/Plugins...

EXAMPLES
Check Netix.Resharper.Test solution for some examples. Ensure you turned
"Verify naming style" on.

SOURCE CODE
Source code is included, but I admit that I lost my way with IDeclaredElement
and IDeclaration hierarchies, so NetixCodeAnalyzer is complete mess of both.
I will try to clean this up in the next version.

Comments are welcome.

Sincerely,
Ilya Ryzhenkov


26 comments
Comment actions Permalink

Hello Ilya,

just curious, but how do you determine whether a type owns its field, or
the field is owned by someone else?


Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

--- Types that own disposable fields should be disposable. Planned
quick
fix to add IDisposable on the class and implement it.



0
Comment actions Permalink

Hello Dmitry,

It doesn't check the real ownership currently, it just checks existing fields
:) Later I plan to check initializations and assignment of fields, and if
such fields are initialized (or assigned) with "new object" expression -
I will consider it should be disposed. Otherwise, I will consider them as
pass-through. May be you have better ideas?

DS> Hello Ilya,
DS>
DS> just curious, but how do you determine whether a type owns its
DS> field, or the field is owned by someone else?
DS>
DS> Regards,
DS> Dmitry Shaporenkov
DS> JetBrains, Inc
DS> http://www.jetbrains.com
DS> "Develop with pleasure!"
>> --- Types that own disposable fields should be disposable. Planned
>> quick
>> fix to add IDisposable on the class and implement it.
Sincerely,
Ilya Ryzhenkov


0
Comment actions Permalink

Hello Ilya,

that makes sense, though I encountered code like the following which will
be treated
as erroneous:

public class BigObject : IDisposable, IBigAndUsefulObject {}

public class BigObjectConstructor
{
private BigObject myBigObject;

public BigObjectConstructor (ExternalObject o) { myBigObject = new BigObject
(); }

public void Construct () { // fill the myBigObject; }

public IBigAndUsefulObject BigObject { return myBigObject; }
}

BigObjectConstructor constr = new BigObjectConstructor ("Very big text file");
IBigAndUsefulObject bigObject = constr.BigObject;
// use big and useful object;
IDisposable disp = bigObject as IDisposable;
if (disp != null) disp.Dispose ();

Not sure this is a good design pattern though.

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Dmitry,

It doesn't check the real ownership currently, it just checks existing
fields :) Later I plan to check initializations and assignment of
fields, and if such fields are initialized (or assigned) with "new
object" expression - I will consider it should be disposed. Otherwise,
I will consider them as pass-through. May be you have better ideas?

DS>> Hello Ilya,
DS>>
DS>> just curious, but how do you determine whether a type owns its
DS>> field, or the field is owned by someone else?
DS>>
DS>> Regards,
DS>> Dmitry Shaporenkov
DS>> JetBrains, Inc
DS>> http://www.jetbrains.com
DS>> "Develop with pleasure!"
>>> --- Types that own disposable fields should be disposable. Planned
>>> quick
>>> fix to add IDisposable on the class and implement it.

Sincerely,
Ilya Ryzhenkov



0
Comment actions Permalink

Dmitry,

The difference between warning and error is obvious.
The difference between warning and suggestion is the fact, that warning definitly can be fixed. I've never encountered warnings issued by Resharper that are false positive.

Suggestion may improve the code, but may be totally wrong, i.e. there could be false positives. However, in most cases (say, 80%) it suggests correct improvement of code, API, prevents logical errors (like leaving IDisposable objects for GC), etc. To deal with the rest 20%, I'm going to invent some sort of "exclude" marks. So that "suggestion" target can be marked to ignore specific rule. Not sure how it will look like yet, there are few possibilities actually. Most obvious - use some sort of comment, probably xml-formatted. Like:

Field myStream is disposed elsewhere
class GeneratesDisposableWarning {...}]]>


This method has very important advantages:

  • it is source-controlled with the target

  • it is human-readable

  • it is bound to source during refactorings, like moving, extracting, etc.

It has disadvantages of course:

  • it pollutes the code

  • it may be hard or even impossible to insert such comments in correct places so that it doesn't break formatting (and is not broken by auto-format) and still target of it can be recognized


We can also add QF for all suggestions, titled "Ignore this suggestion", which will auto-add required comment. I'm going to start with this method and see how it works.

Other possibilities include maintaining separate file with exclusions that have links to target, ignoring the issue altogether, switching on/off suggestions on a per file basis.

Does this make sense?

0
Comment actions Permalink

Hello Ilya,

I just downloaded it and tried to compile under VS2005 (we're no longer using
VS2003 for our projects). So far, I've found only a single compilation issue:
for me IOverridableMember.GetImmediateSuperMembers method returns generic
IList, not its untyped counterpart.

I will try this plugin and let you know about my experience with this as
soon as I get one =)

I've also got a question to the developers from JetBrains: do you use the
same codebase while compiling under both VS2003 and VS2005. If yes, how could
it happen that the same method has different signatures under VS2003 and
VS2005?

Best regards,
Maxim



0
Comment actions Permalink

Hello Maxim,

we're developing under VS 2005 and using generics (for instance, in
that very IOverridableMember.GetImmediateSuperMembers method). However,
the same code is preprocessed by a homegrown tool that replaces generics with
untyped constructs and then compiled under VS 2003. That's where different
signatures come from.

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Ilya,

I just downloaded it and tried to compile under VS2005 (we're no
longer using VS2003 for our projects). So far, I've found only a
single compilation issue: for me
IOverridableMember.GetImmediateSuperMembers method returns generic
IList, not its untyped counterpart.

I will try this plugin and let you know about my experience with this
as soon as I get one =)

I've also got a question to the developers from JetBrains: do you use
the same codebase while compiling under both VS2003 and VS2005. If
yes, how could it happen that the same method has different signatures
under VS2003 and VS2005?

Best regards,
Maxim



0
Comment actions Permalink

Hello Dmitry,

we're developing under VS 2005 and using generics (for instance, in
that very IOverridableMember.GetImmediateSuperMembers method).

Aha... I see. The problem here is that the plugin delevolpers do not have
such tool so they are either forced to maintain two versions of plugin code
(terrible!) or focus on some particular IDE.

Best regards,
Maxim



0
Comment actions Permalink

Hello Maxim,

yes, we realize this problem and I will think of a solution to it.


Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Dmitry,

>> we're developing under VS 2005 and using generics (for instance, in
>> that very IOverridableMember.GetImmediateSuperMembers method).
>>

Aha... I see. The problem here is that the plugin delevolpers do not
have such tool so they are either forced to maintain two versions of
plugin code (terrible!) or focus on some particular IDE.

Best regards,
Maxim



0
Comment actions Permalink

OK, that was too selfish :) I meant 'we will think'.


yes, we realize this problem and I will think of a solution to it.



0
Comment actions Permalink

Hello Dmitry,

OK, that was too selfish :) I meant 'we will think'.

Anyway, now everyone is aware who's be responsible for such solution :)

Best regards,
Maxim



0
Comment actions Permalink

Hello Maxim,

no, that was really a typo :) Seriously, I think we'll simply share the tool
that converts generics.


Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Dmitry,

>> OK, that was too selfish :) I meant 'we will think'.
>>

Anyway, now everyone is aware who's be responsible for such solution
:)

Best regards,
Maxim



0
Comment actions Permalink

Does it mean, that plugin developers are almost forced to use VS2005? Or will you also provide a tool to convert from 1.1 to 2.0? Also, how do I build plugin for VS2005 without having Resharper_for_2005 installed, where do I get assemblies? Can I install it without VS2005? May be it worth to deliver separate SDK package - assemblies for both versions, docs, samples, etc?

0
Comment actions Permalink

Hello Ilya,

I think that there will be two separate SDK packages.


Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

z> May be it worth to deliver separate SDK package - assemblies for both

versions, docs, samples, etc?



0
Comment actions Permalink

Why so? I don't see any reason to develop plugin for one version of VS.

0
Comment actions Permalink

Hello Ilya,

who says you should develop only for one version? You can develop for both
versions with the same
code base, referencing different versions of ReSharper SDK, although it's
somewhat inconvenient. The problem
arises when you want to develop under VS 2003 and also want you plugin to
work under VS 2003 and VS 2005,
as our tool doesn't perform such an 'upward' conversion.
Frankly speaking, I don't know what will be the solution but we'll be definitely
discussing it internally.


Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Why so? I don't see any reason to develop plugin for one version of
VS.



0
Comment actions Permalink

Does it mean, that plugin developers are almost forced to use VS2005?


They are forced to use VS2005 only if they want their plugins to work under
VS2005.

BTW, just curious to known the reasons why don't people switch to VS2005..

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Does it mean, that plugin developers are almost forced to use VS2005?
Or will you also provide a tool to convert from 1.1 to 2.0? Also, how
do I build plugin for VS2005 without having Resharper_for_2005
installed, where do I get assemblies? Can I install it without VS2005?
May be it worth to deliver separate SDK package - assemblies for both
versions, docs, samples, etc?



0
Comment actions Permalink

They don't need to as yet.
They don't need 2.0 features.
They don't want to buy 2005.
They don't have R# for 2005.

"Valentin Kipiatkov (JetBrains)" <valentin@jetbrains.com> wrote in message
news:3fdb29a6a09528c7e5a08cdf0692@news.intellij.net...
>> Does it mean, that plugin developers are almost forced to use VS2005?
>

They are forced to use VS2005 only if they want their plugins to work
under VS2005.

>

BTW, just curious to known the reasons why don't people switch to VS2005..

>

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>
>> Does it mean, that plugin developers are almost forced to use VS2005?
>> Or will you also provide a tool to convert from 1.1 to 2.0? Also, how
>> do I build plugin for VS2005 without having Resharper_for_2005
>> installed, where do I get assemblies? Can I install it without VS2005?
>> May be it worth to deliver separate SDK package - assemblies for both
>> versions, docs, samples, etc?
>>
>



0
Comment actions Permalink

Hello Valentin,

VK> BTW, just curious to known the reasons why don't people switch to
VK> VS2005..

Because they don't want to impose the burden of downloading .NET 2.0 runtime
on the users.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

This seems strange to me. Is .NET 1.1 already installed on all machines and
operating systems?

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Valentin,

VK>> BTW, just curious to known the reasons why don't people switch to
VK>> VS2005..
VK>>

Because they don't want to impose the burden of downloading .NET 2.0
runtime on the users.



0
Comment actions Permalink

Hello Dmitry,

No. But the number of machines on which .NET 1.1 is installed is currently
many times larger than that of machines which have 2.0.

This is particularly important if you already have a released application
which targets .NET 1.1.

DS> This seems strange to me. Is .NET 1.1 already installed on all
DS> machines and operating systems?
DS>
DS> Regards,
DS> Dmitry Shaporenkov
DS> JetBrains, Inc
DS> http://www.jetbrains.com
DS> "Develop with pleasure!"
>> Hello Valentin,
>>
VK>>> BTW, just curious to known the reasons why don't people switch to
VK>>> VS2005..
VK>>>
>> Because they don't want to impose the burden of downloading .NET 2.0
>> runtime on the users.
>>
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

I understand this, but it still seems to me that if the user has enough motivation
and resources to download an average application (ReSharper) of approx. 20
Mb size, downloading the necessary version of .NET runtime will not be a
big hindrance for him. And it is
also possible to include .NET redistributable package into the application
installer.

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Dmitry,

No. But the number of machines on which .NET 1.1 is installed is
currently many times larger than that of machines which have 2.0.

This is particularly important if you already have a released
application which targets .NET 1.1.

DS>> This seems strange to me. Is .NET 1.1 already installed on all
DS>> machines and operating systems?
DS>>
DS>> Regards,
DS>> Dmitry Shaporenkov
DS>> JetBrains, Inc
DS>> http://www.jetbrains.com
DS>> "Develop with pleasure!"
>>> Hello Valentin,
>>>
VK>>>> BTW, just curious to known the reasons why don't people switch to
VK>>>> VS2005..
VK>>>>
>>> Because they don't want to impose the burden of downloading .NET 2.0
>>> runtime on the users.
>>>


0
Comment actions Permalink

Hello Valentin,

VK> BTW, just curious to known the reasons why don't people switch to
VK> VS2005..
1.1 is mature - it has proven that business applications can be created with
1.1. We see real applications that work, and we trust 1.1. At least there
are known problems and solutions to these problems on the net.

2.0 is new - there are almost no business apps, it didn't have service pack,
it is unknown how apps developed in 2.0 will live after years. It is a risk.
If we face a problem with 2.0, we don't have resources to look for solution.
E.g. check this: http://blogs.gotdotnet.ru/personal/mihailik/PermaLink.aspx?guid=1c0ad1e7-df8d-455b-a26a-d24447ef36fb

Personally, I'd like to drop all those typed collections, all those temporary
delegates, temporary methods and use features of 2.0. But I can't now.

/Ilya


0
Comment actions Permalink

Add
- The client does not yet support 2.0
- Current applications need to be migrated (costs money)
- Extended tooling like XDE etc isn't available yet
- Developer system specs aren't good enough
- Process changes take time
- Manager: "I want to be sure it works"
- Testing current tools, applications and such on the new framework
takes time and costs money

And
- I want it now!

:)

Jesse


Amir Kolsky wrote:

They don't need to as yet.
They don't need 2.0 features.
They don't want to buy 2005.
They don't have R# for 2005.

"Valentin Kipiatkov (JetBrains)" <valentin@jetbrains.com> wrote in message
news:3fdb29a6a09528c7e5a08cdf0692@news.intellij.net...

>>> Does it mean, that plugin developers are almost forced to use VS2005?
>> They are forced to use VS2005 only if they want their plugins to work
>> under VS2005.
>>
>> BTW, just curious to known the reasons why don't people switch to VS2005..
>>
>> Valentin Kipiatkov
>> Chief Scientist, Vice President of Product Development
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>
>>> Does it mean, that plugin developers are almost forced to use VS2005?
>>> Or will you also provide a tool to convert from 1.1 to 2.0? Also, how
>>> do I build plugin for VS2005 without having Resharper_for_2005
>>> installed, where do I get assemblies? Can I install it without VS2005?
>>> May be it worth to deliver separate SDK package - assemblies for both
>>> versions, docs, samples, etc?
>>>
>>


0
Comment actions Permalink

That's hilarious :)

I remember that the C# compiler in 1.1 framework has much less exotic bugs,
and people live with them quite fine.
I guess that not everyone has already got to that level of enlightenment
with generics to get faced with this problem.

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

E.g. check this:
http://blogs.gotdotnet.ru/personal/mihailik/PermaLink.aspx?guid=1c0ad1
e7-df8d-455b-a26a-d24447ef36fb



0
Comment actions Permalink

Hello Dmitry,

This just shows that 2.0 is not yet tested quite well by community. I don't
mean that I would use such constructs.

DS> That's hilarious :)
DS>
DS> I remember that the C# compiler in 1.1 framework has much less
DS> exotic bugs,
DS> and people live with them quite fine.
DS> I guess that not everyone has already got to that level of
DS> enlightenment
DS> with generics to get faced with this problem.
DS> Regards,
DS> Dmitry Shaporenkov
DS> JetBrains, Inc
DS> http://www.jetbrains.com
DS> "Develop with pleasure!"
>> E.g. check this:
>> http://blogs.gotdotnet.ru/personal/mihailik/PermaLink.aspx?guid=1c0ad
>> 1 e7-df8d-455b-a26a-d24447ef36fb
>>
Sincerely,
Ilya Ryzhenkov


0

Please sign in to leave a comment.