-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Make System.Transactions.Local trimmable on Windows #75031
Comments
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr Issue Details#72051 added As #74506 points out, this caused a size regression on WASM. Subsequently #74828 fixed it to only be However, Windows is still a problem. Setting As part of this, we should probably add a rule to our build that says "All shared fx libraries should be 'IsTrimmable=true' on all platforms." It is possible (I haven't confirmed) that not being able to trim a shared fx library will cause ILLinker warnings in every publish when PublishTrimmed or PublishAOT is
|
The library was marked as |
@eerhardt @jkotas the distributed transactions part of System.Transactions - which is what does the COM interop - is something we ported mainly in order to unblock .NET Framework users and allow them to move to modern .NET. We don't expect to invest in this component in the future; if a significant need is signaled for cross-platform distributed transactions (#71769), we'll consider implementing new support for that, but that would likely be a separate API, and would most likely not do COM interop in any direct way. So I generally don't see us investing a lot in Sys.Tx going forward, and would definitely avoid the effort to port the COM interop here to be trimming-compatible (via ComWrappers, if I understand correctly), unless it's absolutely necessary.
Does this mean that any Windows user gets an untrimmed System.Transactions regardless of whether they use any type in that assembly? I was under the impression that at least assembly-level trimming should work. Note that System.Transactions does have an unfortunate design whereby distributed transaction code paths - which require the COM interop - aren't clearly distinguishable (e.g. by the linker) from those which aren't. In other words, some users use Sys.Tx only as a way to manage non-distributed transactions in an ambient way (via TransactionScope), and Sys.Tx implicitly escaltes to a distributed transaction needed (i.e. when more than one database is enlisted in the transaction). That makes it impossible to put [RequiresUnreferencedCode] only on the code paths which require the COM interop. |
I think it's OK if we decide to not support trimming for Sys.Tx (depends on scenarios and resource availability and so - also if we get ComWrappers source generated it might become a lot easier). In that case we should annotate the APIs which can lead to the COM usage with |
System.Data.Common references System.Transactions.Local. In the current state, I believe that pretty much any database access will generate trim warnings due to System.Transactions.Local reference. |
@jkotas that's true, but is there a reason we can't just leave the assembly with IsTrimmable=false? Wouldn't the entire assembly be trimmed away if the user doesn't use any Sys.Tx (or System.Data) APIs? If so, that sounds like it could be an acceptable state of affairs until we have ComWrappers source generation etc. |
In The problem only exists in partial trimming mode. Blazor uses partial trimming mode and that's why it showed up there. It would not be enough just mark it as |
Thanks for the info, I wasn't aware that I'm not sure what our options here are... I think it's probably too late to switch to ComWrappers for 7.0. If this can be somehow handled by marking the assembly |
Add the necessary DynamicDependency attributes to System.Transaction.Local in order for it to work with trimming on Windows. Also fix the UnconditionalSuppressMessage attribute to have a valid justification for suppressing, now that we are preserving the necessary interfaces for COM Interop. Fix dotnet#75031
* Make System.Transactions.Local trimmable on Windows Remove `IsTrimmable=false` from the project, so this assembly is still trimmed with `partial` trimming on Windows. Add a "LibraryBuild" ILLink warning, so when the distributed transaction code is not trimmed, the app developer gets a warning that it is not guaranteed to work. Fix #75031 * Fix x86 build. Move the ILLink suppression to a method that is completely trimmed on x86.
* Make System.Transactions.Local trimmable on Windows Remove `IsTrimmable=false` from the project, so this assembly is still trimmed with `partial` trimming on Windows. Add a "LibraryBuild" ILLink warning, so when the distributed transaction code is not trimmed, the app developer gets a warning that it is not guaranteed to work. Fix dotnet#75031 * Fix x86 build. Move the ILLink suppression to a method that is completely trimmed on x86.
* Make System.Transactions.Local trimmable on Windows Remove `IsTrimmable=false` from the project, so this assembly is still trimmed with `partial` trimming on Windows. Add a "LibraryBuild" ILLink warning, so when the distributed transaction code is not trimmed, the app developer gets a warning that it is not guaranteed to work. Fix #75031 * Fix x86 build. Move the ILLink suppression to a method that is completely trimmed on x86.
#72051 added
IsTrimmable=false
toSystem.Transactions.Local
, which is an assembly in the shared framework. This means it is referenced for every app. Users don't opt-in and can't opt-out of referencing it in their app.As #74506 points out, this caused a size regression on WASM. Subsequently #74828 fixed it to only be
IsTrimmable=false
on non-Windows.However, Windows is still a problem. Setting
IsTrimmable=false
on any shared framework library is not correct. Instead, we need to be marking the unsafe APIs with[RequiresUnreferencedCode]
and need to be using trimmer descriptors as necessary in order to make the library build not trim needed, unreferenced code.As part of this, we should probably add a rule to our build that says "All shared fx libraries should be 'IsTrimmable=true' on all platforms."
The text was updated successfully, but these errors were encountered: