Documentation

    Table of Content
    • CodePorting.Native Product Family
      • CodePorting.Native Cs2Cpp
        • Getting Started
          • Product Overview
          • Installation
          • Licensing
          • How to use CodePorting.Native Cs2Cpp
            • How to Use Command line to port and build Projects
            • How to Use GUI to port and build Projects
        • Developer Guide
          • Porting Simple C# Projects
            • Porting Simple Console Application
            • Porting Simple Library
            • Porting Simple NUnit Test
          • Porting Dependent C# Projects
            • Porting Dependent Console Application
            • Porting Dependent Library
            • Porting Dependent NUnit Test
          • Porting Complex C# Projects
            • How to Convert Complex C# Console Application to C++
            • How to Convert Complex C# Library to C++
            • How to Convert Complex C# NUnit Test to C++
          • What Converts to What
            • Abstract Classes
            • Auto Properties
            • Break Statements
            • Class Constructors
            • Continue Statements
            • Delegates
            • Do While Statemetns
            • Enums TypeCast
            • Enums
            • Events
            • Exceptions
            • Expected Exceptions
            • Finalizers
            • For Statements
            • ForEach Statements
            • Generic Classes
            • Generic Delegates
            • Generic Interfaces
            • Generic Methods
            • Generic Structs
            • If Statements
            • Indexers
            • Lambda Expressions
            • Methods
            • Nested Classes
            • Properties
            • Return Statements
            • Simple Class
            • Simple Interface
            • Simple Struct
            • Simple Test
            • Standard TypeCast
            • Static Class
            • Static Constructor
            • Static-Methods
            • Static Properties
            • Switch Statements
            • Test with Setup Methods
            • Throw Statements
            • Try Catch Finally Statements
            • Try Catch Statements
            • Try Finally Statements
            • Var Expressions
            • Virtual Methods
            • While Statements
          • CodePorting Native Cs2Cpp Attributes
          • CodePorting Native Cs2Cpp Configuration File
            • CodePorting.Native Cs2Cpp Configuration File Structure
            • Attributes in Configuration file
            • Configuration file Nodes
            • Configuration file Options
          • Memory Management Model
            • Using aliasing constructor to create a smart pointer
          • Cmake Support
          • Limitations and Bugs
            • Porter Limitations and Bugs
            • Library Limitations and Bugs
            • Cpp Code Injection
        • Release Notes
          • 2020
            • CodePorting.Native Cs2Cpp 20.11
            • CodePorting.Native Cs2Cpp 20.12
            • CodePorting.Native Cs2Cpp 20.10
            • CodePorting.Native Cs2Cpp 20.9
            • CodePorting.Native Cs2Cpp 20.8
            • CodePorting.Native Cs2Cpp 20.7
            • CodePorting.Native Cs2Cpp 20.6
            • CodePorting.Native Cs2Cpp 20.5
            • CodePorting.Native Cs2Cpp 20.4
            • CodePorting.Native Cs2Cpp 20.3
            • CodePorting.Native Cs2Cpp 20.2
            • CodePorting.Native Cs2Cpp 20.1
          • 2021
            • CodePorting.Native Cs2Cpp 21.1
          • 2018
            • CodePorting.Native Cs2Cpp 18.9
            • CodePorting.Native Cs2Cpp 18.9.1
            • CodePorting.Native Cs2Cpp 18.10
            • CodePorting.Native Cs2Cpp 18.11
            • CodePorting.Native Cs2Cpp 18.12
          • 2019
            • CodePorting.Native Cs2Cpp 19.1
            • CodePorting.Native Cs2Cpp 19.2
            • CodePorting.Native Cs2Cpp 19.3
            • CodePorting.Native Cs2Cpp 19.4
            • CodePorting.Native Cs2Cpp 19.4.1
            • CodePorting.Native Cs2Cpp 19.5
            • CodePorting.Native Cs2Cpp 19.6
            • CodePorting.Native Cs2Cpp 19.7
            • CodePorting.Native Cs2Cpp 19.8
            • CodePorting.Native Cs2Cpp 19.9
            • CodePorting.Native Cs2Cpp 19.10
            • CodePorting.Native Cs2Cpp 19.11
            • CodePorting.Native Cs2Cpp 19.12

    What's on this Page

      • Attributes in Configuration file
        • CppSkipEntity
        • CppConstMethod
        • CppPortConstStringAsWChar
        • CppRenameEntity
    1. Home
    2. CodePorting.Native Product Family
    3. CodePorting.Native Cs2Cpp
    4. Developer Guide
    5. CodePorting Native Cs2Cpp Configuration File
    6. Attributes in Configuration file

    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"/>
    Please note, that all strings located after WCharValueByConfig by comma, will also be wchar_t*, as this attribute set on field, not on variable in field directly. Comparing to attribute directly in C# code, in this case response on variable name in config will be on person who created such.

    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&lt;out TResult&gt;()" condition="delegate"/>
    <attribute name="CppRenameEntity" parameter="Func2" namespace="SampleCsProject.Attributes.UsingViaConfig" delegate="public TResult Func&lt;in T, out TResult&gt;(T arg)" condition="delegate"/>
    <attribute name="CppRenameEntity" parameter="Func3" namespace="SampleCsProject.Attributes.UsingViaConfig" delegate="public TResult Func&lt;in T1, in T2, out TResult&gt;(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.