Documentation

    Table of Content
    • CodePorting.Translator Product Family
      • CodePorting.Translator Cs2Cpp
        • Getting Started
          • Product Overview
          • Installation
          • Licensing
          • How to use CodePorting.Translator Cs2Cpp
            • How to Use Command line to translate and build Projects
            • How to Use GUI to translate and build Projects
        • Developer Guide
          • Translating Simple C# Projects
            • Translating Simple Console Application
            • Translating Simple Library
            • Translating Simple NUnit Test
          • Translating Dependent C# Projects
            • Translating Dependent Console Application
            • Translating Dependent Library
            • Translating Dependent NUnit Test
          • Qt support
          • Translating 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
            • AbstractClasses
            • BreakStatements
            • ClassAutoProperties
            • ClassConstructors
            • ClassEvents
            • ClassFinalizers
            • ClassGenericMethods
            • ClassIndexers
            • ClassMethods
            • ClassProperties
            • ClassStaticConstructor
            • ClassStaticMethods
            • ClassStaticProperties
            • ClassVirtualMethods
            • ContinueStatements
            • Delegates
            • DoWhileStatements
            • Enums
            • EnumTypeCast
            • Exceptions
            • ExpectedException
            • ForeachStatements
            • ForeachStatementsStd
            • ForStatements
            • GenericClasses
            • GenericDelegates
            • GenericInterfaces
            • GenericStructs
            • IfStatements
            • LambdaExpressions
            • NestedClasses
            • ReturnStatements
            • SimpleClass
            • SimpleInterface
            • SimpleStruct
            • SimpleTest
            • StandardTypeCast
            • StaticClass
            • SwitchStatements
            • TestWithSetupMethods
            • ThrowStatements
            • TryCatchFinallyStatements
            • TryCatchStatements
            • TryFinallyStatements
            • VarExpressions
            • WhileStatements
          • CodePorting Translator Cs2Cpp Attributes
          • CodePorting Translator Cs2Cpp Configuration File
            • CodePorting.Translator Cs2Cpp Configuration File Structure
            • Attributes in Configuration file
            • Configuration file Nodes
            • Configuration file Options
          • Memory Management Model
            • Memory Management Model Description
            • Using aliasing constructor to create a smart pointer
          • Cmake Support
          • C++ code injection
          • C++ user-defined exception classes
          • Limitations and Bugs
            • Translator Limitations and Bugs
            • Library Limitations and Bugs
            • Cpp Code Injection
        • Release Notes
          • 2022
            • CodePorting.Translator Cs2Cpp 22.6
            • CodePorting.Native Cs2Cpp 22.5
            • CodePorting.Native Cs2Cpp 22.4
            • CodePorting.Native Cs2Cpp 22.3
            • CodePorting.Native Cs2Cpp 22.2
            • CodePorting.Native Cs2Cpp 22.1
          • 2021
            • CodePorting.Native Cs2Cpp 21.12
            • CodePorting.Native Cs2Cpp 21.11
            • CodePorting.Native Cs2Cpp 21.10.1
            • CodePorting.Native Cs2Cpp 21.10
            • CodePorting.Native Cs2Cpp 21.9
            • CodePorting.Native Cs2Cpp 21.8
            • CodePorting.Native Cs2Cpp 21.7
            • CodePorting.Native Cs2Cpp 21.6
            • CodePorting.Native Cs2Cpp 21.5
            • CodePorting.Native Cs2Cpp 21.4
            • CodePorting.Native Cs2Cpp 21.3
            • CodePorting.Native Cs2Cpp 21.2
            • CodePorting.Native Cs2Cpp 21.1
          • 2020
            • CodePorting.Native Cs2Cpp 20.12
            • CodePorting.Native Cs2Cpp 20.11
            • 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
          • 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
          • 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
    1. Home
    2. CodePorting.Translator Product Family
    3. CodePorting.Translator Cs2Cpp
    4. Developer Guide
    5. CodePorting Translator Cs2Cpp Configuration File
    6. Configuration file Options

    Configuration file Options

    What's on this Page

      • General workflow options
        • log_level
        • abort_on_error
        • write_progress
        • collect_porter_coverage_info
        • build_cs_projects
      • Output files control options
        • compare_cpp_hash
        • write_bom
        • write_include_map
        • tab
        • endl
        • start_block_newline
        • low_case_file_names
        • use_pragma_once
        • replace_wchar_with_hex_literal
        • obfuscate_cpp_headers
        • force_public_headers
      • Type subsystem options
        • forwarding_if_possible
        • force_include_enum
        • use_full_base_name
        • external_object_methods
        • cast_delegate
        • deprecate_system_base_type
        • exception_as_reference
        • ignore_base_for_static_class
        • replace_enumerable_type
        • force_dynamic_cast
        • remove_redundant_base_interfaces
        • enable_fast_rtti
        • force_static_cast
      • C# code analysis options
        • exclude_by_description
        • unexpected_override_as_warning
        • use_buildalyzer
      • C++ code generation parameters
        • detect_const_methods
        • emit_enumerator_current_value_holder
        • exclude_volatile
        • put_enum_on_top
        • reorder_class_by_inheritance
        • alternative_string_switch
        • alternative_null_coalescing
        • remove_unused_namespaces
        • indexer_as_method
        • create_unit_test_preprocessor_directive
        • generate_abstract_keyword
        • use_weak_ptr_std_bind
        • deferred_init
        • auto_ctor_self_reference
        • force_add_shared_api_macros
        • finally_statement_as_lambda
        • setter_wrap_with_lambda
        • allow_interface_members_base_class_impl
        • polymorphic_memberwiseclone
        • version_compatibility_check_mode
        • force_const_auto_property_getter
        • force_const_simple_property_getter
        • process_base_overloading
        • thread_static_generation
        • remove_inactive_code
        • emit_preprocessor_directives
        • emplace_assembly_details
        • add_baseclasses_tests
        • nunit_assert_class_aliases
        • original_tests_names
        • cpp_enum_enable_metadata
        • generate_enum_descriptions
        • hide_forward_declarations
        • attributes_into_reflection_info
        • allow_cast_to_non_generic_list
        • fix_setter_return_tag
        • remove_all_comments
        • explicit_destructors
        • rtti_on_testfixture
        • force_wrap_iostream
        • allow_using_directives_in_headers
        • extensions_as_method
        • generate_begin_end_methods
        • default_lambda_capture_mechanism
        • avoid_lambda_holders_if_possible
        • always_include_delegates
        • force_const_ref_parameters
        • force_const_ref_return_type_for_auto_properties
        • force_const_ref_return_type_simple_properties
        • force_enum_flags_attribute
        • alternative_debug_class
        • class_ptr_alias
      • Debug and developer version code options
        • collect_test_methods
        • generate_for_each_member
        • for_each_member_cycles_only
        • for_each_member_cleanup_before_each_test
        • stable_gv_file
        • test_run_stub_file
        • insert_leakage_detectors
        • tests_garbage_collection
        • tests_garbage_collection_generation
        • add_category_name_to_timeout_tests
        • for_each_member_short_names
        • enable_warnings_for_virtual_function_calls
      • Path resolving behavior
        • use_porter_home_directory_while_resolving_path
      • Project settings
        • cmake_targets
        • make_shared_lib
        • cpp_lib_path
        • cmake_temaplates or makefile_templates
        • generatedlist_template
        • include_templates
        • source_templates
        • add_assembly_details
        • additional_defines
        • exclude_conditional_symbols
        • additional_includes
        • custom_gtest_main
        • cpp_files_to
        • interface_as_public
        • internal_as_public
        • do_not_hardcode_aspose_cpp_path
        • tools_version
        • target_framework_version
        • make_library
        • generate_includes_subdirectory
        • make_cpp_file_name_uniq
        • headers_dir_name
        • sources_dir_name
      • Code readability
        • foreach_as_range_based_for_loop
        • simplify_using_statements
        • force_auto_in_variable_declaration
        • prefer_short_type_names
        • use_stream_based_io
        • generate_get_shared_members
        • generate_rtti_info
      • Code documentation
        • keep_documentation_comments
        • fix_self_closing_tags
        • try_expand_cref_types
        • hide_internal_declarations
        • hide_friend_declarations
        • remove_private_comments
      • Legacy options
      • Notes

    There is a number of options that can be used with translator config. The general syntax to add an option is as follows:

    <porter>
        <opt name="option_name_1" value="option_value_1"/>
        <opt name="option_name_2" value="option_value_2" attribute1="attribute1_value"/>
        <opt name="option_name_3">Some text</opt>
        ...
    </porter>

    The options can be split into several categories. This page presents full list of available options.

    General workflow options

    These options define general translator behavior: logging, errors handling, etc.

    log_level

    Defines cut level of logs being written by translator. Logs of specified level and more severe ones are emitted, the logs with lower severity are suppressed.

    Allowed valueMeaning
    debugDebug logs
    infoLogs that do not indicate errors
    warningLogs showing potential problem
    errorLogs indicating error condition

    Default value: debug

    abort_on_error

    States whether the translator should abort execution if any error is encountered. Normally, some errors are not fatal.

    Allowed valueMeaning
    trueAbort on error
    falseDo not abort on error

    Default value: false

    write_progress

    Whether to display line with completion percentage during the work.

    Allowed valueMeaning
    trueShow percentage
    falseDo not show percentage

    Default value: true

    collect_porter_coverage_info

    Enables the translator to collect information on usage of its own code. Only works for the Debug (developer) builds of the translator.

    Allowed valueMeaning
    trueGenerate coverage information (porter_coverage_report.xml and porter_coverage_report.zip)
    falseDo not generate coverage information

    Default value: false

    Since version: 22.3 (not available for publically released builds)

    build_cs_projects

    Makes the translator build the project prior to parsing the C# code.

    Allowed valueMeaning
    trueThe translator builds the project passed to it and then translates it.
    falseThe translator just translates the project passed to it without building it.

    Default value: false

    Since version: 22.3 (not available for publically released builds)

    Output files control options

    These options control how output files are generated.

    compare_cpp_hash

    Allows it to skip overwriting the translated cpp and h files if the hash of their contents already matches such of the translated code to be saved here. Useful if you’re frequently changing and translating C# code without cleaning the output directory and want to avoid recompiling all C++ files (overwriting the same contents updates file timestamp so that the build system will mark it as changed even if the contents is same).

    Allowed valueMeaning
    trueDo not overwrite files if hashes match
    falseOverwrite files unconditionally

    Default value: true

    write_bom

    Whether to add BOM record at the beginning of each output C++ file.

    Allowed valueMeaning
    trueAdd BOM
    falseDo not add BOM

    Default value: false

    write_include_map

    States whether to create include map file which then can be used to manage includes from the dependent project. If you plan to translate another project which depends on the current one, creating typemap is the safest way to share type information between them.

    Allowed valueMeaning
    trueCreate typemap
    falseDo not create typemap

    Default value: true

    Additional attributeMeaningAllowed valuesMandatoryDefault value
    public_onlyWhether to exclude non-public types from the maptrue - dump public types only; false = dump all filesNotrue
    with_dir_prefixWhether to use full (with directory prefix) includes or project-local onestrue - write full includes; false - write local includesNotrue

    tab

    Indent substitution. You can use ‘\n’ and ‘\t’ references there as well as other in-line characters.

    Allowed valueMeaning
    String valueExact string to define one level of indentation

    Default value: Four space characters

    endl

    Line end substitution. You can use ‘\n’, ‘\r’ and ‘\t’ references there.

    Allowed valueMeaning
    String valueExact string to define line break

    Default value: ‘\n’ aka line break

    start_block_newline

    Whether the opening curl bracket beholds on a dedicated line.

    Allowed valueMeaningExample
    trueOpening curl bracket resides on dedicated line
    if (++a == 10)
    {
        a = 0;
        ++b;
    }
    falseOpening curl bracket resides at the end of current line
    if (++a == 10) {
        a = 0;
        ++b;
    }

    Default value: true

    low_case_file_names

    Whether output file names are all lowercase. In this mode, word borders in Camel case class names become underscores.

    Allowed valueMeaningExample
    trueAll output file names are in lower case.‘MyNewClass’ class resides in header file called ‘my_new_class.h’
    falseAll output file names keep case of original type name.‘MyNewClass’ class resides in header file called ‘MyNewClass.h’

    Default value: false

    use_pragma_once

    Whether to use ‘#pragma once’ instead of scope ifndef.

    Allowed valueMeaningExample
    trueUse ‘pragma once’ instruction. 
    #pragma one
    
    #include <cstdint>
    
    namespace SampleProject {
    
    enum class Enum: uint8_t
    {
        item1,
        item2,
        item3
    };
    
    } // namespace SampleProject
    
    falseUse ‘ifdef guard’ construct
    #ifndef _SampleProject_enum_h_
    #define _SampleProject_enum_h_
    
    #include <cstdint>
    
    namespace SampleProject {
    
    enum class Enum: uint8_t
    {
        item1,
        item2,
        item3
    };
    
    } // namespace SampleProject
    
    #endif // _SampleCsProject_enum_h_
    

    Default value: true

    replace_wchar_with_hex_literal

    Whether to replace multibyte symbols in string literals with the hex literals.

    Allowed valueMeaningExample
    trueReplace multibyte symbols with hex literals. 
    System::String a = u"\u0430\u0431\u0432";
    falseKeep multibyte symbols as they are.
    System::String a = u"абв";

    Default value: false

    obfuscate_cpp_headers

    <opt name="obfuscate_cpp_headers" value="true" keep_field_names="false" />

    If enabled, makes translator generate ‘obfuscated’ headers put into obfuscated_include/ directory alongside with standard include/ one. ‘Obfuscated’ headers get some information on implementation details excluded. For example, types of pointers held by private class memebers are excluded.

    One still needs ‘usual’ headers from include/ directory to build the translated project itself. However, for external delivery the headers from obfuscated_include/ must be used. When building your package, make sure to put obfuscated_include/ directory content in place of usual include/ files.

    Allowed valueMeaningExample
    trueGenerate both obfuscated and non-obfuscated includes.
    falseGenerate non-obfuscated includes only.

    Default value: false

    Additional attributeMeaningAllowed valuesMandatoryDefault value
    keep_field_namesWhether to keep original fields name while generating obfuscated code.true, falseNofalse

    force_public_headers

    Enables integrity support for public header files.

    Allowed valueMeaningExample
    trueChecks that all header files included in public header files are in the ‘include /’ directory. If not, then transfers them into it.
    falseHeader files included in the public header files remain in the ‘source /’ directory.

    Default value: false

    Type subsystem options

    These options define how translator behaves regarding the translation of the types.

    forwarding_if_possible

    Use forward declarations in header files instead of includes if possible. This affects function parameters and return values declarations as well as pointers. This does not impact inheritance or value type field cases.

    Allowed valueMeaningExample
    trueUse forward declaration instead of include.
    namespace MyProject {
    class A;
    class B
    {
    public:
        System::SmartPtr<A> Value;
    };
    } // namespace MyProject
    
    falseUse include instead of forward declaration.
    #include "classes/A.h"
    namespace MyProject {
    class B
    {
    public:
        System::SmartPtr<A> Value;
    };
    } // namespace MyProject
    

    Default value: true

    force_include_enum

    Use includes instead of forward declarations in header files for enums. Changing the forwarding_if_possible option does not affect this behavior.

    Allowed valueMeaningExample
    trueUse include instead of forward declaration. 
    #include "enums/A.h"
    namespace MyProject {
    class B
    {
    public:
        System::SmartPtr<A> Value;
    };
    } // namespace MyProject
    
    falseUse forward declaration instead of include. 
    namespace MyProject {
    enum class A;
    class B
    {
    public:
        System::SmartPtr<A> Value;
    };
    } // namespace MyProject
    

    Default value: false

    use_full_base_name

    When referring base class, use the full class name (with all namespaces) instead of the short name.

    Allowed valueMeaningExample
    trueUse full base name.
    namespace MyProject {
    class A
    {
        ...
    };
    class B : public MyProject::A
    {
        ...
    };
    } // namespace MyProject
    
    falseUse compact base name.
    namespace MyProject {
    class A
    {
        ...
    };
    class B : public A
    {
        ...
    };
    } // namespace MyProject
    

    Default value: false

    external_object_methods

    Use static implementations of ‘ToString’, ‘GetType’, ‘GetHashCode’, ‘Equals’ methods and ‘is’ operator located in ObjectExt class instead of the ones provided by Object class itself. Try this option if you experience problems with these methods being called for primitive types or generic type parameters or alike.

    Allowed valueMeaningExample
    trueUse external object methods.
    template <typename T>
    class A
    {
    public:
        System::String ValueToString()
        {
            return System::ObjectExt::ToString(m_value);
        }
    private:
        T m_value;
    };
    falseUse in-object methods.
    template <typename T>
    class A
    {
    public:
        System::String ValueToString()
        {
            return m_value->ToString();
        }
    private:
        T m_value;
    };

    Default value: true

    cast_delegate

    When being a method parameter, cast delegate function to the actual type of expected parameter. Helps to resolve ambiguity in some cases (in C++, lambdas are not of corresponding MulticastDelegate type which can result in ambiguity if more than one signature exist).

    Allowed valueMeaningExample
    trueAdd cast expression.
    ApplyDelegate(static_cast<typename DelegateType>([](String s) { return s; });
    falseDo not add cast expression.
    ApplyDelegate([](String s) { return s; });

    Default value: true

    deprecate_system_base_type

    Whether to omit baseclass references for the classes from ‘System’ or ‘Microsoft’ namespaces. Use with care as it affects the whole project. If in doubt, consider using CppIgnoreBaseType attribute instead.

    Allowed valueMeaningExample
    trueDo not inherit from several base classes.
    class MyStream
    {
        ...
    };
    falseInherit from any base class.
    class MyStream : public System::IO::Stream
    {
        ...
    };

    Default value: false

    exception_as_reference

    Whether to pass exceptions to functions by reference rather than by creating a local copy of an exception object.

    Allowed valueMeaningExample
    truePass exceptions as references.
    class MyClass
    {
    public:
        void HandleException(Exception &e);
    };
    falsePass exceptions by value.
    class MyClass
    {
    public:
        void HandleException(Exception e);
    };

    Default value: false

    ignore_base_for_static_class

    Whether to omit ‘Object’ baseclass for the classes declared as static.

    static class MyClass
    {
        ...
    }
    Allowed valueMeaningExample
    trueDo not inherit static classes from Object.
    class MyClass
    {
        ...
    };
    falseInherit static classes from Object.
    class MyClass : public System::Object
    {
        ...
    };

    Default value: true

    replace_enumerable_type

    <opt name="replace_enumerable_type" enumerable="System.Xml.XmlNodeList" type="System.Xml.XmlNode"/>

    Adds a enumerable type that needs downcasting when in loop operations. Use this option to specify explicitly which type downcasts into what.

    Allowed valueMeaningExample
    Additional attributeMeaningAllowed valuesMandatoryDefault value
    enumerableOriginal typeEnumerable type full nameYes
    typeType to cast toTarget type full nameYes

    force_dynamic_cast

    <opt name="force_dynamic_cast" from_type="A.B.ClassA" to_type="A.B.ClassB" />

    For two given types, forces dynamic_cast to be used instead of default static_cast. Use if auto cast type deduction fails (e. g. due to diamond problem).

    Allowed valueMeaningExample
    Additional attributeMeaningAllowed valuesMandatoryDefault value
    from_typeSource typeFull type nameYes
    to_typeTarget typeFull type nameYes

    remove_redundant_base_interfaces

    If enabled, removes redundant inheritance from interface types, i. e. interfaces inherited more than once.

    namespace TypesPorting
    {
        public interface IFoo
        {
        }
        public abstract class AFoo : IFoo
        {
        }
        public class Foo : AFoo, IFoo
        {
        }
        public class Bar : Foo, IFoo
        {
        }
    }
    Allowed valueMeaningExample
    trueRemove redundant interfaces
    class IFoo : public System::Object
    {
        ...
    };
    class ABSTRACT AFoo : public IFoo
    {
        ...
    };
    class Foo : public AFoo
    {
        ...
    };
    class Bar : public Foo
    {
        ...
    };
    falseDo not remove redundant interfaces
    class IFoo : public System::Object
    {
        ...
    };
    class ABSTRACT AFoo : public IFoo
    {
        ...
    };
    class Foo : public AFoo, public IFoo
    {
        ...
    };
    class Bar : public Foo, public IFoo
    {
        ...
    };

    Default value: true

    enable_fast_rtti

    Enables translator generate code which makes casting faster with the price of bigger image size.

    Allowed valueMeaning
    truePerform fast (virtual functions-based) casting.
    falsePerform usual (dynamic_cast-based) casting.

    Default value: false

    Since version: 20.12

    force_static_cast

    Enables translator generate ForceStaticCast casts when translating any C-style cast instead of StaticCast or DynamicCast. The ForceStaticCast always works via simple static_cast, so this option can only use if you are sure that in translated code each dynamic_cast will succeed.

    Allowed valueMeaning
    truePerform all casts via dynamic_cast (through DynamicCast or StaticCast)
    falsePerform all casts via static_cast (through ForceStaticCast)

    Default value: false

    Since version: 22.6

    C# code analysis options

    These options impact how the original C# code gets analyzed

    exclude_by_description

    Allows it to exclude the entities from translating based on description comment. Individual description comment values can be provided as text inside ‘text’ subnodes.

    Example:

    <opt name="exclude_by_description">
        <text>This is for COM compatibility.</text>
        <text>For COM compatibility.</text>
    </opt>

    unexpected_override_as_warning

    Makes translator produce warning rather than en error if there is a method that overrides one in C++ but not in C#. They may trigger from e. g. the following code:

    class Base
    {
        public virtual void Foo() {}
    }
    class Child : Base
    {
        public new virtual void Foo() {} // Overrides in C++, but not in C#
    }
    Allowed valueMeaningExample
    trueProduce warnings if unexpected overrides occur.[Warning] System.String SampleCsProject.Derived.AnotherVirtual() (derived.cs:22): Method does not override one in C#, however, it will override System.String SampleCsProject.Base.AnotherVirtual() in C++. Consider renaming one branch via using CppRenameEntity attribute
    falseProduce errors if unexpected overrides occur.[Error] System.String SampleCsProject.Derived.AnotherVirtual() (derived.cs:22): Method does not override one in C#, however, it will override System.String SampleCsProject.Base.AnotherVirtual() in C++. Consider renaming one branch via using CppRenameEntity attribute

    Default value: false

    Since version: 20.12

    use_buildalyzer

    Makes translator use Buildalyzer library to pre-compile SDK-styled csproj files before translating.

    Allowed valueMeaning
    trueUse Buildalyzer library to pre-compile the project.
    falseUse MSBuild to pre-compile the project.

    Default value: false

    Since version: 21.3

    C++ code generation parameters

    These options define how translator uses specific C++ code features.

    detect_const_methods

    Whether to generate ‘const’ specifier on methods that do not modify their object. These can be either marked with CppConstMethod attribute or found const by translator check. Therefore, if this option is false, CppConstMethod attribute has no effect.

    class Foo
    {
        public void Bar() {}
    }
    Allowed valueMeaningExample
    trueMark methods as const
    class Foo
    {
        ...
        void Bar() const;
    };
    falseDo not mark methods as const
    class Foo
    {
        ...
        void Bar();
    };

    Default value: false

    emit_enumerator_current_value_holder

    public MyClass Current
    {
        get { return mInner.Current; }
    }
    Allowed valueMeaningExample
    trueEmit value holder. If you think that the use of the holder in a particular case is not justified, you can mark enumerator class with CppDisableEnumeratorCurrentValueHolder attribute to override global option behaviour locally and disable its generation.
    CODEPORTING_CURRENT_RETTYPE(System::SharedPtr<MyClass>) MyEnumerator::get_Current() const
    {
        System::HolderInitializer<System::SharedPtr<MyClass>> holder(m_CurrentHolder);
        
         return holder.HoldIfTemporary(mInner->get_Current());
    }
    falseDo not emit holder. In this mode you can catch С4172 compile error, or catch exceptions, SEH, or other types of UB at runtime, because the result of get_Current method is a local variable or other temporary object. If so, and you still want to keep this global option turned OFF, you can mark your enumerator class with CppEmitEnumeratorCurrentValueHolder attribute. This will override global option behaviour, so, holder will be emited.
    CODEPORTING_CURRENT_RETTYPE(System::SharedPtr<MyClass>) MyEnumerator::get_Current() const
    {
         return mInner->get_Current();
    }

    Default value: true

    Since version: 21.12

    exclude_volatile

    Whether to pass ‘volatile’ flag from C# to C++.

    class Foo
    {
        private volatile int m_bar;
    }
    Allowed valueMeaningExample
    trueMark members as volatile
    class Foo
    {
        ...
        volatile int m_bar;
    };
    falseDo not mark members as volatile
    class Foo
    {
        ...
        int m_bar;
    };

    Default value: false

    put_enum_on_top

    Whether enum declarations preceed class and struct ones in output header files.

    class A {}
    enum B { C, D };
    Allowed valueMeaningExample
    trueEnums are translated first
    enum class B { C, D };
    class A { ... };
    trueOrder is unchanged
    class A { ... };
    enum class B { C, D };

    Default value: false

    reorder_class_by_inheritance

    Reorder class if dependent type declared before dependee.

    class C : B {}
    class B : A {}
    class A {}
    Allowed valueMeaningExample
    trueDependees are translated first
    class A {}
    class B : A {}
    class C : B {}
    falseOrder is unchanged
    class C : B {}
    class B : A {}
    class A {}

    Default value: false

    alternative_string_switch

    Define whether to use if-else or do-while form of string switch translation.

    string s = "abc", s2;
    switch (s)
    {
    case "abc":
        s2 = "cba";
        break;
    case "123":
        s2 = "321";
        break;
    }
    Allowed valueMeaningExample
    trueUse do-while form.
    do {
        if (s == u"abc")
        {
            s2 = u"cba";
            break;
        }
        if (s == u"123")
        {
            s2 = u"321";
            break;
        }
    } while (false);
    falseUse if-else form.
    if (s == u"abc")
    {
        s2 = u"cba";
    }
    else if (s == u"123")
    {
        s2 = u"321";
    }

    Default value: false

    alternative_null_coalescing

    Use an alternative form of ‘??’ operator translation which avoids it calculating right hand operand unless it is used.

    Object obj = obj1 ?? new Object();
    Allowed valueMeaningExample
    trueUse alternative form.
    System::SharedPtr<System::Object> obj = System::ObjectExt::Coalesce(obj1, [&](){return System::MakeObject<System::Object>();});
    falseUse usual form.
    System::SharedPtr<System::Object> obj = obj1 != nullptr ? obj1 : System::MakeObject<System::Object>();

    Default value: false

    remove_unused_namespaces

    Remove unused ‘using namespace’ directives (the references to namespaces no classes from which ones are used). Such constructs can result in compilation errors: if the classes from the namespace are not used, it is possible that no includes introducing this namespace exist, so the name does not get recognized by the compiler.

    using System;
    using System.Collections.Generic;
    class MyClass
    {
        void Foo()
        {
            BitConverter.GetBytes(123);
        }
    }
    Allowed valueMeaningExample
    trueRemove unused namespaces
    #include "MyClass.h"
    
    using namespace System;
    
    void MyClass::Foo()
    {
        BitConverter::GetBytes(123);
    }
    falseKeep unused namespaces
    #include "MyClass.h"
    
    using namespace System;
    using namespace System::Collections::Generic;
    
    void MyClass::Foo()
    {
        BitConverter::GetBytes(123);
    }

    Default value: true

    indexer_as_method

    Defines whether to translate indexer invocation as method instead of operator [] even if the later form is possible.

    System.Collections.Generic.List<int> mylist = GetList();
    int i = mylist[0];
    Allowed valueMeaningExample
    trueTranslate indexers as methods
    System::Collections::Generic::ListPtr<int> mylist = GetList();
    int i = mylist->idx_get(0);
    falseTranslate indexers as operators
    System::Collections::Generic::ListPtr<int> mylist = GetList();
    int i = mylist[0];

    Default value: true

    create_unit_test_preprocessor_directive

    Whether to pass ‘#if UNIT_TEST’ directives from C# to C++.

    #if UNIT_TEST
    [NUnit.Framework.TestFixture]
    
    class MyTests { ... }
    #endif
    
    Allowed valueMeaningExample
    truePass ifdef macros to C++.
    #ifdef UNIT_TEST
    class MyTests : public System::Object, public ::testing::Test
    {
        ...
    };
    #endif
    falseSkip ifdef macros.
    class MyTests : public System::Object, public ::testing::Test
    {
        ...
    };

    Default value: false

    generate_abstract_keyword

    Whether to add an ‘abstract’ attribute to abstract classes. (Currently it is being inserted as ‘ABSTRACT’ define rather than as native C++11 keyword.)

    abstract class Abstract
    {
        ...
    }
    Allowed valueMeaningExample
    trueGenerate ABSTRACT labels.
    class ABSTRACT Abstract : public System::Object
    {
        ...
    }
    falseOmit ABSTRACT labels.
    class Abstract : public System::Object
    {
        ...
    }

    Default value: false

    use_weak_ptr_std_bind

    When generating std::bind() expressions for delegates translating, use WeakPtr instead of raw C++ pointers to pass object reference.

    delegate string ModifyString(string str);
    class WithDelegate
    {
        private string prefix = "prefix_";
        public string AddPrefix(string str)
        {
            return prefix + str;
        }
        public void Foo()
        {
            ModifyString myDelegate = AddPrefix;
        }
    }
    Allowed valueMeaningExample
    trueUse WeakPtrs instead of raw C++ pointers.
    ModifyString myDelegate = std::bind(&WithDelegate::AddPrefix, System::WeakPtr<WithDelegate>(this), std::placeholders::_1);
    falseUse raw C++ pointers.
    ModifyString myDelegate = std::bind(&WithDelegate::AddPrefix, this, std::placeholders::_1);

    Default value: false

    deferred_init

    If enabled, replaces all static fields with singletons and calls static constructors from instance constructors and singleton access functions instead of C++ static objects initializers. Use this option to resolve the static objects initialization races. Slows down static fields access and constructors as there are additional checks.

    Allowed valueMeaningExample
    NoneDisabledStatic constructors are translated as constructors of global static variables. Static class fields are translated as static class fields.
    AllEnabled for all classesStatic constructors are translated as static functions. Static class fields are translated as singletons. Constructors and singleton accessors call into static constructor to make sure it is finished before object creation or static variable access.
    TestsEnabled for test classes onlyStatic constructors of TestFixture classes are translated as static functions. TestFixture classes static fields are translated as singletons. Constructors and singleton accessors of TestFixture classes call into static constructor to make sure it is finished before object creation or static variable access.

    Static constructors of non-TestFixture classes are translated as constructors of global static variables. Static fields of non-TestFixture classes are translated as static class fields.

    Default value: None

    auto_ctor_self_reference

    If enabled, puts constructor self reference guards where required, allowing it for constructor to refer to ‘this’ without deleting the object. Saves the developer from putting CppCtroSelfReference attributes manually but creates more guards than actually required.

    class MyClass
    {
        public MyClass()
        {
            SomeOtherClass.DoSomething(this);
        }
    }
    Allowed valueMeaningExample
    truePlace guards that allow safe usage pf shared pointers to object being constructed
    MyClass::MyClass()
    {
        IncSelfReference();
        auto __local_self_ref = System::MakeScopeGuard([this]{ DecSelfReference(); });
        SomeOtherClass::DoSomething(System::MakeSharedPtr(this));
    }
    falseDo not place guards automatically. Make sure to use CppCtroSelfReference attributes manually, otherwise you will have a ‘deletion in constructor’ issue.
    MyClass::MyClass()
    {
        SomeOtherClass::DoSomething(System::MakeSharedPtr(this));
    }

    Default value: true

    force_add_shared_api_macros

    If enabled, forces production of shared_api_defs.h file and inserts corresponding macros into the translated code. This helps to switch between shared and static library project using the make_shared_lib option but without re-translating whole project.

    Allowed valueMeaningExample
    trueCreate shared_api_defs.h file regardless which library type (shared or dynamic) is targetted
    falseCreate shared_api_defs.h file only if targetting shared library.

    Default value: false

    finally_statement_as_lambda

    Allows translating the try-finally statement as a lambda expression instead of guard object placement.

    try
    {
        InnerMethod();
    }
    finally
    {
        Console.WriteLine("Finally");
        throw new Exception();
    }
    Allowed valueMeaningExample
    truetry-finally statement is translated through lambdas.
    System::DoTryFinally([&] /* try-catch block */ 
    {
        InnerMethod();
    }
    , [&] /* finally block */ 
    {
        System::Console::WriteLine(u"Finally");
    });
    falsetry-finally statement is translated using sentry object.
    auto __finally_guard_0 = ::System::MakeScopeGuard([]()
    {
        System::Console::WriteLine(u"Finally");
        throw System::Exception();
    });
    
    try
    {
        InnerMethod();
    }
    catch (...)
    {
        throw;
    }

    Default value: false

    setter_wrap_with_lambda

    Forces translating complex property assignment operators using lambdas.

    obj.PublicProperty += "abc";
    Allowed valueMeaningExample
    trueComplex property assignments use lambdas.
    System::WithLambda::setter_add_wrap(GETTER_SETTER_LAMBDA_ARGS(obj, PublicProperty), u"abc")
    falseComplex property assignments are translated using default approach.
    System::setter_add_wrap(static_cast<ConcreteBase*>(obj.GetPointer()), &ConcreteBase::get_PublicProperty, &ConcreteBase::set_PublicProperty, u"abc");

    Default value: false

    allow_interface_members_base_class_impl

    In C++, members of interface can be implemented in the base class. In C#, there’s no way doing so. This option generates required calls in child class; however, this can overcomplicate output code in some cases.

    public interface IFoo
    {
       void Do(int i, string s);
    }
    public class FooImpl
    {
        public void Do(int i, string s)
        {
        }
    }
    public class Foo : FooImpl, IFoo
    {
    }
    Allowed valueMeaningExample
    trueAdds required calls to methods implemented in base classes.
    class Foo : public FooImpl, public IFoo
    {
        ...
        void Do(int32_t i, System::String s);
    };
    void Foo::Do(int32_t i, System::String s)
    {
        FooImpl::Do(i, s);
    }
    falseDoesn’t generate required calls.

    Default value: true

    polymorphic_memberwiseclone

    <opt name="polymorphic_memberwiseclone" value="true">
        <root class="MyNamespace.MyClass"/>
        <root class="MyNamespace.MyClass2"/>
    </opt>

    By default, MemberwiseClone() method in translated code slices output object to the type it is called for. All information about child classes is lost for all implementation is static. This option allows injecting additional virtual methods to the classes MemberwiseClone() is called for and to their child classes. This fixes MemberwiseClone() behavior, but generates additional code. Please note that translator only considers MemberwiseClone() calls located in same assembly by default and doesn’t generate additional code for classes which are not subjects for MemberwiseClone() calls. To force generating these methods for specific classes and their subclasses (e. g. if MemberwiseClone() is called from different assembly), use ‘root’ subnodes with mandatory ‘class’ attributes containing C# class names.

    Allowed valueMeaningExample
    trueMemberwiseClone() clones full class tree.
    falseMemberwiseClone() cuts class tree being copied up to the class it is called upon.

    Default value: false

    version_compatibility_check_mode

    Allows translator generate code which compares headers version used to compile project and supplied library version on startup.

    Allowed valueMeaningExample
    stderrOn version mismatch, write error message to stderr, add a record to modules version mismatch registry and continue
    stdoutOn version mismatch, write error message to stdout, add record to modules version mismatch registry and continue
    silentNo output; on version mismatch, add a record to modules version mismatch registry and continue
    exitOn version mismatch, call std::exit(EXIT_FAILURE)
    noneDon’t add version check code to the resulting project

    Default value: stderr

    force_const_auto_property_getter

    Marks auto-generated property getters as const methods.

    Allowed valueMeaningExample
    trueMark auto-generated property getters as const.
    falseDo not mark auto-generated property getters const.

    Default value: false

    force_const_simple_property_getter

    Marks simple property getters consisting of single ‘return field_name’ statement as const.

    Allowed valueMeaningExample
    trueMark property getters like ‘return field_name’ as const.
    falseKeep such property getters non-const.

    Default value: false

    process_base_overloading

    Puts ‘using’ statement to re-declare hidden baseclass methods in subclasses.

    Allowed valueMeaningExample
    trueAdd using statements
    class Bar {
        ...
        void Do();
    };
    class Foo : public Bar {
        ...
        void Do(System::String s);
        using Bar::Do;
    };
    falseDo not add using statements
    class Bar {
        ...
        void Do();
    };
    class Foo : public Bar {
        ...
        void Do(System::String s);
    };

    Default value: false

    thread_static_generation

    Determines how to translate ThreadStatic attribute.

    Allowed valueMeaningExample
    disabledIgnore ThreadStatic attribute
    static System::String m_value;
    nativeTranslate ThreadStatic attribute as thread_local storage class.
    static thread_local System::String m_value;
    singletonConvert such fields into singletons.
    static System::String m_value() { static thread_local value = false; return value; }

    Default value: native

    remove_inactive_code

    Drops comments with inactive code.

    Allowed valueMeaningExample
    falseKeep comments with inactive code.
    trueDrop inactive code silently.

    Default value: false

    emit_preprocessor_directives

    Propagates preprocessor directives to C++.

    Allowed valueMeaningExample
    falseDrop preprocessor directives.
    trueAdd comments on used preprocessor directives.

    Default value: true

    emplace_assembly_details

    Replaces calls into Assembly::Get*Assembly() with calls to project-local GetAssembly_ProjectName(). Unbinds resources from global variables, hides them into local singleton instead.

    Allowed valueMeaningExample
    falseUse global singletons for Assembly.
    trueUse project-local singletons for Assembly.

    Default value: false

    add_baseclasses_tests

    If the class not marked with NUnit.Framework.TestFixture attribute contains methods maked with NUnit.Framework.Test attribute and is inherited by a class marked with NUnit.Framework.TestFixture attribute, the gtest tests are generated for child class instead of parent class.

    class FixtureBase {
        [Test]
        public void MyTest() {}
    }
    [TestFixture]
    class Fixture : FixtureBase
    {}
    Allowed valueMeaingExample
    trueMove tests to child class
    TEST_F(Fixture, MyTest) { ... }
    falseGenerate tests to base class
    TEST_F(FixtureBase, MyTest) { ... }

    Default value: true

    nunit_assert_class_aliases

    Calls to methods of NUnit.Framework.Assert class are translated into gtest-compatible macros. If you use your own test class with similarly named methods, use this option to enable special treatment of these. Enlist classes wrapped inside ‘alias’ subnode as shown below. Also, you might want to exclude such classes from translating.

    <opt name="nunit_assert_class_aliases" value="true">
        <alias class="MyNamespace.MyAssertClass"/>
    </opt>
    Allowed valueMeaningExample
    trueAllow Assert-like classes special treatment.
    falseTranslate Assert-like classes as usual.

    Default value: false

    original_tests_names

    Toggles prefixing test name with category name to simplify tests group run after translating. Alternatively, if you prefer having original tests names, you might want to disable this option.

    <opt name="original_tests_names" value="true"/>
    [TestFixture]
    public class OriginalTestName
    {
        [Test]
        [Category("Original")]
        public void Test1() {}
    }
    Allowed valueMeaningExample
    trueDo not add category prefix.
    TEST_F(OriginalTestName, Test1) { s_instance->Test1(); }
    falseAdd category prefix.
    TEST_F(OriginalTestName, Original_Test1) { s_instance->Test1(); }

    Default value: false

    cpp_enum_enable_metadata

    Enables metadata globally, same as CppEnumEnableMetadata attribute does for individual enums.

    <opt name="cpp_enum_enable_metadata" value="true"/>
    Allowed valueMeaningExample
    trueGenerate metadata for all public enums.Enum to string and string to enum conversions provide full text information, same as in C#.
    falseGenerate metadata for enums marked with CppEnumEnableMetadata attribute only.Unmarked enums convert to string and from string in numeric format only.

    Default value: false

    generate_enum_descriptions

    Enables passing System.ComponentModel.Description attribute value to C++ code.

    <opt name="generate_enum_descriptions" value="true"/>

    To extract such data, use the following syntax:

    System::Enum<T>::GetDescription(value)

    Here T is enum type and value is enum value.

    Allowed valueMeaningExample
    truePass attribute values to C++.
    falseIgnore attribute values.

    Default value: false

    hide_forward_declarations

    Wraps forward declarations section into ‘@cond…@endcond’ section to forbid Doxygen process it.

    Allowed valueMeaningExample
    trueWrap forward declaration into Doxygen conditional block.
    /// @cond
    namespace SomeNS { class Class1; }
    /// @endcond
    
    falseDo not wrap forward declaration into Doxygen conditional block.
    namespace SomeNS { class Class1; }

    Default value: false

    Since version: 20.7

    attributes_into_reflection_info

    Makes translator propagate information on specific attributes into reflection tables. Use like the following:

    <opt name="attributes_into_reflection_info">
        <attribute>JsonIgnore</attribute>
    </opt>

    ‘Attribute’ subnode with attribute name text specifies the attribute to propagate.

    Default value: attributes do not get propagated into reflection information

    Since version: 20.8

    allow_cast_to_non_generic_list

    Allows casts to System.Collections.IList to be translated into compilable code.

    Allowed valueMeaning
    trueSuch casts work in translated code.
    falseSuch casts do not compile. This is a recommended behavior, as .Net 1.0 collection support is legacy in most C# projects.

    Default value: false

    Since version: 20.8

    fix_setter_return_tag

    Replaces <retruns> tag with <param name=“value”> for property setters.

    class A
    {
        /// <summary>
        /// Foo getter and setter
        /// </summary>
        /// <returns>foo</returns>
        public int Foo
        {
            get { return foo; }
            internal set { foo = value; }
        }
    
        int foo;
    }
    Allowed valueMeaningExample
    trueReplaces <returns> tag for setter with <param> tag
    class A : public System::Object
    {
    public:
        /// <summary>
        /// Foo getter and setter
        /// </summary>
        /// <returns>foo</returns>
        int32_t get_Foo();
        /// <summary>
        /// Foo getter and setter
        /// </summary>
        /// <param name="value">foo</param>
        void set_Foo(int32_t value);
     };
    falseLeave all as is
    class A : public System::Object
    {
    public:
        /// <summary>
        /// Foo getter and setter
        /// </summary>
        /// <returns>foo</returns>
        int32_t get_Foo();
        /// <summary>
        /// Foo getter and setter
        /// </summary>
        /// <returns>foo</returns>
        void set_Foo(int32_t value);
    };

    Default value: false

    remove_all_comments

    Removes all comments from sources.

    Default value: false

    explicit_destructors

    Generates destructors for each translated class or struct.

    struct A {}
    class B {}
    Allowed valueMeaningExample
    trueAdds generated desctructor
    class A : public System::Object
    {
    public:
        ~A() {}
    }
    
    class B : public System::Object
    {
    public:
        ~B() {}
    }
    falseDestructor is not generated
    class A : public System::Object
    {
    }
    
    class B : public System::Object
    {
    }

    Since version: 20.9

    Default value: false

    rtti_on_testfixture

    Allows generating RTTI macros for TestFixture classes.

    [TestFixture]
    class SimpleTest {}
    Allowed valueMeaningExample
    trueGenerate RTTI section.
    class SimpleTest : public System::Object
    {
        typedef SimpleTest ThisType;
        typedef System::Object BaseType;
        typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
        RTTI_INFO_DECL();
    };
    falseDo not generate RTTI section.
    class SimpleTest : public System::Object
    {
    };

    Since version: 20.9

    Default value: true

    force_wrap_iostream

    Overloads all methods that accept System::IO::Stream arguments, as if CppIOStreamWrapper attribute was present.

    public void IStream(Stream istream)
    {
        ...
    }
    Allowed valueMeaningExample
    trueGenerate overload.
    void IStream(System::SharedPtr<System::IO::Stream> istream);
    template <typename CharType, typename Traits = std::char_traits<CharType>>
    void IStream(std::basic_istream<CharType, Traits>& istream)
    {
        auto istreamWrapper = System::IO::WrapSTDIOStream(istream);
        IStream(istreamWrapper);
    }
    falseDo not generate overload.
    void IStream(System::SharedPtr<System::IO::Stream> istream);

    Since version: 20.10

    Default value: false

    allow_using_directives_in_headers

    Makes translator simplify header files by utilizing header directives.

    using Namespace1;
    using System;
    namespace Namespace2
    {
        public class Class2
        {
            public void Foo(Class1 c1) { ... }
        }
    }
    Allowed valueMeaningExample
    trueSimplify the code.
    using namespace Namespace1;
    using namespace System;
    namespace Namespace2
    {
        class Class2
        {
        public:
            void Foo(SharedPtr<Class1> c1);
        };
    }
    falseUse full type qualifiers.
    namespace Namespace2
    {
        class Class2
        {
        public:
            void Foo(System::SharedPtr<Namespace1::Class1> c1);
        };
    }

    Since version: 20.10

    Default value: false

    extensions_as_method

    <opt name="extensions_as_method" value="true">
        <extension class="Aspose.BarClassExtensions"/>
    </opt>

    Specifies the classes for which extension method calls should be translated as member function calls instead of a static method from extension class. Value is ignored.

    obj.CallExtensionMethod(arg);
    Allowed valueMeaningExample
    Extension type is meitioned in ‘extension’ node under ‘opt’ config node.Generate method call instead of static function call.
    obj->CallExtensionMethod(arg);
    Extension type is not meitioned in ‘extension’ node under ‘opt’ config node.Generate static function call rather than method call.
    ExtensionClass::CallExtensionMethod(obj, arg);

    Since version: 20.11

    Default value: true

    generate_begin_end_methods

    Allows the translator to generate begin(), end() and other STL-like iterators access methods for those classes implementing the generic IEnumerable interface.

    If the class impelements the generic IEnumerable interface via returning GetEnumerator() call of its field or auto-property, and the type of this field or auto-property provides begin() and end() methods, these methods will be proxied at the class level. For example, the following code will go:

    public class Class0 : IEnumerable<int>
    {
        ...
        protected List<int> list; // List has begin/end methods.
        public IEnumerator<int> GetEnumerator()
        {
            return list.GetEnumerator(); // doing nothing but return list.GetEnumerator()
        }
        ...
    }

    If the implementation of GetEnumerator() is more complex, or the type of the property or field it operates doesn’t provide begin() and end() methods, these won’t be generated at class level, too. The following classes are not eligable for begin() and end() methods generation:

    public class Class1 : IEnumerable<int>
    {
        ...
        protected List<int> list; // List has begin/end methods.
        public IEnumerator<int> GetEnumerator()
        {
            list = new List<int>() { 1, 2, 3 }; // Modifying member before calling GetEnumerator()
            return list.GetEnumerator();
        }
        ...
    }
    public class Class2 : IEnumerable<int>
    {
        ...
        protected Class1 list; // Class1 has no begin/end methods.
        public IEnumerator<int> GetEnumerator()
        {
            return list.GetEnumerator(); // doing nothing else than return list.GetEnumerator()
        }
        ...
    }

    This behavior can be overwritten by using CppNoBeginEndMethods or CppGenerateBeginEndMethods attributes regardless of the option’s value.

    Allowed valueMeaningExample
    trueGenerate iterator methods.
    class Class0 : public System::Collections::Generic::IEnumerable<int32_t>
    {
        ...
    public:
        /// A collection type whose iterator types is used as iterator types in the current collection.
        using iterator_holder_type = System::Collections::Generic::List<int32_t>;
        /// Iterator type.
        using iterator = typename iterator_holder_type::iterator;
        /// Const iterator type.
        using const_iterator = typename iterator_holder_type::const_iterator;
        System::SharedPtr<System::Collections::Generic::IEnumerator<int32_t>> GetEnumerator() override;
        /// Gets iterator pointing to the first element (if any) of the collection.
        /// @return An iterator pointing to the first element (if any) of the collection
        iterator begin() noexcept;
        /// Gets iterator pointing right after the last element (if any) of the collection.
        /// @return An iterator pointing right after the last element (if any) of the collection
        iterator end() noexcept;
        /// Gets iterator pointing to the first element (if any) of the const-qualified instance of the collection.
        /// @return An iterator pointing to the first element (if any) of the const-qualified instance of the collection
        const_iterator begin() const noexcept;
        /// Gets iterator pointing right after the last element (if any) of the const-qualified instance of the collection.
        /// @return An iterator pointing right after the last element (if any) of the const-qualified instance of the collection
        const_iterator end() const noexcept;
        /// Gets iterator pointing to the first const-qualified element (if any) of the collection.
        /// @return An iterator pointing to the first const-qualified element (if any) of the collection
        const_iterator cbegin() const noexcept;
        /// Gets iterator pointing right after the last const-qualified element (if any) of the collection.
        /// @return An iterator pointing right after the last const-qualified element (if any) of the collection
        const_iterator cend() const noexcept;
        ...
    };
    falseDo not generate iterator methods.
    class Class0 : public System::Collections::Generic::IEnumerable<int32_t>
    {
        ...
    public:
        System::SharedPtr<System::Collections::Generic::IEnumerator<int32_t>> GetEnumerator() override;
        ...
    };

    Since version: 21.1

    Default value: true

    default_lambda_capture_mechanism

    Specifies the lambda capturing mechanism.

    Allowed valueMeaningExample
    pass_by_referenceAll lambda expressions will capture variables, parameters, etc. by reference.
    void foo() {
      int32_t value = 10;
      LambdaCaptureTest::VoidVoidDelegate lambda = LambdaCaptureTest::VoidVoidDelegate(static_cast<std::function<void()>>([&value]() -> void {
        ASSERT_EQ(10, value);
      }));
    }
    pass_by_valueAll lambda expressions will capture variables, parameters, etc. by value.
    void foo() {
      int32_t value = 10;
      LambdaCaptureTest::VoidVoidDelegate lambda = LambdaCaptureTest::VoidVoidDelegate(static_cast<std::function<void()>>([value]() -> void {
        ASSERT_EQ(10, value);
      })).template AddHeldVariable<LambdaCaptureTest::VoidVoidDelegate>("value", value);
    }
    use_holdersAll lambda expressions will capture variables, parameters, etc. wrapped into the LambdaCaptureHolder class instances.
    void foo() {
      System::Details::LambdaCaptureHolder<int32_t> _lch_value = 10;
      int32_t &value = _lch_value.GetCapture();
      LambdaCaptureTest::VoidVoidDelegate lambda = LambdaCaptureTest::VoidVoidDelegate(static_cast<std::function<void()>>([_lch_value, &value]() -> void {
        ASSERT_EQ(10, value);
      })).template AddHeldVariable<LambdaCaptureTest::VoidVoidDelegate>("value", value);
    }

    Since version: 21.2

    Default value: use_holders

    avoid_lambda_holders_if_possible

    Allowed valueMeaningExample
    trueThe translator will analyze if LambdaCaptureHolder must be used for wrapping. Variables and this will be passed to lambda expressions by reference when it is possible.
    falseThe analysis is disabled. Variables will be captured using the algotithm specified in the default_lambda_capture_mechanism option value.

    Since version: 21.2

    Default value: true

    always_include_delegates

    Allowed valueMeaningExample
    trueInclude delegates' original declarations.
    falseRe-declare delegates in the files they are used in.

    Since version: 21.3

    Default value: false

    force_const_ref_parameters

    Allowed valueMeaningExample
    trueThe non-virtual methods/constructors/setters/operators parameters with String or SmartPtr<> types are passed by const reference in a translated code.
    falseThe non-virtual methods/constructors/setters/operators parameters with String or SmartPtr<> types are passed by value in a translated code.

    Since version: 21.6

    Default value: false

    force_const_ref_return_type_for_auto_properties

    Allowed valueMeaningExample
    trueAuto-property getters of shared pointer types return const referencs to backed fields.
    falseAuto-property getters of shared pointer types return copies of values of backed fields.

    Since version: 21.7

    Default value: false

    force_const_ref_return_type_simple_properties

    Allowed valueMeaningExample
    trueSimple property getters (that contain only one return statement) of shared pointer types return const references to backed fields.
    falseSimple property getters (that contain only one return statement) of shared pointer types return copies of values to backed fields.

    Since version: 21.11

    Default value: false

    force_enum_flags_attribute

    Allowed valueMeaningExample
    trueGenerate operators for all enums, as if ‘Flags’ attribute was present.
    falseOnly generate enum operators where ‘Flags’ attribute is present.

    Since version: 21.7

    Default value: false

    alternative_debug_class

    Makes the translator convert the calls to the methods of the specified class into macros.

    C# code:

    Aspose.Debug.Assert(true);

    Configuration file:

    <typemap>
        <class csname="Aspose.Debug" cppname="Aspose::Replace::NullDebug"/>
    </typemap>
    <opt name="alternative_debug_class" value="Aspose.Debug"/>

    C++ code:

    NULLDEBUG_ASSERT(true);

    Since version: 21.10

    Default value: false

    class_ptr_alias

    Makes the translator generate a special ‘Ptr’ member type to each public class that aliases a smart poitner to this class.

    C# code:

    public class MyClass
    {}
    Allowed valueMeaningExample
    trueGenerate ‘Ptr’ member type for all public classes.
    class MyClass : public System::Object
    {
        // ...
    public:
        /// An alias for shared pointer to an instance of this class.
        using Ptr = System::SharedPtr<MyClass>;
    }
    falseDo not generate ‘Ptr’ member type.
    class MyClass : public System::Object
    {
        // ...
    }

    Since version: 21.12

    Default value: false

    Debug and developer version code options

    These options control debug and developer version code in generated C++ files.

    collect_test_methods

    Whether to collect information on translated code test methods in C++ runtime by calling “System::TestToolsExt::RegisterTest()” for each test method on initialization stage.

    Allowed valueMeaningExample
    trueCollect information on tests
    falseDon’t collect information on tests

    Default value: false

    generate_for_each_member

    Enables adding for_each_member subsystem-related code to each class and generating gv (graphviz) dumps of in-memory objects after each test.

    Allowed valueMeaningExample
    trueGenerate for_each_member-related code
    falseDon’t generate for_each_member-related code

    Default value: false

    for_each_member_cycles_only

    Enables cycles search using for_each_member

    Allowed valueMeaningExample
    trueGenerate parameter passing that enables loop search
    falseDon’t generate parameter passing that enables loop search

    Default value: false

    Since version: 20.11

    for_each_member_cleanup_before_each_test

    Enables cleaning up the for_each_member model before running each test.

    Allowed valueMeaningExample
    trueGenerate a method call that clears the for_each_member model inside the SetUp method
    falseDon’t generate a method call that clears the for_each_member model inside the SetUp method

    Default value: false

    stable_gv_file

    Enables renumbering objects in for_each_member-based gv dumps so that the indexes in output files do not depend on any temporary objects being created and then destroyed during the execution. Required if you want to compare the gv file against a template and want it to remain stable in all builds (release and debug builds and Visual Studio and non-Visual Studio builds currently create different amounts of temporary objects, therefore, affecting object indexes in non-stabilized builds).

    Allowed valueMeaningExample
    trueRenumbers objects when dumping gv files to stabilize them.
    falseDisables objects renumbering.

    Default value: false

    test_run_stub_file

    Creates a file to dump all tests names into during translating

    Allowed valueMeaningExample
    <Path to stub file>Path to the file to enlist all tests.MyTests.txt
    <Empty>Disables tests enlisting.

    Default value: <Empty>

    insert_leakage_detectors

    Insert helper code to detect the constructors leaking in references. This usually means that the nested objects created by this constructor refer to the object itself using shared pointers instead of weak ones which promises some big problems (memory leaks, double deletion issues on constructor exceptions, etc.). If enabling this feature, check output in debug to track potential problems.

    Allowed valueMeaningExample
    trueInsert leakage detection code.Example output message: Shared pointer leakage: constructor MyClass::MyClass(int, int) leaked 7 references.
    falseDoesn’t generage code to do the checks.

    Default value: false

    tests_garbage_collection

    Calls DBG_GARBAGE_COLLECTION mechanism after each test.

    Allowed valueMeaningExample
    noneDoesn’t collect garbage after tests
    reportCollects garbage and reports collected objects after each test. Class names, memory addresses, member names and addresses of objects these members point to are listed.
    Island of isolation is found.
    Objects:
        0x11223344: MyClass: 2 reference
            m_a: 0x55667788
            m_b: 0x99aabbcc
        0x55667799: MyClass2: 1 reference
            m_owner: 0x11223344
        0x99aabbcc: MyClass2: 1 reference
            m_owner: 0x11223344

    Default value: none

    tests_garbage_collection_generation

    GC generation to collect by __DBG_GARBAGE_COLLECTION wrappers after tests. For optimization purposes.

    Allowed valueMeaningExample
    Integer value 0 to 2Same as generation used by GC in C#

    Default value: 0

    add_category_name_to_timeout_tests

    If defined, value is used as a category name for all tests with timeouts.

    Default value: <Not defined>

    for_each_member_short_names

    Enables short names being generated for members available through for_each_member-related functions.

    Allowed valueMeaningExample
    falseGenerate long names“ForEachMemberTest::ForEachMemberTest::Child”
    trueGenerate short names“Child”

    Default value: false

    enable_warnings_for_virtual_function_calls

    Enables translator raising warnings if any virtual methods are called from constructor, as the behavior will be different in C++.

    Allowed valueMeaningExample
    falseDo not generate warnings
    trueGenerate warningsVirtual function call is found in constructor/destructor definition

    Default value: true

    Since version: 20.7

    Path resolving behavior

    This option regulate how translator check path that located in the config file.

    use_porter_home_directory_while_resolving_path

    Enables translator using translator home directory and translator executable location when resolving paths mentioned in configuration file. Only affects declarations that go after it in configuration file. Can’t be disabled if it is enabled somewhere else in configuration file.

    Allowed valueMeaningExample
    falseOnly directory with current configuration file is used as a lookup for mentioned paths.
    trueAdds translator binary location and %PorterHome% variable set either explicitly or via translator command line to the list of lookup directories.

    Default value: false

    Project settings

    These options specify the settings of output project.

    cmake_targets

    Whether to build translated project, tests or both.

    Allowed valueMeaningExample
    PortedProjectOnly build translated project (application if source project is application, library if source project is library)
    TestsOnly build test application but not the translated project
    BothBuild both tests and translated project

    Default value: Both

    make_shared_lib

    Whether to generate shared library project or static library project. Only makes effect if building translated project is allowed (see cmake_targets option) and source project ls a library rather than executable.

    Allowed valueMeaningExample
    falseGenerate static library
    trueGenerate shared library

    Default value: false

    Additional attributeMeaningAllowed valuesMandatoryDefault value
    export_per_memberWhether to generate per-member export attributes instead of per-class ones.true, falseNotrue
    export_internalsWhether to add *SHARED_API macro to internal class members, not only to public class members.true, falseNofalse
    shared_idOverrides default (generated) *SHARED_API macro.Prefix to *_SHARED macro.NoAssembly name with dots replaced with underscores

    cpp_lib_path

    Path to system library folder (the one containing ‘include/’ and ‘lib/’ directories).

    Allowed valueMeaningExample
    Path to library directoryRelative (to config) or absolute pathD:\Aspose\asposecpplib

    Default value: ../../../../asposecpplib

    cmake_temaplates or makefile_templates

    Path to the directory with CMakeLists.txt file to be used as a template.

    Allowed valueMeaningExample
    Path to the directoryPath or name of directory containing CMakeLists.txt templateMyTemplates

    Default value: cmake

    generatedlist_template

    Path to a file which will be used as a template for outputting list of all generated sources (header and cpp files)

    Allowed valueMeaningExample
    Path to the filePath or name of a template filecmake/GeneratedList.cmake

    Default value: "" (empty string)

    Let’s suppose you have the following GeneratedList.cmake file:

    set(generatedhpp
    %%HEADERS%%
    )
    
    set(generatedcpp
    %%SOURCES%%
    )

    The translator will create file GeneratedList.cmake next to CMakeLists.txt with the following content:

    set(generatedhpp
    include/public_header1.h
    include/public_header2.h
    source/private_header3.h
    source/private_header4.h
    # etc.
    )
    
    set(generatedcpp
    source/public_source1.cpp
    source/public_source2.cpp
    source/private_source3.cpp
    source/prviate_source4.cpp
    # etc.
    )

    Now you can include this file from CMakeLists.txt and use generatedcpp and generatedhpp variables instead of file(GLOB) cmake command.

    include_templates

    Path to the directory with shared_api_defs.h template file used to generate shared library API.

    Allowed valueMeaningExample
    Path to the directoryPath to the directory containing shared_api_defs.h templateMyTemplates

    Default value: include

    source_templates

    Path to the directory with embedded_resources.cpp template to support Assembly class and C# project’s resources access.

    Allowed valueMeaningExample
    Path to the directoryPath to the directory containing embedded_resources.cpp templateMyTemplates

    Default value: source

    add_assembly_details

    Indicates for which returned assembly current project will be used. I.e for executing_assembly Assembly.GetExecutingAssembly() will be used to access assembly name resources etc.

    Allowed valueMeaningExample
    executing_assemblyUse assembly executing at given moment
    entry_assemblyUse assembly used as an entry point
    calling_assemblyUse assembly calling into current one

    Default value: <None>

    additional_defines

    Additional defines for either C# code (used during code parsing) or C++ project (passed to cmake).

    Allowed valueMeaningExample
    List of defines to useList of the defiles. Separators are space (' ‘) and semicolon (';')__cplusplus;UNIT_TEST MY_DEFINE

    Default value: __cplusplus

    Additional attributeMeaningAllowed valuesMandatoryDefault value
    cmakeonlyWhether the define goes only to C++ project and not to C# projecttrue, falseNofalse
    csonlywhether the define goes to only to C# project and not to C++ projecttrue, falseNofalse

    exclude_conditional_symbols

    Exclude defines from being passed from C# project to cmake. Normally, translating applications passes all definitions mentioned in project file to cmake.

    Allowed valueMeaningExample
    List of definesDefines in C# project that won’t be passed to C++ project. Separators are space (’ ‘) and semicolon (';')MY_DEFINE MY_DEFINE_2;MY_DEFINE_3

    Default value: <None>

    additional_includes

    Additional includes to pass to translated project via cmake.

    Allowed valueMeaningExample
    List of directoriesList of additional include directories passed to cmake. Separators are space (’ ‘) and semicolon (';')C:\Cpp\my_lib;C:\Cpp\my_lib_2 C:\Cpp\third_party_lib

    Default value: <Not defined>

    Additional attributeMeaningAllowed valuesMandatoryDefault value
    localIf this path is mentioned in translator-generated include, whether to cut generated include to relative pathtrue

    false | No | false

    custom_gtest_main

    Path to the custom file with gtest main() function to use instead of the default one.

    Allowed valueMeaningExample
    Path to the filePath to the file containing main() function to call into gtest.custom_gtest_main.cpp

    Default value: gtest_main.cc

    cpp_files_to

    Directory to copy cpp files contained in current project to.

    Allowed valueMeaningExample
    Directory nameDirectory name inside output project foldercpp_files

    Default value: source

    interface_as_public

    Unconditionally move all interfaces to public headers, including non-public ones.

    Allowed valueMeaningExample
    trueMove all interfaces to public headers
    falsePut public interfaces to public headers, put private interfaces to private headers

    Default value: false

    internal_as_public

    Whether to translate internal members and types as public. Useful when preparing the library to be linked with tests project.

    Allowed valueMeaningExample
    trueTranslate internal members as public ones.
    falseTranslate internal members as private ones, but generate ‘friend’ declaration for inter-class access if required.

    Default value: false

    do_not_hardcode_aspose_cpp_path

    Disables writing exact path to asposecpplib at CMakeLists.txt. Useful if converted project is compiled from directory different from the one it was translated into.

    Allowed valueMeaningExample
    trueDo not put library path to CMakeLists.txt.
    falsePut library path to CMakeLists.txt.

    Default value: false

    tools_version

    Specific the version of tool that should be used on translating stage. Useful if project converted on machine with higher version of .NET Framework.

    Allowed valueMeaningExample
    Tools versionTools version recognized by MSBuild.4.0

    14.0

    Default value: version of tool specified in project file or any available one if project file doesn’t specify any.

    target_framework_version

    Specific version of .NET Framework to use when parsing C# project.

    Allowed valueMeaningExample
    .NET framework versionFramework available at “%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework.NETFramework"v4.7.1

    Default value: Version specified in project file.

    make_library

    Alternative way to specify output library type in what relates to shared API macros.

    Allowed valueMeaningExample
    sharedCreate shared librarySame as make_shared_lib=true
    staticCreate static librarySame as make_shared_lib=false
    apiCreate library with API export macros. Use this if you are building e. g. shared library which consists of several static ones and need generate shared library exports when translating into static libraries.

    Default value: static

    Additional attributeMeaningAllowed valuesMandatoryDefault value
    hide_local_symbolsWhether to avoid exporting private symbols.true, falsefalsefalse
    export_per_memberIf true, export each member separately. If false, export whole classes.true, falsefalsetrue
    export_internalsIf true, export internal members.true, falsefalsefalse
    shared_idExport macro prefixIdentifierfalseGenerated based on assembly name

    generate_includes_subdirectory

    Creates a subdirectory under ‘include’ directory to avoid header name clashes when using several translated projects from single project.

    Allowed valueMeaningExample
    falseDo not create subdirectoryinclude/MyClass.h is a file for MyClass.
    trueCreate subdirectory named after the C# project unless the name is specified explicitly.include/MyProject/MyClass.h is a file for MyClass from C# ‘MyProject’ project.

    Default value: false

    Additional attributeMeaningAllowed valuesMandatoryDefault value
    directoryExplicit name of the subdirectory under ‘include’ folder.String valuefalseC# project name

    make_cpp_file_name_uniq

    Controls translator behavior in whether file names should be unicalized by extending with trailing underscores.

    Allowed valueMeaning
    trueAll file names are unicalized.
    falseFile names may repeat.

    Default value: true

    Since version: 20.8

    headers_dir_name

    Changes the directory where header files of a translated project will be stored. The ‘include’ directory name is used when this attribute is not present in the config file.

    Default value: include

    Since version: 21.4

    sources_dir_name

    Changes the directory where source files of a translated project will be stored. The ‘source’ directory name is used when this attribute is not present in the config file.

    Default value: source

    Since version: 21.4

    Code readability

    These options improve generated code’s readability. However, the code generated now doesn’t handle some corner cases properly or in the same way C# code does, so using these options on big codebases is error-prone. Instead, use them to translate e. g. code samples for your projects being translated, to make them easy to read.

    foreach_as_range_based_for_loop

    Translate C# foreach loops as C++ range-based for loops

    foreach (HeaderFooter hf in doc.GetChildNodes(NodeType.HeaderFooter, true))
    {
        // ...
    }
    Allowed valueMeaningExample
    falseTranslate foreach loop as while loop
    auto hf_enumerator = doc->GetChildNodes(NodeType::HeaderFooter, true)->GetEnumerator();
    SharedPtr<HeaderFooter> hf;
    while (hf_enumerator->MoveNext() && (hf = DynamicCast<HeaderFooter>(hf_enumerator->get_Current()), true))
    {
        // ...
    }
    trueTranslate foreach loop as range-based for loop
    for (auto hf : IterateOver<HeaderFooter>(doc->GetChildNodes(NodeType::HeaderFooter, true)) )
    {
        // ...
    }

    Default value: false

    simplify_using_statements

    Makes translator generate more compact code for ‘using’ statements that relies on used object destructors rather then on correct Dispose calls.

    Allowed valueMeaningExample
    trueDo not generate compilcated code to call into Dispose().
    {
        System::SharedPtr<Rs> __using_resource_0 = System::MakeObject<Rs>();
        System::Console::WriteLine(u"Statement");
    }
    falseGenerate correct Dispose calls anyway.
    {
        System::SharedPtr<Rs> __using_resource_0 = System::MakeObject<Rs>();
        //Clearing resources under 'using' statement
        System::Details::DisposeGuard<1> dispose_guard_1({ using_resource_0});
        
        try
        {
            System::Console::WriteLine(u"Statement");
        }
        catch(...)
        {
            dispose_guard_1.SetCurrentException(std::current_exception());
        }
    }

    Default value: false

    Since version: 20.8

    force_auto_in_variable_declaration

    Makes translator generate ‘auto’ types for local variables instead of full type name so that code is more compact.

    Allowed valueMeaningExample
    trueGenerate ‘auto’ type names.
    auto rs = System::MakeObject<Rs>();
    falseGenerate full type names.
    System::SharedPtr<Rs> rs = System::MakeObject<Rs>();

    Default value: false

    Since version: 20.8

    prefer_short_type_names

    Makes translator prefer short type names where possible instead of fully qualified names in some contexts.

    Allowed valueMeaningExample
    trueUse short names.
    System::StaticCast<A>(o)
    falseUse fully qualified names.
    System::StaticCast<Full::Namespace::Path::A>(o)

    Default value: false

    Since version: 20.9

    use_stream_based_io

    Replaces System::Console calls with cout invocations.

    Allowed valueMeaningExample
    trueSwitch to cout usage.
    std::cout << "Hello" << std::endl;
    falseUse fully qualified names.
    System::Console::WriteLn(u"Hello");

    Default value: false

    Since version: 20.10

    generate_get_shared_members

    Enables or disables generating GetSharedMembers() method for translated classes.

    Allowed valueMeaning
    trueGetSharedMembers() method is generated.
    falseGetSharedMembers() method is not generated.

    Default value: true

    Since version: 20.11

    generate_rtti_info

    Enables or disables generating RTTI macros for translated classes.

    Allowed valueMeaning
    trueRTTI macros are generated.
    falseRTTI macros are not generated.

    Default value: true

    Since version: 20.11

    Code documentation

    keep_documentation_comments

    Allows passing C# code documentation comments to C++ code.

    Allowed valueMeaningExample
    truePass Doxygen-style comments to C++.
    falseSkip Doxygen-style comments.

    Default value: false

    fix_self_closing_tags

    Enables translator transforming self-closing documentation comment tags into pairs of opening and closing ones.

    Allowed valueMeaningExample
    trueTransform self-closing tags.‘<tag/>’ transforms into ‘<tag></tag>’
    falseKeep self-closing tags as they are.‘<tag/>’ remains as it is.

    Default value: false

    Since version: 20.1

    try_expand_cref_types

    Enables translator to replace cref types with proper C++ substitutions when translating documentation comments to Doxygen format.

    Allowed valueMeaningExample
    trueDo the expansion of cref items.
    <see cref="Doxygen::GoldTests::Porter::TestClass"></see>
    falseDo not expand cref items.
    <see cref="TestClass"></see>

    Default value: false

    Since version: 20.7

    hide_internal_declarations

    Makes translator mark internal entities for Doxygen to skip them.

    Allowed valueMeaningExample
    trueMake Doxygen skip internal entities.
    /// @cond
        /// <summary>
        /// internal constructor
        /// </summary>
        /// <param name="value"></param>
        AbstractTestClass(uint8_t value);
        /// @endcond
    
    falseMake Doxygen generate documentation for internal entities.
    /// <summary>
        /// internal constructor
        /// </summary>
        /// <param name="value"></param>
        AbstractTestClass(uint8_t value);

    Default value: false

    Since version: 20.8

    hide_friend_declarations

    Makes the translator to generate the ‘@cond…@endcond’ wrappers around friend declarations to exclude them from the Doxygen documentation.

    Allowed valueMeaningExample
    trueGenerate wrappers.
    /// @cond
    friend class MyClass;
    /// @endcond
    
    falseDo not generate wrappers.
    friend class MyClass;

    Since version: 21.1

    Default value: false

    remove_private_comments

    Makes translator remove comments for private entities.

    Allowed valueMeaning
    trueTranslate comments for non-private entities only.
    falseTranslate comments for all entities.

    Default value: false

    Since version: 20.8

    Legacy options

    Options no longer supported but still recognized (and ignored) by translator for compatibility reasons are:

    • alternative_base
    • boost_ver
    • additional_libdirs
    • singleton_mode
    • auto_weak_ptr_reference
    • gtest_path
    • insert_using_statement_guard
    • using_statement_as_lambda
    • using_statement_enhanced

    Notes

    Code examples used on this page are for illustration purposes only. Actual translator output may differ.