Attributes in Configuration file
Some attributes are allowed to be specified in configuration files to save editing the source code.
Any ‘attribute’ definition can now be assigned ‘error_if_unused’ XML attribute so the porter will produce an error message if the attribute is unused when porting a project, as follows:
<attribute error_if_unused="true" name="CppConstMethod" class="PorterAttributes.UnusedConfigAttributes" method="System.Void Foo()"/>
The below lists the attributes that are available from configuration files.
CppSkipEntity
porter.config
<attribute name="CppSkipEntity" interface="System.Collections.Generic.IEnumerable" method="System.Collections.IEnumerator GetEnumerator()"/>
<attribute name="CppSkipEntity" set="public System.Void someProperty(System.Int32)"/>
<attribute name="CppSkipEntity" get="public System.Int32 someProperty()"/>
In this section all things - interfaces, classes and so on, set by name with selected method, will be ignored while converting. Get and set methods of properties also included. Method should be in full form: access modification - public, protected, private or default. Default assumed that there is nothing to write. Next static modification, if such present, full return type, name of method, parameters type in full form (System.Int32, System.String, System.Void and so on), if method takes something, and constant modification if such present. Please note, if method(s) of property should be skipped, value of set/get should contain property name of such method.
CppConstMethod
porter.config
<attribute name="CppSkipEntity" interface="System.Collections.Generic.IEnumerator" get="System.Object Current()"/> <!-- mandatory for success compile on C+\+ side, see explanation of this attribute on this page -->
<attribute name="CppConstMethod" interface="System.Collections.Generic.IEnumerator" get="System.Int32 Current()"/>
<attribute name="CppConstMethod" interface="System.Collections.Generic.IEnumerator" get="System.String Current()"/>
<attribute name="CppConstMethod" interface="System.Collections.Generic.IComparer" method="System.Int32 Compare(System.Int32, System.Int32)"/>
<attribute name="CppConstMethod" interface="System.Collections.Generic.IComparer" method="System.Int32 Compare(System.String, System.String)"/>
<!-- or -->
<attribute name="CppConstMethod" interface="System.Collections.Generic.IEnumerator" get="0 Current()"/>
<attribute name="CppConstMethod" interface="System.Collections.Generic.IComparer" method="System.Int32 Compare(0, 0)"/>
In this section all things - interfaces, classes and so on, set by name with selected method, will be with const modification after converting process end. Get and set methods of properties also included. Method should be in full form: access modification - public, protected, private or default. Default assumed that there is nothing to write. Next static modification, if such present, full return type, name of method, parameters type in full form (System.Int32, System.String, System.Void and so on), if method takes something, and constant modification if such present.
For template argument of things located in .NET Framework it also can be set 0 as first type argument record. Template argument of own things “support” only on basic class - that menace you do not get code with const in children method.
Please note, if method(s) of property should be skipped, value of set/get should contain property name of such method.
CppPortConstStringAsWChar
Force to transformate const string as const wchar_t* on C++ side Sample using
porter.config
<attribute name="CppPortConstStringAsWChar" field="SampleCsProject.Attributes.PortConstStringAsWCharTest.WCharValueByConfig" condition="field"/>
CppRenameEntity
Allow to rename delegates from porter.config Sample using
porter.config
<attribute name="CppRenameEntity" parameter="Func1" namespace="SampleCsProject.Attributes.UsingViaConfig" delegate="public TResult Func<out TResult>()" condition="delegate"/>
<attribute name="CppRenameEntity" parameter="Func2" namespace="SampleCsProject.Attributes.UsingViaConfig" delegate="public TResult Func<in T, out TResult>(T arg)" condition="delegate"/>
<attribute name="CppRenameEntity" parameter="Func3" namespace="SampleCsProject.Attributes.UsingViaConfig" delegate="public TResult Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2)" condition="delegate"/>
Please note, that version that available from porter.config allow rename only delegates. At least implemented and tested only for such purpose. Use same named attribute in C# code for rename other supported things.