private void BeforeQueryStatus(object sender, EventArgs e)
        {
            var button = (OleMenuCommand)sender;

            button.Enabled = button.Visible = false;

            var errorList           = VsHelpers.DTE.ToolWindows.ErrorList as IErrorList;
            ITableEntryHandle entry = errorList.TableControl.SelectedEntry;

            if (entry == null || !entry.TryGetValue(StandardTableKeyNames.ErrorCode, out string content))
            {
                return;
            }

            if (!ErrorCatalog.TryGetErrorCode(content, out _selectedError))
            {
                return;
            }

            if (entry == null || !entry.TryGetValue(StandardTableKeyNames.DocumentName, out _filePath))
            {
                return;
            }

            button.Visible = button.Enabled = true;
            button.Text    = "Suppress " + _selectedError.Code;
        }
Esempio n. 2
0
        public override bool TryCreateStringContent(ITableEntryHandle entry, bool truncatedText, bool singleColumnView, out string content)
        {
            if (entry.TryGetValue(TableKeyNames.Status, out var status) && status is BuildStatus and not BuildStatus.Running &&
                entry.TryGetValue(TableKeyNames.Elapsed, out var value) && value is TimeSpan timeSpan)
            {
                content = timeSpan.TotalSeconds.ToString("N3");
                return(true);
            }

            content = null;
            return(false);
        }
Esempio n. 3
0
            public override void PreprocessNavigate(
                ITableEntryHandle entry,
                TableEntryNavigateEventArgs e
                )
            {
                if (entry.Identity is ISupportsNavigation supportsNavigation)
                {
                    // TODO: Use a threaded-wait-dialog here so we can cancel navigation.
                    if (supportsNavigation.TryNavigateTo(e.IsPreview, CancellationToken.None))
                    {
                        e.Handled = true;
                        return;
                    }
                }

                if (
                    entry.TryGetValue(StreamingFindUsagesPresenter.SelfKeyName, out var item) &&
                    item is ISupportsNavigation itemSupportsNavigation
                    )
                {
                    // TODO: Use a threaded-wait-dialog here so we can cancel navigation.
                    if (itemSupportsNavigation.TryNavigateTo(e.IsPreview, CancellationToken.None))
                    {
                        e.Handled = true;
                        return;
                    }
                }

                base.PreprocessNavigate(entry, e);
            }
Esempio n. 4
0
 public override bool TryCreateStringContent(ITableEntryHandle entry, bool truncatedText, bool singleColumnView, out string?content)
 {
     content = entry.TryGetValue <ReferenceType>(UnusedReferencesTableKeyNames.ReferenceType, out var referenceType)
         ? GetText(referenceType)
         : null;
     return(content != null);
 }
        private static bool EntrySupportsSuppressionState(ITableEntryHandle entryHandle, out bool isRoslynEntry, out bool isSuppressedEntry, out bool isCompilerDiagnosticEntry, out bool isNoLocationDiagnosticEntry)
        {
            string filePath;

            isNoLocationDiagnosticEntry = !entryHandle.TryGetValue(StandardTableColumnDefinitions.DocumentName, out filePath) ||
                                          string.IsNullOrEmpty(filePath);

            int index;
            var roslynSnapshot = GetEntriesSnapshot(entryHandle, out index);

            if (roslynSnapshot == null)
            {
                isRoslynEntry             = false;
                isCompilerDiagnosticEntry = false;
                return(IsNonRoslynEntrySupportingSuppressionState(entryHandle, out isSuppressedEntry));
            }

            var diagnosticData = roslynSnapshot?.GetItem(index)?.Primary;

            if (!IsEntryWithConfigurableSuppressionState(diagnosticData))
            {
                isRoslynEntry             = false;
                isSuppressedEntry         = false;
                isCompilerDiagnosticEntry = false;
                return(false);
            }

            isRoslynEntry             = true;
            isSuppressedEntry         = diagnosticData.IsSuppressed;
            isCompilerDiagnosticEntry = SuppressionHelpers.IsCompilerDiagnostic(diagnosticData);
            return(true);
        }
Esempio n. 6
0
        public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement?content)
        {
            if (!entry.TryGetValue(Value, out WhitespaceSetting setting))
            {
                content = null;
                return(false);
            }

            if (setting.Type == typeof(bool))
            {
                var viewModel = new WhitespaceSettingBoolViewModel(setting);
                content = new WhitespaceBoolSettingView(viewModel);
                return(true);
            }

            foreach (var factory in _factories)
            {
                if (factory.IsSupported(setting.Key))
                {
                    var viewModel = factory.CreateViewModel(setting);
                    content = new EnumSettingView(viewModel);
                    return(true);
                }
            }

            content = null;
            return(false);
        }
        public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement content)
        {
            if (entry.TryGetValue(TableKeyNames.Status, out var statusValue) && statusValue != null && statusValue is BuildStatus status &&
                status != BuildStatus.Running &&
                entry.TryGetValue(TableKeyNames.Elapsed, out var value) && value != null && value is TimeSpan timeSpan)
            {
                content = new TextBlock
                {
                    Text          = timeSpan.TotalSeconds.ToString("N3"),
                    TextAlignment = TextAlignment.Right
                };
                return(true);
            }

            content = null;
            return(false);
        }
        public static string GetStringFromTableEntry(ITableEntryHandle i_TableEntry, string i_Value)
        {
            string errorValue = null;

            i_TableEntry?.TryGetValue(i_Value, out errorValue);

            return(errorValue);
        }
        private static Reference CreateReference(ITableEntryHandle tableEntryHandle)
        {
            tableEntryHandle.TryGetValue(StandardTableKeyNames.DocumentName, out string filePath);
            tableEntryHandle.TryGetValue(StandardTableKeyNames.Line, out int line);
            tableEntryHandle.TryGetValue(StandardTableKeyNames.Column, out int column);
            tableEntryHandle.TryGetValue(StandardTableKeyNames.Text, out string code);

            var reference = new Reference
            {
                FilePath = filePath,
                Line     = line,
                Column   = column,
                Code     = code
            };

            return(reference);
        }
        private static bool IsNuGetEntry(ITableEntryHandle entry)
        {
            object sourceObj;

            return(entry != null &&
                   entry.TryGetValue(StandardTableColumnDefinitions.ErrorSource, out sourceObj) &&
                   StringComparer.Ordinal.Equals(ErrorListTableEntry.ErrorSouce, (sourceObj as string)));
        }
 public override IEntryBucket?CreateBucketForEntry(ITableEntryHandle entry)
 {
     return(entry.TryGetValue(
                UnusedReferencesTableKeyNames.SolutionName,
                out string name
                )
       ? new ImageEntryBucket(KnownMonikers.Solution, name)
       : null);
 }
 public override bool TryCreateStringContent(
     ITableEntryHandle entry,
     bool truncatedText,
     bool singleColumnView,
     out string content
     )
 {
     return(entry.TryGetValue(UnusedReferencesTableKeyNames.ProjectName, out content));
 }
        public override int CompareContent(ITableEntryHandle leftEntry, ITableEntryHandle rightEntry)
        {
            if (leftEntry.TryGetValue(this.Name, out object leftValue) && leftValue is WpfTraceInfo leftInfo &&
                rightEntry.TryGetValue(this.Name, out object rightValue) && rightValue is WpfTraceInfo rightInfo)
            {
                return(leftInfo.CompareTo(rightInfo));
            }

            return(base.CompareContent(leftEntry, rightEntry));
        }
Esempio n. 14
0
            public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement?content)
            {
                if (entry.TryGetValue(UnusedReferencesTableKeyNames.ProjectName, out string name))
                {
                    content = CreateGridElement(GetImageMoniker(entry), name, isBold: false);
                    return(true);
                }

                content = null;
                return(false);
            }
        public override bool TryCreateStringContent(ITableEntryHandle entry, bool truncatedText, bool singleColumnView, out string content)
        {
            if (entry.TryGetValue(TableKeyNames.Time, out var value) && value != null && value is DateTime time)
            {
                content = time.ToString("s");
                return(true);
            }

            content = null;
            return(false);
        }
Esempio n. 16
0
        public override bool TryCreateStringContent(ITableEntryHandle entry, bool truncatedText, bool singleColumnView, out string content)
        {
            if (entry.TryGetValue(TableKeyNames.ProjectType, out var value) && value != null && value is string projectType)
            {
                content = projectType;
                return(true);
            }

            content = null;
            return(false);
        }
 private static ImageMoniker GetImageMoniker(ITableEntryHandle entry)
 {
     return
         (entry.TryGetValue(
              UnusedReferencesTableKeyNames.Language,
              out string languageName
              ) &&
          languageName == LanguageNames.VisualBasic
       ? KnownMonikers.VBProjectNode
       : KnownMonikers.CSProjectNode);
 }
Esempio n. 18
0
        public override bool TryCreateStringContent(ITableEntryHandle entry, bool truncatedText, bool singleColumnView, out string content)
        {
            if (entry.TryGetValue(TableKeyNames.Status, out var value) && value is BuildStatus status)
            {
                content = status.ToString();
                return(true);
            }

            content = null;
            return(false);
        }
Esempio n. 19
0
            public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement?content)
            {
                if (entry.TryGetValue <ReferenceType>(UnusedReferencesTableKeyNames.ReferenceType, out var referenceType))
                {
                    content = CreateGridElement(GetImageMoniker(referenceType), GetText(referenceType), isBold: false);
                    return(true);
                }

                content = null;
                return(false);
            }
Esempio n. 20
0
            public bool Match(ITableEntryHandle entry)
            {
                if (!entry.TryGetValue(StandardTableKeyNames.ItemOrigin, out ItemOrigin origin))
                {
                    origin = ItemOrigin.Exact;
                }

                return(_includeExact && origin == ItemOrigin.Exact ||
                       _includeExactMetadata && origin == ItemOrigin.ExactMetadata ||
                       _includeOther && origin == ItemOrigin.Other);
            }
Esempio n. 21
0
        public override bool TryCreateToolTip(ITableEntryHandle entry, out object toolTip)
        {
            if (entry.TryGetValue(TableKeyNames.Targets, out var value) &&
                value is IEnumerable <string> targets)
            {
                toolTip = string.Join(Environment.NewLine, targets);
                return(true);
            }

            return(base.TryCreateToolTip(entry, out toolTip));
        }
Esempio n. 22
0
        public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement content)
        {
            var checkBox = new CheckBox();

            if (entry.TryGetValue(Name, out bool enabled))
            {
                checkBox.IsChecked = enabled;
            }

            content = checkBox;
            return(true);
        }
        public override bool TryCreateToolTip(ITableEntryHandle entry, out object toolTip)
        {
            if (entry.TryGetValue(ColumnName, out var content) &&
                content as string == ServicesVSResources.NotApplicable)
            {
                toolTip = ServicesVSResources.SuppressionNotSupportedToolTip;
                return(true);
            }

            toolTip = null;
            return(false);
        }
Esempio n. 24
0
        public override bool TryCreateStringContent(ITableEntryHandle entry, bool truncatedText, bool singleColumnView, out string content)
        {
            if (entry.TryGetValue(TableKeyNames.Targets, out var value) &&
                value is IEnumerable <string> targets)
            {
                content = string.Join(";", targets);
                return(true);
            }

            content = null;
            return(false);
        }
 public override IEntryBucket?CreateBucketForEntry(ITableEntryHandle entry)
 {
     return(entry.TryGetValue <ReferenceType>(
                UnusedReferencesTableKeyNames.ReferenceType,
                out var referenceType
                )
       ? new ImageEntryBucket(
                GetReferenceTypeImageMoniker(referenceType),
                GetText(referenceType)
                )
       : null);
 }
Esempio n. 26
0
        public void OpenLog(ITableEntryHandle tableEntry)
        {
            if (!tableEntry.TryGetValue(TableKeyNames.LogPath, out string logPath))
            {
                return;
            }

            var guid = VSConstants.LOGVIEWID_Primary;

            _openDocument.OpenDocumentViaProject(logPath, ref guid, out _, out _, out _, out var frame);
            frame?.Show();
        }
        public override bool TryCreateToolTip(ITableEntryHandle entry, out object toolTip)
        {
            if (entry.TryGetValue(ColumnName, out var content) &&
                content as string == ServicesVSResources.NotApplicable)
            {
                toolTip = ServicesVSResources.SuppressionNotSupportedToolTip;
                return true;
            }

            toolTip = null;
            return false;
        }
        private static bool IsNonRoslynEntrySupportingSuppressionState(ITableEntryHandle entryHandle, out bool isSuppressedEntry)
        {
            string suppressionStateValue;

            if (entryHandle.TryGetValue(SuppressionStateColumnDefinition.ColumnName, out suppressionStateValue))
            {
                isSuppressedEntry = suppressionStateValue == ServicesVSResources.SuppressionStateSuppressed;
                return(true);
            }

            isSuppressedEntry = false;
            return(false);
        }
        public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement?content)
        {
            if (!entry.TryGetValue(Severity, out AnalyzerSetting severity))
            {
                content = null;
                return(false);
            }

            var control = new SeverityControl(severity);

            content = control;
            return(true);
        }
        public override bool TryCreateStringContent(ITableEntryHandle entry, bool truncatedText, bool singleColumnView, out string content)
        {
            if (entry.TryGetValue(TableKeyNames.Dimensions, out var value) && value != null &&
                value is IEnumerable <string> dimensions &&
                dimensions.Any())
            {
                content = dimensions.Aggregate((current, next) => $"{current}|{next}");
                return(true);
            }

            content = null;
            return(false);
        }
        public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement?content)
        {
            if (!entry.TryGetValue(Severity, out NamingStyleSetting setting))
            {
                content = null;
                return(false);
            }

            var viewModel = new NamingStylesSeverityViewModel(setting);
            var control   = new NamingStylesSeverityControl(viewModel);

            content = control;
            return(true);
        }
        private static bool IsNonRoslynEntrySupportingSuppressionState(ITableEntryHandle entryHandle, out bool isSuppressedEntry)
        {
            string suppressionStateValue;
            if (entryHandle.TryGetValue(SuppressionStateColumnDefinition.ColumnName, out suppressionStateValue))
            {
                isSuppressedEntry = suppressionStateValue == ServicesVSResources.SuppressionStateSuppressed;
                return true;
            }

            isSuppressedEntry = false;
            return false;
        }
        private static bool EntrySupportsSuppressionState(ITableEntryHandle entryHandle, out bool isRoslynEntry, out bool isSuppressedEntry, out bool isCompilerDiagnosticEntry, out bool isNoLocationDiagnosticEntry)
        {
            string filePath;
            isNoLocationDiagnosticEntry = !entryHandle.TryGetValue(StandardTableColumnDefinitions.DocumentName, out filePath) ||
                string.IsNullOrEmpty(filePath);

            int index;
            var roslynSnapshot = GetEntriesSnapshot(entryHandle, out index);
            if (roslynSnapshot == null)
            {
                isRoslynEntry = false;
                isCompilerDiagnosticEntry = false;
                return IsNonRoslynEntrySupportingSuppressionState(entryHandle, out isSuppressedEntry);
            }

            var diagnosticData = roslynSnapshot?.GetItem(index)?.Primary;
            if (!IsEntryWithConfigurableSuppressionState(diagnosticData))
            {
                isRoslynEntry = false;
                isSuppressedEntry = false;
                isCompilerDiagnosticEntry = false;
                return false;
            }

            isRoslynEntry = true;
            isSuppressedEntry = diagnosticData.IsSuppressed;
            isCompilerDiagnosticEntry = SuppressionHelpers.IsCompilerDiagnostic(diagnosticData);
            return true;
        }