<commit_before>﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ConstructorParametersRequiredContractResolver.cs">
//     Copyright (c) 2016. All rights reserved. Licensed under the MIT license. See LICENSE file in
//     the project root for full license information.
// </copyright>
// <auto-generated>
// Sourced from NuGet package. Will be overwritten with package update except in Spritely.Recipes source.
// </auto-generated>
// --------------------------------------------------------------------------------------------------------------------

namespace Spritely.Recipes
{
    using System;
    using System.Reflection;

    using Newtonsoft.Json;
    using Newtonsoft.Json.Serialization;

    /// <summary>
    /// Resolves member mappings for a type using camel casing property names.
    /// Also requires that constructor parameters are defined in the json string
    /// when deserializing, for types with non-default constructors. 
    /// </summary>
    /// <remarks>
    /// See <a href="https://stackoverflow.com/questions/37416233/json-net-should-not-use-default-values-for-constructor-parameters-should-use-de"/>
    /// </remarks>
#if !RecipesProject
    [System.Diagnostics.DebuggerStepThrough]
    [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
    [System.CodeDom.Compiler.GeneratedCode("Spritely.Recipes", "See package version number")]
#endif
    public class CamelCasePropertyNamesWithConstructorParametersRequiredContractResolver
        : CamelCasePropertyNamesContractResolver
    {
        /// <summary>
        /// As of 7.0.1, Json.NET suggests using a static instance for "stateless" contract resolvers, for performance reasons.
        /// <a href="http://www.newtonsoft.com/json/help/html/ContractResolver.htm"/>
        /// <a href="http://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Serialization_DefaultContractResolver__ctor_1.htm"/>
        /// "Use the parameterless constructor and cache instances of the contract resolver within your application for optimal performance."
        /// Also, <a href="https://stackoverflow.com/questions/33557737/does-json-net-cache-types-serialization-information"/>
        /// </summary>
        public static CamelCasePropertyNamesWithConstructorParametersRequiredContractResolver Instance
            => new CamelCasePropertyNamesWithConstructorParametersRequiredContractResolver();

        /// <inheritdoc />
        protected override JsonProperty CreatePropertyFromConstructorParameter(JsonProperty matchingMemberProperty, ParameterInfo parameterInfo)
        {
            var property = base.CreatePropertyFromConstructorParameter(matchingMemberProperty, parameterInfo);

            if ((property != null) && (matchingMemberProperty != null))
            {
                var required = matchingMemberProperty.Required;
                if (required == Required.Default)<commit_msg>fix for situation where constructor parameter does not match a property in the type, and is also missing in json<commit_after>﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ConstructorParametersRequiredContractResolver.cs">
//     Copyright (c) 2016. All rights reserved. Licensed under the MIT license. See LICENSE file in
//     the project root for full license information.
// </copyright>
// <auto-generated>
// Sourced from NuGet package. Will be overwritten with package update except in Spritely.Recipes source.
// </auto-generated>
// --------------------------------------------------------------------------------------------------------------------

namespace Spritely.Recipes
{
    using System;
    using System.Reflection;

    using Newtonsoft.Json;
    using Newtonsoft.Json.Serialization;

    /// <summary>
    /// Resolves member mappings for a type using camel casing property names.
    /// Also requires that constructor parameters are defined in the json string
    /// when deserializing, for types with non-default constructors. 
    /// </summary>
    /// <remarks>
    /// See <a href="https://stackoverflow.com/questions/37416233/json-net-should-not-use-default-values-for-constructor-parameters-should-use-de"/>
    /// </remarks>
#if !RecipesProject
    [System.Diagnostics.DebuggerStepThrough]
    [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
    [System.CodeDom.Compiler.GeneratedCode("Spritely.Recipes", "See package version number")]
#endif
    public class CamelCasePropertyNamesWithConstructorParametersRequiredContractResolver
        : CamelCasePropertyNamesContractResolver
    {
        /// <summary>
        /// As of 7.0.1, Json.NET suggests using a static instance for "stateless" contract resolvers, for performance reasons.
        /// <a href="http://www.newtonsoft.com/json/help/html/ContractResolver.htm"/>
        /// <a href="http://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Serialization_DefaultContractResolver__ctor_1.htm"/>
        /// "Use the parameterless constructor and cache instances of the contract resolver within your application for optimal performance."
        /// Also, <a href="https://stackoverflow.com/questions/33557737/does-json-net-cache-types-serialization-information"/>
        /// </summary>
        public static CamelCasePropertyNamesWithConstructorParametersRequiredContractResolver Instance
            => new CamelCasePropertyNamesWithConstructorParametersRequiredContractResolver();

        /// <inheritdoc />
        protected override JsonProperty CreatePropertyFromConstructorParameter(JsonProperty matchingMemberProperty, ParameterInfo parameterInfo)
        {
            if (matchingMemberProperty == null)
            {
                string message = parameterInfo == null
                                     ? "All constructor parameters are required; found one that is not specified in json"
                                     : $"This constructor parameter is required, but not specified in json: {parameterInfo.Name}";
                throw new JsonSerializationException(message);
            }

            var property = base.CreatePropertyFromConstructorParameter(matchingMemberProperty, parameterInfo);

            if ((property != null) && (matchingMemberProperty != null))
            {
                var required = matchingMemberProperty.Required;
                if (required == Required.Default)
{'fraction_non_alphanumeric': 0.16090364223144307, 'fraction_numerical': 0.007376671277086215, 'mean_word_length': 2.3807792207792207, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1123119', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1434, 'n_words': 398}