<commit_before>﻿namespace MassTransit.Internals.Reflection
{
    using System;
    using System.Diagnostics;
    using System.Linq.Expressions;
    using System.Reflection;
    using System.Threading;
    using System.Threading.Tasks;
    using MassTransit;


    public class WriteProperty<T, TProperty> :
        IWriteProperty<T, TProperty>
    {
        Action<T, TProperty> _setMethod;

        public WriteProperty(Type implementationType, PropertyInfo propertyInfo)
        {
            if (typeof(T).GetTypeInfo().IsValueType)
                throw new ArgumentException("The message type must be a reference type");

            var implementationPropertyInfo = implementationType.GetProperty(propertyInfo.Name);
            if (propertyInfo == null)
                throw new ArgumentException("The implementation does not have a property named: " + propertyInfo.Name);

            var setMethod = implementationPropertyInfo.GetSetMethod(true);
            if (setMethod == null)
                throw new ArgumentException("The property does not have an accessible set method");

            Name = propertyInfo.Name;

            void SetUsingReflection(T entity, TProperty property) => setMethod.Invoke(entity, new object[] {property});
<commit_msg>Replaced propertyInfo by implementationPropertyInfo in order to prevent null ref<commit_after>﻿namespace MassTransit.Internals.Reflection
{
    using System;
    using System.Diagnostics;
    using System.Linq.Expressions;
    using System.Reflection;
    using System.Threading;
    using System.Threading.Tasks;
    using MassTransit;


    public class WriteProperty<T, TProperty> :
        IWriteProperty<T, TProperty>
    {
        Action<T, TProperty> _setMethod;

        public WriteProperty(Type implementationType, PropertyInfo propertyInfo)
        {
            if (typeof(T).GetTypeInfo().IsValueType)
                throw new ArgumentException("The message type must be a reference type");

            var implementationPropertyInfo = implementationType.GetProperty(propertyInfo.Name);
            if (implementationPropertyInfo == null)
                throw new ArgumentException("The implementation does not have a property named: " + propertyInfo.Name);

            var setMethod = implementationPropertyInfo.GetSetMethod(true);
            if (setMethod == null)
                throw new ArgumentException("The property does not have an accessible set method");

            Name = propertyInfo.Name;

            void SetUsingReflection(T entity, TProperty property) => setMethod.Invoke(entity, new object[] {property});

{'fraction_non_alphanumeric': 0.07589114603296282, 'fraction_numerical': 0.0, 'mean_word_length': 2.9786585365853657, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3014406', 'n_tokens_mistral': 619, 'n_tokens_neox': 606, 'n_words': 183}