Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CA1822 in Visual Studio layer #50569

Merged
merged 28 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e1e9fa4
Enable CA1822 in Visual Studio layer
Youssef1313 Jan 17, 2021
96b0f6d
Update .editorconfig
Youssef1313 Jan 17, 2021
3c4382c
Fix CA1822 - iteration 1
Youssef1313 Jan 18, 2021
012325b
Fix CA1822 - iteration 2
Youssef1313 Jan 18, 2021
bc63693
Fix CA1822 - iteration 3
Youssef1313 Jan 18, 2021
8bf9c81
Fix CA1822 - iteration 4
Youssef1313 Jan 18, 2021
376b670
Fix CA1822 - iteration 5
Youssef1313 Jan 18, 2021
ec7382b
Fix CA1822 - iteration 6
Youssef1313 Jan 18, 2021
f0ea7a3
Fix CA1822 - iteration 7
Youssef1313 Jan 18, 2021
99befa1
Fix CA1822 - iteration 8
Youssef1313 Jan 18, 2021
de87ad7
Fix CA1822 - iteration 9
Youssef1313 Jan 18, 2021
c768901
Fix CA1822 - iteration 10
Youssef1313 Jan 18, 2021
139a937
Fix CA1822 - iteration 11
Youssef1313 Jan 18, 2021
d1183c9
Fix CA1822 - iteration 12
Youssef1313 Jan 18, 2021
5120f0e
Fix CA1822 - iteration 13
Youssef1313 Jan 18, 2021
55a6db8
Fix CA1822 - iteration 14
Youssef1313 Jan 18, 2021
d476569
Fix CA1822 - iteration 15
Youssef1313 Jan 18, 2021
d09960c
Merge branch 'main' into patch-43
Youssef1313 Jan 14, 2022
2dddbbc
Remove redundant option
Youssef1313 Jan 14, 2022
2ce0f30
Resolve missing conflict
Youssef1313 Jan 14, 2022
e7ad72d
More fixes
Youssef1313 Jan 14, 2022
46d0e54
One more method
Youssef1313 Jan 15, 2022
fad6bfc
Update AbstractCodeCleanUpFixer.cs
Youssef1313 Jan 17, 2022
32d502a
Update CodeDefinitionWindow_InProc.cs
Youssef1313 Jan 18, 2022
a77a092
Update MoveStaticMembersViewModelTest.vb
Youssef1313 Jan 18, 2022
1dc81f8
Update InteractiveWindow_InProc.cs
Youssef1313 Jan 19, 2022
4cae7ce
Update MoveStaticMembersViewModelTest.vb
Youssef1313 Jan 19, 2022
defb193
Update AbstractPersistentStorageTests.cs
Youssef1313 Jan 19, 2022
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
5 changes: 2 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,5 @@ dotnet_diagnostic.IDE2004.severity = warning

[src/{VisualStudio}/**/*.{cs,vb}]
# CA1822: Make member static
# Not enforced as a build 'warning' for 'VisualStudio' layer due to large number of false positives from https://github.com/dotnet/roslyn-analyzers/issues/3857 and https://github.com/dotnet/roslyn-analyzers/issues/3858
# Additionally, there is a risk of accidentally breaking an internal API that partners rely on though IVT.
dotnet_diagnostic.CA1822.severity = suggestion
# There is a risk of accidentally breaking an internal API that partners rely on though IVT.
dotnet_code_quality.CA1822.api_surface = private
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CodeModelEventCollector(AbstractCodeModelService codeModelService)
{
}

private IReadOnlyList<MemberDeclarationSyntax> GetValidMembers(SyntaxNode node)
private static IReadOnlyList<MemberDeclarationSyntax> GetValidMembers(SyntaxNode node)
{
return CSharpCodeModelService
.GetChildMemberNodes(node)
Expand Down Expand Up @@ -708,10 +708,10 @@ private bool CompareBaseLists(BaseTypeDeclarationSyntax oldType, BaseTypeDeclara
return false;
}

private bool CompareModifiers(MemberDeclarationSyntax oldMember, MemberDeclarationSyntax newMember)
private static bool CompareModifiers(MemberDeclarationSyntax oldMember, MemberDeclarationSyntax newMember)
=> oldMember.GetModifierFlags() == newMember.GetModifierFlags();

private bool CompareModifiers(ParameterSyntax oldParameter, ParameterSyntax newParameter)
private static bool CompareModifiers(ParameterSyntax oldParameter, ParameterSyntax newParameter)
=> oldParameter.GetParameterFlags() == newParameter.GetParameterFlags();

private bool CompareNames(NameSyntax oldName, NameSyntax newName)
Expand Down Expand Up @@ -826,7 +826,7 @@ private bool CompareTypes(TypeSyntax oldType, TypeSyntax newType)
return false;
}

private TypeSyntax GetReturnType(BaseMethodDeclarationSyntax method)
private static TypeSyntax GetReturnType(BaseMethodDeclarationSyntax method)
{
if (method is MethodDeclarationSyntax methodDecl)
{
Expand Down Expand Up @@ -968,7 +968,7 @@ protected override void EnqueueRemoveEvent(SyntaxNode node, SyntaxNode parent, C
}
}

private void AddEventToEventQueueForAttributes(AttributeSyntax attribute, SyntaxNode parent, Action<SyntaxNode, SyntaxNode> enqueueAddOrRemoveEvent)
private static void AddEventToEventQueueForAttributes(AttributeSyntax attribute, SyntaxNode parent, Action<SyntaxNode, SyntaxNode> enqueueAddOrRemoveEvent)
{
if (parent is BaseFieldDeclarationSyntax baseField)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private class NodeLocator : AbstractNodeLocator
}
}

private VirtualTreePoint GetBodyStartPoint(SourceText text, SyntaxToken openBrace)
private static VirtualTreePoint GetBodyStartPoint(SourceText text, SyntaxToken openBrace)
{
Debug.Assert(!openBrace.IsMissing);

Expand Down Expand Up @@ -208,7 +208,7 @@ private VirtualTreePoint GetBodyStartPoint(SourceText text, OptionSet options, S
}
}

private VirtualTreePoint GetBodyEndPoint(SourceText text, SyntaxToken closeBrace)
private static VirtualTreePoint GetBodyEndPoint(SourceText text, SyntaxToken closeBrace)
{
var closeBraceLine = text.Lines.GetLineFromPosition(closeBrace.SpanStart);
var textBeforeBrace = text.ToString(TextSpan.FromBounds(closeBraceLine.Start, closeBrace.SpanStart));
Expand All @@ -218,7 +218,7 @@ private VirtualTreePoint GetBodyEndPoint(SourceText text, SyntaxToken closeBrace
: new VirtualTreePoint(closeBrace.SyntaxTree, text, closeBrace.SpanStart);
}

private VirtualTreePoint GetStartPoint(SourceText text, ArrowExpressionClauseSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, ArrowExpressionClauseSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand All @@ -239,7 +239,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, ArrowExpressionClauseSyn
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand Down Expand Up @@ -272,7 +272,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, AttributeSyntax node, En
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, AttributeArgumentSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, AttributeArgumentSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand Down Expand Up @@ -302,7 +302,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, AttributeArgumentSyntax
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, BaseTypeDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, BaseTypeDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand Down Expand Up @@ -429,7 +429,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, OptionSet options, BaseM
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private AccessorDeclarationSyntax FindFirstAccessorNode(BasePropertyDeclarationSyntax node)
private static AccessorDeclarationSyntax FindFirstAccessorNode(BasePropertyDeclarationSyntax node)
{
if (node.AccessorList == null)
{
Expand Down Expand Up @@ -553,7 +553,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, OptionSet options, Acces
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, BaseNamespaceDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, BaseNamespaceDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand Down Expand Up @@ -602,7 +602,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, BaseNamespaceDeclaration
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, DelegateDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, DelegateDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand Down Expand Up @@ -642,7 +642,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, DelegateDeclarationSynta
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, UsingDirectiveSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, UsingDirectiveSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand Down Expand Up @@ -675,7 +675,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, UsingDirectiveSyntax nod
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, VariableDeclaratorSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, VariableDeclaratorSyntax node, EnvDTE.vsCMPart part)
{
var field = node.FirstAncestorOrSelf<BaseFieldDeclarationSyntax>();
int startPosition;
Expand Down Expand Up @@ -716,7 +716,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, VariableDeclaratorSyntax
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, EnumMemberDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, EnumMemberDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand Down Expand Up @@ -756,7 +756,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, EnumMemberDeclarationSyn
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetStartPoint(SourceText text, ParameterSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetStartPoint(SourceText text, ParameterSyntax node, EnvDTE.vsCMPart part)
{
int startPosition;

Expand Down Expand Up @@ -796,7 +796,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, ParameterSyntax node, En
return new VirtualTreePoint(node.SyntaxTree, text, startPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, ArrowExpressionClauseSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, ArrowExpressionClauseSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand All @@ -814,7 +814,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, ArrowExpressionClauseSynta
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -847,7 +847,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, AttributeSyntax node, EnvD
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, AttributeArgumentSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, AttributeArgumentSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -877,7 +877,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, AttributeArgumentSyntax no
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, BaseTypeDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, BaseTypeDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -918,7 +918,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, BaseTypeDeclarationSyntax
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, BaseMethodDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, BaseMethodDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -992,7 +992,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, BaseMethodDeclarationSynta
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, BasePropertyDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, BasePropertyDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -1052,7 +1052,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, BasePropertyDeclarationSyn
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, AccessorDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, AccessorDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -1091,7 +1091,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, AccessorDeclarationSyntax
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, DelegateDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, DelegateDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -1132,7 +1132,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, DelegateDeclarationSyntax
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, BaseNamespaceDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, BaseNamespaceDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -1181,7 +1181,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, BaseNamespaceDeclarationSy
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, UsingDirectiveSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, UsingDirectiveSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -1214,7 +1214,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, UsingDirectiveSyntax node,
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, EnumMemberDeclarationSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, EnumMemberDeclarationSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down Expand Up @@ -1255,7 +1255,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, EnumMemberDeclarationSynta
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, VariableDeclaratorSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, VariableDeclaratorSyntax node, EnvDTE.vsCMPart part)
{
var field = node.FirstAncestorOrSelf<BaseFieldDeclarationSyntax>();
int endPosition;
Expand Down Expand Up @@ -1297,7 +1297,7 @@ private VirtualTreePoint GetEndPoint(SourceText text, VariableDeclaratorSyntax n
return new VirtualTreePoint(node.SyntaxTree, text, endPosition);
}

private VirtualTreePoint GetEndPoint(SourceText text, ParameterSyntax node, EnvDTE.vsCMPart part)
private static VirtualTreePoint GetEndPoint(SourceText text, ParameterSyntax node, EnvDTE.vsCMPart part)
{
int endPosition;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ public override SyntaxNode SetAccess(SyntaxNode node, EnvDTE.vsCMAccess newAcces
return member.UpdateModifiers(modifierFlags);
}

private IList<SyntaxTrivia> CollectComments(IList<SyntaxTrivia> triviaList)
private static IList<SyntaxTrivia> CollectComments(IList<SyntaxTrivia> triviaList)
{
var commentList = new List<SyntaxTrivia>();

Expand Down Expand Up @@ -2766,7 +2766,7 @@ private Document Delete(Document document, VariableDeclaratorSyntax node)
}
}

private Document Delete(Document document, EnumMemberDeclarationSyntax node)
private static Document Delete(Document document, EnumMemberDeclarationSyntax node)
{
var enumDeclaration = (EnumDeclarationSyntax)node.Parent!;
var members = enumDeclaration.Members;
Expand All @@ -2786,7 +2786,7 @@ private Document Delete(Document document, EnumMemberDeclarationSyntax node)
return document.ReplaceNodeSynchronously(enumDeclaration, newEnumDeclaration, CancellationToken.None);
}

private Document Delete(Document document, AttributeSyntax node)
private static Document Delete(Document document, AttributeSyntax node)
{
var attributeList = node.FirstAncestorOrSelf<AttributeListSyntax>();
Contract.ThrowIfNull(attributeList);
Expand All @@ -2813,7 +2813,7 @@ private Document Delete(Document document, AttributeSyntax node)
}
}

private Document Delete(Document document, AttributeArgumentSyntax node)
private static Document Delete(Document document, AttributeArgumentSyntax node)
{
var argumentList = node.FirstAncestorOrSelf<AttributeArgumentListSyntax>();
Contract.ThrowIfNull(argumentList);
Expand All @@ -2823,7 +2823,7 @@ private Document Delete(Document document, AttributeArgumentSyntax node)
return document.ReplaceNodeSynchronously(argumentList, newArgumentList, CancellationToken.None);
}

private Document Delete(Document document, ParameterSyntax node)
private static Document Delete(Document document, ParameterSyntax node)
{
var parameterList = node.FirstAncestorOrSelf<ParameterListSyntax>();
Contract.ThrowIfNull(parameterList);
Expand All @@ -2833,7 +2833,7 @@ private Document Delete(Document document, ParameterSyntax node)
return document.ReplaceNodeSynchronously(parameterList, newParameterList, CancellationToken.None);
}

private Document DeleteMember(Document document, SyntaxNode node)
private static Document DeleteMember(Document document, SyntaxNode node)
{
var text = document.GetTextSynchronously(CancellationToken.None);

Expand Down Expand Up @@ -3279,7 +3279,7 @@ private static MemberDeclarationSyntax GetMember(SyntaxNode container, int index
throw Exceptions.ThrowEFail();
}

private SyntaxNode EnsureAfterEndRegion(int index, SyntaxNode container)
private static SyntaxNode EnsureAfterEndRegion(int index, SyntaxNode container)
{
// If the next token after our member has only whitespace and #endregion as leading
// trivia, we'll move that to be leading trivia of our member.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private EndRegionFormattingRule()
{
}

private bool IsAfterEndRegionBeforeMethodDeclaration(SyntaxToken previousToken)
private static bool IsAfterEndRegionBeforeMethodDeclaration(SyntaxToken previousToken)
{
if (previousToken.Kind() == SyntaxKind.EndOfDirectiveToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private string TryGetText(SyntaxToken token, SemanticModel semanticModel, Docume
return string.Empty;
}

private bool TryGetTextForSpecialCharacters(SyntaxToken token, out string text)
private static bool TryGetTextForSpecialCharacters(SyntaxToken token, out string text)
{
if (token.IsKind(SyntaxKind.InterpolatedStringStartToken) ||
token.IsKind(SyntaxKind.InterpolatedStringEndToken) ||
Expand Down
Loading