-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Description column (#33) #35
base: master
Are you sure you want to change the base?
Conversation
…enum-to-lookup into DescriptionColumn Conflicts: ExampleUsage/EnumExample.cs
I haven't forgotten about this, will look when I get some spare time. Thanks for the PR! |
Looks like your indents are spaces, but this project is using my personal preference of tabs. See https://github.com/timabell/ef-enum-to-lookup/blob/master/.editorconfig |
You've done something slightly odd on the history of your branch (looking at the history in gitk). It diverges with two almost identical commits and then merges again. It would be better if your branch just had a single commit with your changes I think. |
I've started a maintenance branch for v1 (called v1), and master is now for the v2 release. |
@@ -100,6 +100,9 @@ | |||
<Name>EfEnumToLookup</Name> | |||
</ProjectReference> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you tell me what this is? It's not something I recognise. Cheers
I found this https://connect.microsoft.com/VisualStudio/feedback/details/800245/vs2013rc-adds-to-vs2012-c-project-section-itemgroup but it's up to microsoft's usual standard of providing zero useful information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think VS 2015 is trying to be "helpful". I'm not sure why this was added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typical, lol. I'm still on 2013 for the moment. I'd take this out until we at least know what it does.
I've created a temporary branch while I look closer at the code you've provided and try it out on my machine. https://github.com/timabell/ef-enum-to-lookup/tree/description-column - this fixes the whitespace issues. |
@@ -111,12 +117,12 @@ private string PopulateLookup(LookupData lookup) | |||
WHEN MATCHED AND src.Name <> dst.Name THEN | |||
UPDATE SET Name = src.Name | |||
WHEN NOT MATCHED THEN | |||
INSERT (Id, Name) | |||
VALUES (src.Id, src.Name) | |||
INSERT (Id, Name, Description) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't pick up changes in description due to the "when matched" clause above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. The "when matched" needs to be updated to catch description changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this indicates we could do with extending the test suite to cover add/remove/updating the lookup rows in the db as the model is changed.
plan: run apply, directly manipulate the db to add/edit/remove, assert changed (just to avoid false positive if this step silently failed), run apply again, assert that table was returned to original state
So having had a closer look at the overall change I like it, and thanks for your work on this. Mostly my feedback is just trivia. There's one bigger thing that's bugging me, which is that as far as I can tell it's no longer possible to override the strings that will go in the "Name" column, which is a feature I'd like to keep. I think you're right about making the description attribute control the description column instead of the name as it's more consistent, even though it's a fairly major change from v1. I think I'd like to see a solution to this problem before this gets merged in. My first thought is supporting a second attribute to control the name field; I'm not sure if there's an existing one that would be suitable, or whether we should create a new one, I'd probably want to do a bit of hunting in the microsoft APIs to see what's already out there. |
Could we use System.ComponentModel.DataAnnotations.DisplayAttribute? Like this: public enum Shape |
I've had a read about it and that looks like a good choice to me. |
"enum" could confuse people with c# enums pr #35
I'm out of time/energy for the moment. It'd definitely be good to get this cleaned up and merged in. Todo:
|
} | ||
|
||
[Test] | ||
public void CheckIfDescriptionColumnsExists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticed, this test is in the wrong project, this project is an example for users of the library of how it's intended to be used, not just generic unit test code, this needs to go in the EfEnumToLookupTests project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
TestConfiguration is an integration test and not an unit test. It might be good thing to separate unit test from integration tests a little more clearly I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right the test suite is a little inelegant at the moment and could do with tidying up and splitting out. I haven't got as far as thinking about the set of variations it needs to cover, it exists in its current form purely to enable me to test-drive the development to avoid regressions.
contribution from PR #35 - Svein Helge <[email protected]> fixed-up, squashed, rewritten by Tim Abell still stuff that needs fixing up in this commit - see pull request for details
my description-column branch has been squashed & rebased onto the latest master, still more to do on it but that's now the best place to start |
I did some testing and in this branch. I used DisplayAttribute and added some more unit tests. Also used more SqlQuery in the tests. https://github.com/sveinhelge/ef-enum-to-lookup/tree/description-column We can probably used some of the code. |
Thanks @sveinhelge At a glance it looks promising, couple of bits of feedback:
Thanks for your efforts on this, it is appreciated. I hope you don't mind me being picky, this is a showcase project for me, and the code in it needs to be something I'd be comfortable looking after in the longer term. |
EnumDisplayName is a good name. This was a "offroad" test. So normally I would based it on master. Picky makes things better. So no problem. |
#33
This will be a breaking change in of terms usage of Description on Enum named constants.
Description will now be used as column and not to override name.
public enum Shape
{
Square,
[System.ComponentModel.Description("Round it is!")]
Round
}