Skip to content

Commit

Permalink
Add analyzer release tracking (#84)
Browse files Browse the repository at this point in the history
Enable analyzer release tracking (i.e. `AnalyzerReleases.Shipped.md`).
Fixes #72.

Wokflow was as follows:

1. Download old release from NuGet
2. Open in ILSpy to view the analyzer metadata
3. Create appropriate release in `AnalyzerReleases.Shipped.md`
4. GOTO 1
5. Add help links pointing to our `//docs/rules` files
- I tried to make the base URL a helper function, but the analyzer is
unable to add documentation URLs to the Unshipped file if the URL isn't
a constant. So instead I used string interpolation so at least the ID
isn't repeated.
6. Use release analyzer codefix to add an unshipped section that adds
help links
  • Loading branch information
MattKotsenas authored Jun 12, 2024
1 parent 5057438 commit 548ec1c
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 16 deletions.
61 changes: 61 additions & 0 deletions Source/Moq.Analyzers/AnalyzerReleases.Shipped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
; Shipped analyzer releases
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

## Release 0.0.1.22865

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
Moq1101 | Moq | Warning | CallbackSignatureAnalyzer
Moq1002 | Moq | Warning | ShouldNotAllowParametersForMockedInterfaceAnalyzer
Moq1001 | Moq | Warning | ShouldNotMockSealedClassesAnalyzer

## Release 0.0.3.40797

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
Moq1003 | Moq | Warning | MatchingConstructorParametersAnalyzer

## Release 0.0.4.43043

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
Moq1100 | Moq | Warning | CallbackSignatureShouldMatchMockedMethodAnalyzer
Moq1000 | Moq | Warning | ConstructorArgumentsShouldMatchAnalyzer

## Release 0.0.6

### Removed Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
Moq1003 | Moq | Warning | ConstructorArgumentsShouldMatchAnalyzer

## Release 0.0.7

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
Moq1200 | Moq | Error | SetupShouldBeUsedOnlyForOverridableMembersAnalyzer

## Release 0.0.8

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
Moq1300 | Moq | Error | AsShouldBeUsedOnlyForInterfaceAnalyzer

## Release 0.0.9

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
Moq1201 | Moq | Error | SetupShouldNotIncludeAsyncResultAnalyzer
2 changes: 2 additions & 0 deletions Source/Moq.Analyzers/AnalyzerReleases.Unshipped.md
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 @@ -5,13 +5,14 @@ public class AsShouldBeUsedOnlyForInterfaceAnalyzer : DiagnosticAnalyzer
{
private static readonly MoqMethodDescriptorBase MoqAsMethodDescriptor = new MoqAsMethodDescriptor();

private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.AsShouldBeUsedOnlyForInterfaceId,
Diagnostics.AsShouldBeUsedOnlyForInterfaceTitle,
Diagnostics.AsShouldBeUsedOnlyForInterfaceMessage,
Diagnostics.Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true);
isEnabledByDefault: true,
helpLinkUri: $"https://github.com/rjmurillo/moq.analyzers/blob/main/docs/rules/{Diagnostics.AsShouldBeUsedOnlyForInterfaceId}.md");

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ namespace Moq.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class CallbackSignatureShouldMatchMockedMethodAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.CallbackSignatureShouldMatchMockedMethodId,
Diagnostics.CallbackSignatureShouldMatchMockedMethodTitle,
Diagnostics.CallbackSignatureShouldMatchMockedMethodMessage,

Check warning on line 9 in Source/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 9 in Source/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
Diagnostics.Category,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
isEnabledByDefault: true,
helpLinkUri: $"https://github.com/rjmurillo/moq.analyzers/blob/main/docs/rules/{Diagnostics.CallbackSignatureShouldMatchMockedMethodId}.md");

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ namespace Moq.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ConstructorArgumentsShouldMatchAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.ConstructorArgumentsShouldMatchId,
Diagnostics.ConstructorArgumentsShouldMatchTitle,
Diagnostics.ConstructorArgumentsShouldMatchMessage,

Check warning on line 11 in Source/Moq.Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
Diagnostics.Category,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
isEnabledByDefault: true,
helpLinkUri: $"https://github.com/rjmurillo/moq.analyzers/blob/main/docs/rules/{Diagnostics.ConstructorArgumentsShouldMatchId}.md");

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ namespace Moq.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class NoConstructorArgumentsForInterfaceMockAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.NoConstructorArgumentsForInterfaceMockId,
Diagnostics.NoConstructorArgumentsForInterfaceMockTitle,
Diagnostics.NoConstructorArgumentsForInterfaceMockMessage,

Check warning on line 11 in Source/Moq.Analyzers/NoConstructorArgumentsForInterfaceMockAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 11 in Source/Moq.Analyzers/NoConstructorArgumentsForInterfaceMockAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
Diagnostics.Category,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
isEnabledByDefault: true,
helpLinkUri: $"https://github.com/rjmurillo/moq.analyzers/blob/main/docs/rules/{Diagnostics.NoConstructorArgumentsForInterfaceMockId}.md");

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
{
Expand Down
5 changes: 3 additions & 2 deletions Source/Moq.Analyzers/NoMethodsInPropertySetupAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ namespace Moq.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class NoMethodsInPropertySetupAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.NoMethodsInPropertySetupId,
Diagnostics.NoMethodsInPropertySetupTitle,
Diagnostics.NoMethodsInPropertySetupMessage,

Check warning on line 9 in Source/Moq.Analyzers/NoMethodsInPropertySetupAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 9 in Source/Moq.Analyzers/NoMethodsInPropertySetupAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
Diagnostics.Category,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
isEnabledByDefault: true,
helpLinkUri: $"https://github.com/rjmurillo/moq.analyzers/blob/main/docs/rules/{Diagnostics.NoMethodsInPropertySetupId}.md");

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
{
Expand Down
5 changes: 3 additions & 2 deletions Source/Moq.Analyzers/NoSealedClassMocksAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ namespace Moq.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class NoSealedClassMocksAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.NoSealedClassMocksId,
Diagnostics.NoSealedClassMocksTitle,
Diagnostics.NoSealedClassMocksMessage,

Check warning on line 9 in Source/Moq.Analyzers/NoSealedClassMocksAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
Diagnostics.Category,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
isEnabledByDefault: true,
helpLinkUri: $"https://github.com/rjmurillo/moq.analyzers/blob/main/docs/rules/{Diagnostics.NoSealedClassMocksId}.md");

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ namespace Moq.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class SetupShouldBeUsedOnlyForOverridableMembersAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.SetupShouldBeUsedOnlyForOverridableMembersId,
Diagnostics.SetupShouldBeUsedOnlyForOverridableMembersTitle,
Diagnostics.SetupShouldBeUsedOnlyForOverridableMembersMessage,

Check warning on line 9 in Source/Moq.Analyzers/SetupShouldBeUsedOnlyForOverridableMembersAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 9 in Source/Moq.Analyzers/SetupShouldBeUsedOnlyForOverridableMembersAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
Diagnostics.Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true);
isEnabledByDefault: true,
helpLinkUri: $"https://github.com/rjmurillo/moq.analyzers/blob/main/docs/rules/{Diagnostics.SetupShouldBeUsedOnlyForOverridableMembersId}.md");

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class SetupShouldNotIncludeAsyncResultAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
private static readonly DiagnosticDescriptor Rule = new(
Diagnostics.SetupShouldNotIncludeAsyncResultId,
Diagnostics.SetupShouldNotIncludeAsyncResultTitle,
Diagnostics.SetupShouldNotIncludeAsyncResultMessage,
Diagnostics.Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true);
isEnabledByDefault: true,
helpLinkUri: $"https://github.com/rjmurillo/moq.analyzers/blob/main/docs/rules/{Diagnostics.SetupShouldNotIncludeAsyncResultId}.md");

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);

Expand Down

0 comments on commit 548ec1c

Please sign in to comment.