System.Sysutils

Top  Previous  Next

Pretranslated C# code > Delphi RTL > System.Sysutils

Delphi2C# includes a managed implementation of important functionality from Delphi’s System.SysUtils unit. It is designed to let translated applications use familiar Delphi routines and exception types while running on the .NET platform.

 

The implementation focuses on practical source-code compatibility rather than binary compatibility with the native Delphi runtime.

 

Supported Functionality

 

The current System.SysUtils implementation includes support for commonly used areas such as:

 

string formatting and replacement;
integer, floating-point and currency conversion;
Delphi-style integer notation, including hexadecimal, binary and octal values;
date and time conversion;
TTimeStamp conversion and validation;
culture-based TFormatSettings;
file and directory helper functions;
GUID comparison and interface-support helpers;
Delphi-compatible runtime exceptions;
managed resource strings;
monitor support required by translated RTL code.

 

FormatSettings is initialized automatically from the current .NET culture.

 

Delphi-Compatible Numeric Parsing

 

Integer conversion functions support Delphi numeric syntax, including:

 

30

$1E

0x1E

%11110

&36

-$1E

 

This behavior is available through functions such as StrToInt, StrToInt64, StrToUInt64 and their Try and default-value variants.

 

Date and Time Handling

 

Date and time routines use Delphi-compatible validation rules.

 

For example, TimeStampToMSecs validates the supplied TTimeStamp before conversion. Its date component must be greater than zero, and its time component must be within the valid millisecond range of one day.

 

Invalid values raise the corresponding SysUtils exception instead of returning an arbitrary result.

 

Runtime Exceptions

 

Translated runtime errors are mapped to managed SysUtils exception classes.

 

Supported mappings include:

 

EOutOfMemory;

EInvalidPointer;

EDivByZero;

ERangeError;

EIntOverflow;

EInvalidOp;

EZeroDivide;

EOverflow;

EUnderflow;

EInvalidCast;

EAccessViolation.

 

An installed Delphi-compatible error hook is used when available; otherwise, the managed runtime raises the appropriate exception directly.

 

Managed Resource Strings

 

Translated resourcestring declarations can be represented by managed TResStringRec values and registered with a numeric resource identifier.

 

The managed implementation supports:

 

direct use of a resource string as a normal string;

 

LoadStr;
FmtLoadStr;
registering and replacing resource strings;
removing individual registrations;
clearing managed registrations.

 

A missing resource identifier returns an empty string, consistent with the expected LoadStr behavior.

 

Native resource lookup in executable files, resource DLLs and Delphi packages is not part of the current managed implementation.

 

Pointer Compatibility

 

The newly translated SysUtils implementation is compatible with Delphi2C#’s current pointer-simulation types.

 

Translated code can therefore continue to use the pointer abstractions required by other RTL units and application code.

 

Internally, however, SysUtils is not dependent on pointer simulation for operations that can be implemented more safely and efficiently with managed .NET functionality. String replacement, buffer construction, parsing and similar operations use managed implementations where appropriate.

 

This provides compatibility at the public RTL boundary while avoiding unnecessary pointer arithmetic inside the implementation.

 

Compatibility Files

 

Several compatibility types used by translated RTL code remain available, including:

 

TVarData;
TMonitorSupport;
monitor callback delegates;
TLibModule;
TResStringRec.

 

 

Current Limitations

 

Some specialized Delphi runtime areas are intentionally reserved for later updates:

 

complete Variant semantics;
Variant arrays and ByRef Variants;
COM Variant types;
Delphi package metadata;
native package resource lookup;
native exception and SEH integration;
native resource DLL switching;
direct FPU and MXCSR control;
component streaming through DefineProperties.

 

These limitations do not affect the normal managed use of the supported SysUtils functions.

 

 



This page belongs to the Delphi2C# Documentation

Delphi2C# home  Content