dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.18k stars 4.72k forks source link

EnC: adding a static field to a struct fails #108301

Open tmat opened 4 weeks ago

tmat commented 4 weeks ago

Description

The runtime doesn't support adding a static field to a struct or class with explicit layout.

This is an odd limitation as static field does not affect layout of the object.

The operation currently fails on all runtimes: .NET Framework, .NET 9, Mono.

Reproduction Steps

Roslyn currently blocks such an edit but a CLR test can be easily written to demonstrate the issue. I can also supply private Roslyn build that removes the rude edit.

Expected behavior

Adding static field into a struct should work.

Actual behavior

Application of EnC delta fails.

Regression?

No.

Known Workarounds

No response

Configuration

No response

Other information

No response

lambdageek commented 4 weeks ago

The runtime doesn't support adding a static field to a struct or class with explicit layout.

@tmat auto and sequential layout works?

tmat commented 3 weeks ago

I have not tested all possible layouts. Just structs. Auto class layout is the default, right? That works fine.