Comments (2)
Hi @adamhill ,
Thank you for bringing the issue to attention. 😎
You're right. Bogus is not compatible with Xamarin at the moment. I think I tried Xamarin some time ago and ran into the same issue with as you've described above. I've just been too lazy to fix the problem because it's not an immediate need of mine in my current projects.
I suspect the crux of the issue is we're missing an explicit build target for profile259/xamarin
in our build process. Additionally, there might be some .NET cross-platform reflection APIs that probably need some tweaking to be fully compatible with Xamarin.
There are a few ways we can proceed to get this resolved:
- I'd be happy to accept a PR for Xamarin compatibility. Just fork Bogus and explore the code on what needs to be fixed. Once you send in the PR:
a) We'll review the PR.
b) Make revisions
c) Merge and Publish - You can set up a bounty for about $200 and I'll get this implemented. I can aim to get it done within 72 hours or so.
- Wait for someone else to do the work.
Some helpful guidelines on modifying Bogus' source:
- Run
build clean
before sending in a PR. - Run
build test
to ensure all tests pass. - Aim for making as little changes to the source code as possible. The smaller the PR the easier it is for me to review. Additionally, smaller changes make it easier for us to rebase some of our work-in-progress feature branches.
Please let me know how you'd like to proceed.
Also, just as a heads-up (no offense) I'll be closing this issue if we don't have a path forward because I'm OCD w.r.t unresolved-open issues in GitHub that might linger on for years. IMHO, GitHub issues are like trying to get to Inbox 📭 zero! Hehe.
Thanks,
Brian
🚗 🚙 "Let the good times roll..."
from bogus.
Hey @adamhill ,
FYI. Latest release v17 (compiled against .NET Standard 2.0) appears to run on Xamarin Mobile now:
Here's how I got it working:
- Ensure you have latest VS 2017 (15.3) update.
- You'll need to create a .NET Standard Library 2.0 (ie:
BougsApp1
). - Reference Bogus v17 in your .NET Standard Shared Libary (
BougsApp1
). - Reference Bogus v17 and your .NET Standard Shared Libary (
BogusApp1
) in your*.Android
project. - Recompile and build.
Here's a screenshot and XAML samples that I used to get it working:
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BogusApp1"
x:Class="BogusApp1.MainPage">
<StackLayout>
<Label Text="Welcome to Xamarin Forms!"
VerticalOptions="Center"
HorizontalOptions="Center" />
<Label Text="" VerticalOptions="Center" HorizontalOptions="Center" x:Name="lblName" />
<Label Text="" VerticalOptions="Center" HorizontalOptions="Center" x:Name="lblAge" />
<Label Text="" VerticalOptions="Center" HorizontalOptions="Center" x:Name="lblEmail" />
<Label Text="Korean Lorem:" VerticalOptions="Center" HorizontalOptions="Center" />
<Label Text="" VerticalOptions="Center" HorizontalOptions="Center" x:Name="lblLorem" />
<Button Clicked="Button_OnClicked" Text="Generate Random Stuff" x:Name="cmdButton"></Button>
</StackLayout>
</ContentPage>
Mainpage.xaml.cs
using System;
using Bogus;
using Bogus.DataSets;
using Xamarin.Forms;
namespace BogusApp1
{
public class Person
{
public string FirstName { get; set; }
public string LastName;
public int Age;
public string Email { get; set; }
}
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_OnClicked(object sender, EventArgs e)
{
var personFaker = new Faker<Person>()
.RuleFor(p => p.FirstName, f => f.Person.FirstName)
.RuleFor(p => p.LastName, f => f.Person.LastName)
.RuleFor(p => p.Age, f => f.Random.Int(18, 38))
.RuleFor(p => p.Email, f => f.Person.Email);
var fakePerson = personFaker.Generate();
this.lblName.Text = $"{fakePerson.FirstName} {fakePerson.LastName}";
this.lblAge.Text = $"Age: {fakePerson.Age}";
this.lblEmail.Text = $"{fakePerson.Email}";
var koLorem = new Lorem("ko");
this.lblLorem.Text = $"{koLorem.Sentence(3, 2)}";
}
}
}
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.