Skip to content

Attributes from implementation file are not seen by the compiler #19560

@auduchinok

Description

@auduchinok

Consider an F# library with a signature and an implementation files:

module Module

val f: unit -> unit
module Module

[<NoDynamicInvocation>]
let f () =
    ()

When checking the implementation against the signature, the attribute is kept in the implementation and is emitted in .NET metadata. It's not copied to signature and is effectively hidden from F# point of view. This is similar to how values themselves are hidden when not present in the signature files, so it can be considered expected. However, analyzing these attributes may be needed by the compiler or the tooling, but it's not possible due to them being completely removed in F# metadata.

There's a place where attributes are copied from the signature to the implementation, so both are present in IL:

else checkAttribs aenv implVal.Attribs sigVal.Attribs (fun attribs -> implVal.SetAttribs attribs)

I propose we also copy the attributes in the other direction, so the compiler and IDEs could analyze them. Are there any objections in doing so?

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions