Browse Source

[csharp] Refactor array type printing code to use interpolation strings.

pull/935/head
Joao Matos 9 years ago
parent
commit
0f0c85de24
  1. 18
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs

18
src/Generator/Generators/CSharp/CSharpTypePrinter.cs

@ -69,22 +69,22 @@ namespace CppSharp.Generators.CSharp
(arrayType.IsPrimitiveType() && MarshalKind != MarshalKind.NativeField)) (arrayType.IsPrimitiveType() && MarshalKind != MarshalKind.NativeField))
{ {
if (primitiveType == PrimitiveType.Void) if (primitiveType == PrimitiveType.Void)
{
return "void*"; return "void*";
}
return string.Format("{0}", array.Type.Visit(this, quals)); return array.Type.Visit(this, quals);
} }
if (Parameter != null) if (Parameter != null)
return string.Format("global::System.IntPtr"); return IntPtrType;
Enumeration @enum; Enumeration @enum;
if (arrayType.TryGetEnum(out @enum)) if (arrayType.TryGetEnum(out @enum))
{ {
return new TypePrinterResult return new TypePrinterResult
{ {
Type = string.Format("fixed {0}", @enum.BuiltinType), Type = $"fixed {@enum.BuiltinType}",
NameSuffix = string.Format("[{0}]", array.Size) NameSuffix = $"[{array.Size}]"
}; };
} }
@ -94,7 +94,7 @@ namespace CppSharp.Generators.CSharp
return new TypePrinterResult return new TypePrinterResult
{ {
Type = "fixed byte", Type = "fixed byte",
NameSuffix = string.Format("[{0}]", array.Size * @class.Layout.Size) NameSuffix = $"[{array.Size * @class.Layout.Size}]"
}; };
} }
@ -109,8 +109,8 @@ namespace CppSharp.Generators.CSharp
var fixedKeyword = array.Type is ArrayType ? string.Empty : "fixed "; var fixedKeyword = array.Type is ArrayType ? string.Empty : "fixed ";
return new TypePrinterResult return new TypePrinterResult
{ {
Type = string.Format("{0}{1}", fixedKeyword, arrayElemType), Type = $"{fixedKeyword}{arrayElemType}",
NameSuffix = string.Format("[{0}]", array.Size) NameSuffix = $"[{array.Size}]",
}; };
} }

Loading…
Cancel
Save