Repository navigation
WIP: Adds support for attributes on modules, types and members - #467
Conversation
|
Thanks for taking care of this. It will help a lot!
I guess you mean FSharp.Formatting/src/FSharp.MetadataFormat/Main.fs Lines 27 to 67 in fd3cd49 If we really want this we would just add a "properly" typed member and either leave the existing one in place or add a forwarding property. We only really care about source code compat and not really about binary compat (as razor templates are re-compiled every time anyway). But I feel like we can leave it as-is as we currently only care about the obsolete information anyway.
Not sure what you mean there? How will changing the templates break stuff? Or do you mean using the templates with older versions of the library? I guess we don't really need to be compatible in that way, because people usually copy (and modify) the templates or they use the ones bundled with the nuget package (but again it will contain a compatible version).
Again I'm not sure I understand.
Honestly I'm not sure about that split either, maybe @tpetricek can enlighten us both? But if not I guess it will be fine ;) Probably only some implementation reason to make stuff easier.
Feed free to change to 2 I guess ;)
I hadn't opened this solution for a while now. |
It would not really break stuff but someone who uses the default template might be surprised. So the general question i should have asked is probably: Should a signature with attributes (not just obsolete) be the default in a template? Should it be optional? If none of the two we can leave it as is. Otherwise i can try to think of a reasonable default in a template.
After reading that again, i did not really understand it myself anymore ;P.
I can also change the file to use 4 if u dont mind. I like 4;) |
If people do not copy but reference our template, they should expect it to change and they decided to opt-in into new features (at least that's my standpoint on this)
Yes it is a regular type?
In the razor-template you can filter out and write custom code to handle that if it is useful for someone.
In general yes, but please in a separate PR for this. remembering how some modules are written I expect some modules to go "quite a bit to the right" and might need some additional refactoring if you really want to start this "mess" ;) |
|
@Krzysztof-Cieslak thanks for checking, apparently i am doing something wrong :(.
of course. Sorry, i did not really make clear what i meant. As far as i can see u just cant tell if a type is a module or a class or an attribute right now. So if there were support for that the naming might be confusing. I will try to come up with something for razor that looks OK. I do like how DocFx generated pages handle attributes etc. Example @matthid do u know how i can get proper intellisense for the razor templates? Or is that just me again and it is working for you. VS does not recognize the Model. |
I think basically the logic is: If some base class in the hierarchy is
Don't waste too much time on this. It worked with a hack on older Visual Studio versions but honestly I'd like to throw Razor away eventually. My current thinking is to replace (= mark obsolete) Razor short/mid-term with https://mangelmaxime.github.io/Fulma/#fulma |
matthid
left a comment
There was a problem hiding this comment.
Can you update the RELEASE_NOTES.md file - it will be released on the appveyor feed automatically after merging...
Feel free to let me know when this is ready (we can do the templates in a separate PR if we want)
Maybe move Razor to separate NuGet package so people that want it can continue using it? It should be fairly simple since all Razor code is in its own project? While I love the idea of removing it I think it may be bit too big change for many people. |
Yes it will still be there but it won't be the first choice anymore |
|
@Krzysztof-Cieslak Even more important would be to get rid of the requirement that we have to provide all dependencies to FCS. This would remove quite some churn from the ecosystem |
yes, but that is probably not something u want to check in razor/whatever generates html. Fulma templates sound fun :). Not sure if that is relevant in any form, but DocFx is currently building a new version. I am hoping they add proper F# support. As far as i can see they are using the asp.net core razor templates as an engine. Maybe there is some interest in cooperating with them (if that is even possible)
I can do that. I am working on razor still, so it might take a bit. I have a one more question though:
|
Maybe, but I'd assume creating the yaml is actually the hardest part, writing the template is not too hard and FSF provides full flexibility. We would probably loose tool tips when hovering over F# code.
Answering in-line |
|
|
||
| /// Gets a value indicating whether this attribute the System.ObsoleteAttribute | ||
| member x.IsObsoleteAttribute = | ||
| x.FullName = "System.ObsoleteAttribute" |
| x.FullName = "System.ObsoleteAttribute" | ||
|
|
||
| /// Returns the obsolete message, when this attribute is the System.ObsoleteAttribute. When its not or no message was specified, an empty string is returned | ||
| member x.ObsoleteMessage = |
There was a problem hiding this comment.
What do u mean with move this up?
| static member FormatAttributesFullName(attributes:seq<Attribute>, ?removeAttributeSuffix:bool) = | ||
| String.Join("\n", attributes |> Seq.map (fun a -> a.FormatFullName(?removeAttributeSuffix = removeAttributeSuffix))) | ||
| /// Tries to find the System.ObsoleteAttribute and return its obsolete message | ||
| static member TryGetObsoleteMessage(attributes:seq<Attribute>)= |
| /// Gets a value indicating whether this member is obsolete | ||
| member x.IsObsolete = | ||
| x.Attributes | ||
| |> Seq.exists (fun a -> a.IsObsoleteAttribute) |
|
|
||
| /// Returns the obsolete message, when this member is obsolete. When its not or no message was specified, an empty string is returned | ||
| member x.ObsoleteMessage = | ||
| Attribute.TryGetObsoleteMessage(x.Attributes) |
There was a problem hiding this comment.
In-line the required code here.
I see that this is not really "clean" but I have no suggestion on how to improve.
Strictly speaking I'm fine with either way. Note that extensions only work when using regular C# extension methods and might lead to problems with the razor template, so I guess leaving this a member is as good as it gets.
One can only dream ;-) |
a4497f6 to
a6abb2d
Compare
|
Ok i think i am done. |
The problem is that this are XML-comments if you do not write |
| { | ||
| <div class="alert alert-warning"> | ||
| <strong>WARNING: </strong> This API is obsolete | ||
| </div> |
There was a problem hiding this comment.
Should we include the obsolete message (as you have already implemented that)?
There was a problem hiding this comment.
We can. The actual message is also listed under the attributes. So if u hover over a method or click into a type/module u can see it there. But i can also include it here.
For Fake i would definitely include it as there are so many obsolete types. But in most APIS there are not that many.
|
So this is ready? |
|
1 sec. I will fix the escaping in the comments and add add the message |
a6abb2d to
fc3c431
Compare
|
Sorry, that should be it. |
No need to be sorry I just couldn't wait to merge ;)
Yeah maybe an fsharp.formatting bug ;) Thanks a lot for this - this is indeed very useful! |

Hi,
i have added support for attributes declared on types, members and modules.
There are also some functions to support the System.ObsoleteAttribute so it is easier to mark stuff as obsolete in documentation.
There is some stuff i am not quite sure about:
Some side notes: