Skip to content

Commit

Permalink
Ensure inheritance attribute is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Jan 16, 2024
1 parent 486d0d1 commit 4bfc0a5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Bonsai.Sgen/CSharpCodeDomGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ public override IEnumerable<CodeArtifact> GenerateTypes()
{
var types = base.GenerateTypes();
var extraTypes = new List<CodeArtifact>();

if (!Settings.SerializerLibraries.HasFlag(SerializerLibraries.NewtonsoftJson) &&
types.Any(r => r.Code.Contains(nameof(JsonInheritanceAttribute))))
{
if (Settings.ExcludedTypeNames?.Contains(nameof(JsonInheritanceAttribute)) != true)
{
var model = new JsonInheritanceConverterTemplateModel(Settings);
var template = Settings.TemplateFactory.CreateTemplate("CSharp", nameof(JsonInheritanceAttribute), model);
var artifact = new CodeArtifact(
nameof(JsonInheritanceAttribute),
CodeArtifactType.Class,
CodeArtifactLanguage.CSharp,
CodeArtifactCategory.Utility,
template);
extraTypes.Add(ReplaceInitOnlyProperties(artifact));
}
}

var schema = (JsonSchema)RootObject;
var classTypes = (from type in types
let classType = type as CSharpClassCodeArtifact
Expand Down

0 comments on commit 4bfc0a5

Please sign in to comment.