public override void Fix(IInspectionResult result, IRewriteSession rewriteSession)
        {
            if (!(result is IWithInspectionResultProperties <(IParseTreeAnnotation Annotation, string AttributeName, IReadOnlyList <string> AttributeValues)> resultProperties))
            {
                return;
            }

            var declaration = result.Target;

            var(oldParseTreeAnnotation, attributeBaseName, attributeValues) = resultProperties.Properties;

            if (declaration.DeclarationType.HasFlag(DeclarationType.Module))
            {
                var componentType = declaration.QualifiedModuleName.ComponentType;
                if (IsDefaultAttribute(componentType, attributeBaseName, attributeValues))
                {
                    _annotationUpdater.RemoveAnnotation(rewriteSession, oldParseTreeAnnotation);
                }
                else
                {
                    var(newAnnotation, newAnnotationValues) = _attributeAnnotationProvider.ModuleAttributeAnnotation(attributeBaseName, attributeValues);
                    _annotationUpdater.UpdateAnnotation(rewriteSession, oldParseTreeAnnotation, newAnnotation, newAnnotationValues);
                }
            }
            else
            {
                var(newAnnotation, newAnnotationValues) = _attributeAnnotationProvider.MemberAttributeAnnotation(attributeBaseName, attributeValues);
                _annotationUpdater.UpdateAnnotation(rewriteSession, oldParseTreeAnnotation, newAnnotation, newAnnotationValues);
            }
        }
Esempio n. 2
0
        public override void Fix(IInspectionResult result, IRewriteSession rewriteSession)
        {
            IParseTreeAnnotation oldAnnotation = result.Properties.Annotation;
            string attributeName = result.Properties.AttributeName;
            IReadOnlyList <string> attributeValues = result.Properties.AttributeValues;

            var declaration = result.Target;

            if (declaration.DeclarationType.HasFlag(DeclarationType.Module))
            {
                var componentType = declaration.QualifiedModuleName.ComponentType;
                if (IsDefaultAttribute(componentType, attributeName, attributeValues))
                {
                    _annotationUpdater.RemoveAnnotation(rewriteSession, oldAnnotation);
                }
                else
                {
                    var(newAnnotation, newAnnotationValues) = _attributeAnnotationProvider.ModuleAttributeAnnotation(attributeName, attributeValues);
                    _annotationUpdater.UpdateAnnotation(rewriteSession, oldAnnotation, newAnnotation, newAnnotationValues);
                }
            }
            else
            {
                var attributeBaseName = AttributeBaseName(attributeName, declaration);
                var(newAnnotation, newAnnotationValues) = _attributeAnnotationProvider.MemberAttributeAnnotation(attributeBaseName, attributeValues);
                _annotationUpdater.UpdateAnnotation(rewriteSession, oldAnnotation, newAnnotation, newAnnotationValues);
            }
        }
        public override void Fix(IInspectionResult result, IRewriteSession rewriteSession)
        {
            if (!(result is IWithInspectionResultProperties <IParseTreeAnnotation> resultProperties))
            {
                return;
            }

            _annotationUpdater.RemoveAnnotation(rewriteSession, resultProperties.Properties);
        }
 public override void Fix(IInspectionResult result, IRewriteSession rewriteSession)
 {
     _annotationUpdater.RemoveAnnotation(rewriteSession, result.Properties.Annotation);
 }