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

Initial presentation UI implementation. #19

Merged
merged 5 commits into from
May 15, 2019

Conversation

kwilliams1987
Copy link
Collaborator

@kwilliams1987 kwilliams1987 commented May 13, 2019

Implementation for #4.

UI Elements are now generated using metadata attributes instead of display templates.

UI Elements are now generated using metadata attributes instead of display templates.
@malware-dev
Copy link
Owner

Can you please explain your thought process with this? Primarily, why the need for a separate metadata class? Why the object properties?

@kwilliams1987
Copy link
Collaborator Author

kwilliams1987 commented May 14, 2019

The use of MetadataType classes is one borrowed from Entity Framework.

It allows us to keep the UI decorator attributes out of the Shared Project (removing the need to have MDK-SE projects include references to the additional assemblies).

The alternative would mean needing to overwrite and re-implement every single property to add the UI attributes.

The use of object as the property type is simply common practice for metadata classes as the datatype is irrelevant. Only the property name is used to match the metadata to it's target property.

The most important goal is to keep the MDK-Mockups shared project purely for the (as portable as possible) mockup functionality.

Anything additional required by MDK-UI to implement additional UI functionality should be part of MDK-UI, the metadata classes are the perfect tool for this use case.

@malware-dev
Copy link
Owner

I see. I don't like the separation, it feels overcomplicated, but I understand the reasoning. I originally figured the attributes would be part of the definition of the mockups themselves and thus part of the shared project, I don't see the harm.

@kwilliams1987
Copy link
Collaborator Author

kwilliams1987 commented May 14, 2019

Harm is a big work, however some of the meta types (RangeAttribute for example) are from assemblies not whitelisted by SE (and thus included by default in the MDK-SE template).

I think it would be counter-intuitive to require anyone using MDK-SE to include a reference to System.ComponentModel.DataAnnotations.dll just so if they decide to use the mockup shared project it can still compile... even though nothing in the System.ComponentModel.DataAnnotations namespace is whitelisted.

The other option would be to have to make custom versions of the attributes in the shared project (with the same .debug.cs file caveats).

@malware-dev
Copy link
Owner

I was kinda hoping that adding the mockup systems to a project would be adding a nuget package, making such issues... well, a non-issue.

@malware-dev
Copy link
Owner

I dunno. This isn't anything I feel strongly about. It was just the basic thoughts and ideas I had when originally designing this project.

@kwilliams1987
Copy link
Collaborator Author

Personally I still feel it makes sense to keep UI markup in the UI project and not clutter up the mockups, regardless how the mockup package is delivered, however it's not something I'd fight tooth and nail for.

I used the practice I'm used to for achieving this, but there's little issue for me in moving the meta data attributes to the mockup project.

Do you also feel the IMockupRuntimeProvider should be in the Mockups shared project?

@malware-dev
Copy link
Owner

malware-dev commented May 14, 2019

Not really. The basic reasoning I have is that with your approach, making a mockup and making it support UI is two separate things. In my opinion, defining a mockup and its UI properties are part of the same job, and should be possible to do in one go, ([add] and should even be a requirement [/add]) without having to reference and modify multiple projects. Separation is all well and good, but it's not always for the best. And these are just attributes, suggestions. They're not actually locked to the UI project - but any kind of project that might want to do some kind of presentation on them. Meaning - having the attributes available directly for the mockups is one thing. Adding any specific interface or code or anything like that - is something completely different.

You've done a lot of work on this project. I'll defer to your judgement on this, I just wanted to state my opinion and the reasoning for it.

@kwilliams1987
Copy link
Collaborator Author

They're not actually locked to the UI project - but any kind of project that might want to do some kind of presentation on them. Meaning - having the attributes available directly for the mockups is one thing. Adding any specific interface or code or anything like that - is something completely different.

You make a good argument here, having the descriptive attributes available to any project which could consume them would be a useful feature.

I'll move the attributes into the MDK-Mockups project, and leave the specific mockup implementation code (IMockupRuntimeProvider) in the MDK-UI.

- Added ability to bind simple methods to the UI using `DisplayNameAttribute`.
@kwilliams1987 kwilliams1987 requested a review from malware-dev May 15, 2019 07:51
Copy link
Owner

@malware-dev malware-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -179,9 +165,51 @@ public virtual void ReadPublicText(StringBuilder buffer, bool append = false)
public virtual void RemoveImageFromSelection(string id, bool removeDuplicates = false)
=> _surface.RemoveImageFromSelection(id, removeDuplicates);

public virtual bool WritePublicText(string value, bool append = false)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are obsolete and should be marked as such

@kwilliams1987
Copy link
Collaborator Author

kwilliams1987 commented May 15, 2019 via email

- Obsolete methods with no implementation now raise compile time errors.
@kwilliams1987 kwilliams1987 merged commit bb0c593 into mockup-ui May 15, 2019
@kwilliams1987 kwilliams1987 deleted the mockup-ui-presentation branch May 15, 2019 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants