-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing attributes information on setter
of a property (in FSharpMemberOrFunctionOrValue
type)
#18157
Comments
Yeah, I don't think attributes are universally propagated to property methods. One of the reasons is that targets on attributes can be incorrect for methods. Which is fine from the runtime perspective, but semantically incorrect. |
You should be able to find the attribute on the symbol for the whole Property (and not just getter/setter). |
@T-Gro What do you mean by Symbol in this context? I tried to look but However, I found that there is a |
(locate the one you want via |
This explains why I had a strange result when removing
This seems possible indeed, it just make the code more verbose compared to the other case where let isErasedPropertySetter (memb : FSharpMemberOrFunctionOrValue) =
if memb.IsPropertySetterMethod then
match memb.DeclaringEntity with
| Some ent ->
// Remove the "set_" prefix
let logicalName = memb.LogicalName.Substring(4)
ent.MembersFunctionsAndValues
|> Seq.tryFind(fun (m : FSharpMemberOrFunctionOrValue) ->
m.LogicalName = logicalName && hasAttrib Atts.erase m.Attributes
)
|> Option.isSome
| _ -> false
else
false Depending on if the attributes should be propagated to the Thank you for the guidance. |
I think automatic propagation might be a breaking change, since AttributeTargets.Property and AttributeTargets.Method are two distinct options. https://learn.microsoft.com/en-us/dotnet/api/system.attributetargets?view=net-8.0 (i.e. it might lead to an error saying that attribute intended for properties only appeared on a method) |
Is it because in F# it could be a Method, and then map it to both a Method / Property in the "generated C#" code? My first thinking when learning about This is probably a naive idea and I don't know if this would be worth the effort or even fix the issue I originally faced. |
Hello,
I am not sure how to report this bug because this is related to the internals of F# Compiler itself, and happening inside of Fable transformation.
In Fable, we want to erase types and properties decorated with
[<Erase>]
.For example, this code should emit nothing.
However, currently it does not seems possible to do it for the
setter
because it is missing the[<Erase>]
attribute information:Please tell me, if I can do anything to reword my issue or help you identify the cause of this problem.
The text was updated successfully, but these errors were encountered: