Skip to content

Commit

Permalink
Merge pull request #47148 from Youssef1313/patch-15
Browse files Browse the repository at this point in the history
Enforce more code style in Compilers area
  • Loading branch information
msftbot[bot] authored Sep 10, 2020
2 parents 3183fa2 + 82c533d commit 0d6a84f
Show file tree
Hide file tree
Showing 303 changed files with 640 additions and 634 deletions.
24 changes: 12 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ dotnet_diagnostic.RS2008.severity = none
dotnet_diagnostic.IDE0073.severity = warning
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\nSee the LICENSE file in the project root for more information.

# IDE0035: Remove unreachable code
dotnet_diagnostic.IDE0035.severity = warning

# IDE0036: Order modifiers
dotnet_diagnostic.IDE0036.severity = warning

# IDE0043: Format string contains invalid placeholder
dotnet_diagnostic.IDE0043.severity = warning

# IDE0044: Make field readonly
dotnet_diagnostic.IDE0044.severity = warning

# CSharp code style settings:
[*.cs]
# Newline settings
Expand Down Expand Up @@ -232,21 +244,9 @@ csharp_prefer_braces = when_multiline:warning
# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201
dotnet_diagnostic.IDE0011.severity = warning

# IDE0035: Remove unreachable code
dotnet_diagnostic.IDE0035.severity = warning

# IDE0036: Order modifiers
dotnet_diagnostic.IDE0036.severity = warning

# IDE0040: Add accessibility modifiers
dotnet_diagnostic.IDE0040.severity = warning

# IDE0043: Format string contains invalid placeholder
dotnet_diagnostic.IDE0043.severity = warning

# IDE0044: Make field readonly
dotnet_diagnostic.IDE0044.severity = warning

# CONSIDER: Are IDE0051 and IDE0052 too noisy to be warnings for IDE editing scenarios? Should they be made build-only warnings?
# IDE0051: Remove unused private member
dotnet_diagnostic.IDE0051.severity = warning
Expand Down
6 changes: 3 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ private static void ReportReadonlyLocalError(SyntaxNode node, LocalSymbol local,
Error(diagnostics, ReadOnlyLocalErrors[index], node, local, cause.Localize());
}

static private ErrorCode GetThisLvalueError(BindValueKind kind, bool isValueType)
private static ErrorCode GetThisLvalueError(BindValueKind kind, bool isValueType)
{
switch (kind)
{
Expand Down Expand Up @@ -1717,7 +1717,7 @@ private static ErrorCode GetMethodGroupOrFunctionPointerLvalueError(BindValueKin
return ErrorCode.ERR_AssgReadonlyLocalCause;
}

static private ErrorCode GetStandardLvalueError(BindValueKind kind)
private static ErrorCode GetStandardLvalueError(BindValueKind kind)
{
switch (kind)
{
Expand Down Expand Up @@ -1750,7 +1750,7 @@ static private ErrorCode GetStandardLvalueError(BindValueKind kind)
throw ExceptionUtilities.UnexpectedValue(kind);
}

static private ErrorCode GetStandardRValueRefEscapeError(uint escapeTo)
private static ErrorCode GetStandardRValueRefEscapeError(uint escapeTo)
{
if (escapeTo == Binder.ExternalScope)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal bool IsEarlyAttributeBinder
/// <summary>
/// Get the next binder in which to look up a name, if not found by this binder.
/// </summary>
internal protected Binder? Next { get; }
protected internal Binder? Next { get; }

/// <summary>
/// <see cref="OverflowChecks.Enabled"/> if we are in an explicitly checked context (within checked block or expression).
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/CatchClauseBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public CatchClauseBinder(Binder enclosing, CatchClauseSyntax syntax)
_syntax = syntax;
}

override protected ImmutableArray<LocalSymbol> BuildLocals()
protected override ImmutableArray<LocalSymbol> BuildLocals()
{
var locals = ArrayBuilder<LocalSymbol>.GetInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public FixedStatementBinder(Binder enclosing, FixedStatementSyntax syntax)
_syntax = syntax;
}

override protected ImmutableArray<LocalSymbol> BuildLocals()
protected override ImmutableArray<LocalSymbol> BuildLocals()
{
if (_syntax.Declaration != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/ForLoopBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ForLoopBinder(Binder enclosing, ForStatementSyntax syntax)
_syntax = syntax;
}

override protected ImmutableArray<LocalSymbol> BuildLocals()
protected override ImmutableArray<LocalSymbol> BuildLocals()
{
var locals = ArrayBuilder<LocalSymbol>.GetInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal override ImmutableArray<LocalFunctionSymbol> GetDeclaredLocalFunctionsF
}

// Labels potentially shared across multiple ScriptLocalScopeBinder instances.
new internal sealed class Labels
internal new sealed class Labels
{
private readonly SynthesizedInteractiveInitializerMethod _scriptInitializer;
private readonly CompilationUnitSyntax _syntax;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal DeconstructionUncommonData(DeconstructMethodInfo deconstructMethodInfoO
DeconstructMethodInfo = deconstructMethodInfoOpt;
}

readonly internal DeconstructMethodInfo DeconstructMethodInfo;
internal readonly DeconstructMethodInfo DeconstructMethodInfo;
}

private Conversion(
Expand Down Expand Up @@ -1050,9 +1050,9 @@ internal DeconstructMethodInfo(BoundExpression invocation, BoundDeconstructValue
(Invocation, InputPlaceholder, OutputPlaceholders) = (invocation, inputPlaceholder, outputPlaceholders);
}

readonly internal BoundExpression Invocation;
readonly internal BoundDeconstructValuePlaceholder InputPlaceholder;
readonly internal ImmutableArray<BoundDeconstructValuePlaceholder> OutputPlaceholders;
internal readonly BoundExpression Invocation;
internal readonly BoundDeconstructValuePlaceholder InputPlaceholder;
internal readonly ImmutableArray<BoundDeconstructValuePlaceholder> OutputPlaceholders;
internal bool IsDefault => Invocation is null;
}
}
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/SwitchBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static Dictionary<object, SourceLabelSymbol> BuildLabelsByValue(Immutabl
return map;
}

override protected ImmutableArray<LocalSymbol> BuildLocals()
protected override ImmutableArray<LocalSymbol> BuildLocals()
{
var builder = ArrayBuilder<LocalSymbol>.GetInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public UsingStatementBinder(Binder enclosing, UsingStatementSyntax syntax)
_syntax = syntax;
}

override protected ImmutableArray<LocalSymbol> BuildLocals()
protected override ImmutableArray<LocalSymbol> BuildLocals()
{
ExpressionSyntax expressionSyntax = TargetExpressionSyntax;
VariableDeclarationSyntax declarationSyntax = _syntax.Declaration;
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/WhileBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal override BoundDoStatement BindDoParts(DiagnosticBag diagnostics, Binder
return new BoundDoStatement(node, this.Locals, condition, body, this.BreakLabel, this.ContinueLabel);
}

override protected ImmutableArray<LocalSymbol> BuildLocals()
protected override ImmutableArray<LocalSymbol> BuildLocals()
{
var locals = ArrayBuilder<LocalSymbol>.GetInstance();
ExpressionSyntax condition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal class Multiple : TupleBinaryOperatorInfo
{
internal readonly ImmutableArray<TupleBinaryOperatorInfo> Operators;

static internal readonly Multiple ErrorInstance =
internal static readonly Multiple ErrorInstance =
new Multiple(operators: ImmutableArray<TupleBinaryOperatorInfo>.Empty, leftConvertedTypeOpt: null, rightConvertedTypeOpt: null);

internal Multiple(ImmutableArray<TupleBinaryOperatorInfo> operators, TypeSymbol? leftConvertedTypeOpt, TypeSymbol? rightConvertedTypeOpt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CSharpCommandLineParser : CommandLineParser
public static CSharpCommandLineParser Default { get; } = new CSharpCommandLineParser();
public static CSharpCommandLineParser Script { get; } = new CSharpCommandLineParser(isScriptCommandLineParser: true);

private readonly static char[] s_quoteOrEquals = new[] { '"', '=' };
private static readonly char[] s_quoteOrEquals = new[] { '"', '=' };

internal CSharpCommandLineParser(bool isScriptCommandLineParser = false)
: base(CSharp.MessageProvider.Instance, isScriptCommandLineParser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private NamedTypeSymbol AttributeType
}
}

internal protected override CSharpSyntaxNode GetBindableSyntaxNode(CSharpSyntaxNode node)
protected internal override CSharpSyntaxNode GetBindableSyntaxNode(CSharpSyntaxNode node)
{
switch (node.Kind())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,7 @@ protected override INamedTypeSymbol CommonCreateNativeIntegerTypeSymbol(bool sig
return CreateNativeIntegerTypeSymbol(signed).GetPublicSymbol();
}

new internal NamedTypeSymbol CreateNativeIntegerTypeSymbol(bool signed)
internal new NamedTypeSymbol CreateNativeIntegerTypeSymbol(bool signed)
{
return GetSpecialType(signed ? SpecialType.System_IntPtr : SpecialType.System_UIntPtr).AsNativeInteger();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal static InitializerSemanticModel CreateSpeculative(SyntaxTreeSemanticMod
return new InitializerSemanticModel(syntax, owner, rootBinder, parentSemanticModelOpt: parentSemanticModel, parentRemappedSymbolsOpt: parentRemappedSymbolsOpt, speculatedPosition: position);
}

internal protected override CSharpSyntaxNode GetBindableSyntaxNode(CSharpSyntaxNode node)
protected internal override CSharpSyntaxNode GetBindableSyntaxNode(CSharpSyntaxNode node)
{
return IsBindableInitializer(node) ? node : base.GetBindableSyntaxNode(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ internal ImmutableArray<BoundNode> GetBoundNodes(CSharpSyntaxNode node)
}

// some nodes don't have direct semantic meaning by themselves and so we need to bind a different node that does
internal protected virtual CSharpSyntaxNode GetBindableSyntaxNode(CSharpSyntaxNode node)
protected internal virtual CSharpSyntaxNode GetBindableSyntaxNode(CSharpSyntaxNode node)
{
switch (node.Kind())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal partial class Symbol : Cci.IReference
/// Checks if this symbol is a definition and its containing module is a SourceModuleSymbol.
/// </summary>
[Conditional("DEBUG")]
internal protected void CheckDefinitionInvariant()
protected internal void CheckDefinitionInvariant()
{
// can't be generic instantiation
Debug.Assert(this.IsDefinition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ internal CSharpDiagnosticFormatter()
{
}

public new static CSharpDiagnosticFormatter Instance { get; } = new CSharpDiagnosticFormatter();
public static new CSharpDiagnosticFormatter Instance { get; } = new CSharpDiagnosticFormatter();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,7 @@ public override BoundNode VisitDeconstructionAssignmentOperator(BoundDeconstruct
return null;
}

public override sealed BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node)
public sealed override BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node)
{
// OutDeconstructVarPendingInference nodes are only used within initial binding, but don't survive past that stage
throw ExceptionUtilities.Unreachable;
Expand Down Expand Up @@ -3018,7 +3018,7 @@ public override BoundNode VisitAwaitableValuePlaceholder(BoundAwaitableValuePlac
return null;
}

public override sealed BoundNode VisitOutVariablePendingInference(OutVariablePendingInference node)
public sealed override BoundNode VisitOutVariablePendingInference(OutVariablePendingInference node)
{
throw ExceptionUtilities.Unreachable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ public override BoundNode VisitWhileStatement(BoundWhileStatement node)
return base.VisitWhileStatement(node);
}

override protected void EnterRegion()
protected override void EnterRegion()
{
base.EnterRegion();
}

override protected void LeaveRegion()
protected override void LeaveRegion()
{
foreach (var pending in PendingBranches)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override void EnterRegion()
base.EnterRegion();
}

override protected void LeaveRegion()
protected override void LeaveRegion()
{
_regionEndPointIsReachable = this.State.Alive;
base.LeaveRegion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ private void RemovePlaceholderReplacement(BoundValuePlaceholderBase placeholder)
Debug.Assert(removed);
}

public override sealed BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node)
public sealed override BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node)
{
// OutDeconstructVarPendingInference nodes are only used within initial binding, but don't survive past that stage
throw ExceptionUtilities.Unreachable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private BoundStatement InstrumentLocalDeclarationIfNecessary(BoundLocalDeclarati
return rewrittenLocalDeclaration;
}

public override sealed BoundNode VisitOutVariablePendingInference(OutVariablePendingInference node)
public sealed override BoundNode VisitOutVariablePendingInference(OutVariablePendingInference node)
{
throw ExceptionUtilities.Unreachable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public override BoundNode VisitBlock(BoundBlock node)
return node.Update(newLocals, newLocalFunctions, newStatements);
}

public override abstract BoundNode VisitScope(BoundScope node);
public abstract override BoundNode VisitScope(BoundScope node);

public override BoundNode VisitSequence(BoundSequence node)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public Interpolation(int openBracePosition, int colonPosition, int closeBracePos
/// Turn a (parsed) interpolated string nonterminal into an interpolated string token.
/// </summary>
/// <param name="interpolatedString"></param>
static internal SyntaxToken RescanInterpolatedString(InterpolatedStringExpressionSyntax interpolatedString)
internal static SyntaxToken RescanInterpolatedString(InterpolatedStringExpressionSyntax interpolatedString)
{
var text = interpolatedString.ToString();
var kind = SyntaxKind.InterpolatedStringToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ internal void DecodeSecurityAttribute<T>(Symbol targetSymbol, CSharpCompilation
}
}

static internal void DecodeSkipLocalsInitAttribute<T>(CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
internal static void DecodeSkipLocalsInitAttribute<T>(CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
where T : WellKnownAttributeData, ISkipLocalsInitAttributeTarget, new()
{
arguments.GetOrCreateData<T>().HasSkipLocalsInitAttribute = true;
Expand All @@ -253,7 +253,7 @@ static internal void DecodeSkipLocalsInitAttribute<T>(CSharpCompilation compilat
}
}

static internal void DecodeMemberNotNullAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
internal static void DecodeMemberNotNullAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
where T : WellKnownAttributeData, IMemberNotNullAttributeTarget, new()
{
var value = arguments.Attribute.CommonConstructorArguments[0];
Expand Down Expand Up @@ -303,7 +303,7 @@ private static void ReportBadNotNullMemberIfNeeded(TypeSymbol type, DecodeWellKn
arguments.Diagnostics.Add(ErrorCode.WRN_MemberNotNullBadMember, arguments.AttributeSyntaxOpt.Location, memberName);
}

static internal void DecodeMemberNotNullWhenAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
internal static void DecodeMemberNotNullWhenAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
where T : WellKnownAttributeData, IMemberNotNullAttributeTarget, new()
{
var value = arguments.Attribute.CommonConstructorArguments[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override SyntaxReference? ApplicationSyntaxReference
get { return null; }
}

internal protected override ImmutableArray<TypedConstant> CommonConstructorArguments
protected internal override ImmutableArray<TypedConstant> CommonConstructorArguments
{
get
{
Expand All @@ -63,7 +63,7 @@ internal protected override ImmutableArray<TypedConstant> CommonConstructorArgum
}
}

internal protected override ImmutableArray<KeyValuePair<string, TypedConstant>> CommonNamedArguments
protected internal override ImmutableArray<KeyValuePair<string, TypedConstant>> CommonNamedArguments
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ internal override bool HasErrors
}
}

internal protected sealed override ImmutableArray<TypedConstant> CommonConstructorArguments
protected internal sealed override ImmutableArray<TypedConstant> CommonConstructorArguments
{
get { return _constructorArguments; }
}

internal protected sealed override ImmutableArray<KeyValuePair<string, TypedConstant>> CommonNamedArguments
protected internal sealed override ImmutableArray<KeyValuePair<string, TypedConstant>> CommonNamedArguments
{
get { return _namedArguments; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override NamedTypeSymbol ConstructedFrom
get { return this; }
}

public override sealed bool AreLocalsZeroed
public sealed override bool AreLocalsZeroed
{
get { throw ExceptionUtilities.Unreachable; }
}
Expand Down Expand Up @@ -125,7 +125,7 @@ internal sealed override bool GetUnificationUseSiteDiagnosticRecursive(ref Diagn
return false;
}

public override sealed bool AreLocalsZeroed
public sealed override bool AreLocalsZeroed
{
get { throw ExceptionUtilities.Unreachable; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Symbols/EventSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal EventSymbol()
}
}

protected override sealed Symbol OriginalSymbolDefinition
protected sealed override Symbol OriginalSymbolDefinition
{
get
{
Expand Down
Loading

0 comments on commit 0d6a84f

Please sign in to comment.