Giter Site home page Giter Site logo

Comments (5)

abjerner avatar abjerner commented on July 17, 2024

Hi @hfloyd

I haven't really looked into this yet due to lack of time.

In your example, TopLevelDictionaryItemWithChildren doesn't really have a value of it's own. Du you have any examples for when it does? The alias of a dictionary item may also contain characters that aren't good for C# member names.

When using nested dictionary items, I tend to use the parent alias as a prefix for the child item's alias. Eg. Something like:

  • MyWebsite probably empty
    • MyWebsite.Footer probably empty
      • MyWebsite.Footer.Address ➡️ Address
        • MyWebsite.Footer.Address.Street ➡️ Street
        • MyWebsite.Footer.Address.City ➡️ City

People may create dictionary items in lots of different ways, so it might be difficult coming up with something that can handle this.

from limbo.umbraco.modelsbuilder.

hfloyd avatar hfloyd commented on July 17, 2024

Hi @abjerner ! This isn't my example - It's Nik's (@NikRimington) I just copied it over as a courtesy.

from limbo.umbraco.modelsbuilder.

hfloyd avatar hfloyd commented on July 17, 2024

I agree with you that If I have nested Dictionary items, the "folders" are usually blank. Of course, really any dictionary item could return a blank value, since it isn't required via the UI.

In terms of the aliases not being good for C# names... I've used a little string extension (.MakeCodeSafe()) when I've wanted to dynamically generate thinks like HTML ID attributes, etc. So I don't think that would be the biggest challenge to overcome.

from limbo.umbraco.modelsbuilder.

abjerner avatar abjerner commented on July 17, 2024

Both my own Skybrud.Essentials (which is already a dependency) and Umbraco also have some logic for creating safe strings. But stripping out unwanted characters could potentially cause conflicts if two different aliases are converted to the same safe string. But if that happens, simple solution could be to return a Models Builder says no style error.

Another issue I hadn't though of before is to actually resolve the dictionary values. If our Models Builder generates one or more static classes with constants (or static readonly fields/properties), we can't really resolve the values in a DI-friendly way, and as a result, the code wouldn't be very testable. That might be bad in some cases, but fine in others.

But if the constants are mapped to the aliases instead of the values, then we shouldn't have problem, but it would require developers to resolve the values on their own.

from limbo.umbraco.modelsbuilder.

hfloyd avatar hfloyd commented on July 17, 2024

But if the constants are mapped to the aliases instead of the values, then we shouldn't have problem, but it would require developers to resolve the values on their own.

I think that would actually be ideal - so that MB doesn't need to manage the actual Dictionary lookup code - since that is part of CMS.Core and might change.

from limbo.umbraco.modelsbuilder.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.