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

Breaking change in DocumentClient constructor in v1.15.0 #307

Closed
bcrobinson opened this issue Jul 25, 2017 · 4 comments
Closed

Breaking change in DocumentClient constructor in v1.15.0 #307

bcrobinson opened this issue Jul 25, 2017 · 4 comments

Comments

@bcrobinson
Copy link

The release notes at docs.microsoft.com mention that support for custom JsonSerializerSettings has been added when instanciating a DocumentClient.

This has been done by adding an extra parameter to the existing constructors for JsonSerializerSettings with a default value.

// V 1.14.1
public DocumentClient(Uri serviceEndpoint, SecureString authKey, ConnectionPolicy connectionPolicy = null, ConsistencyLevel? desiredConsistencyLevel = null)
public DocumentClient(Uri serviceEndpoint, string authKeyOrResourceToken, ConnectionPolicy connectionPolicy = null, ConsistencyLevel? desiredConsistencyLevel = null)
public DocumentClient(Uri serviceEndpoint, IList<Permission> permissionFeed, ConnectionPolicy connectionPolicy = null, ConsistencyLevel? desiredConsistencyLevel = null)

// V 1.15.0
public DocumentClient(Uri serviceEndpoint, SecureString authKey, ConnectionPolicy connectionPolicy = null, ConsistencyLevel? desiredConsistencyLevel = null, JsonSerializerSettings serializerSettings = null)
public DocumentClient(Uri serviceEndpoint, string authKeyOrResourceToken, ConnectionPolicy connectionPolicy = null, ConsistencyLevel? desiredConsistencyLevel = null, JsonSerializerSettings serializerSettings = null)
public DocumentClient(Uri serviceEndpoint, IList<Permission> permissionFeed, ConnectionPolicy connectionPolicy = null, ConsistencyLevel? desiredConsistencyLevel = null) : this(serviceEndpoint, DocumentClient.GetResourceTokens(permissionFeed), connectionPolicy, desiredConsistencyLevel)

While this is not a breaking change for code compiled against the new version, we have a dependency built against v1.14.1 and using this in a project referencing v1.15.0.
This breaks at runtime with the following exception:

Method not found: 'Void Microsoft.Azure.Documents.Client.DocumentClient..ctor(System.Uri, System.String, Microsoft.Azure.Documents.Client.ConnectionPolicy, System.Nullable`1<Microsoft.Azure.Documents.ConsistencyLevel>)'.

Unfortunately this leaves the sdk a bit stuck, as to keep backwards compatibility a two constructors are needed, one with the original parameters and one with the JsonSerializerSettings parameter.

But this would puts you in a situation where you break current users at compile time.
E.g.

public DocumentClient(Uri serviceEndpoint, SecureString authKey, ConnectionPolicy connectionPolicy = null, ConsistencyLevel? desiredConsistencyLevel = null)
public DocumentClient(Uri serviceEndpoint, SecureString authKey, ConnectionPolicy connectionPolicy = null, ConsistencyLevel? desiredConsistencyLevel = null, JsonSerializerSettings serializerSettings = null)

// this will result in "The call is ambiguous" compile error as both ctors are valid.
var client1 = new DocumentClient(endpoint, key);

We can currently work around this by downgrading our dependency on the Microsoft.Azure.DocumentDB nuget package to v1.14.1 until the upstream dependency has been update to 1.15.0.

@DaveAurionix
Copy link

Yes, this stung us too.

@rnagpal
Copy link
Contributor

rnagpal commented Jul 28, 2017

We are working on a fix for that and the new update will be released early next week.

@DaveAurionix
Copy link

That's great, thank you.

@rnagpal
Copy link
Contributor

rnagpal commented Aug 3, 2017

This has been fixed in 1.16.0 release of the SDK.

@rnagpal rnagpal closed this as completed Aug 3, 2017
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

No branches or pull requests

3 participants