Description
Reference source files under "src/libraries/*/ref" are generated and updated on demand via the GenAPI tooling. GenAPI inspects the API surface area of a library's intermediate assembly and based on different inputs, emits the reference source file. One of the inputs to GenAPI is an attribute exclusion list to make it possible to avoid certain attributes from the reference source file. This option is used by our libraries and configured via this file: https://github.com/dotnet/runtime/blob/main/eng/DefaultGenApiDocIds.txt.
This means that the libraries' reference assemblies do not contain any of these attributes (unless someone manually updates the reference source file) and by that diverge from their counterpart (implementation assembly).
Admittedly, this makes implementing #58163 much harder but there's a more important present issue:
Since .NET 6, reference assemblies aren't part of our out-of-band packages anymore. That means that our customers when consuming our packages, bind/compile against the package's implementation assembly and not its reference assembly. Therefore the API surface area that we carefully maintain via the reference source files isn't the actual API surface area that our customers target.
As an example, the ObsoleteAttribute
and EditorBrowsableAttribute
types were until just recently not in sync between the reference and the implementation assembly and some of the recent obsoletion changes potentially didn't reach customers.
Note that Roslyn's RefOut/RefOnly feature doesn't omit attributes and the public api surface area of their emitted reference assemblies match their implementation assembly as closely as possible.
I suggest that we stop omitting attributes from the reference source so that we have an honest representation of the public api surface area that our customers bind on. FWIW as soon as we start leveraging Roslyn to generate our reference assemblies we won't be able to omit attributes anymore.