|
You've got FxCop[^] for instance (see gotdotnet.com).
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
Hey I tried that, and I got so many errors in my code (cant remember what I was testing though), so I uninstalled it . Maybe a newer version is out, and maybe my code looks (is) better now. I'll give it a try again.
|
|
|
|
|
OK, so I got a @#$#load of errors again, though most of these "errors" are totally biased design "rules" (really only considerations).
EG all priority 1:
MemberNameKeywordCollision:
The member name 'Stop' conflicts in whole or part with reserved keyword 'Stop'. //yeah right, maybe with your code, but not with mine
EventHandlerNamesEndInEventHandler:
Rename 'BASSProgessHandler' to end in 'EventHandler'. //why make the name even longer, it wont effect the code.
EventFirstParameterIsNamedSender:
Change the first parameter of 'Progress' to an object type named 'sender'. // hell, i cast enough, why do i need to cast even more?
MemberOnlyShortAcronymsAreAllCaps:
Correct capitalization of member name 'get_ChannelEAXMix'. // again, who cares? EAX looks better to me than Eax (that looks more like some assembler function, maybe FXCop will complain about it too
ExceptionsRequireMultipleConstructors:
Add a constructor with a string parameter to custom exception 'BASSException'. Add a constructor with a string parameter and exception parameter to custom exception 'BASSException'. Add a protected constructor with a SerializationInfo object parameter and a StreamingContext object parameter to custom exception 'BASSException'. // again why? if you dont need it, why clutter your code with useless code?
TypeNameKeywordCollision:
The type name 'Error' conflicts in whole or part with reserved keyword 'Error'. // reserved????
MemberNamesDontUseUnderscores:
Remove the underscore from 'BASS_OK'. //if its not OK, why even make it legal to use?
ParameterNamesUseCamelCasing:
Instead of parameter name 'Length', use 'length'. // i cant help it if i hit my caps lock by mistake.
TypesDontExposePublicInstanceFields:
Make 'fWetDryMix' private or protected and provide a public property to access it. // Properties dont allways work when u need to "chain" a few, also the extra processing (repeated get/sets) makes it inefficient.
NamespaceNamesUsePascalCasing:
Instead of namespace 'nBASS', use 'NBASS'. //no, nBASS looks way cooler
and now for the 2 (yes only 2) usefull ones (priority 1):
AssembliesShouldBeStrongNamed:
Sign 'nBASS' with a strong name key. // not neccesary, but recommended.
MethodShouldKeepAliveIntPtrIfFinalized:
Add a GC.KeepAlive(this) to the method 'Void Stop()'. //i have no idea what they mean...does look like it could break my code though.
Any comments welcome
|
|
|
|
|
This looks somewhat funny and ironical, especially when you know that the MS framework assemblies don't have pass the exam with 0 error. That is, the .NET framework does not strictly follow the .NET design guidelines.
Looks like a FXCop filter feature is welcome, so we only get relevant problems.
I am pretty sure the FXCop forum on gotdotnet is full of rant already...
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
StephaneRodriguez wrote:
This looks somewhat funny and ironical, especially when you know that the MS framework assemblies don't have pass the exam with 0 error. That is, the .NET framework does not strictly follow the .NET design guidelines.
Strictly is weak work in this case, I tried mscorlib.dll. I had about 100x the "errors" I had in my assembly .
StephaneRodriguez wrote:
I am pretty sure the FXCop forum on gotdotnet is full of rant already...
Unfortunately my GPRS can only handle one webpage (is it so bad in other countries?), so i choose CodeProject
|
|
|
|
|
Cheers for the comments folks - i also found this to return loads of Priority 1 violations that i would not necessarily consider to be of that importance (if at all) but as you can toggle the rules on/off before you check the assemblies i'd rather have to many 'insignificant' things flagged than not enough.
There are plenty useful things flagged as well - i guess you could say it's thorough
Thanks
|
|
|
|
|
Martin D wrote:
There are plenty useful things flagged as well - i guess you could say it's thorough
Definately!
I just thought of an idea for a competition. Person that wins must make the most functional library passing all tests in FXCOP.
|
|
|
|
|
For sh*ts and giggles I ran FxCop on my wizard framework[^].
Results:
8 Priority 1 problems. Four of them are caused by the collection generator[^] that I used (and submitted a slight modification for ). Two are caused by a the upper-case constant that you got bit by. And the other two are pointing out that I should put a CLSCompliant attribute on it and demand permissions.
16 Priority 2 problems. 10 of them are from my private/protected members that fire events for me (basically calls On* with the EventArgs passed in). Another 5 from the collection generator
1 Priority 4 problem. Yet another one caused by the collection generator.
If I ignore all the collection generator problems that leaves me with 13 problems
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
WOW!
James T. Johnson wrote:
And the other two are pointing out that I should put a CLSCompliant attribute on it and demand permissions.
I just added CLS compliance to my lib . Just looking for more bugs before I update. Maybe add a "few" suggestions from FXCOP (or is that FXCop).
BTW, bit off topic. Why do u spell .net Server like that and have the .NET framework. I dl'd RC1 and was a bit suprised to see that on the boot logo screen. Especially, after being advised never to use .net, not ever.
|
|
|
|
|
leppie wrote:
Maybe add a "few" suggestions from FXCOP
I think I will too; plus make another change in the collection generator templates.
leppie wrote:
from FXCOP (or is that FXCop).
Neither, FxCop
leppie wrote:
Why do u spell .net Server like that and have the .NET framework.
Microsoft marketing never asked the rest of the company how to spell it
It's sad that they would let something like that happen since it lends even more inconsistancy to printed media when it's talked about.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
leppie wrote:
functional library passing all tests in FXCOP.
Look ma[^], no violations!
Time for me to really go to bed now, I mentioned in an e-mail I was going to bed an hour ago
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Nice Will have a look at a "perfect" library
BTW, I'm still waiting for the food, is that a bug?
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Most of what FxCop looks for are design issues to try to stay compliant with what MS has outlined. Most of this is done just to make it so that a 3rd party using your library will know how to name stuff they wish to use (handy when you lack an IDE with intellisense )
I wouldn't even bother replying if the comments generated weren't for your nBASS wrapper
leppie wrote:
also the extra processing (repeated get/sets) makes it inefficient.
The JITter is generally smart enough to inline small methods to make the call non-existant. I'm not sure what you mean by chaining properties though.
leppie wrote:
Add a constructor with a string parameter to custom exception 'BASSException'. Add a constructor with a string parameter and exception parameter to custom exception 'BASSException'. (cont'd)
These are for consistancy, but the framework uses the information provided by them to customize the exception dialogs.
leppie wrote:
Add a protected constructor with a SerializationInfo object parameter and a StreamingContext object parameter to custom exception 'BASSException'. // again why? if you dont need it, why clutter your code with useless code?
This might be needed; not by you or your code but by the framework. The 'might' depends on how remote debugging works, if it attempts to serialize exceptions to send to the debugger then this function won't work for your code.
The only other time it is used is for serialization of your exception object for use in remoting, but I can't see your library being used in that situation
leppie wrote:
The type name 'Error' conflicts in whole or part with reserved keyword 'Error'. // reserved????
Error is a reserved keyword in VB.NET
leppie wrote:
Sign 'nBASS' with a strong name key. // not neccesary
Yes neccesary! For an example, create an application that is strong named and add a reference to nBASS, now try to build the application. You'll get an error (which stops the build) saying that nBASS isn't signed.
leppie wrote:
Add a GC.KeepAlive(this) to the method 'Void Stop()'.
The GC.KeepAlive method will hold a reference to the object passed in, so that it doesn't get collected prematurely.
I don't know the context in which this report is generated but for example you would use this to keep a reference to a delegate when you pass it to a P/Invoke'd method. Unless you use methods/properties of the delegate after the unmanaged method is done using it, the GC may see that the delegate isn't referenced anymore so it could perform a collection...invalidating your delegate and possibly doing bad things in the unmanaged function.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Firstly, Thanx for your time James
James T. Johnson wrote:
The JITter is generally smart enough to inline small methods to make the call non-existant. I'm not sure what you mean by chaining properties though.
myobject.User.Name.Surname = "Smith";
where the last 3 are properties. Is this bad? I prefer to steer clear as (like this example) value types dont seem to work...
Altough this does work (making objects public):
myobject.user.name.surname = "Smith";
OK this is not real code, so I didnt test it, but I have seen that there IS a difference between the 2, even though the properties are only basic get/sets.
James T. Johnson wrote:
The only other time it is used is for serialization of your exception object for use in remoting, but I can't see your library being used in that situation
WOW! Remote sound objects Although a "media" server ....nah to complicated
James T. Johnson wrote:
The GC.KeepAlive method will hold a reference to the object passed in, so that it doesn't get collected prematurely.
Isnt that what the whole IDisposable issue is about? How can the GC collect a object that is in unmananged space?
James T. Johnson wrote:
Error is a reserved keyword in VB.NET
DOPE! I will change that for my VB.NET user (well I know of one).
James T. Johnson wrote:
Yes neccesary! For an example, create an application that is strong named and add a reference to nBASS, now try to build the application.
But why do I need to sign/strong name my application? I know it the "right" thing todo , but why? Speed? Security? Version tracking?
Thanx again
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
leppie wrote:
I prefer to steer clear as (like this example) value types dont seem to work...
The reason this doesn't work with value types is because you are making changes to copies of what the first two properties hold.
This is a hard problem to wrap your head around because what happens is that every time a get is called on a value type based property a copy of what is stored is returned. So when you chain them together you wind up with (using your example):
myobject.(get)User.(get)Name.(set)Surname
So you've made a change to a copy of the Name type which was a copy of the User type.
When you don't use properties you are accessing the values directly, so no copies are made at all.
leppie wrote:
Isnt that what the whole IDisposable issue is about?
No; IDisposable addresses managed code using unmanaged objects; the issue that I think is at hand is unmanaged code using managed objects (roles are switched).
When unmanaged code has a reference to a managed object the GC has no idea what happens to it; if additional references are made or if it doesn't even use it. That is why you use GC.KeepAlive, so that even if your code doesn't maintain a reference to the object, the GC will.
Note that I haven't looked at the code in question so I'm not sure why you had that issue reported; I just assumed the common case
leppie wrote:
But why do I need to sign/strong name my application?
Mainly security.
Its not a strong form of security; it only ensures that the assembly hasn't been modified since it was signed. But if you know the Public Key token of the person who signed the assembly you can use that as a means of verifying that it was signed by the same person; assuming the private/public key pair hasn't been stolen.
If you browse to %WINDOWSDIR%\assembly on your computer you should see the contents of the global assembly cache; which thanks to the Fusion shell extension also displays among other things the public key token. You can also see that most of the assemblies from Microsoft have the same public key token.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Thanx
James T. Johnson wrote:
Its not a strong form of security; it only ensures that the assembly hasn't been modified since it was signed.
I know what u mean now . It happened a few months back, when i used an unsigned compiled assembly (no source available, well not to the project). It threw an exception and showed me the code of the assembly, without realising it , I modified the assembly to correct the problem. And I was total amazed to seen my changes was reflected, even though I never opened a source file from the assembly and recompiled it. I was very nice in this case, but I can see the security problem, especially in my case.
|
|
|
|
|
How can I display popup menu when I click on a items of list view?
When I overriden Click event of list view,it occures for both right click and left click.How can I manage it only for right click?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
You have two options :
The first is done by using the VS.NET Toolbox window and produces code like this :
this.ContextMenu = new System.Windows.Forms.ContextMenu();
Other, in your listview click handler :
if (this.MouseButtons==MouseButtons.Right)
System.Windows.Forms.ContextMenu.Show (this, this.MousePosition);
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
Thanks.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Aloha everyone...I have a question:
How can I implement auto-updating to my app? I have created a simple TCP/IP application and I would like the client to be able to get the newest version from the server and overwrite itself with the new version.
Obviously this will create problems with trying to overwrite a file in use, so how do you do it?
- Does .NET provide built in "shadow copying"? (I know ASP.NET does)
- Does Windows provide a service to auto-copy a file once an application closes?
- Is there some black-book trick I am unaware of???
Any help would be really appreciated!
|
|
|
|
|
BITS
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
|
|
Thanks, but I'm not sure this does what I need. I have no problem getting the file to the client machine. I have written a simple TCP/IP system to download any size file from the server to the client.
The problem I am trying to figure out is how am I going to replace my application .EXE while it is running? Or rather, how do I smoothly exit the program, get the copy done and re-load (without user interaction).
I only ask because I see other programs doing this and it is very nice
|
|
|
|
|