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

[Enhancement] WithConventions aliases allow expression #92

Open
c-conklin opened this issue Sep 26, 2022 · 0 comments
Open

[Enhancement] WithConventions aliases allow expression #92

c-conklin opened this issue Sep 26, 2022 · 0 comments

Comments

@c-conklin
Copy link

c-conklin commented Sep 26, 2022

AutoBogus.Conventions allow aliases to be configured, expanding the property name targets associated with a given convention mapping. The following adds AnotherEmail and AlternateEmail property names as candidates for the Email generator:

AutoFaker.Configure(builder =>
{
  builder.WithConventions(config =>
  {
    config.Email.Aliases(new [] { "AnotherEmail", "AlternateEmail" });  // Generates an email value for members named AnotherEmail & AlternateEmail
  });
});

Feature Request

Allow Aliases with expression parameter.
Example:

AutoFaker.Configure(builder =>
{
  builder.WithConventions(config =>
  {
    config.Email.Aliases<EntityName>(propName => propName.Contains("Email"));  // Generates an email value for members with names containing Email
  });
});

Work Around

builder.WithConventions(config =>
  {
      var emailProps = (from prop in typeof(<EntityType>).GetProperties() where prop.Name.Contains("Email") select prop.Name).ToArray();
      config.Email.Aliases(emailProps);
  })

I'm unsure how much overhead or complexity is involved with such a feature. However, this is quite useful when dealing with large flattened entities.

@c-conklin c-conklin changed the title WithConventions aliases allow expression [Enhancement] WithConventions aliases allow expression Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant