Skip to content

Commit

Permalink
Merge pull request #4523 from dotnet/merges/master-to-release/6.0.1xx…
Browse files Browse the repository at this point in the history
…-preview1

Merge master to release/6.0.1xx-preview1
  • Loading branch information
mavasani authored Dec 7, 2020
2 parents 16b39be + 868e52e commit 522c99d
Show file tree
Hide file tree
Showing 23 changed files with 418 additions and 267 deletions.
336 changes: 168 additions & 168 deletions docs/Analyzer Configuration.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1370,27 +1370,6 @@
]
}
},
"CA1801": {
"id": "CA1801",
"shortDescription": "Review unused parameters",
"fullDescription": "Avoid unused paramereters in your code. If the parameter cannot be removed, then change its name so it starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.",
"defaultLevel": "warning",
"helpUri": "https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1801",
"properties": {
"category": "Usage",
"isEnabledByDefault": true,
"typeName": "ReviewUnusedParametersAnalyzer",
"languages": [
"C#",
"Visual Basic"
],
"tags": [
"PortedFromFxCop",
"Telemetry",
"EnabledRuleInAggressiveMode"
]
}
},
"CA1802": {
"id": "CA1802",
"shortDescription": "Use literals where appropriate",
Expand Down Expand Up @@ -2052,6 +2031,26 @@
]
}
},
"CA1801": {
"id": "CA1801",
"shortDescription": "Review unused parameters",
"fullDescription": "Avoid unused paramereters in your code. If the parameter cannot be removed, then change its name so it starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.",
"defaultLevel": "warning",
"helpUri": "https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1801",
"properties": {
"category": "Usage",
"isEnabledByDefault": true,
"typeName": "CSharpReviewUnusedParametersAnalyzer",
"languages": [
"C#"
],
"tags": [
"PortedFromFxCop",
"Telemetry",
"EnabledRuleInAggressiveMode"
]
}
},
"CA1812": {
"id": "CA1812",
"shortDescription": "Avoid uninstantiated internal classes",
Expand Down Expand Up @@ -2220,6 +2219,26 @@
]
}
},
"CA1801": {
"id": "CA1801",
"shortDescription": "Review unused parameters",
"fullDescription": "Avoid unused paramereters in your code. If the parameter cannot be removed, then change its name so it starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.",
"defaultLevel": "warning",
"helpUri": "https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1801",
"properties": {
"category": "Usage",
"isEnabledByDefault": true,
"typeName": "BasicReviewUnusedParametersAnalyzer",
"languages": [
"Visual Basic"
],
"tags": [
"PortedFromFxCop",
"Telemetry",
"EnabledRuleInAggressiveMode"
]
}
},
"CA1812": {
"id": "CA1812",
"shortDescription": "Avoid uninstantiated internal classes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,27 +1355,6 @@
]
}
},
"CA1801": {
"id": "CA1801",
"shortDescription": "Review unused parameters",
"fullDescription": "Avoid unused paramereters in your code. If the parameter cannot be removed, then change its name so it starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.",
"defaultLevel": "warning",
"helpUri": "https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1801",
"properties": {
"category": "Usage",
"isEnabledByDefault": true,
"typeName": "ReviewUnusedParametersAnalyzer",
"languages": [
"C#",
"Visual Basic"
],
"tags": [
"PortedFromFxCop",
"Telemetry",
"EnabledRuleInAggressiveMode"
]
}
},
"CA1802": {
"id": "CA1802",
"shortDescription": "Use literals where appropriate",
Expand Down Expand Up @@ -2037,6 +2016,26 @@
]
}
},
"CA1801": {
"id": "CA1801",
"shortDescription": "Review unused parameters",
"fullDescription": "Avoid unused paramereters in your code. If the parameter cannot be removed, then change its name so it starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.",
"defaultLevel": "warning",
"helpUri": "https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1801",
"properties": {
"category": "Usage",
"isEnabledByDefault": true,
"typeName": "CSharpReviewUnusedParametersAnalyzer",
"languages": [
"C#"
],
"tags": [
"PortedFromFxCop",
"Telemetry",
"EnabledRuleInAggressiveMode"
]
}
},
"CA1812": {
"id": "CA1812",
"shortDescription": "Avoid uninstantiated internal classes",
Expand Down Expand Up @@ -2205,6 +2204,26 @@
]
}
},
"CA1801": {
"id": "CA1801",
"shortDescription": "Review unused parameters",
"fullDescription": "Avoid unused paramereters in your code. If the parameter cannot be removed, then change its name so it starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.",
"defaultLevel": "warning",
"helpUri": "https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1801",
"properties": {
"category": "Usage",
"isEnabledByDefault": true,
"typeName": "BasicReviewUnusedParametersAnalyzer",
"languages": [
"Visual Basic"
],
"tags": [
"PortedFromFxCop",
"Telemetry",
"EnabledRuleInAggressiveMode"
]
}
},
"CA1812": {
"id": "CA1812",
"shortDescription": "Avoid uninstantiated internal classes",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeQuality.Analyzers.Maintainability;

namespace Microsoft.CodeQuality.CSharp.Analyzers.Maintainability
{
/// <summary>
/// CA1801: Review unused parameters
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class CSharpReviewUnusedParametersAnalyzer : ReviewUnusedParametersAnalyzer
{
private const SyntaxKind RecordDeclaration = (SyntaxKind)9063;

protected override bool IsPositionalRecordPrimaryConstructor(IMethodSymbol methodSymbol)
{
if (methodSymbol.MethodKind != MethodKind.Constructor)
{
return false;
}

if (methodSymbol.DeclaringSyntaxReferences.Length == 0)
{
return false;
}

return methodSymbol.DeclaringSyntaxReferences[0]
.GetSyntax()
.IsKind(RecordDeclaration);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace Microsoft.CodeQuality.Analyzers.Maintainability
/// <summary>
/// CA1801: Review unused parameters
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
public sealed class ReviewUnusedParametersAnalyzer : DiagnosticAnalyzer
public abstract class ReviewUnusedParametersAnalyzer : DiagnosticAnalyzer
{
internal const string RuleId = "CA1801";

Expand All @@ -34,9 +33,9 @@ public sealed class ReviewUnusedParametersAnalyzer : DiagnosticAnalyzer
isPortedFxCopRule: true,
isDataflowRule: false);

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

public override void Initialize(AnalysisContext context)
public sealed override void Initialize(AnalysisContext context)
{
context.EnableConcurrentExecution();

Expand Down Expand Up @@ -163,7 +162,7 @@ private static void ReportUnusedParameters(
}

#pragma warning disable RS1012 // Start action has no registered actions.
private static bool ShouldAnalyzeMethod(
private bool ShouldAnalyzeMethod(
IMethodSymbol method,
OperationBlockStartAnalysisContext startOperationBlockContext,
INamedTypeSymbol? eventsArgSymbol,
Expand Down Expand Up @@ -196,6 +195,12 @@ private static bool ShouldAnalyzeMethod(
return false;
}

// Ignore primary constructor (body-less) of positional records.
if (IsPositionalRecordPrimaryConstructor(method))
{
return false;
}

// Ignore serialization special methods
if (method.IsSerializationConstructor(serializationInfoType, streamingContextType) ||
method.IsGetObjectData(serializationInfoType, streamingContextType))
Expand Down Expand Up @@ -241,5 +246,7 @@ private static bool ShouldAnalyzeMethod(

return true;
}

protected abstract bool IsPositionalRecordPrimaryConstructor(IMethodSymbol methodSymbol);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@
<value>In most programming languages there is no default implementation of the equality operator (==) for value types. If your programming language supports operator overloads, you should consider implementing the equality operator. Its behavior should be identical to that of Equals.</value>
</data>
<data name="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage" xml:space="preserve">
<value>Implement the equality operators and make their behavior identical to that of 'Equals' method</value>
<value>Implement the equality operators and make their behavior identical to that of the Equals method</value>
</data>
<data name="PassSystemUriObjectsInsteadOfStringsTitle" xml:space="preserve">
<value>Pass system uri objects instead of strings</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Implementujte operátory rovnosti a zajistěte, aby se jejich chování shodovalo s metodou Equals.</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Implementujte operátory rovnosti a zajistěte, aby se jejich chování shodovalo s metodou Equals.</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Implementieren Sie die Gleichheitsoperatoren, und legen Sie deren Verhalten auf das der Equals-Methode fest.</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Implementieren Sie die Gleichheitsoperatoren, und legen Sie deren Verhalten auf das der Equals-Methode fest.</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Implementar los operadores de igualdad y hacer que su comportamiento sea idéntico al del método "Equals"</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Implementar los operadores de igualdad y hacer que su comportamiento sea idéntico al del método "Equals"</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Permet d'implémenter les opérateurs d'égalité et de rendre leur comportement identique à celui de la méthode 'Equals'</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Permet d'implémenter les opérateurs d'égalité et de rendre leur comportement identique à celui de la méthode 'Equals'</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Implementare gli operatori di uguaglianza e impostare il comportamento in modo che sia identico a quello del metodo 'Equals'</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Implementare gli operatori di uguaglianza e impostare il comportamento in modo che sia identico a quello del metodo 'Equals'</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">等値演算子を実装し、'Equals' メソッドと同一の動作にします</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">等値演算子を実装し、'Equals' メソッドと同一の動作にします</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">같음 연산자를 구현하고 해당 동작을 'Equals' 메서드의 동작과 같게 만드세요.</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">같음 연산자를 구현하고 해당 동작을 'Equals' 메서드의 동작과 같게 만드세요.</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Zaimplementuj operatory równości i ustaw ich zachowanie na identyczne z metodą „Equals”</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Zaimplementuj operatory równości i ustaw ich zachowanie na identyczne z metodą „Equals”</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Implementar os operadores de igualdade e tornar o comportamento idêntico ao do método 'Equals'</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Implementar os operadores de igualdade e tornar o comportamento idêntico ao do método 'Equals'</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Реализуйте операторы равенства и сделайте их поведение идентичным поведению метода "Equals".</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Реализуйте операторы равенства и сделайте их поведение идентичным поведению метода "Equals".</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@
<note />
</trans-unit>
<trans-unit id="OverloadOperatorEqualsOnOverridingValueTypeEqualsMessage">
<source>Implement the equality operators and make their behavior identical to that of 'Equals' method</source>
<target state="translated">Eşitlik işleçlerini uygulayın ve davranışlarını 'Equals' yöntemininkiyle aynı yapın</target>
<source>Implement the equality operators and make their behavior identical to that of the Equals method</source>
<target state="needs-review-translation">Eşitlik işleçlerini uygulayın ve davranışlarını 'Equals' yöntemininkiyle aynı yapın</target>
<note />
</trans-unit>
<trans-unit id="PassSystemUriObjectsInsteadOfStringsTitle">
Expand Down
Loading

0 comments on commit 522c99d

Please sign in to comment.