Exemple #1
0
 private static void TryToReportSpinlockPassAsValue(SyntaxNodeAnalysisContext context, SyntaxTokenList modifiers, SyntaxNode memberDeclaration, TypeSyntax fieldDeclarationType)
 {
     if (fieldDeclarationType.ToFullString().Trim().EndsWith("SpinLock") && modifiers.Any(x => x.Kind() == SyntaxKind.ReadOnlyKeyword))
     {
         context.ReportDiagnostic(Diagnostic.Create(MT1015, memberDeclaration.GetLocation()));
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReturnCommentConstruction"/> class.
 /// </summary>
 /// <param name="returnType">The return type.</param>
 public ReturnCommentConstruction(TypeSyntax returnType)
 {
     if (returnType is PredefinedTypeSyntax)
     {
         Comment = GeneratePrefinedTypeComment(returnType as PredefinedTypeSyntax);
     }
     else if (returnType is IdentifierNameSyntax)
     {
         Comment = GenerateIdentifierNameTypeComment(returnType as IdentifierNameSyntax);
     }
     else if (returnType is QualifiedNameSyntax)
     {
         Comment = GenerateQualifiedNameTypeComment(returnType as QualifiedNameSyntax);
     }
     else if (returnType is GenericNameSyntax)
     {
         Comment = GenerateGenericTypeComment(returnType as GenericNameSyntax);
     }
     else if (returnType is ArrayTypeSyntax)
     {
         Comment = GenerateArrayTypeComment(returnType as ArrayTypeSyntax);
     }
     else
     {
         Comment = GenerateGeneralComment(returnType.ToFullString());
     }
 }
Exemple #3
0
 private static void TryToReportViolation(SyntaxNodeAnalysisContext context, SyntaxNode memberDeclaration,
                                          TypeSyntax fieldDeclarationType)
 {
     if (fieldDeclarationType.ToFullString().Trim().EndsWith("ReaderWriterLock"))
     {
         context.ReportDiagnostic(Diagnostic.Create(MT1016, memberDeclaration.GetLocation()));
     }
 }
        /// <summary>
        /// Determines specific object name.
        /// </summary>
        /// <param name="specificType">The specific type.</param>
        /// <returns>The comment.</returns>
        private static string DetermineSpecificObjectName(TypeSyntax specificType)
        {
            string result = null;

            if (specificType is IdentifierNameSyntax)
            {
                result = Pluralizer.Pluralize(((IdentifierNameSyntax)specificType).Identifier.ValueText);
            }
            else if (specificType is PredefinedTypeSyntax)
            {
                result = (specificType as PredefinedTypeSyntax).Keyword.ValueText;
            }
            else if (specificType is GenericNameSyntax)
            {
                result = (specificType as GenericNameSyntax).Identifier.ValueText;
            }
            else
            {
                result = specificType.ToFullString();
            }
            return(result + ".");
        }
 public override string ToString()
 {
     return(_t.ToFullString() + " value");
 }