Skip to content
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

FeatureRequest: Support XML Comments on local methods #2110

Open
YairHalberstadt opened this issue Dec 28, 2018 · 12 comments
Open

FeatureRequest: Support XML Comments on local methods #2110

YairHalberstadt opened this issue Dec 28, 2018 · 12 comments
Assignees
Labels
Needs Approved Specification This issue needs an LDM-approved specification Proposal champion Smallish Feature
Milestone

Comments

@YairHalberstadt
Copy link
Contributor

Currently XML comments are invalid on local methods. As a result, if you add XML comments to local methods, they don't show up in intellisense.

Besides, I find it useful to document behavior of local methods, and having a fixed specification as to how to do so would be useful, rather than an ad-hoc comment system.

(Using XML comments on a local method also generates a warning in resharper that they are not placed on a valid language element, though obviously this isn't the relevant forum for that issue).

@Richiban
Copy link

I'm not really sure why you would ever want XML docs on local methods... since they're normally used for documenting the public API of your library and local methods are, by definition, not public.

Can you give us an example of where you'd like XML comments to show up? Are you using it to document the throwing of exceptions rather than comments?

@YairHalberstadt
Copy link
Contributor Author

I'm using it to say things like what the parameters do, contracts, what it might throw, what the method does, and random comments like "Performance Critical"

I could of course use ad hoc comments to do all that, but I like the formal system of XML comments.

I will point out that XML comments are allowed on private methods, where the same arguments could apply.

@Richiban
Copy link

I know it seems that the line is very thin between private and local methods but it's the same as the difference between fields/properties and local variables, isn't it? ... still I think that local methods are small (they're inside another method!) so you can just look at it to see what it does.

@YairHalberstadt
Copy link
Contributor Author

I don't claim it's particularly important.

It's more that if it's easy to do, I can't see any disadvantages to it, and I would find it useful. It doesn't add any complexity to the language.

@YairHalberstadt
Copy link
Contributor Author

And yes, you can look inside the method, but you would still need a comment along the lines of \\ parameter X must be initialised before calling this method. XML docs give a formal structure for that kind of comment, and intellisense is quite helpful for that kind of thing.

@YairHalberstadt
Copy link
Contributor Author

For anyone on the LDM, Roslyn team:

With this the sort of thing that if I were to hypothetically implement it and raise a PR, would it likely be merged, or does this still need the LDM to discuss it?

@CyrusNajmabadi
Copy link
Member

For anyone on the LDM, Roslyn team:

With this the sort of thing that if I were to hypothetically implement it and raise a PR, would it likely be merged, or does this still need the LDM to discuss it?

Not on the LDM. However, my take on it is that this looks like this could be entirely done as a tooling change, with no need for any sort of language change. The more i think about it, the more i think it's basically entirely reasonable for any symbol (including locals) to have a doc-comment on it that can be used for tool-time help. These local doc-comments might never be emitted to a doc-file, but could still be used to inform the tooling side of things.

I would recommend closing this issue and opening a request over at dotnet/roslyn.

@YairHalberstadt
Copy link
Contributor Author

@CyrusNajmabadi
Thanks. Will do.

@gafter
Copy link
Member

gafter commented Jul 16, 2019

See also #2110

I am championing this.

@gafter gafter self-assigned this Jul 16, 2019
@gafter gafter added this to TRIAGE NEEDED in Language Version Planning Jul 16, 2019
@MadsTorgersen MadsTorgersen moved this from TRIAGE NEEDED to Any Time in Language Version Planning Jul 17, 2019
@gafter gafter added this to the Any Time milestone Jul 17, 2019
@gafter gafter removed their assignment Mar 13, 2020
@gafter gafter self-assigned this Apr 3, 2020
@DarkSystemCD
Copy link

would think the description for XML Comments be like ::

XML Comments allows the developer to better organize the code;
Annotate namespace,classes,methods,variables,local functions,[...]
the comments then are removed from the compilation which and external file could also being referenced in code;

anything else about the productivity with XML Comments are manifestations from internet,
which means the feature should be a development time resource not a product;

example of product comment

I'm not really sure why you would ever want XML docs on local methods... [...]

@dirkbaum
Copy link

I would find it to be a very helpful to be able to document local functions and have the documentation exposed in the IDE intellisense.

@Neme12
Copy link

Neme12 commented May 15, 2022

See also #2110

I am championing this.

You linked to the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Approved Specification This issue needs an LDM-approved specification Proposal champion Smallish Feature
Projects
None yet
Development

No branches or pull requests

8 participants