Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile 259 Compatibility? #78

Closed
adamhill opened this issue Jul 10, 2017 · 2 comments
Closed

Profile 259 Compatibility? #78

adamhill opened this issue Jul 10, 2017 · 2 comments

Comments

@adamhill
Copy link

adamhill commented Jul 10, 2017

Is there any version of Bogus that is compatible with PCL Profile 259 in Xamarin? I tried all the way up to 7.1.2, which is the one just before .NET Core support was official. I always get:

Could not install package 'Bogus 7.1.3'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259'

when I try to add the the Nuget package.

Even though the Dependency is .NET 4.0 and 259 is Version=4.5 shouldn't I be able to add it? I thought dependencies were always >= <X.X>

Thanks.

@bchavez
Copy link
Owner

bchavez commented Jul 11, 2017

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

@bchavez
Copy link
Owner

bchavez commented Aug 25, 2017

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)}";
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants