Skip to content

Instantly share code, notes, and snippets.

@genuinelucifer
Created May 28, 2015 06:04
Show Gist options
  • Select an option

  • Save genuinelucifer/45a29b36ec4f5254ea21 to your computer and use it in GitHub Desktop.

Select an option

Save genuinelucifer/45a29b36ec4f5254ea21 to your computer and use it in GitHub Desktop.
Alternative to using type.replace with type.substring ...
diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generat
index 04b2f35..0c25c0a 100644
--- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs
+++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs
@@ -863,8 +863,8 @@ private void GeneratePropertySetter<T>(QualifiedType returnT
{
CSharpTypePrinter typePrinter = new CSharpTypePrinter(ctx.D
string type = arrayType.CSharpType(typePrinter).Type;
- WriteLine(string.Format("fixed ({0} __arrPtr = {1}.{2})",
- type.Replace("[]","*"), Helpers.InstanceField,
+ WriteLine(string.Format("fixed ({0}* __arrPtr = {1}.{2})",
+ type.Substring(0,type.Length-2), Helpers.InstanceField,
Helpers.SafeIdentifier(field.OriginalName)));
WriteStartBraceIndent();
ctx.ReturnVarName = string.Format("__arrPtr");
@@ -990,8 +990,8 @@ private void GeneratePropertyGetter<T>(QualifiedType returnT
{
CSharpTypePrinter typePrinter = new CSharpTypePrinter(ctx.D
string type = arrayType.CSharpType(typePrinter).Type;
- WriteLine(string.Format("fixed ({0} __arrPtr = {1}.{2})",
- type.Replace("[]", "*"), Helpers.InstanceField,
+ WriteLine(string.Format("fixed ({0}* __arrPtr = {1}.{2})",
+ type.Substring(0,type.Length-2), Helpers.InstanceField,
Helpers.SafeIdentifier(field.OriginalName)));
WriteStartBraceIndent();
ctx.ReturnVarName = string.Format("__arrPtr");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment