Skip to content

An option to always emit attribute symbols in Symbols API #3890

@auduchinok

Description

@auduchinok

We inspect symbol attributes when looking for tests or doing some analysis. Some attributes we're particularly interested in are erased in compiled code due to use of ConditionalAttribute and these attributes aren't emitted in Symbols API either.
Example of such attributes include NotNull, CanBeNull, UsedImplicitly from JetBrains.Annotations package. Ignoring the use of ConditionalAttribute in TypeChecker.fs helps in our case, makes it emit these attributes.

I'd like to add an option to always emit such attributes by ignoring condition. Would FSharpProjectOptions be a suitable place for it? It would require to pass a bool to TcConfigBuilder, TcConfig and then through type check calls.
Another option is to make it always emit such attributes by adding COMPILER_PUBLIC_API condition directive to the code below so all attributes would be available for analysis by clients. Also, another property for checking whether an attribute is actually emitted may be added to FSharpAttribute type.
https://github.com/Microsoft/visualfsharp/blob/fefae464c7fb4f15d5b0a19b2e8bfff123a692ca/src/fsharp/TypeChecker.fs#L10528-L10532

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions