private static void AnalyzeCall(SyntaxNodeAnalysisContext context, ISymbol migratableAttributeType) { var ct = context.CancellationToken; var typeDeclaration = (TypeDeclarationSyntax)context.Node; var attribute = MigrationHashHelper.GetAttribute(typeDeclaration, migratableAttributeType, context.SemanticModel, ct); if (attribute == null) { return; } var typeSymbol = context.SemanticModel.GetDeclaredSymbol(typeDeclaration, ct); var verifier = new MigrationMethodVerifier(CanAssign(context)); var migrationMethods = MigrationHashHelper.GetMigrationMethods(typeSymbol); var invalidMethods = verifier.VerifyMigrationMethods(migrationMethods) .Where(x => x.Result != VerificationResultEnum.Ok); foreach (var x in invalidMethods) { var method = typeSymbol.GetMembers() .First(sy => sy.Name == x.Method.Name); Debug.Assert(method.Locations.Length == 1, "Method has multiple locations."); var diagnostic = Diagnostic.Create(Rule, method.Locations[0], method.Name, typeSymbol.Name, x.Result); context.ReportDiagnostic(diagnostic); } }
private static void AnalyzeCall(SyntaxNodeAnalysisContext context, ISymbol migratableAttributeType, ISymbol dataMemberAttributeType) { var ct = context.CancellationToken; var typeDeclaration = (TypeDeclarationSyntax)context.Node; var attribute = MigrationHashHelper.GetAttribute(typeDeclaration, migratableAttributeType, context.SemanticModel, ct); if (attribute == null) { return; } var attributeHash = GetAttributeHash(attribute, context.SemanticModel, ct); var computedHash = MigrationHashHelper.GetMigrationHashFromType(typeDeclaration, ct, context.SemanticModel, dataMemberAttributeType); if (attributeHash != computedHash) { var diagnostic = Diagnostic.Create(Rule, typeDeclaration.GetLocation(), typeDeclaration.Identifier.ToString(), computedHash, attributeHash); context.ReportDiagnostic(diagnostic); } }