diff --git a/src/Analyzers/Activities/FunctionNotFoundAnalyzer.cs b/src/Analyzers/Activities/FunctionNotFoundAnalyzer.cs index b1222d4b..1bf920a4 100644 --- a/src/Analyzers/Activities/FunctionNotFoundAnalyzer.cs +++ b/src/Analyzers/Activities/FunctionNotFoundAnalyzer.cs @@ -39,7 +39,8 @@ public sealed class FunctionNotFoundAnalyzer : DiagnosticAnalyzer AnalyzersCategories.Activity, DiagnosticSeverity.Warning, customTags: [WellKnownDiagnosticTags.CompilationEnd], - isEnabledByDefault: true); + isEnabledByDefault: true, + helpLinkUri: "https://go.microsoft.com/fwlink/?linkid=2346202"); static readonly DiagnosticDescriptor SubOrchestrationNotFoundRule = new( SubOrchestrationNotFoundDiagnosticId, @@ -48,7 +49,8 @@ public sealed class FunctionNotFoundAnalyzer : DiagnosticAnalyzer AnalyzersCategories.Orchestration, DiagnosticSeverity.Warning, customTags: [WellKnownDiagnosticTags.CompilationEnd], - isEnabledByDefault: true); + isEnabledByDefault: true, + helpLinkUri: "https://go.microsoft.com/fwlink/?linkid=2346202"); /// public override ImmutableArray SupportedDiagnostics => [ActivityNotFoundRule, SubOrchestrationNotFoundRule]; diff --git a/src/Analyzers/Activities/MatchingInputOutputTypeActivityAnalyzer.cs b/src/Analyzers/Activities/MatchingInputOutputTypeActivityAnalyzer.cs index ebdaac79..63da59e7 100644 --- a/src/Analyzers/Activities/MatchingInputOutputTypeActivityAnalyzer.cs +++ b/src/Analyzers/Activities/MatchingInputOutputTypeActivityAnalyzer.cs @@ -40,7 +40,8 @@ public class MatchingInputOutputTypeActivityAnalyzer : DiagnosticAnalyzer AnalyzersCategories.Activity, DiagnosticSeverity.Warning, customTags: [WellKnownDiagnosticTags.CompilationEnd], - isEnabledByDefault: true); + isEnabledByDefault: true, + helpLinkUri: "https://go.microsoft.com/fwlink/?linkid=2346202"); static readonly DiagnosticDescriptor OutputArgumentTypeMismatchRule = new( OutputArgumentTypeMismatchDiagnosticId, @@ -49,7 +50,8 @@ public class MatchingInputOutputTypeActivityAnalyzer : DiagnosticAnalyzer AnalyzersCategories.Activity, DiagnosticSeverity.Warning, customTags: [WellKnownDiagnosticTags.CompilationEnd], - isEnabledByDefault: true); + isEnabledByDefault: true, + helpLinkUri: "https://go.microsoft.com/fwlink/?linkid=2346202"); /// public override ImmutableArray SupportedDiagnostics => [InputArgumentTypeMismatchRule, OutputArgumentTypeMismatchRule]; diff --git a/src/Analyzers/Functions/AttributeBinding/DurableClientBindingAnalyzer.cs b/src/Analyzers/Functions/AttributeBinding/DurableClientBindingAnalyzer.cs index 8089043e..27d96c58 100644 --- a/src/Analyzers/Functions/AttributeBinding/DurableClientBindingAnalyzer.cs +++ b/src/Analyzers/Functions/AttributeBinding/DurableClientBindingAnalyzer.cs @@ -27,7 +27,8 @@ public sealed class DurableClientBindingAnalyzer : MatchingAttributeBindingAnaly MessageFormat, AnalyzersCategories.AttributeBinding, DiagnosticSeverity.Error, - isEnabledByDefault: true); + isEnabledByDefault: true, + helpLinkUri: "https://go.microsoft.com/fwlink/?linkid=2346202"); /// public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Functions/AttributeBinding/EntityTriggerBindingAnalyzer.cs b/src/Analyzers/Functions/AttributeBinding/EntityTriggerBindingAnalyzer.cs index 8667cb32..59513a82 100644 --- a/src/Analyzers/Functions/AttributeBinding/EntityTriggerBindingAnalyzer.cs +++ b/src/Analyzers/Functions/AttributeBinding/EntityTriggerBindingAnalyzer.cs @@ -27,7 +27,8 @@ public sealed class EntityTriggerBindingAnalyzer : MatchingAttributeBindingAnaly MessageFormat, AnalyzersCategories.AttributeBinding, DiagnosticSeverity.Error, - isEnabledByDefault: true); + isEnabledByDefault: true, + helpLinkUri: "https://go.microsoft.com/fwlink/?linkid=2346202"); /// public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Functions/AttributeBinding/OrchestrationTriggerBindingAnalyzer.cs b/src/Analyzers/Functions/AttributeBinding/OrchestrationTriggerBindingAnalyzer.cs index d6642043..603a92f6 100644 --- a/src/Analyzers/Functions/AttributeBinding/OrchestrationTriggerBindingAnalyzer.cs +++ b/src/Analyzers/Functions/AttributeBinding/OrchestrationTriggerBindingAnalyzer.cs @@ -27,7 +27,8 @@ public sealed class OrchestrationTriggerBindingAnalyzer : MatchingAttributeBindi MessageFormat, AnalyzersCategories.AttributeBinding, DiagnosticSeverity.Error, - isEnabledByDefault: true); + isEnabledByDefault: true, + helpLinkUri: "https://go.microsoft.com/fwlink/?linkid=2346202"); /// public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Functions/Orchestration/CancellationTokenOrchestrationAnalyzer.cs b/src/Analyzers/Functions/Orchestration/CancellationTokenOrchestrationAnalyzer.cs index 738f4f7d..503a3005 100644 --- a/src/Analyzers/Functions/Orchestration/CancellationTokenOrchestrationAnalyzer.cs +++ b/src/Analyzers/Functions/Orchestration/CancellationTokenOrchestrationAnalyzer.cs @@ -30,7 +30,8 @@ public class CancellationTokenOrchestrationAnalyzer : OrchestrationAnalyzer public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Functions/Orchestration/OtherBindingsOrchestrationAnalyzer.cs b/src/Analyzers/Functions/Orchestration/OtherBindingsOrchestrationAnalyzer.cs index 6cea911d..9e512af6 100644 --- a/src/Analyzers/Functions/Orchestration/OtherBindingsOrchestrationAnalyzer.cs +++ b/src/Analyzers/Functions/Orchestration/OtherBindingsOrchestrationAnalyzer.cs @@ -30,7 +30,8 @@ class OtherBindingsOrchestrationAnalyzer : OrchestrationAnalyzer public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Orchestration/DateTimeOrchestrationAnalyzer.cs b/src/Analyzers/Orchestration/DateTimeOrchestrationAnalyzer.cs index d6555481..ccfc81ed 100644 --- a/src/Analyzers/Orchestration/DateTimeOrchestrationAnalyzer.cs +++ b/src/Analyzers/Orchestration/DateTimeOrchestrationAnalyzer.cs @@ -29,7 +29,8 @@ public sealed class DateTimeOrchestrationAnalyzer : OrchestrationAnalyzer public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Orchestration/DelayOrchestrationAnalyzer.cs b/src/Analyzers/Orchestration/DelayOrchestrationAnalyzer.cs index 5fcef63a..5674db58 100644 --- a/src/Analyzers/Orchestration/DelayOrchestrationAnalyzer.cs +++ b/src/Analyzers/Orchestration/DelayOrchestrationAnalyzer.cs @@ -29,7 +29,8 @@ public class DelayOrchestrationAnalyzer : OrchestrationAnalyzer public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Orchestration/EnvironmentOrchestrationAnalyzer.cs b/src/Analyzers/Orchestration/EnvironmentOrchestrationAnalyzer.cs index 3e4fb773..c64ea76b 100644 --- a/src/Analyzers/Orchestration/EnvironmentOrchestrationAnalyzer.cs +++ b/src/Analyzers/Orchestration/EnvironmentOrchestrationAnalyzer.cs @@ -31,7 +31,8 @@ public sealed class EnvironmentOrchestrationAnalyzer : OrchestrationAnalyzer public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Orchestration/GuidOrchestrationAnalyzer.cs b/src/Analyzers/Orchestration/GuidOrchestrationAnalyzer.cs index 2b0c4c71..2ba936bf 100644 --- a/src/Analyzers/Orchestration/GuidOrchestrationAnalyzer.cs +++ b/src/Analyzers/Orchestration/GuidOrchestrationAnalyzer.cs @@ -29,7 +29,8 @@ public sealed class GuidOrchestrationAnalyzer : OrchestrationAnalyzer public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Orchestration/IOOrchestrationAnalyzer.cs b/src/Analyzers/Orchestration/IOOrchestrationAnalyzer.cs index 6051ccc5..1f0c1e34 100644 --- a/src/Analyzers/Orchestration/IOOrchestrationAnalyzer.cs +++ b/src/Analyzers/Orchestration/IOOrchestrationAnalyzer.cs @@ -30,7 +30,8 @@ public sealed class IOOrchestrationAnalyzer : OrchestrationAnalyzer public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/src/Analyzers/Orchestration/ThreadTaskOrchestrationAnalyzer.cs b/src/Analyzers/Orchestration/ThreadTaskOrchestrationAnalyzer.cs index 8d640ed1..4fbed41b 100644 --- a/src/Analyzers/Orchestration/ThreadTaskOrchestrationAnalyzer.cs +++ b/src/Analyzers/Orchestration/ThreadTaskOrchestrationAnalyzer.cs @@ -29,7 +29,8 @@ public sealed class ThreadTaskOrchestrationAnalyzer : OrchestrationAnalyzer public override ImmutableArray SupportedDiagnostics => [Rule]; diff --git a/test/Analyzers.Tests/DiagnosticDescriptorTests.cs b/test/Analyzers.Tests/DiagnosticDescriptorTests.cs new file mode 100644 index 00000000..0ef564ac --- /dev/null +++ b/test/Analyzers.Tests/DiagnosticDescriptorTests.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System.Collections.Immutable; +using System.Reflection; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.DurableTask.Analyzers.Activities; +using Microsoft.DurableTask.Analyzers.Functions.AttributeBinding; +using Microsoft.DurableTask.Analyzers.Functions.Orchestration; +using Microsoft.DurableTask.Analyzers.Orchestration; + +namespace Microsoft.DurableTask.Analyzers.Tests; + +/// +/// Tests to validate diagnostic descriptor properties. +/// +public class DiagnosticDescriptorTests +{ + [Theory] + [InlineData(typeof(DateTimeOrchestrationAnalyzer))] + [InlineData(typeof(GuidOrchestrationAnalyzer))] + [InlineData(typeof(DelayOrchestrationAnalyzer))] + [InlineData(typeof(ThreadTaskOrchestrationAnalyzer))] + [InlineData(typeof(IOOrchestrationAnalyzer))] + [InlineData(typeof(EnvironmentOrchestrationAnalyzer))] + [InlineData(typeof(CancellationTokenOrchestrationAnalyzer))] + [InlineData(typeof(OtherBindingsOrchestrationAnalyzer))] + [InlineData(typeof(OrchestrationTriggerBindingAnalyzer))] + [InlineData(typeof(DurableClientBindingAnalyzer))] + [InlineData(typeof(EntityTriggerBindingAnalyzer))] + [InlineData(typeof(MatchingInputOutputTypeActivityAnalyzer))] + [InlineData(typeof(FunctionNotFoundAnalyzer))] + public void AllDiagnosticDescriptorsHaveHelpLinkUri(Type analyzerType) + { + // Arrange + DiagnosticAnalyzer? analyzer = Activator.CreateInstance(analyzerType) as DiagnosticAnalyzer; + Assert.NotNull(analyzer); + + ImmutableArray diagnostics = analyzer!.SupportedDiagnostics; + Assert.NotEmpty(diagnostics); + + // Act & Assert + foreach (Microsoft.CodeAnalysis.DiagnosticDescriptor diagnostic in diagnostics) + { + Assert.NotNull(diagnostic.HelpLinkUri); + Assert.NotEmpty(diagnostic.HelpLinkUri); + Assert.Equal("https://go.microsoft.com/fwlink/?linkid=2346202", diagnostic.HelpLinkUri); + } + } +}