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
4 changes: 4 additions & 0 deletions build/targets/codeanalysis/CodeAnalysis.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions build/targets/codeanalysis/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ItemGroup>
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.173" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.11.0-beta1.24454.1" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.8" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" />
Expand Down
3 changes: 3 additions & 0 deletions src/Analyzers/SquiggleCop.Baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@
- {Id: RemoveUnnecessaryImportsFixable, Title: '', Category: Style, DefaultSeverity: Note, IsEnabledByDefault: true, EffectiveSeverities: [Note], IsEverSuppressed: true}
- {Id: ROS0002, Title: Analyzer option is obsolete, Category: '', DefaultSeverity: Warning, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: ROS0003, Title: Analyzer requires config option to be specified, Category: '', DefaultSeverity: Note, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: RS0030, Title: Do not use banned APIs, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: true}
- {Id: RS0031, Title: The list of banned symbols contains a duplicate, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0035, Title: External access to internal symbols outside the restricted namespace(s) is prohibited, Category: ApiDesign, DefaultSeverity: Error, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1001, Title: Missing diagnostic analyzer attribute, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1002, Title: Missing kind argument when registering an analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1003, Title: Unsupported SymbolKind argument when registering a symbol analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
Expand Down
8 changes: 8 additions & 0 deletions src/BannedSymbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Prefer our DiagnosticExtensions.CreateDiagnostic for readability and consistency
M:Microsoft.CodeAnalysis.Diagnostic.Create(Microsoft.CodeAnalysis.DiagnosticDescriptor,Microsoft.CodeAnalysis.Location,System.Object[]);Use DiagnosticExtensions.CreateDiagnostic
M:Microsoft.CodeAnalysis.Diagnostic.Create(Microsoft.CodeAnalysis.DiagnosticDescriptor,Microsoft.CodeAnalysis.Location,System.Collections.Immutable.ImmutableDictionary{System.String,System.String},System.Object[]);Use DiagnosticExtensions.CreateDiagnostic
M:Microsoft.CodeAnalysis.Diagnostic.Create(Microsoft.CodeAnalysis.DiagnosticDescriptor,Microsoft.CodeAnalysis.Location,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Location},System.Object[]);Use DiagnosticExtensions.CreateDiagnostic
M:Microsoft.CodeAnalysis.Diagnostic.Create(Microsoft.CodeAnalysis.DiagnosticDescriptor,Microsoft.CodeAnalysis.Location,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Location},System.Collections.Immutable.ImmutableDictionary{System.String,System.String},System.Object[]);Use DiagnosticExtensions.CreateDiagnostic
M:Microsoft.CodeAnalysis.Diagnostic.Create(Microsoft.CodeAnalysis.DiagnosticDescriptor,Microsoft.CodeAnalysis.Location,Microsoft.CodeAnalysis.DiagnosticSeverity,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Location},System.Collections.Immutable.ImmutableDictionary{System.String,System.String},System.Object[]);Use DiagnosticExtensions.CreateDiagnostic;Use DiagnosticExtensions.CreateDiagnostic
M:Microsoft.CodeAnalysis.Diagnostic.Create(System.String,System.String,Microsoft.CodeAnalysis.LocalizableString,Microsoft.CodeAnalysis.DiagnosticSeverity,Microsoft.CodeAnalysis.DiagnosticSeverity,System.Boolean,System.Int32,Microsoft.CodeAnalysis.LocalizableString,Microsoft.CodeAnalysis.LocalizableString,System.String,Microsoft.CodeAnalysis.Location,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Location},System.Collections.Generic.IEnumerable{System.String},System.Collections.Immutable.ImmutableDictionary{System.String,System.String});Use DiagnosticExtensions.CreateDiagnostic
M:Microsoft.CodeAnalysis.Diagnostic.Create(System.String,System.String,Microsoft.CodeAnalysis.LocalizableString,Microsoft.CodeAnalysis.DiagnosticSeverity,Microsoft.CodeAnalysis.DiagnosticSeverity,System.Boolean,System.Int32,System.Boolean,Microsoft.CodeAnalysis.LocalizableString,Microsoft.CodeAnalysis.LocalizableString,System.String,Microsoft.CodeAnalysis.Location,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Location},System.Collections.Generic.IEnumerable{System.String},System.Collections.Immutable.ImmutableDictionary{System.String,System.String});Use DiagnosticExtensions.CreateDiagnostic
3 changes: 3 additions & 0 deletions src/CodeFixes/SquiggleCop.Baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@
- {Id: RemoveUnnecessaryImportsFixable, Title: '', Category: Style, DefaultSeverity: Note, IsEnabledByDefault: true, EffectiveSeverities: [Note], IsEverSuppressed: true}
- {Id: ROS0002, Title: Analyzer option is obsolete, Category: '', DefaultSeverity: Warning, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: ROS0003, Title: Analyzer requires config option to be specified, Category: '', DefaultSeverity: Note, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: RS0030, Title: Do not use banned APIs, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: true}
- {Id: RS0031, Title: The list of banned symbols contains a duplicate, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0035, Title: External access to internal symbols outside the restricted namespace(s) is prohibited, Category: ApiDesign, DefaultSeverity: Error, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1001, Title: Missing diagnostic analyzer attribute, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1002, Title: Missing kind argument when registering an analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1003, Title: Unsupported SymbolKind argument when registering a symbol analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
Expand Down
5 changes: 4 additions & 1 deletion src/Common/DiagnosticExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Moq.Analyzers.Common;
using System.Diagnostics.CodeAnalysis;

namespace Moq.Analyzers.Common;

internal static class DiagnosticExtensions
{
Expand Down Expand Up @@ -37,6 +39,7 @@ public static Diagnostic CreateDiagnostic(
ImmutableDictionary<string, string?>? properties,
params object?[]? messageArgs) => location.CreateDiagnostic(rule, additionalLocations: null, properties, messageArgs);

[SuppressMessage("ApiDesign", "RS0030:Do not use banned APIs", Justification = "This is the API that wraps the banned API, so it must be allowed to call banned APIs.")]
public static Diagnostic CreateDiagnostic(
this Location location,
DiagnosticDescriptor rule,
Expand Down
7 changes: 7 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)/../'))" />

<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)/BannedSymbols.txt" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions src/tools/PerfDiff/SquiggleCop.Baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@
- {Id: RemoveUnnecessaryImportsFixable, Title: '', Category: Style, DefaultSeverity: Note, IsEnabledByDefault: true, EffectiveSeverities: [Note], IsEverSuppressed: true}
- {Id: ROS0002, Title: Analyzer option is obsolete, Category: '', DefaultSeverity: Warning, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: ROS0003, Title: Analyzer requires config option to be specified, Category: '', DefaultSeverity: Note, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: RS0030, Title: Do not use banned APIs, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0031, Title: The list of banned symbols contains a duplicate, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0035, Title: External access to internal symbols outside the restricted namespace(s) is prohibited, Category: ApiDesign, DefaultSeverity: Error, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1001, Title: Missing diagnostic analyzer attribute, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1002, Title: Missing kind argument when registering an analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1003, Title: Unsupported SymbolKind argument when registering a symbol analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
Expand Down
3 changes: 3 additions & 0 deletions tests/Moq.Analyzers.Benchmarks/SquiggleCop.Baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,9 @@
- {Id: RemoveUnnecessaryImportsFixable, Title: '', Category: Style, DefaultSeverity: Note, IsEnabledByDefault: true, EffectiveSeverities: [Note], IsEverSuppressed: true}
- {Id: ROS0002, Title: Analyzer option is obsolete, Category: '', DefaultSeverity: Warning, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: ROS0003, Title: Analyzer requires config option to be specified, Category: '', DefaultSeverity: Note, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: RS0030, Title: Do not use banned APIs, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0031, Title: The list of banned symbols contains a duplicate, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0035, Title: External access to internal symbols outside the restricted namespace(s) is prohibited, Category: ApiDesign, DefaultSeverity: Error, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1001, Title: Missing diagnostic analyzer attribute, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1002, Title: Missing kind argument when registering an analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1003, Title: Unsupported SymbolKind argument when registering a symbol analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@
- {Id: RemoveUnnecessaryImportsFixable, Title: '', Category: Style, DefaultSeverity: Note, IsEnabledByDefault: true, EffectiveSeverities: [Note], IsEverSuppressed: true}
- {Id: ROS0002, Title: Analyzer option is obsolete, Category: '', DefaultSeverity: Warning, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: ROS0003, Title: Analyzer requires config option to be specified, Category: '', DefaultSeverity: Note, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: RS0030, Title: Do not use banned APIs, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0031, Title: The list of banned symbols contains a duplicate, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0035, Title: External access to internal symbols outside the restricted namespace(s) is prohibited, Category: ApiDesign, DefaultSeverity: Error, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1001, Title: Missing diagnostic analyzer attribute, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1002, Title: Missing kind argument when registering an analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1003, Title: Unsupported SymbolKind argument when registering a symbol analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
Expand Down
3 changes: 3 additions & 0 deletions tests/Moq.Analyzers.Test/SquiggleCop.Baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@
- {Id: RemoveUnnecessaryImportsFixable, Title: '', Category: Style, DefaultSeverity: Note, IsEnabledByDefault: true, EffectiveSeverities: [Note], IsEverSuppressed: true}
- {Id: ROS0002, Title: Analyzer option is obsolete, Category: '', DefaultSeverity: Warning, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: ROS0003, Title: Analyzer requires config option to be specified, Category: '', DefaultSeverity: Note, IsEnabledByDefault: false, EffectiveSeverities: [None], IsEverSuppressed: true}
- {Id: RS0030, Title: Do not use banned APIs, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0031, Title: The list of banned symbols contains a duplicate, Category: ApiDesign, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS0035, Title: External access to internal symbols outside the restricted namespace(s) is prohibited, Category: ApiDesign, DefaultSeverity: Error, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1001, Title: Missing diagnostic analyzer attribute, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1002, Title: Missing kind argument when registering an analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
- {Id: RS1003, Title: Unsupported SymbolKind argument when registering a symbol analyzer action, Category: MicrosoftCodeAnalysisCorrectness, DefaultSeverity: Warning, IsEnabledByDefault: true, EffectiveSeverities: [Error], IsEverSuppressed: false}
Expand Down