Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,13 @@ dotnet_naming_style.test_methods.word_separator = _
dotnet_naming_rule.test_methods.style = test_methods
dotnet_naming_rule.test_methods.symbols = test_methods
dotnet_naming_rule.test_methods.severity = error

# these sources are compiled into the analyzer as well as the library they belong to. RS1035 bans the symbols an
# analyzer must not depend on, and only the analyzer compilation applies it. every use here shapes exception text
# or a backport hash seed rather than what a rule reports, so the ban is scoped off the linked sources instead of
# the analyzer projects, which keeps it enforced for the rules themselves
[src/Abstractions/src/Asp.Versioning.Abstractions/**.cs]
dotnet_diagnostic.RS1035.severity = none

[src/Common/src/Common.Backport/**.cs]
dotnet_diagnostic.RS1035.severity = none
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>10.2.0</VersionPrefix>
<VersionPrefix>10.2.1</VersionPrefix>
<AssemblyVersion>10.2.0.0</AssemblyVersion>
<TargetFrameworks>$(DefaultTargetFramework);netstandard1.0;netstandard2.0</TargetFrameworks>
<AssemblyTitle>API Versioning Abstractions</AssemblyTitle>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@

Patch analyzers; no functional changes
7 changes: 5 additions & 2 deletions src/Analyzers/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
</ItemGroup>

<!-- the analyzers package only supplies the rules applied while building an analyzer and never ships anywhere -->
<ItemGroup Condition=" '$(IsTestProject)' == 'true' ">
<!-- the analyzers package only supplies the rules applied while building an analyzer and never ships anywhere.
the analyzer projects are what those rules have to run against, so it cannot be scoped to the tests. the
compiler package depends on this one and otherwise pins a version whose rules predate RS1037, which is what
reports a descriptor that is missing the CompilationEnd tag -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.6.0" PrivateAssets="all" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; Shipped analyzer releases
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

## Release 10.2.0

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|---------------------------------
AV0001 | Usage | Error | Invalid API version
AV0002 | Usage | Error | Invalid API version range
AV0003 | Usage | Error | Invalid API version status
AV0004 | Usage | Error | Invalid API version number
AV0005 | Usage | Error | Invalid API version year
AV0006 | Usage | Error | Invalid API version month
AV0007 | Usage | Error | Invalid API version day
AV0008 | Usage | Error | Invalid API version date
AV0009 | Usage | Error | Invalid API version format
AV0010 | Usage | Warning | Unexpected API version format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; Unshipped analyzer release
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@
<Compile Include="$(AbstractionsDir)ApiVersionRange.cs" Link="Linked\ApiVersionRange.cs" />
</ItemGroup>

<!-- the ledger the release tracking rules check the descriptors against, so that a rule cannot be added, or have
its category or severity changed, without saying so. it is read while building this project and is not part
of the package -->
<ItemGroup>
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
</ItemGroup>

</Project>
47 changes: 26 additions & 21 deletions src/Analyzers/src/Asp.Versioning.Analyzers/Descriptor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Copyright (c) .NET Foundation and contributors. All rights reserved.

// the descriptors are fields rather than properties because that is the only shape the rules which check a
// descriptor are able to trace back from a report site. the underscore keeps the rule id and its name legible
// where the fields are used, which is what SA1310 objects to
#pragma warning disable SA1310

namespace Asp.Versioning.Analyzers;

Expand All @@ -19,83 +24,83 @@ private static DiagnosticDescriptor Diagnostic(
return new( id, title, messageFormat, category, defaultSeverity, isEnabledByDefault: true, helpLinkUri: helpLink );
}

public static DiagnosticDescriptor AV0001_InvalidApiVersionSyntax { get; } =
public static readonly DiagnosticDescriptor AV0001_InvalidApiVersionSyntax =
Diagnostic(
"AV0001",
"Invalid API version",
Usage,
Error,
"An API version must be a date or a number, optionally with a status." );
"An API version must be a date or a number, optionally with a status" );

public static DiagnosticDescriptor AV0002_InvalidApiVersionRangeSyntax { get; } =
public static readonly DiagnosticDescriptor AV0002_InvalidApiVersionRangeSyntax =
Diagnostic(
"AV0002",
"Invalid API version range",
Usage,
Error,
"A range must include 1-2 valid API versions, optionally with inclusive ('[', ']') or exclusive ('(', ')') bounds." );
"A range must include 1-2 valid API versions, optionally with inclusive ('[', ']') or exclusive ('(', ')') bounds" );

public static DiagnosticDescriptor AV0003_InvalidApiVersionStatus { get; } =
public static readonly DiagnosticDescriptor AV0003_InvalidApiVersionStatus =
Diagnostic(
"AV0003",
"Invalid API version status",
Usage,
Error,
"An API version status may only be a letter followed by letters or numbers with optional periods in between." );
"An API version status may only be a letter followed by letters or numbers with optional periods in between" );

public static DiagnosticDescriptor AV0004_InvalidApiVersionNumber { get; } =
public static readonly DiagnosticDescriptor AV0004_InvalidApiVersionNumber =
Diagnostic(
"AV0004",
"Invalid API version number",
Usage,
Error,
"An API version number cannot be negative." );
"An API version number cannot be negative" );

public static DiagnosticDescriptor AV0005_InvalidApiVersionYear { get; } =
public static readonly DiagnosticDescriptor AV0005_InvalidApiVersionYear =
Diagnostic(
"AV0005",
"Invalid API version year",
Usage,
Error,
"An API version year must be between 1 and 9999." );
"An API version year must be between 1 and 9999" );

public static DiagnosticDescriptor AV0006_InvalidApiVersionMonth { get; } =
public static readonly DiagnosticDescriptor AV0006_InvalidApiVersionMonth =
Diagnostic(
"AV0006",
"Invalid API version month",
Usage,
Error,
"An API version month must be between 1 and 12." );
"An API version month must be between 1 and 12" );

public static DiagnosticDescriptor AV0007_InvalidApiVersionDay { get; } =
public static readonly DiagnosticDescriptor AV0007_InvalidApiVersionDay =
Diagnostic(
"AV0007",
"Invalid API version day",
Usage,
Error,
"An API version day must be between 1 and 31." );
"An API version day must be between 1 and 31" );

public static DiagnosticDescriptor AV0008_InvalidApiVersionDate { get; } =
public static readonly DiagnosticDescriptor AV0008_InvalidApiVersionDate =
Diagnostic(
"AV0008",
"Invalid API version date",
Usage,
Error,
"The specified API version is not a valid date." );
"The specified API version is not a valid date" );

public static DiagnosticDescriptor AV0009_InvalidApiVersionFormat { get; } =
public static readonly DiagnosticDescriptor AV0009_InvalidApiVersionFormat =
Diagnostic(
"AV0009",
"Invalid API version format",
Usage,
Error,
"The API version format string is malformed and will throw when applied. {0}" );
"The API version format string is malformed and will throw when applied: {0}" );

public static DiagnosticDescriptor AV0010_UnexpectedApiVersionFormat { get; } =
public static readonly DiagnosticDescriptor AV0010_UnexpectedApiVersionFormat =
Diagnostic(
"AV0010",
"Unexpected API version format",
Usage,
Warning,
"The API version format specifier '{0}' is only meaningful up to {1} time(s); repeating it {2} times does not produce the expected result." );
"The API version format specifier '{0}' is only meaningful up to {1} time(s); repeating it {2} times does not produce the expected result" );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
; Shipped analyzer releases
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

## Release 10.2.0

### New Rules

Rule ID | Category | Severity | Notes
--------|---------------|----------|--------------------------------------------------------
AV0011 | Style | Info | Remove unnecessary default API version
AV0012 | Usage | Error | Invalid default API version
AV0013 | Usage | Warning | Missing AddMvc
AV0014 | Usage | Warning | Missing API behavior
AV0015 | Performance | Warning | Use a specific API version reader
AV0016 | Usage | Warning | Do not assume default API version
AV0017 | Usage | Info | Remove unnecessary default value
AV0018 | Usage | Error | All endpoints are version-neutral
AV0019 | Usage | Error | An API cannot be versioned and version-neutral at the same time
AV0020 | Style | Info | Remove unnecessary API explorer
AV0021 | Usage | Warning | Use the versioned API explorer
AV0022 | Usage | Warning | Missing AddOData
AV0023 | Usage | Warning | Route components are ignored
AV0024 | Usage | Info | Remove unnecessary API explorer option
AV0025 | Documentation | Info | Missing OpenAPI document description
AV0026 | Usage | Info | Remove unnecessary group name format
AV0027 | Usage | Warning | Use DescribeApiVersions
AV0028 | Usage | Warning | Sunset policy takes effect before deprecation
AV0029 | Usage | Warning | Remove unnecessary OpenAPI services
AV0030 | Usage | Warning | Missing WithDocumentPerVersion
AV0031 | Usage | Warning | Missing API explorer
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; Unshipped analyzer release
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
<InternalsVisibleTo Include="Asp.Versioning.Api.Analyzers.Tests" Key="$(StrongNamePublicKey)" />
</ItemGroup>

<!-- the ledger the release tracking rules check the descriptors against, so that a rule cannot be added, or have
its category or severity changed, without saying so. it is read while building this project and is not part
of the package -->
<ItemGroup>
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
</ItemGroup>

<ItemGroup Label="Linked from Asp.Versioning.Abstractions">
<Compile Include="$(AbstractionsDir)NamespaceParser.cs" Link="Linked\NamespaceParser.cs" />
</ItemGroup>
Expand Down
Loading
Loading