question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use of `Data` property

See original GitHub issue

Describe the bug Just noticed that there are some internal uses within Terminal.Gui library of the Data field e.g.

https://github.com/gui-cs/Terminal.Gui/blob/fb3dde2289a9929434f98d2cd7649389312585fe/Terminal.Gui/Views/FrameView.cs#L55

https://github.com/gui-cs/Terminal.Gui/blob/fb3dde2289a9929434f98d2cd7649389312585fe/Terminal.Gui/Views/Wizard/WizardStep.cs#L42

The documentation for this property indicates that we won’t do this:

/// <summary>
/// Gets or sets arbitrary data for the view.
/// </summary>
/// <remarks>This property is not used internally.</remarks>

Within the designer, I use Data to track the field member name in the source code written out to .Designer.cs. And to store the Design (editable properties blueprint).

So there is a meaning when Data has a value (user designed this view) and theres a meaning when it is null (this view is an artifact of another view e.g. ContentView).

There may be other library users making similar assumptions.

Is it please possible to move the internal uses of this property to a new field or adjust the approach?

Issue Analytics

  • State:open
  • Created 4 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
tigcommented, May 28, 2023

We should add a Unit Test that uses reflection to find every subclass of View and test and Assert.Null (view.Data) after construction and after IsInitialized = true.

1reaction
tigcommented, May 28, 2023

Related: https://github.com/gui-cs/Terminal.Gui/issues/2502

This PR (removing TopLevel completely) will fix one egregious violation of us using Data internally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using data attributes - Learn web development | MDN
data -* attributes allow us to store extra information on standard, semantic HTML elements without other hacks such as non-standard attributes, ...
Read more >
HTML data-* Attribute
The data-* attribute is used to store custom data private to the page or application. The data-* attribute gives us the ability to...
Read more >
Using the data Property
The following example shows how you can use the data property to specify item data when performing a single push operation (see Add...
Read more >
What's "Data Property" in JavaScript?
In JavaScript, a "data property" is a type of object property that has the following attributes (or property descriptors):.
Read more >
Data Property Hierarchy
The data property hierarchy view displays the asserted and inferred data property hierarchies. The asserted data property hierarchy is visible by default.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found