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

Change | Separate tests for NetFx and NetCore - NetFx-Only Connection String Properties #2466

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

benrr101
Copy link
Contributor

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
    • Throws if netfx-only properties are used in the connection string
  • SqlConnectionStringBuilderTest.ConnectionStringTestsNetFx_OnNetFx_Success
    • Same as original test, validates the property is supported

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:

  • Manually running the new tests works correctly on netcore and netfx

…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 = {
Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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");

Copy link
Contributor Author

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.

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.68%. Comparing base (68d35bb) to head (db130cf).
Report is 5 commits behind head on main.

❗ Current head db130cf differs from pull request most recent head 8078560. Consider uploading reports for the commit 8078560 to get more accurate results

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     
Flag Coverage Δ
addons 92.88% <ø> (ø)
netcore 77.01% <100.00%> (-0.06%) ⬇️
netfx 70.36% <ø> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@David-Engel David-Engel left a 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 = {
Copy link
Contributor

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.

@DavoudEshtehari DavoudEshtehari added this to the 6.0-preview1 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants