<commit_before>﻿using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace FilterLists.Data.Seed.Extensions
{
    public static class SeedExtension
    {
        public static void HasDataJsonFile<TEntity>(this EntityTypeBuilder entityTypeBuilder)
        {
            string path = Path.Combine("../../../data", $"{typeof(TEntity).Name}.json");
            if (File.Exists(path))
            {
                var entitiesJson = File.ReadAllText(path);
                var entities = JsonSerializer.Deserialize<IEnumerable<TEntity>>(entitiesJson, new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                });
                entityTypeBuilder.HasData((IEnumerable<object>)entities);
            }
        }
    }
}<commit_msg>resolve CA1062 warning<commit_after>﻿using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using Ardalis.GuardClauses;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace FilterLists.Data.Seed.Extensions
{
    public static class SeedExtension
    {
        public static void HasDataJsonFile<TEntity>(this EntityTypeBuilder entityTypeBuilder)
        {
            Guard.Against.Null(entityTypeBuilder, nameof(entityTypeBuilder));

            var path = Path.Combine("../../../data", $"{typeof(TEntity).Name}.json");
            if (!File.Exists(path)) return;

            var entitiesJson = File.ReadAllText(path);
            var entities = JsonSerializer.Deserialize<IEnumerable<TEntity>>(entitiesJson, new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            });
            entityTypeBuilder.HasData((IEnumerable<object>)entities);
        }
    }
}
{'fraction_non_alphanumeric': 0.10245231607629428, 'fraction_numerical': 0.0021798365122615805, 'mean_word_length': 2.6646706586826348, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2494697', 'n_tokens_mistral': 487, 'n_tokens_neox': 473, 'n_words': 81}