public IEnumerable <SuggestedActionSet> CreateActionSet(IRapidXamlTag tag, params BaseSuggestedAction[] actions)
        {
            var result = new List <SuggestedActionSet>()
            {
                new SuggestedActionSet(
                    PredefinedSuggestedActionCategoryNames.Refactoring,
                    actions: actions,
                    title: StringRes.UI_SuggestedActionSetTitle,
                    priority: SuggestedActionSetPriority.None,
                    applicableToSpan: tag.Span),
            };

            if (tag is RapidXamlDisplayedTag rxdt)
            {
                foreach (var action in actions)
                {
                    // Don't show a suppression action if there is no ErrorCode
                    if (!string.IsNullOrWhiteSpace(rxdt.ErrorCode))
                    {
                        result.Add(new SuggestedActionSet(
                                       PredefinedSuggestedActionCategoryNames.Any,
                                       actions: new[] { SuppressWarningAction.Create(rxdt, action.File, this) },
                                       title: StringRes.UI_SuggestedActionSetTitle,
                                       priority: SuggestedActionSetPriority.None,
                                       applicableToSpan: tag.Span));
                    }
                }
            }

            return(result);
        }
Пример #2
0
        public IEnumerable <SuggestedActionSet> CreateActionSet(IRapidXamlTag tag, params BaseSuggestedAction[] actions)
        {
            var enabledActions = actions.Where(action => action.IsEnabled);

            var result = new List <SuggestedActionSet>()
            {
                new SuggestedActionSet(
                    PredefinedSuggestedActionCategoryNames.Refactoring,
                    actions: enabledActions,
                    title: StringRes.UI_SuggestedActionSetTitle,
                    priority: SuggestedActionSetPriority.None,
                    applicableToSpan: tag.Span),
            };

            if (tag is RapidXamlDisplayedTag rxdt)
            {
                foreach (var action in actions)
                {
                    result.Add(new SuggestedActionSet(
                                   PredefinedSuggestedActionCategoryNames.Any,
                                   actions: new[] { SuppressWarningAction.Create(rxdt, action.File, this) },
                                   title: StringRes.UI_SuggestedActionSetTitle,
                                   priority: SuggestedActionSetPriority.None,
                                   applicableToSpan: tag.Span));
                }
            }

            return(result);
        }