Skip to content

Commit ea8aa10

Browse files
authored
Merge pull request #6353 from Youssef1313/enable-ide-experimental-rules
Enable IDE2xxx experimental rules
2 parents dc21b95 + 9e92aa9 commit ea8aa10

File tree

123 files changed

+378
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+378
-30
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,21 @@ dotnet_diagnostic.IDE0130.severity = silent
242242
# IDE0150: Null check can be clarified
243243
dotnet_diagnostic.IDE0150.severity = silent
244244

245+
# IDE2000: Allow multiple blank lines
246+
dotnet_style_allow_multiple_blank_lines_experimental = false
247+
248+
# IDE2001: Embedded statements must be on their own line
249+
csharp_style_allow_embedded_statements_on_same_line_experimental = false
250+
251+
# IDE2002: Consecutive braces must not have blank line between them
252+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
253+
254+
# IDE2003: Blank line required between block and subsequent statement
255+
dotnet_style_allow_statement_immediately_after_block_experimental = false
256+
257+
# IDE2004: Blank line not allowed after constructor initializer colon
258+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
259+
245260
### Configuration for FxCop analyzers executed on this repo ###
246261
[*.{cs,vb}]
247262

src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ private static void HandleInvocationOperation(
165165
{
166166
context.ReportDiagnostic(invocationOperation.CreateDiagnostic(GetHashCodeRule));
167167
}
168+
168169
break;
169170

170171
case s_symbolEqualsName:
@@ -176,6 +177,7 @@ private static void HandleInvocationOperation(
176177
context.ReportDiagnostic(invocationOperation.Syntax.GetLocation().CreateDiagnostic(EqualityRule));
177178
}
178179
}
180+
179181
break;
180182

181183
case s_HashCodeCombineName:
@@ -187,6 +189,7 @@ invocationOperation.Instance is null &&
187189
{
188190
context.ReportDiagnostic(invocationOperation.CreateDiagnostic(GetHashCodeRule));
189191
}
192+
190193
break;
191194

192195
default:
@@ -198,6 +201,7 @@ invocationOperation.Instance is null &&
198201
{
199202
context.ReportDiagnostic(invocationOperation.CreateDiagnostic(CollectionRule));
200203
}
204+
201205
break;
202206
}
203207

src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/Fixers/AnalyzerReleaseTrackingFix.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
7272
cancellationToken => UpdateEntryInUnshippedFileAsync(context.Document.Project, ruleId, entryToUpdate, cancellationToken),
7373
equivalenceKey: CodeAnalysisDiagnosticsResources.UpdateEntryForDiagnosticIdInAnalyzerReleaseCodeFixTitle);
7474
}
75+
7576
break;
7677

7778
case DiagnosticIds.EnableAnalyzerReleaseTrackingRuleId:

src/Microsoft.CodeAnalysis.Analyzers/VisualBasic/MetaAnalyzers/Fixers/BasicPreferIsKindFix.vb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Analyzers.MetaAnalyzers.CodeFixes
3535
If invocation Is Nothing Then
3636
Return binaryExpression
3737
End If
38+
3839
Dim newInvocation = invocation _
3940
.WithExpression(ConvertKindNameToIsKind(invocation.Expression)) _
4041
.AddArgumentListArguments(SyntaxFactory.SimpleArgument(binaryExpression.Right.WithoutTrailingTrivia())) _

src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Core/SymbolIsBannedAnalyzerBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ private void OnCompilationStart(CompilationStartAnalysisContext compilationConte
101101
VerifySymbol(context.ReportDiagnostic, conversion.OperatorMethod, context.Operation.Syntax);
102102
VerifyType(context.ReportDiagnostic, conversion.OperatorMethod.ContainingType, context.Operation.Syntax);
103103
}
104+
104105
break;
105106

106107
case IUnaryOperation unary:
@@ -109,6 +110,7 @@ private void OnCompilationStart(CompilationStartAnalysisContext compilationConte
109110
VerifySymbol(context.ReportDiagnostic, unary.OperatorMethod, context.Operation.Syntax);
110111
VerifyType(context.ReportDiagnostic, unary.OperatorMethod.ContainingType, context.Operation.Syntax);
111112
}
113+
112114
break;
113115

114116
case IBinaryOperation binary:
@@ -117,6 +119,7 @@ private void OnCompilationStart(CompilationStartAnalysisContext compilationConte
117119
VerifySymbol(context.ReportDiagnostic, binary.OperatorMethod, context.Operation.Syntax);
118120
VerifyType(context.ReportDiagnostic, binary.OperatorMethod.ContainingType, context.Operation.Syntax);
119121
}
122+
120123
break;
121124

122125
case IIncrementOrDecrementOperation incrementOrDecrement:
@@ -125,6 +128,7 @@ private void OnCompilationStart(CompilationStartAnalysisContext compilationConte
125128
VerifySymbol(context.ReportDiagnostic, incrementOrDecrement.OperatorMethod, context.Operation.Syntax);
126129
VerifyType(context.ReportDiagnostic, incrementOrDecrement.OperatorMethod.ContainingType, context.Operation.Syntax);
127130
}
131+
128132
break;
129133
case ITypeOfOperation typeOfOperation:
130134
VerifyType(context.ReportDiagnostic, typeOfOperation.TypeOperand, context.Operation.Syntax);
@@ -220,6 +224,7 @@ bool VerifyTypeArguments(Action<Diagnostic> reportDiagnostic, ITypeSymbol? type,
220224
return false;
221225
}
222226
}
227+
223228
break;
224229

225230
case IArrayTypeSymbol arrayTypeSymbol:

src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/AbstractResxGenerator.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ public bool Execute(GeneratorExecutionContext context)
304304
RenderFormatMethod(memberIndent, language, strings, resourceString);
305305
}
306306
}
307+
307308
break;
308309

309310
case Lang.VisualBasic:
@@ -324,6 +325,7 @@ public bool Execute(GeneratorExecutionContext context)
324325
{
325326
throw new NotImplementedException();
326327
}
328+
327329
break;
328330

329331
default:
@@ -378,6 +380,7 @@ public bool Execute(GeneratorExecutionContext context)
378380
{memberIndent}}}
379381
";
380382
}
383+
381384
break;
382385

383386
case Lang.VisualBasic:
@@ -390,6 +393,7 @@ public bool Execute(GeneratorExecutionContext context)
390393
{
391394
throw new NotImplementedException();
392395
}
396+
393397
break;
394398

395399
default:
@@ -450,6 +454,7 @@ public bool Execute(GeneratorExecutionContext context)
450454
{resourceTypeDefinition}
451455
}}";
452456
}
457+
453458
break;
454459

455460
case Lang.VisualBasic:
@@ -461,6 +466,7 @@ public bool Execute(GeneratorExecutionContext context)
461466
{resourceTypeDefinition}
462467
End Namespace";
463468
}
469+
464470
break;
465471

466472
default:
@@ -603,6 +609,7 @@ private static string CreateStringLiteral(string original, Lang lang)
603609
{
604610
stringLiteral.Append('@');
605611
}
612+
606613
stringLiteral.Append('\"');
607614
for (var i = 0; i < original.Length; i++)
608615
{
@@ -611,8 +618,10 @@ private static string CreateStringLiteral(string original, Lang lang)
611618
{
612619
stringLiteral.Append('"');
613620
}
621+
614622
stringLiteral.Append(original[i]);
615623
}
624+
616625
stringLiteral.Append('\"');
617626

618627
return stringLiteral.ToString();
@@ -644,6 +653,7 @@ private static void RenderFormatMethod(string indent, Lang language, StringBuild
644653
{
645654
strings.AppendLine($@"{indent} => string.Format(Culture, GetResourceString(""{resourceString.Name}"") ?? """", {resourceString.GetArguments()});");
646655
}
656+
647657
strings.AppendLine();
648658
}
649659

src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/InteropServices/CSharpDisableRuntimeMarshalling.FixAllProvider.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ protected override async Task<SyntaxNode> FixAllInDocumentAsync(FixAllContext fi
2828
// We can't code fix if unsafe code isn't allowed.
2929
return await document.GetSyntaxRootAsync(fixAllContext.CancellationToken);
3030
}
31+
3132
var editor = await DocumentEditor.CreateAsync(document, fixAllContext.CancellationToken).ConfigureAwait(false);
3233
SyntaxNode root = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false);
3334

@@ -47,12 +48,14 @@ protected override async Task<SyntaxNode> FixAllInDocumentAsync(FixAllContext fi
4748
{
4849
identifierGenerator = scopeMap[block] = new IdentifierGenerator(editor.SemanticModel, block);
4950
}
51+
5052
if (TryRewriteMethodCall(node, editor, identifierGenerator, addRenameAnnotation: false, fixAllContext.CancellationToken))
5153
{
5254
AddUnsafeModifierToEnclosingMethod(editor, node);
5355
}
5456
}
5557
}
58+
5659
return editor.GetChangedRoot();
5760
}
5861
}

src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/InteropServices/CSharpDisableRuntimeMarshalling.Fixer.IdentifierGenerator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public IdentifierGenerator(SemanticModel model, IBlockOperation block)
2626
{
2727
identifier = NextIdentifier();
2828
}
29+
2930
if (identifier is not null)
3031
{
3132
// The last identifier was not in use, so go back one to use it the next call.

src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/InteropServices/CSharpDisableRuntimeMarshalling.Fixer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
3232
// We can't code fix if unsafe code isn't allowed.
3333
return;
3434
}
35+
3536
SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
3637

3738
SyntaxNode enclosingNode = root.FindNode(context.Span);
@@ -64,6 +65,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
6465
return i;
6566
}
6667
}
68+
6769
return 0;
6870
}
6971

@@ -102,6 +104,7 @@ private static bool TryRewriteMethodCall(SyntaxNode node, DocumentEditor editor,
102104
return true;
103105
}
104106
}
107+
105108
if (operation.TargetMethod.Name == "StructureToPtr" && operation.Arguments[0].Value.Type.IsUnmanagedType)
106109
{
107110
editor.ReplaceNode(syntax,
@@ -112,6 +115,7 @@ private static bool TryRewriteMethodCall(SyntaxNode node, DocumentEditor editor,
112115
operation.Arguments[0].Value.Syntax));
113116
return true;
114117
}
118+
115119
if (operation.TargetMethod.Name == "PtrToStructure")
116120
{
117121
ITypeSymbol type;
@@ -178,6 +182,7 @@ private static bool TryRewriteMethodCall(SyntaxNode node, DocumentEditor editor,
178182
{
179183
return false;
180184
}
185+
181186
editor.ReplaceNode(syntax, replacementNode);
182187
return true;
183188
}

src/NetAnalyzers/CSharp/Microsoft.NetCore.Analyzers/InteropServices/CSharpDynamicInterfaceCastableImplementation.Fixer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected override async Task<Document> ImplementInterfacesOnDynamicCastableImpl
7070
{
7171
return null;
7272
}
73+
7374
var methodDeclaration = generator.MethodDeclaration(method);
7475
methodDeclaration = generator.WithModifiers(methodDeclaration, generator.GetModifiers(methodDeclaration).WithIsAbstract(false));
7576
return generator.WithStatements(methodDeclaration, defaultMethodBodyStatements);
@@ -90,6 +91,7 @@ SyntaxNode GeneratePropertyImplementation(IPropertySymbol property)
9091
{
9192
propertyDeclaration = generator.WithGetAccessorStatements(propertyDeclaration, defaultMethodBodyStatements);
9293
}
94+
9395
if (property.SetMethod is not null
9496
&& model.Compilation.IsSymbolAccessibleWithin(property.SetMethod, type))
9597
{

0 commit comments

Comments
 (0)