Comments (6)
Hi @andrejohansson thanks very much!
It could possibly be a bug, could you post an example of your model and faker setup? Also, what nuget version are you using?
It would help a lot and I'll take a look asap.
from bogus.
@andrejohansson I have a possible fix for read-only properties. Please give v3.0.5-beta-4 a try on NuGet. Bogus now ignores read-only properties.
Let me know if it fixes your issue. Thanks.
-Brian
from bogus.
Hello again, sorry for the late reply. I updated on nuget to 3.0.5.0 but the problem remains.
The error is:
Cannot generate BokaMera.API.ServiceModel.Models.BookedEvent because strict mode is enabled on this type and some properties/fields have no rules.
I have rules for 17 of 19 properties and two properties are read Only. I have posted the model and rules in this gist: https://gist.github.com/andrejohansson/39926be13017cb607370
from bogus.
Hi @andrejohansson ,
Thanks very much for your model and faker setup. I was able to reproduce the issue.
Bogus v3.0.6 and v3.0.6-beta-1 should have the fix published on NuGet.
Additionally, I added a new method that can be used in conjunction with StrictMode
. You can use .Ignore(c => c.SomePropertyOrField)
and the field will be removed from StrictMode
checking.
Please give them a try and let me know if it works for you. Hope that helps.
Brian
from bogus.
Works like a charm, thank you!
from bogus.
This workaround also helped me on obsolete field that are marked to give compilation error on use, e.g.:
[Obsolete("Use property 'xxx' instead", true)]
public string SomeOldProperty { get; set; }
When using StrictMode(true)
there is no way to reference the property as an expression without the compiler throwing an error, so I had to do it by it's name:
.Ignore("SomeOldProperty") // Obsolete property
Hopefully this comment might help someone in the future.
I have also created a new feature request to silently ignore obsolete fields that is marked to generate compile time errors: #450
from bogus.
Related Issues (20)
- Bogus is slow on Blazor WASM HOT 1
- Add Amka number (Greek social security number) to Extensions.Greece
- Option to filter out en_AU_ocker
- Generating a deep object graph based on rules HOT 1
- Xamarin fails to publish due to Nordic characters in Method names HOT 2
- Add Direct License Information In Nuget metadata HOT 2
- Foreign Key Constraint Violation Issue with Bogus and EF Core
- Binder throw ambiguous match exception for object with read only indexer property that has two implementations in base class HOT 2
- First and Full names are incorrectly generated with locale "sv" HOT 2
- Request to add language English (Hong Kong) / locale en_HK
- Faker.Tv() is missing from Bogus.Hollywood HOT 3
- Feature request: New localized data: Word(s).
- Add ability to except random numbers HOT 2
- Update Denmark (da) locale from faker-js
- Nuget for .NET 8.0.x HOT 4
- Random history facts generation
- Are Randomizer's number ranges inclusive or exclusive? HOT 3
- bogus is missing NuGet package README file HOT 1
- .NET 8 support HOT 9
- Gender-digit is incorrect for Swedish Personnummer generation HOT 3
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 bogus.