Autofixture: Is there a way to idenitfy which property is causing an exception?

Created on 7 Jul 2017  路  12Comments  路  Source: AutoFixture/AutoFixture

Hi guys,

As per my comment on another issue, I'm getting a System.OverflowException: "Value was either too large or too small for a Decimal."

I'm entirely expecting this to be caused by an issue with my underlying models. Trying to identify the field in question is proving challenging, due to the complex hierarchical nature of the objects.

Is there a way to debug the AutoFixture process to work out where it's getting stuck?

Many thanks,
Tom

For reference, here's the stack trace:

System.OverflowException : Value was either too large or too small for a Decimal.
at System.Decimal..ctor(Double value)
at System.Double.System.IConvertible.ToDecimal(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Ploeh.AutoFixture.DataAnnotations.RangeAttributeRelay.Create(RangeAttribute rangeAttribute, Object request)
at Ploeh.AutoFixture.DataAnnotations.RangeAttributeRelay.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.AutoPropertiesCommand1.Execute(Object specimen, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.AutoPropertiesCommand1.Execute(Object specimen, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.StableFiniteSequenceRelay.<>c__DisplayClass0_0.b__0(Object req)
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.EnumerableRelay.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at Ploeh.AutoFixture.Kernel.MethodInvoker.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.AutoPropertiesCommand1.Execute(Object specimen, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.AutoPropertiesCommand1.Execute(Object specimen, ISpecimenContext context) at Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.Postprocessor`1.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TracingBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.TerminatingWithPathSpecimenBuilder.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
at Ploeh.AutoFixture.SpecimenFactory.CreateT
at Ploeh.AutoFixture.SpecimenFactory.CreateT
at AccountsDispatcher.Tests.QBAddSalesReceiptTests.AddReceipt_WhenCalled_SavesToDataService() in C:\Users\twright\Documents\Visual Studio 2015\Projects\Redacted\Redacted.cs:line 37

question

All 12 comments

This is one more reference to implement #694. Currently, I'd suggest you the following:

  1. Update to the AutoFixture 3.50.3 (its symbols are present in feed).
  2. Add the https://nuget.smbsrc.net symbol feed to VS.
  3. Tick the Enable Source Server support option in VS Debugging options.

Configure VS to stop on exceptions. Next time the exception happens, you should be able to navigate through the Stack Trace and see which requests are present on stack:
image

Each request handling starts with RecursionGuard (and later sub-requests are created), so you can use these method invocations as a "frame" start indicator.

After you find the full request chain, you should understand which exact property causes the issue, so we could simplify the reproduction steps.

This approach should work in any VS version, but I've tested that with VS 2017.

Hi @zvirja,

Thanks for the response. Unfortunately VS doesn't seem to be able to find the symbols on https://nuget.smbsrc.net:

image

Are they available to download anywhere?

Many thanks,
Tom

Could you please double-check you updated AutoFixture to the most recent 3.50.3? It seems that symbols are not available for the previous AF versions. Also please specify the VS version and target framework version you use - it's very strange 馃槙

Sure, you can download them from the build artifacts. However, I'm not sure that Source feature will work nice if you specify pdb file manually.

OK, definitely using 3.50.3:

image

I'm using VS15 with ReSharper. My test project was targeting 4.5.2, but I've just changed this to 4.5 to match the SUT project - sadly this didn't help.

Anyway, I was able to download the PDB file from the build artefacts and load it manually. And (drum-roll please) I was able to find the issue.

Buried deep in my object tree, I traced the issue to this:

[Range(0.0, Double.MaxValue)]
public decimal Width { get; set; }

Which was a bit of a head-desk moment!

If you want to get to the bottom of the SrcSrv issue, I'll gladly lend a hand. Otherwise (if I was an anomaly) I think we can safely close the issue now.

Thanks for all your help!

Tom

That's fine that the initial issue has been fixed! 馃憤

As for the symbols, I even don't know how to troubleshoot that :open_mouth: I've just tried that approach on a couple of machines (VS 2015 + R# + Symbol Server + Enable Source Server support option) and everything worked fine. What is exactly the issue - symbols are not found or sources don't open?

Just to discard any caches - could you please test that with a plain solution? I installed AutoFixture + XUnit and put breakpoint to constructor:

public class TestContainer
{
  [Fact]
  public void Run()
  {
    var f = new Fixture();
    f.Create<ClassForBreakpoint>();
  }

  public class ClassForBreakpoint
  {
    public ClassForBreakpoint()
    {
      //put pb here.
    }
  }
}

Also please check that you can open symbol feed in browser, so it's accessible :) And one more thing is to ensure that Cache folder is specified on Symbol Settings configuration options page.

To take your last point first, I see a very concise XML doc at that URL:

<service xml:base="https://nuget.smbsrc.net/">
    <workspace>
        <atom:title type="text">Default</atom:title>
        <collection href="Packages">
            <atom:title type="text">Packages</atom:title>
        </collection>
    </workspace>
</service>

I'm not sure what I'm supposed to see though - is this normal?

I've recreated a bare-bones project:

using System;
using NUnit.Framework;
using Ploeh.AutoFixture;

namespace AutofixtureTest
{
    [TestFixture]
    public class Tests
    {
        [Test]
        public void Test1()
        {
            var fix = new Fixture();
            fix.Create<ClassUnderTest>();
        }
    }

    public class ClassUnderTest
    {
        public ClassUnderTest()
        {
            Console.WriteLine("in ctor");
        }
    }
}

_(I used NUnit, instead of XUnit - assuming this is irrelevant?)_

Unfortunately I get the same problem - no symbols loaded.

Oh, and the cache folder seems to be working - it has been populated with symbols from the MS servers.

Everything seems to be fine. Yep, it's expected that you will obtain a short XML doc from that site.

Could you share the Symbol Load Information log?
image

Also try adding a trailing slash - it helped me sometimes (like https://nuget.smbsrc.net/) or without https (i.e. http://nuget.smbsrc.net/) :)

Well, try adding all the possible configurations as SymbolServers:

  • https://nuget.smbsrc.net/
  • https://nuget.smbsrc.net
  • http://nuget.smbsrc.net/
  • http://nuget.smbsrc.net

It sounds weird but it helps and I'm unable to reach particular symbols using some particular one, while others work fine. It seems MS servers behave really well 馃槱

This is bizarre! I can navigate to that URL in my browser, but VS reports that it's not available:

SYMSRV: https://nuget.smbsrc.net: not available

https://nuget.smbsrc.net: Symbols not found on symbol server.
SYMSRV: C:\Users\twright\SrcSrv Symbols\Ploeh.AutoFixture.pdb\B3542BA9173C405197A5287ABC9B27821\Ploeh.AutoFixture.pdb - file not found

* ERROR: HTTP_STATUS_NOT_FOUND

* ERROR: HTTP_STATUS_NOT_FOUND

* ERROR: HTTP_STATUS_NOT_FOUND

As you suggested, I also tried the http/https and trailing slash combinations. I wonder if some wacky firewall rule is blocking traffic from VS? I'll raise it with our IT team.

In fact, it tries to download the following file: https://nuget.smbsrc.net/Ploeh.AutoFixture.pdb/B3542BA9173C405197A5287ABC9B27821/Ploeh.AutoFixture.pd_ (or http://nuget.smbsrc.net/Ploeh.AutoFixture.pdb/B3542BA9173C405197A5287ABC9B27821/Ploeh.AutoFixture.pd_). I don't know why, but sometimes VS fails.

It seems like some issues with VS or Symbol Server, as everything is present there.

Nevertheless, that should be fixed soon after we switch to SourceLink approach.

Agree - SourceLink looks tons easier.

I'll close this issue for now then.

Thanks for all your help. And sorry we couldn't get closure on the smbsrc thing.

Tom

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Eldar1205 picture Eldar1205  路  5Comments

JoshKeegan picture JoshKeegan  路  6Comments

tiesmaster picture tiesmaster  路  7Comments

mjfreelancing picture mjfreelancing  路  4Comments

ploeh picture ploeh  路  7Comments