Przejdź do treści
Biblioteka skilli
Programowanie · Konwersja i formaty

delphi-to-csharp

/delphi-to-csharp

Przenosi logikę z aplikacji Delphi do C# i .NET, mapuje typy i pułapki zmieniające zachowanie oraz dowodzi równoważności testami.

Repozytorium
delphi-ai-dev ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
02.11.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść25 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
2
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 02.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co sprawdzić przed instalacją
  • SKILL.md zawiera komentarze HTML (2). Nie widać ich w podglądzie Markdown, a model je czyta.

Co robi i kiedy

Przenosi logikę z aplikacji Delphi do C# i .NET, mapuje typy i pułapki zmieniające zachowanie oraz dowodzi równoważności testami.

Wyzwalacze z opisu

port to C#migrate from Delphirewrite in .NETsame behaviour as the Delphi versionC# equivalent
Oryginalny opis (EN)

Use when porting logic from a Delphi desktop application to C# / .NET (for example a web successor of a desktop tool), or when both implementations must behave identically during a transition period. Covers type and idiom mapping, the traps that change behaviour silently, and how to prove equivalence with shared test vectors. Triggers on "port to C#", "migrate from Delphi", "rewrite in .NET", "same behaviour as the Delphi version", "C# equivalent".

Jak działa

  1. Strategy
  2. Type mapping
  3. Behaviour that changes silently
  4. Done means
  5. Learned rules
Sekcje z nagłówków SKILL.md, w oryginale · 56 linii, 572 słów
Podgląd SKILL.md
---
name: delphi-to-csharp
description: Use when porting logic from a Delphi desktop application to C# / .NET (for example a web successor of a desktop tool), or when both implementations must behave identically during a transition period. Covers type and idiom mapping, the traps that change behaviour silently, and how to prove equivalence with shared test vectors. Triggers on "port to C#", "migrate from Delphi", "rewrite in .NET", "same behaviour as the Delphi version", "C# equivalent".
---

# Porting Delphi logic to C#

## Strategy

1. **Port logic, not screens.** Protocol, configuration model, validation and rules move; the UI is redesigned for the new platform.
2. **Pin the Delphi behaviour first.** Characterisation tests in Delphi produce **test vectors**: inputs and
   expected outputs (encoded frames, decoded configurations, validation results) stored as files.
3. **Run the same vectors against the C# code.** Equivalence is proven by data, not by reading code side by side.
4. **Port module by module**, smallest dependency first, and keep both implementations green on the same vectors.

## Type mapping

| Delphi | C# | Watch out |
|--------|----|-----------|
| `Integer` / `Cardinal` | `int` / `uint` | |
| `Int64` / `UInt64` | `long` / `ulong` | |
| `Byte`, `Word`, `LongWord` | `byte`, `ushort`, `uint` | |
| `NativeInt` / `NativeUInt` | `nint` / `nuint` | size follows the platform |
| `Boolean` / `LongBool` | `bool` | in a binary layout `Boolean` is 1 byte, `LongBool` 4; marshal explicitly |
| `Currency` | `decimal` | Currency is fixed 4 decimals |
| `Single` | `float` | |
| `Double` / `Extended` | `double` | `Extended` is 80-bit on Win32; results can differ in the last digits |
| `TDateTime` | `DateTime` via `DateTime.FromOADate` / `ToOADate` | same epoch (1899-12-30); `FromOADate` rounds to whole milliseconds and returns `Kind = Unspecified`; compare test vectors with a tolerance or as ticks |
| `string` (1-based) | `string` (0-based) | every index and `Copy(s, i, n)` call shifts by one |
| `AnsiString`, `RawByteString`, `ShortString`, `AnsiChar`, `PAnsiChar` | `byte[]` + an explicit `Encoding` | code-page text in protocols and files; on .NET (Core) `Encoding.GetEncoding(1250)` throws until `CodePagesEncodingProvider.Instance` is registered; `ShortString` has a length byte in front |
| `TBytes` | `byte[]` / `ReadOnlySpan<byte>` | |
| set of enum | `[Flags] enum` | |
| `record` | `struct` or `record struct` | value semantics match; check copies in loops |
| `TObjectList<T>` | `List<T>` | ownership disappears with the GC; `IDisposable` for real resources |
| interface (refcounted) | interface (GC) | deterministic destruction is gone; use `using` where it mattered |
| `TThread` + `Synchronize` | `Task` / `async` | in a web app there is no UI thread to synchronise with |

## Behaviour that changes silently

- **Integer overflow:** Delphi without `{$Q+}` wraps; C# wraps too unless `checked`. Match the original, and say which it is.
- **`div` and `mod` with negative numbers** behave like C# `/` and `%` on integers (truncation). Keep a test anyway.
- **Rounding:** Delphi `Round` uses banker's rounding; C# `Math.Round` defaults to the same (`ToEven`). `Trunc` → `Math.Truncate`.
- **Byte order:** use `BinaryPrimitives.ReadUInt16BigEndian` etc. explicitly, never `BitConverter` without checking `IsLittleEndian`.
- **String comparison:** Delphi `SameText` / `CompareText` fold only ASCII letters, `AnsiSameText` uses the
  locale, C# `OrdinalIgnoreCase` folds all of Unicode. With Czech characters (`é` / `É`) they disagree.
  Choose the comparison explicitly and cover it with a vector.
- **Default values:** Delphi zeroes object fields and initialises managed locals (`string`, dynamic arrays,
  interfaces, `Variant`); other locals (`Integer`, `Double`, records without managed fields, pointers) start
  with garbage. C# refuses to compile a read of an unassigned local, so such Delphi bugs surface during the port.

## Done means

- All shared test vectors pass in both implementations.
- Differences that are intended are listed in the merge request, with the reason.

## Learned rules

<!-- learned-rules -->
<!-- /learned-rules -->

Wersje

W bazie nie ma innych skilli o nazwie delphi-to-csharp.

Migawka bazy z 13.11.2026 · wersja paczki 5e562b50e298 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90delphi
    Pomaga w tworzeniu aplikacji desktopowych w Delphi i Object Pascal, w tym w VCL, FMX i aplikacjach bazodanowych dla Windows.
  • 100delphi
    Wspiera pracę z Delphi i Object Pascal: VCL, FireMonkey, RTL oraz utrzymanie i modernizacja desktopowych aplikacji dla Windows i natywnych aplikacji wieloplatformowych.
  • 100delphi-architecture
    Wyznacza, gdzie trafia nowy kod w dużej aplikacji VCL w Delphi, jak wyprowadzić logikę z obsługi zdarzeń i planuje bezpieczne refaktoryzacje.
  • 98delphi-build-test
    Buduje projekt Delphi z linii poleceń, uruchamia testy jednostkowe i czyta błędy kompilatora, by agent sam poprawił kod przed przeglądem.
  • 100delphi-build
    Konfiguruje kompilację projektów Delphi: flagi dcc32 i dcc64, ścieżki wyszukiwania w .dproj, cele MSBuild i definicje warunkowe.
  • 95csharp-client
    Dostarcza materiał referencyjny klienta SpacetimeDB w C#/.NET dla aplikacji konsolowych i desktopowych.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.