Skip to content

Commit 1893a93

Browse files
committed
More cleanup
1 parent 3bb143a commit 1893a93

4 files changed

Lines changed: 55 additions & 26 deletions

File tree

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
namespace NServiceBus.AzureFunctions.Analyzer.Tests
22
{
33
using System.Threading.Tasks;
4-
using Microsoft.CodeAnalysis.CSharp;
54
using NUnit.Framework;
5+
using static AzureFunctionsDiagnostics;
66

77
[TestFixture]
88
public class AzureFunctionsConfigurationAnalyzerTests : AnalyzerTestFixture<AzureFunctionsConfigurationAnalyzer>
99
{
10-
[TestCase("DefineCriticalErrorAction((errorContext, cancellationToken) => Task.CompletedTask)", AzureFunctionsDiagnostics.DefineCriticalErrorActionNotAllowedId, LanguageVersion.CSharp7)]
11-
[TestCase("LimitMessageProcessingConcurrencyTo(5)", AzureFunctionsDiagnostics.LimitMessageProcessingToNotAllowedId, LanguageVersion.CSharp7)]
12-
[TestCase("MakeInstanceUniquelyAddressable(null)", AzureFunctionsDiagnostics.MakeInstanceUniquelyAddressableNotAllowedId, LanguageVersion.CSharp7)]
13-
[TestCase("OverrideLocalAddress(null)", AzureFunctionsDiagnostics.OverrideLocalAddressNotAllowedId, LanguageVersion.CSharp7)]
14-
[TestCase("PurgeOnStartup(true)", AzureFunctionsDiagnostics.PurgeOnStartupNotAllowedId, LanguageVersion.CSharp7)]
15-
[TestCase("SetDiagnosticsPath(null)", AzureFunctionsDiagnostics.SetDiagnosticsPathNotAllowedId, LanguageVersion.CSharp7)]
16-
// HINT: In C# 7 this call is ambiguous with the LearningTransport version as the compiler cannot differentiate method calls via generic type constraints
17-
[TestCase("UseTransport<AzureServiceBusTransport>()", AzureFunctionsDiagnostics.UseTransportNotAllowedId, LanguageVersion.CSharp8)]
18-
[TestCase("UseTransport(new AzureServiceBusTransport(null))", AzureFunctionsDiagnostics.UseTransportNotAllowedId, LanguageVersion.CSharp7)]
19-
public Task DiagnosticIsReportedForEndpointConfiguration(string configuration, string diagnosticId, LanguageVersion minimumLangVersion)
10+
[TestCase("DefineCriticalErrorAction((errorContext, cancellationToken) => Task.CompletedTask)", DefineCriticalErrorActionNotAllowedId)]
11+
[TestCase("LimitMessageProcessingConcurrencyTo(5)", LimitMessageProcessingToNotAllowedId)]
12+
[TestCase("MakeInstanceUniquelyAddressable(null)", MakeInstanceUniquelyAddressableNotAllowedId)]
13+
[TestCase("OverrideLocalAddress(null)", OverrideLocalAddressNotAllowedId)]
14+
[TestCase("PurgeOnStartup(true)", PurgeOnStartupNotAllowedId)]
15+
[TestCase("SetDiagnosticsPath(null)", SetDiagnosticsPathNotAllowedId)]
16+
[TestCase("UseTransport(new AzureServiceBusTransport(null))", UseTransportNotAllowedId)]
17+
public Task DiagnosticIsReportedForEndpointConfiguration(string configuration, string diagnosticId)
2018
{
21-
testSpecificLangVersion = minimumLangVersion;
22-
2319
var source =
2420
$@"using NServiceBus;
2521
using System;
@@ -37,8 +33,5 @@ void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
3733

3834
return Assert(diagnosticId, source);
3935
}
40-
41-
LanguageVersion testSpecificLangVersion;
42-
protected override LanguageVersion AnalyzerLanguageVersion => testSpecificLangVersion;
4336
}
4437
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace NServiceBus.AzureFunctions.Analyzer.Tests
2+
{
3+
using System.Threading.Tasks;
4+
using Microsoft.CodeAnalysis.CSharp;
5+
using NUnit.Framework;
6+
using static AzureFunctionsDiagnostics;
7+
8+
[TestFixture]
9+
public class AzureFunctionsConfigurationAnalyzerTestsCSharp8 : AnalyzerTestFixture<AzureFunctionsConfigurationAnalyzer>
10+
{
11+
// HINT: In C# 7 this call is ambiguous with the LearningTransport version as the compiler cannot differentiate method calls via generic type constraints
12+
[TestCase("UseTransport<AzureServiceBusTransport>()", UseTransportNotAllowedId)]
13+
public Task DiagnosticIsReportedForEndpointConfiguration(string configuration, string diagnosticId)
14+
{
15+
var source =
16+
$@"using NServiceBus;
17+
using System;
18+
using System.Threading.Tasks;
19+
class Foo
20+
{{
21+
void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
22+
{{
23+
[|endpointConfig.AdvancedConfiguration.{configuration}|];
24+
25+
var advancedConfig = endpointConfig.AdvancedConfiguration;
26+
[|advancedConfig.{configuration}|];
27+
}}
28+
}}";
29+
30+
return Assert(diagnosticId, source);
31+
}
32+
protected override LanguageVersion AnalyzerLanguageVersion => LanguageVersion.CSharp8;
33+
}
34+
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ namespace NServiceBus.AzureFunctions.Analyzer.Tests
22
{
33
using System.Threading.Tasks;
44
using NUnit.Framework;
5+
using static AzureFunctionsDiagnostics;
56

67
[TestFixture]
78
public class AzureFunctionsSendReplyOptionsAnalyzerTests : AnalyzerTestFixture<AzureFunctionsConfigurationAnalyzer>
89
{
9-
[TestCase("SendOptions", "RouteReplyToAnyInstance", AzureFunctionsDiagnostics.RouteReplyToAnyInstanceNotAllowedId)]
10-
[TestCase("SendOptions", "RouteReplyToThisInstance", AzureFunctionsDiagnostics.RouteReplyToThisInstanceNotAllowedId)]
11-
[TestCase("SendOptions", "RouteToThisInstance", AzureFunctionsDiagnostics.RouteToThisInstanceNotAllowedId)]
12-
[TestCase("ReplyOptions", "RouteReplyToAnyInstance", AzureFunctionsDiagnostics.RouteReplyToAnyInstanceNotAllowedId)]
13-
[TestCase("ReplyOptions", "RouteReplyToThisInstance", AzureFunctionsDiagnostics.RouteReplyToThisInstanceNotAllowedId)]
10+
[TestCase("SendOptions", "RouteReplyToAnyInstance", RouteReplyToAnyInstanceNotAllowedId)]
11+
[TestCase("SendOptions", "RouteReplyToThisInstance", RouteReplyToThisInstanceNotAllowedId)]
12+
[TestCase("SendOptions", "RouteToThisInstance", RouteToThisInstanceNotAllowedId)]
13+
[TestCase("ReplyOptions", "RouteReplyToAnyInstance", RouteReplyToAnyInstanceNotAllowedId)]
14+
[TestCase("ReplyOptions", "RouteReplyToThisInstance", RouteReplyToThisInstanceNotAllowedId)]
1415
public Task DiagnosticIsReportedForOptions(string optionsType, string method, string diagnosticId)
1516
{
1617
var source =

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ namespace NServiceBus.AzureFunctions.Analyzer.Tests
22
{
33
using System.Threading.Tasks;
44
using NUnit.Framework;
5+
using static AzureFunctionsDiagnostics;
56

67
[TestFixture]
78
public class AzureFunctionsTransportAnalyzerTests : AnalyzerTestFixture<AzureFunctionsConfigurationAnalyzer>
89
{
9-
[TestCase("EntityMaximumSize", "5", AzureFunctionsDiagnostics.EntityMaximumSizeNotAllowedId)]
10-
[TestCase("MaxAutoLockRenewalDuration", "new System.TimeSpan(0, 0, 5, 0)", AzureFunctionsDiagnostics.MaxAutoLockRenewalDurationNotAllowedId)]
11-
[TestCase("PrefetchCount", "5", AzureFunctionsDiagnostics.PrefetchCountNotAllowedId)]
12-
[TestCase("PrefetchMultiplier", "5", AzureFunctionsDiagnostics.PrefetchMultiplierNotAllowedId)]
13-
[TestCase("TimeToWaitBeforeTriggeringCircuitBreaker", "new System.TimeSpan(0, 0, 5, 0)", AzureFunctionsDiagnostics.TimeToWaitBeforeTriggeringCircuitBreakerNotAllowedId)]
10+
[TestCase("EntityMaximumSize", "5", EntityMaximumSizeNotAllowedId)]
11+
[TestCase("MaxAutoLockRenewalDuration", "new System.TimeSpan(0, 0, 5, 0)", MaxAutoLockRenewalDurationNotAllowedId)]
12+
[TestCase("PrefetchCount", "5", PrefetchCountNotAllowedId)]
13+
[TestCase("PrefetchMultiplier", "5", PrefetchMultiplierNotAllowedId)]
14+
[TestCase("TimeToWaitBeforeTriggeringCircuitBreaker", "new System.TimeSpan(0, 0, 5, 0)", TimeToWaitBeforeTriggeringCircuitBreakerNotAllowedId)]
1415
public Task DiagnosticIsReportedTransportConfiguration(string configName, string configValue, string diagnosticId)
1516
{
1617
var source =

0 commit comments

Comments
 (0)