Skip to content

Commit 22d2912

Browse files
committed
Add short to number primitive type mapping and return any when no match found and add a log message
1 parent 8470b9a commit 22d2912

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/WebApiToTypeScript/Types/TypeService.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private void LoadPrimitiveTypesMapping()
2727

2828
mapping["string"] = new List<Type> { typeof(string), typeof(System.Guid), typeof(DateTime), typeof(TimeSpan) };
2929
mapping["boolean"] = new List<Type> { typeof(bool) };
30-
mapping["number"] = new List<Type> { typeof(byte), typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) };
30+
mapping["number"] = new List<Type> { typeof(byte), typeof(short), typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) };
3131
mapping["any"] = new List<Type> { typeof(object) };
3232
}
3333

@@ -212,6 +212,16 @@ public TypeScriptType GetTypeScriptType(TypeReference cSharpType, string paramet
212212
return result;
213213
}
214214

215+
var logTypeName = typeDefinition?.FullName ?? cSharpType.FullName;
216+
var isValueType = typeDefinition?.IsValueType ?? cSharpType.IsValueType;
217+
218+
LogMessage($"Parameter [{parameterName}] of type [{logTypeName}] unmapped. IsValueType: [{isValueType}]");
219+
result.TypeName = "any";
220+
result.InterfaceName = "any";
221+
result.IsPrimitive = isValueType;
222+
223+
return result;
224+
215225
throw new NotSupportedException("Maybe it is a generic class, or a yet unsupported collection, or chain thereof?");
216226
}
217227

0 commit comments

Comments
 (0)