Closed ghost closed 7 years ago
Hi RobThree,
I have changed the code accordingly.
I think that AppVeyor cannot handle C# 6 language features. It errors over the collection initializer that I used: https://github.com/keesdewit82/SimpleFeedReader/blob/master/SimpleFeedReader/FeedItem.cs#L41
It's not AppVeyor at fault here; it is/was the solution file being VS2013. I updated the solution file and, as you can see, the build now passes. I'll merge/release a new version soon. Again: thanks for the PR and implementing the changes!
Bumping this issue; this does appear to be a problem in my VS (2015) project:
Property or indexer 'FeedItem.Images' cannot be assigned to -- it is read only
Can you please provide a testcase to reproduce the problem?
It has no setter because collection properties should not have setters.
Alright, my testcase: https://gist.github.com/theNailz/5386edf719dfd568af6e60df17b15daf
Copied the default normalizer source into my own class, and use the normalizer in my feedreader. Error on line 65
Makes sense. From the hip.... I guess making it protected instead of internal should probably solve it?
Yep, that way we can pass it in through the constructor, and set it from there.
Protected would make sense if you use FeedItem as base class. FeedItem is not sealed so you should be allowed to set the Images property from the inheriting class, thus making protected the right access modifier in this case.
So we all agree on making it protected
? I'm also fine making it public
; the rest of the properties have public setters too so I don't think it's that big of a problem.
I would make it protected. It also depends on what guidelines you are used to work with. This is one of them https://msdn.microsoft.com/en-us/library/ms182327.aspx
Also @theNailz Small advice: You should not be passing stateful objects through the constructor.
Protected won't suffice since even the DefaultFeedItemNormalizer
won't be able to create a FeedItem.
I'm going for public; the FeedItem is nothing more than a DTO (or POCO if you will) anyway.
No problem. Making it public will work. In my opinion the right way is to use the AddRange method in the DefaultFeedItemNormalizer class to add the images. Its up to you Rob ;)
AddRange
implies an IList
implementation, we have an IEnumerable
which may not even implement an AddRange
😉
Whoops you got me there :)
Hi and thanks @keesdewit82!
Although I like your idea, I do have a few nitpicks with this PR. If you could change those I will merge this PR.
ICollection
is not in line with the rest; I thinkIEnumerable
should be usedimageUri
andGetFeedItemImage
should be plural; the former contains (possibly)N
items, the latter returns (possibly)N
items (you did use Images (plural) here).Having said that; I do appreciate the PR. The project is due for some 'refactoring' anyway; so if you can't be bothered, no hard feelings; I may change the PR myself and then merge.