Add `IsTrimmable` property for libraries
See original GitHub issueTwo things we want to get out of this:
- Enable feature switch defaults
- Define
IsTrimmable
attribute in generated sources
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Trimming options - .NET
In .NET 6, only assemblies that opted-in to trimming via [AssemblyMetadata("IsTrimmable", "True")] would be trimmed by default.
Read more >Marking libraries as IsTrimmable · Issue #24238 · Azure ...
I've filed this as Azure/azure-libraries-for-net#1274 where our ... just need to add an [AssemblyMetadata("IsTrimmable", "True")] attribute.
Read more >linker/docs/design/trimmed-assemblies.md at main
The only understood value is True (case-insensitive). Adding [assembly: AssemblyMetadata("IsTrimmable", "False")] will have no effect on the linker's behavior, ...
Read more >c# - Add Property to an existing class in a library
I want to add a Property to the Microsoft.Exchange.WebServices.Data.Folder class. The reason for this is, I need a bool Property "Selected" ...
Read more >Creating a Visual Studio property sheet to ease the use of ...
I would be happy to just support the default two "Debug" and "Release" for my library. I am new to this property sheet...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t really have an opinion here yet – I thought about it a bit and it just sounded like a tough problem. 😊
But I do think it’s important to think ahead to library trimming. I’d hate for us to make a choice which does the opposite of what a user would expect in those situations.
Re feature switches: Properly designed and implemented feature switch should not cause more warnings in libraries. Let’s assume there’s an API
DoSomethingWild
which is annotated with RUC. And it has a feature switch which disablesWildFeature
in the framework. CallingDoSomethingWild
is problematic regardless if the feature switch is on or off:This is for public feature switches. For internal feature switches (like startup hooks and so on), this is even simpler. There should be no way for the library to trigger the relevant code in the framework directly, so it should not get any warnings. Once built within an app, the behavior is entirely based on the app’s config.
In the future the only place where this might cause trouble is if we provide the full library mode for linker - that is running linker on a library with framework implementation assemblies. That would require correctly setting feature switches. But we don’t have that yet.
Re
IsTrimmable
on apps: I just tried withPublishTrimmed
on an app - it works perfectly. So I don’t have any problem at all with the proposed behavior. In the future we may decide to supportIsTrimmable
on the app as well, but it would effectively behave in the same way as on libs - add the attribute to the app’s assembly.