Code Analysis / nested classes / what to do
I discovered by accident that if I took the stuff I'd normally put in a module and nested it in a class (usually as shared) I really uncluttered the autocompletion lists. (I'm a great one for always typing system.windows.forms.... So seeing less and typing more is in for me!)
OTH Code Analysis complains loudly about nested public classes, presumably for a good reason.
My question is simple - is there a way of correctly using modules so that a module's members are not visible in the auto completion list until you enter the module name?
If mod mine has thingies A,B,C in it I don't want autocompletion to list A,B, & C until i have typed mine. at which point it would show A, B and C for completion.
Regards,
Al
The only way I can think this would work would be if you applied the EditorBrowsableStateAttribute() to the module.
| |
<EditorBrowsable(EditorBrowsableState.Advanced)>
|
This would hide the member in the completion list all together if 'Hide advanced members' in the options was selected.
| |
<EditorBrowsable(EditorBrowsableState.Never)>
|
This would always hide the member in the completion list.
However, as VB for some reason will not allow you apply class attributes to modules, you will need to change you modules to sealed classes with a private constructor (which is what a Module is underneath).
Since I'm a one man operation, I can get away with things, but I do need to put down foot prints. So I stumbled across the following solution. Just mark the individual components in the following fashion:
<System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Scope:="class", Justification:="I like nested classes for what they do to the autocompletion.")> _
...
The IDE will even do this for you with right click suppress on the on the CA1034 message. HOWEVER, for MS lurkers it does NOT put them in the right place. They need to be at the inner level not the outer level as the system placed them.
While i'm on the subject, i'm not at all sure that i'm doing what I'm supposed to be doing. That said, I have some data sets definitions(*.xsd) that give ca1034's in the auto gen'd code. They also give CA1003 and CA1010 and warnings CA1710. The CA1710 is simply because the emitted code doesn't end the event names in Args. This is something someone should fix in redmond. The other ones I don't comprehend at all.
Now for the point of adding it here. Redmond - pay attention. In all the above cases, when I select suppress, the IDE goes through the motions BUT does not mark anything. Nor does it put it in ModuleSuppressions.vb.
Note also, i was rather unhappy to discover that ModuleSuppressions.vb either emptied or disappeared or something in this multi assembly project when I temporarily turned off code analysis.
Regards,
Al