Browse Source

Address Copilot review feedback on PR #25380

- Index.cshtml.cs: cache the rendered parameter name set so
  IsParameterVisible doesn't allocate a HashSet per call inside the cshtml
  loop; clarify per-rule semantics in comments (empty allow-list is an
  explicit "never show", null/unknown-key rules fail-open)
- forms-validation.md: drop the inaccurate IValidationRule reference and
  describe MudBlazor's actual validation surface (ValidationAttribute on
  the Validation parameter, Func<T,string>/Func<T,IEnumerable<string>>,
  optional FluentValidation)
- book-store/part-02.md: use {(int)context.Item.Type} for the BookType
  localization key to stay consistent with the rest of the tutorial
pull/25380/head
maliming 2 weeks ago
parent
commit
615917ceb8
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      docs/en/framework/ui/blazor/forms-validation.md
  2. 2
      docs/en/tutorials/book-store/part-02.md
  3. 15
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

2
docs/en/framework/ui/blazor/forms-validation.md

@ -59,7 +59,7 @@ _The example is provided by official Blazorise documentation._
{{if BlazorUI == "MudBlazor"}}
ABP Blazor UI built on top of [MudBlazor](https://mudblazor.com) uses MudBlazor's built-in form components and validation infrastructure. MudBlazor integrates with ASP.NET Core's `DataAnnotations` and supports custom validation through `IValidationRule`, `Func<T, IEnumerable<string>>`, or fluent validators.
ABP Blazor UI built on top of [MudBlazor](https://mudblazor.com) uses MudBlazor's built-in form components and validation infrastructure. MudBlazor accepts a `ValidationAttribute` (e.g. `[Required]`, `[EmailAddress]` from ASP.NET Core's `DataAnnotations`) on the input's `Validation` parameter, plus custom `Func<T, string>` / `Func<T, IEnumerable<string>>` delegates. FluentValidation can be plugged in the same way.
## Sample

2
docs/en/tutorials/book-store/part-02.md

@ -660,7 +660,7 @@ Open the `Books.razor` and replace the content as the following:
<PropertyColumn Property="x => x.Type"
Title="@L["Type"]">
<CellTemplate>
@L[$"Enum:BookType.{context.Item.Type}"]
@L[$"Enum:BookType.{(int)context.Item.Type}"]
</CellTemplate>
</PropertyColumn>
<PropertyColumn Property="x => x.PublishDate"

15
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

@ -90,6 +90,10 @@ namespace Volo.Docs.Pages.Documents.Project
public DocumentRenderParameters UserPreferences { get; set; } = new DocumentRenderParameters();
private HashSet<string>? _renderedParameterNamesCache;
private HashSet<string> RenderedParameterNames =>
_renderedParameterNamesCache ??= (DocumentPreferences?.Parameters?.Select(p => p.Name).ToHashSet() ?? new HashSet<string>());
public virtual bool IsParameterVisible(DocumentParameterDto parameter)
{
if (parameter.DependsOn == null || parameter.DependsOn.Count == 0)
@ -97,11 +101,14 @@ namespace Volo.Docs.Pages.Documents.Project
return true;
}
var renderedKeys = DocumentPreferences?.Parameters?.Select(p => p.Name).ToHashSet() ?? new HashSet<string>();
// A rule passes if it's malformed/irrelevant (fail-open) OR the current value matches the allow-list.
// Per-rule semantics:
// - rule.Value == null : malformed list, skip the rule (fail-open)
// - key not in current document : rule references an unknown parameter, skip (fail-open)
// - rule.Value.Count == 0 : explicit empty allow-list, hide the parameter (author intent: "never show")
// - current value not in allow-list: hide
// - current value in allow-list : pass this rule
return parameter.DependsOn.All(rule =>
rule.Value == null || !renderedKeys.Contains(rule.Key) // skip malformed / unknown-key rules
rule.Value == null || !RenderedParameterNames.Contains(rule.Key)
|| (rule.Value.Count > 0
&& UserPreferences.TryGetValue(rule.Key, out var current)
&& rule.Value.Contains(current)));

Loading…
Cancel
Save