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
Change | Separate tests for NetFx and NetCore - NetFx-Only Connection String Properties #2466
base: main
Are you sure you want to change the base?
Change | Separate tests for NetFx and NetCore - NetFx-Only Connection String Properties #2466
Conversation
…orm connection string error messages Splitting unit test for netfx-only connection string properties such that test does not fail on netcore
@@ -912,17 +911,19 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex | |||
} | |||
} | |||
#else | |||
private static readonly string[] s_notSupportedKeywords = new string[DeprecatedKeywordsCount] { | |||
private static readonly string[] s_notSupportedKeywords = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array initialization is always the same size as the number of elements, so its unnecessary to specify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are eliminating the DeprecatedKeywordsCount reference here, you should just get rid of DeprecatedKeywordsCount entirely and just reference the size of this array in the one other place it's used. Otherwise, DeprecatedKeywordsCount needs to be changed from 3 to 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@David-Engel Ok, I've updated the PR, chaning DeprecatedKeywordsCount
to 5 and removing DeprecatedSynonymsCount
from SqlConnectionString
. As far as I can tell, I can't access s_notSupportedKeywords
array from SqlConnectionString
, so I think it makes more sense to just change the number.
As far as I can tell, the only reason for calculating the count is to determine the optimum size of the dictionary. net8 added support for a FrozenDictionary
that has its size fixed at initialization, but it looks like we can't utilize that today. That'd be a nice option here...
Please let me know if this isn't what you had in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't considering DeprecatedSynonymCount, just DeprecatedKeywordsCount. Just make sure the count is correct in the debug assert at line 927/928 of SqlConnectionString.cs after your changes. I'm pretty sure it's there to ensure we are initializing the Dictionary to the correct size to maximize perf. An incorrect count won't show up at runtime or in tests.
Debug.Assert(synonyms.Count == count, "incorrect initial ParseSynonyms size");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. It sounds like we're on the same page, then.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2466 +/- ##
==========================================
- Coverage 72.74% 72.68% -0.07%
==========================================
Files 313 313
Lines 61737 61741 +4
==========================================
- Hits 44910 44875 -35
- Misses 16827 16866 +39
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with the minor comment.
@@ -912,17 +911,19 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex | |||
} | |||
} | |||
#else | |||
private static readonly string[] s_notSupportedKeywords = new string[DeprecatedKeywordsCount] { | |||
private static readonly string[] s_notSupportedKeywords = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are eliminating the DeprecatedKeywordsCount reference here, you should just get rid of DeprecatedKeywordsCount entirely and just reference the size of this array in the one other place it's used. Otherwise, DeprecatedKeywordsCount needs to be changed from 3 to 5.
Description: In an effort to make running all unit tests in vs not throw "correct" test failures, this PR creates two tests.
SqlConnectionStringBuilderTest.ConnectionStringTestsNetFx_OnNetCore_Throws
SqlConnectionStringBuilderTest.ConnectionStringTestsNetFx_OnNetFx_Success
As a side effect of this, I had to add
Transparent Network IP Resolution
to the list of properties that will return a "not supported on this platform" exception. This might be considered a breaking change since it changes an exception type, but I see it more as a fix, since it's true - that property is not supported on netcore (yet?) and that exception should be returned.Tests: