Should Enums be usable as Types? e.g.:
parameters:
- name: loc
type: [ Location ]
description: The location to check.
instead of using int and linking to the enum in the description:
parameters:
- name: loc
type: [ int ]
description: The [Location](/api/enums/Location) to check.
This means the signature of Card.IsLocation in the site would be displayed as Card.IsLocation(Card c, Location loc) instead of Card.IsLocation(Card c, int loc).
Pros:
- The allowed values are formalized and summarized nicely. Can also help static analyzers narrow down erroneous values.
- No need to redundantly link to the enum in the description, especially if the enum's name gets mentioned more than once. (Related: shorthand for linking to api entries)
Cons:
- Could confuse people expecting an "enum" to represent all allowed values when used as a type. For example, in the case of the Location enum, you could actually pass a combination of
LOCATION_ constants, e.g. LOCATION_MZONE|LOCATION_SZONE.
Should Enums be usable as Types? e.g.:
instead of using
intand linking to the enum in the description:This means the signature of
Card.IsLocationin the site would be displayed asCard.IsLocation(Card c, Location loc)instead ofCard.IsLocation(Card c, int loc).Pros:
Cons:
LOCATION_constants, e.g. LOCATION_MZONE|LOCATION_SZONE.