Skip to content

Commit

Permalink
´Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLarsson committed Dec 12, 2021
1 parent 6d6ba80 commit 6544bd3
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class OrdersController : Controller
public IActionResult Get() => this.Ok();
}
}";
var message = "The route template has parameter 'id' that does not have a corresponding method parameter.";
var message = "The route template has parameter 'id' that does not have a corresponding method parameter";
RoslynAssert.Diagnostics(Analyzer, ExpectedDiagnostic.WithMessage(message), code);
}

Expand Down Expand Up @@ -80,7 +80,7 @@ public async Task<IActionResult> Get(int orderId)
}
}
}";
var message = "The route template has parameter 'itemId' that does not have a corresponding method parameter.";
var message = "The route template has parameter 'itemId' that does not have a corresponding method parameter";
RoslynAssert.Diagnostics(Analyzer, ExpectedDiagnostic.WithMessage(message), order, db, code);
}

Expand Down Expand Up @@ -204,7 +204,7 @@ public IActionResult Get()
}
}
}";
var message = "The route template has parameter 'id' that does not have a corresponding method parameter.";
var message = "The route template has parameter 'id' that does not have a corresponding method parameter";
RoslynAssert.Diagnostics(Analyzer, ExpectedDiagnostic.WithMessage(message), code);
}

Expand Down
48 changes: 24 additions & 24 deletions AspNetCoreAnalyzers/Descriptors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@ internal static class Descriptors
{
internal static readonly DiagnosticDescriptor ASP001ParameterSymbolName = Create(
id: "ASP001",
title: "Parameter name does not match the name specified by the route parameter.",
messageFormat: "Parameter name does not match the name specified by the route parameter.",
title: "Parameter name does not match the name specified by the route parameter",
messageFormat: "Parameter name does not match the name specified by the route parameter",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Parameter name does not match the name specified by the route parameter.");

internal static readonly DiagnosticDescriptor ASP002RouteParameterName = Descriptors.Create(
id: "ASP002",
title: "Route parameter name does not match the method parameter name.",
messageFormat: "Route parameter name does not match the method parameter name.",
title: "Route parameter name does not match the method parameter name",
messageFormat: "Route parameter name does not match the method parameter name",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Route parameter name does not match the method parameter name.");

internal static readonly DiagnosticDescriptor ASP003ParameterSymbolType = Descriptors.Create(
id: "ASP003",
title: "Parameter type does not match the type specified by the name specified by the route parameter.",
messageFormat: "Parameter type does not match the type specified by the name specified by the route parameter.",
title: "Parameter type does not match the type specified by the name specified by the route parameter",
messageFormat: "Parameter type does not match the type specified by the name specified by the route parameter",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Parameter type does not match the type specified by the name specified by the route parameter.");

internal static readonly DiagnosticDescriptor ASP004RouteParameterType = Descriptors.Create(
id: "ASP004",
title: "Route parameter type does not match the method parameter type.",
messageFormat: "Route parameter type does not match the method parameter type.",
title: "Route parameter type does not match the method parameter type",
messageFormat: "Route parameter type does not match the method parameter type",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Route parameter type does not match the method parameter type.");

internal static readonly DiagnosticDescriptor ASP005ParameterSyntax = Descriptors.Create(
id: "ASP005",
title: "Syntax error in parameter.",
messageFormat: "Syntax error in parameter.",
title: "Syntax error in parameter",
messageFormat: "Syntax error in parameter",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
Expand All @@ -54,43 +54,43 @@ internal static class Descriptors
/// </summary>
internal static readonly DiagnosticDescriptor ASP006ParameterRegex = Descriptors.Create(
id: "ASP006",
title: "Escape constraint regex.",
messageFormat: "Escape constraint regex.",
title: "Escape constraint regex",
messageFormat: "Escape constraint regex",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Escape constraint regex.");

internal static readonly DiagnosticDescriptor ASP007MissingParameter = Descriptors.Create(
id: "ASP007",
title: "The method has no corresponding parameter.",
messageFormat: "The route template has parameter '{0}' that does not have a corresponding method parameter.",
title: "The method has no corresponding parameter",
messageFormat: "The route template has parameter '{0}' that does not have a corresponding method parameter",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "The method has no corresponding parameter.");

internal static readonly DiagnosticDescriptor ASP008ValidRouteParameterName = Descriptors.Create(
id: "ASP008",
title: "Invalid route parameter name.",
messageFormat: "Invalid route parameter name.",
title: "Invalid route parameter name",
messageFormat: "Invalid route parameter name",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Invalid route parameter name.");

internal static readonly DiagnosticDescriptor ASP009KebabCaseUrl = Descriptors.Create(
id: "ASP009",
title: "Use kebab-cased urls.",
messageFormat: "Use kebab-cased urls.",
title: "Use kebab-cased urls",
messageFormat: "Use kebab-cased urls",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Use kebab-cased urls.");

internal static readonly DiagnosticDescriptor ASP010UrlSyntax = Descriptors.Create(
id: "ASP010",
title: "Unexpected character in url.",
title: "Unexpected character in url",
messageFormat: "Literal sections cannot contain the '{0}' character",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
Expand All @@ -99,25 +99,25 @@ internal static class Descriptors

internal static readonly DiagnosticDescriptor ASP011RouteParameterNameMustBeUnique = Descriptors.Create(
id: "ASP011",
title: "Route parameter appears more than once.",
messageFormat: "Route parameter appears more than once.",
title: "Route parameter appears more than once",
messageFormat: "Route parameter appears more than once",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Route parameter appears more than once.");

internal static readonly DiagnosticDescriptor ASP012UseExplicitRoute = Descriptors.Create(
id: "ASP012",
title: "Don't use [controller].",
messageFormat: "Don't use [controller].",
title: "Don't use [controller]",
messageFormat: "Don't use [controller]",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Don't use [controller]. Prefer explicit string so that renaming the class is not a breaking change.");

internal static readonly DiagnosticDescriptor ASP013ControllerNameShouldMatchRoute = Descriptors.Create(
id: "ASP013",
title: "Name the controller to match the route.",
title: "Name the controller to match the route",
messageFormat: "Name the controller to match the route. Expected: '{0}'.",
category: AnalyzerCategory.Routing,
defaultSeverity: DiagnosticSeverity.Warning,
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ Roslyn analyzers for ASP.NET.Core.

| Id | Title
| :-- | :--
| [ASP001](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP001.md)| Parameter name does not match the name specified by the route parameter.
| [ASP002](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP002.md)| Route parameter name does not match the method parameter name.
| [ASP003](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP003.md)| Parameter type does not match the type specified by the name specified by the route parameter.
| [ASP004](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP004.md)| Route parameter type does not match the method parameter type.
| [ASP005](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP005.md)| Syntax error in parameter.
| [ASP006](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP006.md)| Escape constraint regex.
| [ASP007](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP007.md)| The method has no corresponding parameter.
| [ASP008](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP008.md)| Invalid route parameter name.
| [ASP009](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP009.md)| Use kebab-cased urls.
| [ASP010](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP010.md)| Unexpected character in url.
| [ASP011](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP011.md)| Route parameter appears more than once.
| [ASP012](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP012.md)| Don't use [controller].
| [ASP013](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP013.md)| Name the controller to match the route.
| [ASP001](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP001.md)| Parameter name does not match the name specified by the route parameter
| [ASP002](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP002.md)| Route parameter name does not match the method parameter name
| [ASP003](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP003.md)| Parameter type does not match the type specified by the name specified by the route parameter
| [ASP004](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP004.md)| Route parameter type does not match the method parameter type
| [ASP005](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP005.md)| Syntax error in parameter
| [ASP006](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP006.md)| Escape constraint regex
| [ASP007](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP007.md)| The method has no corresponding parameter
| [ASP008](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP008.md)| Invalid route parameter name
| [ASP009](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP009.md)| Use kebab-cased urls
| [ASP010](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP010.md)| Unexpected character in url
| [ASP011](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP011.md)| Route parameter appears more than once
| [ASP012](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP012.md)| Don't use [controller]
| [ASP013](https://github.com/DotNetAnalyzers/AspNetCoreAnalyzers/tree/master/documentation/ASP013.md)| Name the controller to match the route


## Using AspNetCoreAnalyzers
Expand Down
10 changes: 5 additions & 5 deletions documentation/ASP001.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ASP001
## Parameter name does not match the name specified by the route parameter.
## Parameter name does not match the name specified by the route parameter

| Topic | Value
| :-- | :--
Expand Down Expand Up @@ -58,21 +58,21 @@ Configure the severity per project, for more info see [MSDN](https://msdn.micros

### Via #pragma directive.
```C#
#pragma warning disable ASP001 // Parameter name does not match the name specified by the route parameter.
#pragma warning disable ASP001 // Parameter name does not match the name specified by the route parameter
Code violating the rule here
#pragma warning restore ASP001 // Parameter name does not match the name specified by the route parameter.
#pragma warning restore ASP001 // Parameter name does not match the name specified by the route parameter
```

Or put this at the top of the file to disable all instances.
```C#
#pragma warning disable ASP001 // Parameter name does not match the name specified by the route parameter.
#pragma warning disable ASP001 // Parameter name does not match the name specified by the route parameter
```

### Via attribute `[SuppressMessage]`.

```C#
[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing",
"ASP001:Parameter name does not match the name specified by the route parameter.",
"ASP001:Parameter name does not match the name specified by the route parameter",
Justification = "Reason...")]
```
<!-- end generated config severity -->
10 changes: 5 additions & 5 deletions documentation/ASP002.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ASP002
## Route parameter name does not match the method parameter name.
## Route parameter name does not match the method parameter name

| Topic | Value
| :-- | :--
Expand Down Expand Up @@ -58,21 +58,21 @@ Configure the severity per project, for more info see [MSDN](https://msdn.micros

### Via #pragma directive.
```C#
#pragma warning disable ASP002 // Route parameter name does not match the method parameter name.
#pragma warning disable ASP002 // Route parameter name does not match the method parameter name
Code violating the rule here
#pragma warning restore ASP002 // Route parameter name does not match the method parameter name.
#pragma warning restore ASP002 // Route parameter name does not match the method parameter name
```

Or put this at the top of the file to disable all instances.
```C#
#pragma warning disable ASP002 // Route parameter name does not match the method parameter name.
#pragma warning disable ASP002 // Route parameter name does not match the method parameter name
```

### Via attribute `[SuppressMessage]`.

```C#
[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing",
"ASP002:Route parameter name does not match the method parameter name.",
"ASP002:Route parameter name does not match the method parameter name",
Justification = "Reason...")]
```
<!-- end generated config severity -->
10 changes: 5 additions & 5 deletions documentation/ASP003.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ASP003
## Parameter type does not match the type specified by the name specified by the route parameter.
## Parameter type does not match the type specified by the name specified by the route parameter

| Topic | Value
| :-- | :--
Expand Down Expand Up @@ -30,21 +30,21 @@ Configure the severity per project, for more info see [MSDN](https://msdn.micros

### Via #pragma directive.
```C#
#pragma warning disable ASP003 // Parameter type does not match the type specified by the name specified by the route parameter.
#pragma warning disable ASP003 // Parameter type does not match the type specified by the name specified by the route parameter
Code violating the rule here
#pragma warning restore ASP003 // Parameter type does not match the type specified by the name specified by the route parameter.
#pragma warning restore ASP003 // Parameter type does not match the type specified by the name specified by the route parameter
```

Or put this at the top of the file to disable all instances.
```C#
#pragma warning disable ASP003 // Parameter type does not match the type specified by the name specified by the route parameter.
#pragma warning disable ASP003 // Parameter type does not match the type specified by the name specified by the route parameter
```

### Via attribute `[SuppressMessage]`.

```C#
[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing",
"ASP003:Parameter type does not match the type specified by the name specified by the route parameter.",
"ASP003:Parameter type does not match the type specified by the name specified by the route parameter",
Justification = "Reason...")]
```
<!-- end generated config severity -->
10 changes: 5 additions & 5 deletions documentation/ASP004.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ASP004
## Route parameter type does not match the method parameter type.
## Route parameter type does not match the method parameter type

| Topic | Value
| :-- | :--
Expand Down Expand Up @@ -30,21 +30,21 @@ Configure the severity per project, for more info see [MSDN](https://msdn.micros

### Via #pragma directive.
```C#
#pragma warning disable ASP004 // Route parameter type does not match the method parameter type.
#pragma warning disable ASP004 // Route parameter type does not match the method parameter type
Code violating the rule here
#pragma warning restore ASP004 // Route parameter type does not match the method parameter type.
#pragma warning restore ASP004 // Route parameter type does not match the method parameter type
```

Or put this at the top of the file to disable all instances.
```C#
#pragma warning disable ASP004 // Route parameter type does not match the method parameter type.
#pragma warning disable ASP004 // Route parameter type does not match the method parameter type
```

### Via attribute `[SuppressMessage]`.

```C#
[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing",
"ASP004:Route parameter type does not match the method parameter type.",
"ASP004:Route parameter type does not match the method parameter type",
Justification = "Reason...")]
```
<!-- end generated config severity -->
Loading

0 comments on commit 6544bd3

Please sign in to comment.