Skip to content

Port caching of method discovery to main - #4133

Merged
OsirisTerje merged 21 commits into
masterfrom
cache-method-discovery-main
Apr 11, 2023
Merged

OsirisTerje merged 21 commits into
masterfrom
cache-method-discovery-main

Conversation

@stevenaw

@stevenaw stevenaw commented Jun 21, 2022 •

Copy link
Copy Markdown
Member

@stevenaw

Copy link
Copy Markdown
Member Author

@manfred-brands I was going to ask you for a review on this, but I would instead like to ask for some help :)
I've tried to port both the method caching + your exception handling bugfix but it seems one of the tests in main reliably fails. You're more familiar with this change, would you be able to help me out?

NUnit.Framework.Internal.AttributeThrowingExceptionTests.TestSuiteContainsAllTests(NUnit.TestData.AttributeThrowingExceptionFixture.AttributeOnFixtureThrowingExceptionFixture)

@manfred-brands

Copy link
Copy Markdown
Member

@stevenaw I didn't have time today, will look at it tomorrow.

@stevenaw

Copy link
Copy Markdown
Member Author

Thanks @manfred-brands No rush at all. My setup is acting up and I was having a hard time debugging it myself

@manfred-brands

Copy link
Copy Markdown
Member

@stevenaw I have traced this to nunit 4.0 specific code introduced with #3926 where it calls unconstrained GetCustomAttributes. I have rewritten the OSPlatformTranslator so it doesn't do that anymore.

I then looked where else we called GetCustomAttributes and removed the last call in AsyncToSyncAdapter.
Surprisingly this broke tests.

As Nunit now only interrogates know attributes, it will never trigger any exception from bad behaving 3rd party attributes.
To me this is correct. 3rd party attributes, unless implementing IApplyToTest should not affect NUnit.

@manfred-brands

Copy link
Copy Markdown
Member

See my changes on top of your changes #4137

@stevenaw stevenaw changed the title DRAFT: Port caching of method discovery to main Port caching of method discovery to main Jun 25, 2022
@stevenaw
stevenaw marked this pull request as ready for review June 25, 2022 15:58
@stevenaw

Copy link
Copy Markdown
Member Author

Thanks once again for all your help with this @manfred-brands
I think this is now ready for review

@stevenaw

stevenaw commented Aug 4, 2022

Copy link
Copy Markdown
Member Author

@nunit/framework-team Is anyone up to reviewing this? It's a large PR but is mostly cherry picks and should sync a few large pieces of work between the two branches

@stevenaw stevenaw changed the title Port caching of method discovery to main Port caching of method discovery to v4 Oct 3, 2022
@stevenaw stevenaw changed the title Port caching of method discovery to v4 Port caching of method discovery to main Nov 6, 2022
@rprouse rprouse self-assigned this Feb 21, 2023
@OsirisTerje

Copy link
Copy Markdown
Member

@stevenaw @manfred-brands This PR is rather big, but it is migration to 4.0 branch. I tried to look at the changes here, but there is simply too much. I believe you two have to agree if this looks ok or not, and then we just merge it in. What could possibly go wrong?

@stevenaw

stevenaw commented Apr 4, 2023

Copy link
Copy Markdown
Member Author

What could possibly go wrong?

🙂
I will volunteer that this PR was largely made by cherry-picking commits. To the best of my knowledge, most merge conflicts are likely related to pattern matching changes in default. I recall having looked at @manfred-brands small post-fix and being ok with it

@OsirisTerje

Copy link
Copy Markdown
Member

Ok, then I suggest we just need to fix the merge conflicts and then we merge it, right ?

@stevenaw

stevenaw commented Apr 4, 2023

Copy link
Copy Markdown
Member Author

That makes sense to me.

@OsirisTerje

Copy link
Copy Markdown
Member

I tried to merge this, but the conflicts are not that simple. The OSPlatformTranslator is complaining, and there also seems to be a ton of name clashes. I think it is best if either of you do this: @manfred-brands or @stevenaw .

@OsirisTerje OsirisTerje added the mergeconflicts This PR have merge conflicts label Apr 7, 2023
@manfred-brands

Copy link
Copy Markdown
Member

I will see if I can sort out the conflicts.

@manfred-brands
manfred-brands force-pushed the cache-method-discovery-main branch from 3b5c64e to 0e495d1 Compare April 10, 2023 03:47
@manfred-brands

manfred-brands commented Apr 10, 2023 •

Copy link
Copy Markdown
Member

I have rebased the branch and solved the merge conflicts.

Then added three more commits:

  1. Protect the newly added TestSuite.ApplyAttributesToTestSuite from rogue attributes by only asking for relevant attribute.
  2. Fix previously non-detected bugs in the recently added 'Add support for ref/in keywords in ValueAtttribute'. Due to the bug the code was throwing in the test discovery resulting in finding zero test and hence not showing any failure. The changes in this branch (commit Exception in ApplyToTest are recognized) now detect this. However, the test asserts only in the OneTimeTearDown which doesn't show any failing tests nor does it seem to be picked up by the build, even though it is shown in the dotnet cake run as text.
  3. Due to us no longer including System.Runtime, on some platforms the AsyncStateMachineAttribute type is not found. This resulted in a ArgumentNullException.

Can someone @stevenaw or @OsirisTerje give this a final review?

@manfred-brands
manfred-brands force-pushed the cache-method-discovery-main branch from 618806c to aeed2b0 Compare April 10, 2023 04:23
@stevenaw stevenaw added awaiting:review and removed mergeconflicts This PR have merge conflicts labels Apr 10, 2023
@stevenaw

Copy link
Copy Markdown
Member Author

Thanks for this @manfred-brands !

Due to us no longer including System.Runtime, on some platforms the AsyncStateMachineAttribute type is not found. This resulted in a ArgumentNullException.

Ah, I had been a little afraid of something like this. I noticed we simply added a null check. Based on your checking in this PR, should we instead add the reference back (in separate PR) or is it alright as-is?

@stevenaw

Copy link
Copy Markdown
Member Author

This PR looks ok to me. There's been a lot of catch-up it's had to do over the last while, and now that it's caught up I think it'd be great to merge it in.

@OsirisTerje Are you able to approve? I'm unable to as I've created this PR.

@OsirisTerje OsirisTerje left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved

@OsirisTerje
OsirisTerje merged commit c1311f6 into master Apr 11, 2023
@OsirisTerje
OsirisTerje deleted the cache-method-discovery-main branch April 11, 2023 07:30
@OsirisTerje

Copy link
Copy Markdown
Member

@stevenaw @manfred-brands

Due to us no longer including System.Runtime, on some platforms the AsyncStateMachineAttribute type is not found. This resulted in a ArgumentNullException.

Ah, I had been a little afraid of something like this. I noticed we simply added a null check. Based on your checking in this PR, should we instead add the reference back (in separate PR) or is it alright as-is?

I could not see this in this PR, so I assume it was done somewhere else. If it fails on some platforms, we better add it back. I noticed we do refer to that assembly in this PR (by reflection). Its better to be safe than sorry wrt to this.

@stevenaw

Copy link
Copy Markdown
Member Author

@OsirisTerje I suspect the runtime/reflection issue could be from #4335 . I can spin up a PR to add it back, with a test for the used functionality

@manfred-brands

Copy link
Copy Markdown
Member

@OsirisTerje @stevenaw If something uses async methods, System.Runtime should be loaded. If not we don't care.
As long as the tests that rely on AsyncToSyncAdapter.IsAsyncOperation pass then it should be OK.
Unfortunately the AsyncToSyncAdapter doesn't have its own nunit tests but is used indirectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants