Пример #1
0
        private void ErrorListInlineLink_Click(object sender, RoutedEventArgs e)
        {
            Hyperlink hyperLink = sender as Hyperlink;

            if (hyperLink != null)
            {
                Tuple <int, int> data = hyperLink.Tag as Tuple <int, int>;
                // data.Item1 = index of SarifErrorListItem
                // data.Item2 = id of related location to link

                SarifErrorListItem sarifResult = _errors[Convert.ToInt32(data.Item1)];

                CodeFlowLocationModel location = sarifResult.RelatedLocations.Where(l => l.Id == data.Item2).FirstOrDefault();

                if (location != null)
                {
                    // Set the current sarif error in the manager so we track code locations.
                    CodeAnalysisResultManager.Instance.CurrentSarifResult = sarifResult;

                    SarifViewerPackage.SarifToolWindow.Control.DataContext = null;

                    if (sarifResult.HasDetails)
                    {
                        // Setting the DataContext to null (above) forces the TabControl to select the appropriate tab.
                        SarifViewerPackage.SarifToolWindow.Control.DataContext = sarifResult;
                    }

                    location.NavigateTo(false);
                    location.ApplyDefaultSourceFileHighlighting();
                }
            }
        }
Пример #2
0
        public static CodeFlowLocationModel ToCodeFlowLocationModel(this Location location)
        {
            var model = new CodeFlowLocationModel();
            PhysicalLocation physicalLocation = location.PhysicalLocation;

            if (physicalLocation?.FileLocation != null)
            {
                model.Id     = physicalLocation.Id;
                model.Region = physicalLocation.Region;

                Uri uri = physicalLocation.FileLocation.Uri;

                if (uri != null)
                {
                    model.FilePath  = uri.ToPath();
                    model.UriBaseId = physicalLocation.FileLocation.UriBaseId;
                }
            }

            model.Message         = location.Message?.Text;
            model.LogicalLocation = location.FullyQualifiedLogicalName;

            return(model);
        }