Skip to content

Commit

Permalink
Add Swift support for TreatTypesAsStrings
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Nov 4, 2015
1 parent 2adfdd7 commit 86d5b59
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ServiceStack/NativeTypes/Swift/SwiftGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ public string GetCode(MetadataTypes metadata, IRequest request)
sb.AppendLine("{0}AddResponseStatus: {1}".Fmt(defaultValue("AddResponseStatus"), Config.AddResponseStatus));
sb.AppendLine("{0}AddImplicitVersion: {1}".Fmt(defaultValue("AddImplicitVersion"), Config.AddImplicitVersion));
sb.AppendLine("{0}InitializeCollections: {1}".Fmt(defaultValue("InitializeCollections"), Config.InitializeCollections));
sb.AppendLine("{0}TreatTypesAsStrings: {1}".Fmt(defaultValue("TreatTypesAsStrings"), Config.TreatTypesAsStrings.Safe().ToArray().Join(",")));
sb.AppendLine("{0}DefaultImports: {1}".Fmt(defaultValue("DefaultImports"), defaultImports.Join(",")));

sb.AppendLine("*/");
sb.AppendLine();

foreach (var typeName in Config.TreatTypesAsStrings.Safe())
{
TypeAliases[typeName] = "String";
}

string lastNS = null;

var existingTypes = new HashSet<string>();
Expand Down Expand Up @@ -204,7 +210,8 @@ private string AppendType(ref StringBuilderWrapper sb, ref StringBuilderWrapper
{
//sb = sb.Indent();

if (Config.ExcludeGenericBaseTypes && type.Inherits != null && !type.Inherits.GenericArgs.IsEmpty())
var hasGenericBaseType = type.Inherits != null && !type.Inherits.GenericArgs.IsEmpty();
if (Config.ExcludeGenericBaseTypes && hasGenericBaseType)
{
sb.AppendLine("//Excluded {0} : {1}<{2}>".Fmt(type.Name, type.Inherits.Name.SplitOnFirst('`')[0], string.Join(",", type.Inherits.GenericArgs)));
return lastNS;
Expand Down

0 comments on commit 86d5b59

Please sign in to comment.