private string GetMethodName(ExternalMethod method, bool preserveMemberCase) { string methodName = method.Name; var scriptNameAttr = method.Attributes.FirstOrDefault(x => x.Type == "System.Runtime.CompilerServices.ScriptNameAttribute"); if (scriptNameAttr != null) { methodName = scriptNameAttr.Arguments[0].Value as string; } else if (!preserveMemberCase && !method.Attributes.Any(x => x.Type == "System.Runtime.CompilerServices.PreserveCaseAttribute")) { if (methodName == "ID") { methodName = "id"; } else { methodName = methodName.Substring(0, 1).ToLowerInvariant() + methodName.Substring(1); } } return(methodName); }
private void SSDeclarationMethod(ExternalMethod method, string codeNamespace, bool isStaticClass, bool preserveMemberCase) { if (method.IsConstructor || method.IsOverride || method.IsGetter || method.IsSetter) { return; } SSDeclarationMethodInternal(method, codeNamespace, isStaticClass, preserveMemberCase); }
private void SSDeclarationMethodInternal(ExternalMethod method, string codeNamespace, bool isStaticClass, bool preserveMemberCase) { if (method.Attributes.Any(x => x.Type == "System.Runtime.CompilerServices.InlineCodeAttribute")) { return; } var methodName = GetMethodName(method, preserveMemberCase); if (isStaticClass && method.IsStatic) { cw.Indented("function "); sb.Append(methodName); } else if (method.IsStatic) { cw.Indented("static "); sb.Append(methodName); } else { cw.Indented(methodName); } sb.Append("("); SSMethodArguments(method.Arguments, codeNamespace); sb.Append("): "); if (method.Type == null || method.Type == "System.Void") { sb.Append("void"); } else { SSTypeNameToTS(method.Type, codeNamespace); } sb.AppendLine(";"); }
private void SSDeclarationConstructor(ExternalMethod ctor, string codeNamespace) { cw.Indented("constructor("); SSMethodArguments(ctor.Arguments, codeNamespace); sb.AppendLine(");"); }
private void SSDeclarationMethod(ExternalMethod method, string codeNamespace, bool isStaticClass, bool preserveMemberCase) { if (method.IsConstructor || method.IsOverride || method.IsGetter || method.IsSetter) return; SSDeclarationMethodInternal(method, codeNamespace, isStaticClass, preserveMemberCase); }
private void SSDeclarationMethodInternal(ExternalMethod method, string codeNamespace, bool isStaticClass, bool preserveMemberCase) { if (method.Attributes.Any(x => x.Type == "System.Runtime.CompilerServices.InlineCodeAttribute")) return; var methodName = GetMethodName(method, preserveMemberCase); if (isStaticClass && method.IsStatic) { cw.Indented("function "); sb.Append(methodName); } else if (method.IsStatic) { cw.Indented("static "); sb.Append(methodName); } else { cw.Indented(methodName); } sb.Append("("); SSMethodArguments(method.Arguments, codeNamespace); sb.Append("): "); if (method.Type == null || method.Type == "System.Void") { sb.Append("void"); } else { SSTypeNameToTS(method.Type, codeNamespace); } sb.AppendLine(";"); }
private string GetMethodName(ExternalMethod method, bool preserveMemberCase) { string methodName = method.Name; var scriptNameAttr = method.Attributes.FirstOrDefault(x => x.Type == "System.Runtime.CompilerServices.ScriptNameAttribute"); if (scriptNameAttr != null) methodName = scriptNameAttr.Arguments[0].Value as string; else if (!preserveMemberCase && !method.Attributes.Any(x => x.Type == "System.Runtime.CompilerServices.PreserveCaseAttribute")) { if (methodName == "ID") methodName = "id"; else methodName = methodName.Substring(0, 1).ToLowerInvariant() + methodName.Substring(1); } return methodName; }
private void SSDeclarationConstructor(ExternalMethod ctor, string codeNamespace) { cw.Indented("constructor("); SSMethodArguments(ctor.Arguments, codeNamespace); sb.AppendLine(");"); }