Пример #1
0
            private static void AddMissingMembers(FixAllContext fixAllContext, DocumentEditor editor, IEnumerable <Diagnostic> diagnostics, SyntaxNode node)
            {
                var(missingMemberNames, _) = GetRequiredShapeMissingMemberNames(diagnostics);
                ITypeSymbol marshallerType = (ITypeSymbol)editor.SemanticModel.GetDeclaredSymbol(node);

                editor.ReplaceNode(
                    node,
                    (node, gen) =>
                    CustomTypeMarshallerFixer.AddMissingMembers(
                        node,
                        marshallerType,
                        missingMemberNames,
                        editor.SemanticModel.Compilation,
                        gen));
            }
Пример #2
0
            private static async Task AddMissingFeatures(FixAllContext fixAllContext, DocumentEditor editor, IEnumerable <Diagnostic> diagnostics, SyntaxNode node)
            {
                var(featuresToAdd, _) = GetFeaturesToAdd(diagnostics);
                ITypeSymbol   marshallerType = (ITypeSymbol)editor.SemanticModel.GetDeclaredSymbol(node);
                AttributeData customTypeMarshallerAttribute = marshallerType.GetAttributes().FirstOrDefault(attr => attr.AttributeClass.ToDisplayString() == TypeNames.CustomTypeMarshallerAttribute);

                SyntaxNode attributeSyntax = await customTypeMarshallerAttribute.ApplicationSyntaxReference !.GetSyntaxAsync(fixAllContext.CancellationToken).ConfigureAwait(false);

                editor.ReplaceNode(
                    attributeSyntax,
                    (node, gen) =>
                    CustomTypeMarshallerFixer.AddMissingFeatures(
                        gen.GetName(node),
                        customTypeMarshallerAttribute,
                        featuresToAdd,
                        gen));
            }