Skip to content

docs: fix Manager parent class in README example - #578

Open
jasonfigueroa wants to merge 1 commit into
ardalis:mainfrom
jasonfigueroa:fix-readme-employee-example
Open

jasonfigueroa wants to merge 1 commit into
ardalis:mainfrom
jasonfigueroa:fix-readme-employee-example

Conversation

@jasonfigueroa

Copy link
Copy Markdown

Fixes #401.

The README's Manager example does not compile when copied alongside the EmployeeType example. It references ManagerType, a private nested class, calls BonusSize as a method, declares the bonus as string instead of decimal, and assigns to an undefined _bonusSize_ field.

Use the public EmployeeType for the stored value and TryFromName lookup. Initialize the value to EmployeeType.Manager so callers can read the properties immediately. Expose BonusSize as a read-only decimal property.

Verification used a standalone .NET 10 console project that compiled the README snippets against the local SmartEnum source. Successive builds reproduced these compiler errors:

  • CS0246 for the unresolved ManagerType reference.
  • CS0122 after qualifying the private type as EmployeeType.ManagerType.
  • CS1955 for calling BonusSize as a method.
  • CS0029 for returning decimal through a string property.
  • CS0103 for the undefined _bonusSize_ field.

The corrected example compiled and passed runtime checks. A new instance returned Manager with a bonus of 10000. Setting Type to "assistant" resolved Assistant with a bonus of 1000. An unknown name threw the expected exception and preserved the previous selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

README Example does not compile

1 participant