Hi, I’m having a small issue with the instant generator when using using the association tool to link to classes together.
In the code generator it gives you the option to add a prefix to the attribute and parameter variable names when generating the code. However these prefixes are not applied to attributes created due to associations. Also it would be nice to have the option to capitilise the first letter of the variable name created from an association.
An example:
I have 2 classes, one called SecurityEngine and another called Account. I use the association tool to create a composition link between them (the SecurityEngine contains an Account instance). I run the Instant Generator to generate C# code but apply a “m_” as an attribute prefix (which is the convention in C#) but the code results in:
private Account account
instead of:
private Account m_Account
which is what I’m aiming for.
I’m also wondering whether VP can generate getters and setters for C# properties, so instead of:
public int GetAccess() {
return m_Access;
}
public int SetAccess(int access) {
m_Access = access;
}
it generates:
public int Access {
get {
return m_Access;
}
set {
m_Access = value;
}
}
Am I overlooking something? Is there a simple way to get this functionality?
Thanks for your bug report. We will fix the two issues, and come back to you as soon as possible. Concerning your suggestion:
Also it would be nice to have the option to capitilise the first letter of the variable name created from an association.
May I know the reason of this suggestion? Isn’t the convention use lowercase for the first letter? Besides, why not just enter the correct name in the role? Sorry to ask so many questions.
It is, but if applying a prefix to the attribute or parameter such as “m_” then the first letter of the actual attribute/parameter name will need to be capatilised to follow convention.
Example:
I have an attribute called account, the attribute prefix should result in m_Account instead of m_account.
As for entering in the name as the role, I was unaware you could do this however, the prefix still is not applied.
Ok, I have just been playing with the roles on the associations and spotted another anomaly.
In the role properties you can assign the attribute it references or create a new attribute for it to reference in the appropriate class, which is excellent. However, the role name is derived either from the name of the attribute it references or if that is left blank, then it uses the name of the class. But it still does not use the prefix information supplied in the Instant Generator options, so you end up with:
private Account m_Account
at the top of the generated code (above the constructors and methods)
AND
private Account account
at the bottom of the generated code ( below the constructors and methods)
My question is, should the role name even by generated into code? It seems to me that this is just descriptive and is not needed since you can link the association to a specific attribute in the role properties. This would also stop the code generator creating an attribute in the class at both ends of the association instead of just in the “Association End From”, which a composition association should do.
Replace $vp-suite-install-dir/lib/vpplatform.jar with the downloaded jar file
Run $vp-suite-install-dir/bin/VP Suite.exe to install the patch
Restart the application
Note:
If you are going to download with Internet Explorer, you may need to rename the file from .zip to .jar manually
Please do not run Product Update after applying the patch. Otherwise the update will replace the patch with the previous version (I will inform you to run the update when the next release is ready)
Please let me know if it works.
As for entering in the name as the role, I was unaware you could do this however, the prefix still is not applied.
I do not quite understand. Weren’t the two problems you reported earlier both related to code generated from roles? :?:
However, the patch is causing me issues. It will not generate the code any more, reporting the error in the Generator Output:
ResourceManager : unable to find resource ‘v.ipzr@c91629/generic.vm’ in any resource loader.
In regards to your question. Yes, they probably were related but at the time I wasn’t aware it was using the information from the roles properties. I only identified the problem from the output it gave.
Hopefully this error can be fixed as fast as the patch was released
Concerning your requests of having the getters and setters appear below all attribute declarations, we have updated the template to make it work for your request. Please find the template files attached. Please replace the templates inside ${vpsuite-install-dir}\resources\instantgenerator\csharp with those attached. After that, run the tool and run Instant Generator of C#. The code should be generated in the way you expected.
Please notice that when you perform product update, you have deselect to update the template files. Otherwise they will be replaced by the original files.
I have a small problem trying to download the files. From what I can tell the class.vm file is incomplete. I had a look inside and it seems to end abruptly, in the middle of a word. It’s odd though as Internet Explorer and Firefox end up with different, yet incomplete files.
We just released the new build of VP Suite. It is now safe to run the product updater (inside ${vp-suite-install-dir}/bin) to advance to the latest release. Please feel free to let me know if there are any questions.