Closed Gerfaut closed 5 years ago
After generating models, the CustomTypeProvider is still implementing the removed interface ICodeFirstTypeProvider.
Using following command CloudModelGenerator.exe --projectid "MYAPPID" --namespace "Kentico.Cloud.Starter.Infra.KCloud.Models" --outputdir "Kentico.Cloud.Starter.Infra\KCloud\Models" --baseclass "BaseModel"
CloudModelGenerator.exe --projectid "MYAPPID" --namespace "Kentico.Cloud.Starter.Infra.KCloud.Models" --outputdir "Kentico.Cloud.Starter.Infra\KCloud\Models" --baseclass "BaseModel"
The following class is not compiling anymore:
using System; using System.Collections.Generic; using System.Linq; using KenticoCloud.Delivery; namespace Kentico.Cloud.Starter.Infra.KCloud.Models { public class CustomTypeProvider : ICodeFirstTypeProvider { private static readonly Dictionary<Type, string> _codenames = new Dictionary<Type, string> { {typeof(AboutUs), "about_us"}, {typeof(Accessory), "accessory"}, {typeof(Article), "article"}, {typeof(Brewer), "brewer"}, {typeof(Cafe), "cafe"}, {typeof(Coffee), "coffee"}, {typeof(FactAboutUs), "fact_about_us"}, {typeof(Grinder), "grinder"}, {typeof(HeroUnit), "hero_unit"}, {typeof(Home), "home"}, {typeof(HostedVideo), "hosted_video"}, {typeof(Office), "office"}, {typeof(Tweet), "tweet"} }; public Type GetType(string contentType) { return _codenames.Keys.FirstOrDefault(type => GetCodename(type).Equals(contentType)); } public string GetCodename(Type contentType) { return _codenames.TryGetValue(contentType, out var codename) ? codename : null; } } }
The class should be generated using ITypeProvider instead of ICodeFirstTypeProvider
Thanks a lot !
Gerfaut
Great, thanks a lot! And thanks for the merge 👍
Brief bug description
After generating models, the CustomTypeProvider is still implementing the removed interface ICodeFirstTypeProvider.
Repro steps
Using following command
CloudModelGenerator.exe --projectid "MYAPPID" --namespace "Kentico.Cloud.Starter.Infra.KCloud.Models" --outputdir "Kentico.Cloud.Starter.Infra\KCloud\Models" --baseclass "BaseModel"
The following class is not compiling anymore:
Expected behavior
The class should be generated using ITypeProvider instead of ICodeFirstTypeProvider
Test environment
Thanks a lot !
Gerfaut