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

Use of Data property #2676

Open
tznind opened this issue May 27, 2023 · 5 comments
Open

Use of Data property #2676

tznind opened this issue May 27, 2023 · 5 comments
Labels
v2 For discussions, issues, etc... relavant for v2

Comments

@tznind
Copy link
Collaborator

tznind commented May 27, 2023

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

Border.Data = "Border";

private View contentView = new View () { Data = "WizardContentView" };

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?

@tznind tznind added the v2 For discussions, issues, etc... relavant for v2 label May 27, 2023
@BDisp
Copy link
Collaborator

BDisp commented May 27, 2023

Here my opinion on this. View class has a Data property which is for the user use it as he like. We should avoid use this property internally and only use it on app, like the scenarios, etc. @tznind you said use Data property and I ask if it's possible a user set the Data property for whatever he want, at least at design time, I guess. So, my suggestion is use the Id property to handle with field member name. Is this isn't enough then probably you have to create a sub-file to track that. e.g. app.cs, app.Designer.cs, app without extension or with an extension properly named for track the field members. But I may be wrong.

@tig
Copy link
Collaborator

tig commented May 28, 2023

I believe it is possible, and we should remove the usages of Data internally, except if used for a view that is never exposed eternally.

But, to be clear, Designer is NOT part of the library and should be able to use it as it see fits.

@tig
Copy link
Collaborator

tig commented May 28, 2023

Related: #2502

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

@tig
Copy link
Collaborator

tig commented 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.

@BDisp
Copy link
Collaborator

BDisp commented May 28, 2023

But, to be clear, Designer is NOT part of the library and should be able to use it as it see fits.

Yes, I know. I only was asking @tznind if the Data was available to user to do what he want after compile or contains some track that is used during the runtime avoiding the user really use the Data property. If it's only used during the design and not after compiled, there no problem with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 For discussions, issues, etc... relavant for v2
Projects
Status: No status
Development

No branches or pull requests

3 participants