-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(DockView): remove EditorRequired attribute #985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,15 +14,6 @@ namespace BootstrapBlazor.Components; | |||||
| /// </summary> | ||||||
| public partial class DockViewV2 | ||||||
| { | ||||||
| /// <summary> | ||||||
| /// <para lang="zh">获得/设置 DockView 名称,默认为 null,用于本地存储标识</para> | ||||||
| /// <para lang="en">Gets or sets the DockView name. Default is null and it is used for local storage identification</para> | ||||||
| /// </summary> | ||||||
| [Parameter] | ||||||
| [EditorRequired] | ||||||
| [NotNull] | ||||||
| public string? Name { get; set; } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// <para lang="zh">获得/设置 布局配置</para> | ||||||
| /// <para lang="en">Gets or sets the layout configuration</para> | ||||||
|
|
@@ -128,6 +119,14 @@ public partial class DockViewV2 | |||||
| [Parameter] | ||||||
| public string? Version { get; set; } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// <para lang="zh">获得/设置 DockView 名称,默认为 null,用于本地存储标识</para> | ||||||
| /// <para lang="en">Gets or sets the DockView name. Default is null and it is used for local storage identification</para> | ||||||
| /// </summary> | ||||||
| [Parameter] | ||||||
| [NotNull] | ||||||
| public string? Name { get; set; } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// <para lang="zh">获得/设置 是否启用本地存储布局,默认为 null</para> | ||||||
| /// <para lang="en">Gets or sets whether local storage layout is enabled. Default is null</para> | ||||||
|
|
@@ -186,6 +185,20 @@ protected override void OnInitialized() | |||||
| ThemeProviderService.ThemeChangedAsync += OnThemeChangedAsync; | ||||||
| } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// <inheritdoc/> | ||||||
| /// </summary> | ||||||
| protected override void OnParametersSet() | ||||||
| { | ||||||
| base.OnParametersSet(); | ||||||
|
|
||||||
| // 开启本体存储未提供 Name 时抛出异常提示 | ||||||
|
||||||
| // 开启本体存储未提供 Name 时抛出异常提示 | |
| // 开启本地存储未提供 Name 时抛出异常提示 |
Copilot
AI
Apr 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thrown InvalidOperationException message could be more actionable for consumers. Consider including the component/parameter names via nameof(Name)/nameof(EnableLocalStorage) and clarifying that local storage may be enabled either via the parameter or global DockViewOptions, so users know what to change.
| throw new InvalidOperationException("Name must be provided when local storage is enabled."); | |
| throw new InvalidOperationException($"{nameof(Name)} must be provided when local storage is enabled. Local storage can be enabled either by the {nameof(EnableLocalStorage)} parameter or by global {nameof(DockViewOptions)} configuration."); |
Copilot
AI
Apr 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalStorageKey is now null when local storage is disabled, but some JS code (e.g. dockview-utils.js) reads options.localStorageKey outside the enableLocalStorage guard. This can cause unexpected access to localStorage keys like null-panels/undefined-panels, and potentially JSON parse errors if those keys exist. Consider always providing a stable non-null key, or updating the JS side to only access localStorageKey when enableLocalStorage is true.
| private string? LocalStorageKey => IsEnableLocalStorage ? $"{GetPrefixKey()}-{Name}-{GetVersion()}" : null; | |
| private string LocalStorageKey => $"{GetPrefixKey()}-{Name}-{GetVersion()}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nameis declared as nullable (string?) and is intentionally optional now (only required when local storage is enabled), but it is still annotated with[NotNull]. That attribute communicates to the nullability analyzer that the property getter never returns null, which is no longer true and can lead to incorrect flow analysis. Consider removing[NotNull](or makingNamenon-nullable again if it must always be supplied).