Code Monkey home page Code Monkey logo

Comments (2)

bchavez avatar bchavez commented on May 19, 2024

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:

  1. 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
  2. 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.
  3. 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.

bchavez avatar bchavez commented on May 19, 2024

Hey @adamhill ,

FYI. Latest release v17 (compiled against .NET Standard 2.0) appears to run on Xamarin Mobile now:

screen_526


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:

devenv_528

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)

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.