Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8632725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:23:28+00:00 2026-06-12T09:23:28+00:00

When creating a named argument for a constructor, I am running into a problem

  • 0

When creating a named argument for a constructor, I am running into a problem where the only constructors avaliable to me ask for a refOrOutKeyword SyntaxToken. Passing null is not allowed, moreover Syntax.ParseToken("") fails. Syntax.Token(SyntaxKind.RefKeyword) and Syntax.Token(SyntaxKind.OutKeyword) are both unsuitable, as they insert either ref or out:

var ctorArgs = Syntax.ArgumentList();
var ctor = enclosingType.Members
                        .OfType<ConstructorDeclarationSyntax>()
                        .OrderBy(cc => cc.ParameterList.Parameters.Count)
                        .FirstOrDefault();
if (ctor != null)
{
    //
    // Summary:
    //     Creates a new ArgumentSyntax instance.
    // public static ArgumentSyntax Argument(
    //     NameColonSyntax nameColon,
    //     SyntaxToken refOrOutKeyword,
    // ExpressionSyntax expression);
    ctorArgs.AddArguments((
        from param in ctor.ParameterList.Parameters
        select Syntax.Argument(
                Syntax.NameColon(param.Identifier.ValueText),
                Syntax.ParseToken("") /* <- what to put here */, 
                Syntax.DefaultExpression(param.Type))
    ).ToArray());
}

I’ve not found any suitable documentation to elucidate how I can create named arguments either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:23:29+00:00Added an answer on June 12, 2026 at 9:23 am

    Usually, looking how is such code represented at runtime helps. If I parse code that uses named arguments and look at RefOrOutKeyword.Kind of the ArgumentSyntax in question, it’s None. So, you need to do the same thing: create a SyntaxToken with None as its Kind:

    Syntax.Token(SyntaxKind.None)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a temp image always named 1.png under specific folder and once i
I am creating a MKMapView in a method named generateMap. From inside viewDidLoad, this
I implemented Forms authentication by creating Default.aspx and custom login page named login.aspx .
In SharePoint, a file named ONET.xml is usually needed when creating a custom site
In VS2008, you could enable right-margin marks by creating a string registry entry named
I am trying to inject an IList into a constructor and want to know
I want to inherit to extend java.util.logging.Logger . The only visible constructor is protected
I am creating a yui3 widget and I keep getting this error: this.constructor.NAME is
When creating a subversion repo a number of hook template files are dropped into
I have the following bean defined: <bean id=myBean class=com.me.myapp.Widget> <constructor-arg name=fizz value=null/> <constructor-arg name=buzz

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.