public static DiagnosticData Create(Document document, Diagnostic diagnostic) { var location = CreateLocation(document, diagnostic.Location); var additionalLocations = diagnostic.AdditionalLocations.Count == 0 ? (IReadOnlyCollection <DiagnosticDataLocation>)SpecializedCollections.EmptyArray <DiagnosticDataLocation>() : diagnostic.AdditionalLocations.Where(loc => loc.IsInSource) .Select(loc => CreateLocation(document.Project.GetDocument(loc.SourceTree), loc)) .WhereNotNull() .ToReadOnlyCollection(); return(new DiagnosticData( diagnostic.Id, diagnostic.Descriptor.Category, diagnostic.GetMessage(CultureInfo.CurrentUICulture), diagnostic.GetBingHelpMessage(), diagnostic.Severity, diagnostic.DefaultSeverity, diagnostic.Descriptor.IsEnabledByDefault, diagnostic.WarningLevel, diagnostic.Descriptor.CustomTags.AsImmutableOrEmpty(), diagnostic.Properties, document.Project.Solution.Workspace, document.Project.Id, location, additionalLocations, title: diagnostic.Descriptor.Title.ToString(CultureInfo.CurrentUICulture), description: diagnostic.Descriptor.Description.ToString(CultureInfo.CurrentUICulture), helpLink: diagnostic.Descriptor.HelpLinkUri, isSuppressed: diagnostic.IsSuppressed)); }
private static Uri GetHelpLink(Diagnostic diagnostic, string language, string projectType, out string helpLinkToolTipText) { var isBing = false; helpLinkToolTipText = string.Empty; Uri helpLink; if (!BrowserHelper.TryGetUri(diagnostic.Descriptor.HelpLinkUri, out helpLink)) { // We use the ENU version of the message for bing search. helpLink = BrowserHelper.CreateBingQueryUri(diagnostic.Id, diagnostic.GetBingHelpMessage(), language, projectType); isBing = true; } // We make sure not to use Uri.AbsoluteUri for the url displayed in the tooltip so that the url displayed in the tooltip stays human readable. if (helpLink != null) { helpLinkToolTipText = string.Format(ServicesVSResources.DiagnosticIdHyperlinkTooltipText, diagnostic.Id, isBing ? ServicesVSResources.FromBing : null, Environment.NewLine, helpLink); } return(helpLink); }
public static DiagnosticData Create(Project project, Diagnostic diagnostic) { Contract.Requires(diagnostic.Location == null || !diagnostic.Location.IsInSource); return(new DiagnosticData( diagnostic.Id, diagnostic.Descriptor.Category, diagnostic.GetMessage(CultureInfo.CurrentUICulture), diagnostic.GetBingHelpMessage(), diagnostic.Severity, diagnostic.DefaultSeverity, diagnostic.Descriptor.IsEnabledByDefault, diagnostic.WarningLevel, diagnostic.Descriptor.CustomTags.AsImmutableOrEmpty(), diagnostic.Properties, project.Solution.Workspace, project.Id, title: diagnostic.Descriptor.Title.ToString(CultureInfo.CurrentUICulture), description: diagnostic.Descriptor.Description.ToString(CultureInfo.CurrentUICulture), helpLink: diagnostic.Descriptor.HelpLinkUri, isSuppressed: diagnostic.IsSuppressed)); }
private static Uri GetHelpLink(Diagnostic diagnostic, string language, string projectType, out string helpLinkToolTipText) { var isBing = false; helpLinkToolTipText = string.Empty; Uri helpLink; if (!BrowserHelper.TryGetUri(diagnostic.Descriptor.HelpLinkUri, out helpLink)) { // We use the ENU version of the message for bing search. helpLink = BrowserHelper.CreateBingQueryUri(diagnostic.Id, diagnostic.GetBingHelpMessage(), language, projectType); isBing = true; } // We make sure not to use Uri.AbsoluteUri for the url displayed in the tooltip so that the url displayed in the tooltip stays human readable. if (helpLink != null) { helpLinkToolTipText = string.Format(ServicesVSResources.DiagnosticIdHyperlinkTooltipText, diagnostic.Id, isBing ? ServicesVSResources.FromBing : null, Environment.NewLine, helpLink); } return helpLink; }
public static DiagnosticData Create(Document document, Diagnostic diagnostic) { var location = CreateLocation(document, diagnostic.Location); var additionalLocations = diagnostic.AdditionalLocations.Count == 0 ? (IReadOnlyCollection<DiagnosticDataLocation>)SpecializedCollections.EmptyArray<DiagnosticDataLocation>() : diagnostic.AdditionalLocations.Where(loc => loc.IsInSource) .Select(loc => CreateLocation(document.Project.GetDocument(loc.SourceTree), loc)) .WhereNotNull() .ToReadOnlyCollection(); return new DiagnosticData( diagnostic.Id, diagnostic.Descriptor.Category, diagnostic.GetMessage(CultureInfo.CurrentUICulture), diagnostic.GetBingHelpMessage(), diagnostic.Severity, diagnostic.DefaultSeverity, diagnostic.Descriptor.IsEnabledByDefault, diagnostic.WarningLevel, diagnostic.Descriptor.CustomTags.AsImmutableOrEmpty(), diagnostic.Properties, document.Project.Solution.Workspace, document.Project.Id, location, additionalLocations, title: diagnostic.Descriptor.Title.ToString(CultureInfo.CurrentUICulture), description: diagnostic.Descriptor.Description.ToString(CultureInfo.CurrentUICulture), helpLink: diagnostic.Descriptor.HelpLinkUri, isSuppressed: diagnostic.IsSuppressed); }
public static DiagnosticData Create(Project project, Diagnostic diagnostic) { Contract.Requires(diagnostic.Location == null || !diagnostic.Location.IsInSource); return new DiagnosticData( diagnostic.Id, diagnostic.Descriptor.Category, diagnostic.GetMessage(CultureInfo.CurrentUICulture), diagnostic.GetBingHelpMessage(), diagnostic.Severity, diagnostic.DefaultSeverity, diagnostic.Descriptor.IsEnabledByDefault, diagnostic.WarningLevel, diagnostic.Descriptor.CustomTags.AsImmutableOrEmpty(), diagnostic.Properties, project.Solution.Workspace, project.Id, title: diagnostic.Descriptor.Title.ToString(CultureInfo.CurrentUICulture), description: diagnostic.Descriptor.Description.ToString(CultureInfo.CurrentUICulture), helpLink: diagnostic.Descriptor.HelpLinkUri, isSuppressed: diagnostic.IsSuppressed); }