Skip to content

ArgumentException - Parameter, Message parameters #1

@IgorWolbers

Description

@IgorWolbers

Converting

Contract.Requires<ArgumentException>(expression, message); 

yields this when executing the tool with the Convert option:

if (expression) { throw new ArgumentException("parameter", "message"); } 

But the string,string constructor for ArgumentException is the opposite, the correct generated line should be:

if (expression) { throw new ArgumentException("message", "parameter"); } 

In the case where ArgumentNullException is used instead of ArgumentException it is correct as that order happens to be the inverse. I am guessing it was 2 different developers that wrote those 2 classes a long time ago

Thanks for your time in writing this extension/package and it is a shame Code Contracts never really took off (IMO).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions