runtime: New ILLinker attributes are not available outside of net5.0

We’ve added a few attributes to net5.0 to help with linker analysis. See

  • #33861 - DynamicallyAccessedMembersAttribute
  • #35339 - UnconditionalSuppressMessageAttribute
  • #30902 - DynamicDependencyAttribute

If a netstandard library needs to add these annotations, it will be forced to cross-compile to net5.0 just so it can add these attributes. And then of course add #if to all the attribute declarations.

We should make these attributes available down-level. They are simple attributes, and don’t have dependencies on newer APIs, so they should be able to be supported on netstandard1.0.

However, this would mean shipping a new package.

An alternative to this would be developers would need to declare the internal attributes themselves (but not in net5.0, since that would conflict).

cc @vitek-karas @marek-safar @stephentoub @terrajobst @ericstj

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

In any event, I don’t think it’s worthwhile doing (1) currently. All of the work necessary to make the libraries linker-friendly is in .NET 5; the experience of working in alternate runtimes is going to be far less than ideal, both in terms of resulting size and in terms of warnings. I suggest we do (2) above, as it’s a) straightforward, b) doesn’t require a ton of ifdefing, and c) will still include the attributes in any netstandard libs we do ship and that use them. And we can always graduate from that to (1) if the situation proves it valuable.