Skip to content

Branch settings Validate() is never called #1897

@xfischer

Description

@xfischer

Describe the bug
When I override a branch setting using

public override ValidationResult Validate()

[EDIT] the base Validate() method is never called.

Here is a full example (taken from the docs) :

public class AddSettings : CommandSettings
{
    [CommandArgument(0, "[PROJECT]")]
    public string Project { get; set; }

    // This is never called
    public override ValidationResult Validate() => ValidationResult.Success();
}

public class AddPackageSettings : AddSettings
{
    [CommandArgument(0, "<PACKAGE_NAME>")]
    public string PackageName { get; set; }

    [CommandOption("-v|--version <VERSION>")]
    public string Version { get; set; }

    // This one is called
    public override ValidationResult Validate() => ValidationResult.Success();
}

public class AddReferenceSettings : AddSettings
{
    [CommandArgument(0, "<PROJECT_REFERENCE>")]
    public string ProjectReference { get; set; }

    // This one is called
    public override ValidationResult Validate() => ValidationResult.Success();
}

The problem is that I don't want to call base.Validate() for every child command as it complicates future additions to the project: every new setting would have to remember to call base.Validate().

I don't know if this is because it's declared as a branch or because it has child settings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo 🕑

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions