5using System.Collections.Immutable;
10 [DiagnosticAnalyzer(LanguageNames.CSharp)]
14 private static readonly DiagnosticDescriptor makeSerializableRule =
15 new DiagnosticDescriptor(
16 Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable, IsBusinessObjectSerializableConstants.Title,
17 IsBusinessObjectSerializableConstants.Message, Constants.Categories.Usage,
18 DiagnosticSeverity.Error,
true,
19 helpLinkUri: HelpUrlBuilder.Build(
22 public override ImmutableArray<DiagnosticDescriptor>
SupportedDiagnostics => ImmutableArray.Create(makeSerializableRule);
26 context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
27 context.EnableConcurrentExecution();
28 context.RegisterSyntaxNodeAction(AnalyzeClassDeclaration, SyntaxKind.ClassDeclaration);
31 private static void AnalyzeClassDeclaration(SyntaxNodeAnalysisContext context)
33 var classNode = (ClassDeclarationSyntax)context.Node;
34 var classSymbol = context.SemanticModel.GetDeclaredSymbol(classNode);
36 if (classSymbol.IsMobileObject() && !classSymbol.IsSerializable)
38 context.ReportDiagnostic(Diagnostic.Create(makeSerializableRule,
39 classNode.Identifier.GetLocation()));
override ImmutableArray< DiagnosticDescriptor > SupportedDiagnostics
override void Initialize(AnalysisContext context)