static void Analyze(SyntaxNodeAnalysisContext context) { var model = context.SemanticModel; var typeDeclaration = context.Node as TypeDeclarationSyntax; if (typeDeclaration == null) { return; } var declaredSymbol = model.GetDeclaredSymbol(typeDeclaration); if (declaredSymbol == null) { return; } var typeReferences = new ReferenceSymbols(model.Compilation); if ( ((declaredSymbol.TypeKind == TypeKind.Interface) && declaredSymbol.GetAttributes().Any(x2 => x2.AttributeClass == typeReferences.UnionAttribute)) || ((declaredSymbol.TypeKind == TypeKind.Class) && declaredSymbol.GetAttributes().Any(x2 => x2.AttributeClass == typeReferences.MessagePackObjectAttribnute)) || ((declaredSymbol.TypeKind == TypeKind.Struct) && declaredSymbol.GetAttributes().Any(x2 => x2.AttributeClass == typeReferences.MessagePackObjectAttribnute)) ) { var reportContext = new DiagnosticsReportContext(context); var collector = new TypeCollector(reportContext, model.Compilation); collector.CollectCore(declaredSymbol); reportContext.ReportAll(); } }
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(); } }