Skip to content

Commit

Permalink
Move into Shared for SqlConnectionString.cs (#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcheunglci authored Oct 19, 2021
1 parent 9fd88b1 commit e848450
Show file tree
Hide file tree
Showing 8 changed files with 488 additions and 1,358 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlConnectionPoolProviderInfo.cs">
<Link>Microsoft\Data\SqlClient\SqlConnectionPoolProviderInfo.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlConnectionString.cs">
<Link>Microsoft\Data\SqlClient\SqlConnectionString.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlCredential.cs">
<Link>Microsoft\Data\SqlClient\SqlCredential.cs</Link>
</Compile>
Expand Down Expand Up @@ -496,7 +499,6 @@
<ItemGroup Condition="'$(OSGroup)' != 'AnyOS' AND '$(TargetGroup)' == 'netcoreapp'">
<Compile Include="Microsoft\Data\ProviderBase\DbConnectionPool.NetCoreApp.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlAuthenticationProviderManager.NetCoreApp.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionString.NetCoreApp.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlDiagnosticListener.NetCoreApp.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlDelegatedTransaction.NetCoreApp.cs" />
<Compile Include="Microsoft\Data\SqlClient\TdsParser.NetCoreApp.cs" />
Expand Down Expand Up @@ -564,7 +566,6 @@
<Compile Include="Microsoft\Data\SqlClient\SqlConnection.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionFactory.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionHelper.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionString.cs" />
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlConnectionTimeoutErrorInternal.cs">
<Link>Microsoft\Data\SqlClient\SqlConnectionTimeoutErrorInternal.cs</Link>
</Compile>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlConnectionPoolProviderInfo.cs">
<Link>Microsoft\Data\SqlClient\SqlConnectionPoolProviderInfo.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlConnectionString.cs">
<Link>Microsoft\Data\SqlClient\SqlConnectionString.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlDataAdapter.cs">
<Link>Microsoft\Data\SqlClient\SqlDataAdapter.cs</Link>
</Compile>
Expand Down Expand Up @@ -554,7 +557,6 @@
<Compile Include="Microsoft\Data\SqlClient\SqlConnection.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionFactory.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionHelper.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionString.cs" />
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlConnectionTimeoutErrorInternal.cs">
<Link>Microsoft\Data\SqlClient\SqlConnectionTimeoutErrorInternal.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ internal static class DbConnectionStringDefaults
internal const bool ContextConnection = false;
internal static readonly bool TransparentNetworkIPResolution = !LocalAppContextSwitches.DisableTNIRByDefault;
internal const string NetworkLibrary = "";
internal const bool Asynchronous = false;
#if ADONET_CERT_AUTH
internal const string Certificate = "";
#endif
Expand Down Expand Up @@ -982,7 +983,7 @@ internal static class DbConnectionStringDefaults
internal const int ConnectRetryCount = 1;
internal const int ConnectRetryInterval = 10;
internal static readonly SqlAuthenticationMethod Authentication = SqlAuthenticationMethod.NotSpecified;
internal static readonly SqlConnectionColumnEncryptionSetting ColumnEncryptionSetting = SqlConnectionColumnEncryptionSetting.Disabled;
internal const SqlConnectionColumnEncryptionSetting ColumnEncryptionSetting = SqlConnectionColumnEncryptionSetting.Disabled;
internal const string EnclaveAttestationUrl = "";
internal const SqlConnectionAttestationProtocol AttestationProtocol = SqlConnectionAttestationProtocol.NotSpecified;
internal const SqlConnectionIPAddressPreference IPAddressPreference = SqlConnectionIPAddressPreference.IPv4First;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void Constructor2_ConnectionString_Invalid()
// Keyword not supported: 'invalidkeyword'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'invalidkeyword'") != -1);
Assert.True(ex.Message.IndexOf("'invalidkeyword'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// invalid packet size (< minimum)
Expand Down Expand Up @@ -267,7 +267,7 @@ public void ConnectionString_Value_Invalid()
// Keyword not supported: 'invalidkeyword'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'invalidkeyword'") != -1);
Assert.True(ex.Message.IndexOf("'invalidkeyword'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);
}

Expand Down Expand Up @@ -468,7 +468,7 @@ public void ConnectionString_ConnectTimeout_Invalid()
// Invalid value for key 'connect timeout'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'connect timeout'") != -1);
Assert.True(ex.Message.IndexOf("'connect timeout'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// invalid number
Expand All @@ -477,7 +477,7 @@ public void ConnectionString_ConnectTimeout_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(FormatException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'connect timeout'") != -13);
Assert.True(ex.Message.IndexOf("'connect timeout'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Input string was not in a correct format
Expand All @@ -491,7 +491,7 @@ public void ConnectionString_ConnectTimeout_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(OverflowException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'connect timeout'") != -1);
Assert.True(ex.Message.IndexOf("'connect timeout'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Value was either too large or too small for an Int32
Expand Down Expand Up @@ -526,7 +526,7 @@ public void ConnectionString_CommandTimeout_Invalid()
// Invalid value for key 'connect timeout'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'command timeout'") != -1);
Assert.True(ex.Message.IndexOf("'command timeout'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// invalid number
Expand All @@ -535,7 +535,7 @@ public void ConnectionString_CommandTimeout_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(FormatException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'command timeout'") != -13);
Assert.True(ex.Message.IndexOf("'command timeout'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Input string was not in a correct format
Expand All @@ -549,7 +549,7 @@ public void ConnectionString_CommandTimeout_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(OverflowException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'command timeout'") != -1);
Assert.True(ex.Message.IndexOf("'command timeout'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Value was either too large or too small for an Int32
Expand Down Expand Up @@ -634,7 +634,7 @@ public void ConnectionString_MaxPoolSize_Invalid()
// Invalid value for key 'max pool size'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'max pool size'") != -1);
Assert.True(ex.Message.IndexOf("'max pool size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// invalid number
Expand All @@ -643,7 +643,7 @@ public void ConnectionString_MaxPoolSize_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(FormatException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'max pool size'") != -1);
Assert.True(ex.Message.IndexOf("'max pool size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Input string was not in a correct format
Expand All @@ -657,7 +657,7 @@ public void ConnectionString_MaxPoolSize_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(OverflowException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'max pool size'") != -1);
Assert.True(ex.Message.IndexOf("'max pool size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Value was either too large or too small for an Int32
Expand All @@ -670,7 +670,7 @@ public void ConnectionString_MaxPoolSize_Invalid()
// Invalid value for key 'max pool size'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'max pool size'") != -1);
Assert.True(ex.Message.IndexOf("'max pool size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// less than min pool size
Expand Down Expand Up @@ -702,7 +702,7 @@ public void ConnectionString_MinPoolSize_Invalid()
// Invalid value for key 'min pool size'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'min pool size'") != -1);
Assert.True(ex.Message.IndexOf("'min pool size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// invalid number
Expand All @@ -711,7 +711,7 @@ public void ConnectionString_MinPoolSize_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(FormatException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'min pool size'") != -1);
Assert.True(ex.Message.IndexOf("'min pool size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Input string was not in a correct format
Expand All @@ -725,7 +725,7 @@ public void ConnectionString_MinPoolSize_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(OverflowException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'min pool size'") != -1);
Assert.True(ex.Message.IndexOf("'min pool size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Value was either too large or too small for an Int32
Expand All @@ -750,7 +750,7 @@ public void ConnectionString_MultipleActiveResultSets_Invalid()
// Invalid value for key 'multiple active result sets'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'multiple active result sets'") != -1);
Assert.True(ex.Message.IndexOf("'multiple active result sets'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);
}

Expand Down Expand Up @@ -781,7 +781,7 @@ public void ConnectionString_PacketSize_Invalid()
// integer >= 512 and <= 32768
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Packet Size'") != -1);
Assert.True(ex.Message.IndexOf("'Packet Size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// invalid packet size (> maximum)
Expand All @@ -790,7 +790,7 @@ public void ConnectionString_PacketSize_Invalid()
// integer >= 512 and <= 32768
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Packet Size'") != -1);
Assert.True(ex.Message.IndexOf("'Packet Size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// overflow
Expand All @@ -799,7 +799,7 @@ public void ConnectionString_PacketSize_Invalid()
Assert.NotNull(ex.InnerException);
Assert.Equal(typeof(OverflowException), ex.InnerException.GetType());
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'packet size'") != -1);
Assert.True(ex.Message.IndexOf("'packet size'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);

// Value was either too large or too small for an Int32
Expand Down Expand Up @@ -849,7 +849,7 @@ public void ConnectionString_UserInstance_Invalid()
// Invalid value for key 'user instance'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'user instance'") != -1);
Assert.True(ex.Message.IndexOf("'user instance'", StringComparison.OrdinalIgnoreCase) != -1);
Assert.Null(ex.ParamName);
}

Expand Down Expand Up @@ -1009,7 +1009,7 @@ public void ConnectionString_IPAddressPreference_Invalid(string value)
// Invalid value for key 'ip address preference'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.Contains("'ip address preference'", ex.Message);
Assert.Contains("'ip address preference'", ex.Message, StringComparison.OrdinalIgnoreCase);
Assert.Null(ex.ParamName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static void InvalidAuthTypeTest()
ArgumentException e = Assert.Throws<ArgumentException>(() => ConnectAndDisconnect(connStr));

string expectedMessage = "Invalid value for key 'authentication'.";
Assert.Contains(expectedMessage, e.Message);
Assert.Contains(expectedMessage, e.Message, StringComparison.OrdinalIgnoreCase);
}

[ConditionalFact(nameof(IsAADConnStringsSetup))]
Expand Down

0 comments on commit e848450

Please sign in to comment.