T O P I C R E V I E W |
invino4 |
Posted - Apr 04 2009 : 04:39:58 AM My group and I have been writing a lot of asynchronous and event-based code lately and our coding patterns call for a lot of anonymous delegates. A very common problem people are having is quickly distinguishing in the code which pieces are going to execute immediately as part of the function and which are part of a delegate body that will be executed later. Plus, in an anonymous delegate body there can be tricky issues with doing variable capture so weG??d love to make the editor call out when this is occurring so the developer is sure to notice. I was wondering if Visual Assist could enhance its existing syntax coloring to include this as a feature? Perhaps an idea would be to darken the color of delegate body text background (by say 20%) while also coloring captured variables some configurable color (say defaults to yellow). For example:
It would be even better if this occurred recursively inside delegates so that delegates defined within delegates were color differently still so they were always distinguishable:
I know this would increase the readability of our code significantly!
- Jason. |
5 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - Apr 09 2009 : 1:08:22 PM I see why you want this, but I am really not sure about trying to change the background colour like this. I have asked internally to see what people think of this idea.
The screen shots show the problem, but what would be a good solution? |
invino4 |
Posted - Apr 08 2009 : 3:41:00 PM Hmm...tough questions. Some suggetsions:
1.) I realize the difficulty of the background issue in the current product. Perhaps this issue is resolved in Dev10 with the new display engine? 2.) Perhaps modifiers could specify a negative gradient (-10%) for those that use a dark background (e.g. Black)? 3.) I would think other sub-functional scopes (if, switch, etc) would all be modifiers rather than bases. I think it would be up to you guys how many you wanted to provide configuration for. I didn't think of if/switch since they happen so frequently I would find it distracting, but I agree, you never really know what people will want. I guess you'd have to pick a set to start with and see what people say?
Actually it just occurred to me that you could unify bases and modifiers by simply having a flat list of scopes and for each you can either pick a fixed color OR a gradient percentage. If you pick a color its that color, if you pick a gradient then it applies the gradient to the parent scope's background. That might make the configuration control dialogs easier to produce and give people a lot of display choice.
- Jason.
|
feline |
Posted - Apr 08 2009 : 11:28:28 AM Have you ever tried setting:
VA Options -> Advanced -> Display -> Highlight current line = * Foreground and background
You will notice that when VA does this you loose the foreground syntax highlighting. Basically this is happening since we are sneaking around behind the IDE's back, doing things it does not know about.
Also consider anyone who is not using White as the background colour in the editor. Black is a fairly common background colour, while others prefer off white as their background colour, I know I do.
This idea has a certain appeal, but I am not sure what to try and do.
After all, people are not going to want to stop just at the function, what about switch statements, if statements, etc. |
invino4 |
Posted - Apr 07 2009 : 8:00:30 PM (Yeah C#! => but the idea probably applies to any language.)
HaHa! Functions, did you say? Now that you mention it, coloring functions would be great too!
In fact this could quite easily be a general feature that is the inverse of the current syntax color coding. In today's syntax color coding you primarily set the foreground color for items based on the syntactic context. This would be setting their background color based on syntactic scope/locality.
E.g. Base Coloring: Namespace scope bg=light green Class body (decl, fields, etc.) bg=pale blue Function definition bg=white
Modifiers: (apply on top of the scope/locality color) inlined delegate bg=(10% darker) inline class bg=(10%darker)
With the base colors being very light pastel to start allows several step downs from modifiers that would easily distinguish cross of context and the modifiers can be applied repeatedly for nested scopes. If you want to make it configurable you can allow users to set the base colors and the steepness of the modifier gradient for each category.
Surely the editor already has this scope information since it is displayed in the VA toolbar?
|
feline |
Posted - Apr 07 2009 : 6:05:36 PM I am assuming this is C# code, is this correct?
If we try and do this then people are going to want functions picked out, inline functions, etc. It could quickly become quite "interesting".
Have you considered using a VA Snippet entry for a delegate that adds marker comments, so you end up with something like:
Action b = () =>
{ /*** DELEGATE START ***/
foo.SomeMetohd();
i++;
} /**** DELEGATE END ****/
I know it is not the same, but it might help. |
|
|