How can I create class in specific folder (namespace) in my project, and see the classes grouped by there namespace?
1) Create a class in the appropriate folder with the option Add new Item.
2) Drop the class in to the class diagram.
http://social.msdn.microsoft.com/Forums/en-US/vsclassdesigner/thread/bebfa1a4-1930-4a56-b0fc-e15a238650ac/
When using Visual Studio Ultimate you can choose "Architecture" from the menu and generate a namespace diagram.
Once the diagram has rendered, you can expand the namespaces and other elements to show the classes they contain.
Note, specific folder != namespace. New files in given folders are defaulted to the namespace, but from experience, try not to rely on it when working in a team or with someone elses' code. ;-)
Related
I'm getting start with DSL, I have build my DSL and I have a T4 template for generate code from a design.
I can create a new element in my project of my DSL type, I can create my design and then I have to run my T4 to generate code.
But, I can see how to work the default Visual Studio Class Diagram, it don't need to run any T4. For example when you drop a class in the diagram it shows a dialog to choose the class name and file.
When I change a class (adding properties for example) by edit the file the diagram update itself the new information (properties, methods, ...). When you add a property in a class using the diagram its update the file adding the correct property ...
How to do it? I'm newbie and I would like to find documentation about it.
After converting a Web Site Project to a Web Application Project in Visual Studio, it seems that there is a problem with some meta data. The first noticeable is the fact that the project is mentioned twice in the Class View window.
If I add a new namespace and a new class in it, I'm not able to select it using intellisense. when I open the hierarchy of the Class view, I see my new namespace in one of them (that are indentical except the recent addings)
Is there a way to clean that up ?
You have to get rid off the App Folder. That's the origin of this problem.
http://vishaljoshi.blogspot.be/2009/07/appcode-folder-doesnt-work-with-web.html
I created a project in Visual Studio 2010 but I mispelled the name well into development.
If I right click, and rename the project, it seems the changes aren't cascaded to folders and classes.
For example, if my project was named Foa and I added a class, the namespace would be:
namespace Foa
{
public class Bar
If I renamed the project to Foo, the class stays:
namespace Foa
{
public class bar
Is there a way to cascade that change?
Change the namespace in one spot and then Ctrl+. on it and choose the refactor option. This will change the namespace throughout.
Change the default namespace in the project properties, then use a refactor tool to change the namespaces. Resharper has a fix inconsistent namespaces tool that will do it but you can just use the visual studio refactor to do it manually.
My strategy was to keep the project's layout clean. Given that this is a datalayer project, and I'll have a class file for each concerned entity, I thought I would put the .dbml into its own directory. It turns out that locating your .dbml file within a subdirectory turns it into a lower level namespace of sorts.
This is a C# class library project.
Any hints where I could turn this functionality off, and get access to the LinqToSql dbml datacontext name without having to type the directory name to get access to the actual LinqToSql classes?
Turns out you need to find the properties of your DBML on the LinqToSql design canvas.
Right click -> Properties Find the Context Namespace.
Type in the namespace that you expect to have your DataContext classes available in.
Right below, find the Entity Namespace.
Do the same
Resharper Users: you have the option to view the properties of your DBML's subdirectory, and set the namespace attribute there.
If you go to the directory in your solution and view the properties of that directory you will see the attribute: Namespace provider = true
Set this to false
You can then go update the namespace to match the root namespace in your DBML file. Now whenever you add new dbml files in there, it will keep the namespace based on the root folder.
I have a code snippet that creates a C# class for me. It puts the regions in all the right places and sets it up just the way I like it.
When I create a class by adding a new item it automatically creates the namespace based on my project and folder structure.
Is there a way I could do the same action with my custom snippet?
Is there a way I can change the default class to look like the class format I want?
This is possible now (2018), at least part of your's wishes, with adding this:
<Snippet>
...
<Imports>
<Import>
<Namespace>SomeNamespace</Namespace>
</Import>
<Import>
<Namespace>AnotherNamespace</Namespace>
</Import>
</Imports>
</Snippet>
For more info: https://github.com/dotnet/roslyn/issues/4457
I do not think that this is possible with VS Snippets, there are only a few available functions, and they are listed at MSDN. You could, though, create a new Item Template and use the parameter $rootnamespace$, which will be replaced with the root namespace of the current project. Item templates are a really useful part of Visual Studio, and MSDN has extensive documentation on it and Visual Studio Magazine had a nice walkthrough about them.