question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `IsTrimmable` property for libraries

See original GitHub issue

Two things we want to get out of this:

  • Enable feature switch defaults
  • Define IsTrimmable attribute in generated sources

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
agockecommented, May 13, 2021

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.

1reaction
vitek-karascommented, May 13, 2021

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 disables WildFeature in the framework. Calling DoSomethingWild is problematic regardless if the feature switch is on or off:

  • If the feature switch is on - it will not work when trimmed -> produces a warning that trimming is problematic
  • If the feature switch is off - the API should typically throw -> producing a warning when trimming is not ideal, but it doesn’t hurt (the API won’t do what it’s supposed to do anyway).

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 with PublishTrimmed 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 support IsTrimmable 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found