How to customize generated Source Code Using Altova Mapforce Project - altova

Background: When I generate the code for my mapping project, only one map will run, regardless of which file type I send in to the command.
I would like to modify the project code generation so that when the maps are generated the applicationConsole.cs allows multiple files and file types, and chooses the appropriate map based upon the parameters I send in.
so far, my project contains 4 maps, each one is different and has a parameter indicating whether or not to run the map. Once the code is generated, the applicationConsole.cs does not differentiate when running the maps. the first map listed in the applicationConsole.cs is run and the others are not. if the first map matches the given parameters, the output is correct, but if the next file coming in does not match, the console closes rather than moving on to the next map.
I am trying to avoid direct manipulation of the applicationConsole.cs, due to having to generate the code frequently.
the question: Does anyone know how to modify the output of Mapforce Project code generation to add a switch for map type based on file type?

In altova mapforce Application Install Directory,there is one SPL Directory. this is generate auto generate code as per your selected Language.
Take the backup of that Directory and modify SPL Directory code as per your requirement.
You need to learn SPL (Spy Programming Language) .
http://manual.altova.com/Mapforce/mapforce-enterprise/index.html?cgthewaytospl(spyprogrammingla.htm
If you need anything else then please inform me here. I have Good command on Customize the SPL.
Thank you

Take a look at refactoring under Java and C#
Really when you look at the stub code generated and you need to combine a couple maps the first refactoring task is to rename the namespace, Altova uses it's namespace as a default, so a mapa namespace would be helpful mapb namespace etc.
I'll provide the C# examples
http://msdn.microsoft.com/en-us/library/vstudio/6kxxabwd.aspx
Then you have the console app so you want to copy the applicationConsole.cs and rename it your project name or class name and then extract the method
http://msdn.microsoft.com/en-us/library/vstudio/0s21cwxk.aspx
Finally you would want to extract the interface so as to return the exception Constructor
http://msdn.microsoft.com/en-us/library/vstudio/fb3dyx26.aspx
and:
http://msdn.microsoft.com/en-us/library/tz6bzkbf.aspx
What you would have is a project with your start-up being the original applicationConsole.cs that you copied and renamed in a project or solution folder. When you update the map you should be able to over-write the code in that folder with what Mapforce generated.
This file was generated by MapForce 2013r2sp2.
YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
Refer to the MapForce Documentation for further details
This is what you will see in that file, use the technique outlined above and the tool is very easy to use. If you are a desktop programmer the refactoring might be new but it saves allot of time and effort down the road and makes the product complete.

Related

Method to make IncludeDirs available to external tool

I'm currently trying to make splint available as an external tool in Visual Studio 2010.
It has problems with finding all includes for the file, since it seems that the INCLUDE variable is only set at build time and I haven't found any other possibility to extract the include files in any way.
My question: Would there be any way to extract the IncludeDir field from the current file's project's Properties page, ideally with the VC++'s AdditionalIncludeDirectories?
Note also that AdditionalIncludeDirectories is per file, as it can be changed for individual source files as well as on the project level, and if it contains macros it can evaluate differently for each source file too!
I'm not familiar with driving the MSBuild objects via the API, but that's used by the IDE. Whether that way or by simply running MSBuild.exe, you need to get it to figure out all the properties, conditions, etc. and then tell you the result. If everything is well behaved, you could create a target that also uses the ClCompile item array and emits the %(AdditionalIncludeDirectories) metadata somehow such as writing it to a file or passing it to your other tool somehow. That's what's used to generate the /I parameters to CL, and you can get the same values.
If things are not well behaved in that necessary values are changed during the detailed build process, you would need to get the same prelims done just like the ClCompile target normally does, too. Or just override ClCompile with your own (last definition of a target is used) so it certainly is in the same context.
Either way, there are places where build script files can be automatically included into all projects, so you can add your stuff there or use a command argument (I think) to MSBuild to add another Include.
—John

How to specify AssemblyVersion in LLBLGen?

I'm using LLBL Gen Pro 3.5 command line (CLIRefresher and CLIGenerator) to create the solutions.
It automatically creates a AssemblyInfo.cs which contains this code:
AssemblyVersion("1.0")
I want to set it to another version while building the project. For example:
AssemblyVersion("2.1.0.234")
Question1: How can I tell LLBL to create the project with this version?
Question2: If it is not possible, how can I tell LLBL NOT to create this file, so I can add this file later using MSBuild?
A1: you can, through a custom template for assemblyinfo. It's bound in the file SD.TemplateBindings.SharedTemplates.templatebindings in the folder \Frameworks\LLBLGen Pro\Templates
You can define a new binding by creating a new templatebindings file, store it in the folder you define as 'AdditionalTemplates' folder in the project properties, and you should give that templatebindings folder a higher precedence than the one you're 'overriding' (or move it up in tab 2 on the code generator config dialog). See the SDK docs for details.
A2: It is possible, see A1. But here's the thing: this file is written once (done in the preset you're using to generate code). If the file exists the next time you generate code, it's left alone. This means that if you change it, e.g. by giving it a different version number, it won't be overwritten.
So while you could change the template easily, in this case it's not needed: you can do whatever you want with the file after it's been generated, it's not generated again.
(ps: please ask questions about LLBLGen Pro on our forums at http://www.llblgen.com/tinyforum, as we don't monitor stackoverflow that regularly. Thanks)

How to make IBM Rational Developer for Power IDE retrieve error list automatically?

I am currently working on a task to exploit the iProject Remote Build functionality of Rational Developer for Power (RDP) IDE for AS/400 related objects. I am developing a customized compilation utility, which is a generic tool to compile different source members, e.g. RPGLE, CLLE, PF. It is a command which accepts the source member, the source file, the source library and the target library as parameters. It is going to compile the specified source member and place the created object into the target library. Inside it the actual compilation is done using QCMDEXC API, with the compilation command set up as input parameter. It works fine on AS/400. Now I need to make it work on RDP directly with iProject Remote Build capability. Meanwhile any error generated should be automatically loaded to the Error List view after the compilation. I am aware the fact that Option(*EVENTF) must be included in order to generate the event file. But how to make RDP load it? The compilation utility is a command called CPLOBJ. Using source member A in file B in library C to create object A in library D is something like this: CPLOBJ SERMBR(C/B/A) LIBRARY(D).
See if this old article helps: http://www.itjungle.com/fhg/fhg080404-story01.html
Basically, the link between RDP and the compiler is through the event file. The compiler won't produce an event file unless you tell it to. Most compiler commands allow OPTION(*EVENTF) which is how you tell the compiler to create an event file. Your custom compile command needs the same parameter. It must also have a SRCMBR() parameter. So your custom compile command will need to look something like this:
COMPILE SRCMBR(nnnnn) OPTION(*EVENTF)
...and it will pass these values on to the IBM compile command.
Because you are using QCMDEXC to execute the IBM compile command (the one that actually generates the event file) you will need an additional step. You need to tell RDP that the compile completed and the event file is ready. This happens by placing the event file library and member name in the local data area. The library name goes in columns 1-10 and the member name in 11-20.
It might be best to ask this question on midrange.com. There are members of the Rational development team on the list as well as others that know the inner workings of RDP.
It has worked for me automatically, I have a feeling there is something not setup right or your missing a PTF somewhere.

Getting an IVsTextLines from file path

I've written a basic LanguageService extension for Visual Studio 2008 for my studio's proprietary scripting language. It works perfectly fine, and I've implemented a basic symbol table to keep track of script definitions and calls allowing for goto definition functionality.
The problem I've run into is that I only know how to parse the current active view, and I'd like to scan the entire solution's contents so that the user can goto the definition of a script defined in a file they have yet to open and have parsed. I've figured out how to generate a list of all files in the solution, but now I need to create a new Microsoft.VisualStudio.Package.Source which requires a Microsoft.VisualStudio.TextManager.Interop.IVsTextLines and I have no idea how to create a new one based off of the file I have.
Maybe I'm going about the problem the wrong way and someone can point me towards a better way to cause a file to be parsed by the LanguageService.
Regards,
Colin
Poking around I found that the reason Visual Studio needs a new Source is that it's keeping an internal list of them, and they're like the view into the text file held by the editor.
I came to the conclusion that files that are closed do not need IVsTextLines or to be entered into the VS internal list of Source files because I'm not doing any operations directly on them, all I care about in this case is to build a table of symbols and their corresponding TextSpan. So instead I created a new API for my parser that just took in a string and built my AST instead of grabbing the text from a ParseRequest, and only worried about specific types of symbols I needed to record. I then pushed this into a BackgroundWorker.
So I guess I was going about the problem in the wrong way. Although it does seem weird I can't just trigger a file to be opened into the Source list.
Interestingly I asked this question to Microsoft on their support forums and they advised me I had to purchase some service and support plan for them to answer my question.

Software To Help Me Reuse Code

I often find myself writing small (5-20 lines) files for things like input validation, reading a URL and so on. In fact, I probably write nearly the same files over and over because I either forget that I've already implemented such functionality in another project or I don't want to have to go searching for that file.
I want to know if there is a way to simply add code to a global repository from an IDE (in my case Visual Studio) and simply extract that code into whatever project I'm working on. It should be able to:
Extract code to a new file or to the currently open file in my IDE.
w.r.t. #1 I want smart defaults based on how I added the code to the repository.
Easy to use UI.
I don't need replacement/substitution of variables.
For instance, if I right click on a file I want to add to the repository then the default extraction operation is to create a new file. If, instead, I highlight some text in the currently open file and commit that, then the default is just to paste the snippet into the currently open file.
I've tried VS's snippet manager a few times, always with disappointment and quick abandonment. My biggest complaint is its interface and complexity required to add new code to it, plus the inability to extract the code to a file versus just inside whatever I have open.
You might want to check out ReSharper's Live Templates.
I don't use them to the extent that you're obviously looking for, but you can definitely create new file-based templates. I use that all the time when I create a new unit testing fixture class - just Add New Item -> From Template -> NUnit Test Fixture, where "NUnit Test Fixture" is one of my defined file templates.
Additionally, all the templates can be assigned a shortcut sequence, so you can auto-replace a given combination of text with a code snippet.
All the template configuration is file based, so you can save them to solutions or global workspaces as well.

Resources