public RequiredAttributeDescriptor Build()
        {
            var validationDiagnostics = Validate();
            var diagnostics           = new HashSet <RazorDiagnostic>(validationDiagnostics);

            if (_diagnostics != null)
            {
                diagnostics.UnionWith(_diagnostics);
            }

            var displayName = NameComparisonMode == RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch ? string.Concat(Name, "...") : Name;
            var rule        = new DefaultRequiredAttributeDescriptor(
                Name,
                NameComparisonMode,
                Value,
                ValueComparisonMode,
                displayName,
                diagnostics?.ToArray() ?? Array.Empty <RazorDiagnostic>());

            return(rule);
        }
        public RequiredAttributeDescriptor Build()
        {
            var validationDiagnostics = Validate();
            var diagnostics           = new HashSet <RazorDiagnostic>(validationDiagnostics);

            if (_diagnostics != null)
            {
                diagnostics.UnionWith(_diagnostics);
            }

            var displayName = GetDisplayName();
            var rule        = new DefaultRequiredAttributeDescriptor(
                Name,
                NameComparisonMode,
                Value,
                ValueComparisonMode,
                displayName,
                diagnostics?.ToArray() ?? Array.Empty <RazorDiagnostic>(),
                new Dictionary <string, string>(Metadata));

            return(rule);
        }