Umbraco alias from CamelCase to PascalCase #14531
rammi987
started this conversation in
Features and ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When you creating new doctypes, mediatypes, membertypes, properties types you name it. The names you give will be converter pr automatic to a matching alias as CamelCase, and it always have been that way but I´ll like to start a discussion for an idea, now when the times have change and have we developing now.
With Umbraco model builder everything have now been easy, just to say
@Model.Headline
but in the end getting the Headline alias from the ModelBuilder is still a challenges. There is still at the this day not an easy way to get the alias for a property, as for the doctype, where you just can type inFrontpage.ModelTypeAlias
and you get the alias, but for a property you need to write is asFrontpage.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Headline).Alias
witch both need an dependency injection and a lamba expression.When I created this property, I gave it the name "Headline" witch means the alias was "headline", and override it to be "Headline". And it is a pratic I have adopted, just to do this easy when need to get the alias.
@nameof(Frontpage.Headline)
a beautiful way to get the alias, without to much code and needed for DI, and performance beneficial.To the day I still changes all alias Umbraco make to be PascalCase. PascalCase matche have you normal in the .Net world write Models, Both for the model class and its properties, and ModelBuild also do it that way. That´s why
nameof
not work.If alias is headline but nameof return Headline, then Umbraco can not match any properties.
I know this will be a breaking change, but the impact is small, but it will optimize the work, have code is written and be more efficient, both to remeber for us lazy developers and and the the workload on the CPU. Just imaging if you need 15 properties alias, and need to write the way we have today instead just writen nameof.
Still when using nameof(Frontpage.Headline) and you delete the Headline property and rebuild the solution you will still get and build error becouse the model Frontpage do not have a property in the model class matching Headline.
Beta Was this translation helpful? Give feedback.
All reactions