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.

Annotate Vanara libraries for trimming

See original GitHub issue

It is possible to manually mark Vanara for Trimming by adding hints to the csproj of every project that uses it, but this is laborious and repetitive. For example, if using just Vanara.PInvoke.User32 in a net6 app, I would need to add the following to the csproj of each exe to enable trimming:

<ItemGroup>
  <!-- trim Vanara.PInvoke.User32 and all of it's dependencies -->
  <TrimmableAssembly Include="Vanara.Core" />
  <TrimmableAssembly Include="Vanara.PInvoke.Gdi32" />
  <TrimmableAssembly Include="Vanara.PInvoke.Kernel32" />
  <TrimmableAssembly Include="Vanara.PInvoke.Shared" />
  <TrimmableAssembly Include="Vanara.PInvoke.User32" />
</ItemGroup>

It would be more convenient if Vanara libraries are already pre-annotated for trimming, so this happens automatically. This can be done by adding the [AssemblyMetadata("IsTrimmable", "True")] attribute to each Vanara assembly.

Additionally, it might be useful to annotate any functions which use reflection (if there are any) with RequiresUnreferencedCode and/or DynamicallyAccessedMembers, as appropriate, to give hints to the trimmer and produce better results/warnings.

See also

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dahallcommented, Dec 23, 2021

Great suggestions. I’ll look at including soon.

0reactions
dahallcommented, Nov 11, 2022

Over half of the COM interfaces in Vanara are extracted from C++ and do not have Type Library support. In the past, all COMWrapper generation only worked with typelibs. Maybe that will change, but I really doubt it. Let’s move this conversation to Discussion thread #341 which references this issue. This is a area that obviously needs more research and better support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Epic: .NET libraries are annotated to support trimming and ...
Epic: .NET libraries are annotated to support trimming and we provide trimming guidance for library authors #43543.
Read more >
Prepare .NET libraries for trimming
There are two ways to find trim warnings in your library: Enable project-specific trimming using the IsTrimmable property.
Read more >
Vantage Analytics Library User Guide | VAL | 2.2
Learn how the Vantage Analytics Library generates SQL for descriptive analytics, data transformation/engineering, hypothesis testing and ...
Read more >
'Label', a library to annotate your functions : r/rust
I created a library I called 'label' which you can use to annotate functions with a custom label. It allows you to iterate...
Read more >
DocViewer: Annotations library - Instructure Community
I want to use my comment library as I annotate student work, highlighting specific words and sentences on student essays and inserting my ......
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