Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click [decimal/int32/enum] DataGrid Header crash when publish aot. #14059

Closed
dameng324 opened this issue Dec 29, 2023 · 2 comments · Fixed by #17248
Closed

Click [decimal/int32/enum] DataGrid Header crash when publish aot. #14059

dameng324 opened this issue Dec 29, 2023 · 2 comments · Fixed by #17248

Comments

@dameng324
Copy link
Contributor

Describe the bug

When I click the datagrid column header to sort which display decimal/enum/int32 field, the application will crash.
It works normal when not aot mode.
It works normal when dotnet run with PublishAot=true
It works normal when column data type is string/double

To Reproduce

I create a simple demo to reproduce this bug:

  1. create a avalonia data grid demo.
  2. create a TestModel which has decimal/int32/enum fields.
  3. create a DataGrid to display TestModel data.
  4. add <PublishAot>true</PublishAot> to csproj.
  5. publish the application with NativeAot:dotnet publish -c Release
  6. execute the published application:.\bin\Release\net8.0\win-x64\publish\AvaloniaDataGrid.exe
  7. Click header to sort.

I have create a repo to reproduce that. https://github.com/dameng324/AvaloniaDataGridDemo

Expected behavior

do not crash when

Screenshots

you can simple download the code and reproduce it.

Environment

  • OS: Windows
  • Avalonia-Version: 11.0.6
  • dotnet sdk version: 8.0.100

Additional context

I have tried many types. result:

type dotnet publish aot and run manually
int32 crash
decimal crash
enum crash
double normal
string normal
@workgroupengineering
Copy link
Contributor

workgroupengineering commented Jan 3, 2024

A workaround is

    // Avalonia configuration, don't remove; also used by visual designer.
    public static AppBuilder BuildAvaloniaApp()
        => AppBuilder.Configure<App>()
            .UsePlatformDetect()
            .WithInterFont()
            .AfterSetup(_ =>
            {
                var x = Comparer<int>.Default;
                var y = Comparer<decimal>.Default;
                var z = Comparer<PlatformID>.Default;
            })
            .LogToTrace();
}

@dameng324
Copy link
Contributor Author

@workgroupengineering Thanks, It works. Hope fixing it with a more elegant way in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants