Exemplo n.º 1
0
 private static void ReportWalkerResult([NotNull] TopLevelTypeSyntaxWalker walker, SemanticModelAnalysisContext context)
 {
     if (walker.TopLevelTypeDeclarations.Count > 1)
     {
         foreach (SyntaxNode extraTypeSyntax in walker.TopLevelTypeDeclarations.Skip(1))
         {
             ReportType(context, extraTypeSyntax);
         }
     }
 }
        private static void AnalyzeSemanticModel(SemanticModelAnalysisContext context)
        {
            SyntaxNode syntaxRoot = context.SemanticModel.SyntaxTree.GetRoot(context.CancellationToken);

            var walker = new TopLevelTypeSyntaxWalker();
            walker.Visit(syntaxRoot);

            context.CancellationToken.ThrowIfCancellationRequested();

            ReportWalkerResult(walker, context);
        }
Exemplo n.º 3
0
        private static void ReportWalkerResult([NotNull] TopLevelTypeSyntaxWalker walker, SemanticModelAnalysisContext context)
        {
            if (walker.TopLevelTypeDeclarations.Count > 1)
            {
                SyntaxNode firstTypeSyntax = walker.TopLevelTypeDeclarations.First();
                string     firstTypeName   = GetTypeName(firstTypeSyntax);

                foreach (SyntaxNode extraTypeSyntax in walker.TopLevelTypeDeclarations.Skip(1)
                         .Where(typeSyntax => GetTypeName(typeSyntax) != firstTypeName))
                {
                    ReportType(context, extraTypeSyntax);
                }
            }
        }