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

code generation for strongly-typed content types and their properties #18

Merged
merged 1 commit into from May 25, 2017

Conversation

Projects
None yet
4 participants
@djanjicek
Contributor

djanjicek commented May 22, 2017

Implemented code generation for strongly-typed content types and their properties in order to get rid of magic strings when querying. This will also prevent sudden breaking changes when someone changes a content type in Kentico Cloud. Regenerating the classes will cause a broken build and it informs every developer about possible changes before the web application is deployed to any target environment.

@petrsvihlik petrsvihlik self-requested a review May 23, 2017

@petrsvihlik

This comment has been minimized.

Member

petrsvihlik commented May 23, 2017

sample output:

// This code was generated by a cloud-generators-net tool 
// (see https://github.com/Kentico/cloud-generators-net).
// 
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 
// For further modifications of the class, create a separate file with the partial class.

using System;
using System.Collections.Generic;
using KenticoCloud.Delivery;

namespace RoadshowShowcase.Models
{
    public partial class CompleteContentType
    {
        public const string Codename = "complete_content_type";
        public const string TextFieldCodename = "text_field";
        public const string RichTextFieldCodename = "rich_text_field";
        public const string NumberFieldCodename = "number_field";
        public const string MultipleChoiceFieldAsRadioButtonsCodename = "multiple_choice_field_as_radio_buttons";
        public const string MultipleChoiceFieldAsCheckboxesCodename = "multiple_choice_field_as_checkboxes";
        public const string DateTimeFieldCodename = "date___time_field";
        public const string AssetFieldCodename = "asset_field";
        public const string ModularContentFieldCodename = "modular_content_field";
        public const string CompleteTypeTaxonomyCodename = "complete_type_taxonomy";
        public const string UrlSlugFieldCodename = "url_slug_field";

        public string TextField { get; set; }
        public string RichTextField { get; set; }
        public decimal? NumberField { get; set; }
        public IEnumerable<MultipleChoiceOption> MultipleChoiceFieldAsRadioButtons { get; set; }
        public IEnumerable<MultipleChoiceOption> MultipleChoiceFieldAsCheckboxes { get; set; }
        public DateTime? DateTimeField { get; set; }
        public IEnumerable<Asset> AssetField { get; set; }
        public IEnumerable<object> ModularContentField { get; set; }
        public IEnumerable<TaxonomyTerm> CompleteTypeTaxonomy { get; set; }
        public string UrlSlugField { get; set; }
        public ContentItemSystemAttributes System { get; set; }
    }
}
@alanta

This comment has been minimized.

alanta commented May 24, 2017

Nice work Dražen :)

@djanjicek

This comment has been minimized.

Contributor

djanjicek commented May 25, 2017

Thanks :-) I'm already using it all over the place... Feels nice!

@petrsvihlik petrsvihlik merged commit 9b44bd6 into Kentico:master May 25, 2017

@petrsvihlik

This comment has been minimized.

Member

petrsvihlik commented May 25, 2017

Good job @djanjicek !

Next time, please check that all unit tests are passing before you submit a PR :) I've just fixed them...

@djanjicek

This comment has been minimized.

Contributor

djanjicek commented May 25, 2017

Argh, my bad. Sorry , won't happen again :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment