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

Share more files and add MultiPartIdentifier tests #827

Merged
merged 2 commits into from
Dec 22, 2020

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Nov 29, 2020

Merged a couple of files into the shared location, MultipartIdentifier and DBConnectionPoolKey. Datastorage in netfx was not included in the project and was not used so i removed it. I've also added some tests for the MultipartIdentifier by including the file in the functional tests project and giving it some local context (ADP methods it calls) in the test class.

@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 30, 2020

Wonder if it would be good to add StringComparison.Ordinal with IndexOf (but maybe that is a general issue in the entire codebase) - see dotnet/runtime#43736

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 30, 2020

Perhaps. It's above my level to make that decision. It'll only affect .Net5 at the moment but moving to 5 is a good idea for sql perf not least because of dotnet/runtime#1637
I've got a complete replacement for MultipartIdentifier which works in terms of spans which is why I have the test coverage, I'll see if there's anywhere in there that IndexOf is used.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Dec 10, 2020

@David-Engel @cheenamalhotra any chance of getting this and the other couple of recent merge PR's reviewed and merged? There's more to do but having too many PR's open makes it confusing to work on.

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.

Looks good to me apart from the csproj issues I noted.

@David-Engel
Copy link
Contributor

any chance of getting this and the other couple of recent merge PR's reviewed and merged? There's more to do but having too many PR's open makes it confusing to work on.

@Wraith2 Sorry for the delay. Holidays + vacations has made for less time to get things done. Thanks for the contributions! I'll try and look at the others ASAP.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Dec 10, 2020

Netfx subtype project changes reverted.

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.

LGTM. Thanks!

@@ -55,6 +56,7 @@
<Compile Include="SerializeSqlTypesTest.cs" />
<Compile Include="TestTdsServer.cs" />
<Compile Include="SqlHelperTest.cs" />
<Compile Include="..\..\src\Microsoft\Data\Common\MultipartIdentifier.cs" />
Copy link
Member

@cheenamalhotra cheenamalhotra Dec 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you did this to be able to access this source code here, but this approach will not give code coverage to netcore\M.D.S project csproj (as that is what we measure). This class will be executed from within this project.

You could instead provide access to test namespace by adding assembly tag:
[assembly:InternalsVisibleTo("")]

You'd not need ADP overrides too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I avoid InternalsVisibleTo because it's deprecated in netcore and wasn't a good idea to begin with. While it doesn't give code coverage it doesn't decrease code coverage either and it does increase test coverage so that the behaviour, which is most important, is now tested and deviations can be caught.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an official doc on it's deprecated status or why it's not a good idea? I mean there should be a better way of referencing internals if this is going to be deprecated! I don't think we need to limit ourselves.

If not, I'd rather increase code coverage than use this approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I know there are many placed in corefx/runtime where it's been removed and in general they don't seem to want to use it but i don't have concrete information about why, some mention of build perf and trimming problems. I've asked on the discord if there's an official opinion on it's use.

There is the obvious negative that it adds the name of the test assemblies irrevocably into the released binary which is unneeded and since there is no strong name capability on core anything that wants to can see those names and pretend to be that assembly allowing them to screw with internals.

I can understand why you'd want to increase coverage but contributors still can't see any of those coverage numbers and as I said I've increased test coverage., Requiring me to hit a target I can't evaluate seems unreasonable.

Copy link
Member

@cheenamalhotra cheenamalhotra Dec 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually a work in progress to be able to report coverage on PRs as they come along, there's just so much activity on higher priority. But we regularly run code coverage internally (link here). I was saying in reference to new tests that we are adding, they should contribute to code coverage, and doesn't sound like we have large concerns over using the assembly tag.

it adds the name of the test assemblies irrevocably into the released binary

We already have a few assembly tags in other classes for internal testing, so it's not going to make additional difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had a look and there are no test related InternalsVisibleTo attributes in the library. I also tried to look at the code coverage from your link but all I can find is an overall percentage and a .coverage file which I can't open.

Copy link
Member

@cheenamalhotra cheenamalhotra Dec 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my bad. I think the alternate approach is using Reflection to access internal classes if not this way.
You're right, we should not use InternalsVisibleTo, as it causes assembly signing issues too.

It just hurts to lose code coverage.

@cheenamalhotra cheenamalhotra added this to the 3.0.0-preview1 milestone Dec 18, 2020
@Wraith2
Copy link
Contributor Author

Wraith2 commented Dec 22, 2020

Any chance this can get merged and then when code coverage support is ready the tests can be changed around to use internals visibility if needed? I'd really like to get my open PR's in before the holiday so I've got a clean start on some of the more complex files.

Copy link
Member

@cheenamalhotra cheenamalhotra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else looks good.
Todo: Improve internal class exposure without duplicating reference.

@cheenamalhotra cheenamalhotra merged commit a9c21bb into dotnet:master Dec 22, 2020
@Wraith2
Copy link
Contributor Author

Wraith2 commented Dec 22, 2020

Excellent, thanks 😁

@Wraith2 Wraith2 deleted the combine8 branch December 23, 2020 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants