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

Proposal: XML doc comments for multiple results by tuple #13216

Closed
ufcpp opened this issue Aug 17, 2016 · 5 comments
Closed

Proposal: XML doc comments for multiple results by tuple #13216

ufcpp opened this issue Aug 17, 2016 · 5 comments
Assignees
Milestone

Comments

@ufcpp
Copy link
Contributor

ufcpp commented Aug 17, 2016

The most common use case of tuples is multiple results. Tuples are counterpart of method parameters and param tags in XML doc comments has a name attribute for each parameter. Thus, returns tags should have a name attribute too.

So far, I have to write doc comments as the following code. The method F has two results s and t, but the doc comment cannot have their names.

/// <summary>
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns>s is [description for s], t is [description for t]</returns>
static (int s, int t) F(int x, int y)
{
    return (x + y, x - y);
}

I'd like to write as the following. Let the returns tags have a name attribute for tuple element name.

/// <summary>
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns name="s">[description for s]</returns>
/// <returns name="t">[description for t]</returns>
static (int s, int t) F(int x, int y)
{
    return (x + y, x - y);
}
@dsaf
Copy link

dsaf commented Aug 17, 2016

I thought tuples are not recommended for public "user-facing" code?

@DavidArno
Copy link

@dsaf,

I thought tuples are not recommended for public "user-facing" code?

The very first example on the Quickstart guide for tuples (C# 7.0) page shows a public class with a public method that returns a tuple. So I'm not sure everyone is agreeing with that idea.

Do you have a reference though for that recommendation as I can't think of reason to adopt that approach, but no doubt I'm missing something.

@dsaf
Copy link

dsaf commented Aug 17, 2016

@DavidArno That sample is not an argument. However, given that naming metadata is emitted for compiled code, I guess there is no reason not to use them now. They will actually be more usable than common lambdas #12716!

@MartinJohns
Copy link

MartinJohns commented Aug 25, 2016

I thought tuples are not recommended for public "user-facing" code?

This would be a guideline, but it's not enforced by the compiler. We need a way to properly document return types.

@gafter gafter added this to the 2.1 milestone Aug 25, 2016
@ufcpp
Copy link
Contributor Author

ufcpp commented Feb 19, 2017

Ported to dotnet/csharplang#145

@ufcpp ufcpp closed this as completed Feb 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants