bchavez / Bogus

:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Other
8.66k stars 495 forks source link

Generating Fake Address - cannot be inferred from the usage #417

Closed bluedog13 closed 2 years ago

bluedog13 commented 2 years ago

Version Information

Software Version(s)
Bogus NuGet Package 34.0.2
.NET Core? 6.0
.NET Full Framework?
Windows OS?
Linux OS? yes
Visual Studio? No (Rider)

What locale are you using with Bogus?

No locale. (Tried using "en" but no luck)

What's the problem?

I am trying to generate some address using Bogus. I see the below error

  UnitTest1.cs(20, 14): [CS0411] The type arguments for method 'Faker<Address>.RuleFor<TProperty>(Expression<Func<Address, TProperty>>, Func<Faker, Address, TProperty>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

What possible solutions have you considered?

Tried debugging - not sure why it's so hard to generate some random addresses.

Do you have sample code to show what you're trying to do?

Below is the sample code

var address = new Faker<Address>()
            .RuleFor(a => a.City, f => f.Address.City)
            .RuleFor(a => a.State, f => f.Address.State)
            .RuleFor(a => a.Latitude, f => f.Address.Latitude)
            .RuleFor(a => a.Longitude, f => f.Address.Longitude)
            .Generate(100);

(Please be complete. Provide all code necessary to run your example in LINQPad.) (The more complete code examples are, the more accurate answers will be.) (https://www.linqpad.net)

bluedog13 commented 2 years ago

This has been resolved.

The confusion was due to the class name being the same between the actual entity and faker.