Skip to content

Conversation

@Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Nov 9, 2016

Give all the responses some ❤️

As per #2299 be more consistent responses with returning empty collections vs null on responses. We did this sporadically but not consistently.
Now that we dropped .NET 4.0 we can make the response IEnumerable and Dictionaries IReadOnly*

Made sure all the interfaces only define getters and not setters

Copy link
Contributor

@gmarz gmarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM 👍 I wonder if we should be returning concrete types (ReadOnlyDictionary, ReadOnlyCollection) rather than interfaces though.

@Mpdreamz
Copy link
Member Author

Mpdreamz commented Nov 9, 2016

Can you explain why you wonder that @gmarz? Interested to hear your thoughts on this.

@gmarz
Copy link
Contributor

gmarz commented Nov 9, 2016

@Mpdreamz Robustness principle http://stackoverflow.com/questions/17170/when-to-use-ilist-and-when-to-use-list

On the other hand, when returning an object out of a function, you want to give the user the richest possible set of operations without them having to cast around.

Previously the richest types would be List<T> and Dictionary<T>, and now with this PR ReadOnlyCollection<T> and ReadOnlyDictionary<T>.

@Mpdreamz
Copy link
Member Author

Mpdreamz commented Nov 9, 2016

Not sure how I feel about returning the concrete types since they expose a lot of operations we dont want to expose e.g searchResponse.Documents.Add(). I generally agree with Postel's law but I feel the concrete types set wrong expectations. Also it ties us down.

Need to sleep on this :)

@Mpdreamz
Copy link
Member Author

@gmarz @russcam rebased against master and fixed the flakey tests.

Still some integration test failures but they are unrelated to this branch.

@russcam
Copy link
Contributor

russcam commented Nov 20, 2016

Will have a look at this today @Mpdreamz

@russcam
Copy link
Contributor

russcam commented Nov 21, 2016

7 failing integration tests:

  • Tests.XPack.Security.User.PutUser.PutUserRunAsApiTests.ReturnsExpectedIsValid [FAIL]
  • Tests.XPack.Security.User.PutUser.PutUserRunAsApiTests.HandlesStatusCode [FAIL]
  • Tests.XPack.Security.Role.PutRole.PutRoleRunAsApiTests.HandlesStatusCode [FAIL]
  • Tests.XPack.Security.Role.PutRole.PutRoleRunAsApiTests.ReturnsExpectedIsValid [FAIL]

related to the param for shield run as #2394

  • Tests.Indices.StatusManagement.Upgrade.UpgradeApiTests.ReturnsExpectedIsValid [FAIL]
  • Tests.Indices.StatusManagement.Upgrade.UpgradeApiTests.HandlesStatusCode [FAIL]

related to allow_no_indices #2397

  • Tests.Indices.Monitoring.IndicesShardStores.IndicesShardStoresApiTests.AssertResponse [FAIL]

not sure why this one is failing right now. Expected collection not to be empty.

@russcam
Copy link
Contributor

russcam commented Nov 21, 2016

LGTM - would be good to have some Coding Standards unit tests to ensure that this is the case across all IResponse types

As per #2299 be more consistent responses with returning empty collections vs null on responses.
Now that we dropped .NET 4.0 we can make the response IEnumerable and Dictionaries IReadOnly*

Made sure all the interfaces only define getters and not setters
…terfaces and not rely on implicit conversion.

Fix sorts on covariant hits having trouble going from JArray to ReadOnlyCollection<object>
@Mpdreamz
Copy link
Member Author

The IndicesShardResponse was an easy fix, the property now needed an explicit [JsonProperty], squashing and merging this one in.

@Mpdreamz Mpdreamz merged commit 30ac823 into master Nov 21, 2016
Mpdreamz added a commit that referenced this pull request Nov 21, 2016
* Give all the responses some ❤️

As per #2299 be more consistent responses with returning empty collections vs null on responses.
Now that we dropped .NET 4.0 we can make the response IEnumerable and Dictionaries IReadOnly*

Made sure all the interfaces only define getters and not setters

* another pass at all response objects

* Make sure EmptyReadOnly returns actual ReadOnly* instances for the interfaces and not rely on implicit conversion.
Fix sorts on covariant hits having trouble going from JArray to ReadOnlyCollection<object>

* fix shard store response because Stores now needs an explicit JsonProperty

Conflicts:
	src/Tests/tests.yaml
@Mpdreamz Mpdreamz deleted the fix/response-love branch November 30, 2016 16:58
awelburn pushed a commit to Artesian/elasticsearch-net that referenced this pull request Nov 6, 2017
* Give all the responses some ❤️

As per elastic#2299 be more consistent responses with returning empty collections vs null on responses.
Now that we dropped .NET 4.0 we can make the response IEnumerable and Dictionaries IReadOnly*

Made sure all the interfaces only define getters and not setters

* another pass at all response objects

* Make sure EmptyReadOnly returns actual ReadOnly* instances for the interfaces and not rely on implicit conversion.
Fix sorts on covariant hits having trouble going from JArray to ReadOnlyCollection<object>

* fix shard store response because Stores now needs an explicit JsonProperty
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