<commit_before>﻿using Serenity.ComponentModel;
using Serenity.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;

namespace Serenity.PropertyGrid
{
    public partial class BasicPropertyProcessor : PropertyProcessor
    {
        private void SetTitle(IPropertySource source, PropertyItem item)
        {
            if (source.Property != null)
            {
                var attr = source.Property.GetCustomAttribute<DisplayNameAttribute>(false);
                if (attr != null)
                    item.Title = attr.DisplayName;
            }

            if (item.Title == null)
            {
                var basedOnField = source.BasedOnField;

                if (!ReferenceEquals(null, basedOnField))
                {
                    Field textualField = null;
                    if (basedOnField.TextualField != null)
                        textualField = basedOnField.Fields.FindFieldByPropertyName(basedOnField.TextualField) ??
                            basedOnField.Fields.FindField(basedOnField.TextualField);

                    if (!ReferenceEquals(null, textualField))
                    {
                        item.Title = !object.ReferenceEquals(null, textualField.Caption) ?
                            textualField.Caption.Key : textualField.Title;
                    }
                    else
                    {
                        item.Title = !object.ReferenceEquals(null, basedOnField.Caption) ?
                            basedOnField.Caption.Key : basedOnField.Title;
                    }
                }
                else
                    item.Title = item.Name;
            }
        }
    }
}<commit_msg>[BREAKING CHANGE!] titles for foreign ID fields are no longer determined by Textual Field. DisplayName attribute on the ID field itself is used instead.<commit_after>﻿using Serenity.ComponentModel;
using Serenity.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;

namespace Serenity.PropertyGrid
{
    public partial class BasicPropertyProcessor : PropertyProcessor
    {
        private void SetTitle(IPropertySource source, PropertyItem item)
        {
            if (source.Property != null)
            {
                var attr = source.Property.GetCustomAttribute<DisplayNameAttribute>(false);
                if (attr != null)
                    item.Title = attr.DisplayName;
            }

            if (item.Title == null)
            {
                var basedOnField = source.BasedOnField;

                if (!ReferenceEquals(null, basedOnField))
                {
                    item.Title = !object.ReferenceEquals(null, basedOnField.Caption) ?
                        basedOnField.Caption.Key : basedOnField.Title;
                }
                else
                    item.Title = item.Name;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07535641547861507, 'fraction_numerical': 0.0, 'mean_word_length': 1.5648389904264577, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4268422', 'n_tokens_mistral': 718, 'n_tokens_neox': 677, 'n_words': 147}