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

Shrink SqlParameter XmlSchema #1033

Merged
merged 5 commits into from May 7, 2021
Merged

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Apr 15, 2021

In dotnet/corefx#35549 I changed SqlParameter to use SqlMetaDataXmlSchemaCollection to hold xml schema information if it is present. This reduces the memory size because rather than keeping 3 string references which will mostly be null a single reference is kept for the sub object and it is created before use. This ports that change to netcore and netfx and adds the covering tests, it includes the fixes from dotnet/corefx#41008 which covered a problem in the original.

While working on SqlParameter i made a couple of other minor changes:

The direction field was not initialized but had a getter which checked for the 0 value and then returned ParameterDirection.Input. Recent profiling work on parameter passing showed that getting the parameter direction is an unexpectedly hot call. Because it is not possible for users to observe the 0 value it is safe to simply initialize the value in the ctors and then use a simple getter. The only observable change in this is if a user changes the value and is using INotifyPropertyChanged (usually designers use this) they will now not see a change from 0 to 1 if they assign to the Direction property, given that they could never observe the 0 value this seems like it is unlikely to break anyone.

The ctor call chain in netfx and netcore was slightly different so I synchronized them. This should have no practical effect but it will make merging the files later easier.

I removed some uses of ADP.StrEmpty and replaced them with string.Empty, these two expressions point to the same string instance because of runtime interning of constant strings. Using our own alias for it is no more secure than referring to it as string.Empty or "", as such just use the runtime supported constant and remove our copy from the library at some future date when all other references have been removed.

@cheenamalhotra cheenamalhotra added this to In Progress in SqlClient v3.0 via automation Apr 28, 2021
@cheenamalhotra cheenamalhotra added this to the 3.0.0-preview3 milestone Apr 28, 2021
SqlClient v3.0 automation moved this from In Progress to Reviewer Approved May 3, 2021
@cheenamalhotra cheenamalhotra merged commit 1eabe06 into dotnet:main May 7, 2021
SqlClient v3.0 automation moved this from Reviewer Approved to Done May 7, 2021
@Wraith2 Wraith2 deleted the combine20 branch May 7, 2021 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants