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

AV1702: Add casing for tuples and local functions #107

Closed
bkoelman opened this issue Oct 17, 2017 · 1 comment
Closed

AV1702: Add casing for tuples and local functions #107

bkoelman opened this issue Oct 17, 2017 · 1 comment

Comments

@bkoelman
Copy link
Contributor

Existing rule:

Use proper casing for language elements (AV1702)
Then a table follows with casing per language element

New language features to consider:

  • tuples
    We should add casing for tuple element names to the table. But what the casing should be is not so obvious. Consider the next example:
class Example
{
    (string firstName, string lastName) GetData()
    {
        throw new NotImplementedException();
    }

    void Test1()
    {
        (string firstName, string lastName) = GetData();
        var name = firstName + " " + lastName; // prefer camelCase variables
    }

    void Test2()
    {
        var data = GetData();
        var name = data.firstName + " " + data.lastName; // prefer PascalCase tuple members
    }
}

The GetData method declares camelCase tuple element names. That nicely matches what the Test1 method expects. It deconstructs into local variables, which should be camelCase. So no issues up to here. But method Test2 now gets into a conflict, because it dots into the tuple element names. Because they read as instance properties, they should be PascalCase. To summarize: it depends on how the caller uses the return value of GetData to determine which casing is the "right" choice.

  • local functions
    We should add casing for local functions to the table. From what I have seen, they should match the casing of methods, which is Pascal casing.

Proposal:

  • Add tuple elements to the table. Choose camelCase.
  • Add local functions to the table. Choose PascalCase.
@dennisdoomen
Copy link
Owner

I see the dilemma, but I agree with your proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants