Aras Innovator Platform

Cross-Platform Development

Despite of being cross-platform and providing high-level abstractions for low-level APIs, some .NET Core and .NET 8.0 API still may work differently depending on a current platform it is running on.

It is necessary for developers to know and understand these differences to be sure that the application works identically on all supported platforms:

  • Working with native code

    .NET provides mechanisms to call native code via Platform Invoke.

    There might be an existing code that uses P\Invoke to call Windows-specific API (e.g.via kernel32.dll), and since it is not present on Linux, the code will not work when running in Linux.To avoid compatibility issues, it is better to use available .NET Core and .NET 8.0 functionality or 3rd-party libraries that provide cross-platform capabilities.

    If different libraries need to be loaded or APIs called depending on a current OS, consider decorating the code with platform-specific blocks:

    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
    
    {
    
        // Call Windows-specific API
    
    }
    
    else
    
    {
    
        // Call Linux-specific API
    
    } 

    Follow the link to find more about native interoperability: Native interoperability - .NET

  • OS-specific APIs

    .NET Core and .NET 8.0 exposes several APIs that might not be available for the given platform. Such APIs throw PlatformNotSupportedException when called from an unsupported OS. For instance, Process.MainWindowHandle throws the exception on Linux and macOS.

    Make sure you do not use one of these APIs if you plan to run the Innovator on multiple platforms.

    Follow the link to find more about unsupported APIs: APIs that always throw exceptions on .NET Core and .NET 8.0

  • File system case-sensitivity

    Windows uses a case-insensitife file system allowing to access files regardless of path casing, so a single file or folder can be accessed by paths written in different cases, e.g. c:\Innovator\Aras.Server.exe is equal to c:\INNOVATOR\aras.server.EXE

    Unlike Windows, the Linux file system is case-sensitive, meaning that two paths with different casing will point to a two different files\directories, e.g.

    /app/bin/Aras.Server.exe is not equal to /app/bin/Aras.server.EXE

    During development, make sure that all paths in code match corresponding entities on file system to avoid any issues when running Aras Innovator on Linux.

  • Filesystem path delimiter

    In Windows, it is allowed to use both slash (‘/’) and backslash (‘\’) as a path delimiter as they cannot be part of file\folder name, so the next two paths are equal:

    c:\Innovator\Aras.Server.exe is equal to c:/INNOVATOR/aras.server.EXE

    On Linux, because the backslash is a valid file name character, the only allowed path delimiter is slash (‘/’) so

    /app/Innovator/Aras.Server.exe is not equal to /app/Innovator\Aras.server.EXE

    To avoid any issues with accessing file system, it is strongly recommended to avoid building paths manually, and use special .NET API instead to build platform-specific file path:

    • Path.Combine()
    • Path.Join()
    • Path.DirectorySeparatorChar

    Example:

    Calling Path.Join(Directory.GetCurrentDirectory(), “data”); will produce the following results:

    On Windows: “C:\Innovator\data”

    On Linux: “/app/Innovator/data”

  • Cultures and string comparison

    .NET exposes CultureInfo API to work with different cultures. This API is platform-dependent and may work differently on different platforms: Windows and Linux do not use identical lists of cultures. In Windows it is part of the installation while Linux relies on data from International Components of Unicode (ICU). Another difference is that certain cultures may not be installed on a particular OS.

    String comparison with the use of InvariantCulture and CurrentCulture settings works differently on Windows and Linux. To avoid cross-platform issues, it is highly recommended to specify string comparison/culture explicitly and follow Best Practices for Comparing Strings in .NET

  • Date and time formatting

    Date and Time .NET API may return date and time in a different format depending on the current OS and its regional settings. For instance, calling DateTime.Now.ToString(); will produce the following results:

    On Windows: “05/21/2021 2:22:55 PM”

    On Linux: “05/21/2021 15:22:55”

    It is recommended to explicitly set culture or date/time format to avoid the differences between the date format on Linux and Windows.

  • Timezones

    .NET provides an API to work with time zones via TimeZoneInfo. Depending on a platform, the result of calling this API will be different: Windows maintains its own list of timezones while Linux uses IANA time zones. These formats are not identical and might have different names for the same time zone. For instance, the result of calling TimeZoneInfo.Local will be as follows:

    On Windows: ”(UTC+03:00) Minsk”

    On Linux: ”(UTC+03:00) GMT+03:00”

    Please note that the Innovator has a custom implementation for mapping between these formats. It always expects that the time zone name is provided in the Windows format and transforms it to IANA name when TimeZoneInfo API is needed on non-Windows platform. In addition, the time zone name on Aras Innovator Client is always converted to the Windows format from IANA.

  • Line ending

    Line endings vary by OS. Windows uses carriage return and line feed ("\n”) as a line ending while UNIX-based OSes use just line feed ("\n”).

    In .NET calling Environment.NewLine will also return different values depending on a current OS.

    On Windows:

    Environment.NewLine => “\n”;

    On Linux:

    Environment.NewLine => “\n”;