Comments (3)
I have no clue what you are trying to achieve, but the bug is not in AutoFixture but in your code.
There is no recursion in your classes Top/Bottom, so basically everything works like it should if you remove the addition of the behavior.
But lets assume your original problem is recursion, then your IsSeededRequestComparer is the problem. Basically you are saying that every SeededRequest is the same. So at the crash comes when a SeededRequest for Top is equal to a SeededRequest of Nullable.
Just change
public ISpecimenBuilderNode Transform(ISpecimenBuilder builder)
{
return new RecursionGuard(builder, new OmitOnRecursionHandler(), new IsSeededRequestComparer(), Depth);
}
to
public ISpecimenBuilderNode Transform(ISpecimenBuilder builder)
{
return new RecursionGuard(builder, new OmitOnRecursionHandler(), Depth);
}
and also everything works as expected.
from autofixture.
Thank you for responding
I have a 1000 or so classes that i am trying to generate. they are deeply nested and many of them have recursive loops. For my test i want to go 1 or 2 levels into the nesting when generating the top level class. With this level of nesting generating 1 class might take 20min or more. So, i am trying to limit the depth of generation. After applying the proposed solution from #1032 i ran into this issue but they did not mention the issue back then.
I will give this new info a try thank you.
from autofixture.
So, the code in my initial post does not work for me because certain types count for an additional level in the nesting counting. For example public int? NumberTwo {get;set;}
counts one level for the Nullable and then one level for the int. so the int returns omitspecimen and then the nullable creation blows up. I hacked my way to something that works well enough for my purposes. I would not recommend using it as is but will hopefully help someone else.
I took the initial post from #1032 and modified the currentDepth calculation so that a nullable int would not get a nest increase. and would potentially work out.
int currentDepth = -1;
var seededRequest = (SeededRequest)request;
var requestsForCurrentThread = this.GetMonitoredRequestsForCurrentThread();
if (requestsForCurrentThread.Count > 0)
{
int depthIncrease = 1;
if (IsType(seededRequest.Request)
&& (IsNullableValue(seededRequest.Request) || IsValue(seededRequest.Request)))
{
depthIncrease = 0;
}
currentDepth = requestsForCurrentThread.Max(x => x.Depth) + depthIncrease;
}
but when i brought it over to my actual usage i had a bunch of issues with generic types like dictionaries where they would add a whole bunch of nesting levels to the counter. For example a dictionary is made up of keyvalue pairs which is made up of the actual type parameters. a that point i gave up and slapped a trycatch on the return and called it good enough.
else
{
try
{
return this.Builder.Create(request, context);
}
catch (Exception)
{
return new OmitSpecimen(); // Hack
}
}
from autofixture.
Related Issues (20)
- β¨ Support FakeItEasy 8 HOT 1
- β¨ Support for NUnit 4 HOT 18
- π FromFactory doesn't honor the Range attribute HOT 6
- β¨ Accept `ISpecimentBuilder` as value generator for `With` HOT 1
- β¨ DataAnnotations support for specimen factories
- π Auto properties on large record types causes severe performance degradation HOT 4
- ICustomization for DateOnly causes a hang. HOT 1
- π RandomNumericSequenceGenerator with limits, can create values outside of these limits in certain scenarios HOT 1
- autofixture is missing NuGet package README file HOT 7
- autofixture.automoq is missing NuGet package README file HOT 1
- `IAsyncEnumerable` generates an infinite sequence π HOT 2
- π SourceLink doesn't work because of incorrect casing in GitHub URLs HOT 4
- π¨ Vulnerability in packages System.Net.Http and System.Text.RegularExpressions HOT 3
- Builder.WithVariations⨠HOT 4
- π FromSeed() does not set value from seeded object property HOT 4
- π Cannot create model with DateOnly field HOT 3
- π (v5) `MemberAutoData` and `ClassAutoData` override explicit `null` in data source HOT 2
- π v5 `MemberAutoData` does not find static members on base classes
- π AutoMoq fails to work with TimeProvider in .NET 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autofixture.