autorest icon indicating copy to clipboard operation
autorest copied to clipboard

change summary on validate method

Open brenovieira opened this issue 11 years ago • 2 comments

The generated code says the Validate method throw ArgumentException, but that is not true.

/// <summary>
/// Validate the object. Throws ArgumentException or ArgumentNullException if validation fails.
/// </summary>
public virtual void Validate()
{
    if (Id == null)
    {
        throw new ValidationException(ValidationRules.CannotBeNull, "Id");
    }
}

note: ValidateException doesn't inherit from ArgumentException nor ArgumentNullException.

Let me know if I can provide a PR to this.

brenovieira avatar Oct 30 '15 21:10 brenovieira

Good catch! If you can submit a PR that would be great.

stankovski avatar Oct 30 '15 23:10 stankovski

What is the proposed fix? To update the comment or change Validate to throw ArgumentNullException/ArgumentException? The latter would better follow the principle of least surprise.

bitsforthought avatar Nov 11 '15 03:11 bitsforthought