Skip to content

Immutable options type ctor not seen #499

@JGCreator

Description

@JGCreator
class Program
    {
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments<CmdOptions>(args)
                  .WithNotParsed(e => Environment.Exit(e.Count()))
                  .WithParsed(WriteReportData);
        }
    }

    public class CmdOptions
    {
        public CmdOptions(string user, string token, int releaseId, int buildId)
        {
            User = user;
            Token = token;
            ReleaseId = releaseId;
            BuildId = buildId;
        }

        [Option('b', "buildid", Required = true, HelpText = "The build id associated with the release")]
        public int BuildId { get; }

        [Option('r', "releaseid", Required = true, HelpText = "The release id for fetching")]
        public int ReleaseId { get; }

        [Option('t', "token", Required = true, HelpText = "The authentication token (agent oAuth or user PAT)")]
        public string Token { get; }

        [Option('u', "user", Required = false, Default = "", HelpText = "Username value to send when using basic authentication with a PAT")]
        public string User { get; }
    }

Arguments debugged:
-u userFirstName -r 123 -b 4567 -t someToken

Exception thrown:
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions