fbpx
× Share your code snippets, screen shots etc. here

A couple of Visual Studio tips

More
1 year 4 months ago #1 by Nick Friend
A couple of Visual Studio tips was created by Nick Friend
Hi All,

This is pure coincidence, but I was thinking to post a couple of little tips I learnt recently with VS, then Phil posted suggesting doing exactly that.... and hey, it might even annoy Dick a little ;-)

If like me you're sometimes a bit lazy when creating code, you may put more than one entity into a single file (I particularly tend do this when creating enums). When your conscience kicks in and you want to separate out each entity, just right-click on the entity, Quick Actions and Refactoring, then Move type to xxxxxxx. VS automatically creates a separate file with just that code and named according to the entity (class, enum, etc).

Next one, I thought the visual scroll bar (showing a mini-view of your code file in place of the scroll bar, the old MetalScroll extension) had disappeared. But if you right-click on the scroll bar and go to Scroll Bar Options and select "map mode", it's still there and configurable.

Maybe everyone knows this already, but just in case...

Nick

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #2 by Phil Hepburn
Replied by Phil Hepburn on topic A couple of Visual Studio tips
Nice one (well two actually) Nick !

This was just the sort of thing I was thinking about. If we all try to post a short note here along with yours, as well come to something useful, then we will soon have a nice pile/set which will be geared towards .NET and X# application creation.

I will post a couple of things tomorrow, now that I feel that I have at least one listener/reader ;-0)

Thanks Nick,
and regards to all.
Phil.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #3 by Dick
Replied by Dick on topic A couple of Visual Studio tips
Hello Nick,

it might even annoy Dick a little


Well, I have to inform you that you failed in this B). Why would I it annoy me when I would finally read something which actually could be useful in VS?

First I am actually intrigued by your posting. I understand that it is considered good practice to make a separate .prg/.cs of every entity? In none of the many samples this is done, including a 100+ solutions from Microsoft with Universal Apps. It would have the advantage that it would more or less give me back the thing I miss most in VS compared to VO, which is being able to see which entity changed most recent. I would of course need to open a Explorer for that, and it's project wide then (instead of per mef as in VO) but VS would actually become a bit more of a "poor men's VO".

Next I have to inform you that I haven't been able to get this working. There is no Quick Action menu in X#. In C# there is and in VS 2015 that menu only contains Change signature (whatever that may be). But I have no C# projects yet on the Azure server where I have VS 2017 so I assume it works (only) there?

Please keep on posting these tips. As written in chit-chat, I am looking forward to the moment (if ever) that I find more positive option in VS than negative and posting tips like these could help.

Dick
Last edit: 1 year 4 months ago by Dick.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #4 by Robert van der Hulst
Replied by Robert van der Hulst on topic A couple of Visual Studio tips
Dick,

There are no quick actions yet. Fabrice wanted to add some of these, but I told him that there are some users that would like to see smartindent and case synchronization first.
We have added case synchronization in 1.02. Smartindent was also almost ready. I have personally disabled the smart indent in the release version of 1.02 because it was not working the way it works in XIDE and VO and I was sure you would not like it.

Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #5 by Nick Friend
Replied by Nick Friend on topic A couple of Visual Studio tips

Dick wrote: Hello Nick,
First I am actually intrigued by your posting. I understand that it is considered good practice to make a separate .prg/.cs of every entity?

Dick,

Definitely. Of course there are limits eg. every client-end data object class in my app has an associated mapping object, which is normally a one line instantiation of a generic class, so I stick that in with the relevant data class. But otherwise put each class, enum, etc. into a separate code file.

Then organisation in folders becomes your friend...



In the screenshot you can see....
Solution (CIO Vesta)
The solution is divided into 4 folders - Client, Common, Core and Server
Each of those contains one or more projects (eg. Server contains CIOServerBase, CIOServerDAL, CIOServerEF, etc.
Each project is divided into folders....
And so on.

This allows a very granular organisation. Perhaps the only disadvantage is that VS automatically creates namespaces according to the folder structure - so if I create a class in the Companies folder it will automatically be in the namespaces CIOServerEF.EFEntities.Companies which I may or may not want. Haven't found how to change that behaviour yet.

Nick
Attachments:
Last edit: 1 year 4 months ago by Nick Friend.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #6 by Robert van der Hulst
Replied by Robert van der Hulst on topic A couple of Visual Studio tips
Nick,

I think you and Dick are talking about different things. In VO an entity is a class declaration, a method, a property (access and/or assign) a function etc. I doubt that you will put each of these in a separate file. Your image shows that you work with the "one type = one file" principle and that is something different.

Dick, we are looking at adding an Entity browser window to the VS IDE. This would list all "entities" (methods, properties, functions procedures etc) from an Module in a single window. These are the same entities that are shown in the navigation bar in the editor. Selecting an entity from the list will open the source code editor at the right position.
Navigating to a different file in the Solution Explorer will refresh this list, just like navigating to a different module in VO will refresh the entity list. It will not be added to the next build but it is definitely on our "todo list".
We cannot limit the editor to a single entity like you can in VO. That wou require switching from a file based compiler to an entity based compiler and would require a repository of source code. We all know how long it took for the VO repository to become stable. We really do not want to go there.

Robert



Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.
Last edit: 1 year 4 months ago by Robert van der Hulst.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #7 by Dick
Replied by Dick on topic A couple of Visual Studio tips
Hello Nick

Thanks for your reply. I think just like Robert that you are not putting every single entity in a different file, right? In that case you would get 1000's of files. But indeed for smaller projects one tends to put it all in 1 file.

I have copied a C# project to out Azure server with VS 2017. As you see in the picture I still have only the options Change signature in that menu.

What am I missing?



Dick
Attachments:

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #8 by Dick
Replied by Dick on topic A couple of Visual Studio tips
Hello Robert,

Robert van der Hulst wrote: Nick,

Dick, we are looking at adding an Entity browser window to the VS IDE. This would list all "entities" (methods, properties, functions procedures etc) from an Module in a single window. These are the same entities that are shown in the navigation bar in the editor. Selecting an entity from the list will open the source code editor at the right position.
Navigating to a different file in the Solution Explorer will refresh this list, just like navigating to a different module in VO will refresh the entity list. It will not be added to the next build but it is definitely on our "todo list".

Robert


This would be a big improvement I think and yes, I realize that not much more can be done in VS. One of the main reasons of my VS dissatisfaction is that I rely heavily on the VO options to sort on last changed mefs/entities to see what I changed last. It saves me a lot of time, both in quickly finding were I was working on previously and on finding bugs: if someone reports a problem in this and that screen, the chance is high that the offending code is on the last changed entity or around. Doing the same in VS is so much more time consuming or simply impossible. Anything which (partly) mimics the VO behavior would help.


Dick

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #9 by Dick
Replied by Dick on topic A couple of Visual Studio tips
Hello Robert,

Robert van der Hulst wrote: Dick,

There are no quick actions yet. Fabrice wanted to add some of these, but I told him that there are some users that would like to see smartindent and case synchronization first.
We have added case synchronization in 1.02. Smartindent was also almost ready. I have personally disabled the smart indent in the release version of 1.02 because it was not working the way it works in XIDE and VO and I was sure you would not like it.

Robert


I appreciate your consideration regarding smartindent very much. Note that the absence of Quick actions is not a criticism; I was merely to indicate that I couldn't find Nick's option. Not in VS 2017/C# either by the way (see other posting).

Dick

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #10 by Nick Friend
Replied by Nick Friend on topic A couple of Visual Studio tips
Hi Dick,

You're accessing the little quick action menu via the light bulb... rather than that, just right-click for the normal popup menu and you should see something like this.



The option I was talking about in the first post is within the first menu option here - "Quick Actions and Refactorings".

Nick
Attachments:
Last edit: 1 year 4 months ago by Nick Friend.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #11 by Dick
Replied by Dick on topic A couple of Visual Studio tips
Hello Nick,

Yes, I see that right mouse menu, I see the light bulb + Quick Actions and Refactoring Ctrl+ on top of the menu, and when I click on that I get nothing else than the light bulb as in my picture.

But I think I know what causes it to work for you and not for me. In marketplace.visualstudio.com/items?itemN...Shilo.MoveTypeToFile I see that in order to have that option, you need to install an extensions, which you most likely did.

Although I probably have already separate files for each class I think it's a good idea to install that, in case I haven't.

Dick

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #12 by Nick Friend
Replied by Nick Friend on topic A couple of Visual Studio tips
No, I haven't installed any extensions....

It probably comes back to what Robert said - I'm talking about classes, structs, enums etc., not individual methods of classes.

Try doing this over the declaration of a class to see what options you get.

Nick

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #13 by Dick
Replied by Dick on topic A couple of Visual Studio tips

It probably comes back to what Robert said - I'm talking about classes, structs, enums etc., not individual methods of classes.

Try doing this over the declaration of a class to see what options you get.


That's it Nick! Below what I see then in VS 2015 and in VS 2017. For all future readers.



Dick
Attachments:
Last edit: 1 year 4 months ago by Dick.

Please Log in or Create an account to join the conversation.