vspacer
 
vspacer
 

The Visual C# IDE

 

ZDS Languages
ByDave Goodall

The Visual C# IDE has a version 1.0 feel to it. Dave's tour of the low lights..


Panes In the

Panes for code, output, forms, icons, open all over the place. Every time you open a new window everything moves around.

The result is a constantly shifting visual hash, with constant trips to the Solution Explorer window to get back the window you were just working with, that's been shuffled out of existence.


Where's the code?

For a .cs file [X.cs Design] shows up in the window selection bar with the visual representation of the form being used by the code as the default, NOT the real code.

It's no way obvious how to get the real code to show up!

You have to go to 'Solution Explorer', and click on the .cs module for a window with the real code to show up. (If you right click on the module in the 'Solution Explorer' window you get View Code | View Designer options)


'Features' you never asked for

When real code does show up it's infested with a (default) (unwanted) code outliner feature. It's not immediately obvious how to turn this off.

Seems to be controlled by

  #region Outliner Section Title
  #endregion

Use Edit | Outlining | Stop Outlining to abate this nuisance!


Contextual Help

blue_bulletUsing what?

Unbelievably, no auto-prompt support is provided for the 'using' keyword to provide tree-help lists of the available namespaces and the .NET classes and com objects therein.

The number of namespaces and classes is VAST.

Not providing auto search for this most basic keyword to find out what's available at the basic building block level is incomprehensible.

blue_bulletSyntax be dammed. What does this method/property actually do?

One of the most frustrating things, as you evolve an expression and mouse down a new list of methods and properties, is that the help provided is limited to a small pop up tip.

You can not expand this to get a detailed explanation of the property or method.

A complex object like Excel may have up to a thousand properties and methods. Figuring out what does which from this embarrassment of riches is daunting.

For example : we want to get the number of rows and columns.

  objWorksheet.Columns.Count;
  objWorksheet.Rows.Count;

do NOT return the number of rows and columns used as you would intuitively expect but the maximum possible numbers of rows and columns (65536-256).

  objWorksheet.UsedRange.Columns.Count;
  objWorksheet.UsedRange.Rows.Count;

are what is needed.

In both cases the tip information exposed when the mouse is over these properties is just the useless syntax:

  [Property] int Range.Count.

When what we really want to see is:

  'Maximum possible Column or Row count.
  Hint : see UsedRange for actual range count'

in the first case, and in the second :

  'Actual used Column or Row count
  Hint : see Columns.Count for maximum possible count'

blue_bulletExpression tooltip help

There's an insiduous gotcha here. Tooltip help is less helpful than it appears.

When using the IDE to specify object methods/properties, as the expression evolves the IDE displays a pulldown prompt from which to select the properties of successive objects e.g :

  wTable.
  wTable.Columns.
  wTable.Columns.ToString().
  wTable.Columns.ToString().Length;

This is all very nice, but it's easy to fall into the trap of thinking that you are being offered a complete list of choices!

Now NOTE! prompting is NOT provided for fundamental operators!

To retrieve the (string) value for a row-column table intersection

wTable.Rows[r].

results in a list that does not contain a 'Columns' member that you could then select with a

Columns[c].ToString.length

Instead

  wTable.Rows[r][c]                     will return the (implicit) string
  wTable.Rows[r][c].ToString().Length   will return the cell string length

Once more with feeling : IDE pull down lists do not contain prompts for permitted operators! That's supposed to be obvious.

Also note that because the datatype returned by the [] operator is implicit, it's on you to check the data type for the Column in the Column collection and be prepared to handle the returned type appropriately.


Forms Designer

This generates chunks of 'do-not-modify' 'Windows Forms Designer generated code' mixed in with the real code with a hopeful injunction to not use the code editor to modify it.

Logical enough for the Vbasic crowd perhaps, but from a 'c' perspective another attempt to force you into using the Microsoft way of specifying windows dialog logic by the finger painting method instead of directly.

You ARE going to want to modify the code generated by Forms Designer.

Because the guy who coded this was bone lazy, it has bad habits, and left to it's own devices it will pee in your code space.

*Instead of listing controls in top-to-bottom right-to-left order it just slops them in any old how.
*Instead of listing control attributes in a consistent order e.g :
  this.labLicense.Name       = "labLicense";
  this.labLicense.Location   = new System.Drawing.Point(132,64);
  this.labLicense.Size       = new System.Drawing.Size(153, 15);
  this.labLicense.TabIndex   = 2;
  this.labLicense.Text       = "Free for public distribution";
  etc
it just slops them in any old how.
*It does'nt provide any support for generating item names prefixed with your own set of standard menmonics e.g:
  Button                     btn...
  TextBox                    tbx...
  PictureBox                 pbx...
  Label                      lab...
  LinkLabel                  lnk...
Or for Menu items e.g : miFileConnect, miFileSep1
This makes it very difficult to review and understand the code.

You are STRONGLY advised to use Forms Designer only to select and drag to the form the appropriate type and quantity of controls and get them roughly in the right place.

Then go to a decent (external) editor and

*Organize the items top-top-bottom left-to-right.
*Organise the element attributes in a consistent order.
*Check you have used consistent type name prefixes.
*Check that the Tab Indices increment properly ( this is a snap once you've organized the information to flow t-b-l-r.

This makes a dramatic difference in the visibility of your code, So, if you want to check-in decent maintainable code for the next guy (who may be you), you can add cleaning up the poo left by Forms Designer to your task list.


The Code Editor

This is set by default to tab size 4 indent 4 in order to guarantee rendering problems with other people who may use your code but assuredly have their editors set to values different from yours.

To turn this annoyance off and revert to all spaces with manual indentation:

  select Options | Text Editor | All Langauges
  Indenting None
  Tab Size    (change default from 4 to 1)
  Indent Size (change default from 4 to 1)
  Insert spaces

The Tab and Indent sizes cannot be set to 0, the natural way to indicate they are not wanted.


Intelligent bracketing(Not)

After specifically indenting and using richie bracketing conventions

  foo() {
     // indent four
  }

Your nicely laid out code wll get reformatted back to

  foo()
       {
        //indent four
       }

To turn off the default follow the menu sequence:

Options
  Text Editor
    C# formatting
      Automatically format completed constructs and pasted source

You should also turn off '[ ] Collapse region blocks when files open' to keep stuff visible and stable


Surplus change reminders

If you edit a .cs file outside the IDE, the IDE is aware of it when you try and SAVE changes, not when you try to MAKE changes.

It then bugs you for ever on every subsequent save even for changes made in it's own code editor.


Set it? Forget it

'Settings' is conspicuously absent from the the C# IDE 'Project' menu, leaving one wondering how to turn off incremental compilation, apply optimization and other switch settings, and compile to a .dll instead of a .exe.

Presumably this oversight will be remedied in version 1.1


   

Back to top | ZDS Home | This article updated September 12, 2002.