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

Stack overflow with Custom Spec #3

Closed
nuclearsuitcase opened this issue Sep 24, 2018 · 5 comments
Closed

Stack overflow with Custom Spec #3

nuclearsuitcase opened this issue Sep 24, 2018 · 5 comments

Comments

@nuclearsuitcase
Copy link

I've created a custom spec class similar to the "CustomerFromCountrySpec" in the README.md. When I create my custom class, within a second or two I get a stack overflow.

Here's my class:

public class CustomSpec: Specification<string>
{
        public string Name { get; set; }

        public CustomSpec(string name)
        {
            Name = name;
        }

        public override Expression<Func<string, bool>> ToExpression()
        {
           return  s => s == Name;
        }
}

Here's my test method

[Test]
public void CustomClassShouldntStackOverflow()
{
            var s = new CustomSpec("Jose");
            Assert.True(true); //Put a break point here and let it set for 5 seconds, you'll stack overflow.
}
@navozenko
Copy link
Owner

navozenko commented Sep 25, 2018

Hi, stroebele.
Unfortunately I could not reproduce the issue. Can you give a full example of the project? Which .NET framework? What OS? What version of .NUnit are you using? What VS? What test runner?

@nuclearsuitcase
Copy link
Author

I created a PR #4 with a unit test that recreates the issue for me. I wish there was a better way of catching the error.

@navozenko
Copy link
Owner

navozenko commented Sep 25, 2018

I can not reproduce the exception. I have run your test with both TestDriven.NET and Microsoft Test Explorer.

And in truth, I generally do not understand where StackoverflowException can comes from when execution is suspendedat the breakpoint, because LinqSpecs is a single-threaded library (threads and tasks are not used). Also Specification class has no constructor and static fields.

Could this be a bug of the test runner you are using? Which runner you are using? May be ReSharper?.. it is very bugged.. Try another test runner please.

And post a complete exception message including a stacktrace please.
Also I ask you to comment line with var customSpec = new CustomSpec("Jose"); Does exception disappear?

@nuclearsuitcase
Copy link
Author

You nailed it, Resharper was the problem. Even using MS Test Explorer would cause a crash, however once Resharper was completely disabled, everything worked fine. Thanks for your help.

@navozenko
Copy link
Owner

OK, thanks.

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

No branches or pull requests

2 participants