Giter VIP home page Giter VIP logo

Comments (6)

bchavez avatar bchavez commented on May 21, 2024

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.

bchavez avatar bchavez commented on May 21, 2024

@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.

andrejohansson avatar andrejohansson commented on May 21, 2024

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.

bchavez avatar bchavez commented on May 21, 2024

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.

andrejohansson avatar andrejohansson commented on May 21, 2024

Works like a charm, thank you!

from bogus.

Gakk avatar Gakk commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.