-
Notifications
You must be signed in to change notification settings - Fork 321
Fix | Adding type convertor support for SqlConnectionEncryptOption #2057
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
Merged
Kaur-Parminder
merged 25 commits into
dotnet:main
from
arellegue:SqlConnectionEncryptOption
Jul 6, 2023
Merged
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5c505a1
Add SqlConnectionEncryptOptionConverter class which is used to conver…
arellegue 9b9af7e
Merge branch 'main' of https://github.com/arellegue/SqlClient
arellegue 4ebaabd
Removed added blank line.
arellegue 39a7ea8
Removed redundant InLineData from ConnectionStringFromJsonTests.
arellegue 0a0768e
Fix issues found in PR request.
arellegue ab6a469
Changed SqlConnectionEnryptOptionConverter from public to internal.
arellegue 892625c
Applied Davoud's suggestions for changes.
arellegue 789670e
Update src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnecti…
DavoudEshtehari 5455314
Update tools/props/Versions.props
DavoudEshtehari e07547a
Add more SqlConnectionEncryptOptionConverter unit tests.
arellegue 7197981
Add assessment of exception thrown in ExecuteConnectionStringFromJson…
arellegue d7f0058
Added blank line.
arellegue 7dee649
Apply suggestions from code review
DavoudEshtehari c9d115c
Removed unnecessary XML file for internal class SqlConnectionEncryptO…
arellegue 4b5f86d
Use ADP.ConvertFailed helper function in SqlConnectionEncryptOptionCo…
arellegue 14ac22f
Resolved merged conflict.
arellegue 9a42b07
Apply suggestions from code review
DavoudEshtehari 809bbe8
Add message to show more information if CanCanConvert returns false.
arellegue 20170ee
Fixed grammar error in the message to show more information if CanCon…
arellegue 06b3536
Removed entry for EncryptOptionConverter XML.
arellegue 99d1243
Revert "Removed entry for EncryptOptionConverter XML."
arellegue 766d859
Remove EncryptOptionConverter xml in MDS solution.
arellegue 1040674
Add more messages to show more information if CanConvertFrom and CanC…
arellegue f54d699
Change messages to show the expections when CanConvertFrom and CanCon…
arellegue 7415ec1
Fix CanConvertTo messages.
arellegue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptOptionConverter.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?xml version="1.0"?> | ||
| <docs> | ||
| <members name="SqlConnectionEncryptOptionConverter"> | ||
| <SqlConnectionEncryptOption> | ||
| <summary>Converts a string Sql Connection Encrypt option into SqlConnectionEncryptOption object</summary> | ||
| <remarks> | ||
| <para> | ||
| ## Remarks | ||
| Implicit conversions have been added to maintain backwards compatibility with boolean behahavior for the <see cref="Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Encrypt" /> property. When converting from a boolean, a value of `true` converts to <see cref="Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory" /> and a value of `false` converts to <see cref="Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Optional"/>. When converting to a boolean, <see cref="Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory"/>, <see cref="Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Strict"/> , and `null` convert to `true` and <see cref="Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Optional"/> converts `false`. | ||
| </para> | ||
| </remarks> | ||
| </SqlConnectionEncryptOption> | ||
| <CanConvertFrom> | ||
| <summary> | ||
| If the source type is a string then conversion is allowed <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption"/>. | ||
| </summary> | ||
| <param name="value">A string containing the value to convert.</param> | ||
| <returns> | ||
| <see langword="true" /> if the <paramref name="value"/> parameter can be converted successfully; otherwise, <see langword="false" />. | ||
| </returns> | ||
| <remarks>This method does not throw an exception.</remarks> | ||
| </CanConvertFrom> | ||
| <ConvertFrom> | ||
| <summary> | ||
| Converts the specified string representation of a logical value to its <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption"/> equivalent. | ||
| </summary> | ||
| <param name="value">A string containing the value to convert.</param> | ||
| <param name="result"> | ||
| An object that is equivalent to <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption"/>. | ||
| </param> | ||
| <returns> | ||
| An object that is equivalent to <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption"/> with value of <paramref name="value"/> if conversion was successful; | ||
| otherwise, an exception is thrown. | ||
| </returns> | ||
| <remarks>This method throws an exception if conversion fails.</remarks> | ||
| </ConvertFrom> | ||
| <ConvertTo> | ||
| <summary> | ||
| Converts an object <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption"/> value to its string representation. | ||
| </summary> | ||
| <param name="value">An object <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption"/> containing the value to convert.</param> | ||
| <param name="result"> | ||
| A string representation of the value of <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption"/>. | ||
| </param> | ||
| <returns> | ||
| A string representation of the value of <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption"/>. | ||
| </returns> | ||
| <remarks>This method does not throw an exception if conversion fails.</remarks> | ||
| </ConvertTo> | ||
| </members> | ||
| </docs> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...rosoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionEncryptOptionConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
| using System; | ||
| using System.ComponentModel; | ||
| using System.Globalization; | ||
| using System.Drawing; | ||
DavoudEshtehari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| namespace Microsoft.Data.SqlClient | ||
| { | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptOptionConverter.xml' path='docs/members[@name="SqlConnectionEncryptOptionConverter"]/SqlConnectionEncryptOptionConverter/*'/> | ||
| public class SqlConnectionEncryptOptionConverter : TypeConverter | ||
| { | ||
| // Overrides the CanConvertFrom method of TypeConverter. | ||
| // The ITypeDescriptorContext interface provides the context for the | ||
| // conversion. Typically, this interface is used at design time to | ||
| // provide information about the design-time container. | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptOptionConverter.xml' path='docs/members[@name="SqlConnectionEncryptOptionConverter"]/SqlConnectionEncryptOptionConverter/CanConvertFrom/*'/> | ||
| public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) | ||
| { | ||
| if (sourceType == typeof(string)) | ||
| { | ||
| return true; | ||
| } | ||
| return base.CanConvertFrom(context, sourceType); | ||
DavoudEshtehari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| // Overrides the ConvertFrom method of TypeConverter. | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptOptionConverter.xml' path='docs/members[@name="SqlConnectionEncryptOptionConverter"]/SqlConnectionEncryptOptionConverter/ConvertFrom/*'/> | ||
| public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) | ||
| { | ||
| if (value is string) | ||
| { | ||
| return SqlConnectionEncryptOption.Parse(value.ToString()); | ||
| } | ||
| throw new Exception("Value to convert must be of string type!"); | ||
DavoudEshtehari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
DavoudEshtehari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| // Overrides the ConvertTo method of TypeConverter. | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptOptionConverter.xml' path='docs/members[@name="SqlConnectionEncryptOptionConverter"]/SqlConnectionEncryptOptionConverter/ConvertTo/*'/> | ||
| public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) | ||
| { | ||
| return base.ConvertTo(context, culture, value, destinationType); | ||
DavoudEshtehari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.