Skip to content
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

Format.Items and Format.HasNested getting out-of-sync #415

Closed
imprima opened this issue Jun 8, 2024 · 0 comments · Fixed by #416
Closed

Format.Items and Format.HasNested getting out-of-sync #415

imprima opened this issue Jun 8, 2024 · 0 comments · Fixed by #416
Assignees

Comments

@imprima
Copy link
Member

imprima commented Jun 8, 2024

Format.Items and Format.HasNested can get out-of-sync.

The Parser sets HasNested correctly when adding a Placeholder:

_resultFormat.Items.Add(newPlaceholder);
_resultFormat.HasNested = true;

However, HasNested will not change automatically in case a Placeholder is added or removed, e.g. in an extension.

Consequently this overload should marked as obsolete, as it also sets HasNested independently.

public Format Initialize(SmartSettings smartSettings, string baseString, int startIndex, int endIndex, bool hasNested)
{
base.Initialize(smartSettings, null, baseString, startIndex, endIndex);
ParentPlaceholder = null;
HasNested = hasNested;
return this;
}

@axunonb axunonb self-assigned this Jun 8, 2024
axunonb added a commit to axunonb/SmartFormat that referenced this issue Jun 8, 2024
Closes  axuno#415
* `Format.HasNested` checks Items for existing `Placeholder`
* Update Format Class Initialization (mark overload with arg `bool hasNested` as obsolete
axunonb added a commit that referenced this issue Jun 9, 2024
* feat: Format.HasNested checks for existing Placeholder

Closes  #415
* `Format.HasNested` checks Items for existing `Placeholder`
* Update Format Class Initialization (mark overload with arg `bool hasNested` as obsolete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants