Skip to content
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

Bug/138 guidelines element #139

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ namespace KenticoKontentModels
}
}
```
⚠️ Please note that _Guidelines_ element is not supported, thus it will not be included in the generated model.

## Feedback & Contributing

Expand Down
3 changes: 3 additions & 0 deletions src/Kentico.Kontent.ModelGenerator.Core/CodeGeneratorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ protected static void WriteConsoleErrorMessage(Exception exception, string eleme
case ArgumentNullException or ArgumentException:
Console.WriteLine($"Warning: Skipping unknown Content Element type '{elementType}'. (Content Type: '{className}', Element Codename: '{elementCodename}').");
break;
case UnsupportedTypeException:
Console.WriteLine($"Info: Skipping unsupported Content Element type '{elementType}'. (Content Type: '{className}', Element Codename: '{elementCodename}').");
break;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/Kentico.Kontent.ModelGenerator.Core/Common/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public static Property FromContentTypeElement(ElementMetadataBase element)
return new Property(element.Codename, ManagementElementTypesDictionary[element.Type], element.Id.ToString());
}

if (element.Type == ElementMetadataType.Guidelines)
{
throw new UnsupportedTypeException();
}

throw new ArgumentException($"Unknown Content Type {element.Type}", nameof(element));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace Kentico.Kontent.ModelGenerator.Core.Common
{
public class UnsupportedTypeException : Exception
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void FromContentTypeElement_DeliveryApiModel_InvalidContentTypeElement_Th
[Fact]
public void FromContentTypeElement_ManagementApiModel_GuidelinesElement_Throws()
{
Assert.Throws<ArgumentException>(() =>
Assert.Throws<UnsupportedTypeException>(() =>
Property.FromContentTypeElement(TestHelper.GenerateGuidelinesElement(Guid.NewGuid(), "codename")));
}

Expand Down