realm / realm-dotnet

Realm is a mobile database: a replacement for SQLite & ORMs
https://realm.io
Apache License 2.0
1.25k stars 164 forks source link

Realm dynamic exhibits strange behavior in .NET Core 3 (works in .NET Core 2.1) #1941

Closed yoda29-1977 closed 3 years ago

yoda29-1977 commented 4 years ago

Goals

Using DLR and dynamic realm to dump a realm database

Expected Results

The output should be identical on both .NET Core 2.1 and .NET Core 3.0

Actual Results

.NET Core 3 output appears different and wrong RealmDlrTest.zip

Steps to Reproduce

Attached visual studio 2019 solution - RealmDlrTest, comprising two projects: one NETSTANDARD2.0 class library project (RealmDlrLib) with the realm stuff that exposes a static method DumpJson() and a test driver console application project (RealmDlrTest) that simply invokes the above method to dump json from a realm database. Sample realm database test.realm is also included.

Build the solution first my modifying the RealmDlrTest.csproj TargetFramework to netcoreapp2.1. Rebuild yet again by modifying the RealmDlrTest.csproj TargetFramework to netcoreapp3.0. You will find the binaries under respective publish sub-folders under the root path RealmDlrTest\RealmDlrTest\bin\Debug.....

Change directory (CD command) to RealmDlrTest\RealmDlrTest\bin\Debug\netcoreapp2.1\publish and launch the test: dotnet RealmDlrTest.dll RealmDlrTest\test.realm You will see json output that exactly matches the realm database as viewed in realm studio

Next change directory to the netcoreapp3.0\publish folder and launch the test again. You will see json output that appears different on the second table dump. Due to the matching column name between the two tables in the test sample database, the second table output appears to miss the first column output and next two column data appear to shift in the output.

Code Sample

Attached zip

Version of Realm and Tooling

4.2.0 Windows 10 Mac OS Catalina 10.15.1

nirinchev commented 3 years ago

This was fixed in 10.0.0-beta.3.