used literal argument is not named

4 posts, 0 answers
  1. Thomas Weissert
    Thomas Weissert avatar
    2 posts
    Member since:
    Oct 2004

    Posted 28 Jul 2015 Link to this post



    Just upgraded to Q2 2015 SP1 (2015.2.724.2) in VS 2015

     Now I'm getting the warning above all over the place.

     code example:

            var searcher = new DirectorySearcher(root, string.Format(CultureInfo.InvariantCulture,

    , attributeMapUsername, username));​

    What is the fix?




  2. Najid Hanif
    Najid Hanif avatar
    92 posts
    Member since:
    Jul 2011

    Posted 28 Jul 2015 in reply to Thomas Weissert Link to this post

    I just ran into this as well. You can have JustCode ignore this in the options. See screen shot for where this is located.
  3. DevCraft R3 2016 release webinar banner
  4. Thomas Weissert
    Thomas Weissert avatar
    2 posts
    Member since:
    Oct 2004

    Posted 28 Jul 2015 in reply to Najid Hanif Link to this post

    Thanks, I did find this way out. But I'm wondering what is the purpose of this warning?  What is the preferred code technique?
  5. Nikolay Valchev
    Nikolay Valchev avatar
    72 posts

    Posted 31 Jul 2015 Link to this post


    We added this warning for people who prefer to name all literal arguments. It is considered by some that it improves readability and makes the code more descriptive and understandable. Lets take this code for example:

    SyntaxToken token = syntaxTree.GetTouchingToken(0, null, cancellationToken, true);

    Without looking at or knowing the signature of GetTouchingToken, could you be sure what the literals stand for? Yes, the digit is predictable but the rest two literals might mean so many things. Let's look of the code when named arguments are used.

    SyntaxToken token = syntaxTree.GetTouchingToken(position: 0,
                                  condition: null,
                                  cancellationToken : cancellationToken,
                                  findInsideTrivia: true);

    It looks way more understandable. Of course, this is a personal/team preference, we do not want to impose it as a better practice, hence there is a setting that disables the warning.

    Nikolay Valchev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top