Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetDiscreteEnum for when the enum is not used as property #798

Merged
merged 5 commits into from
May 20, 2020

Conversation

matthiaslischka
Copy link
Contributor

@matthiaslischka matthiaslischka commented Feb 28, 2017

Hi,
the tableRow extension method GetEnum<T> surprised me since it does not work as I would have expected by signature. Naturally I would have guessed that T is the enum I want to receive. Turned out it is the class where the enum I want to parse has to be used as property and the table row header represents the property name by which the enum is found.

So the very basic thing that should be changed is adding a generic type constraint on the GetEnum<T> method to allow only where T is class - preventing calls where T is an enum.

Furthermore I added a method of how I would have expected the GetEnum to work. Called it GetDiscreteEnum<T>. Usable for whenever the enum I want to parse is not mapped as property in a suitable class. Also offers the possibility of a default value for when the column is not always used in the feature step.

BR, Matthias

@SabotageAndi
Copy link
Contributor

@darrencauthon Assists is your baby. ;-)

@matthiaslischka
Copy link
Contributor Author

matthiaslischka commented Mar 13, 2017

I want to stress once more that the GetEnum<T> does not work as one would guess.
The way cleaner solution would be to change GetEnum so that T is the Enum and not the Class Type as it is right now. There should be a extension like e.g. GetEnumFromClass<ClassType> if this behavior shall be available any longer.

However, since this is a actively used framework I wasn't sure how you go with breaking changes. Therefore I tried to only implement the minimum changes that are necessary IMHO.

Open for discussion...

BR Matthias

@304NotModified
Copy link
Contributor

304NotModified commented Apr 13, 2020

Is there a reason why this never has been merged? (Could think of some issues, but those will be wild guesses)

@SabotageAndi
Copy link
Contributor

@304NotModified No idea why this is still open.
I resolved the merge conflict. When the build runs through, I will merge this. Better late than never.

matthiaslischka and others added 3 commits May 5, 2020 15:34
…class.

Generic type constraint to point out the purpose of the GetEnum and GetDiscreteEnum method.
@304NotModified
Copy link
Contributor

Green! But the changelog is also needed. Unfortunately I can't push to the branch.

I think should be under API changes: @SabotageAndi

+ (breaking) tableRow.GetEnum<T>(..) has now a class contraint on T
+ (breaking) tableRow.GetTheEnumValue<T>(..) has now a class contraint on T
+ added tableRow.GetDiscreteEnum<T>

@SabotageAndi
Copy link
Contributor

Finally, after more than 3 years this PR is merged. Sorry @matthiaslischka that it took so long.

@SabotageAndi SabotageAndi merged commit f69a503 into SpecFlowOSS:master May 20, 2020
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.

4 participants