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.
Related
I am creating a Visual Studio extension and have added a custom configuration-specific property to an existing Microsoft Visual C++ (vcxproj) project using the IVsBuildPropertyStorage interface.
I would like to have that custom property show up in the Project Designer's property pages, as part of a new property page. There is some information on how to achieve that for a custom project type but the approach relies on reimplementing the project system which is not appropriate for all situations. Is there a way to extend the Project Designer for an existing project type?
One way to customise the Project Designer pages for a vcxproj is to include an additional property schema by adding the following:
<ImportGroup Label="PropertySheets" />
<ItemGroup>
<PropertyPageSchema Include="proppage.xml">
<Context>Project</Context>
</PropertyPageSchema>
</ItemGroup>
to a project which can be done by either copying this snippet into the project file directly or by putting it into a custom props file and including that into the project. Details on the structure of a property page schema are available here.
The main issue with this approach is that it requires manual intervention or an explicit step for setting up a project to use the custom property page, making it unsuitable for my use case.
It is also bit cumbersome as it requires shipping one-two additional files with the extension and it leaves a footprint in the project file. I would like to come across a more minimalistic solution that automatically applies to all MS VC++ projects but does not modify the project files unless the user inputs a property into the custom property page.
T4 text templates can be used to generate not only code but also any kind of text with visual studio.
I've read blogs and tutorials about T4 and as far as I can understand, visual studio dynamically builds a class in the background, compiles and runs the code in that class to build the text output.
Is it possible to see the source code of that class?
Yes, the easiest way is to change the Custom Tool in the properties window when the template file is selected in Solution Explorer.
By default, it will be 'TextTemplatingFileGenerator'.
If you change the custom tool to 'TextTemplatingFilePreprocessor' you'll get the underlying template class instead of the template output generated into your project.
To be precise, this code won't be exactly the same as that which is run under the covers, but it will be very close.
If you need the absolute exact code, you should leave the custom tool alone, but set the debug="true" flag on your <## template #> directive. This will then leave the generated code sitting around in a random named '.cs' or 'vb' file in your %TEMP% directory. Just sort the directory by time and it should be up at the top.
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. ;-)
I have "DOM like" data structure in c# (parent, childNodes, properties, enums...) and I want to use xml\xaml file to some of the initializing. I already wrote a tool that transform my xaml to c# and inject them in the right place.
I want the exact Intellisense behavior of WPF except that my classes doesn't inherits from WPF base classes and my project in not wpf application on library and doesn't reference wpf assemblies. i also don't want to use xsd schema because classes are added and edited very frequently.
I'm using visual studio 2010
Is it possible?
Create a xaml (start by creating a resource dictionary and delete the content).
Add your own assembly as the default namespace and start using your types. I have created a test for sample data recently, here's how it looks like:
<MainViewModel xmlns="clr-namespace:MvvmTest.ViewModels.DesignTime"
Name="The design time main view model">
<MainViewModel.SubViewModels>
<FirstSubViewModel Name="The design time first sub-view model" />
<SecondSubViewModel Name="The design time second sub-view model" />
</MainViewModel.SubViewModels>
</MainViewModel>
You can load the file using the XamlReader class. As a bonus compared to xml, the file will be compiled and run time loading will be much faster.
In a visual studio project I have three layers, Data Layer, Business Layer and Presentation Layer.
In the Data Layer I have a few XSLT's that transform some objects into an email, all works fine but I have discovered that the XSLTs do not get built/copied when building.
I have currently, created a folder in the deploy location and placed the XSLT's there but I am concerned about relying on a manual process to update these.
Has anyone encountered a similar issue and if so how did they get around it.
It smacks of changing the MSBuild script to copy the build artifacts to the required location, does anyone have examples of this?
Thaks
If you are using Visual Studio 2005/2008, the easiest way to do this is by including your XSLT files as project resources.
Open the Properties for your project.
Select the Resources tab. You will probably see a link that says "This project does not contain a default resources file. Click here to create one." Go ahead and click on that.
Click the Add Resource drop-down near the top and select Add Existing File.
Browse to your XSLT files and select them.
After you have done this, you can easily access the resources in the following manner:
// To get the contents of the resource as a string:
string xslt = global::MyNamespace.Properties.Resources.MyXsltFile;
// To get a Stream containing the resource:
Stream xsltStream = global::MyNamespace.Properties.Resources.ResourceManager.GetStream("MyXsltFile");
If you are using Visual Studio 2003, your best bet is to include those XSLT files as embedded resources for the DLL. In Visual Studio, select the file(s) in Solution Explorer, open the Properties pane, and change the Build Type to "Embedded Resource". You can then use the GetManifestResourceStream method to get a Stream containing the XSLT(s). The name to pass will be based on the default namespace of your assembly, the folder containing the file, and the name of the file.
For example, say your data layer assembly has a default namespace of My.DataLayer. Within your data layer project you have a folder named Templates which contains a file called Transform.xslt. The code to get your XSLT would look like this:
// There are numerous ways to get a reference to the Assembly ... this way works
// when called from a class that is in your data layer. Have a look also at the
// static methods available on the Assembly class.
System.Reflection.Assembly assembly = (GetType()).Assembly;
System.IO.Stream xsltStream = assembly.GetManifestResourceStream("My.DataLayer.Templates.Transform.xslt");
For more information check out this article on CodeProject.
Obvious question maybe, but still has to be asked, did you include the folder containing the XSLT's in the project itself? Is this a web or forms app?
In VS, it is easy to set the properties of the XSLT files in the project to copy on build, by default they do not.
I may have explained myself poorly.
THe Data layer is a class library that a the presentation layer references.
On building the DataLayer I can get the XSLTs to output to the Bin directory of the DataLayer. However when I build and publish the presentation layer, it correctly grabs the DLL but not the XSLTs