Skip to content

Commit fe96d6d

Browse files
author
Thiago Almeida
committed
Support for Partial objects
1 parent 961ecda commit fe96d6d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Onbox.TypeSharp/Services/TypeConverter.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public string ConvertModel(Type type)
199199
}
200200
}
201201
}
202-
202+
203203
if (!typeUnitSuccess)
204204
{
205205
var nullableType = "";
@@ -220,6 +220,11 @@ public string ConvertModel(Type type)
220220
propType = "unknown";
221221
}
222222

223+
if (ContainsPartialAttr(prop))
224+
{
225+
propType = $"Partial<{propType}>";
226+
}
227+
223228
classBodyBuilder.AppendLine($" {propName}{optionalType}: {propType}{nullableType};");
224229
}
225230
}
@@ -249,6 +254,12 @@ private bool ContainsUnknownObjectAttr(PropertyInfo prop)
249254
return prop.CustomAttributes.FirstOrDefault(a => a.AttributeType.Name.Equals("UnknownObjectAttribute")) != null;
250255
}
251256

257+
private bool ContainsPartialAttr(PropertyInfo prop)
258+
{
259+
if (prop == null) return false;
260+
return prop.CustomAttributes.FirstOrDefault(a => a.AttributeType.Name.StartsWith("Partial")) != null;
261+
}
262+
252263
private void HandlePropertyWritting(Type parentType, Type propType)
253264
{
254265
if (this.propertyUtils.ShouldImport(propType) && propType != parentType && !this.typeCache.Contains(propType) && propType.Name != "List`1")

0 commit comments

Comments
 (0)