Skip to content

Commit be5dbfa

Browse files
committed
Update naming for diagnostics codes and add last Send/Reply diagnostic
1 parent 8929455 commit be5dbfa

3 files changed

Lines changed: 52 additions & 15 deletions

File tree

src/NServiceBus.AzureFunctions.Analyzer.Tests/AzureFunctionsConfigurationAnalyzerTests.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,13 @@ public Task DiagnosticIsReportedForRouteReplyToThisInstance()
163163
using System.Threading.Tasks;
164164
class Foo
165165
{{
166-
void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
166+
void Bar()
167167
{{
168168
var replyOptions = new ReplyOptions();
169169
[|replyOptions.RouteReplyToThisInstance()|];
170+
171+
var sendOptions = new SendOptions();
172+
[|sendOptions.RouteReplyToThisInstance()|];
170173
}}
171174
}}";
172175

@@ -182,7 +185,7 @@ public Task DiagnosticIsReportedForRouteToThisInstance()
182185
using System.Threading.Tasks;
183186
class Foo
184187
{{
185-
void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
188+
void Bar()
186189
{{
187190
var options = new SendOptions();
188191
[|options.RouteToThisInstance()|];
@@ -191,5 +194,27 @@ void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
191194

192195
return Assert(AzureFunctionsDiagnostics.RouteToThisInstanceNotAllowedId, source);
193196
}
197+
198+
[Test]
199+
public Task DiagnosticIsReportedForRouteReplyToAnyInstance()
200+
{
201+
var source =
202+
$@"using NServiceBus;
203+
using System;
204+
using System.Threading.Tasks;
205+
class Foo
206+
{{
207+
void Bar()
208+
{{
209+
var options = new SendOptions();
210+
[|options.RouteReplyToAnyInstance()|];
211+
212+
var replyOptions = new ReplyOptions();
213+
[|replyOptions.RouteReplyToAnyInstance()|];
214+
}}
215+
}}";
216+
217+
return Assert(AzureFunctionsDiagnostics.RouteReplyToAnyInstanceNotAllowedId, source);
218+
}
194219
}
195220
}

src/NServiceBus.AzureFunctions.Analyzer/AzureFunctionsConfigurationAnalyzer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public class AzureFunctionsConfigurationAnalyzer : DiagnosticAnalyzer
2020
AzureFunctionsDiagnostics.UseTransportNotAllowed,
2121
AzureFunctionsDiagnostics.OverrideLocalAddressNotAllowed,
2222
AzureFunctionsDiagnostics.RouteReplyToThisInstanceNotAllowed,
23-
AzureFunctionsDiagnostics.RouteToThisInstanceNotAllowed
23+
AzureFunctionsDiagnostics.RouteToThisInstanceNotAllowed,
24+
AzureFunctionsDiagnostics.RouteReplyToAnyInstanceNotAllowed
2425
);
2526

2627
static readonly Dictionary<string, DiagnosticDescriptor> NotAllowedEndpointConfigurationMethods
@@ -39,7 +40,8 @@ static readonly Dictionary<string, DiagnosticDescriptor> NotAllowedSendAndReplyO
3940
= new Dictionary<string, DiagnosticDescriptor>
4041
{
4142
["RouteReplyToThisInstance"] = AzureFunctionsDiagnostics.RouteReplyToThisInstanceNotAllowed,
42-
["RouteToThisInstance"] = AzureFunctionsDiagnostics.RouteToThisInstanceNotAllowed
43+
["RouteToThisInstance"] = AzureFunctionsDiagnostics.RouteToThisInstanceNotAllowed,
44+
["RouteReplyToAnyInstance"] = AzureFunctionsDiagnostics.RouteReplyToAnyInstanceNotAllowed
4345
};
4446

4547
public override void Initialize(AnalysisContext context)

src/NServiceBus.AzureFunctions.Analyzer/AzureFunctionsDiagnostics.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
public static class AzureFunctionsDiagnostics
66
{
7-
public const string PurgeOnStartupNotAllowedId = "NSBAF0001";
8-
public const string LimitMessageProcessingToNotAllowedId = "NSBAF0002";
9-
public const string DefineCriticalErrorActionNotAllowedId = "NSBAF0003";
10-
public const string SetDiagnosticsPathNotAllowedId = "NSBAF0004";
11-
public const string MakeInstanceUniquelyAddressableNotAllowedId = "NSBAF0005";
12-
public const string UseTransportNotAllowedId = "NSBAF0006";
13-
public const string OverrideLocalAddressNotAllowedId = "NSBAF0007";
14-
public const string RouteReplyToThisInstanceNotAllowedId = "NSBAF0008";
15-
public const string RouteToThisInstanceNotAllowedId = "NSBAF0009";
7+
public const string PurgeOnStartupNotAllowedId = "NSBFUNC003";
8+
public const string LimitMessageProcessingToNotAllowedId = "NSBFUNC004";
9+
public const string DefineCriticalErrorActionNotAllowedId = "NSBFUNC005";
10+
public const string SetDiagnosticsPathNotAllowedId = "NSBFUNC006";
11+
public const string MakeInstanceUniquelyAddressableNotAllowedId = "NSBFUNC007";
12+
public const string UseTransportNotAllowedId = "NSBFUNC008";
13+
public const string OverrideLocalAddressNotAllowedId = "NSBFUNC009";
14+
public const string RouteReplyToThisInstanceNotAllowedId = "NSBFUNC010";
15+
public const string RouteToThisInstanceNotAllowedId = "NSBFUNC011";
16+
public const string RouteReplyToAnyInstanceNotAllowedId = "NSBFUNC012";
1617

1718
const string DiagnosticCategory = "NServiceBus.AzureFunctions";
1819

@@ -82,7 +83,7 @@ public static class AzureFunctionsDiagnostics
8283
internal static readonly DiagnosticDescriptor RouteReplyToThisInstanceNotAllowed = new DiagnosticDescriptor(
8384
id: RouteReplyToThisInstanceNotAllowedId,
8485
title: "RouteReplyToThisInstance is not supported in Azure Functions",
85-
messageFormat: "Azure Functions endpoints do not control the message receiver and cannot configure receiver routing.",
86+
messageFormat: "Azure Functions endpoints do not control the message receiver and cannot configure specific instance routing.",
8687
category: DiagnosticCategory,
8788
defaultSeverity: DiagnosticSeverity.Error,
8889
isEnabledByDefault: true
@@ -91,10 +92,19 @@ public static class AzureFunctionsDiagnostics
9192
internal static readonly DiagnosticDescriptor RouteToThisInstanceNotAllowed = new DiagnosticDescriptor(
9293
id: RouteToThisInstanceNotAllowedId,
9394
title: "RouteToThisInstance is not supported in Azure Functions",
94-
messageFormat: "Azure Functions endpoints do not control the message receiver and cannot configure receiver routing.",
95+
messageFormat: "Azure Functions endpoints do not control the message receiver and cannot configure specific instance routing.",
9596
category: DiagnosticCategory,
9697
defaultSeverity: DiagnosticSeverity.Error,
9798
isEnabledByDefault: true
9899
);
100+
101+
internal static readonly DiagnosticDescriptor RouteReplyToAnyInstanceNotAllowed = new DiagnosticDescriptor(
102+
id: RouteReplyToAnyInstanceNotAllowedId,
103+
title: "RouteReplyToAnyInstance is not supported in Azure Functions",
104+
messageFormat: "Azure Functions endpoints do not control the message receiver and by default route the replies to any instance.",
105+
category: DiagnosticCategory,
106+
defaultSeverity: DiagnosticSeverity.Warning,
107+
isEnabledByDefault: true
108+
);
99109
}
100110
}

0 commit comments

Comments
 (0)