private static void AnalyzeIfGenerationRequired(SyntaxNodeAnalysisContext context, TypeDeclarationSyntax typeDeclaration, INamedTypeSymbol typeSymbol)
        {
            var recordPartial = RecordPartialGenerator.GetGeneratedPartial(typeDeclaration, typeSymbol);

            if (recordPartial == null)
            {
                // no generated partial found
                var missingPartialDiagnostic =
                    RecordPartialMissingDiagnostic.Create(
                        typeDeclaration.Identifier.GetLocation(),
                        typeDeclaration.Identifier.ValueText);

                context.ReportDiagnostic(missingPartialDiagnostic);
                return;
            }

            // check partial is equivalent to would-be generated partial
            var wouldBePartialRoot = RecordPartialGenerator.GenerateRecordPartialRoot(typeDeclaration, context.CancellationToken);
            var currentPartialRoot = recordPartial.SyntaxTree.GetRoot(context.CancellationToken);

            var equivalenceResult = wouldBePartialRoot.IsTokenwiseEquivalentTo(currentPartialRoot);

            switch (equivalenceResult)
            {
            case RecordPartialComparer.Result.Equivalent:
                return;

            case RecordPartialComparer.Result.EquivalentExceptGeneratedCodeAttributeVersion:
            {
                string version = recordPartial.ExtractGeneratedCodeAttributeVersionArgument();
                // report info "record partial might need update"
                var differentToolVersionDiagnostic =
                    GeneratorVersionDifferentDiagnostic.Create(
                        typeDeclaration.Identifier.GetLocation(),
                        typeDeclaration.Identifier.ValueText,
                        version,
                        Properties.VersionString);

                context.ReportDiagnostic(differentToolVersionDiagnostic);
            }
                return;

            case RecordPartialComparer.Result.NotEquivalent:
            {
                // report error "record partial requires update"
                var invalidPartialDiagnostic =
                    RecordPartialInvalidDiagnostic.Create(
                        typeDeclaration.Identifier.GetLocation(),
                        typeDeclaration.Identifier.ValueText);

                context.ReportDiagnostic(invalidPartialDiagnostic);
            }
                return;

            default:
                break;
            }
        }
        private async Task <Solution> FixMissingRecordPartialAsync(Document document, TypeDeclarationSyntax declaration, CancellationToken c)
        {
            (document, declaration) = await AddPartialModifierIfRequired(document, declaration, c).ConfigureAwait(false);

            var semanticModel = await document.GetSemanticModelAsync(c).ConfigureAwait(false);

            var typeSymbol        = semanticModel.GetDeclaredSymbol(declaration);
            var generatedDocument = RecordPartialGenerator.GenerateRecordPartialDocument(document, declaration, typeSymbol, c);

            return(generatedDocument.Project.Solution);
        }