public MissingRefitAttributeWarning(InterfaceDeclarationSyntax @interface, MethodDeclarationSyntax method) : base("RF001") { setLocation(method.GetLocation()); InterfaceName = @interface.Identifier.Text; MethodName = method.Identifier.Text; Message = string.Format( "Method {0}.{1} either has no Refit HTTP method attribute or you've used something other than a string literal for the 'path' argument.", InterfaceName, MethodName); }
/// <summary> /// Récupère le nom complet du type de la méthode (avec paramètre de type éventuel). /// </summary> /// <param name="méthode">La méthode.</param> /// <param name="méthodeCorrespondante">La méthode correspondante.</param> /// <param name="modèleSémantique">Le modèle sémantique (pour simplifier les types).</param> /// <returns>Le nom complet de la méthode.</returns> private static string RécupérerNomType(MethodDeclarationSyntax méthode, IMethodSymbol méthodeCorrespondante, SemanticModel modèleSémantique) => méthodeCorrespondante.ContainingType.ConstructedFrom .ToMinimalDisplayString(modèleSémantique, méthode.GetLocation().SourceSpan.Start) .Replace('<', '{').Replace('>', '}');
/// <summary> /// Récupère les paramètres de la méthode. /// </summary> /// <param name="méthode">La méthode.</param> /// <param name="méthodeCorrespondante">La méthode correspondante.</param> /// <param name="modèleSémantique">Le modèle sémantique (pour simplifier les types).</param> /// <param name="nombreMéthodesSurchargées">Le nombre de méthodes avec le même nom dans l'interface.</param> /// <returns>Le nom complet de la méthode.</returns> private static string RécupérerParamètres(MethodDeclarationSyntax méthode, IMethodSymbol méthodeCorrespondante, SemanticModel modèleSémantique, int nombreMéthodesSurchargées) { if (nombreMéthodesSurchargées == 1 || méthodeCorrespondante.Parameters.Count() == 0) return string.Empty; #pragma warning disable SA1513 return $@"({string.Join(", ", méthodeCorrespondante.Parameters .Select(symbol => symbol.Type.ToMinimalDisplayString( modèleSémantique, méthode.GetLocation().SourceSpan.Start)))})"; #pragma warning restore SA1513 }
internal void WriteDetectedMisuseAsyncUsageToTable(int type, Microsoft.CodeAnalysis.Document Document, MethodDeclarationSyntax node) { string resultfile = @"C:\Users\Semih\Desktop\MisuseTables\" + type + ".txt"; string delimStr = "/"; char[] delimiter = delimStr.ToCharArray(); var location = node.GetLocation().GetLineSpan(); var app = AppName.Replace("+", "/"); var methodName= node.Modifiers.ToString()+ " "+ node.ReturnType.ToString()+ " "+ node.Identifier.ToString() + " "+ node.ParameterList.ToString(); string filepathWithLineNumbers = "http://www.github.com/" + app + "/blob/" + commit + "/" + Document.FilePath.Replace(@"\", @"/").Split(delimiter, 6)[5] + "#L" + (location.StartLinePosition.Line + 1) + "-" + (location.EndLinePosition.Line + 1); var row = String.Format(@"<tr><td>{0}</td><td><a href='{1}'>Link to Source Code</a></td> </tr>", methodName, filepathWithLineNumbers); using (StreamWriter sw = File.AppendText(resultfile)) { sw.WriteLine(row); } }
public void WriteNodeToCallTrace(MethodDeclarationSyntax node, int n) { var path = node.SyntaxTree.FilePath; var start = node.GetLocation().GetLineSpan().StartLinePosition; string message = ""; for (var i = 0; i < n; i++) message += " "; message += node.Identifier + " " + n + " @ " + path + ":" + start; Logs.CallTraceLog.Info(message); }
public MultipleRefitMethodSameNameWarning(InterfaceDeclarationSyntax @interface, MethodDeclarationSyntax method) : base("RF002") { setLocation(method.GetLocation()); InterfaceName = @interface.Identifier.Text; MethodName = method.Identifier.Text; Message = string.Format( "Method {0}.{1} has been declared multiple times. Refit doesn't support overloading.", InterfaceName, MethodName); }