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

  • SEARCH
  • Home
  • 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 3500048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:41:10+00:00 2026-05-18T12:41:10+00:00

I have a class library that wraps the command line client for Mercurial. My

  • 0

I have a class library that wraps the command line client for Mercurial.

My intention is to implement support for all the built-in commands, but in addition to those, there’s a ton of extensions out there.

So I need to make my library extendable in the sense that both others and I can add support for extensions. I plan on adding support for some of the more popular and typical extensions (at the very least quite a few of those that come bundled with Mercurial), but I still want to be able to extend it from the outside.

At the moment, the syntax of a command look like this:

Repo.Execute(new CommitCommand
{
    Message = "Your commit message",
    AddRemove = true,
});

This, however, doesn’t lend itself very easily to extensions, without the programmer feeling that the extension is just a tacked on part.

For instance, let’s assume I expose a public collection of additional command line arguments, to that I could manually do this:

var cmd = new CommitCommand
{
    Message = "Your commit message",
    AddRemove = true,
};
cmd.Arguments.Add("--my-commit-extension");
Repo.Execute(cmd);

There seems to be no easy way for me to get that additional extension added in such a way that it can be set as part of the object initializer.

I’ve been thinking of adding, or perhaps switching, to a fluent interface syntax. In this case, you could write something like this:

Repo.Execute(new CommitCommand()
    .Message("Your commit message")
    .AddRemove()
    .MyCommitExtension());

However, I see people don’t like fluent interfaces, they feel they become too chatty.

What other options do I have?

What I want, basically:

  • One common syntax style
    • For both built-in things
    • As well as extensions added by users of my library

I envision that users of my library would extend it by adding new classes, and extension methods to get intellisense support, but extension methods can’t be used in object initializers, which means that all extensions look like some afterthought. That’s not what I want.

Any ideas are welcome.

  • 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-05-18T12:41:11+00:00Added an answer on May 18, 2026 at 12:41 pm

    I’m not familier with Mercurial and your question seems too general to address specifically, but I can address one particular comment.

    var cmd = new CommitCommand 
    { 
        Message = "Your commit message", 
        AddRemove = true, 
    }; 
    cmd.Arguments.Add("--my-commit-extension"); 
    Repo.Execute(cmd); 
    

    If CommitCommand.Arguments is IList<T> you already have the ability to use initializer syntax:

    class CommitCommand
    {
        public string Message { get; set; }
        public bool AddRemove { get; set; }
        public List<string> Arguments = new List<string>();
    }
    
    Repo.Execute(new CommitCommand
    {
        Message = "Your commit message",
        AddRemove = true,
        Arguments = { "--my-commit-extension", "--my-other-commit-extension" }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my own php data object class that wraps the mysqli library. It
I have a class library that has settings within an app.config. I know that
My Scenario I have a class library that is going to be called from
I have a signed class library that I want to create assemblies for via
I have a DAL class library that is included in my program as a
I have a class library project that references the version 4.1 Microsoft.Practices.Common dll. I
I have a class, which is part of a code library project that was
Hey we have a library class (lib/Mixpanel) that calls delayed job as follows: class
I have a Visual Studio 2010 solution that contains a class library (ProjectA) and
Let's say I have a project that is a class library. I have a

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.