-
Notifications
You must be signed in to change notification settings - Fork 286
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
SQLConnectionStringBuilder 5.0 is not Backwards Compatible #1702
Comments
Thanks @PeteSL for bringing that up. If you pass the entire connection string into the SqlConnectionStringBuilder constructor, it will do the conversion from |
SMO needs to be updated to support 5.0 |
@lcheunglci I understand but I have no control over what methods the Microsoft.SqlServer.Management.Smo.Server class calls (Microsoft owns this). Repurposing a property without supporting prior methods is a bad idea, especially when the methods are used by other Microsoft classes. Until SQLClient or Smo.Server are brought into compliance, I will have to leave SQLClient at 4.1.0. |
The intention was to keep the connection string backwards compatible. Meaning if Encrypt is set to either Optional or Mandatory, or False or True, SqlConnectionStringBuilder would emit Encrypt=False or Encrypt=True. I thought I saw functional tests covering that scenario, |
This test passes on latest main: [Fact]
public void ConnectionBuilderEncryptBackwardsCompatibility()
{
SqlConnectionStringBuilder builder = new();
builder.Encrypt = false;
Assert.Equal("Encrypt=False", builder.ConnectionString);
Assert.False(builder.Encrypt);
builder.Encrypt = true;
Assert.Equal("Encrypt=True", builder.ConnectionString);
Assert.True(builder.Encrypt);
builder.Encrypt = SqlConnectionEncryptOption.Optional;
Assert.Equal("Encrypt=False", builder.ConnectionString);
Assert.False(builder.Encrypt);
builder.Encrypt = SqlConnectionEncryptOption.Mandatory;
Assert.Equal("Encrypt=True", builder.ConnectionString);
Assert.True(builder.Encrypt);
} |
That makes me wonder how SMO is calling our methods. There is an implicit conversion defined for SqlConnectionEncryptOption to/from a bool that was meant to cover backwards compatibility. |
It's a binary break, but not a source break. Old code recompiled against the new method will work. Old binaries are bound against the old method signature, and hence will break. |
SMO should update to 5.0 !? |
Ah, right. I'll make a change to the release notes to that effect. Thanks! |
When we bump SMO's major version (post SQL 2022 GA) we'll also: |
Closing this issue. The backwards compatibility issue is not with MDS connection strings, but with the fact that MDS 5.0 is not binary compatible with existing libraries, like SMO. Their code should be backwards compatible, but they need to be recompiled against MDS 5.0. |
I have new code compiled against these as configured by NuGet: But was getting the Method Not Found for encrypt at runtime. Had to change source like so: #if false
#endif |
Pull request 1608 states that the Encrypt property is backwards compatible with boolean interfaces. It is not. Microsoft.SqlServer.Management.Smo.Server("servername") constructor is failing with "Method not found: 'Void Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)'." during the construction. This is a bug as 1608 states it is backwards compatible. Rolling back to 4.1.0 fixes the issue, as expected.
The text was updated successfully, but these errors were encountered: