Skip to content

Commit 3a12a97

Browse files
committed
Help link (from VS Error List to issue description web page).
1 parent 36964a1 commit 3a12a97

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
using Codartis.NsDepCop.Core.Analyzer.Roslyn;
1+
using System.Globalization;
2+
using Codartis.NsDepCop.Core.Analyzer.Roslyn;
23
using Codartis.NsDepCop.Core.Common;
34
using Microsoft.CodeAnalysis;
45

56
namespace Codartis.NsDepCop.VisualStudioIntegration
67
{
78
public static class IssueDescriptorExtensions
89
{
10+
/// <summary>
11+
/// Format string to create a help link for diagnostics. The parameter is the diagnostic's code in full UPPERCASE.
12+
/// </summary>
13+
private const string HELP_LINK_FORMAT = @"https://nsdepcop.codeplex.com/wikipage?title=Diagnostics#{0}";
14+
915
public static DiagnosticDescriptor ToDiagnosticDescriptor(this IssueDescriptor issueDescriptor)
1016
{
1117
return new DiagnosticDescriptor(
@@ -14,7 +20,13 @@ public static DiagnosticDescriptor ToDiagnosticDescriptor(this IssueDescriptor i
1420
issueDescriptor.MessageFormat,
1521
Constants.TOOL_NAME,
1622
issueDescriptor.DefaultKind.ToDiagnosticSeverity(),
17-
true);
23+
true,
24+
helpLinkUri: GetHelpLink(issueDescriptor.Id));
25+
}
26+
27+
private static string GetHelpLink(string issueDescriptorId)
28+
{
29+
return string.Format(HELP_LINK_FORMAT, issueDescriptorId.ToUpper(CultureInfo.InvariantCulture));
1830
}
1931
}
2032
}

source/NsDepCop.VisualStudioIntegration/NsDepCopDiagnosticAnalyzer.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ public class NsDepCopDiagnosticAnalyzer : DiagnosticAnalyzer
2222
/// <summary>
2323
/// Descriptor for the 'Illegal namespace dependency' diagnostic.
2424
/// </summary>
25-
private static readonly DiagnosticDescriptor _illegalDependencyDescriptor = Constants.IllegalDependencyIssue.ToDiagnosticDescriptor();
25+
private static readonly DiagnosticDescriptor _illegalDependencyDescriptor =
26+
Constants.IllegalDependencyIssue.ToDiagnosticDescriptor();
2627

2728
/// <summary>
2829
/// Descriptor for the 'Config exception' diagnostic.
2930
/// </summary>
30-
private static readonly DiagnosticDescriptor _configExceptionDescriptor = Constants.ConfigExceptionIssue.ToDiagnosticDescriptor();
31+
private static readonly DiagnosticDescriptor _configExceptionDescriptor =
32+
Constants.ConfigExceptionIssue.ToDiagnosticDescriptor();
3133

3234
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
3335
{
@@ -113,7 +115,9 @@ private Diagnostic CreateIllegalDependencyDiagnostic(SyntaxNode node, Dependency
113115
defaultSeverity: _illegalDependencyDescriptor.DefaultSeverity,
114116
isEnabledByDefault: true,
115117
warningLevel: warningLevel,
116-
location: Location.Create(node.SyntaxTree, node.Span));
118+
location: Location.Create(node.SyntaxTree, node.Span),
119+
helpLink: _illegalDependencyDescriptor.HelpLinkUri,
120+
title: _illegalDependencyDescriptor.Title);
117121
}
118122

119123
private void ReportConfigException(SyntaxNodeAnalysisContext context, Exception exception)

0 commit comments

Comments
 (0)