Пример #1
0
        private static void Analyze(SyntaxNodeAnalysisContext context, ReferenceSymbols typeReferences)
        {
            TypeDeclarationSyntax typeDeclaration = (TypeDeclarationSyntax)context.Node;
            INamedTypeSymbol?     declaredSymbol  = context.SemanticModel.GetDeclaredSymbol(typeDeclaration);

            if (declaredSymbol is null)
            {
                return;
            }

            if (
                ((declaredSymbol.TypeKind == TypeKind.Interface) && declaredSymbol.GetAttributes().Any(x2 => Equals(x2.AttributeClass, typeReferences.UnionAttribute))) ||
                ((declaredSymbol.TypeKind == TypeKind.Class) && declaredSymbol.GetAttributes().Any(x2 => Equals(x2.AttributeClass, typeReferences.MessagePackObjectAttribute))) ||
                ((declaredSymbol.TypeKind == TypeKind.Struct) && declaredSymbol.GetAttributes().Any(x2 => Equals(x2.AttributeClass, typeReferences.MessagePackObjectAttribute))))
            {
                var reportContext = new DiagnosticsReportContext(context);
                var collector     = new TypeCollector(reportContext, typeReferences);
                collector.CollectCore(declaredSymbol);
                reportContext.ReportAll();
            }
        }