Compartir a través de


C# Proxy Source Code for X++ Classes

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

This topic describes details about the C# source code that is written for X++ classes by the proxy generator. In Microsoft Dynamics AX, there are a few different techniques to invoke the proxy generator, but each technique produces the same output.

Note

This topic uses the C# language. The information applies to any language that is supported by the Microsoft .NET common language runtime, including Microsoft Visual Basic.

Source Code Details

The following table describes details about the C# source code that is written by the proxy generator.

Detail

Comment

Proxies are automatically included for compile time dependencies.

When you generate a proxy for the X++ class QueryRun, a proxy is also generated for the X++ class ObjectRun. QueryRun depends on ObjectRun because QueryRun inherits from ObjectRun.

An X++ method creates a dependency on another X++ class if either of the following is true:

  • The method inputs the other X++ class as a parameter, or

  • The other class is the return type of the method.

No dependency is detected if the method only declares and uses a variable of other class type.

Inheritance by the proxy class.

Every proxy class extends Microsoft.Dynamics.AX.ManagedInterop.Object.

Separate output file for each proxy.

Every proxy from the proxy generator is written to its own separate source code file.

///<summary> XML documentation is included.

If the X++ source code contains ///<summary> XML documentation, the proxy generator copies the documentation to the output proxy.

SYS versus USR layers.

Proxy classes are built to match the changes to the target AOT element in all layers, regardless of which layer you are logged into with Microsoft Visual Studio.

protected methods are omitted from the proxies.

You have only limited ability to create new classes in C# that inherit from a proxy class. X++ methods with the protected access modifier are excluded by the proxy generator.

Note

If you want to extend a proxy class, consider instead extending the X++ class before you generate the proxy.

The abstract modifier in X++ is discarded from the C# proxy.

The proxy generator ignores the abstract modifiers it encounters in X++ classes. No proxy classes or members are ever abstract.

Every X++ method is marked either virtual, override, or new in the C# proxy.

Suppose in X++ you have a class DerivedClass that extends X++ class BaseClass. In their C# proxies, the methods would be decorated as follows:

  • int BaseClass.method22() – virtual

  • int method333() – virtual

  • int DerivedClass.method22() – override

  • int64 method333() – new

  • void Derived.method4444(bool b) – virtual

The new method in X++ is represented as a constructor in C#.

If the X++ class has no method that is named new, the proxy generator writes a default constructor in C#.

X++ names are modified if they conflict with a C# keyword.

For example, an X++ class that is named stackalloc would conflict with the C# keyword keyword stackalloc. Therefore, in the proxy file the C# class name would be _stackalloc. However, this same proxy if generated in Visual Basic would have the unaltered class name of stackalloc.

See also

Proxy Classes for .NET Interop to X++

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.