Skip to content

Regression in 3.8.1: ApartmentAttribute no longer works when applied to an assembly #2426

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

Closed
thecontrarycat opened this issue Sep 8, 2017 · 9 comments · Fixed by #2537
Closed

Comments

@thecontrarycat
Copy link

Create a test project containing the following test:

[assembly:Apartment(ApartmentState.STA)]
namespace TestProject
{
    [TestFixture]
    public class TestFixture
    {
        [Test]
        public void Test()
        {
            if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
            {
                throw new ThreadStateException("The current threads apartment state is not STA");
            }
        }
    }
}

Compile it against NUnit 3.7.1 - Test Passes
Compile it against NUnit 3.8.1 - Test Fails

Compile it against NUnit 3.8.1 but with the [Apartment] attribute on the TestFixture - Test Passes
Compile it against NUnit 3.8.1 but with the [Apartment] attribute on the Test - Test Passes

Note that this bug is present in 3.8.0 as well as 3.8.1

@CharliePoole
Copy link
Member

I'm suspicious that this could be a side effect of the fix to #2361

@CharliePoole
Copy link
Member

This is different from but probably related to #2388

@CharliePoole CharliePoole removed their assignment Sep 11, 2017
@CharliePoole
Copy link
Member

I'm going away on a family trip for a couple of weeks so I'm taking my name off this to free it up for somebody else to work on.

@rinubaby
Copy link

We've already upgraded to 3.8.1 (was on 2.6.2 earlier), since we have a large number of tests, we are being blocked by this issue, any timeline as to when the next release (fix) will be available? Also, seeing occasionally that test runs are getting hung. Is this only a 3.8.1 problem, wondering if going back to 3.7.1 would fix the hanging issue as well. Thanks.

@ChrisMaddock
Copy link
Member

ChrisMaddock commented Oct 20, 2017

Both these issues were regressions in 3.8.x - so 3.7.1 should work for you until the next release.

Your hanging could be caused by a number of things - however, if you are using NUnit's parallelization attributes, there were some changes there in 3.8.x which caused tests to hang more often. A fix for this is being worked on at the moment.

Regarding the AppartmentAttribute issue, I don't believe anyone's currently working on this - so as to a fix it really depends when someone picks it up and submits a pull request.

@rinubaby
Copy link

I have a fix for this issue, can I do a pull request so that you can look at it? I am getting access denied.

@CharliePoole
Copy link
Member

Anyone can do a pull request. Did you fork to your own account first?

rinubaby pushed a commit to rinubaby/nunit that referenced this issue Oct 30, 2017
@rinubaby
Copy link

Thanks Charlie, have opened a pull request.

rinubaby pushed a commit to rinubaby/nunit that referenced this issue Oct 31, 2017
…eing propogated correctly to tests."

This reverts commit 3df3558.
rinubaby pushed a commit to rinubaby/nunit that referenced this issue Oct 31, 2017
…om 3.7.1. This method was earlier on ParallelWorkItemDispatcher.
rinubaby pushed a commit to rinubaby/nunit that referenced this issue Nov 1, 2017
…y STA from 3.7.1. This method was earlier on ParallelWorkItemDispatcher."

This reverts commit ff42836.
rinubaby pushed a commit to rinubaby/nunit that referenced this issue Nov 1, 2017
…code was to get the ApartmentState from the parent, this was lost in recursion. Setting it correctly.
@rprouse rprouse modified the milestones: 3.8.2, 3.9 Nov 3, 2017
@rprouse rprouse added pri:high and removed confirm labels Nov 5, 2017
@rprouse
Copy link
Member

rprouse commented Nov 5, 2017

I tested with 3.9.0-dev-04639 and this has not been fixed with our recent parallel fixes.

This is possibly a duplicate of #2388

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

Successfully merging a pull request may close this issue.

5 participants