private string ToVBNetDisplaySignature() { var sb = new StringBuilder(); switch (DefineKinds) { case DefineKinds.Namespace: break; case DefineKinds.Class: case DefineKinds.Struct: case DefineKinds.Interface: case DefineKinds.Module: case DefineKinds.Enum: sb.Append(DisplayDefineName); break; case DefineKinds.Field: case DefineKinds.Property: // X As Integer sb.Append($"{DisplayDefineName} As {DisplayReturnType}"); break; case DefineKinds.Constructor: // New() sb.Append("New"); sb.Append("("); if (MethodArguments.Any()) { sb.Append($"{DisplayMethodArguments}"); } sb.Append(")"); break; case DefineKinds.Operator: case DefineKinds.WindowsAPI: case DefineKinds.EventHandler: case DefineKinds.Method: case DefineKinds.Delegate: case DefineKinds.Indexer: // +(Point, Point) As Point // MoveFile(String, String) As Boolean // Button1_Click(sender As Object, e As EventArgs) // F() : IEnumerable(Of T) // CalcDelegate // Items(i As Integer) As Integer // // Delegate の場合、デリゲート名しか表示しないが、分かりづらいので本ツールでは通常メソッド扱いする // CalcDelegate ではなく、CalcDelegate(i1 As Integer, i2 As Integer) As Integer sb.Append($"{DisplayDefineName}"); sb.Append("("); if (MethodArguments.Any()) { sb.Append($"{DisplayMethodArguments}"); } sb.Append(")"); if (!string.IsNullOrEmpty(DisplayReturnType) && DisplayReturnType.ToLower() != "void") { sb.Append(" As "); sb.Append($"{DisplayReturnType}"); } break; case DefineKinds.Event: // Clicked() // Clicked As EventHandler // // Public Event Clicked(sender As Object, e As EventArgs) と書くと、 // Clicked() と表示されるが分かりづらいので、本ツールでは引数も表示させる // Clicked(sender As Object, e As EventArgs) sb.Append($"{DisplayDefineName}"); sb.Append("("); if (MethodArguments.Any()) { sb.Append($"{DisplayMethodArguments}"); } sb.Append(")"); if (!string.IsNullOrEmpty(DisplayReturnType) && DisplayReturnType.ToLower() != "void") { sb.Append(" As "); sb.Append($"{DisplayReturnType}"); } break; } return(sb.ToString()); }
// private string ToCSharpDisplaySignature() { var sb = new StringBuilder(); switch (DefineKinds) { case DefineKinds.Namespace: break; case DefineKinds.Class: case DefineKinds.Struct: case DefineKinds.Interface: case DefineKinds.Module: case DefineKinds.Enum: sb.Append(DisplayDefineName); break; case DefineKinds.Field: case DefineKinds.Property: case DefineKinds.Event: // X : int sb.Append($"{DisplayDefineName} : {DisplayReturnType}"); break; case DefineKinds.Constructor: // Class1() sb.Append($"{DisplayDefineName}"); sb.Append("("); if (MethodArguments.Any()) { sb.Append($"{DisplayMethodArguments}"); } sb.Append(")"); break; case DefineKinds.Operator: // Visual Studio では戻り値は表示されないが、本ツールでは戻り値も表示する // operator +(Point, Point) // ↓ // operator +(Point, Point) : Point sb.Append("operator "); sb.Append($"{DisplayDefineName}"); sb.Append("("); if (MethodArguments.Any()) { sb.Append($"{DisplayMethodArguments}"); } sb.Append(")"); sb.Append(" : "); sb.Append($"{DisplayReturnType}"); break; case DefineKinds.WindowsAPI: case DefineKinds.EventHandler: case DefineKinds.Method: case DefineKinds.Delegate: // Beep(uint, uint) : bool // Button1_Click(object sender, EventArgs e) : void // f() : int // f(int i) : IEnumerable<T> sb.Append($"{DisplayDefineName}"); sb.Append("("); if (MethodArguments.Any()) { sb.Append($"{DisplayMethodArguments}"); } sb.Append(")"); sb.Append(" : "); sb.Append($"{DisplayReturnType}"); break; case DefineKinds.Indexer: // this[int i] : int sb.Append($"{DisplayDefineName}"); sb.Append("["); if (MethodArguments.Any()) { sb.Append($"{DisplayMethodArguments}"); } sb.Append("]"); sb.Append(" : "); sb.Append($"{DisplayReturnType}"); break; } return(sb.ToString()); }