Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Fixes: #5197

[Preserve] still works in some form, as the ApplyPreserveAttribute trimmer step will "mark" types it encounters. It unfortuantely, does not work if an assembly is deemed to be fully removed, as the ApplyPreserveAttribute will not be called for these types.

To better align with the future of .NET, we should remove our usage of [Preserve]. The only failing result is Java.Lang.Object.SetHandleOnDeserialized which can be preserved in Mono.Android.xml instead.

In a future PR, we can consider emitting warnings in customer code with [Preserve] usage.

@jonathanpeppers jonathanpeppers force-pushed the RemovePreserveAttributeUsage branch from 23f3ddc to 094909a Compare July 22, 2024 20:53
Fixes: dotnet#5197

`[Preserve]` still works in some form, as the `ApplyPreserveAttribute`
trimmer step will "mark" types it encounters. It unfortuantely, *does
not* work if an assembly is deemed to be fully removed, as the
`ApplyPreserveAttribute` will not be called for these types.

To better align with the future of .NET, we should remove *our* usage of
`[Preserve]`. The only failing result is `Java.Lang.Object.SetHandleOnDeserialized`
which can be preserved in `Mono.Android.xml` instead.

In a future PR, we can consider emitting warnings in customer code with
`[Preserve]` usage.
@jonathanpeppers jonathanpeppers force-pushed the RemovePreserveAttributeUsage branch from 094909a to 23ce1f0 Compare July 23, 2024 14:55
@jonathanpeppers jonathanpeppers merged commit 688245d into dotnet:main Jul 23, 2024
@jonathanpeppers jonathanpeppers deleted the RemovePreserveAttributeUsage branch July 23, 2024 19:22
grendello added a commit that referenced this pull request Jul 24, 2024
* main:
  [trimming] remove our usage of `[Preserve]` (#9126)
  Bump lz4 to v1.10.0 (#9127)
@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace usage of [Preserve] attribute in our code

2 participants