-
Notifications
You must be signed in to change notification settings - Fork 18
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
Feature/90 known types #165
Conversation
This reverts commit 2844427.
8c2de83
to
6f5f58a
Compare
# Conflicts: # src/Kontent.Ai.ModelGenerator.Core/CodeGeneratorBase.cs # src/Kontent.Ai.ModelGenerator.Core/Common/ClassCodeGeneratorFactory.cs # src/Kontent.Ai.ModelGenerator.Core/Common/ClassDefinition.cs # src/Kontent.Ai.ModelGenerator.Core/Common/Property.cs # src/Kontent.Ai.ModelGenerator.Core/Configuration/CodeGeneratorOptions.cs # src/Kontent.Ai.ModelGenerator.Core/DeliveryCodeGenerator.cs # src/Kontent.Ai.ModelGenerator.Core/Generators/Class/BaseClassCodeGenerator.cs # src/Kontent.Ai.ModelGenerator.Core/Generators/Class/ClassCodeGenerator.cs # src/Kontent.Ai.ModelGenerator.Core/Generators/Class/DeliveryClassCodeGenerator.cs # src/Kontent.Ai.ModelGenerator.Core/Generators/Class/DeliveryClassCodeGeneratorBase.cs # src/Kontent.Ai.ModelGenerator.Core/Generators/Class/ManagementClassCodeGenerator.cs # src/Kontent.Ai.ModelGenerator.Core/Generators/Class/PartialClassCodeGenerator.cs # src/Kontent.Ai.ModelGenerator.Core/Helpers/TextHelpers.cs # src/Kontent.Ai.ModelGenerator/Program.cs # src/Kontent.Ai.ModelGenerator/ValidationExtensions.cs # test/Kontent.Ai.ModelGenerator.Tests/CodeGeneratorTestsBase.cs # test/Kontent.Ai.ModelGenerator.Tests/Common/ClassCodeGeneratorFactoryTests.cs # test/Kontent.Ai.ModelGenerator.Tests/Common/PropertyTests.cs # test/Kontent.Ai.ModelGenerator.Tests/DeliveryCodeGeneratorTests.cs # test/Kontent.Ai.ModelGenerator.Tests/Generators/Class/BaseClassCodeGeneratorTests.cs # test/Kontent.Ai.ModelGenerator.Tests/Generators/Class/DeliveryClassCodeGeneratorTests.cs # test/Kontent.Ai.ModelGenerator.Tests/Generators/Class/ManagementClassCodeGeneratorTests.cs # test/Kontent.Ai.ModelGenerator.Tests/Helpers/ManagementElementHelperTests.cs # test/Kontent.Ai.ModelGenerator.Tests/Helpers/TextHelpersTests.cs # test/Kontent.Ai.ModelGenerator.Tests/ManagementCodeGeneratorTests.cs # test/Kontent.Ai.ModelGenerator.Tests/TestHelper.cs # test/Kontent.Ai.ModelGenerator.Tests/ValidationExtensionsTests.cs
# Conflicts: # test/Kontent.Ai.ModelGenerator.Tests/Kontent.Ai.ModelGenerator.Tests.csproj
374d1a1
to
805dd72
Compare
Please adjust https://github.com/kontent-ai/model-generator-net/blob/feature/90_known_types/src/Kontent.Ai.ModelGenerator/appSettings.json to respect new options and cover related tests if necessary. |
I would emphasize the Api key with the example for the section: https://github.com/kontent-ai/model-generator-net/tree/feature/90_known_types#customizing-models---extended-delivery-models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casing problem
By running .\KontentModelGenerator.exe -p ABC -e true -k XYZ
for project 6d7f2b4b-9432-012e-f6be-c9feb74c3912
(@Sevitas - you are invited) => it is because faulty casing -> the original property is JustMessages
-> the typed one is JustmessagesTypes and trying to load from Justmessages (see the m
vs. M).
Opt in for IContentItem
-
I also got for
*.Generated
. inheritance fromIContentItem
. I would add this as non-default behavior. => I would extend thestructuredmodel
argument with another enum flag i.e.linkedItems
(I am open to another name) because it probably (not sure) applies on the subPages element too. -
Introduce
IContentItem
into the DAPI SDK Abstractions (I think the minor release is fine) and do not generate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
rename the
extendeddelivermodels
- it is delivery everywhere we use it -
I am getting a warnings fron
self-contained.ps1
C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\ServiceCollectionExtensions.cs(24,9): warning IL2026: Using member 'Microsoft.Extensions.Configur ation.ConfigurationBinder.Bind(IConfiguration, Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. C annot statically analyze the type of instance so its members may be trimmed. [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGen erator.csproj] C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Options\ArgHelpers.cs(97,32): warning IL2070: 'this' argument does not satisfy 'DynamicallyAccess edMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The parameter 'type' of method 'Kontent.Ai.ModelGenerator.Options.ArgHelpers.ProgramO ptionsData.ProgramOptionsData(Type, String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Options\ArgHelpers.cs(105,32): warning IL2070: 'this' argument does not satisfy 'DynamicallyAcces sedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The parameter 'optionsType' of method 'Kontent.Ai.ModelGenerator.Options.ArgHelpers. ProgramOptionsData.ProgramOptionsData(Type, Type, String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Program.cs(38,13): warning IL2026: Using member 'Microsoft.Extensions.DependencyInjection.Options ConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)' which has 'RequiresUnreferencedCodeAttribute' can break funct ionality when trimming application code. TOptions's dependent types may have their members trimmed. Ensure all required members are preserved. [C:\projects\mod el-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] Kontent.Ai.ModelGenerator -> C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\bin\Release\net6.0\linux-x64\KontentModelGenerator.dll Optimizing assemblies for size. This process might take a while. C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Program.cs(38,13): Trim analysis warning IL2026: Kontent.Ai.ModelGenerator.Program.<Main>d__0.Mov eNext(): Using member 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfig uration)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. TOptions's dependent types may have their membe rs trimmed. Ensure all required members are preserved. [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Options\ArgHelpers.cs(105,13): Trim analysis warning IL2070: Kontent.Ai.ModelGenerator.Options.Ar gHelpers.ProgramOptionsData.ProgramOptionsData(Type, Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The parameter 'optionsType' of method 'Kontent.Ai.ModelGenerator.Options.ArgHelpers.ProgramOptionsData.ProgramOptionsData(Typ e, Type, String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Options\ArgHelpers.cs(97,13): Trim analysis warning IL2070: Kontent.Ai.ModelGenerator.Options.Arg Helpers.ProgramOptionsData.ProgramOptionsData(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'Sys tem.Type.GetProperties()'. The parameter 'type' of method 'Kontent.Ai.ModelGenerator.Options.ArgHelpers.ProgramOptionsData.ProgramOptionsData(Type, String)' do es not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [C:\ projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\ServiceCollectionExtensions.cs(24,9): Trim analysis warning IL2026: Kontent.Ai.ModelGenerator.Ser viceCollectionExtensions.LoadOptionsConfiguration(IServiceCollection, IConfiguration, String): Using member 'Microsoft.Extensions.Configuration.ConfigurationBi nder.Bind(IConfiguration, Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Cannot statically anal yze the type of instance so its members may be trimmed. [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] ILLink : Trim analysis warning IL2026: System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.GetSchema(): Using member 'System.Data.DataSet.WriteXmlSch ema(DataSet, XmlWriter)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataSet.GetSchema uses TypeDescr iptor and XmlSerialization underneath which are not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\model- generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] ILLink : Trim analysis warning IL2026: System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader): Using member 'System.Data.DataSet.Read XmlSerializableInternal(XmlReader)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataSet.ReadXml uses XmlSerialization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\model-generator-n et\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] ILLink : Trim analysis warning IL2026: System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter): Using member 'System.Data.DataSet.Wri teXmlInternal(XmlWriter)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataSet.WriteXml uses XmlSerial ization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\model-generator-net\src\Ko ntent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] ILLink : Trim analysis warning IL2026: System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.GetSchema(): Using member 'System.Data.DataTable.GetXmlS chema()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataTable.GetSchema uses TypeDescriptor and XmlS erialization underneath which are not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\model-generator-net\ src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] ILLink : Trim analysis warning IL2026: System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader): Using member 'System.Data.DataTable. ReadXmlSerializableInternal(XmlReader)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataTable.ReadXml uses XmlSerialization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\model-gener ator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] ILLink : Trim analysis warning IL2026: System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter): Using member 'System.Data.DataTable .WriteXmlInternal(XmlWriter)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. DataTable.WriteXml uses Xml Serialization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly. [C:\projects\model-generator-net\ src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\anglesharp\0.17.1\lib\netstandard2.0\AngleSharp.dll : warning IL2104: Assembly 'AngleSharp' produced trim warnings. Fo r more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\humanizer.core\2.14.1\lib\net6.0\Humanizer.dll : warning IL2104: Assembly 'Humanizer' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\kontent.ai.delivery\17.4.0\lib\net6.0\Kontent.Ai.Delivery.dll : warning IL2104: Assembly 'Kontent.Ai.Delivery' produce d trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.Mode lGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\kontent.ai.management\4.4.0\lib\net6.0\Kontent.Ai.Management.dll : warning IL2104: Assembly 'Kontent.Ai.Management' pr oduced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai .ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\microsoft.codeanalysis.common\4.5.0\lib\netcoreapp3.1\Microsoft.CodeAnalysis.dll : warning IL2104: Assembly 'Microsoft .CodeAnalysis' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.ModelGen erator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\microsoft.codeanalysis.csharp.workspaces\4.5.0\lib\netcoreapp3.1\Microsoft.CodeAnalysis.CSharp.Workspaces.dll : warnin g IL2104: Assembly 'Microsoft.CodeAnalysis.CSharp.Workspaces' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\proje cts\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\microsoft.codeanalysis.workspaces.common\4.5.0\lib\netcoreapp3.1\Microsoft.CodeAnalysis.Workspaces.dll : warning IL210 4: Assembly 'Microsoft.CodeAnalysis.Workspaces' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-gene rator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\newtonsoft.json\13.0.1\lib\netstandard2.0\Newtonsoft.Json.dll : warning IL2104: Assembly 'Newtonsoft.Json' produced tr im warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGen erator.csproj] C:\Users\OndrejChrastina\.nuget\packages\scrutor\4.2.0\lib\net6.0\Scrutor.dll : warning IL2104: Assembly 'Scrutor' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.ModelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\system.composition.convention\6.0.0\lib\net6.0\System.Composition.Convention.dll : warning IL2104: Assembly 'System.Co mposition.Convention' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.M odelGenerator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\system.composition.hosting\6.0.0\lib\net6.0\System.Composition.Hosting.dll : warning IL2104: Assembly 'System.Composit ion.Hosting' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.ModelGener ator\Kontent.Ai.ModelGenerator.csproj] C:\Users\OndrejChrastina\.nuget\packages\system.composition.typedparts\6.0.0\lib\net6.0\System.Composition.TypedParts.dll : warning IL2104: Assembly 'System.Co mposition.TypedParts' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\projects\model-generator-net\src\Kontent.Ai.M odelGenerator\Kontent.Ai.ModelGenerator.csproj]
-
I would use
FirstOrDefault
also forAtMost
= 1 linked items - what do you think?
test/Kontent.Ai.ModelGenerator.Tests/Configuration/CodeGeneratorOptionsExtensionsTests.cs
Show resolved
Hide resolved
src/Kontent.Ai.ModelGenerator.Core/Helpers/TypedDeliveryPropertyMapper.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tested locally and from nuget
Motivation
Fixes #90. Scenarios 1 and 2.
Checklist
How to test
Test that models are generated for senarios 1 and 2 and everything else works without a change.