Comments (5)
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 emptyMyWebsite.Footer
probably emptyMyWebsite.Footer.Address
➡️ AddressMyWebsite.Footer.Address.Street
➡️ StreetMyWebsite.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.
Hi @abjerner ! This isn't my example - It's Nik's (@NikRimington) I just copied it over as a courtesy.
from limbo.umbraco.modelsbuilder.
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.
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.
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)
- Getting Started Questions/Issues HOT 8
- Feature Request: Add in Static Getters for Compositions HOT 14
- Don't generate interface properties for customized interface properties HOT 5
- Smidge JS conflict with Umbraco Deploy and Umbraco Forms dashboards HOT 5
- Generating sets invalid type for nested classes
- Build warning "warning CS0108" should be ignored HOT 9
- Investigate deleting files before generating models HOT 4
- Nested Content Properties being generated with empty types HOT 3
- [ImplementPropertyType()] Attribute being ignored for customized property names HOT 2
- Version 2.0.0-alpha002 - NuGet "DirectoryNotFoundException" for "staticwebassets" HOT 4
- Logic behind `[IgnorePropertyType]` should be case insentive
- Models generator doesn't detect classes in partial classes using file-scoped namespaces
- [IgnorePropertyType] doesn't work as expected HOT 3
- Disable dashboard or show warning when environment doesn't match `Development`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from limbo.umbraco.modelsbuilder.