From 958850c9972b36daece521ffb18316ff22ffd912 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 2 Jan 2020 10:31:23 -0800 Subject: [PATCH 01/50] Add FirstAncestorOrSelf extension with an argument --- ...stractRemoveUnusedValuesCodeFixProvider.cs | 5 ++- .../Syntax/InternalSyntaxNodeExtensions.cs | 45 +++++++++++++++++++ .../Core/Portable/Syntax/SyntaxNode.cs | 2 +- .../Core/Implementation/Peek/PeekHelpers.cs | 4 +- ...ntAccessExpressionSignatureHelpProvider.cs | 4 +- .../AbstractAddImportFeatureService.cs | 2 +- ...ymousTypeToClassCodeRefactoringProvider.cs | 2 +- ...vertAnonymousTypeToTupleCodeFixProvider.cs | 2 +- ...ertTupleToStructCodeRefactoringProvider.cs | 2 +- .../MethodExtractor.VariableSymbol.cs | 2 +- ...ddParameterCheckCodeRefactoringProvider.cs | 9 +++- ...tializeParameterCodeRefactoringProvider.cs | 9 +++- .../Finders/AbstractReferenceFinder.cs | 2 +- .../Core/CompilerExtensions.projitems | 1 + .../Core/Extensions/SyntaxEditorExtensions.cs | 14 +++--- 15 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 src/Compilers/Core/Portable/Syntax/InternalSyntaxNodeExtensions.cs diff --git a/src/Analyzers/Core/CodeFixes/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs index 3dd32c18c2cb7..26e6b709faaae 100644 --- a/src/Analyzers/Core/CodeFixes/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs +++ b/src/Analyzers/Core/CodeFixes/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs @@ -621,10 +621,11 @@ TLocalDeclarationStatementSyntax CreateLocalDeclarationStatement(ITypeSymbol typ void InsertLocalDeclarationStatement(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node) { // Find the correct place to insert the given declaration statement based on the node's ancestors. - var insertionNode = node.FirstAncestorOrSelf(n => n.Parent is TSwitchCaseBlockSyntax || + var insertionNode = node.FirstAncestorOrSelf((n, syntaxFacts) => n.Parent is TSwitchCaseBlockSyntax || syntaxFacts.IsExecutableBlock(n.Parent) && !(n is TCatchStatementSyntax) && - !(n is TCatchBlockSyntax)); + !(n is TCatchBlockSyntax), + syntaxFacts); if (insertionNode is TSwitchCaseLabelOrClauseSyntax) { InsertAtStartOfSwitchCaseBlockForDeclarationInCaseLabelOrClause(insertionNode.GetAncestor(), editor, declarationStatement); diff --git a/src/Compilers/Core/Portable/Syntax/InternalSyntaxNodeExtensions.cs b/src/Compilers/Core/Portable/Syntax/InternalSyntaxNodeExtensions.cs new file mode 100644 index 0000000000000..e37c50d69bd06 --- /dev/null +++ b/src/Compilers/Core/Portable/Syntax/InternalSyntaxNodeExtensions.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable enable + +using System; + +namespace Microsoft.CodeAnalysis +{ + internal static class InternalSyntaxNodeExtensions + { + /// + /// Gets the first node of type TNode that matches the predicate. + /// + internal static TNode? FirstAncestorOrSelf(this SyntaxNode? node, Func predicate, TArg argument, bool ascendOutOfTrivia = true) + where TNode : SyntaxNode + { + for (; node != null; node = GetParent(node, ascendOutOfTrivia)) + { + if (node is TNode tnode && predicate(tnode, argument)) + { + return tnode; + } + } + + return null; + } + + private static SyntaxNode? GetParent(SyntaxNode node, bool ascendOutOfTrivia) + { + var parent = node.Parent; + if (parent == null && ascendOutOfTrivia) + { + var structuredTrivia = node as IStructuredTriviaSyntax; + if (structuredTrivia != null) + { + parent = structuredTrivia.ParentTrivia.Token.Parent; + } + } + + return parent; + } + } +} diff --git a/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs b/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs index 61dd4eef3e2eb..b0ba90b0a9448 100644 --- a/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs +++ b/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs @@ -827,7 +827,7 @@ public SyntaxNode FindNode(TextSpan span, bool findInsideTrivia = false, bool ge var node = FindToken(span.Start, findInsideTrivia) .Parent - !.FirstAncestorOrSelf(a => a.FullSpan.Contains(span)); + !.FirstAncestorOrSelf((a, span) => a.FullSpan.Contains(span), span); RoslynDebug.Assert(node is object); SyntaxNode? cuRoot = node.SyntaxTree?.GetRoot(); diff --git a/src/EditorFeatures/Core/Implementation/Peek/PeekHelpers.cs b/src/EditorFeatures/Core/Implementation/Peek/PeekHelpers.cs index 3998b43262a76..d3a0051fc8ae6 100644 --- a/src/EditorFeatures/Core/Implementation/Peek/PeekHelpers.cs +++ b/src/EditorFeatures/Core/Implementation/Peek/PeekHelpers.cs @@ -56,12 +56,12 @@ internal static LinePositionSpan GetEntityOfInterestSpan(ISymbol symbol, Workspa case SymbolKind.Field: case SymbolKind.Method: case SymbolKind.Property: - node = node.FirstAncestorOrSelf(syntaxFactsService.IsMethodLevelMember) ?? node; + node = node.FirstAncestorOrSelf((node, syntaxFactsService) => syntaxFactsService.IsMethodLevelMember(node), syntaxFactsService) ?? node; break; case SymbolKind.NamedType: case SymbolKind.Namespace: - node = node.FirstAncestorOrSelf(syntaxFactsService.IsTopLevelNodeWithMembers) ?? node; + node = node.FirstAncestorOrSelf((node, syntaxFactsService) => syntaxFactsService.IsTopLevelNodeWithMembers(node), syntaxFactsService) ?? node; break; } diff --git a/src/Features/CSharp/Portable/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs index 7ec327592a623..03e14273acc84 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs @@ -386,8 +386,8 @@ internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsSer if (CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out ElementBindingExpressionSyntax elementBindingExpression)) { // Find the first conditional access expression that starts left of our open bracket - var conditionalAccess = elementBindingExpression.FirstAncestorOrSelf( - c => c.SpanStart < elementBindingExpression.SpanStart); + var conditionalAccess = elementBindingExpression.FirstAncestorOrSelf( + (c, elementBindingExpression) => c.SpanStart < elementBindingExpression.SpanStart, elementBindingExpression); identifier = conditionalAccess.Expression; openBrace = elementBindingExpression.ArgumentList.OpenBracketToken; diff --git a/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs b/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs index 6cde1ea387731..76a58283b2462 100644 --- a/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs +++ b/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs @@ -552,6 +552,6 @@ protected bool AncestorOrSelfIsAwaitExpression(ISyntaxFacts syntaxFactsService, => FirstAwaitExpressionAncestor(syntaxFactsService, node) != null; private SyntaxNode FirstAwaitExpressionAncestor(ISyntaxFacts syntaxFactsService, SyntaxNode node) - => node.FirstAncestorOrSelf(n => syntaxFactsService.IsAwaitExpression(n)); + => node.FirstAncestorOrSelf((n, syntaxFactsService) => syntaxFactsService.IsAwaitExpression(n), syntaxFactsService); } } diff --git a/src/Features/Core/Portable/ConvertAnonymousTypeToClass/AbstractConvertAnonymousTypeToClassCodeRefactoringProvider.cs b/src/Features/Core/Portable/ConvertAnonymousTypeToClass/AbstractConvertAnonymousTypeToClassCodeRefactoringProvider.cs index b28009c60ca9f..d1bbda2ba72bf 100644 --- a/src/Features/Core/Portable/ConvertAnonymousTypeToClass/AbstractConvertAnonymousTypeToClassCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/ConvertAnonymousTypeToClass/AbstractConvertAnonymousTypeToClassCodeRefactoringProvider.cs @@ -118,7 +118,7 @@ private async Task ConvertToClassAsync(Document document, TextSpan spa var editor = new SyntaxEditor(root, generator); var syntaxFacts = document.GetLanguageService(); - var containingMember = anonymousObject.FirstAncestorOrSelf(syntaxFacts.IsMethodLevelMember) ?? anonymousObject; + var containingMember = anonymousObject.FirstAncestorOrSelf((node, syntaxFacts) => syntaxFacts.IsMethodLevelMember(node), syntaxFacts) ?? anonymousObject; // Next, go and update any references to these anonymous type properties to match // the new PascalCased name we've picked for the new properties that will go in diff --git a/src/Features/Core/Portable/ConvertAnonymousTypeToTuple/AbstractConvertAnonymousTypeToTupleCodeFixProvider.cs b/src/Features/Core/Portable/ConvertAnonymousTypeToTuple/AbstractConvertAnonymousTypeToTupleCodeFixProvider.cs index 64ab0c076af7f..5fde95bdc094f 100644 --- a/src/Features/Core/Portable/ConvertAnonymousTypeToTuple/AbstractConvertAnonymousTypeToTupleCodeFixProvider.cs +++ b/src/Features/Core/Portable/ConvertAnonymousTypeToTuple/AbstractConvertAnonymousTypeToTupleCodeFixProvider.cs @@ -73,7 +73,7 @@ private async Task FixInCurrentMemberAsync( } var syntaxFacts = document.GetLanguageService(); - var containingMember = creationNode.FirstAncestorOrSelf(syntaxFacts.IsMethodLevelMember) ?? creationNode; + var containingMember = creationNode.FirstAncestorOrSelf((node, syntaxFacts) => syntaxFacts.IsMethodLevelMember(node), syntaxFacts) ?? creationNode; var childCreationNodes = containingMember.DescendantNodesAndSelf() .OfType(); diff --git a/src/Features/Core/Portable/ConvertTupleToStruct/AbstractConvertTupleToStructCodeRefactoringProvider.cs b/src/Features/Core/Portable/ConvertTupleToStruct/AbstractConvertTupleToStructCodeRefactoringProvider.cs index f2c9d744092ba..a0d5d8c7b370f 100644 --- a/src/Features/Core/Portable/ConvertTupleToStruct/AbstractConvertTupleToStructCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/ConvertTupleToStruct/AbstractConvertTupleToStructCodeRefactoringProvider.cs @@ -439,7 +439,7 @@ private static ImmutableArray GetDocumentsToUpdateForContainin Document document, SyntaxNode tupleExprOrTypeNode) { var syntaxFacts = document.GetLanguageService(); - var containingMember = tupleExprOrTypeNode.FirstAncestorOrSelf(syntaxFacts.IsMethodLevelMember) ?? tupleExprOrTypeNode; + var containingMember = tupleExprOrTypeNode.FirstAncestorOrSelf((node, syntaxFacts) => syntaxFacts.IsMethodLevelMember(node), syntaxFacts) ?? tupleExprOrTypeNode; return ImmutableArray.Create(new DocumentToUpdate( document, ImmutableArray.Create(containingMember))); diff --git a/src/Features/Core/Portable/ExtractMethod/MethodExtractor.VariableSymbol.cs b/src/Features/Core/Portable/ExtractMethod/MethodExtractor.VariableSymbol.cs index f9b746a9a40b0..4a81d381973c0 100644 --- a/src/Features/Core/Portable/ExtractMethod/MethodExtractor.VariableSymbol.cs +++ b/src/Features/Core/Portable/ExtractMethod/MethodExtractor.VariableSymbol.cs @@ -263,7 +263,7 @@ public override bool GetUseSaferDeclarationBehavior(CancellationToken cancellati return true; } - var declStatement = identifier.Parent.FirstAncestorOrSelf(n => true); + var declStatement = identifier.Parent.FirstAncestorOrSelf(); if (declStatement == null) { return true; diff --git a/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs b/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs index ded953ad1fb4a..4470884ccf45c 100644 --- a/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs @@ -36,6 +36,13 @@ internal abstract partial class AbstractAddParameterCheckCodeRefactoringProvider where TExpressionSyntax : SyntaxNode where TBinaryExpressionSyntax : TExpressionSyntax { + private readonly Func _isFunctionDeclarationFunc; + + protected AbstractAddParameterCheckCodeRefactoringProvider() + { + _isFunctionDeclarationFunc = IsFunctionDeclaration; + } + protected abstract bool CanOffer(SyntaxNode body); protected abstract bool PrefersThrowExpression(DocumentOptionSet options); @@ -116,7 +123,7 @@ private async Task UpdateDocumentForRefactoringAsync( var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var firstParameterNode = root.FindNode(parameterSpan) as TParameterSyntax; - var functionDeclaration = firstParameterNode.FirstAncestorOrSelf(IsFunctionDeclaration); + var functionDeclaration = firstParameterNode.FirstAncestorOrSelf(_isFunctionDeclarationFunc); var generator = SyntaxGenerator.GetGenerator(document); var parameterNodes = generator.GetParameters(functionDeclaration); diff --git a/src/Features/Core/Portable/InitializeParameter/AbstractInitializeParameterCodeRefactoringProvider.cs b/src/Features/Core/Portable/InitializeParameter/AbstractInitializeParameterCodeRefactoringProvider.cs index ac1be2bedb01f..ed7272651699f 100644 --- a/src/Features/Core/Portable/InitializeParameter/AbstractInitializeParameterCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/InitializeParameter/AbstractInitializeParameterCodeRefactoringProvider.cs @@ -31,6 +31,13 @@ internal abstract partial class AbstractInitializeParameterCodeRefactoringProvid where TStatementSyntax : SyntaxNode where TExpressionSyntax : SyntaxNode { + private readonly Func _isFunctionDeclarationFunc; + + protected AbstractInitializeParameterCodeRefactoringProvider() + { + _isFunctionDeclarationFunc = IsFunctionDeclaration; + } + protected abstract bool IsFunctionDeclaration(SyntaxNode node); protected abstract bool IsImplicitConversion(Compilation compilation, ITypeSymbol source, ITypeSymbol destination); @@ -70,7 +77,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte return; } - var functionDeclaration = selectedParameter.FirstAncestorOrSelf(IsFunctionDeclaration); + var functionDeclaration = selectedParameter.FirstAncestorOrSelf(_isFunctionDeclarationFunc); if (functionDeclaration is null) { return; diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs index f98f5709fc2be..95f5a89a92f22 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs @@ -573,7 +573,7 @@ TypeOrNamespaceUsageInfo GetTypeOrNamespaceUsageInfo() { usageInfo |= TypeOrNamespaceUsageInfo.NamespaceDeclaration; } - else if (node.FirstAncestorOrSelf(syntaxFacts.IsUsingOrExternOrImport) != null) + else if (node.FirstAncestorOrSelf((node, syntaxFacts) => syntaxFacts.IsUsingOrExternOrImport(node), syntaxFacts) != null) { usageInfo |= TypeOrNamespaceUsageInfo.Import; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 67ecd2919605d..63fdabf379945 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -34,6 +34,7 @@ + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxEditorExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxEditorExtensions.cs index fecb36c0ee232..591cbd0762a58 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxEditorExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxEditorExtensions.cs @@ -197,18 +197,20 @@ private static SyntaxNode GetExpressionSemanticBoundary(ISyntaxFactsService synt // single group keyed off the root of the tree. If more than one such node exists // in the document, all will be verified. // 2. Cannot include ArgumentSyntax because it could affect generic argument inference. - return node.FirstAncestorOrSelf( - n => syntaxFacts.IsExecutableStatement(n) || + return node.FirstAncestorOrSelf( + (n, syntaxFacts) => syntaxFacts.IsExecutableStatement(n) || syntaxFacts.IsParameter(n) || syntaxFacts.IsVariableDeclarator(n) || - n.Parent == null); + n.Parent == null, + syntaxFacts); } private static SyntaxNode GetMethodBodySemanticBoundary(ISyntaxFactsService syntaxFacts, SyntaxNode node) { - return node.FirstAncestorOrSelf( - n => syntaxFacts.IsMethodBody(n) || - n.Parent == null); + return node.FirstAncestorOrSelf( + (n, syntaxFacts) => syntaxFacts.IsMethodBody(n) || + n.Parent == null, + syntaxFacts); } } } From 94a090db579caa4b9aa557d98a0e3ccc690f2451 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 31 Dec 2019 23:01:58 -0800 Subject: [PATCH 02/50] Pool delegates for IsSupportedDiagnostic --- .../DiagnosticAnalyzer/AnalyzerExecutor.cs | 24 ++++++++++++------- ...osoft.CodeAnalysis.PooledObjects.projitems | 1 + .../PooledObjects}/PooledDelegates.cs | 0 .../Core/CompilerExtensions.projitems | 1 - 4 files changed, 17 insertions(+), 9 deletions(-) rename src/{Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools => Dependencies/PooledObjects}/PooledDelegates.cs (100%) diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs index 374341f146333..596f275c29ba1 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs @@ -372,7 +372,8 @@ public bool TryExecuteCompilationActions( private void ExecuteCompilationActionsCore(ImmutableArray compilationActions, DiagnosticAnalyzer analyzer, AnalyzerStateData analyzerStateOpt) { var addDiagnostic = GetAddCompilationDiagnostic(analyzer); - Func isSupportedDiagnostic = d => IsSupportedDiagnostic(analyzer, d); + + using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func isSupportedDiagnostic); foreach (var endAction in compilationActions) { @@ -456,7 +457,8 @@ private void ExecuteSymbolActionsCore( var symbol = symbolDeclaredEvent.Symbol; var addDiagnostic = GetAddDiagnostic(symbol, symbolDeclaredEvent.DeclaringSyntaxReferences, analyzer, getTopMostNodeForAnalysis); - Func isSupportedDiagnostic = d => IsSupportedDiagnostic(analyzer, d); + + using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func isSupportedDiagnostic); foreach (var symbolAction in symbolActions) { @@ -592,7 +594,8 @@ private void ExecuteSymbolEndActionsCore( var symbol = symbolDeclaredEvent.Symbol; var addDiagnostic = GetAddDiagnostic(symbol, symbolDeclaredEvent.DeclaringSyntaxReferences, analyzer, getTopMostNodeForAnalysis); - Func isSupportedDiagnostic = d => IsSupportedDiagnostic(analyzer, d); + + using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func isSupportedDiagnostic); foreach (var symbolAction in symbolEndActions) { @@ -672,7 +675,8 @@ private void ExecuteSemanticModelActionsCore( } var diagReporter = GetAddDiagnostic(semanticModel.SyntaxTree, analyzer, isSyntaxDiagnostic: false); - Func isSupportedDiagnostic = d => IsSupportedDiagnostic(analyzer, d); + + using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func isSupportedDiagnostic); foreach (var semanticModelAction in semanticModelActions) { @@ -751,7 +755,8 @@ private void ExecuteSyntaxTreeActionsCore( } var diagReporter = GetAddDiagnostic(tree, analyzer, isSyntaxDiagnostic: true); - Func isSupportedDiagnostic = d => IsSupportedDiagnostic(analyzer, d); + + using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func isSupportedDiagnostic); foreach (var syntaxTreeAction in syntaxTreeActions) { @@ -975,7 +980,6 @@ private void ExecuteBlockActionsCore isSupportedDiagnostic = d => IsSupportedDiagnostic(analyzer, d); try { @@ -1041,6 +1045,8 @@ private void ExecuteBlockActionsCore arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func isSupportedDiagnostic); + // Execute stateful executable node analyzers, if any. if (executableNodeActions.Any()) { @@ -1205,7 +1211,8 @@ private void ExecuteSyntaxNodeActionsCore( } var diagReporter = GetAddDiagnostic(model.SyntaxTree, filterSpan, analyzer, isSyntaxDiagnostic: false); - Func isSupportedDiagnostic = d => IsSupportedDiagnostic(analyzer, d); + + using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func isSupportedDiagnostic); ExecuteSyntaxNodeActions(nodesToAnalyze, nodeActionsByKind, analyzer, containingSymbol, model, getKind, diagReporter.AddDiagnosticAction, isSupportedDiagnostic, analyzerStateOpt); diagReporter.Free(); } @@ -1346,7 +1353,8 @@ private void ExecuteOperationActionsCore( } var diagReporter = GetAddDiagnostic(model.SyntaxTree, filterSpan, analyzer, isSyntaxDiagnostic: false); - Func isSupportedDiagnostic = d => IsSupportedDiagnostic(analyzer, d); + + using var _ = PooledDelegates.GetPooledFunction((d, arg) => arg.self.IsSupportedDiagnostic(arg.analyzer, d), (self: this, analyzer), out Func isSupportedDiagnostic); ExecuteOperationActions(operationsToAnalyze, operationActionsByKind, analyzer, containingSymbol, model, diagReporter.AddDiagnosticAction, isSupportedDiagnostic, analyzerStateOpt); diagReporter.Free(); } diff --git a/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.projitems b/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.projitems index b41a668ed18dc..92388f4a600f1 100644 --- a/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.projitems +++ b/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.projitems @@ -13,6 +13,7 @@ + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledDelegates.cs b/src/Dependencies/PooledObjects/PooledDelegates.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledDelegates.cs rename to src/Dependencies/PooledObjects/PooledDelegates.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 67ecd2919605d..8b753a865ec18 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -307,7 +307,6 @@ - From a734c1633aedb04d9ff5943d0c6477cc04a3283b Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 31 Mar 2020 15:54:26 -0700 Subject: [PATCH 03/50] Make Suppression implement IEquatable --- .../DiagnosticAnalyzer/Suppression.cs | 33 ++++++++++++++++++- .../Core/Portable/PublicAPI.Unshipped.txt | 5 +++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/Suppression.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/Suppression.cs index eb057bbe62a7e..07843bbf26700 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/Suppression.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/Suppression.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Diagnostics; namespace Microsoft.CodeAnalysis.Diagnostics @@ -10,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Diagnostics /// /// Programmatic suppression of a by a . /// - public struct Suppression + public struct Suppression : IEquatable { private Suppression(SuppressionDescriptor descriptor, Diagnostic suppressedDiagnostic) { @@ -48,5 +49,35 @@ public static Suppression Create(SuppressionDescriptor descriptor, Diagnostic su /// Diagnostic suppressed by this suppression. /// public Diagnostic SuppressedDiagnostic { get; } + + public static bool operator ==(Suppression left, Suppression right) + { + return left.Equals(right); + } + + public static bool operator !=(Suppression left, Suppression right) + { + return !(left == right); + } + + public override bool Equals(object obj) + { + return obj is Suppression suppression + && Equals(suppression); + } + + public bool Equals(Suppression other) + { + return EqualityComparer.Default.Equals(Descriptor, other.Descriptor) + && EqualityComparer.Default.Equals(SuppressedDiagnostic, other.SuppressedDiagnostic); + } + + public override int GetHashCode() + { + int hashCode = 1755072348; + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Descriptor); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(SuppressedDiagnostic); + return hashCode; + } } } diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 9eba7331187f2..2e5a46ab28b18 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -1,3 +1,8 @@ Microsoft.CodeAnalysis.CommandLineSourceFile.CommandLineSourceFile(string path, bool isScript, bool isInputRedirected) -> void Microsoft.CodeAnalysis.CommandLineSourceFile.IsInputRedirected.get -> bool +Microsoft.CodeAnalysis.Diagnostics.Suppression.Equals(Microsoft.CodeAnalysis.Diagnostics.Suppression other) -> bool const Microsoft.CodeAnalysis.WellKnownDiagnosticTags.CustomObsolete = "CustomObsolete" -> string +override Microsoft.CodeAnalysis.Diagnostics.Suppression.Equals(object obj) -> bool +override Microsoft.CodeAnalysis.Diagnostics.Suppression.GetHashCode() -> int +static Microsoft.CodeAnalysis.Diagnostics.Suppression.operator !=(Microsoft.CodeAnalysis.Diagnostics.Suppression left, Microsoft.CodeAnalysis.Diagnostics.Suppression right) -> bool +static Microsoft.CodeAnalysis.Diagnostics.Suppression.operator ==(Microsoft.CodeAnalysis.Diagnostics.Suppression left, Microsoft.CodeAnalysis.Diagnostics.Suppression right) -> bool From 4f0d7b1d4d79e882c47b5688a6448579565cd893 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 31 Mar 2020 15:58:47 -0700 Subject: [PATCH 04/50] Improve fast path for comparison of same instance --- .../CommonCompiler.SuppressionDiagnostic.cs | 10 +++++----- ...Diagnostic.DiagnosticWithProgrammaticSuppression.cs | 10 +++++----- .../Core/Portable/Diagnostic/DiagnosticDescriptor.cs | 5 +++++ .../Core/Portable/Diagnostic/DiagnosticWithInfo.cs | 2 +- .../Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs | 5 +++++ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/Compilers/Core/Portable/CommandLine/CommonCompiler.SuppressionDiagnostic.cs b/src/Compilers/Core/Portable/CommandLine/CommonCompiler.SuppressionDiagnostic.cs index dd2fe205ad0c8..401977bfd76b6 100644 --- a/src/Compilers/Core/Portable/CommandLine/CommonCompiler.SuppressionDiagnostic.cs +++ b/src/Compilers/Core/Portable/CommandLine/CommonCompiler.SuppressionDiagnostic.cs @@ -69,15 +69,15 @@ public override string GetMessage(IFormatProvider formatProvider = null) public override bool Equals(Diagnostic obj) { - var other = obj as SuppressionDiagnostic; - if (other == null) + if (ReferenceEquals(this, obj)) { - return false; + return true; } - if (ReferenceEquals(this, other)) + var other = obj as SuppressionDiagnostic; + if (other == null) { - return true; + return false; } return Equals(_originalDiagnostic, other._originalDiagnostic) && diff --git a/src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs b/src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs index eed63550dbc27..75c6af395ec26 100644 --- a/src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs +++ b/src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs @@ -87,15 +87,15 @@ public override ImmutableDictionary Properties public override bool Equals(Diagnostic? obj) { - var other = obj as DiagnosticWithProgrammaticSuppression; - if (other == null) + if (ReferenceEquals(this, obj)) { - return false; + return true; } - if (ReferenceEquals(this, other)) + var other = obj as DiagnosticWithProgrammaticSuppression; + if (other == null) { - return true; + return false; } return Equals(_originalUnsuppressedDiagnostic, other._originalUnsuppressedDiagnostic) && diff --git a/src/Compilers/Core/Portable/Diagnostic/DiagnosticDescriptor.cs b/src/Compilers/Core/Portable/Diagnostic/DiagnosticDescriptor.cs index c945e26eebbc6..5dab028d82387 100644 --- a/src/Compilers/Core/Portable/Diagnostic/DiagnosticDescriptor.cs +++ b/src/Compilers/Core/Portable/Diagnostic/DiagnosticDescriptor.cs @@ -173,6 +173,11 @@ internal DiagnosticDescriptor( public bool Equals(DiagnosticDescriptor? other) { + if (ReferenceEquals(this, other)) + { + return true; + } + return other != null && this.Category == other.Category && diff --git a/src/Compilers/Core/Portable/Diagnostic/DiagnosticWithInfo.cs b/src/Compilers/Core/Portable/Diagnostic/DiagnosticWithInfo.cs index 3863e82718e4d..d227221baeada 100644 --- a/src/Compilers/Core/Portable/Diagnostic/DiagnosticWithInfo.cs +++ b/src/Compilers/Core/Portable/Diagnostic/DiagnosticWithInfo.cs @@ -150,7 +150,7 @@ public override bool Equals(object? obj) public override bool Equals(Diagnostic? obj) { - if (this == obj) + if (ReferenceEquals(this, obj)) { return true; } diff --git a/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs b/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs index 1906545d14b9c..0abef2a8b0ed8 100644 --- a/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs +++ b/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs @@ -146,6 +146,11 @@ public override ImmutableDictionary Properties public override bool Equals(Diagnostic? obj) { + if (ReferenceEquals(this, obj)) + { + return true; + } + var other = obj as SimpleDiagnostic; if (other == null) { From afe5a491ba32d8fa7bacbf65c7e8dcf660104b85 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 31 Mar 2020 14:59:51 -0700 Subject: [PATCH 05/50] Remove duplicate target from Roslyn.Test.Utilities --- src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj index fef75f9c26d5b..a5095789aec03 100644 --- a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj +++ b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj @@ -4,7 +4,7 @@ Library true - netstandard2.0;$(RoslynPortableTargetFrameworks);net472 + netstandard2.0;$(RoslynPortableTargetFrameworks) false From 7b684e620611a18e3ad8a01e0a21fb5d65deb395 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 2 Apr 2020 08:28:30 -0700 Subject: [PATCH 06/50] Use Hash.Combine instead of the long form generated by the IDE --- .../Core/Portable/DiagnosticAnalyzer/Suppression.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/Suppression.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/Suppression.cs index 07843bbf26700..a32c2fc8dbf04 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/Suppression.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/Suppression.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Diagnostics { @@ -74,10 +75,9 @@ public bool Equals(Suppression other) public override int GetHashCode() { - int hashCode = 1755072348; - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Descriptor); - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(SuppressedDiagnostic); - return hashCode; + return Hash.Combine( + EqualityComparer.Default.GetHashCode(Descriptor), + EqualityComparer.Default.GetHashCode(SuppressedDiagnostic)); } } } From 44d50e278ebf3c6b26376409f535bd21f8a84242 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Thu, 2 Apr 2020 09:00:24 -0700 Subject: [PATCH 07/50] Port UseCompoundAssignment to shared layer --- src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems | 3 +++ .../CSharpUseCompoundAssignmentDiagnosticAnalyzer.cs | 0 .../CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs | 2 +- .../CSharp/Analyzers}/UseCompoundAssignment/Utilities.cs | 0 src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems | 2 ++ .../CSharpUseCompoundAssignmentCodeFixProvider.cs | 0 .../CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs | 4 ++-- .../CSharp/Tests/CSharpAnalyzers.UnitTests.projitems | 2 ++ .../UseCompoundAssignment/UseCompoundAssignmentTests.cs | 0 .../UseCompoundCoalesceAssignmentTests.cs | 0 src/Analyzers/Core/Analyzers/Analyzers.projitems | 2 ++ .../AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs | 2 +- .../UseCompoundAssignment/UseCompoundAssignmentUtilities.cs | 0 src/Analyzers/Core/CodeFixes/CodeFixes.projitems | 1 + .../AbstractUseCompoundAssignmentCodeFixProvider.cs | 4 ++-- .../VisualBasic/Analyzers}/UseCompoundAssignment/Utilities.vb | 0 .../VisualBasicUseCompoundAssignmentDiagnosticAnalyzer.vb | 0 .../VisualBasic/Analyzers/VisualBasicAnalyzers.projitems | 2 ++ .../VisualBasicUseCompoundAssignmentCodeFixProvider.vb | 0 .../VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems | 1 + .../UseCompoundAssignment/UseCompoundAssignmentTests.vb | 0 .../Tests/VisualBasicAnalyzers.UnitTests.projitems | 1 + 22 files changed, 20 insertions(+), 6 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/UseCompoundAssignment/CSharpUseCompoundAssignmentDiagnosticAnalyzer.cs (100%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (95%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/UseCompoundAssignment/Utilities.cs (100%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/UseCompoundAssignment/CSharpUseCompoundAssignmentCodeFixProvider.cs (100%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (95%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/UseCompoundAssignment/UseCompoundAssignmentTests.cs (100%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/UseCompoundAssignment/UseCompoundCoalesceAssignmentTests.cs (100%) rename src/{Features/Core/Portable => Analyzers/Core/Analyzers}/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs (97%) rename src/{Features/Core/Portable => Analyzers/Core/Analyzers}/UseCompoundAssignment/UseCompoundAssignmentUtilities.cs (100%) rename src/{Features/Core/Portable => Analyzers/Core/CodeFixes}/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs (95%) rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/Analyzers}/UseCompoundAssignment/Utilities.vb (100%) rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/Analyzers}/UseCompoundAssignment/VisualBasicUseCompoundAssignmentDiagnosticAnalyzer.vb (100%) rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/CodeFixes}/UseCompoundAssignment/VisualBasicUseCompoundAssignmentCodeFixProvider.vb (100%) rename src/{EditorFeatures/VisualBasicTest => Analyzers/VisualBasic/Tests}/UseCompoundAssignment/UseCompoundAssignmentTests.vb (100%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index c177df4bb9932..f30a9d20951f3 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -32,6 +32,9 @@ + + + diff --git a/src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundAssignmentDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundAssignmentDiagnosticAnalyzer.cs similarity index 100% rename from src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundAssignmentDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundAssignmentDiagnosticAnalyzer.cs diff --git a/src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs similarity index 95% rename from src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs index 2ad0a70ef9b6e..a0dffafcae225 100644 --- a/src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs @@ -22,7 +22,7 @@ internal class CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer public CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseCoalesceCompoundAssignmentDiagnosticId, CodeStyleOptions2.PreferCompoundAssignment, - new LocalizableResourceString(nameof(FeaturesResources.Use_compound_assignment), FeaturesResources.ResourceManager, typeof(FeaturesResources))) + new LocalizableResourceString(nameof(AnalyzersResources.Use_compound_assignment), AnalyzersResources.ResourceManager, typeof(AnalyzersResources))) { } diff --git a/src/Features/CSharp/Portable/UseCompoundAssignment/Utilities.cs b/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/Utilities.cs similarity index 100% rename from src/Features/CSharp/Portable/UseCompoundAssignment/Utilities.cs rename to src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/Utilities.cs diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index f678c2b44c163..0f9c513c9fe9b 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -30,6 +30,8 @@ + + diff --git a/src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundAssignmentCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCompoundAssignment/CSharpUseCompoundAssignmentCodeFixProvider.cs similarity index 100% rename from src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundAssignmentCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/UseCompoundAssignment/CSharpUseCompoundAssignmentCodeFixProvider.cs diff --git a/src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs similarity index 95% rename from src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs index 66155919adf6d..af0a3cd5fccdf 100644 --- a/src/Features/CSharp/Portable/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs @@ -88,10 +88,10 @@ protected override async Task FixAllAsync( } } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(FeaturesResources.Use_compound_assignment, createChangedDocument, FeaturesResources.Use_compound_assignment) + : base(AnalyzersResources.Use_compound_assignment, createChangedDocument, AnalyzersResources.Use_compound_assignment) { } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index 2876688be1b46..0088a4ae5ab6b 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -19,6 +19,8 @@ + + diff --git a/src/EditorFeatures/CSharpTest/UseCompoundAssignment/UseCompoundAssignmentTests.cs b/src/Analyzers/CSharp/Tests/UseCompoundAssignment/UseCompoundAssignmentTests.cs similarity index 100% rename from src/EditorFeatures/CSharpTest/UseCompoundAssignment/UseCompoundAssignmentTests.cs rename to src/Analyzers/CSharp/Tests/UseCompoundAssignment/UseCompoundAssignmentTests.cs diff --git a/src/EditorFeatures/CSharpTest/UseCompoundAssignment/UseCompoundCoalesceAssignmentTests.cs b/src/Analyzers/CSharp/Tests/UseCompoundAssignment/UseCompoundCoalesceAssignmentTests.cs similarity index 100% rename from src/EditorFeatures/CSharpTest/UseCompoundAssignment/UseCompoundCoalesceAssignmentTests.cs rename to src/Analyzers/CSharp/Tests/UseCompoundAssignment/UseCompoundCoalesceAssignmentTests.cs diff --git a/src/Analyzers/Core/Analyzers/Analyzers.projitems b/src/Analyzers/Core/Analyzers/Analyzers.projitems index 668c1a24c11ec..c2033ec2b0fb7 100644 --- a/src/Analyzers/Core/Analyzers/Analyzers.projitems +++ b/src/Analyzers/Core/Analyzers/Analyzers.projitems @@ -51,6 +51,8 @@ + + diff --git a/src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs similarity index 97% rename from src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs rename to src/Analyzers/Core/Analyzers/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs index bd7618bd813c7..37dcecdf89d11 100644 --- a/src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs @@ -40,7 +40,7 @@ protected AbstractUseCompoundAssignmentDiagnosticAnalyzer( : base(IDEDiagnosticIds.UseCompoundAssignmentDiagnosticId, CodeStyleOptions2.PreferCompoundAssignment, new LocalizableResourceString( - nameof(FeaturesResources.Use_compound_assignment), FeaturesResources.ResourceManager, typeof(FeaturesResources))) + nameof(AnalyzersResources.Use_compound_assignment), AnalyzersResources.ResourceManager, typeof(AnalyzersResources))) { _syntaxFacts = syntaxFacts; UseCompoundAssignmentUtilities.GenerateMaps(kinds, out _binaryToAssignmentMap, out _assignmentToTokenMap); diff --git a/src/Features/Core/Portable/UseCompoundAssignment/UseCompoundAssignmentUtilities.cs b/src/Analyzers/Core/Analyzers/UseCompoundAssignment/UseCompoundAssignmentUtilities.cs similarity index 100% rename from src/Features/Core/Portable/UseCompoundAssignment/UseCompoundAssignmentUtilities.cs rename to src/Analyzers/Core/Analyzers/UseCompoundAssignment/UseCompoundAssignmentUtilities.cs diff --git a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems index 819db58fd44cf..a46ca1c85f30a 100644 --- a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems +++ b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems @@ -31,6 +31,7 @@ + diff --git a/src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs similarity index 95% rename from src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs rename to src/Analyzers/Core/CodeFixes/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs index a2674ddf303f3..d281b3851a9f3 100644 --- a/src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs +++ b/src/Analyzers/Core/CodeFixes/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs @@ -92,10 +92,10 @@ protected override Task FixAllAsync( return Task.CompletedTask; } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(FeaturesResources.Use_compound_assignment, createChangedDocument, FeaturesResources.Use_compound_assignment) + : base(AnalyzersResources.Use_compound_assignment, createChangedDocument, AnalyzersResources.Use_compound_assignment) { } } diff --git a/src/Features/VisualBasic/Portable/UseCompoundAssignment/Utilities.vb b/src/Analyzers/VisualBasic/Analyzers/UseCompoundAssignment/Utilities.vb similarity index 100% rename from src/Features/VisualBasic/Portable/UseCompoundAssignment/Utilities.vb rename to src/Analyzers/VisualBasic/Analyzers/UseCompoundAssignment/Utilities.vb diff --git a/src/Features/VisualBasic/Portable/UseCompoundAssignment/VisualBasicUseCompoundAssignmentDiagnosticAnalyzer.vb b/src/Analyzers/VisualBasic/Analyzers/UseCompoundAssignment/VisualBasicUseCompoundAssignmentDiagnosticAnalyzer.vb similarity index 100% rename from src/Features/VisualBasic/Portable/UseCompoundAssignment/VisualBasicUseCompoundAssignmentDiagnosticAnalyzer.vb rename to src/Analyzers/VisualBasic/Analyzers/UseCompoundAssignment/VisualBasicUseCompoundAssignmentDiagnosticAnalyzer.vb diff --git a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems index 865cb48bbbc24..bfcb7d366177d 100644 --- a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems +++ b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems @@ -30,6 +30,8 @@ + + diff --git a/src/Features/VisualBasic/Portable/UseCompoundAssignment/VisualBasicUseCompoundAssignmentCodeFixProvider.vb b/src/Analyzers/VisualBasic/CodeFixes/UseCompoundAssignment/VisualBasicUseCompoundAssignmentCodeFixProvider.vb similarity index 100% rename from src/Features/VisualBasic/Portable/UseCompoundAssignment/VisualBasicUseCompoundAssignmentCodeFixProvider.vb rename to src/Analyzers/VisualBasic/CodeFixes/UseCompoundAssignment/VisualBasicUseCompoundAssignmentCodeFixProvider.vb diff --git a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems index ce344f5151817..d3acb9fabc560 100644 --- a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems +++ b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems @@ -25,6 +25,7 @@ + diff --git a/src/EditorFeatures/VisualBasicTest/UseCompoundAssignment/UseCompoundAssignmentTests.vb b/src/Analyzers/VisualBasic/Tests/UseCompoundAssignment/UseCompoundAssignmentTests.vb similarity index 100% rename from src/EditorFeatures/VisualBasicTest/UseCompoundAssignment/UseCompoundAssignmentTests.vb rename to src/Analyzers/VisualBasic/Tests/UseCompoundAssignment/UseCompoundAssignmentTests.vb diff --git a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems index 24c92c4812e67..96b17d03fc111 100644 --- a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems +++ b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems @@ -32,6 +32,7 @@ + From 09b00d6e8b15b35f5566d14f9e11689fe5be5cff Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Thu, 2 Apr 2020 09:00:36 -0700 Subject: [PATCH 08/50] xlf and resx file changes --- src/Analyzers/Core/Analyzers/AnalyzersResources.resx | 3 +++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf | 5 +++++ .../Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf | 5 +++++ .../Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf | 5 +++++ .../Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf | 5 +++++ src/Features/Core/Portable/FeaturesResources.resx | 3 --- src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.de.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.es.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.it.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 5 ----- 28 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/Analyzers/Core/Analyzers/AnalyzersResources.resx b/src/Analyzers/Core/Analyzers/AnalyzersResources.resx index 28566b0f5eaaf..9aeee3884875d 100644 --- a/src/Analyzers/Core/Analyzers/AnalyzersResources.resx +++ b/src/Analyzers/Core/Analyzers/AnalyzersResources.resx @@ -265,6 +265,9 @@ Use explicitly provided tuple name + + Use compound assignment + Use null propagation diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf index 28f0b5aeefa2a..5569d0997677e 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf index a83d6c66a28ce..69e70239046ac 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf index 93dff970b9fa3..3080fdefca713 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf index 31756ea330f88..578ce56ec4b9e 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf index 0954499cead21..51a33e3820b55 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf index c0d48edf2eff6..c795230916e64 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf index b10798b88e5c4..c3229f5990c12 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf index 71136759fac19..5057f683909ac 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf index f06a67e6df2e9..9221c79b48b15 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf index eaa43720bdf82..4ad7c47100ee8 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf index a548884b42277..ee118c2f42b04 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf index 162db2c21540a..22e64a2f9baa5 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf index ff3a99bcd4d4d..8cd8cc8cb6c92 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf @@ -247,6 +247,11 @@ Use coalesce expression + + Use compound assignment + Use compound assignment + + Use explicitly provided tuple name Use explicitly provided tuple name diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 35c42ed39baaf..063983d2a1b62 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -1249,9 +1249,6 @@ This version used in: {2} Warning: Changing namespace may produce invalid code and change code meaning. - - Use compound assignment - Invert conditional diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index 68188b2257934..d53e36f6d7b62 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -617,11 +617,6 @@ Pro lambda výrazy používat text bloku - - Use compound assignment - Použít složené přiřazení - - Use expression body for lambda expressions Používat text výrazu pro lambda výrazy diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 5f1ee650e7644..8d1a11de808f9 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -617,11 +617,6 @@ Blocktextkörper für Lambdaausdrücke verwenden - - Use compound assignment - Verbundzuweisung verwenden - - Use expression body for lambda expressions Ausdruckskörper für Lambdaausdrücke verwenden diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index c4f26bcfac2ae..5bad79fc51012 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -617,11 +617,6 @@ Usar cuerpo del bloque para las expresiones lambda - - Use compound assignment - Usar la asignación compuesta - - Use expression body for lambda expressions Usar órgano de expresión para expresiones lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 1b6f29dee0a31..61b29c46b12c1 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -617,11 +617,6 @@ Utiliser le corps de bloc pour les expressions lambda - - Use compound assignment - Utiliser une assignation composée - - Use expression body for lambda expressions Utiliser le corps d'expression pour les expressions lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index 6eadcded8aa4f..8bff51c06a4d2 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -617,11 +617,6 @@ Usa il corpo del blocco per le espressioni lambda - - Use compound assignment - Usa l'assegnazione composta - - Use expression body for lambda expressions Usa il corpo dell'espressione per le espressioni lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index 6a48ee1f0d8dc..8dd143a2c7642 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -617,11 +617,6 @@ ラムダ式にブロック本体を使用する - - Use compound assignment - 複合代入を使用 - - Use expression body for lambda expressions ラムダ式に式本体を使用する diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 392577a31e26b..0f0a197ae5a5a 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -617,11 +617,6 @@ 람다 식에 블록 본문 사용 - - Use compound assignment - 복합형 할당 사용 - - Use expression body for lambda expressions 람다 식에 식 본문 사용 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 4a5920a62ef66..d386050c7cb31 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -617,11 +617,6 @@ Użyj treści bloku dla wyrażeń lambda - - Use compound assignment - Użyj przypisania złożonego - - Use expression body for lambda expressions Użyj treści wyrażenia dla wyrażeń lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 55876d72d036c..5a323d248ee2b 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -617,11 +617,6 @@ Usar o corpo do bloco para expressões lambda - - Use compound assignment - Usar a atribuição composta - - Use expression body for lambda expressions Usar corpo da expressão para expressões lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 56261889a2638..6293224dc9f2d 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -617,11 +617,6 @@ Использовать тело блока для лямбда-выражений - - Use compound assignment - Использовать составной оператор назначения - - Use expression body for lambda expressions Использовать тело выражения для лямбда-выражений diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 90be018d507be..377b25a8ffdfc 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -617,11 +617,6 @@ Lambda ifadeleri için blok vücut kullanımı - - Use compound assignment - Bileşik atama kullan - - Use expression body for lambda expressions Lambda ifadeleri için ifade vücut kullanımı diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index a58fae0cb39a9..f65462344595d 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -617,11 +617,6 @@ 对 lambda 表达式使用块主体 - - Use compound assignment - 使用复合分配 - - Use expression body for lambda expressions 对 lambda 表达式使用表达式正文 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index d8164a31c97fb..ef92e273094c5 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -617,11 +617,6 @@ 使用 Lambda 運算式的區塊主體 - - Use compound assignment - 使用複合指派 - - Use expression body for lambda expressions 使用 Lambda 運算式的運算式主體 From 06e707a37035a31f2a1ae3373a1c30ebdcdea6c2 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 31 Mar 2020 16:19:23 -0700 Subject: [PATCH 09/50] Move FirstAncestorOrSelf to SyntaxNode --- .../CodeStyleSyntaxNodeExtensions.cs} | 7 ++++++- .../Core/Portable/PublicAPI.Unshipped.txt | 3 ++- .../Core/Portable/Syntax/SyntaxNode.cs | 19 +++++++++++++++++++ .../Core/CompilerExtensions.projitems | 1 - 4 files changed, 27 insertions(+), 3 deletions(-) rename src/{Compilers/Core/Portable/Syntax/InternalSyntaxNodeExtensions.cs => CodeStyle/Core/Analyzers/Extensions/CodeStyleSyntaxNodeExtensions.cs} (76%) diff --git a/src/Compilers/Core/Portable/Syntax/InternalSyntaxNodeExtensions.cs b/src/CodeStyle/Core/Analyzers/Extensions/CodeStyleSyntaxNodeExtensions.cs similarity index 76% rename from src/Compilers/Core/Portable/Syntax/InternalSyntaxNodeExtensions.cs rename to src/CodeStyle/Core/Analyzers/Extensions/CodeStyleSyntaxNodeExtensions.cs index e37c50d69bd06..f70a3fdeb7a5c 100644 --- a/src/Compilers/Core/Portable/Syntax/InternalSyntaxNodeExtensions.cs +++ b/src/CodeStyle/Core/Analyzers/Extensions/CodeStyleSyntaxNodeExtensions.cs @@ -8,11 +8,16 @@ namespace Microsoft.CodeAnalysis { - internal static class InternalSyntaxNodeExtensions + internal static class CodeStyleSyntaxNodeExtensions { /// /// Gets the first node of type TNode that matches the predicate. /// + /// + /// This method was added to as a public API. This extension method can be removed once + /// the code style layer is updated to reference a version of Roslyn that includes it. It will be easy to + /// identify since this method will show 0 references once the switch occurs. + /// internal static TNode? FirstAncestorOrSelf(this SyntaxNode? node, Func predicate, TArg argument, bool ascendOutOfTrivia = true) where TNode : SyntaxNode { diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 1d57d1cc953f8..b2a83c2dfabfd 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -1,2 +1,3 @@ Microsoft.CodeAnalysis.CommandLineSourceFile.CommandLineSourceFile(string path, bool isScript, bool isInputRedirected) -> void -Microsoft.CodeAnalysis.CommandLineSourceFile.IsInputRedirected.get -> bool \ No newline at end of file +Microsoft.CodeAnalysis.CommandLineSourceFile.IsInputRedirected.get -> bool +Microsoft.CodeAnalysis.SyntaxNode.FirstAncestorOrSelf(System.Func predicate, TArg argument, bool ascendOutOfTrivia = true) -> TNode diff --git a/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs b/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs index b0ba90b0a9448..dcb0373fbca43 100644 --- a/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs +++ b/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Text; @@ -724,6 +725,24 @@ public IEnumerable AncestorsAndSelf(bool ascendOutOfTrivia = true) return null; } + /// + /// Gets the first node of type TNode that matches the predicate. + /// + [SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required for consistent API usage patterns.")] + public TNode? FirstAncestorOrSelf(Func predicate, TArg argument, bool ascendOutOfTrivia = true) + where TNode : SyntaxNode + { + for (var node = this; node != null; node = GetParent(node, ascendOutOfTrivia)) + { + if (node is TNode tnode && predicate(tnode, argument)) + { + return tnode; + } + } + + return null; + } + /// /// Gets a list of descendant nodes in prefix document order. /// diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 63fdabf379945..67ecd2919605d 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -34,7 +34,6 @@ - From 6e1c37cdd0d596b4e5d4ca4ee309572aa1b5f6a4 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 2 Apr 2020 12:46:53 -0700 Subject: [PATCH 10/50] Move away from IEnumerables in core rename results. --- .../CSharpRenameRewriterLanguageService.cs | 23 +++---- .../Rename/ConflictEngine/ConflictResolver.cs | 18 ------ .../Rename/IRenameRewriterLanguageService.cs | 34 ++++++++++ .../RenameLocation.ReferenceProcessing.cs | 26 ++++---- .../Core/Portable/Rename/RenameLocations.cs | 62 ++++++++++--------- .../Core/Portable/Rename/Renamer.cs | 5 +- ...isualBasicRenameRewriterLanguageService.vb | 28 ++++----- 7 files changed, 110 insertions(+), 86 deletions(-) diff --git a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs index 4249cfd6eaf0b..ab4d6adef547b 100644 --- a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs +++ b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs @@ -11,7 +11,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Simplification; using Microsoft.CodeAnalysis.CSharp.Symbols; @@ -19,10 +18,8 @@ using Microsoft.CodeAnalysis.CSharp.Utilities; using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.FindSymbols; -using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServices; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Rename; using Microsoft.CodeAnalysis.Rename.ConflictEngine; @@ -34,7 +31,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Rename { [ExportLanguageService(typeof(IRenameRewriterLanguageService), LanguageNames.CSharp), Shared] - internal class CSharpRenameConflictLanguageService : IRenameRewriterLanguageService + internal class CSharpRenameConflictLanguageService : AbstractRenameRewriterLanguageService { [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] @@ -43,7 +40,7 @@ public CSharpRenameConflictLanguageService() } #region "Annotation" - public SyntaxNode AnnotateAndRename(RenameRewriterParameters parameters) + public override SyntaxNode AnnotateAndRename(RenameRewriterParameters parameters) { var renameAnnotationRewriter = new RenameRewriter(parameters); return renameAnnotationRewriter.Visit(parameters.SyntaxRoot); @@ -727,7 +724,7 @@ private SyntaxToken RenameWithinToken(SyntaxToken oldToken, SyntaxToken newToken #region "Declaration Conflicts" - public bool LocalVariableConflict( + public override bool LocalVariableConflict( SyntaxToken token, IEnumerable newReferencedSymbols) { @@ -767,7 +764,7 @@ public bool LocalVariableConflict( return false; } - public async Task> ComputeDeclarationConflictsAsync( + public override async Task> ComputeDeclarationConflictsAsync( string replacementText, ISymbol renamedSymbol, ISymbol renameSymbol, @@ -852,7 +849,7 @@ renamedSymbol.ContainingSymbol is IMethodSymbol methodSymbol && } } - ConflictResolver.AddConflictingParametersOfProperties( + AddConflictingParametersOfProperties( properties.Distinct(), replacementText, conflicts); } else if (renamedSymbol.Kind == SymbolKind.Alias) @@ -974,7 +971,7 @@ private void AddSymbolSourceSpans( } } - public async Task> ComputeImplicitReferenceConflictsAsync( + public override async Task> ComputeImplicitReferenceConflictsAsync( ISymbol renameSymbol, ISymbol renamedSymbol, IEnumerable implicitReferenceLocations, CancellationToken cancellationToken) { // Handle renaming of symbols used for foreach @@ -1019,7 +1016,7 @@ public async Task> ComputeImplicitReferenceConflictsAsy return ImmutableArray.Empty; } - public ImmutableArray ComputePossibleImplicitUsageConflicts( + public override ImmutableArray ComputePossibleImplicitUsageConflicts( ISymbol renamedSymbol, SemanticModel semanticModel, Location originalDeclarationLocation, @@ -1088,7 +1085,7 @@ public ImmutableArray ComputePossibleImplicitUsageConflicts( #endregion - public void TryAddPossibleNameConflicts(ISymbol symbol, string replacementText, ICollection possibleNameConflicts) + public override void TryAddPossibleNameConflicts(ISymbol symbol, string replacementText, ICollection possibleNameConflicts) { if (replacementText.EndsWith("Attribute", StringComparison.Ordinal) && replacementText.Length > 9) { @@ -1142,7 +1139,7 @@ public void TryAddPossibleNameConflicts(ISymbol symbol, string replacementText, /// /// The token to get the complexification target for. /// - public SyntaxNode GetExpansionTargetForLocation(SyntaxToken token) + public override SyntaxNode GetExpansionTargetForLocation(SyntaxToken token) => GetExpansionTarget(token); private static SyntaxNode GetExpansionTarget(SyntaxToken token) @@ -1205,7 +1202,7 @@ private static SyntaxNode GetExpansionTarget(SyntaxToken token) #region "Helper Methods" - public bool IsIdentifierValid(string replacementText, ISyntaxFactsService syntaxFactsService) + public override bool IsIdentifierValid(string replacementText, ISyntaxFactsService syntaxFactsService) { // Identifiers we never consider valid to rename to. switch (replacementText) diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs index 13e974124a5c9..0c77efb4b3ac4 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs @@ -268,24 +268,6 @@ private static async Task AddDeclarationConflictsAsync( } } - private static void AddConflictingParametersOfProperties( - IEnumerable properties, string newPropertyName, ArrayBuilder conflicts) - { - // check if the new property name conflicts with any parameter of the properties. - // Note: referencedSymbols come from the original solution, so there is no need to reverse map the locations of the parameters - foreach (var symbol in properties) - { - var prop = (IPropertySymbol)symbol; - - var conflictingParameter = prop.Parameters.FirstOrDefault(param => string.Compare(param.Name, newPropertyName, StringComparison.OrdinalIgnoreCase) == 0); - - if (conflictingParameter != null) - { - conflicts.AddRange(conflictingParameter.Locations); - } - } - } - private static void AddConflictingSymbolLocations(IEnumerable conflictingSymbols, ConflictResolution conflictResolution, IDictionary reverseMappedLocations) { foreach (var newSymbol in conflictingSymbols) diff --git a/src/Workspaces/Core/Portable/Rename/IRenameRewriterLanguageService.cs b/src/Workspaces/Core/Portable/Rename/IRenameRewriterLanguageService.cs index 0a1dc6b113873..bbb6b56d294eb 100644 --- a/src/Workspaces/Core/Portable/Rename/IRenameRewriterLanguageService.cs +++ b/src/Workspaces/Core/Portable/Rename/IRenameRewriterLanguageService.cs @@ -2,13 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.LanguageServices; +using Microsoft.CodeAnalysis.PooledObjects; namespace Microsoft.CodeAnalysis.Rename { @@ -116,4 +119,35 @@ bool IsIdentifierValid( /// SyntaxNode GetExpansionTargetForLocation(SyntaxToken token); } + + internal abstract class AbstractRenameRewriterLanguageService : IRenameRewriterLanguageService + { + public abstract SyntaxNode AnnotateAndRename(RenameRewriterParameters parameters); + public abstract Task> ComputeDeclarationConflictsAsync(string replacementText, ISymbol renamedSymbol, ISymbol renameSymbol, IEnumerable referencedSymbols, Solution baseSolution, Solution newSolution, IDictionary reverseMappedLocations, CancellationToken cancellationToken); + public abstract Task> ComputeImplicitReferenceConflictsAsync(ISymbol renameSymbol, ISymbol renamedSymbol, IEnumerable implicitReferenceLocations, CancellationToken cancellationToken); + public abstract ImmutableArray ComputePossibleImplicitUsageConflicts(ISymbol renamedSymbol, SemanticModel semanticModel, Location originalDeclarationLocation, int newDeclarationLocationStartingPosition, CancellationToken cancellationToken); + public abstract SyntaxNode GetExpansionTargetForLocation(SyntaxToken token); + public abstract bool IsIdentifierValid(string replacementText, ISyntaxFactsService syntaxFactsService); + public abstract bool LocalVariableConflict(SyntaxToken token, IEnumerable newReferencedSymbols); + public abstract void TryAddPossibleNameConflicts(ISymbol symbol, string newName, ICollection possibleNameConflicts); + + + protected static void AddConflictingParametersOfProperties( + IEnumerable properties, string newPropertyName, ArrayBuilder conflicts) + { + // check if the new property name conflicts with any parameter of the properties. + // Note: referencedSymbols come from the original solution, so there is no need to reverse map the locations of the parameters + foreach (var symbol in properties) + { + var prop = (IPropertySymbol)symbol; + + var conflictingParameter = prop.Parameters.FirstOrDefault(param => string.Compare(param.Name, newPropertyName, StringComparison.OrdinalIgnoreCase) == 0); + + if (conflictingParameter != null) + { + conflicts.AddRange(conflictingParameter.Locations); + } + } + } + } } diff --git a/src/Workspaces/Core/Portable/Rename/RenameLocation.ReferenceProcessing.cs b/src/Workspaces/Core/Portable/Rename/RenameLocation.ReferenceProcessing.cs index e0875106940f2..8eb45a22b3d03 100644 --- a/src/Workspaces/Core/Portable/Rename/RenameLocation.ReferenceProcessing.cs +++ b/src/Workspaces/Core/Portable/Rename/RenameLocation.ReferenceProcessing.cs @@ -426,7 +426,7 @@ internal static async Task> GetRenamableReferenceLoc return results; } - internal static async Task, IEnumerable>> GetRenamableLocationsInStringsAndCommentsAsync( + internal static async Task<(ImmutableArray, ImmutableArray)> GetRenamableLocationsInStringsAndCommentsAsync( ISymbol originalSymbol, Solution solution, ISet renameLocations, @@ -435,13 +435,12 @@ internal static async Task, IEnumerable, IEnumerable>(null, null); - } + return default; var renameText = originalSymbol.Name; - var stringLocations = renameInStrings ? new List() : null; - var commentLocations = renameInComments ? new List() : null; + + using var _1 = ArrayBuilder.GetInstance(out var stringLocations); + using var _2 = ArrayBuilder.GetInstance(out var commentLocations); foreach (var documentsGroupedByLanguage in RenameUtilities.GetDocumentsAffectedByRename(originalSymbol, solution, renameLocations).GroupBy(d => d.Project.Language)) { @@ -453,7 +452,8 @@ internal static async Task, IEnumerable, IEnumerable>(stringLocations, commentLocations); + return (renameInStrings ? stringLocations.ToImmutable() : default, + renameInComments ? commentLocations.ToImmutable() : default); } - private static async Task AddLocationsToRenameInStringsAsync(Document document, string renameText, ISyntaxFactsService syntaxFactsService, List renameLocations, CancellationToken cancellationToken) + private static async Task AddLocationsToRenameInStringsAsync( + Document document, string renameText, ISyntaxFactsService syntaxFactsService, + ArrayBuilder renameLocations, CancellationToken cancellationToken) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var renameTextLength = renameText.Length; @@ -485,7 +488,8 @@ private static async Task AddLocationsToRenameInStringsAsync(Document document, } } - private static async Task AddLocationsToRenameInCommentsAsync(Document document, string renameText, List renameLocations, CancellationToken cancellationToken) + private static async Task AddLocationsToRenameInCommentsAsync( + Document document, string renameText, ArrayBuilder renameLocations, CancellationToken cancellationToken) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var renameTextLength = renameText.Length; @@ -507,7 +511,7 @@ private static void AddLocationsToRenameInStringsAndComments( SyntaxTree tree, string renameText, IEnumerable> renameStringsAndPositions, - List renameLocations, + ArrayBuilder renameLocations, bool isRenameInStrings, bool isRenameInComments) { diff --git a/src/Workspaces/Core/Portable/Rename/RenameLocations.cs b/src/Workspaces/Core/Portable/Rename/RenameLocations.cs index f13461f832842..ad723020e3ca8 100644 --- a/src/Workspaces/Core/Portable/Rename/RenameLocations.cs +++ b/src/Workspaces/Core/Portable/Rename/RenameLocations.cs @@ -4,12 +4,14 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; @@ -23,14 +25,14 @@ internal sealed partial class RenameLocations { private class SearchResult { - public readonly IEnumerable ImplicitLocations; - public readonly ISet Locations; - public readonly IEnumerable ReferencedSymbols; + public readonly ImmutableHashSet Locations; + public readonly ImmutableArray ImplicitLocations; + public readonly ImmutableArray ReferencedSymbols; public SearchResult( - ISet locations, - IEnumerable implicitLocations, - IEnumerable referencedSymbols) + ImmutableHashSet locations, + ImmutableArray implicitLocations, + ImmutableArray referencedSymbols) { this.Locations = locations; this.ImplicitLocations = implicitLocations; @@ -44,18 +46,20 @@ public SearchResult( private readonly SearchResult _mergedResult; internal OptionSet Options { get; } + // can be default + private readonly ImmutableArray _stringsResult; + private readonly ImmutableArray _commentsResult; + // possibly null fields private readonly SearchResult _originalSymbolResult; private readonly List _overloadsResult; - private readonly IEnumerable _stringsResult; - private readonly IEnumerable _commentsResult; internal RenameLocations( - ISet locations, + ImmutableHashSet locations, SymbolAndProjectId symbolAndProjectId, Solution solution, - IEnumerable referencedSymbols, - IEnumerable implicitLocations, + ImmutableArray referencedSymbols, + ImmutableArray implicitLocations, OptionSet options) { _symbolAndProjectId = symbolAndProjectId; @@ -70,8 +74,8 @@ private RenameLocations( OptionSet options, SearchResult originalSymbolResult, List overloadsResult, - IEnumerable stringsResult, - IEnumerable commentsResult) + ImmutableArray stringsResult, + ImmutableArray commentsResult) { _symbolAndProjectId = symbolAndProjectId; _solution = solution; @@ -81,9 +85,9 @@ private RenameLocations( _stringsResult = stringsResult; _commentsResult = commentsResult; - var mergedLocations = new HashSet(); - var mergedReferencedSymbols = new List(); - var mergedImplicitLocations = new List(); + var mergedLocations = ImmutableHashSet.CreateBuilder(); + using var _1 = ArrayBuilder.GetInstance(out var mergedReferencedSymbols); + using var _2 = ArrayBuilder.GetInstance(out var mergedImplicitLocations); if (options.GetOption(RenameOptions.RenameInStrings)) { @@ -108,15 +112,16 @@ private RenameLocations( mergedReferencedSymbols.AddRange(result.ReferencedSymbols); } - _mergedResult = new SearchResult(mergedLocations, mergedImplicitLocations, mergedReferencedSymbols); + _mergedResult = new SearchResult( + mergedLocations.ToImmutable(), mergedImplicitLocations.ToImmutable(), mergedReferencedSymbols.ToImmutable()); } public ISet Locations => _mergedResult.Locations; public SymbolAndProjectId SymbolAndProjectId => _symbolAndProjectId; public ISymbol Symbol => _symbolAndProjectId.Symbol; public Solution Solution => _solution; - public IEnumerable ReferencedSymbols => _mergedResult.ReferencedSymbols; - public IEnumerable ImplicitLocations => _mergedResult.ImplicitLocations; + public ImmutableArray ReferencedSymbols => _mergedResult.ReferencedSymbols; + public ImmutableArray ImplicitLocations => _mergedResult.ImplicitLocations; /// /// Find the locations that need to be renamed. @@ -129,7 +134,8 @@ internal static async Task FindAsync( { symbolAndProjectId = await ReferenceProcessing.FindDefinitionSymbolAsync(symbolAndProjectId, solution, cancellationToken).ConfigureAwait(false); var originalSymbolResult = await AddLocationsReferenceSymbolsAsync(symbolAndProjectId, solution, cancellationToken).ConfigureAwait(false); - var intermediateResult = new RenameLocations(symbolAndProjectId, solution, optionSet, originalSymbolResult, overloadsResult: null, stringsResult: null, commentsResult: null); + var intermediateResult = new RenameLocations( + symbolAndProjectId, solution, optionSet, originalSymbolResult, overloadsResult: null, stringsResult: default, commentsResult: default); return await intermediateResult.FindWithUpdatedOptionsAsync(optionSet, cancellationToken).ConfigureAwait(false); } @@ -148,15 +154,15 @@ internal async Task FindWithUpdatedOptionsAsync(OptionSet optio _symbolAndProjectId.Symbol, _solution, _originalSymbolResult.Locations, - optionSet.GetOption(RenameOptions.RenameInStrings) && _stringsResult == null, - optionSet.GetOption(RenameOptions.RenameInComments) && _commentsResult == null, + optionSet.GetOption(RenameOptions.RenameInStrings) && _stringsResult.IsDefault, + optionSet.GetOption(RenameOptions.RenameInComments) && _commentsResult.IsDefault, cancellationToken).ConfigureAwait(false); return new RenameLocations( _symbolAndProjectId, _solution, optionSet, _originalSymbolResult, _overloadsResult ?? overloadsResult, - _stringsResult ?? stringsAndComments.Item1, - _commentsResult ?? stringsAndComments.Item2); + _stringsResult.IsDefault ? stringsAndComments.Item1 : _stringsResult, + _commentsResult.IsDefault ? stringsAndComments.Item2 : _commentsResult); } } @@ -198,7 +204,7 @@ private static async Task AddLocationsReferenceSymbolsAsync( CancellationToken cancellationToken) { var symbol = symbolAndProjectId.Symbol; - var locations = new HashSet(); + var locations = ImmutableHashSet.CreateBuilder(); var referenceSymbols = await SymbolFinder.FindRenamableReferencesAsync( symbolAndProjectId, solution, cancellationToken).ConfigureAwait(false); @@ -213,10 +219,10 @@ await referencedSymbol.Locations.SelectManyAsync refSym.Locations).Where(loc => loc.IsImplicit).ToList(); - var referencedSymbols = referenceSymbols.Select(r => r.DefinitionAndProjectId).Where(r => !r.Symbol.Equals(symbol)).ToList(); + var implicitLocations = referenceSymbols.SelectMany(refSym => refSym.Locations).Where(loc => loc.IsImplicit).ToImmutableArray(); + var referencedSymbols = referenceSymbols.Select(r => r.DefinitionAndProjectId).Where(r => !r.Symbol.Equals(symbol)).ToImmutableArray(); - return new SearchResult(locations, implicitLocations, referencedSymbols); + return new SearchResult(locations.ToImmutable(), implicitLocations, referencedSymbols); } } } diff --git a/src/Workspaces/Core/Portable/Rename/Renamer.cs b/src/Workspaces/Core/Portable/Rename/Renamer.cs index bcd8f4bec80b1..3bc8e4c1f8d8c 100644 --- a/src/Workspaces/Core/Portable/Rename/Renamer.cs +++ b/src/Workspaces/Core/Portable/Rename/Renamer.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -69,9 +70,9 @@ internal static async Task RenameAsync( if (filter != null) { locations = new RenameLocations( - locations.Locations.Where(loc => filter(loc.Location)).ToSet(), + locations.Locations.Where(loc => filter(loc.Location)).ToImmutableHashSet(), symbolAndProjectId, locations.Solution, - locations.ReferencedSymbols, locations.ImplicitLocations.Where(loc => filter(loc.Location)), + locations.ReferencedSymbols, locations.ImplicitLocations.WhereAsArray(loc => filter(loc.Location)), locations.Options); } diff --git a/src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb b/src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb index 67d2f79720ff4..2448d554dcdae 100644 --- a/src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb +++ b/src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb @@ -22,7 +22,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.Rename Friend Class VisualBasicRenameRewriterLanguageService - Implements IRenameRewriterLanguageService + Inherits AbstractRenameRewriterLanguageService Private ReadOnly _languageServiceProvider As HostLanguageServices @@ -32,7 +32,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename #Region "Annotate" - Public Function AnnotateAndRename(parameters As RenameRewriterParameters) As SyntaxNode Implements IRenameRewriterLanguageService.AnnotateAndRename + Public Overrides Function AnnotateAndRename(parameters As RenameRewriterParameters) As SyntaxNode Dim renameRewriter = New RenameRewriter(parameters) Return renameRewriter.Visit(parameters.SyntaxRoot) End Function @@ -656,16 +656,16 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename #Region "Declaration Conflicts" - Public Function LocalVariableConflict( + Public Overrides Function LocalVariableConflict( token As SyntaxToken, newReferencedSymbols As IEnumerable(Of ISymbol) - ) As Boolean Implements IRenameRewriterLanguageService.LocalVariableConflict + ) As Boolean ' This scenario is not present in VB and only in C# Return False End Function - Public Function ComputeDeclarationConflictsAsync( + Public Overrides Function ComputeDeclarationConflictsAsync( replacementText As String, renamedSymbol As ISymbol, renameSymbol As ISymbol, @@ -674,7 +674,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename newSolution As Solution, reverseMappedLocations As IDictionary(Of Location, Location), cancellationToken As CancellationToken - ) As Task(Of ImmutableArray(Of Location)) Implements IRenameRewriterLanguageService.ComputeDeclarationConflictsAsync + ) As Task(Of ImmutableArray(Of Location)) Dim conflicts = ArrayBuilder(Of Location).GetInstance() @@ -748,7 +748,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename conflicts.AddRange( DeclarationConflictHelpers.GetMembersWithConflictingSignatures(DirectCast(renamedSymbol, IPropertySymbol), trimOptionalParameters:=True) _ .Select(Function(loc) reverseMappedLocations(loc))) - ConflictResolver.AddConflictingParametersOfProperties( + AddConflictingParametersOfProperties( referencedSymbols.Select(Function(s) s.Symbol).Concat(renameSymbol).Where(Function(sym) sym.Kind = SymbolKind.Property), renamedSymbol.Name, conflicts) @@ -781,10 +781,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename Return Task.FromResult(conflicts.ToImmutableAndFree()) End Function - Public Async Function ComputeImplicitReferenceConflictsAsync( + Public Overrides Async Function ComputeImplicitReferenceConflictsAsync( renameSymbol As ISymbol, renamedSymbol As ISymbol, implicitReferenceLocations As IEnumerable(Of ReferenceLocation), - cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of Location)) Implements IRenameRewriterLanguageService.ComputeImplicitReferenceConflictsAsync + cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of Location)) ' Handle renaming of symbols used for foreach Dim implicitReferencesMightConflict = renameSymbol.Kind = SymbolKind.Property AndAlso @@ -820,7 +820,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename ''' statement of this lambda. ''' ''' The token to get the complexification target for. - Public Function GetExpansionTargetForLocation(token As SyntaxToken) As SyntaxNode Implements IRenameRewriterLanguageService.GetExpansionTargetForLocation + Public Overrides Function GetExpansionTargetForLocation(token As SyntaxToken) As SyntaxNode Return GetExpansionTarget(token) End Function @@ -858,7 +858,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename End Function #Region "Helper Methods" - Public Function IsIdentifierValid(replacementText As String, syntaxFactsService As ISyntaxFactsService) As Boolean Implements IRenameRewriterLanguageService.IsIdentifierValid + Public Overrides Function IsIdentifierValid(replacementText As String, syntaxFactsService As ISyntaxFactsService) As Boolean replacementText = SyntaxFacts.MakeHalfWidthIdentifier(replacementText) Dim possibleIdentifier As String If syntaxFactsService.IsTypeCharacter(replacementText.Last()) Then @@ -882,12 +882,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename Return True End Function - Public Function ComputePossibleImplicitUsageConflicts( + Public Overrides Function ComputePossibleImplicitUsageConflicts( renamedSymbol As ISymbol, semanticModel As SemanticModel, originalDeclarationLocation As Location, newDeclarationLocationStartingPosition As Integer, - cancellationToken As CancellationToken) As ImmutableArray(Of Location) Implements IRenameRewriterLanguageService.ComputePossibleImplicitUsageConflicts + cancellationToken As CancellationToken) As ImmutableArray(Of Location) ' TODO: support other implicitly used methods like dispose If CaseInsensitiveComparison.Equals(renamedSymbol.Name, "MoveNext") OrElse @@ -955,7 +955,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename Return ImmutableArray(Of Location).Empty End Function - Public Sub TryAddPossibleNameConflicts(symbol As ISymbol, replacementText As String, possibleNameConflicts As ICollection(Of String)) Implements IRenameRewriterLanguageService.TryAddPossibleNameConflicts + Public Overrides Sub TryAddPossibleNameConflicts(symbol As ISymbol, replacementText As String, possibleNameConflicts As ICollection(Of String)) Dim halfWidthReplacementText = SyntaxFacts.MakeHalfWidthIdentifier(replacementText) Const AttributeSuffix As String = "Attribute" From 78b32d2c1d9876f6cedebad1ff92177639db992d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 2 Apr 2020 12:54:34 -0700 Subject: [PATCH 11/50] Fix --- .../Compiler/Core/Utilities/ICollectionExtensions.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ICollectionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ICollectionExtensions.cs index d8ef1f6432da7..001e565fea9c5 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ICollectionExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ICollectionExtensions.cs @@ -35,9 +35,12 @@ public static void AddRange(this ICollection collection, ImmutableArray throw new ArgumentNullException(nameof(collection)); } - foreach (var item in values) + if (!values.IsDefault) { - collection.Add(item); + foreach (var item in values) + { + collection.Add(item); + } } } } From a8af598efd243353753b58e935671cedebc6c2b6 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Thu, 2 Apr 2020 17:15:28 -0700 Subject: [PATCH 12/50] Order roslyn signature help after LSP command handler. --- .../SignatureHelpAfterCompletionCommandHandler.cs | 3 +++ .../SignatureHelpBeforeCompletionCommandHandler.cs | 3 +++ .../Extensibility/Commands/PredefinedCommandHandlerNames.cs | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/src/EditorFeatures/Core/CommandHandlers/SignatureHelpAfterCompletionCommandHandler.cs b/src/EditorFeatures/Core/CommandHandlers/SignatureHelpAfterCompletionCommandHandler.cs index a02601a43586d..143c9e2e4f580 100644 --- a/src/EditorFeatures/Core/CommandHandlers/SignatureHelpAfterCompletionCommandHandler.cs +++ b/src/EditorFeatures/Core/CommandHandlers/SignatureHelpAfterCompletionCommandHandler.cs @@ -38,6 +38,9 @@ namespace Microsoft.CodeAnalysis.Editor.CommandHandlers [ContentType(ContentTypeNames.RoslynContentType)] [Name(PredefinedCommandHandlerNames.SignatureHelpAfterCompletion)] [Order(After = PredefinedCompletionNames.CompletionCommandHandler)] + // Ensure roslyn comes after LSP to allow them to provide results. + // https://github.com/dotnet/roslyn/issues/42338 + [Order(After = PredefinedCommandHandlerNames.LSPSignatureHelp)] internal class SignatureHelpAfterCompletionCommandHandler : AbstractSignatureHelpCommandHandler, IChainedCommandHandler, diff --git a/src/EditorFeatures/Core/CommandHandlers/SignatureHelpBeforeCompletionCommandHandler.cs b/src/EditorFeatures/Core/CommandHandlers/SignatureHelpBeforeCompletionCommandHandler.cs index 96dbc13ec3dc3..afdd96b5a9056 100644 --- a/src/EditorFeatures/Core/CommandHandlers/SignatureHelpBeforeCompletionCommandHandler.cs +++ b/src/EditorFeatures/Core/CommandHandlers/SignatureHelpBeforeCompletionCommandHandler.cs @@ -38,6 +38,9 @@ namespace Microsoft.CodeAnalysis.Editor.CommandHandlers [ContentType(ContentTypeNames.RoslynContentType)] [Name(PredefinedCommandHandlerNames.SignatureHelpBeforeCompletion)] [Order(Before = PredefinedCompletionNames.CompletionCommandHandler)] + // Ensure roslyn comes after LSP to allow them to provide results. + // https://github.com/dotnet/roslyn/issues/42338 + [Order(After = PredefinedCommandHandlerNames.LSPSignatureHelp)] internal class SignatureHelpBeforeCompletionCommandHandler : AbstractSignatureHelpCommandHandler, IChainedCommandHandler, diff --git a/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs b/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs index c061874735ffd..907f1ed2c5717 100644 --- a/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs +++ b/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs @@ -171,5 +171,10 @@ internal static class PredefinedCommandHandlerNames /// Command handler name for Edit and Continue file save handler. /// public const string EditAndContinueFileSave = "Edit and Continue Save File Handler"; + + /// + /// Command handler name for the LSP client Signature Help command handler. + /// + public const string LSPSignatureHelp = "LSP SignatureHelpCommandHandler"; } } From 08469d6413e9fca488c1e6d07e53d7beea7501d5 Mon Sep 17 00:00:00 2001 From: Gen Lu Date: Thu, 2 Apr 2020 17:21:21 -0700 Subject: [PATCH 13/50] show stackallock completion in expression context --- .../StackAllocKeywordRecommenderTests.cs | 67 +++++++++++++++---- .../StackAllocKeywordRecommender.cs | 51 ++------------ 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/StackAllocKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/StackAllocKeywordRecommenderTests.cs index aa21f59e38c18..bbb124be890d5 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/StackAllocKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/StackAllocKeywordRecommenderTests.cs @@ -12,32 +12,32 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Recommendations public class StackAllocKeywordRecommenderTests : KeywordRecommenderTests { [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAtRoot_Interactive() + public async Task TestAtRoot_Interactive() { - await VerifyAbsenceAsync(SourceCodeKind.Script, + await VerifyKeywordAsync(SourceCodeKind.Script, @"$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterClass_Interactive() + public async Task TestAfterClass_Interactive() { - await VerifyAbsenceAsync(SourceCodeKind.Script, + await VerifyKeywordAsync(SourceCodeKind.Script, @"class C { } $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterGlobalStatement_Interactive() + public async Task TestAfterGlobalStatement_Interactive() { - await VerifyAbsenceAsync(SourceCodeKind.Script, + await VerifyKeywordAsync(SourceCodeKind.Script, @"System.Console.WriteLine(); $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterGlobalVariableDeclaration_Interactive() + public async Task TestAfterGlobalVariableDeclaration_Interactive() { - await VerifyAbsenceAsync(SourceCodeKind.Script, + await VerifyKeywordAsync(SourceCodeKind.Script, @"int i = 0; $$"); } @@ -50,9 +50,11 @@ await VerifyAbsenceAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInEmptyStatement() + public async Task TestInEmptyStatement() { - await VerifyAbsenceAsync(AddInsideMethod( + // e.g. this is a valid statement + // stackalloc[] { 1, 2, 3 }.IndexOf(1); + await VerifyKeywordAsync(AddInsideMethod( @"$$")); } @@ -92,11 +94,14 @@ void Goo() { } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInField() + public async Task TestInField() { - await VerifyAbsenceAsync( -@"unsafe class C { - int* v = $$"); + // While assigning stackalloc'd value to a field is invalid, + // using one in the initializer is OK. e.g. + // int _f = stackalloc[] { 1, 2, 3 }.IndexOf(1); + await VerifyKeywordAsync( +@"class C { + int v = $$"); } [WorkItem(544504, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544504")] @@ -268,5 +273,39 @@ await VerifyAbsenceAsync(AddInsideMethod(@" await VerifyAbsenceAsync(AddInsideMethod(@" x $$ =")); } + + [WorkItem(41736, "https://github.com/dotnet/roslyn/issues/41736")] + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestInArgument() + { + await VerifyKeywordAsync(@" +class Program +{ + static void Method(System.Span span) + { + Method($$); + } +}"); + + await VerifyKeywordAsync(@" +class Program +{ + static void Method(int x, System.Span span) + { + Method(1, $$); + } +}"); + } + + [WorkItem(41736, "https://github.com/dotnet/roslyn/issues/41736")] + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestNotInConstFieldInitializer() + { + await VerifyAbsenceAsync(@" +class Program +{ + private const int _f = $$ +}"); + } } } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StackAllocKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StackAllocKeywordRecommender.cs index 4d1e9570937e1..27f343fad6052 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StackAllocKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StackAllocKeywordRecommender.cs @@ -17,52 +17,11 @@ public StackAllocKeywordRecommender() protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken) { - var node = context.TargetToken.Parent; - - // At start of a file - if (node == null) - { - return false; - } - - // After a cast or parenthesized expression: (Span)stackalloc - if (context.TargetToken.IsAfterPossibleCast()) - { - node = node.Parent; - } - - // Inside a conditional expression: value ? stackalloc : stackalloc - while (node.IsKind(SyntaxKind.ConditionalExpression) && - (context.TargetToken.IsKind(SyntaxKind.QuestionToken, SyntaxKind.ColonToken) || context.TargetToken.IsAfterPossibleCast())) - { - node = node.Parent; - } - - // assignment: x = stackalloc - if (node.IsKind(SyntaxKind.SimpleAssignmentExpression)) - { - return node.Parent.IsKind(SyntaxKind.ExpressionStatement); - } - - // declaration: var x = stackalloc - if (node.IsKind(SyntaxKind.EqualsValueClause)) - { - node = node.Parent; - - if (node.IsKind(SyntaxKind.VariableDeclarator)) - { - node = node.Parent; - - if (node.IsKind(SyntaxKind.VariableDeclaration)) - { - node = node.Parent; - - return node.IsKind(SyntaxKind.LocalDeclarationStatement, SyntaxKind.ForStatement); - } - } - } - - return false; + // Beginning with C# 8.0, stackalloc expression can be used inside other expressions + // whenever a Span or ReadOnlySpan variable is allowed. + return (context.IsAnyExpressionContext && !context.IsConstantExpressionContext) || + context.IsStatementContext || + context.IsGlobalStatementContext; } } } From 3f20bc25158ce381ca4f4040ab8ca02b6671263f Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 2 Apr 2020 18:26:49 -0700 Subject: [PATCH 14/50] Skip test --- src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs b/src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs index 862e240cf5a6b..1499e007054af 100644 --- a/src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs +++ b/src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs @@ -238,7 +238,7 @@ public async Task RemoveDiagnosticForMappedFileToManyDocumentsTestAsync() Assert.Contains(results[2].Diagnostics, d => d.Code == "doc2Diagnostic"); } - [Fact] + [Fact(Skip = "https://github.com/dotnet/roslyn/issues/43046")] public async Task ClearAllDiagnosticsForMappedFilesTestAsync() { using var workspace = CreateTestWorkspace("", out _); From 07bf1adfb09d55e8ab7eade37f49c91c3a925e87 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 2 Apr 2020 20:11:23 -0700 Subject: [PATCH 15/50] Skip test --- src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs b/src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs index 1499e007054af..c8314bd6458f2 100644 --- a/src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs +++ b/src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs @@ -284,7 +284,7 @@ await CreateMockDiagnosticDatasWithMappedLocationAsync(document, ("id1", mappedF Assert.False(languageServer._publishedFileToDiagnostics.Keys.Any()); } - [Fact] + [Fact(Skip = "https://github.com/dotnet/roslyn/issues/43046")] public async Task ClearAllDiagnosticsForMappedFileToManyDocumentsTestAsync() { using var workspace = CreateTestWorkspace(new string[] { "", "" }, out _); From 845f2430a354b73e8c6c936f45cbcfe729f2b5f7 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Thu, 2 Apr 2020 21:24:05 -0700 Subject: [PATCH 16/50] Respond to breaking package changes --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index aac53b98e4e68..5675c76680ef2 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -198,7 +198,7 @@ 4.5.3 1.1.2 1.1.0.14 - 16.3.2099 + 16.5.2044 16.0.2032702 7.0.3301 14.0.25030 From 6bbfdc8fe2318f7fd6118f861e2bcaa4da3b0a85 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 3 Apr 2020 11:05:56 -0700 Subject: [PATCH 17/50] Fix --- .../AbstractEncapsulateFieldService.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Features/Core/Portable/EncapsulateField/AbstractEncapsulateFieldService.cs b/src/Features/Core/Portable/EncapsulateField/AbstractEncapsulateFieldService.cs index d41c1259d4eda..9e89eeba21ef7 100644 --- a/src/Features/Core/Portable/EncapsulateField/AbstractEncapsulateFieldService.cs +++ b/src/Features/Core/Portable/EncapsulateField/AbstractEncapsulateFieldService.cs @@ -244,14 +244,12 @@ private async Task UpdateReferencesAsync( var projectId = document.Project.Id; if (field.IsReadOnly) { - var fieldAnProjectId = SymbolAndProjectId.Create(field, projectId); - // Inside the constructor we want to rename references the field to the final field name. var constructorLocations = GetConstructorLocations(field.ContainingType); if (finalFieldName != field.Name && constructorLocations.Count > 0) { solution = await RenameAsync( - solution, fieldAnProjectId, finalFieldName, + solution, SymbolAndProjectId.Create(field, projectId), finalFieldName, location => IntersectsWithAny(location, constructorLocations), cancellationToken).ConfigureAwait(false); @@ -264,7 +262,7 @@ private async Task UpdateReferencesAsync( // Outside the constructor we want to rename references to the field to final property name. return await RenameAsync( - solution, fieldAnProjectId, generatedPropertyName, + solution, SymbolAndProjectId.Create(field, projectId), generatedPropertyName, location => !IntersectsWithAny(location, constructorLocations), cancellationToken).ConfigureAwait(false); } @@ -272,8 +270,7 @@ private async Task UpdateReferencesAsync( { // Just rename everything. return await Renamer.RenameSymbolAsync( - solution, SymbolAndProjectId.Create(field, projectId), - generatedPropertyName, solution.Options, cancellationToken).ConfigureAwait(false); + solution, SymbolAndProjectId.Create(field, projectId), generatedPropertyName, solution.Options, cancellationToken).ConfigureAwait(false); } } @@ -287,10 +284,9 @@ private async Task RenameAsync( var initialLocations = await Renamer.GetRenameLocationsAsync( solution, field, solution.Options, cancellationToken).ConfigureAwait(false); - var insideLocations = initialLocations.Filter(filter); - return await Renamer.RenameAsync( - insideLocations, finalName, cancellationToken: cancellationToken).ConfigureAwait(false); + initialLocations.Filter(filter), finalName, + cancellationToken: cancellationToken).ConfigureAwait(false); } private bool IntersectsWithAny(Location location, ISet constructorLocations) From fe7288914b8bf78052fe2dfbdd30092d71f76168 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 3 Apr 2020 13:04:53 -0700 Subject: [PATCH 18/50] Remove 'options' parameter, it is redundant --- ...stractEditorInlineRenameService.InlineRenameLocationSet.cs | 2 +- src/EditorFeatures/Test2/Rename/RenameEngineResult.vb | 2 +- .../Rename/ConflictEngine/ConflictResolver.Session.cs | 3 +-- .../Core/Portable/Rename/ConflictEngine/ConflictResolver.cs | 4 +--- src/Workspaces/Core/Portable/Rename/Renamer.cs | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs b/src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs index a73134ef64201..a8221796b849f 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs @@ -41,7 +41,7 @@ public async Task GetReplacementsAsync(string repl { var conflicts = await ConflictResolver.ResolveConflictsAsync( _renameLocationSet, _renameLocationSet.Symbol.Name, - _renameInfo.GetFinalSymbolName(replacementText), optionSet, nonConflictSymbols: null, cancellationToken: cancellationToken).ConfigureAwait(false); + _renameInfo.GetFinalSymbolName(replacementText), nonConflictSymbols: null, cancellationToken: cancellationToken).ConfigureAwait(false); return new InlineRenameReplacementInfo(conflicts); } diff --git a/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb b/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb index b43e9d13b47f9..27c9e81abfe5c 100644 --- a/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb +++ b/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb @@ -79,7 +79,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename Dim locations = RenameLocations.FindAsync(symbolAndProjectId, workspace.CurrentSolution, optionSet, CancellationToken.None).Result Dim originalName = symbol.Name.Split("."c).Last() - Dim result = ConflictResolver.ResolveConflictsAsync(locations, originalName, renameTo, optionSet, nonConflictSymbols:=Nothing, cancellationToken:=CancellationToken.None).Result + Dim result = ConflictResolver.ResolveConflictsAsync(locations, originalName, renameTo, nonConflictSymbols:=Nothing, cancellationToken:=CancellationToken.None).Result engineResult = New RenameEngineResult(workspace, result, renameTo) engineResult.AssertUnlabeledSpansRenamedAndHaveNoConflicts() diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs index 341376f754c30..0231a3a906942 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs @@ -58,7 +58,6 @@ public Session( Location renameSymbolDeclarationLocation, string originalText, string replacementText, - OptionSet optionSet, ImmutableHashSet nonConflictSymbols, CancellationToken cancellationToken) { @@ -66,7 +65,7 @@ public Session( _renameSymbolDeclarationLocation = renameSymbolDeclarationLocation; _originalText = originalText; _replacementText = replacementText; - _optionSet = optionSet; + _optionSet = renameLocationSet.Options; _nonConflictSymbols = nonConflictSymbols; _cancellationToken = cancellationToken; diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs index 368e8e4e3d0e6..4aa6bf77de7d8 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs @@ -43,7 +43,6 @@ internal static partial class ConflictResolver /// The locations to perform the renaming at. /// The original name of the identifier. /// The new name of the identifier - /// The option for rename /// Used after renaming references. References that now bind to any of these /// symbols are not considered to be in conflict. Useful for features that want to rename existing references to /// point at some existing symbol. Normally this would be a conflict, but this can be used to override that @@ -54,7 +53,6 @@ public static Task ResolveConflictsAsync( RenameLocations renameLocationSet, string originalText, string replacementText, - OptionSet optionSet, ImmutableHashSet nonConflictSymbols, CancellationToken cancellationToken) { @@ -71,7 +69,7 @@ public static Task ResolveConflictsAsync( var session = new Session( renameLocationSet, renameSymbolDeclarationLocation, originalText, replacementText, - optionSet, nonConflictSymbols, cancellationToken); + nonConflictSymbols, cancellationToken); return session.ResolveConflictsAsync(); } diff --git a/src/Workspaces/Core/Portable/Rename/Renamer.cs b/src/Workspaces/Core/Portable/Rename/Renamer.cs index 8cc921c6ce310..21752b8642710 100644 --- a/src/Workspaces/Core/Portable/Rename/Renamer.cs +++ b/src/Workspaces/Core/Portable/Rename/Renamer.cs @@ -62,7 +62,7 @@ internal static async Task RenameAsync( var conflictResolution = await ConflictResolver.ResolveConflictsAsync( locations, locations.SymbolAndProjectId.Symbol.Name, newName, - locations.Options, nonConflictSymbols, cancellationToken).ConfigureAwait(false); + nonConflictSymbols, cancellationToken).ConfigureAwait(false); return conflictResolution.NewSolution; } From d59a4cf1c783b1c323342c9b6bddfe6dab586943 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 13:07:23 -0700 Subject: [PATCH 19/50] Port MakeLocalFunctionStatic analyzer and tests to shared layer CodeFix has not yet been ported because it depends on internal CodeGenerationSymbolFactory APIs. https://github.com/dotnet/roslyn/issues/43056 tracks making these APIs public and subsequently porting the fixer. To enable porting the tests, I have added a workaround in CodeStyle layer test framework to use the IDE code fixer with the CodeStyle layer analyzer for tests. --- .../Analyzers/CSharpAnalyzers.projitems | 2 + ...keLocalFunctionStaticDiagnosticAnalyzer.cs | 4 +- .../MakeLocalFunctionStaticHelper.cs | 39 +++++++++++++++++++ .../Tests/CSharpAnalyzers.UnitTests.projitems | 1 + .../MakeLocalFunctionStaticTests.cs | 2 +- ...agnosticProviderBasedUserDiagnosticTest.cs | 11 ++++++ ...> MakeLocalFunctionStaticCodeFixHelper.cs} | 30 ++------------ .../MakeLocalFunctionStaticCodeFixProvider.cs | 6 +-- ...alFunctionStaticCodeRefactoringProvider.cs | 6 +-- ...uredVariablesAsArgumentsCodeFixProvider.cs | 8 ++-- ...rosoft.CodeAnalysis.CSharp.Features.csproj | 1 + .../Microsoft.CodeAnalysis.Features.csproj | 1 + ...t.CodeAnalysis.VisualBasic.Features.vbproj | 1 + 13 files changed, 73 insertions(+), 39 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs (87%) create mode 100644 src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticHelper.cs rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs (99%) rename src/Features/CSharp/Portable/MakeLocalFunctionStatic/{MakeLocalFunctionStaticHelper.cs => MakeLocalFunctionStaticCodeFixHelper.cs} (85%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index bcf00f1b9eed9..4c12c3c79f6f1 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -24,6 +24,8 @@ + + diff --git a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs similarity index 87% rename from src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs index 6155f54d878c2..d0001fae32156 100644 --- a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs @@ -17,8 +17,8 @@ public MakeLocalFunctionStaticDiagnosticAnalyzer() : base(IDEDiagnosticIds.MakeLocalFunctionStaticDiagnosticId, CSharpCodeStyleOptions.PreferStaticLocalFunction, LanguageNames.CSharp, - new LocalizableResourceString(nameof(FeaturesResources.Make_local_function_static), FeaturesResources.ResourceManager, typeof(FeaturesResources)), - new LocalizableResourceString(nameof(FeaturesResources.Local_function_can_be_made_static), FeaturesResources.ResourceManager, typeof(FeaturesResources))) + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Make_local_function_static), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)), + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Local_function_can_be_made_static), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources))) { } diff --git a/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticHelper.cs b/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticHelper.cs new file mode 100644 index 0000000000000..f4568716b9d4c --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticHelper.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable enable + +using System.Collections.Immutable; +using System.Linq; +using Microsoft.CodeAnalysis.CSharp.Extensions; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Shared.Extensions; + +namespace Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic +{ + internal static class MakeLocalFunctionStaticHelper + { + public static bool IsStaticLocalFunctionSupported(SyntaxTree tree) + => tree.Options is CSharpParseOptions csharpOption && csharpOption.LanguageVersion >= LanguageVersion.CSharp8; + + public static bool TryGetCaputuredSymbols(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray captures) + { + var dataFlow = semanticModel.AnalyzeDataFlow(localFunction); + if (dataFlow is null) + { + captures = default; + return false; + } + + captures = dataFlow.CapturedInside; + return dataFlow.Succeeded; + } + + public static bool TryGetCaputuredSymbolsAndCheckApplicability(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray captures) + => TryGetCaputuredSymbols(localFunction, semanticModel, out captures) && CanMakeLocalFunctionStatic(captures); + + private static bool CanMakeLocalFunctionStatic(ImmutableArray captures) + => captures.Length > 0 && !captures.Any(s => s.IsThisParameter()); + } +} diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index a4cf6996fa5a4..9487ce64ed906 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -15,6 +15,7 @@ + diff --git a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs b/src/Analyzers/CSharp/Tests/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs rename to src/Analyzers/CSharp/Tests/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs index 1908975e0d4cf..94dd518a94fa3 100644 --- a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs +++ b/src/Analyzers/CSharp/Tests/MakeLocalFunctionStatic/MakeLocalFunctionStaticTests.cs @@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.MakeLocalFunctionStatic public partial class MakeLocalFunctionStaticTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest { internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace) - => (new MakeLocalFunctionStaticDiagnosticAnalyzer(), new MakeLocalFunctionStaticCodeFixProvider()); + => (new MakeLocalFunctionStaticDiagnosticAnalyzer(), GetMakeLocalFunctionStaticCodeFixProvider()); private static readonly ParseOptions CSharp72ParseOptions = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_2); private static readonly ParseOptions CSharp8ParseOptions = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8); diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs index 9eda24525ad95..0783856819ff1 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; @@ -228,5 +229,15 @@ private void AssertNoAnalyzerExceptionDiagnostics(IEnumerable diagno var analyzerExceptionDiagnostics = diagnostics.Where(diag => diag.Descriptor.CustomTags.Contains(WellKnownDiagnosticTags.AnalyzerException)); AssertEx.Empty(analyzerExceptionDiagnostics, "Found analyzer exception diagnostics"); } + + // This region provides instances of code fix providers from Features layers, such that the corresponding + // analyzer has been ported to CodeStyle layer, but not the fixer. + // This enables porting the tests for the ported analyzer in CodeStyle layer. + #region CodeFixProvider Helpers + + // https://github.com/dotnet/roslyn/issues/43056 blocks porting the fixer to CodeStyle layer. + protected static CodeFixProvider GetMakeLocalFunctionStaticCodeFixProvider() => new MakeLocalFunctionStaticCodeFixProvider(); + + #endregion } } diff --git a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticHelper.cs b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs similarity index 85% rename from src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticHelper.cs rename to src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs index b385200b78da4..b234bd30d2b6f 100644 --- a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticHelper.cs +++ b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs @@ -21,30 +21,8 @@ namespace Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic { - internal static class MakeLocalFunctionStaticHelper + internal static class MakeLocalFunctionStaticCodeFixHelper { - public static bool IsStaticLocalFunctionSupported(SyntaxTree tree) - => tree.Options is CSharpParseOptions csharpOption && csharpOption.LanguageVersion >= LanguageVersion.CSharp8; - - public static bool TryGetCaputuredSymbols(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray captures) - { - var dataFlow = semanticModel.AnalyzeDataFlow(localFunction); - if (dataFlow is null) - { - captures = default; - return false; - } - - captures = dataFlow.CapturedInside; - return dataFlow.Succeeded; - } - - public static bool TryGetCaputuredSymbolsAndCheckApplicability(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray captures) - => TryGetCaputuredSymbols(localFunction, semanticModel, out captures) && CanMakeLocalFunctionStatic(captures); - - private static bool CanMakeLocalFunctionStatic(ImmutableArray captures) - => captures.Length > 0 && !captures.Any(s => s.IsThisParameter()); - public static async Task MakeLocalFunctionStaticAsync( Document document, LocalFunctionStatementSyntax localFunction, @@ -155,7 +133,7 @@ public static async Task MakeLocalFunctionStaticAsync( { syntaxEditor.ReplaceNode( identifierNode, - (node, generator) => generator.IdentifierName(parameter.Name.ToIdentifierToken()).WithTriviaFrom(node)); + (node, generator) => generator.IdentifierName(parameter.Name).WithTriviaFrom(node)); } } } @@ -173,11 +151,11 @@ public static async Task MakeLocalFunctionStaticAsync( if (shouldWarn) { - var annotation = WarningAnnotation.Create(CSharpFeaturesResources.Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code); + var annotation = WarningAnnotation.Create(CSharpCodeFixesResources.Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code); localFunctionWithNewParameters = localFunctionWithNewParameters.WithAdditionalAnnotations(annotation); } - return AddStaticModifier(localFunctionWithNewParameters, CSharpSyntaxGenerator.Instance); + return AddStaticModifier(localFunctionWithNewParameters, SyntaxGenerator.GetGenerator(document)); }); } diff --git a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs index de892eda98096..f12543b7567c2 100644 --- a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixProvider.cs @@ -48,16 +48,16 @@ protected override Task FixAllAsync( { editor.ReplaceNode( localFunction, - (current, generator) => MakeLocalFunctionStaticHelper.AddStaticModifier(current, generator)); + (current, generator) => MakeLocalFunctionStaticCodeFixHelper.AddStaticModifier(current, generator)); } return Task.CompletedTask; } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(FeaturesResources.Make_local_function_static, createChangedDocument, FeaturesResources.Make_local_function_static) + : base(CSharpAnalyzersResources.Make_local_function_static, createChangedDocument, CSharpAnalyzersResources.Make_local_function_static) { } } diff --git a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeRefactoringProvider.cs b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeRefactoringProvider.cs index 560b5795a779c..acda5799c0dba 100644 --- a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeRefactoringProvider.cs +++ b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeRefactoringProvider.cs @@ -50,12 +50,12 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte if (MakeLocalFunctionStaticHelper.TryGetCaputuredSymbolsAndCheckApplicability(localFunction, semanticModel, out var captures)) { context.RegisterRefactoring(new MyCodeAction( - FeaturesResources.Make_local_function_static, - c => MakeLocalFunctionStaticHelper.MakeLocalFunctionStaticAsync(document, localFunction, captures, c))); + CSharpAnalyzersResources.Make_local_function_static, + c => MakeLocalFunctionStaticCodeFixHelper.MakeLocalFunctionStaticAsync(document, localFunction, captures, c))); } } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(string title, Func> createChangedDocument) : base(title, createChangedDocument) diff --git a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/PassInCapturedVariablesAsArgumentsCodeFixProvider.cs b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/PassInCapturedVariablesAsArgumentsCodeFixProvider.cs index 0fc4c7c1299cc..36ff6cff1a6c3 100644 --- a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/PassInCapturedVariablesAsArgumentsCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/PassInCapturedVariablesAsArgumentsCodeFixProvider.cs @@ -43,7 +43,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) (document, localFunction, captures) => { context.RegisterCodeFix( - new MyCodeAction(c => MakeLocalFunctionStaticHelper.MakeLocalFunctionStaticAsync( + new MyCodeAction(c => MakeLocalFunctionStaticCodeFixHelper.MakeLocalFunctionStaticAsync( document, localFunction, captures, @@ -59,7 +59,7 @@ protected override Task FixAllAsync(Document document, ImmutableArray WrapFixAsync( document, diagnostics, - (d, localFunction, captures) => MakeLocalFunctionStaticHelper.MakeLocalFunctionStaticAsync( + (d, localFunction, captures) => MakeLocalFunctionStaticCodeFixHelper.MakeLocalFunctionStaticAsync( d, localFunction, captures, @@ -109,10 +109,10 @@ private static async Task WrapFixAsync( } } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(CSharpFeaturesResources.Pass_in_captured_variables_as_arguments, createChangedDocument, CSharpFeaturesResources.Pass_in_captured_variables_as_arguments) + : base(CSharpCodeFixesResources.Pass_in_captured_variables_as_arguments, createChangedDocument, CSharpCodeFixesResources.Pass_in_captured_variables_as_arguments) { } } diff --git a/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj b/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj index 99f3f3f285784..d97e994912687 100644 --- a/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj +++ b/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj @@ -44,6 +44,7 @@ + diff --git a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj index f8ca01637d771..a9416744905ed 100644 --- a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj +++ b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj @@ -79,6 +79,7 @@ + diff --git a/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj b/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj index c914b7aaa6db2..828bd70a7b7af 100644 --- a/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj +++ b/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj @@ -41,6 +41,7 @@ + From 7ec8cf63c846ec2a06a2bd387339739b36f640a0 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 13:07:32 -0700 Subject: [PATCH 20/50] xlf and resx changes --- .../CSharp/Analyzers/CSharpAnalyzersResources.resx | 6 ++++++ .../Analyzers/xlf/CSharpAnalyzersResources.cs.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.de.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.es.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.fr.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.it.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ja.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ko.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.pl.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ru.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.tr.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf | 10 ++++++++++ .../CSharp/CodeFixes/CSharpCodeFixesResources.resx | 6 ++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.de.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.es.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.fr.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.it.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.ja.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.ko.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.pl.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.pt-BR.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.ru.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.tr.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.zh-Hans.xlf | 10 ++++++++++ .../CodeFixes/xlf/CSharpCodeFixesResources.zh-Hant.xlf | 10 ++++++++++ .../CSharp/Portable/CSharpFeaturesResources.resx | 6 ------ .../CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf | 10 ---------- .../Portable/xlf/CSharpFeaturesResources.pt-BR.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf | 10 ---------- .../CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf | 10 ---------- .../Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf | 10 ---------- .../Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf | 10 ---------- src/Features/Core/Portable/FeaturesResources.resx | 6 ------ .../Core/Portable/xlf/FeaturesResources.cs.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.de.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.es.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.fr.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.it.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ja.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ko.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.pl.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ru.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.tr.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 10 ---------- 56 files changed, 272 insertions(+), 272 deletions(-) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx index 5ad67910a9679..fecbecd2ecbd5 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx @@ -210,6 +210,12 @@ Variable declaration can be deconstructed + + Local function can be made static + + + Make local function 'static' + {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf index 4b65f74dd2178..9c104732bf230 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf index 51d164d9255f8..cd965a374fb39 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf index a202dc4663708..caa8e7fb819f7 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf index 692637a92c67e..aebbde67a69e4 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf index dfdae7c36ce3e..b871e8f01b1fc 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf index ea04cb2b56279..9c79b36d4815b 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf index 7f28b30ae6ddf..a6b2ac1e74782 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf index 1720d528600c6..c0b5f71324ea7 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf index 0d564ae0a951d..18a8f9759e5c2 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf index 6886af67f604f..248072588f899 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf index f5176f627a1ff..44a0da5018e3d 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf index a1b3849ce4b42..739d729eafc00 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf index 78ee10db86a08..bdac3918e2502 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Local function can be made static + Local function can be made static + + + + Make local function 'static' + Make local function 'static' + + Simplify 'default' expression Simplify 'default' expression diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx index 5aeef948ece79..3b4c51953448d 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx @@ -126,4 +126,10 @@ Remove unreachable code + + Pass in captured variables as arguments + + + Warning: Adding parameters to local function declaration may produce invalid code. + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf index 22fe0ec795bc9..d16c46761e333 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.de.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.de.xlf index 00b32008e070f..fe2f64f2dc71e 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.de.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.de.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.es.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.es.xlf index d81bc2a710441..4f326f0cad583 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.es.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.es.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.fr.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.fr.xlf index 6f8beeb519738..bc9d877db4ecf 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.fr.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.fr.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.it.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.it.xlf index 8e0b13b02102f..fd5f9f462901e 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.it.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.it.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ja.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ja.xlf index de89f6a82c16e..844f6a0dbcfe4 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ja.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ja.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ko.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ko.xlf index 845f9c81e6f75..c8f1eefb2942c 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ko.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ko.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pl.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pl.xlf index fdd523451b2eb..8f935f803fbbf 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pl.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pl.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pt-BR.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pt-BR.xlf index c4b8644775e7e..68ab4387159cf 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pt-BR.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pt-BR.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ru.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ru.xlf index 09ceb411b9811..c32379510f394 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ru.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ru.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.tr.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.tr.xlf index 985419bb53208..2c1550ba99dbb 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.tr.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.tr.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hans.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hans.xlf index 70391413b0a9a..33190633aebe9 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hans.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hans.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hant.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hant.xlf index 6bf3a8b8879d2..3370cdf2e35b0 100644 --- a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hant.xlf +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hant.xlf @@ -7,6 +7,11 @@ Add 'this.' + + Pass in captured variables as arguments + Pass in captured variables as arguments + + Remove Unnecessary Usings Remove Unnecessary Usings @@ -17,6 +22,11 @@ Remove unreachable code + + Warning: Adding parameters to local function declaration may produce invalid code. + Warning: Adding parameters to local function declaration may produce invalid code. + + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx index 0e5eb9d0e71c5..5580a282040fc 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx @@ -612,12 +612,6 @@ switch statement case clause {Locked="switch"}{Locked="case"} "switch" and "case" are a C# keyword and should not be localized. - - Warning: Adding parameters to local function declaration may produce invalid code. - - - Pass in captured variables as arguments - Reverse 'for' statement {Locked="for"} "for" is a C# keyword and should not be localized. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf index beaffbcbc6187..24151d68c1521 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf @@ -132,11 +132,6 @@ Nastavit jako ref struct {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Předat zachycené proměnné jako argumenty - - Remove unnecessary casts Odebrat nepotřebná přetypování @@ -177,11 +172,6 @@ Upozornění: dočasné vkládání do volání podmíněné metody. - - Warning: Adding parameters to local function declaration may produce invalid code. - Upozornění: Když se do deklarace místní funkce přidají parametry, může to vytvořit neplatný kód. - - '{0}' is not null here. {0} tady není null. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf index 78f45798e53a3..8fcc6c57cbd0f 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf @@ -132,11 +132,6 @@ "ref struct" erstellen {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Erfasste Variablen als Argumente übergeben - - Remove unnecessary casts Nicht erforderliche Umwandlungen entfernen @@ -177,11 +172,6 @@ Warnung: temporäres Inlining in bedingtem Methodenaufruf. - - Warning: Adding parameters to local function declaration may produce invalid code. - Warnung: Das Hinzufügen von Parametern zur Deklaration einer lokalen Funktion kann zu ungültigem Code führen. - - '{0}' is not null here. "{0}" ist hier nicht NULL. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf index 3857c97d76c3e..c53791571922b 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf @@ -132,11 +132,6 @@ Convertir "ref struct" {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Pasar variables capturadas como argumentos - - Remove unnecessary casts Quitar conversiones innecesarias @@ -177,11 +172,6 @@ Advertencia: Inserción de una llamada temporal en otra de método condicional. - - Warning: Adding parameters to local function declaration may produce invalid code. - Advertencia: Agregar parámetros a la declaración de función local puede generar código no válido. - - '{0}' is not null here. "{0}" no es NULL aquí. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf index c4de91b2c7a0d..081c0c370e859 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf @@ -132,11 +132,6 @@ Définir 'ref struct' {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Passer les variables capturées en tant qu'arguments - - Remove unnecessary casts Supprimer les casts inutiles @@ -177,11 +172,6 @@ Avertissement : Inlining temporaire dans un appel de méthode conditionnel. - - Warning: Adding parameters to local function declaration may produce invalid code. - Avertissement : L'ajout de paramètres à la déclaration de fonction locale peut produire du code non valide. - - '{0}' is not null here. '{0}' n'a pas une valeur null ici. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf index 56b6aaff21ff0..e6eaf11d54624 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf @@ -132,11 +132,6 @@ Imposta come 'ref struct' {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Passa le variabili acquisite come argomenti - - Remove unnecessary casts Rimuovi i cast non necessari @@ -177,11 +172,6 @@ Avviso: incorporamento dell'elemento temporaneo nella chiamata a un metodo condizionale. - - Warning: Adding parameters to local function declaration may produce invalid code. - Avviso: l'aggiunta di parametri alla dichiarazione di funzione locale potrebbe produrre codice non valido. - - '{0}' is not null here. '{0}' non è Null in questo punto. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf index 54bb84e97c418..1a76e5714995a 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf @@ -132,11 +132,6 @@ 'ref struct' を作成します {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - キャプチャされた変数を引数として渡す - - Remove unnecessary casts 不要なキャストを削除する @@ -177,11 +172,6 @@ 警告: 一時メソッド呼び出しを条件付きメソッド呼び出しにインライン展開しています。 - - Warning: Adding parameters to local function declaration may produce invalid code. - 警告: ローカル関数の宣言にパラメーターを追加すると、無効なコードが生成される可能性があります。 - - '{0}' is not null here. ここでは、'{0}' は null ではありません。 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf index 6b1569d2e4329..f5b438be57a2f 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf @@ -132,11 +132,6 @@ 'ref struct'로 지정 {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - 캡처된 변수를 인수로 전달 - - Remove unnecessary casts 불필요한 캐스트 제거 @@ -177,11 +172,6 @@ 경고: 임시 작업을 조건부 메서드 호출로 인라인 처리합니다. - - Warning: Adding parameters to local function declaration may produce invalid code. - 경고: 로컬 함수 선언에 매개 변수를 추가할 경우 잘못된 코드가 생성될 수 있습니다. - - '{0}' is not null here. '{0}'은(는) 여기에서 null이 아닙니다. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf index dbfd2243ac0b2..3242fc4967b04 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf @@ -132,11 +132,6 @@ Ustaw jako „ref struct” {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Przekaż przechwycone zmienne jako argumenty - - Remove unnecessary casts Usuń niepotrzebne rzutowania @@ -177,11 +172,6 @@ Ostrzeżenie: tymczasowe wbudowywanie do wywołania metody warunkowej. - - Warning: Adding parameters to local function declaration may produce invalid code. - Ostrzeżenie: Dodanie parametrów do deklaracji funkcji lokalnej może prowadzić do powstania nieprawidłowego kodu. - - '{0}' is not null here. Element „{0}” nie ma wartości null w tym miejscu. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf index 50c72109d98b6..53151120ad860 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf @@ -132,11 +132,6 @@ Alterar 'ref struct' {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Passar variáveis capturadas como argumentos - - Remove unnecessary casts Remover conversões desnecessárias @@ -177,11 +172,6 @@ Aviso: embutindo a chamada de método temporária na condicional. - - Warning: Adding parameters to local function declaration may produce invalid code. - Aviso: a adição de parâmetros à declaração de função local pode produzir um código inválido. - - '{0}' is not null here. '{0}' não é nulo aqui. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf index 564940e011634..415b34d47109a 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf @@ -132,11 +132,6 @@ Сделать ref struct {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Передача захваченных переменных в качестве аргументов - - Remove unnecessary casts Удалить ненужные приведения @@ -177,11 +172,6 @@ Предупреждение: встраивание временных элементов в условный вызов метода. - - Warning: Adding parameters to local function declaration may produce invalid code. - Предупреждение! Добавление параметров в объявление локальной функции может привести к недопустимому коду. - - '{0}' is not null here. Здесь "{0}" имеет значение, отличное от NULL. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf index 7276782aae4f0..5dc4f06f08ef3 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf @@ -132,11 +132,6 @@ 'ref struct' yap {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - Yakalanan değişkenleri bağımsız değişken olarak geçir - - Remove unnecessary casts Gereksiz atamaları kaldır @@ -177,11 +172,6 @@ Uyarı: Koşullu yöntem çağrısında geçici öğe satır içinde kullanılıyor. - - Warning: Adding parameters to local function declaration may produce invalid code. - Uyarı: Yerel işlev bildirimine parametre eklendiğinde geçersiz kod üretilebilir. - - '{0}' is not null here. '{0}' burada null değil. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf index d1b95c117d967..bda76897b96c3 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf @@ -132,11 +132,6 @@ 生成 "ref struct" {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - 以参数形式传入捕获的变量 - - Remove unnecessary casts 删除不必要的转换 @@ -177,11 +172,6 @@ 警告: 即将在条件方法调用中内联临时内容。 - - Warning: Adding parameters to local function declaration may produce invalid code. - 警告: 将参数添加到本地函数声明可能产生无效的代码。 - - '{0}' is not null here. “{0}”在此处不为 null。 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf index 50ef9c4afe756..9cfaf32d1ed97 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf @@ -132,11 +132,6 @@ 設為 'ref struct' {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Pass in captured variables as arguments - 以引數形式傳入擷取到的變數 - - Remove unnecessary casts 移除不必要的 Cast @@ -177,11 +172,6 @@ 警告: 內嵌臨時加入條件式方法呼叫。 - - Warning: Adding parameters to local function declaration may produce invalid code. - 警告: 新增參數到區域函式宣告可能會產生無效的程式碼。 - - '{0}' is not null here. '{0}' 在此不是 null。 diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 6aa8dacf3753f..49beb6411b7b8 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -1369,12 +1369,6 @@ This version used in: {2} Wrap and align expression - - Local function can be made static - - - Make local function 'static' - Use simple 'using' statement diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index e4c582e364530..08521daa30747 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -387,16 +387,6 @@ Převrátit podmínku - - Local function can be made static - Místní funkce se dá nastavit jako statická. - - - - Make local function 'static' - Nastavit místní funkci jako statickou - - Merge with nested '{0}' statement Sloučit s vnořeným příkazem {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index e3c197228e6f2..5521719a3fcd3 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -387,16 +387,6 @@ Bedingten Operator umkehren - - Local function can be made static - Die lokale Funktion kann als statisch festgelegt werden. - - - - Make local function 'static' - Lokale Funktion als "static" festlegen - - Merge with nested '{0}' statement Mit geschachtelter {0}-Anweisung zusammenführen diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index 449bacfd79a88..0c7a5af16459b 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -387,16 +387,6 @@ Invertir condicional - - Local function can be made static - La función local se puede convertir en estática - - - - Make local function 'static' - Convertir la función local "static" - - Merge with nested '{0}' statement Combinar con la instrucción "{0}" anidada diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 8379e91eda2e4..79d5947a084f7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -387,16 +387,6 @@ Inverser un élément conditionnel - - Local function can be made static - Une fonction locale peut être rendue statique - - - - Make local function 'static' - Rendre la fonction locale 'static' - - Merge with nested '{0}' statement Fusionner avec l'instruction '{0}' imbriquée diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index 02654c08faeb6..ddbf7ac6ce5c2 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -387,16 +387,6 @@ Inverti espressione condizionale - - Local function can be made static - La funzione locale può essere resa statica - - - - Make local function 'static' - Rendi la funzione locale 'static' - - Merge with nested '{0}' statement Unisci con istruzione '{0}' nidificata diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index bb3f340606453..9cf943e957022 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -387,16 +387,6 @@ 条件を反転します - - Local function can be made static - ローカル関数を静的にすることができます - - - - Make local function 'static' - ローカル関数を 'static' にします - - Merge with nested '{0}' statement 入れ子になった '{0}' ステートメントとマージします diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 41ec5c1f0f32e..b2c32fb033710 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -387,16 +387,6 @@ 조건 반전 - - Local function can be made static - 로컬 함수를 정적으로 지정할 수 있습니다. - - - - Make local function 'static' - 로컬 함수를 '정적'으로 지정 - - Merge with nested '{0}' statement 중첩 '{0}' 문과 병합 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 20e256b44738f..276a6c05e98d2 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -387,16 +387,6 @@ Odwróć warunkowe - - Local function can be made static - Funkcję lokalną można ustawić jako statyczną - - - - Make local function 'static' - Ustaw funkcję lokalną jako „static” - - Merge with nested '{0}' statement Scal z zagnieżdżoną instrukcją „{0}” diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 233d15e042861..cb1176bd3e9cb 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -387,16 +387,6 @@ Inverter condicional - - Local function can be made static - A função local pode ser alterada para estática - - - - Make local function 'static' - Alterar a função local para 'static' - - Merge with nested '{0}' statement Mesclar com a instrução '{0}' aninhada diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index dd79c6e117d55..705661895c62c 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -387,16 +387,6 @@ Инвертировать условный оператор - - Local function can be made static - Локальную функцию можно сделать статической - - - - Make local function 'static' - Сделать локальную функцию статической - - Merge with nested '{0}' statement Объединить с вложенным оператором "{0}" diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 12d158c995c2c..f3ba3ead63e98 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -387,16 +387,6 @@ Koşullu öğeyi ters çevir - - Local function can be made static - Yerel işlev statik yapılabilir - - - - Make local function 'static' - Yerel işlevi 'static' yap - - Merge with nested '{0}' statement İç içe '{0}' deyimiyle birleştir diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 2bf044412b41c..c56d3549f1735 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -387,16 +387,6 @@ 反转条件 - - Local function can be made static - 可以使本地函数成为静态函数 - - - - Make local function 'static' - 使本地函数成为静态函数 - - Merge with nested '{0}' statement 与嵌套的 "{0}" 语句合并 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index 963b8abb1d455..7f659c0e71b3a 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -387,16 +387,6 @@ 反轉條件 - - Local function can be made static - 區域函式可以變成靜態 - - - - Make local function 'static' - 將區域函式設為 'static' - - Merge with nested '{0}' statement 與巢狀 '{0}' 陳述式合併 From d0556cb7b7bc4b3eb82b9892fe591a1c4bc0b25c Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 3 Apr 2020 11:35:21 -0700 Subject: [PATCH 21/50] Implement faster equality for naming styles option --- .../Compiler/Core/NamingStyles/NamingStyle.cs | 28 ++++++++++++- .../Serialization/NamingStylePreferences.cs | 18 ++++++--- .../Serialization/SerializableNamingRule.cs | 23 ++++++++++- .../Serialization/SymbolSpecification.cs | 39 +++++++++++++++---- 4 files changed, 94 insertions(+), 14 deletions(-) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/NamingStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/NamingStyle.cs index d70866901c0b7..fa593e79d081c 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/NamingStyle.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/NamingStyle.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.NamingStyles { - internal partial struct NamingStyle + internal partial struct NamingStyle : IEquatable { public Guid ID { get; } public string Name { get; } @@ -63,6 +63,32 @@ public NamingStyle With( newName, newPrefix, newSuffix, newWordSeparator, newCapitalizationScheme); } + public override bool Equals(object obj) + { + return obj is NamingStyle other + && Equals(other); + } + + public bool Equals(NamingStyle other) + { + return ID == other.ID + && Name == other.Name + && Prefix == other.Prefix + && Suffix == other.Suffix + && WordSeparator == other.WordSeparator + && CapitalizationScheme == other.CapitalizationScheme; + } + + public override int GetHashCode() + { + return Hash.Combine(ID.GetHashCode(), + Hash.Combine(Name?.GetHashCode() ?? 0, + Hash.Combine(Prefix?.GetHashCode() ?? 0, + Hash.Combine(Suffix?.GetHashCode() ?? 0, + Hash.Combine(WordSeparator?.GetHashCode() ?? 0, + (int)CapitalizationScheme))))); + } + public string CreateName(ImmutableArray words) { var wordsWithCasing = ApplyCapitalization(words); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/NamingStylePreferences.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/NamingStylePreferences.cs index 543005577eda3..99ffd45f7c00b 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/NamingStylePreferences.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/NamingStylePreferences.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Xml.Linq; using Microsoft.CodeAnalysis.NamingStyles; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles { @@ -17,7 +18,7 @@ namespace Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles /// 2. Name Style /// 3. Naming Rule (points to Symbol Specification IDs) /// - internal class NamingStylePreferences : IEquatable + internal sealed class NamingStylePreferences : IEquatable { private const int s_serializationVersion = 5; @@ -81,9 +82,12 @@ public override bool Equals(object obj) public bool Equals(NamingStylePreferences other) { - return other == null - ? false - : CreateXElement().ToString() == other.CreateXElement().ToString(); + if (other is null) + return false; + + return SymbolSpecifications.SequenceEqual(other.SymbolSpecifications) + && NamingStyles.SequenceEqual(other.NamingStyles) + && NamingRules.SequenceEqual(other.NamingRules); } public static bool operator ==(NamingStylePreferences left, NamingStylePreferences right) @@ -104,7 +108,11 @@ public bool Equals(NamingStylePreferences other) => !(left == right); public override int GetHashCode() - => CreateXElement().ToString().GetHashCode(); + { + return Hash.Combine(Hash.CombineValues(SymbolSpecifications), + Hash.Combine(Hash.CombineValues(NamingStyles), + Hash.CombineValues(NamingRules))); + } private static readonly string _defaultNamingPreferencesString = $@" diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/SerializableNamingRule.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/SerializableNamingRule.cs index 2973cda3bfa2f..df2f911648232 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/SerializableNamingRule.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/SerializableNamingRule.cs @@ -4,10 +4,11 @@ using System; using System.Xml.Linq; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles { - internal class SerializableNamingRule + internal sealed class SerializableNamingRule : IEquatable { public Guid SymbolSpecificationID; public Guid NamingStyleID; @@ -40,5 +41,25 @@ internal static SerializableNamingRule FromXElement(XElement namingRuleElement) SymbolSpecificationID = Guid.Parse(namingRuleElement.Attribute(nameof(SymbolSpecificationID)).Value) }; } + + public override bool Equals(object obj) + { + return Equals(obj as SerializableNamingRule); + } + + public bool Equals(SerializableNamingRule other) + { + return other != null + && SymbolSpecificationID.Equals(other.SymbolSpecificationID) + && NamingStyleID.Equals(other.NamingStyleID) + && EnforcementLevel == other.EnforcementLevel; + } + + public override int GetHashCode() + { + return Hash.Combine(SymbolSpecificationID.GetHashCode(), + Hash.Combine(NamingStyleID.GetHashCode(), + (int)EnforcementLevel)); + } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/SymbolSpecification.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/SymbolSpecification.cs index 6afad71257482..c0543c03d141f 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/SymbolSpecification.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/Serialization/SymbolSpecification.cs @@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles { - internal class SymbolSpecification + internal sealed class SymbolSpecification : IEquatable { private static readonly SymbolSpecification DefaultSymbolSpecificationTemplate = CreateDefaultSymbolSpecification(); @@ -182,6 +182,32 @@ private bool AllMatches(ImmutableArray matchers, return true; } + public override bool Equals(object obj) + { + return Equals(obj as SymbolSpecification); + } + + public bool Equals(SymbolSpecification other) + { + if (other is null) + return false; + + return ID == other.ID + && Name == other.Name + && ApplicableSymbolKindList.SequenceEqual(other.ApplicableSymbolKindList) + && ApplicableAccessibilityList.SequenceEqual(other.ApplicableAccessibilityList) + && RequiredModifierList.SequenceEqual(other.RequiredModifierList); + } + + public override int GetHashCode() + { + return Hash.Combine(ID.GetHashCode(), + Hash.Combine(Name.GetHashCode(), + Hash.Combine(Hash.CombineValues(ApplicableSymbolKindList), + Hash.Combine(Hash.CombineValues(ApplicableAccessibilityList), + Hash.CombineValues(RequiredModifierList))))); + } + internal XElement CreateXElement() { return new XElement(nameof(SymbolSpecification), @@ -338,11 +364,10 @@ public bool Equals(SymbolKindOrTypeKind other) => this.SymbolKind == other.SymbolKind && this.TypeKind == other.TypeKind && this.MethodKind == other.MethodKind; public override int GetHashCode() - => Hash.CombineValues(new[] { - (int)this.SymbolKind.GetValueOrDefault(), - (int)this.TypeKind.GetValueOrDefault(), - (int)this.MethodKind.GetValueOrDefault() - }); + { + return Hash.Combine((int)SymbolKind.GetValueOrDefault(), + Hash.Combine((int)TypeKind.GetValueOrDefault(), (int)MethodKind.GetValueOrDefault())); + } } public struct ModifierKind : ISymbolMatcher, IEquatable @@ -437,7 +462,7 @@ public override bool Equals(object obj) => obj is ModifierKind kind && Equals(kind); public override int GetHashCode() - => ModifierKindWrapper.GetHashCode(); + => (int)ModifierKindWrapper; public bool Equals(ModifierKind other) => ModifierKindWrapper == other.ModifierKindWrapper; From 3ccf504538923a745b79e16657b790c043686e13 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 13:33:31 -0700 Subject: [PATCH 22/50] Revert unintentional change --- .../MakeLocalFunctionStaticCodeFixHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs index b234bd30d2b6f..92114f7183cc3 100644 --- a/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs +++ b/src/Features/CSharp/Portable/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs @@ -133,7 +133,7 @@ public static async Task MakeLocalFunctionStaticAsync( { syntaxEditor.ReplaceNode( identifierNode, - (node, generator) => generator.IdentifierName(parameter.Name).WithTriviaFrom(node)); + (node, generator) => generator.IdentifierName(parameter.Name.ToIdentifierToken()).WithTriviaFrom(node)); } } } @@ -155,7 +155,7 @@ public static async Task MakeLocalFunctionStaticAsync( localFunctionWithNewParameters = localFunctionWithNewParameters.WithAdditionalAnnotations(annotation); } - return AddStaticModifier(localFunctionWithNewParameters, SyntaxGenerator.GetGenerator(document)); + return AddStaticModifier(localFunctionWithNewParameters, CSharpSyntaxGenerator.Instance); }); } From 0064c7de5a28f8196ab1630e5ce444705b7a0296 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 3 Apr 2020 11:36:53 -0700 Subject: [PATCH 23/50] Cache common options in AbstractTriviaDataFactory --- .../Engine/Trivia/TriviaDataFactory.cs | 16 ++++++++-------- .../Engine/AbstractTriviaDataFactory.cs | 14 +++++++++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/TriviaDataFactory.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/TriviaDataFactory.cs index e988f2015a404..b18a78c6b629e 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/TriviaDataFactory.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/TriviaDataFactory.cs @@ -129,10 +129,10 @@ private TriviaData GetWhitespaceOnlyTriviaInfo(SyntaxToken token1, SyntaxToken t private int CalculateSpaces(SyntaxToken token1, SyntaxToken token2) { - var initialColumn = (token1.RawKind == 0) ? 0 : this.TreeInfo.GetOriginalColumn(this.Options.GetOption(FormattingOptions2.TabSize), token1) + token1.Span.Length; + var initialColumn = (token1.RawKind == 0) ? 0 : this.TreeInfo.GetOriginalColumn(TabSize, token1) + token1.Span.Length; var textSnippet = this.TreeInfo.GetTextBetween(token1, token2); - return textSnippet.ConvertTabToSpace(this.Options.GetOption(FormattingOptions2.TabSize), initialColumn, textSnippet.Length); + return textSnippet.ConvertTabToSpace(TabSize, initialColumn, textSnippet.Length); } private (bool canUseTriviaAsItIs, int lineBreaks, int indentation) GetLineBreaksAndIndentation(Analyzer.AnalysisResult result) @@ -140,7 +140,7 @@ private int CalculateSpaces(SyntaxToken token1, SyntaxToken token2) Debug.Assert(result.Tab >= 0); Debug.Assert(result.LineBreaks >= 0); - var indentation = result.Tab * this.Options.GetOption(FormattingOptions2.TabSize) + result.Space; + var indentation = result.Tab * TabSize + result.Space; if (result.HasTrailingSpace || result.HasUnknownWhitespace) { if (result.HasUnknownWhitespace && result.LineBreaks == 0 && indentation == 0) @@ -152,7 +152,7 @@ private int CalculateSpaces(SyntaxToken token1, SyntaxToken token2) return (canUseTriviaAsItIs: false, result.LineBreaks, indentation); } - if (!this.Options.GetOption(FormattingOptions2.UseTabs)) + if (!UseTabs) { if (result.Tab > 0) { @@ -162,7 +162,7 @@ private int CalculateSpaces(SyntaxToken token1, SyntaxToken token2) return (canUseTriviaAsItIs: true, result.LineBreaks, indentation); } - Debug.Assert(this.Options.GetOption(FormattingOptions2.UseTabs)); + Debug.Assert(UseTabs); // tab can only appear before space to be a valid tab for indentation if (result.HasTabAfterSpace) @@ -170,13 +170,13 @@ private int CalculateSpaces(SyntaxToken token1, SyntaxToken token2) return (canUseTriviaAsItIs: false, result.LineBreaks, indentation); } - if (result.Space >= this.Options.GetOption(FormattingOptions2.TabSize)) + if (result.Space >= TabSize) { return (canUseTriviaAsItIs: false, result.LineBreaks, indentation); } - Debug.Assert((indentation / this.Options.GetOption(FormattingOptions2.TabSize)) == result.Tab); - Debug.Assert((indentation % this.Options.GetOption(FormattingOptions2.TabSize)) == result.Space); + Debug.Assert((indentation / TabSize) == result.Tab); + Debug.Assert((indentation % TabSize) == result.Space); return (canUseTriviaAsItIs: true, result.LineBreaks, indentation); } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractTriviaDataFactory.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractTriviaDataFactory.cs index 6d85d64944697..a937fd2a0a1de 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractTriviaDataFactory.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractTriviaDataFactory.cs @@ -17,6 +17,10 @@ internal abstract partial class AbstractTriviaDataFactory protected readonly TreeData TreeInfo; protected readonly AnalyzerConfigOptions Options; + protected readonly bool UseTabs; + protected readonly int TabSize; + protected readonly int IndentationSize; + private readonly Whitespace[] _spaces = new Whitespace[SpaceCacheSize]; private readonly Whitespace[,] _whitespaces = new Whitespace[LineBreakCacheSize, IndentationLevelCacheSize]; @@ -28,6 +32,10 @@ protected AbstractTriviaDataFactory(TreeData treeInfo, AnalyzerConfigOptions opt this.TreeInfo = treeInfo; this.Options = options; + UseTabs = options.GetOption(FormattingOptions2.UseTabs); + TabSize = options.GetOption(FormattingOptions2.TabSize); + IndentationSize = options.GetOption(FormattingOptions2.IndentationSize); + for (var i = 0; i < SpaceCacheSize; i++) { _spaces[i] = new Whitespace(this.Options, space: i, elastic: false, language: treeInfo.Root.Language); @@ -67,11 +75,11 @@ protected TriviaData GetWhitespaceTriviaData(int lineBreaks, int indentation, bo useTriviaAsItIs && lineBreaks > 0 && lineBreaks <= LineBreakCacheSize && - indentation % this.Options.GetOption(FormattingOptions2.IndentationSize) == 0; + indentation % IndentationSize == 0; if (canUseCache) { - var indentationLevel = indentation / this.Options.GetOption(FormattingOptions2.IndentationSize); + var indentationLevel = indentation / IndentationSize; if (indentationLevel < IndentationLevelCacheSize) { var lineIndex = lineBreaks - 1; @@ -94,7 +102,7 @@ private void EnsureWhitespaceTriviaInfo(int lineIndex, int indentationLevel) // set up caches if (_whitespaces[lineIndex, indentationLevel] == null) { - var indentation = indentationLevel * this.Options.GetOption(FormattingOptions2.IndentationSize); + var indentation = indentationLevel * IndentationSize; var triviaInfo = new Whitespace(this.Options, lineBreaks: lineIndex + 1, indentation: indentation, elastic: false, language: this.TreeInfo.Root.Language); Interlocked.CompareExchange(ref _whitespaces[lineIndex, indentationLevel], triviaInfo, null); } From e4d788ef2d7ba1d5a8694d7a8b2d5d96ae929550 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 3 Apr 2020 14:32:08 -0700 Subject: [PATCH 24/50] Remove origina name parameter. it's redundant. --- ...tractEditorInlineRenameService.InlineRenameLocationSet.cs | 4 ++-- src/EditorFeatures/Test2/Rename/RenameEngineResult.vb | 2 +- .../Rename/ConflictEngine/ConflictResolver.Session.cs | 3 +-- .../Core/Portable/Rename/ConflictEngine/ConflictResolver.cs | 5 +---- src/Workspaces/Core/Portable/Rename/Renamer.cs | 3 +-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs b/src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs index a8221796b849f..3932901ab5b44 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs @@ -40,8 +40,8 @@ private InlineRenameLocation ConvertLocation(RenameLocation location) public async Task GetReplacementsAsync(string replacementText, OptionSet optionSet, CancellationToken cancellationToken) { var conflicts = await ConflictResolver.ResolveConflictsAsync( - _renameLocationSet, _renameLocationSet.Symbol.Name, - _renameInfo.GetFinalSymbolName(replacementText), nonConflictSymbols: null, cancellationToken: cancellationToken).ConfigureAwait(false); + _renameLocationSet, _renameInfo.GetFinalSymbolName(replacementText), + nonConflictSymbols: null, cancellationToken: cancellationToken).ConfigureAwait(false); return new InlineRenameReplacementInfo(conflicts); } diff --git a/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb b/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb index 27c9e81abfe5c..1064be74c9d76 100644 --- a/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb +++ b/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb @@ -79,7 +79,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename Dim locations = RenameLocations.FindAsync(symbolAndProjectId, workspace.CurrentSolution, optionSet, CancellationToken.None).Result Dim originalName = symbol.Name.Split("."c).Last() - Dim result = ConflictResolver.ResolveConflictsAsync(locations, originalName, renameTo, nonConflictSymbols:=Nothing, cancellationToken:=CancellationToken.None).Result + Dim result = ConflictResolver.ResolveConflictsAsync(locations, renameTo, nonConflictSymbols:=Nothing, cancellationToken:=CancellationToken.None).Result engineResult = New RenameEngineResult(workspace, result, renameTo) engineResult.AssertUnlabeledSpansRenamedAndHaveNoConflicts() diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs index 0231a3a906942..bd7ddb2f7afbc 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs @@ -56,14 +56,13 @@ private class Session public Session( RenameLocations renameLocationSet, Location renameSymbolDeclarationLocation, - string originalText, string replacementText, ImmutableHashSet nonConflictSymbols, CancellationToken cancellationToken) { _renameLocationSet = renameLocationSet; _renameSymbolDeclarationLocation = renameSymbolDeclarationLocation; - _originalText = originalText; + _originalText = renameLocationSet.Symbol.Name; _replacementText = replacementText; _optionSet = renameLocationSet.Options; _nonConflictSymbols = nonConflictSymbols; diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs index 4aa6bf77de7d8..4d23ab6ecb63d 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs @@ -41,7 +41,6 @@ internal static partial class ConflictResolver /// resolves them where possible. /// /// The locations to perform the renaming at. - /// The original name of the identifier. /// The new name of the identifier /// Used after renaming references. References that now bind to any of these /// symbols are not considered to be in conflict. Useful for features that want to rename existing references to @@ -51,7 +50,6 @@ internal static partial class ConflictResolver /// A conflict resolution containing the new solution. public static Task ResolveConflictsAsync( RenameLocations renameLocationSet, - string originalText, string replacementText, ImmutableHashSet nonConflictSymbols, CancellationToken cancellationToken) @@ -68,8 +66,7 @@ public static Task ResolveConflictsAsync( var session = new Session( renameLocationSet, renameSymbolDeclarationLocation, - originalText, replacementText, - nonConflictSymbols, cancellationToken); + replacementText, nonConflictSymbols, cancellationToken); return session.ResolveConflictsAsync(); } diff --git a/src/Workspaces/Core/Portable/Rename/Renamer.cs b/src/Workspaces/Core/Portable/Rename/Renamer.cs index 21752b8642710..1be67f8779b56 100644 --- a/src/Workspaces/Core/Portable/Rename/Renamer.cs +++ b/src/Workspaces/Core/Portable/Rename/Renamer.cs @@ -61,8 +61,7 @@ internal static async Task RenameAsync( cancellationToken.ThrowIfCancellationRequested(); var conflictResolution = await ConflictResolver.ResolveConflictsAsync( - locations, locations.SymbolAndProjectId.Symbol.Name, newName, - nonConflictSymbols, cancellationToken).ConfigureAwait(false); + locations, newName, nonConflictSymbols, cancellationToken).ConfigureAwait(false); return conflictResolution.NewSolution; } From 77fb9ae222c85fe65303c5f114bf11fdb15a379d Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 15:20:16 -0700 Subject: [PATCH 25/50] Port UseSimpleUsingStatement analyzer/fixer/test to shared layer --- src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems | 1 + .../UseSimpleUsingStatementDiagnosticAnalyzer.cs | 4 ++-- src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems | 1 + .../UseSimpleUsingStatementCodeFixProvider.cs | 4 ++-- .../CSharp/Tests/CSharpAnalyzers.UnitTests.projitems | 1 + .../UseSimpleUsingStatement/UseSimpleUsingStatementTests.cs | 0 6 files changed, 7 insertions(+), 4 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs (96%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs (96%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/UseSimpleUsingStatement/UseSimpleUsingStatementTests.cs (100%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index 36f18bafd3cb9..04c9b6a62976e 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -75,6 +75,7 @@ + diff --git a/src/Features/CSharp/Portable/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs similarity index 96% rename from src/Features/CSharp/Portable/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs index 6da4a0a6334d1..b3a79b597a89b 100644 --- a/src/Features/CSharp/Portable/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs @@ -53,8 +53,8 @@ public UseSimpleUsingStatementDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseSimpleUsingStatementDiagnosticId, CSharpCodeStyleOptions.PreferSimpleUsingStatement, LanguageNames.CSharp, - new LocalizableResourceString(nameof(FeaturesResources.Use_simple_using_statement), FeaturesResources.ResourceManager, typeof(FeaturesResources)), - new LocalizableResourceString(nameof(FeaturesResources.using_statement_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Use_simple_using_statement), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)), + new LocalizableResourceString(nameof(CSharpAnalyzersResources.using_statement_can_be_simplified), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources))) { } diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index 1951d713fc281..00716c4d539bb 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -51,6 +51,7 @@ + diff --git a/src/Features/CSharp/Portable/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs similarity index 96% rename from src/Features/CSharp/Portable/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs index 707ce55ecbf55..ad4b123767780 100644 --- a/src/Features/CSharp/Portable/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs @@ -143,10 +143,10 @@ private static LocalDeclarationStatementSyntax Convert(UsingStatementSyntax usin Token(SyntaxKind.SemicolonToken)).WithTrailingTrivia(ElasticCarriageReturnLineFeed); } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(FeaturesResources.Use_simple_using_statement, createChangedDocument, FeaturesResources.Use_simple_using_statement) + : base(CSharpAnalyzersResources.Use_simple_using_statement, createChangedDocument, CSharpAnalyzersResources.Use_simple_using_statement) { } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index 1852d9e2bcbda..f0f8722b720dc 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -70,6 +70,7 @@ + diff --git a/src/EditorFeatures/CSharpTest/UseSimpleUsingStatement/UseSimpleUsingStatementTests.cs b/src/Analyzers/CSharp/Tests/UseSimpleUsingStatement/UseSimpleUsingStatementTests.cs similarity index 100% rename from src/EditorFeatures/CSharpTest/UseSimpleUsingStatement/UseSimpleUsingStatementTests.cs rename to src/Analyzers/CSharp/Tests/UseSimpleUsingStatement/UseSimpleUsingStatementTests.cs From fbd68022b36ab63aac045ea5cd3699a5ce1e092a Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 15:20:35 -0700 Subject: [PATCH 26/50] xlf and resx file changes --- .../CSharp/Analyzers/CSharpAnalyzersResources.resx | 6 ++++++ .../Analyzers/xlf/CSharpAnalyzersResources.cs.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.de.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.es.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.fr.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.it.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ja.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ko.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.pl.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ru.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.tr.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf | 10 ++++++++++ src/Features/Core/Portable/FeaturesResources.resx | 6 ------ .../Core/Portable/xlf/FeaturesResources.cs.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.de.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.es.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.fr.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.it.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ja.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ko.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.pl.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ru.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.tr.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 10 ---------- 28 files changed, 136 insertions(+), 136 deletions(-) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx index 5ad67910a9679..bb18e0e7d9651 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx @@ -195,6 +195,12 @@ Use 'is null' check + + Use simple 'using' statement + + + 'using' statement can be simplified + 'if' statement can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf index 4b65f74dd2178..426e5977e59d3 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf index 51d164d9255f8..bd6e9e3b16dcb 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf index a202dc4663708..79a0f51ea8f51 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf index 692637a92c67e..bdcd5d2074e67 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf index dfdae7c36ce3e..a04d19087e41d 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf index ea04cb2b56279..14dcb9e274d11 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf index 7f28b30ae6ddf..3faade72ad3f9 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf index 1720d528600c6..a7d381035803b 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf index 0d564ae0a951d..0116cd5348795 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf index 6886af67f604f..fb827e089d958 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf index f5176f627a1ff..e9cf0041faa0a 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf index a1b3849ce4b42..f41877c19155b 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf index 78ee10db86a08..4513b421a9f0d 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf @@ -142,6 +142,11 @@ Use range operator + + Use simple 'using' statement + Use simple 'using' statement + + Use 'switch' expression Use 'switch' expression @@ -177,6 +182,11 @@ Using directive is unnecessary. + + 'using' statement can be simplified + 'using' statement can be simplified + + \ No newline at end of file diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 3db1932656494..98b7950e8b897 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -1372,12 +1372,6 @@ This version used in: {2} Make local function 'static' - - Use simple 'using' statement - - - 'using' statement can be simplified - Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index 78d15c24a600e..5903a362e73e8 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -627,11 +627,6 @@ Použijte doporučený vzor Dispose, abyste měli jistotu, že objekt vytvořený pomocí {0} se vyřadí na všech cestách: příkaz/deklarace using nebo výraz try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Použít jednoduchý příkaz using - - Value: Value: @@ -2320,11 +2315,6 @@ Tato verze se používá zde: {2}. aktualizace použití v závislých projektech - - 'using' statement can be simplified - Příkaz using lze zjednodušit. - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 722a74dd31ecf..974245e1238b7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -627,11 +627,6 @@ Verwenden Sie das empfohlene Dispose-Muster, um sicherzustellen, dass das von "{0}" erstellte Objekt in allen Pfaden gelöscht wird: using-Anweisung/-Deklaration oder try/finally. {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Einfache using-Anweisung verwenden - - Value: Value: @@ -2320,11 +2315,6 @@ Diese Version wird verwendet in: {2} Verwendungen in abhängigen Projekten werden aktualisiert. - - 'using' statement can be simplified - Die using-Anweisung kann vereinfacht werden. - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index cdaddee9c38ee..a8922622e7c16 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -627,11 +627,6 @@ Use el patrón de Dispose recomendado para asegurarse de que el objeto creado por "{0}" se desecha en todas las rutas de acceso: instrucción o declaración using o try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Use la instrucción "using" simple - - Value: Value: @@ -2320,11 +2315,6 @@ Esta versión se utiliza en: {2} actualización de usos en proyectos dependientes - - 'using' statement can be simplified - La instrucción "using" se puede simplificar - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 10611d00b3098..c8da1833a79c4 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -627,11 +627,6 @@ Utilisez le modèle Dispose recommandé pour vérifier que l'objet créé par '{0}' est supprimé sur tous les chemins : instruction/déclaration using ou try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Utiliser une instruction 'using' simple - - Value: Value: @@ -2320,11 +2315,6 @@ Version utilisée dans : {2} mise à jour des utilisations dans les projets dépendants - - 'using' statement can be simplified - L'instruction 'using' peut être simplifiée - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index bfe981e34f829..2ea12746a9164 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -627,11 +627,6 @@ Usare il criterio dispose consigliato per garantire che l'oggetto creato da '{0}' venga eliminato in tutti i percorsi, ovvero istruzione/dichiarazione using o try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Usa l'istruzione 'using' semplice - - Value: Value: @@ -2320,11 +2315,6 @@ Questa versione è usata {2} aggiornamento degli utilizzi nei progetti dipendenti - - 'using' statement can be simplified - L'istruzione 'using' può essere semplificata - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index f696c8fc56069..488be4c295534 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -627,11 +627,6 @@ 推奨された破棄パターンを使用して、'{0}' が作成したオブジェクトがすべてのパスで破棄されるようにします: using ステートメント/宣言または try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - 単純な 'using' ステートメントを使用する - - Value: Value: @@ -2320,11 +2315,6 @@ This version used in: {2} 依存プロジェクトの使用の更新 - - 'using' statement can be simplified - 'using' ステートメントは単純にできます - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 670e07287b15c..b5c173b15f4dc 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -627,11 +627,6 @@ 권장 dispose 패턴을 사용하여, '{0}'에 의해 만들어진 개체가 모든 경로(using 문/선언 또는 try/finally)에서 삭제되도록 합니다. {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - 간단한 'using' 문 사용 - - Value: Value: @@ -2320,11 +2315,6 @@ This version used in: {2} 종속 프로젝트에서 사용을 업데이트하는 중 - - 'using' statement can be simplified - 'using' 문을 간소화할 수 있습니다. - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 3b336f7f95164..0b2985afd6695 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -627,11 +627,6 @@ Użyj zalecanego wzorca likwidacji, aby upewnić się, że obiekt utworzony przez element „{0}” jest likwidowany we wszystkich ścieżkach: instrukcja/deklaracja using lub try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Użyj prostej instrukcji „using” - - Value: Value: @@ -2320,11 +2315,6 @@ Ta wersja jest używana wersja: {2} aktualizowanie użyć w projektach zależnych - - 'using' statement can be simplified - Instrukcję „using” można uprościć - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index f2902b99e9320..252d1c46ef3ef 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -627,11 +627,6 @@ Use o padrão de descarte recomendado para garantir que o objeto criado por '{0}' seja descartado em todos os caminhos: instrução/declaração using ou try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Usar a instrução 'using' simples - - Value: Value: @@ -2320,11 +2315,6 @@ Essa versão é usada no: {2} atualizar usos em projetos dependentes - - 'using' statement can be simplified - A instrução 'using' pode ser simplificada - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 2c60bdc6955cd..49f24c907cc9d 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -627,11 +627,6 @@ Используйте рекомендуемый шаблон освобождения, чтобы убедиться, что объект, созданный "{0}", освобожден для всех путей: инструкцию или объявление using либо конструкцию try/finally. {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Использовать простой оператор using - - Value: Value: @@ -2320,11 +2315,6 @@ This version used in: {2} обновление директив usage в зависимых проектах - - 'using' statement can be simplified - Оператор using можно упростить - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 809943b122f92..824fcc0d8b801 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -627,11 +627,6 @@ '{0}' tarafından oluşturulan nesnenin tüm yollarda atıldığından emin olmak için önerilen atma desenini kullanın: using deyimi/bildirimi veya try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - Basit 'using' deyimini kullan - - Value: Value: @@ -2320,11 +2315,6 @@ Bu sürüm şurada kullanılır: {2} bağımlı projelerdeki kullanımlar güncelleştiriliyor - - 'using' statement can be simplified - 'using' deyimi basitleştirilebilir - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 2ddd4b9320a22..fd74cac41899e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -627,11 +627,6 @@ 使用建议的释放模式以确保在所有路径上释放由 "{0}" 创建的对象: using 语句/声明或 try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - 使用简单的 "using" 语句 - - Value: Value: @@ -2320,11 +2315,6 @@ This version used in: {2} 更新相关项目中的用法 - - 'using' statement can be simplified - 可简化 "using" 语句 - - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index e9cb1acb6487d..55f6be6f29c1b 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -627,11 +627,6 @@ 請使用建議的處置模式,確保 '{0}' 建立的物件在所有路徑上均會經過處置: using 陳述式/宣告或 try/finally {Locked="using"}{Locked="try"}{Locked="finally"} "using", "try" and "finally" are C# keywords and should not be localized. - - Use simple 'using' statement - 使用簡單的 'using' 陳述式 - - Value: Value: @@ -2320,11 +2315,6 @@ This version used in: {2} 正在更新相依專案中的使用方式 - - 'using' statement can be simplified - 'using' 陳述式可簡化 - - \ No newline at end of file From b822423e066e27241865d6a8c7c04c04ec3dac0f Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 15:33:49 -0700 Subject: [PATCH 27/50] Port C# MakeStructFieldsWritable analyzer/fixer/tests to shared layer --- src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems | 1 + .../CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs | 4 ++-- src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems | 1 + .../CSharpMakeStructFieldsWritableCodeFixProvider.cs | 4 ++-- .../CSharp/Tests/CSharpAnalyzers.UnitTests.projitems | 1 + .../MakeStructFieldsWritable/MakeStructFieldsWritableTests.cs | 0 6 files changed, 7 insertions(+), 4 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (92%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs (94%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/MakeStructFieldsWritable/MakeStructFieldsWritableTests.cs (100%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index 36f18bafd3cb9..94c79f53645d2 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -24,6 +24,7 @@ + diff --git a/src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs similarity index 92% rename from src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs index 49e400057f075..5390934ffe46c 100644 --- a/src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs @@ -15,8 +15,8 @@ internal sealed class CSharpMakeStructFieldsWritableDiagnosticAnalyzer : Abstrac { private static readonly DiagnosticDescriptor s_diagnosticDescriptor = CreateDescriptor( IDEDiagnosticIds.MakeStructFieldsWritable, - new LocalizableResourceString(nameof(FeaturesResources.Make_readonly_fields_writable), FeaturesResources.ResourceManager, typeof(FeaturesResources)), - new LocalizableResourceString(nameof(FeaturesResources.Struct_contains_assignment_to_this_outside_of_constructor_Make_readonly_fields_writable), FeaturesResources.ResourceManager, typeof(FeaturesResources)), + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Make_readonly_fields_writable), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)), + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Struct_contains_assignment_to_this_outside_of_constructor_Make_readonly_fields_writable), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)), isUnnecessary: false); public CSharpMakeStructFieldsWritableDiagnosticAnalyzer() diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index 1951d713fc281..3220f00bd6085 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -20,6 +20,7 @@ + diff --git a/src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs similarity index 94% rename from src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs index f2a838dcbe314..35fa4cdfa13e9 100644 --- a/src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs @@ -74,10 +74,10 @@ protected override Task FixAllAsync( return Task.CompletedTask; } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(FeaturesResources.Make_readonly_fields_writable, createChangedDocument) + : base(CSharpAnalyzersResources.Make_readonly_fields_writable, createChangedDocument) { } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index 1852d9e2bcbda..3bf1a82c2bcbe 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -15,6 +15,7 @@ + diff --git a/src/EditorFeatures/CSharpTest/MakeStructFieldsWritable/MakeStructFieldsWritableTests.cs b/src/Analyzers/CSharp/Tests/MakeStructFieldsWritable/MakeStructFieldsWritableTests.cs similarity index 100% rename from src/EditorFeatures/CSharpTest/MakeStructFieldsWritable/MakeStructFieldsWritableTests.cs rename to src/Analyzers/CSharp/Tests/MakeStructFieldsWritable/MakeStructFieldsWritableTests.cs From 557cdce4bc845d1d8d21de489303003866b24862 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 15:33:58 -0700 Subject: [PATCH 28/50] xlf and resx file changes --- .../CSharp/Analyzers/CSharpAnalyzersResources.resx | 8 ++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.cs.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.de.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.es.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.fr.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.it.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ja.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ko.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.pl.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.ru.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.tr.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf | 10 ++++++++++ .../Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf | 10 ++++++++++ src/Features/Core/Portable/FeaturesResources.resx | 8 -------- .../Core/Portable/xlf/FeaturesResources.cs.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.de.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.es.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.fr.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.it.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ja.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ko.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.pl.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ru.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.tr.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 10 ---------- 28 files changed, 138 insertions(+), 138 deletions(-) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx index 5ad67910a9679..e62f10b9c362c 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx @@ -204,6 +204,14 @@ 'default' expression can be simplified + + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Deconstruct variable declaration diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf index 4b65f74dd2178..91e2360d6da65 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf index 51d164d9255f8..157b37aeabb6a 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf index a202dc4663708..41b20432d0a14 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf index 692637a92c67e..5ec638e88fc0a 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf index dfdae7c36ce3e..704b159c979af 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf index ea04cb2b56279..58579ee49a96b 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf index 7f28b30ae6ddf..f601079393708 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf index 1720d528600c6..13f4b05070ab9 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf index 0d564ae0a951d..50dee73e39177 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf index 6886af67f604f..07b08e6f13794 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf index f5176f627a1ff..e57f0cf1493ca 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf index a1b3849ce4b42..2075f68683bd8 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf index 78ee10db86a08..3da11c5d77e40 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf @@ -27,11 +27,21 @@ Indexing can be simplified + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression + + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + Struct contains assignment to 'this' outside of constructor. Make readonly fields writable + {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. + Unreachable code detected Unreachable code detected diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 3db1932656494..0408c608225f8 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -1378,10 +1378,6 @@ This version used in: {2} 'using' statement can be simplified - - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Move contents to namespace... @@ -1512,10 +1508,6 @@ This version used in: {2} Implement explicitly - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Resolve conflict markers diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index 78d15c24a600e..3b5d95c5632cf 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -377,11 +377,6 @@ Nastavit jako statickou - - Make readonly fields writable - Umožnit zápis do polí jen pro čtení (readonly) - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Převrátit podmínku @@ -512,11 +507,6 @@ Stream musí podporovat operace read a seek. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} Potlačit {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 722a74dd31ecf..29925d4364bfc 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -377,11 +377,6 @@ Als statisch festlegen - - Make readonly fields writable - readonly-Felder als schreibbar festlegen - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Bedingten Operator umkehren @@ -512,11 +507,6 @@ Stream muss Lese- und Suchvorgänge unterstützen. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} {0} unterdrücken diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index cdaddee9c38ee..4871adba69b27 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -377,11 +377,6 @@ Hacer estático - - Make readonly fields writable - Convertir en editables los campos readonly - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Invertir condicional @@ -512,11 +507,6 @@ La secuencia debe admitir las operaciones de lectura y búsqueda. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} Suprimir {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 10611d00b3098..5772ff1b72740 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -377,11 +377,6 @@ Rendre statique - - Make readonly fields writable - Rendre les champs readonly accessibles en écriture - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Inverser un élément conditionnel @@ -512,11 +507,6 @@ Le flux doit prendre en charge les opérations de lecture et de recherche. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} Supprimer {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index bfe981e34f829..2ec3b2f78d4b1 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -377,11 +377,6 @@ Imposta come statici - - Make readonly fields writable - Rendi scrivibili i campi readonly - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Inverti espressione condizionale @@ -512,11 +507,6 @@ Il flusso deve supportare operazioni di lettura e ricerca. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} Elimina {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index f696c8fc56069..200d832c8cee6 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -377,11 +377,6 @@ 静的にする - - Make readonly fields writable - readonly フィールドを書き込み可能にします - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional 条件を反転します @@ -512,11 +507,6 @@ ストリームは、読み取りとシーク操作をサポートする必要があります。 - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} {0} の非表示 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 670e07287b15c..094063e903190 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -377,11 +377,6 @@ 정적으로 만들기 - - Make readonly fields writable - readonly 필드를 쓰기 가능으로 지정 - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional 조건 반전 @@ -512,11 +507,6 @@ 스트림은 읽기 및 찾기 작업을 지원해야 합니다. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} {0}을(를) 표시하지 않음 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 3b336f7f95164..f847616ca3489 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -377,11 +377,6 @@ Ustaw jako statyczne - - Make readonly fields writable - Ustaw możliwość zapisu dla pól z deklaracją readonly - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Odwróć warunkowe @@ -512,11 +507,6 @@ Strumień musi obsługiwać operacje odczytu i wyszukiwania. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} Pomiń element {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index f2902b99e9320..ddcbbd663096b 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -377,11 +377,6 @@ Tornar estático - - Make readonly fields writable - Alterar os campos readonly para graváveis - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Inverter condicional @@ -512,11 +507,6 @@ O fluxo deve fornecer suporte a operações de leitura e busca. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} Suprimir {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 2c60bdc6955cd..63ea5487dee68 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -377,11 +377,6 @@ Сделать статическим - - Make readonly fields writable - Сделать поля readonly доступными для записи - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Инвертировать условный оператор @@ -512,11 +507,6 @@ Поток должен поддерживать операции чтения и поиска. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} Скрыть {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 809943b122f92..5581adb134f4c 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -377,11 +377,6 @@ Statik yap - - Make readonly fields writable - readonly alanları yazılabilir yap - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Koşullu öğeyi ters çevir @@ -512,11 +507,6 @@ Akış okuma ve arama işlemlerini desteklemelidir. - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} {0} eylemini bastır diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 2ddd4b9320a22..25e96ce5fe16e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -377,11 +377,6 @@ 设为静态 - - Make readonly fields writable - 使 readonly 字段可写 - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional 反转条件 @@ -512,11 +507,6 @@ 流必须支持读取和搜寻操作。 - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} 取消 {0} diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index e9cb1acb6487d..906a71b4b57f8 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -377,11 +377,6 @@ 使其變成靜態 - - Make readonly fields writable - 將 readonly 欄位設為可寫入 - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional 反轉條件 @@ -512,11 +507,6 @@ 資料流必須支援讀取及搜尋作業。 - - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - Struct contains assignment to 'this' outside of constructor. Make readonly fields writable - {Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized. - Suppress {0} 隱藏 {0} From 8637fb620f5f63befbdb816cc9827e76f9f25125 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 3 Apr 2020 12:00:39 -0700 Subject: [PATCH 29/50] Convert combinatorics tests to theories --- ...hangeSignature_CheckAllSignatureChanges.cs | 31 +++++++++---- .../AbstractChangeSignatureTests.cs | 21 +++------ ...hangeSignature_CheckAllSignatureChanges.vb | 45 ++++++++++++++----- 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/ChangeSignature/ChangeSignature_CheckAllSignatureChanges.cs b/src/EditorFeatures/CSharpTest/ChangeSignature/ChangeSignature_CheckAllSignatureChanges.cs index 803e77007617f..8b8d729754d12 100644 --- a/src/EditorFeatures/CSharpTest/ChangeSignature/ChangeSignature_CheckAllSignatureChanges.cs +++ b/src/EditorFeatures/CSharpTest/ChangeSignature/ChangeSignature_CheckAllSignatureChanges.cs @@ -13,8 +13,9 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ChangeSignature { public partial class ChangeSignatureTests : AbstractChangeSignatureTests { - [WpfFact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] - public async Task TestAllSignatureChanges_1This_3Regular_2Default_1Params() + [WpfTheory, Trait(Traits.Feature, Traits.Features.ChangeSignature)] + [MemberData(nameof(AbstractChangeSignatureTests.GetAllSignatureSpecificationsForTheory), new[] { 1, 3, 2, 1 }, MemberType = typeof(AbstractChangeSignatureTests))] + public async Task TestAllSignatureChanges_1This_3Regular_2Default_1Params(int totalParameters, int[] signature) { var markup = @" static class Ext @@ -57,12 +58,19 @@ static class Ext M(p: new[] { 5 }, y: ""four"", x: 3, c: true, b: ""two"", a: 1, o: t); } }"; - var signaturePartCounts = new[] { 1, 3, 2, 1 }; - await TestAllSignatureChangesAsync(LanguageNames.CSharp, markup, signaturePartCounts); + + await TestChangeSignatureViaCommandAsync( + LanguageNames.CSharp, + markup, + expectedSuccess: true, + updatedSignature: signature, + totalParameters: totalParameters, + verifyNoDiagnostics: true); } - [WpfFact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] - public async Task TestAllSignatureChanges_OnDelegate_3Regular() + [WpfTheory, Trait(Traits.Feature, Traits.Features.ChangeSignature)] + [MemberData(nameof(AbstractChangeSignatureTests.GetAllSignatureSpecificationsForTheory), new[] { 0, 3, 0, 0 }, MemberType = typeof(AbstractChangeSignatureTests))] + public async Task TestAllSignatureChanges_OnDelegate_3Regular(int totalParameters, int[] signature) { var markup = @" using System; @@ -151,8 +159,15 @@ void Goo4(int a, string b, bool c) { } /// void Goo5(int a, string b, bool c) { } }"; - var signaturePartCounts = new[] { 0, 3, 0, 0 }; - await TestAllSignatureChangesAsync(LanguageNames.CSharp, markup, signaturePartCounts, new CSharpParseOptions(LanguageVersion.CSharp7)); + + await TestChangeSignatureViaCommandAsync( + LanguageNames.CSharp, + markup, + expectedSuccess: true, + updatedSignature: signature, + totalParameters: totalParameters, + verifyNoDiagnostics: true, + parseOptions: new CSharpParseOptions(LanguageVersion.CSharp7)); } } } diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs b/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs index b67485162df9a..09147a0545eb7 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs @@ -157,7 +157,7 @@ private string GetSignatureDescriptionString(int[] signature, int? totalParamete /// /// A four element array containing [s, m, n, p] as /// described above. - public async Task TestAllSignatureChangesAsync(string languageName, string markup, int[] signaturePartCounts, ParseOptions parseOptions = null) + public static IEnumerable GetAllSignatureSpecificationsForTheory(int[] signaturePartCounts) { Assert.Equal(4, signaturePartCounts.Length); Assert.True(signaturePartCounts[0] == 0 || signaturePartCounts[0] == 1); @@ -167,18 +167,11 @@ public async Task TestAllSignatureChangesAsync(string languageName, string marku foreach (var signature in GetAllSignatureSpecifications(signaturePartCounts)) { - await TestChangeSignatureViaCommandAsync( - languageName, - markup, - expectedSuccess: true, - updatedSignature: signature, - totalParameters: totalParameters, - verifyNoDiagnostics: true, - parseOptions: parseOptions); + yield return new object[] { totalParameters, signature }; } } - private IEnumerable GetAllSignatureSpecifications(int[] signaturePartCounts) + private static IEnumerable GetAllSignatureSpecifications(int[] signaturePartCounts) { var regularParameterStartIndex = signaturePartCounts[0]; var defaultValueParameterStartIndex = signaturePartCounts[0] + signaturePartCounts[1]; @@ -204,7 +197,7 @@ private IEnumerable GetAllSignatureSpecifications(int[] signaturePartCoun } } - private IEnumerable> GetPermutedSubsets(int startIndex, int count) + private static IEnumerable> GetPermutedSubsets(int startIndex, int count) { foreach (var subset in GetSubsets(Enumerable.Range(startIndex, count))) { @@ -215,7 +208,7 @@ private IEnumerable> GetPermutedSubsets(int startIndex, int cou } } - private IEnumerable> GetPermutations(IEnumerable list) + private static IEnumerable> GetPermutations(IEnumerable list) { if (!list.Any()) { @@ -236,7 +229,7 @@ private IEnumerable> GetPermutations(IEnumerable list) } } - private IEnumerable GetListWithoutElementAtIndex(IEnumerable list, int skippedIndex) + private static IEnumerable GetListWithoutElementAtIndex(IEnumerable list, int skippedIndex) { var index = 0; foreach (var x in list) @@ -250,7 +243,7 @@ private IEnumerable GetListWithoutElementAtIndex(IEnumerable list, int } } - private IEnumerable> GetSubsets(IEnumerable list) + private static IEnumerable> GetSubsets(IEnumerable list) { if (!list.Any()) { diff --git a/src/EditorFeatures/VisualBasicTest/ChangeSignature/ChangeSignature_CheckAllSignatureChanges.vb b/src/EditorFeatures/VisualBasicTest/ChangeSignature/ChangeSignature_CheckAllSignatureChanges.vb index 4afb6aca94004..fc63d8f7825d9 100644 --- a/src/EditorFeatures/VisualBasicTest/ChangeSignature/ChangeSignature_CheckAllSignatureChanges.vb +++ b/src/EditorFeatures/VisualBasicTest/ChangeSignature/ChangeSignature_CheckAllSignatureChanges.vb @@ -9,8 +9,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ChangeSignature Partial Public Class ChangeSignatureTests Inherits AbstractChangeSignatureTests - - Public Async Function TestAllSignatureChanges_1This_3Regular_2Default() As Task + + + Public Async Function TestAllSignatureChanges_1This_3Regular_2Default(totalParameters As Integer, signature As Integer()) As Task Dim markup = .NormalizedValue() - Dim signaturePartCounts = {1, 3, 2, 0} - Await TestAllSignatureChangesAsync(LanguageNames.VisualBasic, markup, signaturePartCounts) + + Await TestChangeSignatureViaCommandAsync( + LanguageNames.VisualBasic, + markup, + expectedSuccess:=True, + updatedSignature:=signature, + totalParameters:=totalParameters, + verifyNoDiagnostics:=True) End Function - - Public Async Function TestAllSignatureChanges_1This_3Regular_1ParamArray() As Task + + + Public Async Function TestAllSignatureChanges_1This_3Regular_1ParamArray(totalParameters As Integer, signature As Integer()) As Task Dim markup = .NormalizedValue() - Dim signaturePartCounts = {1, 3, 0, 1} - Await TestAllSignatureChangesAsync(LanguageNames.VisualBasic, markup, signaturePartCounts) + + Await TestChangeSignatureViaCommandAsync( + LanguageNames.VisualBasic, + markup, + expectedSuccess:=True, + updatedSignature:=signature, + totalParameters:=totalParameters, + verifyNoDiagnostics:=True) End Function - - Public Async Function TestAllSignatureChanges_Delegate_3() As Task + + + Public Async Function TestAllSignatureChanges_Delegate_3(totalParameters As Integer, signature As Integer()) As Task Dim markup = .NormalizedValue() - Dim signaturePartCounts = {0, 3, 0, 0} - Await TestAllSignatureChangesAsync(LanguageNames.VisualBasic, markup, signaturePartCounts) + + Await TestChangeSignatureViaCommandAsync( + LanguageNames.VisualBasic, + markup, + expectedSuccess:=True, + updatedSignature:=signature, + totalParameters:=totalParameters, + verifyNoDiagnostics:=True) End Function End Class End Namespace From d2c8125839bae2fa25053bc41401794aba02160c Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 3 Apr 2020 12:08:21 -0700 Subject: [PATCH 30/50] Improve the performance of ProjectCacheHostServiceFactoryTests --- src/Test/Utilities/Portable/ObjectReference.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Test/Utilities/Portable/ObjectReference.cs b/src/Test/Utilities/Portable/ObjectReference.cs index 2f12231ab4b63..15bb26336dee3 100644 --- a/src/Test/Utilities/Portable/ObjectReference.cs +++ b/src/Test/Utilities/Portable/ObjectReference.cs @@ -86,13 +86,13 @@ private void ReleaseAndGarbageCollect() _strongReference = null; - // We'll loop 1000 times, or until the weak reference disappears. When we're trying to assert that the + // We'll loop 10 times, or until the weak reference disappears. When we're trying to assert that the // object is released, once the weak reference goes away, we know we're good. But if we're trying to assert // that the object is held, our only real option is to know to do it "enough" times; but if it goes away then // we are definitely done. - for (var i = 0; i < 1000 && _weakReference.IsAlive; i++) + for (var i = 0; i < 10 && _weakReference.IsAlive; i++) { - GC.Collect(); + GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, blocking: true, compacting: true); GC.WaitForPendingFinalizers(); } } From 17a9ee46b4a167b4bd5e697eeb6e1f2faa11d4b6 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 16:20:31 -0700 Subject: [PATCH 31/50] Port MisplacedUsingDirectives to shared layer --- .../Analyzers/CSharpAnalyzers.projitems | 1 + ...placedUsingDirectivesDiagnosticAnalyzer.cs | 6 ++--- .../CodeFixes/CSharpCodeFixes.projitems | 1 + ...MisplacedUsingDirectivesCodeFixProvider.cs | 23 +++++++++++++------ .../Tests/CSharpAnalyzers.UnitTests.projitems | 1 + ...acedUsingDirectivesCodeFixProviderTests.cs | 22 +++++++----------- 6 files changed, 30 insertions(+), 24 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs (90%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs (96%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProviderTests.cs (97%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index 36f18bafd3cb9..9c2daae65a520 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -24,6 +24,7 @@ + diff --git a/src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs similarity index 90% rename from src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs index c07c7d15ed4e5..4a021bffde600 100644 --- a/src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs @@ -19,16 +19,16 @@ namespace Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives internal sealed class MisplacedUsingDirectivesDiagnosticAnalyzer : AbstractBuiltInCodeStyleDiagnosticAnalyzer { private static readonly LocalizableResourceString s_localizableTitle = new LocalizableResourceString( - nameof(CSharpFeaturesResources.Misplaced_using_directive), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)); + nameof(CSharpAnalyzersResources.Misplaced_using_directive), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)); private static readonly LocalizableResourceString s_localizableOutsideMessage = new LocalizableResourceString( - nameof(CSharpFeaturesResources.Using_directives_must_be_placed_outside_of_a_namespace_declaration), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)); + nameof(CSharpAnalyzersResources.Using_directives_must_be_placed_outside_of_a_namespace_declaration), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)); private static readonly DiagnosticDescriptor s_outsideDiagnosticDescriptor = CreateDescriptorWithId( IDEDiagnosticIds.MoveMisplacedUsingDirectivesDiagnosticId, s_localizableTitle, s_localizableOutsideMessage); private static readonly LocalizableResourceString s_localizableInsideMessage = new LocalizableResourceString( - nameof(CSharpFeaturesResources.Using_directives_must_be_placed_inside_of_a_namespace_declaration), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)); + nameof(CSharpAnalyzersResources.Using_directives_must_be_placed_inside_of_a_namespace_declaration), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)); private static readonly DiagnosticDescriptor s_insideDiagnosticDescriptor = CreateDescriptorWithId( IDEDiagnosticIds.MoveMisplacedUsingDirectivesDiagnosticId, s_localizableTitle, s_localizableInsideMessage); diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index 1951d713fc281..b1f2d77db7247 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -20,6 +20,7 @@ + diff --git a/src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs similarity index 96% rename from src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs index f2c3d7d3c69bb..7fce1c151cee2 100644 --- a/src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs @@ -20,11 +20,15 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.LanguageServices; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Simplification; using Roslyn.Utilities; -using static Microsoft.CodeAnalysis.CodeActions.CodeAction; + +#if CODE_STYLE +using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +#else +using Microsoft.CodeAnalysis.Options; +#endif namespace Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives { @@ -58,7 +62,12 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var compilationUnit = (CompilationUnitSyntax)syntaxRoot; + +#if CODE_STYLE + var options = document.Project.AnalyzerOptions.GetAnalyzerOptionSet(syntaxRoot.SyntaxTree, cancellationToken); +#else var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); +#endif // Read the preferred placement option and verify if it can be applied to this code file. // There are cases where we will not be able to fix the diagnostic and the user will need to resolve @@ -72,7 +81,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) foreach (var diagnostic in context.Diagnostics) { context.RegisterCodeFix( - new MoveMisplacedUsingsCodeAction(token => GetTransformedDocumentAsync(document, compilationUnit, options, placement, token)), + new MoveMisplacedUsingsCodeAction(token => GetTransformedDocumentAsync(document, compilationUnit, placement, token)), diagnostic); } } @@ -80,7 +89,6 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync( Document document, CompilationUnitSyntax compilationUnit, - OptionSet options, AddImportPlacement placement, CancellationToken cancellationToken) { @@ -93,7 +101,7 @@ private static async Task GetTransformedDocumentAsync( var (compilationUnitWithoutHeader, fileHeader) = RemoveFileHeader(compilationUnitWithExpandedUsings, syntaxFactsService); // A blanket warning that this codefix may change code so that it does not compile. - var warningAnnotation = WarningAnnotation.Create(CSharpFeaturesResources.Warning_colon_Moving_using_directives_may_change_code_meaning); + var warningAnnotation = WarningAnnotation.Create(CSharpAnalyzersResources.Warning_colon_Moving_using_directives_may_change_code_meaning); var newCompilationUnit = placement == AddImportPlacement.InsideNamespace ? MoveUsingsInsideNamespace(compilationUnitWithoutHeader, warningAnnotation) @@ -104,6 +112,7 @@ private static async Task GetTransformedDocumentAsync( var newDocument = document.WithSyntaxRoot(newCompilationUnitWithHeader); // Simplify usings now that they have been moved and are in the proper context. + var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); return await Simplifier.ReduceAsync(newDocument, Simplifier.Annotation, options, cancellationToken).ConfigureAwait(false); } @@ -389,10 +398,10 @@ private static CompilationUnitSyntax AddFileHeader(CompilationUnitSyntax compila return compilationUnit.ReplaceToken(firstToken, newFirstToken); } - private class MoveMisplacedUsingsCodeAction : DocumentChangeAction + private class MoveMisplacedUsingsCodeAction : CustomCodeActions.DocumentChangeAction { public MoveMisplacedUsingsCodeAction(Func> createChangedDocument) - : base(CSharpFeaturesResources.Move_misplaced_using_directives, createChangedDocument) + : base(CSharpAnalyzersResources.Move_misplaced_using_directives, createChangedDocument) { } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index 1852d9e2bcbda..95237454434b4 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -15,6 +15,7 @@ + diff --git a/src/EditorFeatures/CSharpTest/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProviderTests.cs b/src/Analyzers/CSharp/Tests/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProviderTests.cs similarity index 97% rename from src/EditorFeatures/CSharpTest/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProviderTests.cs rename to src/Analyzers/CSharp/Tests/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProviderTests.cs index 84cbed0935262..5332934faf771 100644 --- a/src/EditorFeatures/CSharpTest/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProviderTests.cs +++ b/src/Analyzers/CSharp/Tests/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProviderTests.cs @@ -17,11 +17,11 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.MisplacedUsingDirectives { - /// - /// Unit tests for the and . - /// public class MisplacedUsingDirectivesInCompilationUnitCodeFixProviderTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest { + internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace) + => (new MisplacedUsingDirectivesDiagnosticAnalyzer(), new MisplacedUsingDirectivesCodeFixProvider()); + internal static readonly CodeStyleOption2 OutsidePreferPreservationOption = new CodeStyleOption2(AddImportPlacement.OutsideNamespace, NotificationOption2.None); @@ -54,17 +54,14 @@ public class MisplacedUsingDirectivesInCompilationUnitCodeFixProviderTests : Abs protected const string DelegateDefinition = @"public delegate void TestDelegate();"; + private static TestParameters GetTestParameters(CodeStyleOption2 preferredPlacementOption) + => new TestParameters(options: OptionsSet((new OptionKey2(CSharpCodeStyleOptions.PreferredUsingDirectivePlacement), preferredPlacementOption))); + private protected Task TestDiagnosticMissingAsync(string initialMarkup, CodeStyleOption2 preferredPlacementOption) - { - var options = OptionsSet(CSharpCodeStyleOptions.PreferredUsingDirectivePlacement, preferredPlacementOption); - return TestDiagnosticMissingAsync(initialMarkup, new TestParameters(options: options)); - } + => TestDiagnosticMissingAsync(initialMarkup, GetTestParameters(preferredPlacementOption)); private protected Task TestMissingAsync(string initialMarkup, CodeStyleOption2 preferredPlacementOption) - { - var options = OptionsSet(CSharpCodeStyleOptions.PreferredUsingDirectivePlacement, preferredPlacementOption); - return TestMissingAsync(initialMarkup, new TestParameters(options: options)); - } + => TestMissingAsync(initialMarkup, GetTestParameters(preferredPlacementOption)); private protected Task TestInRegularAndScriptAsync(string initialMarkup, string expectedMarkup, CodeStyleOption2 preferredPlacementOption, bool placeSystemNamespaceFirst) { @@ -76,9 +73,6 @@ private protected Task TestInRegularAndScriptAsync(string initialMarkup, string return TestInRegularAndScriptAsync(initialMarkup, expectedMarkup, options: options); } - internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace) - => (new MisplacedUsingDirectivesDiagnosticAnalyzer(), new MisplacedUsingDirectivesCodeFixProvider()); - #region Test Preserve /// From 434dec115e024c65a387d3d0077a0fe32f6d56a5 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 16:20:38 -0700 Subject: [PATCH 32/50] xlf and resx file changes --- .../Analyzers/CSharpAnalyzersResources.resx | 20 +++++++++++++++ .../xlf/CSharpAnalyzersResources.cs.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.de.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.es.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.fr.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.it.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.ja.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.ko.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.pl.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.pt-BR.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.ru.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.tr.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.zh-Hans.xlf | 25 +++++++++++++++++++ .../xlf/CSharpAnalyzersResources.zh-Hant.xlf | 25 +++++++++++++++++++ .../Portable/CSharpFeaturesResources.resx | 20 --------------- .../xlf/CSharpFeaturesResources.cs.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.de.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.es.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.fr.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.it.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.ja.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.ko.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.pl.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.pt-BR.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.ru.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.tr.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.zh-Hans.xlf | 25 ------------------- .../xlf/CSharpFeaturesResources.zh-Hant.xlf | 25 ------------------- 28 files changed, 345 insertions(+), 345 deletions(-) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx index 5ad67910a9679..0d42500f5d073 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx @@ -144,6 +144,26 @@ Add braces to '{0}' statement. + + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + Use expression body for methods diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf index 4b65f74dd2178..3f860d78b8f74 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf index 51d164d9255f8..223571d0e7c8b 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf index a202dc4663708..06dc67f276272 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf index 692637a92c67e..02fade6cb34eb 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf index dfdae7c36ce3e..7af5ad83f0586 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf index ea04cb2b56279..54ec19772ade7 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf index 7f28b30ae6ddf..2f9c3624fff87 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf index 1720d528600c6..118f615f179a6 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf index 0d564ae0a951d..0c622c8ea26e5 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf index 6886af67f604f..a23c9c133e4c8 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf index f5176f627a1ff..3fdefdea70088 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf index a1b3849ce4b42..edf186d87a6d3 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf index 78ee10db86a08..4daf02fd8e927 100644 --- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf @@ -27,6 +27,16 @@ Indexing can be simplified + + Misplaced using directive + Misplaced using directive + {Locked="using"} "using" is a C# keyword and should not be localized. + + + Move misplaced using directives + Move misplaced using directives + {Locked="using"} "using" is a C# keyword and should not be localized. + Simplify 'default' expression Simplify 'default' expression @@ -147,11 +157,26 @@ Use 'switch' expression + + Using directives must be placed inside of a namespace declaration + Using directives must be placed inside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + + + Using directives must be placed outside of a namespace declaration + Using directives must be placed outside of a namespace declaration + {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. + Variable declaration can be deconstructed Variable declaration can be deconstructed + + Warning: Moving using directives may change code meaning. + Warning: Moving using directives may change code meaning. + {Locked="using"} "using" is a C# keyword and should not be localized. + {0} can be simplified {0} can be simplified diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx index 0e5eb9d0e71c5..9c3cc130c47b8 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx @@ -568,26 +568,6 @@ Make 'ref struct' {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Misplaced using directive - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - {Locked="using"} "using" is a C# keyword and should not be localized. - '{0}' is not null here. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf index beaffbcbc6187..328f300b0b95b 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf @@ -757,31 +757,6 @@ Zavést příkaz using {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Nesprávné umístění direktivy using - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Přesunout nesprávně umístěné direktivy using - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Direktivy using se musí umístit do deklarace namespace. - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Direktivy using se musí umístit mimo deklaraci namespace. - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Upozornění: Přesunutí direktiv using může změnit význam kódu. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement příkaz yield break diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf index 78f45798e53a3..b187327cb0e53 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf @@ -757,31 +757,6 @@ "using"-Anweisung einführen {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Die using-Anweisung wurde falsch platziert. - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Falsch platzierte using-Anweisungen verschieben - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Using-Anweisungen müssen in einer namespace-Deklaration platziert werden. - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Using-Anweisungen müssen außerhalb einer namespace-Deklaration platziert werden. - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Warnung: Durch das Verschieben von using-Anweisungen kann sich die Codebedeutung ändern. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement yield break-Anweisung diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf index 3857c97d76c3e..e8540b3566e4a 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf @@ -757,31 +757,6 @@ Introducir la instrucción "using" {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Directiva using mal colocada - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Mover directivas using mal colocadas - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Las directivas using deben colocarse dentro de una declaración de namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Las directivas using deben colocarse fuera de una declaración de namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Advertencia: El movimiento de directivas using puede cambiar el significado del código. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement instrucción yield break diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf index c4de91b2c7a0d..842606ee0211a 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf @@ -757,31 +757,6 @@ Introduire l’instruction 'using' {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Directive using mal placée - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Déplacer les directives using mal placées - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Les directives using doivent être placées dans une déclaration namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Les directives using doivent être placées en dehors d'une déclaration namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Avertissement : Le déplacement des directives using peut changer la signification du code. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement instruction yield break diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf index 56b6aaff21ff0..0dada6c312e67 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf @@ -757,31 +757,6 @@ Introduci l'istruzione 'using' {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Direttiva using in posizione errata - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Sposta le direttive using in posizione errata - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Le direttive using devono essere inserite all'interno di una dichiarazione di namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Le direttive using devono essere inserite all'esterno di una dichiarazione di namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Avviso: in seguito allo spostamento di direttive using, il significato del codice può cambiare. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement istruzione yield break diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf index 54bb84e97c418..3d1ace553d086 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf @@ -757,31 +757,6 @@ 'using' ステートメントを導入します {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - using ディレクティブが正しく配置されていません - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - 誤って配置された using ディレクティブを移動します - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - using ディレクティブを namespace 宣言の中に配置する必要があります - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - using ディレクティブを namespace 宣言の外に配置する必要があります - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - 警告: using ディレクティブを移動すると、コードの意味が変わる可能性があります。 - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement yield break ステートメント diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf index 6b1569d2e4329..6b3f84c7d5420 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf @@ -757,31 +757,6 @@ 'using' 문 지정 {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - 위치가 잘못된 using 지시문 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - 위치가 잘못된 using 지시문 이동 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Using 지시문은 namespace 선언 내부에 배치되어야 합니다. - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Using 지시문은 namespace 선언 외부에 배치되어야 합니다. - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - 경고: using 지시문을 이동하면 코드 의미가 변경될 수 있습니다. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement yield break 문 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf index dbfd2243ac0b2..83da8c18a2b4b 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf @@ -757,31 +757,6 @@ Wprowadź instrukcję „using” {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Nieprawidłowo umieszczona dyrektywa using - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Przenieś nieprawidłowo umieszczone dyrektywy using - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Dyrektywy using muszą znajdować się wewnątrz deklaracji namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Dyrektywy using muszą znajdować się poza deklaracją namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Uwaga: przeniesienie dyrektyw using może zmienić znaczenie kodu. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement instrukcja yield break diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf index 50c72109d98b6..14feef0610cca 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf @@ -757,31 +757,6 @@ Introduzir a instrução 'using' {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Diretiva using em local incorreto - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Mover diretivas using no local incorreto - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - As diretivas using precisam ser colocadas dentro de uma declaração de namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - As diretivas using precisam ser colocadas fora de uma declaração de namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Aviso: a movimentação das diretivas using pode alterar o significado do código. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement instrução yield break diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf index 564940e011634..df6b4397384f7 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf @@ -757,31 +757,6 @@ Добавить инструкцию 'using' {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Неправильно расположенная директива using - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Переместить неправильно расположенные директивы using - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Директивы using должны находиться внутри объявления namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Директивы using должны находиться вне объявления namespace - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Предупреждение! Перемещение директив using может изменить значение кода. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement оператор yield break diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf index 7276782aae4f0..bbe934f01f8d7 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf @@ -757,31 +757,6 @@ 'using' deyimi ekle {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - Yanlış yerleştirilmiş using yönergesi - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - Yanlış yerleştirilmiş using yönergelerini taşı - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - Using yönergelerinin bir namespace bildiriminin içine yerleştirilmesi gerekir - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - Using yönergelerinin bir namespace bildiriminin dışına yerleştirilmesi gerekir - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - Uyarı: using yönergelerini taşımak, kodun anlamını değiştirebilir. - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement yield break deyimi diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf index d1b95c117d967..19cdbf51e6f96 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf @@ -757,31 +757,6 @@ 介绍 'using' 语句 {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - 错放了 using 指令 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - 移动错放的 using 指令 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - using 指令必须放在 namespace 声明的内部 - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - using 指令必须放在 namespace 声明之外 - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - 警告: 移动 using 指令可能会更改代码含义。 - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement yield break 语句 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf index 50ef9c4afe756..48f28bbb5b87b 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf @@ -757,31 +757,6 @@ 引進 'using’ 陳述式 {Locked="using"} "using" is a C# keyword and should not be localized. - - Misplaced using directive - using 指示詞位置錯誤 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Move misplaced using directives - 移動位置錯誤的 using 指示詞 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Using directives must be placed inside of a namespace declaration - using 指示詞必須放在 namespace 宣告內 - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Using directives must be placed outside of a namespace declaration - using 指示詞必須放在 namespace 宣告外 - {Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized. - - - Warning: Moving using directives may change code meaning. - 警告: 移動 using 指示詞可能會變更程式碼意義。 - {Locked="using"} "using" is a C# keyword and should not be localized. - yield break statement yield break 陳述式 From dd1e496a66901b7934672faa0118cb8eb4bd9484 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 3 Apr 2020 17:00:11 -0700 Subject: [PATCH 33/50] Make additional rename information immutable --- .../Core/Portable/Rename/RenameLocations.cs | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Workspaces/Core/Portable/Rename/RenameLocations.cs b/src/Workspaces/Core/Portable/Rename/RenameLocations.cs index 03a97f26c5b99..7e1a6022516cf 100644 --- a/src/Workspaces/Core/Portable/Rename/RenameLocations.cs +++ b/src/Workspaces/Core/Portable/Rename/RenameLocations.cs @@ -47,12 +47,12 @@ public SearchResult( internal OptionSet Options { get; } // can be default + private readonly ImmutableArray _overloadsResult; private readonly ImmutableArray _stringsResult; private readonly ImmutableArray _commentsResult; // possibly null fields private readonly SearchResult _originalSymbolResult; - private readonly List _overloadsResult; internal RenameLocations( ImmutableHashSet locations, @@ -73,7 +73,7 @@ private RenameLocations( Solution solution, OptionSet options, SearchResult originalSymbolResult, - List overloadsResult, + ImmutableArray overloadsResult, ImmutableArray stringsResult, ImmutableArray commentsResult) { @@ -101,7 +101,9 @@ private RenameLocations( var renameMethodGroupReferences = options.GetOption(RenameOptions.RenameOverloads) || !GetOverloadedSymbols(symbolAndProjectId).Any(); - var overloadsToMerge = (options.GetOption(RenameOptions.RenameOverloads) ? overloadsResult : null) ?? SpecializedCollections.EmptyEnumerable(); + var overloadsToMerge = options.GetOption(RenameOptions.RenameOverloads) + ? overloadsResult.NullToEmpty() + : ImmutableArray.Empty; foreach (var result in overloadsToMerge.Concat(originalSymbolResult)) { mergedLocations.AddRange(renameMethodGroupReferences @@ -135,7 +137,7 @@ internal static async Task FindAsync( symbolAndProjectId = await ReferenceProcessing.FindDefinitionSymbolAsync(symbolAndProjectId, solution, cancellationToken).ConfigureAwait(false); var originalSymbolResult = await AddLocationsReferenceSymbolsAsync(symbolAndProjectId, solution, cancellationToken).ConfigureAwait(false); var intermediateResult = new RenameLocations( - symbolAndProjectId, solution, optionSet, originalSymbolResult, overloadsResult: null, stringsResult: default, commentsResult: default); + symbolAndProjectId, solution, optionSet, originalSymbolResult, overloadsResult: default, stringsResult: default, commentsResult: default); return await intermediateResult.FindWithUpdatedOptionsAsync(optionSet, cancellationToken).ConfigureAwait(false); } @@ -146,9 +148,11 @@ internal async Task FindWithUpdatedOptionsAsync(OptionSet optio Contract.ThrowIfNull(Options, "FindWithUpdatedOptionsAsync can only be called on a result of FindAsync"); using (Logger.LogBlock(FunctionId.Rename_AllRenameLocations, cancellationToken)) { - var overloadsResult = _overloadsResult ?? (optionSet.GetOption(RenameOptions.RenameOverloads) - ? await GetOverloadsAsync(_symbolAndProjectId, _solution, cancellationToken).ConfigureAwait(false) - : null); + var overloadsResult = !_overloadsResult.IsDefault + ? _overloadsResult + : optionSet.GetOption(RenameOptions.RenameOverloads) + ? await GetOverloadsAsync(_symbolAndProjectId, _solution, cancellationToken).ConfigureAwait(false) + : default; var stringsAndComments = await ReferenceProcessing.GetRenamableLocationsInStringsAndCommentsAsync( _symbolAndProjectId.Symbol, @@ -160,22 +164,20 @@ internal async Task FindWithUpdatedOptionsAsync(OptionSet optio return new RenameLocations( _symbolAndProjectId, _solution, optionSet, _originalSymbolResult, - _overloadsResult ?? overloadsResult, + _overloadsResult.IsDefault ? overloadsResult : _overloadsResult, _stringsResult.IsDefault ? stringsAndComments.Item1 : _stringsResult, _commentsResult.IsDefault ? stringsAndComments.Item2 : _commentsResult); } } - private static async Task> GetOverloadsAsync( + private static async Task> GetOverloadsAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, CancellationToken cancellationToken) { - var overloadsResult = new List(); + using var _ = ArrayBuilder.GetInstance(out var overloadsResult); foreach (var overloadedSymbol in GetOverloadedSymbols(symbolAndProjectId)) - { overloadsResult.Add(await AddLocationsReferenceSymbolsAsync(overloadedSymbol, solution, cancellationToken).ConfigureAwait(false)); - } - return overloadsResult; + return overloadsResult.ToImmutable(); } internal static IEnumerable GetOverloadedSymbols( From 6db969b48ad1ea71c76f981993a0eb156a405099 Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Fri, 3 Apr 2020 17:08:44 -0700 Subject: [PATCH 34/50] Fix crash for Equals analysis of types with bad base clauses (#42968) --- .../Portable/FlowAnalysis/NullableWalker.cs | 16 +++--- .../Semantics/NullableReferenceTypesTests.cs | 52 +++++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs b/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs index 4f98e8f7b28ce..2ef8a8f7ad491 100644 --- a/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs +++ b/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs @@ -3958,12 +3958,14 @@ private void ReinferMethodAndVisitArguments(BoundCall node, TypeWithState receiv SetUpdatedSymbol(node, node.Method, method); } +#nullable enable private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node, TypeWithState receiverType, ImmutableArray results) { // easy out var parameterCount = method.ParameterCount; var arguments = node.Arguments; - if ((parameterCount != 1 && parameterCount != 2) + if (node.HasErrors + || (parameterCount != 1 && parameterCount != 2) || parameterCount != arguments.Length || method.MethodKind != MethodKind.Ordinary || method.ReturnType.SpecialType != SpecialType.System_Boolean @@ -3986,11 +3988,12 @@ private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node, TypeWith var isObjectEqualsMethodOrOverride = method.GetLeastOverriddenMethod(accessingTypeOpt: null) .Equals(compilation.GetSpecialTypeMember(SpecialMember.System_Object__Equals)); - if (isObjectEqualsMethodOrOverride || - isWellKnownEqualityMethodOrImplementation(compilation, method, receiverType.Type, WellKnownMember.System_IEquatable_T__Equals)) + if (node.ReceiverOpt is BoundExpression receiver && + (isObjectEqualsMethodOrOverride || + isWellKnownEqualityMethodOrImplementation(compilation, method, receiverType.Type, WellKnownMember.System_IEquatable_T__Equals))) { Debug.Assert(arguments.Length == 1); - learnFromEqualsMethodArguments(node.ReceiverOpt, receiverType, arguments[0], results[0].RValueType); + learnFromEqualsMethodArguments(receiver, receiverType, arguments[0], results[0].RValueType); return; } @@ -4007,9 +4010,9 @@ static bool anyOverriddenMethodHasExplicitImplementation(MethodSymbol method) return false; } - static bool isWellKnownEqualityMethodOrImplementation(CSharpCompilation compilation, MethodSymbol method, TypeSymbol receiverType, WellKnownMember wellKnownMember) + static bool isWellKnownEqualityMethodOrImplementation(CSharpCompilation compilation, MethodSymbol method, TypeSymbol? receiverType, WellKnownMember wellKnownMember) { - var wellKnownMethod = (MethodSymbol)compilation.GetWellKnownTypeMember(wellKnownMember); + var wellKnownMethod = (MethodSymbol?)compilation.GetWellKnownTypeMember(wellKnownMember); if (wellKnownMethod is null || receiverType is null) { return false; @@ -4120,6 +4123,7 @@ void learnFromEqualsMethodArguments(BoundExpression left, TypeWithState leftType } } } +#nullable restore private bool IsCompareExchangeMethod(MethodSymbol method) { diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index 541228cf7d30e..f5ff53e45930f 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs @@ -123946,6 +123946,58 @@ static void M1(C c, string? s) Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "s").WithLocation(18, 15)); } + [Fact, WorkItem(42960, "https://github.com/dotnet/roslyn/issues/42960")] + public void EqualsMethod_IncompleteBaseClause() + { + var source = @" +class C : +{ + void M(C? other) + { + if (Equals(other)) { other.ToString(); } + if (this.Equals(other)) { other.ToString(); } + } +} +"; + var comp = CreateNullableCompilation(source); + comp.VerifyDiagnostics( + // (2,10): error CS1031: Type expected + // class C : + Diagnostic(ErrorCode.ERR_TypeExpected, "").WithLocation(2, 10), + // (6,13): error CS0120: An object reference is required for the non-static field, method, or property 'object.Equals(object)' + // if (Equals(other)) { other.ToString(); } + Diagnostic(ErrorCode.ERR_ObjectRequired, "Equals").WithArguments("object.Equals(object)").WithLocation(6, 13), + // (6,30): warning CS8602: Dereference of a possibly null reference. + // if (Equals(other)) { other.ToString(); } + Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "other").WithLocation(6, 30)); + } + + [Fact, WorkItem(42960, "https://github.com/dotnet/roslyn/issues/42960")] + public void EqualsMethod_ErrorBaseClause() + { + var source = @" +class C : ERROR +{ + void M(C? other) + { + if (Equals(other)) { other.ToString(); } + if (this.Equals(other)) { other.ToString(); } + } +} +"; + var comp = CreateNullableCompilation(source); + comp.VerifyDiagnostics( + // (2,11): error CS0246: The type or namespace name 'ERROR' could not be found (are you missing a using directive or an assembly reference?) + // class C : ERROR + Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "ERROR").WithArguments("ERROR").WithLocation(2, 11), + // (6,13): error CS0120: An object reference is required for the non-static field, method, or property 'object.Equals(object)' + // if (Equals(other)) { other.ToString(); } + Diagnostic(ErrorCode.ERR_ObjectRequired, "Equals").WithArguments("object.Equals(object)").WithLocation(6, 13), + // (6,30): warning CS8602: Dereference of a possibly null reference. + // if (Equals(other)) { other.ToString(); } + Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "other").WithLocation(6, 30)); + } + [Fact] [WorkItem(36131, "https://github.com/dotnet/roslyn/issues/36131")] public void ShouldRunNullableWalker_GlobalDirective() From f2c14f64f19f5e66f8a63abfce1cdc7e8955fe02 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 17:36:41 -0700 Subject: [PATCH 35/50] Move extensions down to shared layer --- .../CodeGeneration/CSharpSyntaxGenerator.cs | 6 ---- .../Core/Portable/Editing/SyntaxGenerator.cs | 2 +- ...xGeneratorExtensions_CreateEqualsMethod.cs | 29 ++----------------- .../CSharpSyntaxGeneratorInternal.cs | 6 ++++ .../Extensions/SyntaxGeneratorExtensions.cs | 25 ++++++++++++++++ ...ratorExtensions_CreateGetHashCodeMethod.cs | 12 ++++---- .../SyntaxGeneratorInternal.cs | 8 +++++ .../Core/WorkspaceExtensions.projitems | 1 + .../VisualBasicSyntaxGeneratorInternal.vb | 6 ++++ .../VisualBasicSyntaxGenerator.vb | 6 ---- 10 files changed, 56 insertions(+), 45 deletions(-) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Extensions/SyntaxGeneratorExtensions_CreateGetHashCodeMethod.cs (94%) diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs index e6f7fce0795a0..dc40e854c7fad 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs @@ -2945,12 +2945,6 @@ public override SyntaxNode ThrowExpression(SyntaxNode expression) internal override bool SupportsThrowExpression() => true; - /// - /// C# always requires a type to be present with a local declaration. (Even if that type is - /// var). - /// - internal override bool RequiresLocalDeclarationType() => true; - public override SyntaxNode IfStatement(SyntaxNode condition, IEnumerable trueStatements, IEnumerable falseStatements = null) { if (falseStatements == null) diff --git a/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs b/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs index d0ae9bd1d4151..972dcb74db40b 100644 --- a/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs +++ b/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs @@ -1378,7 +1378,7 @@ internal SyntaxNode YieldReturnStatement(SyntaxNode expression) /// . /// if the language allows the type node to be entirely elided. /// - internal abstract bool RequiresLocalDeclarationType(); + internal bool RequiresLocalDeclarationType() => SyntaxGeneratorInternal.RequiresLocalDeclarationType(); /// /// Creates a statement that declares a single local variable. diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxGeneratorExtensions_CreateEqualsMethod.cs b/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxGeneratorExtensions_CreateEqualsMethod.cs index f20944ad177ba..be76eb3b7cc6c 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxGeneratorExtensions_CreateEqualsMethod.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxGeneratorExtensions_CreateEqualsMethod.cs @@ -16,11 +16,6 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions { internal static partial class SyntaxGeneratorExtensions { - private const string EqualsName = "Equals"; - private const string DefaultName = "Default"; - private const string ObjName = "obj"; - public const string OtherName = "other"; - public static IMethodSymbol CreateEqualsMethod( this SyntaxGenerator factory, Compilation compilation, @@ -147,7 +142,7 @@ private static ImmutableArray CreateEqualsMethodStatements( // // var myType = (MyType)obj; - var localDeclaration = factory.SimpleLocalDeclarationStatement( + var localDeclaration = factory.SimpleLocalDeclarationStatement(factory.SyntaxGeneratorInternal, containingType, localName, factory.CastExpression(containingType, objNameExpression)); statements.Add(ifStatement); @@ -159,7 +154,7 @@ private static ImmutableArray CreateEqualsMethodStatements( // // var myType = obj as MyType; - var localDeclaration = factory.SimpleLocalDeclarationStatement( + var localDeclaration = factory.SimpleLocalDeclarationStatement(factory.SyntaxGeneratorInternal, containingType, localName, factory.TryCastExpression(objNameExpression, containingType)); statements.Add(localDeclaration); @@ -367,26 +362,6 @@ private static bool ShouldUseEqualityOperator(ITypeSymbol typeSymbol) return false; } - public static SyntaxNode GetDefaultEqualityComparer( - this SyntaxGenerator factory, - Compilation compilation, - ITypeSymbol type) - { - var equalityComparerType = compilation.EqualityComparerOfTType(); - var constructedType = equalityComparerType.Construct(type); - return factory.MemberAccessExpression( - factory.TypeExpression(constructedType), - factory.IdentifierName(DefaultName)); - } - - private static ITypeSymbol GetType(Compilation compilation, ISymbol symbol) - => symbol switch - { - IFieldSymbol field => field.Type, - IPropertySymbol property => property.Type, - _ => compilation.GetSpecialType(SpecialType.System_Object), - }; - private static bool HasExistingBaseEqualsMethod(INamedTypeSymbol containingType) { // Check if any of our base types override Equals. If so, first check with them. diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs index c78bf4f09d74d..3a4feead7a2d9 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs @@ -73,5 +73,11 @@ internal static ExpressionSyntax Parenthesize(SyntaxNode expression, bool includ internal override SyntaxNode YieldReturnStatement(SyntaxNode expressionOpt = null) => SyntaxFactory.YieldStatement(SyntaxKind.YieldReturnStatement, (ExpressionSyntax)expressionOpt); + + /// + /// C# always requires a type to be present with a local declaration. (Even if that type is + /// var). + /// + internal override bool RequiresLocalDeclarationType() => true; } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxGeneratorExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxGeneratorExtensions.cs index 8769659106f91..70a007bf35148 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxGeneratorExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxGeneratorExtensions.cs @@ -10,6 +10,11 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions { internal static partial class SyntaxGeneratorExtensions { + private const string EqualsName = "Equals"; + private const string DefaultName = "Default"; + private const string ObjName = "obj"; + public const string OtherName = "other"; + public static SyntaxNode CreateThrowNotImplementedStatement( this SyntaxGenerator codeDefinitionFactory, Compilation compilation) { @@ -46,5 +51,25 @@ private static SyntaxNode CreateArgument( { return factory.Argument(parameter.RefKind, factory.IdentifierName(parameter.Name)); } + + public static SyntaxNode GetDefaultEqualityComparer( + this SyntaxGenerator factory, + Compilation compilation, + ITypeSymbol type) + { + var equalityComparerType = compilation.EqualityComparerOfTType(); + var constructedType = equalityComparerType.Construct(type); + return factory.MemberAccessExpression( + factory.TypeExpression(constructedType), + factory.IdentifierName(DefaultName)); + } + + private static ITypeSymbol GetType(Compilation compilation, ISymbol symbol) + => symbol switch + { + IFieldSymbol field => field.Type, + IPropertySymbol property => property.Type, + _ => compilation.GetSpecialType(SpecialType.System_Object), + }; } } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxGeneratorExtensions_CreateGetHashCodeMethod.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxGeneratorExtensions_CreateGetHashCodeMethod.cs similarity index 94% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxGeneratorExtensions_CreateGetHashCodeMethod.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxGeneratorExtensions_CreateGetHashCodeMethod.cs index 426dee9b4f16a..523ac5fda6637 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxGeneratorExtensions_CreateGetHashCodeMethod.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxGeneratorExtensions_CreateGetHashCodeMethod.cs @@ -40,7 +40,8 @@ public static ImmutableArray GetGetHashCodeComponents( } public static ImmutableArray CreateGetHashCodeStatementsUsingSystemHashCode( - this SyntaxGenerator factory, INamedTypeSymbol hashCodeType, ImmutableArray memberReferences) + this SyntaxGenerator factory, SyntaxGeneratorInternal generatorInternal, + INamedTypeSymbol hashCodeType, ImmutableArray memberReferences) { if (memberReferences.Length <= 8) { @@ -53,7 +54,7 @@ public static ImmutableArray CreateGetHashCodeStatementsUsingSystemH const string hashName = "hash"; var statements = ArrayBuilder.GetInstance(); - statements.Add(factory.SimpleLocalDeclarationStatement( + statements.Add(factory.SimpleLocalDeclarationStatement(generatorInternal, hashCodeType, hashName, factory.ObjectCreationExpression(hashCodeType))); var localReference = factory.IdentifierName(hashName); @@ -78,6 +79,7 @@ public static ImmutableArray CreateGetHashCodeStatementsUsingSystemH /// public static ImmutableArray CreateGetHashCodeMethodStatements( this SyntaxGenerator factory, + SyntaxGeneratorInternal generatorInternal, Compilation compilation, INamedTypeSymbol containingType, ImmutableArray members, @@ -132,7 +134,7 @@ public static ImmutableArray CreateGetHashCodeMethodStatements( const string HashCodeName = "hashCode"; statements.Add(!useInt64 - ? factory.SimpleLocalDeclarationStatement(compilation.GetSpecialType(SpecialType.System_Int32), HashCodeName, CreateLiteralExpression(factory, initHash)) + ? factory.SimpleLocalDeclarationStatement(generatorInternal, compilation.GetSpecialType(SpecialType.System_Int32), HashCodeName, CreateLiteralExpression(factory, initHash)) : factory.LocalDeclarationStatement(compilation.GetSpecialType(SpecialType.System_Int64), HashCodeName, CreateLiteralExpression(factory, initHash))); var hashCodeNameExpression = factory.IdentifierName(HashCodeName); @@ -175,10 +177,10 @@ public static ImmutableArray CreateGetHashCodeMethodStatements( /// type and let the simplifier decide if it should be var or not. /// private static SyntaxNode SimpleLocalDeclarationStatement( - this SyntaxGenerator generator, INamedTypeSymbol namedTypeSymbol, + this SyntaxGenerator generator, SyntaxGeneratorInternal generatorInternal, INamedTypeSymbol namedTypeSymbol, string name, SyntaxNode initializer) { - return generator.RequiresLocalDeclarationType() + return generatorInternal.RequiresLocalDeclarationType() ? generator.LocalDeclarationStatement(namedTypeSymbol, name, initializer) : generator.LocalDeclarationStatement(name, initializer); } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs index 68cca9f55cc65..f540649219af1 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs @@ -52,5 +52,13 @@ internal SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initi /// /// An expression that can be yielded. internal abstract SyntaxNode YieldReturnStatement(SyntaxNode expression); + + /// + /// if the language requires a + /// (including ) to be stated when making a + /// . + /// if the language allows the type node to be entirely elided. + /// + internal abstract bool RequiresLocalDeclarationType(); } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems index 05e5161a97e83..e9e13ff7a7fae 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems @@ -12,6 +12,7 @@ + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb index d9c2159f1a501..1c74dbefa75d1 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb @@ -80,5 +80,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration Friend Overrides Function YieldReturnStatement(expression As SyntaxNode) As SyntaxNode Return SyntaxFactory.YieldStatement(DirectCast(expression, ExpressionSyntax)) End Function + + Friend Overrides Function RequiresLocalDeclarationType() As Boolean + ' VB supports `dim x = ...` as well as `dim x as Y = ...`. The local declaration type + ' is not required. + Return False + End Function End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb b/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb index c90bf2dfa96fe..892ba346cbd0c 100644 --- a/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb +++ b/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb @@ -3721,12 +3721,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration Return False End Function - Friend Overrides Function RequiresLocalDeclarationType() As Boolean - ' VB supports `dim x = ...` as well as `dim x as Y = ...`. The local declaration type - ' is not required. - Return False - End Function - Friend Overrides Function IsPatternExpression(expression As SyntaxNode, pattern As SyntaxNode) As SyntaxNode Throw New NotImplementedException() End Function From e2fda86a41d54a9f50a58e753780e87cca5e1a5b Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 17:37:26 -0700 Subject: [PATCH 36/50] Port UseSystemHashCode analyzer/fixer/tests to shared layer --- .../CSharp/Tests/CSharpAnalyzers.UnitTests.projitems | 2 ++ .../Tests}/UseSystemHashCode/UseSystemHashCodeTests.cs | 2 +- .../CSharp/Tests}/UseVarTestExtensions.cs | 5 +++++ src/Analyzers/Core/Analyzers/Analyzers.projitems | 3 +++ .../UseSystemHashCode/Analyzer.OperationDeconstructor.cs | 0 .../Core/Analyzers}/UseSystemHashCode/Analyzer.cs | 2 +- .../UseSystemHashCodeDiagnosticAnalyzer.cs | 4 ++-- src/Analyzers/Core/CodeFixes/CodeFixes.projitems | 1 + .../UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs | 7 ++++--- .../Tests}/UseSystemHashCode/UseSystemHashCodeTests.vb | 0 .../Tests/VisualBasicAnalyzers.UnitTests.projitems | 1 + .../AbstractGenerateEqualsAndGetHashCodeService.cs | 7 ++++--- 12 files changed, 24 insertions(+), 10 deletions(-) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/UseSystemHashCode/UseSystemHashCodeTests.cs (99%) rename src/{EditorFeatures/CSharpTest/CodeActions => Analyzers/CSharp/Tests}/UseVarTestExtensions.cs (97%) rename src/{Features/Core/Portable => Analyzers/Core/Analyzers}/UseSystemHashCode/Analyzer.OperationDeconstructor.cs (100%) rename src/{Features/Core/Portable => Analyzers/Core/Analyzers}/UseSystemHashCode/Analyzer.cs (99%) rename src/{Features/Core/Portable => Analyzers/Core/Analyzers}/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs (88%) rename src/{Features/Core/Portable => Analyzers/Core/CodeFixes}/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs (91%) rename src/{EditorFeatures/VisualBasicTest => Analyzers/VisualBasic/Tests}/UseSystemHashCode/UseSystemHashCodeTests.vb (100%) diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index 1852d9e2bcbda..12f53e5d4fd89 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -70,8 +70,10 @@ + + diff --git a/src/EditorFeatures/CSharpTest/UseSystemHashCode/UseSystemHashCodeTests.cs b/src/Analyzers/CSharp/Tests/UseSystemHashCode/UseSystemHashCodeTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/UseSystemHashCode/UseSystemHashCodeTests.cs rename to src/Analyzers/CSharp/Tests/UseSystemHashCode/UseSystemHashCodeTests.cs index 82d875f37bacc..e02cdbfdf1e76 100644 --- a/src/EditorFeatures/CSharpTest/UseSystemHashCode/UseSystemHashCodeTests.cs +++ b/src/Analyzers/CSharp/Tests/UseSystemHashCode/UseSystemHashCodeTests.cs @@ -1209,7 +1209,7 @@ public override int GetHashCode() hash.Add(i); return hash.ToHashCode(); } -}", options: this.PreferImplicitTypeWithInfo()); +}", options: UseVarTestExtensions.PreferImplicitTypeWithInfo(this)); } [WorkItem(39916, "https://github.com/dotnet/roslyn/issues/39916")] diff --git a/src/EditorFeatures/CSharpTest/CodeActions/UseVarTestExtensions.cs b/src/Analyzers/CSharp/Tests/UseVarTestExtensions.cs similarity index 97% rename from src/EditorFeatures/CSharpTest/CodeActions/UseVarTestExtensions.cs rename to src/Analyzers/CSharp/Tests/UseVarTestExtensions.cs index e9bc24c53f409..70c924ca2c82d 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/UseVarTestExtensions.cs +++ b/src/Analyzers/CSharp/Tests/UseVarTestExtensions.cs @@ -5,7 +5,12 @@ using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; + +#if CODE_STYLE +using AbstractCodeActionOrUserDiagnosticTest = Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest; +#else using static Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions.AbstractCodeActionOrUserDiagnosticTest; +#endif namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeActions { diff --git a/src/Analyzers/Core/Analyzers/Analyzers.projitems b/src/Analyzers/Core/Analyzers/Analyzers.projitems index a2de9de87a2f8..c198a0748106c 100644 --- a/src/Analyzers/Core/Analyzers/Analyzers.projitems +++ b/src/Analyzers/Core/Analyzers/Analyzers.projitems @@ -67,6 +67,9 @@ + + + diff --git a/src/Features/Core/Portable/UseSystemHashCode/Analyzer.OperationDeconstructor.cs b/src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.OperationDeconstructor.cs similarity index 100% rename from src/Features/Core/Portable/UseSystemHashCode/Analyzer.OperationDeconstructor.cs rename to src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.OperationDeconstructor.cs diff --git a/src/Features/Core/Portable/UseSystemHashCode/Analyzer.cs b/src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.cs similarity index 99% rename from src/Features/Core/Portable/UseSystemHashCode/Analyzer.cs rename to src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.cs index a21d4ebee1c7f..664007f961077 100644 --- a/src/Features/Core/Portable/UseSystemHashCode/Analyzer.cs +++ b/src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.UseSystemHashCode { /// - /// Helper code to support both and + /// Helper code to support both "UseSystemHashCodeCodeFixProvider" and /// . /// internal partial struct Analyzer diff --git a/src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs similarity index 88% rename from src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs rename to src/Analyzers/Core/Analyzers/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs index bb6ebb5cfd037..954d4be6f5428 100644 --- a/src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs @@ -16,8 +16,8 @@ internal class UseSystemHashCodeDiagnosticAnalyzer : AbstractBuiltInCodeStyleDia public UseSystemHashCodeDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseSystemHashCode, CodeStyleOptions2.PreferSystemHashCode, - new LocalizableResourceString(nameof(FeaturesResources.Use_System_HashCode), FeaturesResources.ResourceManager, typeof(FeaturesResources)), - new LocalizableResourceString(nameof(FeaturesResources.GetHashCode_implementation_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) + new LocalizableResourceString(nameof(AnalyzersResources.Use_System_HashCode), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)), + new LocalizableResourceString(nameof(AnalyzersResources.GetHashCode_implementation_can_be_simplified), AnalyzersResources.ResourceManager, typeof(AnalyzersResources))) { } diff --git a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems index 47c65d846b99f..63e45e161c1ab 100644 --- a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems +++ b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems @@ -41,6 +41,7 @@ + diff --git a/src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs similarity index 91% rename from src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs rename to src/Analyzers/Core/CodeFixes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs index 301bef06b6382..8a80679b5b5b8 100644 --- a/src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs +++ b/src/Analyzers/Core/CodeFixes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs @@ -51,6 +51,7 @@ protected override async Task FixAllAsync( SyntaxEditor editor, CancellationToken cancellationToken) { var generator = SyntaxGenerator.GetGenerator(document); + var generatorInternal = document.GetRequiredLanguageService(); var declarationService = document.GetLanguageService(); if (declarationService == null) { @@ -88,16 +89,16 @@ protected override async Task FixAllAsync( var updatedDecl = generator.WithStatements( methodBlock, generator.CreateGetHashCodeStatementsUsingSystemHashCode( - analyzer.SystemHashCodeType, components)); + generatorInternal, analyzer.SystemHashCodeType, components)); editor.ReplaceNode(methodBlock, updatedDecl); } } } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(FeaturesResources.Use_System_HashCode, createChangedDocument, FeaturesResources.Use_System_HashCode) + : base(AnalyzersResources.Use_System_HashCode, createChangedDocument, AnalyzersResources.Use_System_HashCode) { } } diff --git a/src/EditorFeatures/VisualBasicTest/UseSystemHashCode/UseSystemHashCodeTests.vb b/src/Analyzers/VisualBasic/Tests/UseSystemHashCode/UseSystemHashCodeTests.vb similarity index 100% rename from src/EditorFeatures/VisualBasicTest/UseSystemHashCode/UseSystemHashCodeTests.vb rename to src/Analyzers/VisualBasic/Tests/UseSystemHashCode/UseSystemHashCodeTests.vb diff --git a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems index f09dff0afc5a1..0cc6c8c979947 100644 --- a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems +++ b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems @@ -40,6 +40,7 @@ + diff --git a/src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/AbstractGenerateEqualsAndGetHashCodeService.cs b/src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/AbstractGenerateEqualsAndGetHashCodeService.cs index d142f2a8fccb6..818073e60a9a7 100644 --- a/src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/AbstractGenerateEqualsAndGetHashCodeService.cs +++ b/src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/AbstractGenerateEqualsAndGetHashCodeService.cs @@ -155,12 +155,13 @@ private ImmutableArray CreateGetHashCodeStatements( if (components.Length > 0 && hashCodeType != null) { - return factory.CreateGetHashCodeStatementsUsingSystemHashCode(hashCodeType, components); + return factory.CreateGetHashCodeStatementsUsingSystemHashCode( + factory.SyntaxGeneratorInternal, hashCodeType, components); } // Otherwise, try to just spit out a reasonable hash code for these members. var statements = factory.CreateGetHashCodeMethodStatements( - compilation, namedType, members, useInt64: false); + factory.SyntaxGeneratorInternal, compilation, namedType, members, useInt64: false); // Unfortunately, our 'reasonable' hash code may overflow in checked contexts. // C# can handle this by adding 'checked{}' around the code, VB has to jump @@ -194,7 +195,7 @@ private ImmutableArray CreateGetHashCodeStatements( // // This does mean all hashcodes will be positive. But it will avoid the overflow problem. return factory.CreateGetHashCodeMethodStatements( - compilation, namedType, members, useInt64: true); + factory.SyntaxGeneratorInternal, compilation, namedType, members, useInt64: true); } } } From 2583d7088a89a92cea3687abb3c44c6f2e0bbf20 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 17:37:32 -0700 Subject: [PATCH 37/50] xlf and resx file changes --- src/Analyzers/Core/Analyzers/AnalyzersResources.resx | 6 ++++++ .../Core/Analyzers/xlf/AnalyzersResources.cs.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.de.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.es.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.fr.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.it.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.ja.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.ko.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.pl.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.ru.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.tr.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf | 10 ++++++++++ .../Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf | 10 ++++++++++ src/Features/Core/Portable/FeaturesResources.resx | 6 ------ .../Core/Portable/xlf/FeaturesResources.cs.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.de.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.es.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.fr.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.it.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ja.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ko.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.pl.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.ru.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.tr.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 10 ---------- .../Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 10 ---------- 28 files changed, 136 insertions(+), 136 deletions(-) diff --git a/src/Analyzers/Core/Analyzers/AnalyzersResources.resx b/src/Analyzers/Core/Analyzers/AnalyzersResources.resx index 4ca9ae9cdfd9e..92bc8c7b5634a 100644 --- a/src/Analyzers/Core/Analyzers/AnalyzersResources.resx +++ b/src/Analyzers/Core/Analyzers/AnalyzersResources.resx @@ -265,6 +265,12 @@ Use explicitly provided tuple name + + Use 'System.HashCode' + + + 'GetHashCode' implementation can be simplified + Use compound assignment diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf index 68f4fa72559ea..0602b871aaa9e 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf index 6bb7a42d40240..5c66de0c38e22 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf index 1d8f4e009e91c..2dbdf2efcbe1a 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf index 719f1e5f8c9b7..52d47926cf7d4 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf index 788baacc4c040..a60565429d12a 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf index 20f2a48b81591..712ff4dec8529 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf index 9569dd1670275..bd87341de835d 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf index 27aad4fb8611b..4cfd07329b3d3 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf index b665146a17510..187469f24da65 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf index edc5379aa1302..cc63674d3c364 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf index 39ddb535f2f91..e066a1c832420 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf index 6502fc519d7a3..8da7c01b2acf5 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf index 2615ae7515feb..64ef51a016dbd 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf @@ -77,6 +77,11 @@ Format string contains invalid placeholder + + 'GetHashCode' implementation can be simplified + 'GetHashCode' implementation can be simplified + + Invalid format string Invalid format string @@ -247,6 +252,11 @@ Unnecessary assignment of a value to '{0}' + + Use 'System.HashCode' + Use 'System.HashCode' + + Use coalesce expression Use coalesce expression diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 3db1932656494..6614b6ee1dd5f 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -1473,12 +1473,6 @@ This version used in: {2} Add null checks for all parameters - - Use 'System.HashCode' - - - 'GetHashCode' implementation can be simplified - Implement '{0}' implicitly diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index 78d15c24a600e..d6984acf66930 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -272,11 +272,6 @@ Generovat parametr {0} (a přepsání/implementace) - - 'GetHashCode' implementation can be simplified - Implementace GetHashCode se dá zjednodušit. - - Implement '{0}' explicitly Implementovat rozhraní {0} explicitně @@ -597,11 +592,6 @@ Použijte doporučený vzor Dispose, abyste měli jistotu, že objekty, které lze vyřadit v místním oboru, se vyřadí na všech cestách. Pokud je to možné, zabalte vytváření do příkazu nebo deklarace using. Jinak použijte vzor try-finally s vyhrazenou místní proměnnou deklarovanou před oblastí try a nepodmíněným voláním Dispose pro hodnotu, která není null, v oblasti finally, třeba x?.Dispose(). Pokud se objekt explicitně vyřadí v oblasti try nebo se vlastnictví Dispose převede na jiný objekt nebo metodu, přiřaďte ihned po takové operaci místní proměnné hodnotu null, aby ve finally nedošlo k dvojímu Dispose. - - Use 'System.HashCode' - Použijte System.HashCode. - - Use block body for lambda expressions Pro lambda výrazy používat text bloku diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 722a74dd31ecf..0971c765e99b2 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -272,11 +272,6 @@ Parameter "{0}" (und Außerkraftsetzungen/Implementierungen) generieren - - 'GetHashCode' implementation can be simplified - Die Implementierung von "GetHashCode" kann vereinfacht werden. - - Implement '{0}' explicitly "{0}" explizit implementieren @@ -597,11 +592,6 @@ Verwenden Sie das empfohlene Dispose-Muster, um sicherzustellen, dass löschbare Objekte für den lokalen Bereich in allen Pfaden gelöscht werden. Schließen Sie die Erstellung nach Möglichkeit in einer using-Anweisung oder einer using-Deklaration ein. Verwenden Sie andernfalls ein try-finally-Muster mit einer vor dem try-Bereich deklarierten dedizierten lokalen Variablen und einem Dispose-Aufruf ohne Bedingung für den Nicht-NULL-Wert im finally-Bereich, beispielsweise "x?.Dispose()". Wenn das Objekt explizit innerhalb des try-Bereichs gelöscht oder der Dispose-Besitz auf ein anderes Objekt oder eine andere Methode übertragen wird, weisen Sie der lokalen Variablen gleich nach einem solchen Vorgang NULL zu, um einen doppelten Löschvorgang in "finally" zu vermeiden. - - Use 'System.HashCode' - "System.Hashcode" verwenden - - Use block body for lambda expressions Blocktextkörper für Lambdaausdrücke verwenden diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index cdaddee9c38ee..c602c4905d3dc 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -272,11 +272,6 @@ Generar el parámetro "{0}" (y reemplazos/implementaciones) - - 'GetHashCode' implementation can be simplified - La implementación de "GetHashCode" se puede simplificar. - - Implement '{0}' explicitly Implementar "{0}" de forma explícita @@ -597,11 +592,6 @@ Use el patrón de Dispose recomendado para asegurarse de que los objetos descartables de ámbito local se desechan en todas las rutas de acceso. Si es posible, incluya la creación en una instrucción "using" o una declaración "using". En caso contrario, use un patrón try-finally, con la declaración de una variable local dedicada antes de la región "try" y una invocación de Dispose incondicional en un valor no nulo en la región "finally", por ejemplo, "x?.Dispose()". Si el objeto se desecha de forma explícita en la región "try" o la pertenencia de Dispose se transfiere a otro objeto o método, asigne "null" a la variable local justo después de tal operación para evitar un doble Dispose en "finally". - - Use 'System.HashCode' - Usar "System.HashCode" - - Use block body for lambda expressions Usar cuerpo del bloque para las expresiones lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 10611d00b3098..ca44ac7661508 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -272,11 +272,6 @@ Générer le paramètre '{0}' (et les substitutions/implémentations) - - 'GetHashCode' implementation can be simplified - L'implémentation de 'GetHashCode' peut être simplifiée - - Implement '{0}' explicitly Implémenter '{0}' explicitement @@ -597,11 +592,6 @@ Utilisez le modèle Dispose recommandé pour vérifier que les objets supprimables de l'étendue locale sont bien supprimés sur tous les chemins. Si possible, enveloppez la création dans une instruction 'using' ou une déclaration 'using'. Sinon, utilisez un modèle try-finally avec une variable locale dédiée déclarée avant la région try et un appel inconditionnel de Dispose sur une valeur non null dans la région 'finally', par exemple 'x?.Dispose()'. Si l'objet est explicitement supprimé dans la région try ou si la propriété de suppression est transférée vers un autre objet ou une autre méthode, affectez la valeur 'null' à la variable locale juste après cette opération pour éviter une double suppression dans 'finally' - - Use 'System.HashCode' - Utiliser 'System.HashCode' - - Use block body for lambda expressions Utiliser le corps de bloc pour les expressions lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index bfe981e34f829..be34cbf2614c3 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -272,11 +272,6 @@ Generare il parametro '{0}' (e override/implementazioni) - - 'GetHashCode' implementation can be simplified - L'implementazione di 'GetHashCode' può essere semplificata - - Implement '{0}' explicitly Implementa '{0}' in modo esplicito @@ -597,11 +592,6 @@ Usare il criterio dispose consigliato per garantire che gli oggetti eliminabili con ambito locale vengano eliminati in tutti i percorsi. Se possibile, eseguire il wrapping della creazione in un'istruzione 'using' o una dichiarazione 'using'. In caso contrario, usare un criterio try-finally, con una variabile locale dedicata dichiarata prima dell'area try e una chiamata Dispose non condizionale al valore non Null nell'area 'finally', ad esempio 'x?.Dispose()'. Se l'oggetto viene eliminato in modo esplicito nell'area try oppure la proprietà di dispose viene trasferita a un altro oggetto o metodo, assegnare 'null' alla variabile locale subito dopo una tale operazione per evitare di raddoppiare dispose in 'finally' - - Use 'System.HashCode' - Usa 'System.HashCode' - - Use block body for lambda expressions Usa il corpo del blocco per le espressioni lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index f696c8fc56069..dec09bb128aab 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -272,11 +272,6 @@ パラメーター '{0}' の生成 (およびオーバーライド/実装) - - 'GetHashCode' implementation can be simplified - 'GetHashCode' の実装を簡略化できます - - Implement '{0}' explicitly '{0}' を明示的に実装する @@ -597,11 +592,6 @@ 推奨される破棄パターンを使用して、ローカル スコープの破棄可能なオブジェクトがすべてのパスで破棄されるようにします。可能なら、'using' ステートメントまたは 'using' 宣言内で作成を折り返します。または、try-finally パターンを、try 領域の前で宣言された専用のローカル変数と、'finally' 領域の非 null 値での条件なしの Dispose の呼び出し (例: 'x?.Dispose()') とともに使用します。オブジェクトが try 領域内で明示的に破棄されるか、dispose の所有権が他のオブジェクトまたはメソッドに移される場合、その操作のすぐ後で 'null' をローカル変数に割り当てて、'finally' 内での dispose の重複を回避します - - Use 'System.HashCode' - 'System.HashCode' を使用する - - Use block body for lambda expressions ラムダ式にブロック本体を使用する diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 670e07287b15c..cefe03f236c56 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -272,11 +272,6 @@ '{0}' 매개 변수(및 재정의/구현) 생성 - - 'GetHashCode' implementation can be simplified - 'GetHashCode' 구현이 간소화될 수 있습니다. - - Implement '{0}' explicitly '{0}'을(를) 명시적으로 구현 @@ -597,11 +592,6 @@ 권장 dispose 패턴을 사용하여 로컬로 범위가 지정된 삭제 가능한 개체가 모든 경로에서 삭제되도록 합니다. 가능한 경우 'using' 문이나 'using' 선언 내에서 생성을 래핑합니다. 그러지 않으면 try 영역 앞에 선언된 전용 지역 변수 및 'finally' 영역에 있는 null이 아닌 값의 비조건부 Dispose 호출('x?.Dispose()')과 함께 try-finally 패턴을 사용하세요. 개체가 try 영역 내에서 명시적으로 삭제되거나 삭제 소유권이 다른 개체나 메서드로 이전되면 해당 작업 바로 뒤의 지역 변수에 'null'을 할당하여 'finally'에서 이중 삭제를 방지하세요. - - Use 'System.HashCode' - 'System.HashCode' 사용 - - Use block body for lambda expressions 람다 식에 블록 본문 사용 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 3b336f7f95164..282b04e6dd9c3 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -272,11 +272,6 @@ Generowanie parametru „{0}” (i przesłonięć/implementacji) - - 'GetHashCode' implementation can be simplified - Implementację „GetHashCode” można uprościć - - Implement '{0}' explicitly Jawnie zaimplementuj interfejs „{0}” @@ -597,11 +592,6 @@ Użyj zalecanego wzorca likwidacji, aby upewnić się, że obiekty możliwe do likwidacji w lokalnym zakresie są likwidowane we wszystkich ścieżkach. Jeśli to możliwe, opakuj tworzenie w instrukcji „using” lub deklaracji „using”. W przeciwnym razie użyj wzorca try-finally z dedykowaną zmienną lokalną zadeklarowaną przed regionem try i bezwarunkowym wywołaniem metody Dispose dla wartości innej niż null w regionie „finally”, na przykład „x?.Dispose()”. Jeśli obiekt jest jawnie likwidowany w regionie try lub własność dispose jest przenoszona do innego obiektu lub metody, przypisz wartość „null” do zmiennej lokalnej zaraz po takiej operacji, aby zapobiec podwójnemu wywołaniu dispose w regionie „finally” - - Use 'System.HashCode' - Użyj elementu „System.HashCode” - - Use block body for lambda expressions Użyj treści bloku dla wyrażeń lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index f2902b99e9320..37b88a19fbffa 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -272,11 +272,6 @@ Gerar o parâmetro '{0}' (e as substituições/implementações) - - 'GetHashCode' implementation can be simplified - A implementação de 'GetHashCode' pode ser simplificada - - Implement '{0}' explicitly Implementar '{0}' explicitamente @@ -597,11 +592,6 @@ Use o padrão de descarte recomendado para garantir que os objetos descartáveis no escopo local sejam descartados em todos os caminhos. Se possível, encapsule a criação em uma instrução 'using' ou em uma declaração 'using'. Caso contrário, use um padrão try-finally, com uma variável local dedicada declarada antes da região try e uma invocação de Dispose incondicional em um valor que não seja nulo na região 'finally', como 'x?.Dispose()'. Se o objeto for descartado explicitamente dentro da região try ou se a propriedade de descarte for transferida para outro objeto ou método, atribua 'null' à variável local logo após essa operação para evitar um descarte duplo em 'finally' - - Use 'System.HashCode' - Use 'System.HashCode' - - Use block body for lambda expressions Usar o corpo do bloco para expressões lambda diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 2c60bdc6955cd..3ff454b6fd23c 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -272,11 +272,6 @@ Создать параметр "{0}" (а также переопределения или реализации) - - 'GetHashCode' implementation can be simplified - Реализацию "GetHashCode" можно упростить. - - Implement '{0}' explicitly Реализовать "{0}" явно @@ -597,11 +592,6 @@ Используйте рекомендуемый шаблон для корректного освобождения объектов в локальной области по всем путям. По возможности создание следует заключить в оператор using или объявление using. Если это невозможно, используйте шаблон try-finally с выделенной локальной переменной, объявляемой до области try, и безусловным вызовом Dispose для отличного от NULL значения в области finally, например: x?.Dispose(). Если объект явно освобождается в области try или владение освобождением передается другому объекту или методу, то сразу после такой операции присвойте локальной переменной значение NULL, чтобы предотвратить двойное освобождение в finally. - - Use 'System.HashCode' - Используйте "System.HashCode". - - Use block body for lambda expressions Использовать тело блока для лямбда-выражений diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 809943b122f92..20e727abc2df2 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -272,11 +272,6 @@ '{0}' parametresini (ve geçersiz kılmaları/uygulamaları) üret - - 'GetHashCode' implementation can be simplified - 'GetHashCode' uygulaması basitleştirilebilir - - Implement '{0}' explicitly '{0}' öğesini açıkça uygula @@ -597,11 +592,6 @@ Yerel olarak kapsamı oluşturulan atılabilir nesnelerin tüm yollarda atıldığından emin olmak için önerilen atma desenini kullanın. Mümkünse, oluşturulan nesneyi 'using' deyimi veya 'using' bildirimiyle sarmalayın. Aksi halde, try bölgesinden önce bildirilen ayrılmış bir yerel değişkeni ve 'finally' bölgesinde null olmayan değer üzerinde koşulsuz bir Dispose çağrısı (örneğin, 'x?.Dispose()') olan bir try-finally deseni kullanın. Nesne try bölgesi içinde açıkça atıldıysa veya atma sahipliği başka bir nesne ya da metoda aktarıldıysa, 'finally' bölgesinde çift atma gerçekleşmesini önlemek için bu tür bir işlemden hemen sonra yerel değişkene 'null' atayın - - Use 'System.HashCode' - 'System.HashCode' kullan - - Use block body for lambda expressions Lambda ifadeleri için blok vücut kullanımı diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 2ddd4b9320a22..492da39fbaab9 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -272,11 +272,6 @@ 生成参数 {0}(和重写/实现) - - 'GetHashCode' implementation can be simplified - 可简化 "GetHashCode" 实现 - - Implement '{0}' explicitly 显式实现 "{0}" @@ -597,11 +592,6 @@ 使用推荐的释放模式以确保在所有路径中释放局部可释放对象。如果可能,请将创建包装在 "using" 语句或 "using" 声明中。否则,请使用 try-finally 模式,在 try 区域之前声明一个专用的局部变量,在 "finally" 区域中对非 null 值进行无条件 Dispose 调用,比如,"x?.Dispose()"。如果对象显式释放在 try 区域内或释放所有权转让给另一个对象或方法,则在这样的操作之后立即将 "null" 分配给局部变量,以防止在 "finally" 中进行双重释放。 - - Use 'System.HashCode' - 使用 "System.HashCode" - - Use block body for lambda expressions 对 lambda 表达式使用块主体 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index e9cb1acb6487d..acd3ac349db59 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -272,11 +272,6 @@ 產生參數 '{0}' (以及覆寫/實作) - - 'GetHashCode' implementation can be simplified - 'GetHashCode' 實作可簡化 - - Implement '{0}' explicitly 明確實作 '{0}' @@ -597,11 +592,6 @@ 請使用建議的處置模式,確保區域範圍的可處置物件在所有路徑上均會經過處置。在可能的情況下,請將建立包在 'using' 陳述式或 'using' 宣告內。否則,請使用 try-finally 模式,同時在 try 區域之前先宣告專用的區域變數,並在 'finally' 區域中的非 null 值上,設定無條件 Dispose 引動過程,比如 'x?.Dispose()'。如果 try 區域內已明確地處置了該物件,或是處置擁有權已轉移到另一個物件或方法,則請在這類作業之後,對區域變數指派 'null',以避免在 'finally' 中發生雙重處置 - - Use 'System.HashCode' - 使用 'System.HashCode' - - Use block body for lambda expressions 使用 Lambda 運算式的區塊主體 From 2d96be7108f7cdc94b2d724eb442418f63b3dc33 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 3 Apr 2020 19:48:48 -0700 Subject: [PATCH 38/50] Fix build warning --- .../SyntaxGeneratorInternal.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs index f540649219af1..c2d32c378ea71 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs @@ -54,9 +54,9 @@ internal SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initi internal abstract SyntaxNode YieldReturnStatement(SyntaxNode expression); /// - /// if the language requires a + /// if the language requires a "TypeExpression" /// (including ) to be stated when making a - /// . + /// . /// if the language allows the type node to be entirely elided. /// internal abstract bool RequiresLocalDeclarationType(); From 2a6be197264605b830e78077e5486757684ac59e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 3 Apr 2020 13:32:05 -0700 Subject: [PATCH 39/50] Avoid delegate allocations --- .../Providers/SymbolCompletionItem.cs | 7 +++++-- .../Shared/Extensions/ISymbolExtensions.cs | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Features/Core/Portable/Completion/Providers/SymbolCompletionItem.cs b/src/Features/Core/Portable/Completion/Providers/SymbolCompletionItem.cs index ad4061f946a96..62378d3d921c8 100644 --- a/src/Features/Core/Portable/Completion/Providers/SymbolCompletionItem.cs +++ b/src/Features/Core/Portable/Completion/Providers/SymbolCompletionItem.cs @@ -15,6 +15,9 @@ namespace Microsoft.CodeAnalysis.Completion.Providers { internal static partial class SymbolCompletionItem { + private static readonly Func, CompletionItem, CompletionItem> s_addSymbolEncoding = AddSymbolEncoding; + private static readonly Func, CompletionItem, CompletionItem> s_addSymbolInfo = AddSymbolInfo; + private static CompletionItem CreateWorker( string displayText, string displayTextSuffix, @@ -280,7 +283,7 @@ public static CompletionItem CreateWithSymbolId( { return CreateWorker( displayText, displayTextSuffix, symbols, rules, contextPosition, - AddSymbolEncoding, sortText, insertionText, + s_addSymbolEncoding, sortText, insertionText, filterText, supportedPlatforms, properties, tags); } @@ -299,7 +302,7 @@ public static CompletionItem CreateWithNameAndKind( { return CreateWorker( displayText, displayTextSuffix, symbols, rules, contextPosition, - AddSymbolInfo, sortText, insertionText, + s_addSymbolInfo, sortText, insertionText, filterText, supportedPlatforms, properties, tags); } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.cs index 4d2ec0d4a9aee..6a65c31a3a509 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.cs @@ -653,18 +653,19 @@ public static ImmutableArray FilterToVisibleAndBrowsableSymbols( // PERF: HasUnsupportedMetadata may require recreating the syntax tree to get the base class, so first // check to see if we're referencing a symbol defined in source. - bool isSymbolDefinedInSource(Location l) => l.IsInSource; - return symbols.WhereAsArray(s => + static bool isSymbolDefinedInSource(Location l) => l.IsInSource; + return symbols.WhereAsArray((s, arg) => (s.Locations.Any(isSymbolDefinedInSource) || !s.HasUnsupportedMetadata) && !s.IsDestructor() && s.IsEditorBrowsable( - hideAdvancedMembers, - compilation, - editorBrowsableAttributeConstructor, - typeLibTypeAttributeConstructors, - typeLibFuncAttributeConstructors, - typeLibVarAttributeConstructors, - hideModuleNameAttribute)); + arg.hideAdvancedMembers, + arg.compilation, + arg.editorBrowsableAttributeConstructor, + arg.typeLibTypeAttributeConstructors, + arg.typeLibFuncAttributeConstructors, + arg.typeLibVarAttributeConstructors, + arg.hideModuleNameAttribute), + (hideAdvancedMembers, compilation, editorBrowsableAttributeConstructor, typeLibTypeAttributeConstructors, typeLibFuncAttributeConstructors, typeLibVarAttributeConstructors, hideModuleNameAttribute)); } private static ImmutableArray RemoveOverriddenSymbolsWithinSet(this ImmutableArray symbols) where T : ISymbol From 8fea41a41e2fc3c91e1eb775f4de265f7a19b58e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 5 Apr 2020 16:58:07 -0700 Subject: [PATCH 40/50] Share section keys when a parent of a root is different --- src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs index f9b3f17ad933a..e3699277fd1a6 100644 --- a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs +++ b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs @@ -164,6 +164,7 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) analyzerOptionsBuilder.Clear(); treeOptionsBuilder.Clear(); diagnosticBuilder.Clear(); + sectionKey.Clear(); } int dirLength = config.NormalizedDirectory.Length; From d049cff18d94a222a9ac4c09855a6c64680fea18 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 5 Apr 2020 16:58:24 -0700 Subject: [PATCH 41/50] Use config cache to avoid tree creation --- .../Portable/CommandLine/AnalyzerConfigSet.cs | 55 +++++++++++++------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs index e3699277fd1a6..04661d74ff31c 100644 --- a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs +++ b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs @@ -142,9 +142,6 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) throw new ArgumentNullException(nameof(sourcePath)); } - var treeOptionsBuilder = _treeOptionsPool.Allocate(); - var analyzerOptionsBuilder = _analyzerOptionsPool.Allocate(); - var diagnosticBuilder = ArrayBuilder.GetInstance(); var sectionKey = _sectionKeyPool.Allocate(); var normalizedPath = PathUtilities.NormalizeWithForwardSlash(sourcePath); @@ -161,9 +158,6 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) // to this source file. if (config.IsRoot) { - analyzerOptionsBuilder.Clear(); - treeOptionsBuilder.Clear(); - diagnosticBuilder.Clear(); sectionKey.Clear(); } @@ -183,13 +177,6 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) if (matchers[sectionIndex]?.IsMatch(relativePath) == true) { var section = config.NamedSections[sectionIndex]; - addOptions( - section, - treeOptionsBuilder, - analyzerOptionsBuilder, - diagnosticBuilder, - config.PathToFile, - _diagnosticIdCache); sectionKey.Add(section); } } @@ -200,10 +187,47 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) // exact same options if (!_optionsCache.TryGetValue(sectionKey, out var result)) { + var treeOptionsBuilder = _treeOptionsPool.Allocate(); + var analyzerOptionsBuilder = _analyzerOptionsPool.Allocate(); + var diagnosticBuilder = ArrayBuilder.GetInstance(); + + int sectionIndex = 0; + for (int analyzerConfigIndex = 0; + analyzerConfigIndex < _analyzerConfigs.Length && sectionIndex < sectionKey.Count; + analyzerConfigIndex++) + { + AnalyzerConfig config = _analyzerConfigs[analyzerConfigIndex]; + ImmutableArray matchers = _analyzerMatchers[analyzerConfigIndex]; + for (int matcherIndex = 0; matcherIndex < matchers.Length; matcherIndex++) + { + if (sectionKey[sectionIndex] == config.NamedSections[matcherIndex]) + { + addOptions( + sectionKey[sectionIndex], + treeOptionsBuilder, + analyzerOptionsBuilder, + diagnosticBuilder, + config.PathToFile, + _diagnosticIdCache); + sectionIndex++; + if (sectionIndex == sectionKey.Count) + { + break; + } + } + } + } + result = new AnalyzerConfigOptionsResult( treeOptionsBuilder.Count > 0 ? treeOptionsBuilder.ToImmutable() : SyntaxTree.EmptyDiagnosticOptions, analyzerOptionsBuilder.Count > 0 ? analyzerOptionsBuilder.ToImmutable() : AnalyzerConfigOptions.EmptyDictionary, diagnosticBuilder.ToImmutableAndFree()); + + treeOptionsBuilder.Clear(); + analyzerOptionsBuilder.Clear(); + _treeOptionsPool.Free(treeOptionsBuilder); + _analyzerOptionsPool.Free(analyzerOptionsBuilder); + if (_optionsCache.TryAdd(sectionKey, result)) { // Release the pooled object to be used as a key @@ -219,11 +243,6 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) freeKey(sectionKey, _sectionKeyPool); } - treeOptionsBuilder.Clear(); - analyzerOptionsBuilder.Clear(); - _treeOptionsPool.Free(treeOptionsBuilder); - _analyzerOptionsPool.Free(analyzerOptionsBuilder); - return result; static void freeKey(List
sectionKey, ObjectPool> pool) From 264930a4d0a3670e2f407d73d452ad105d3d4261 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 5 Apr 2020 20:43:26 -0700 Subject: [PATCH 42/50] Update Microsoft.CodeAnalysis.Testing reference --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 6c9de7624ad7b..7110d7fd918fd 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -29,7 +29,7 @@ 3.0.0-beta2.20169.3 3.3.1 - 1.0.1-beta1.20126.2 + 1.0.1-beta1.20206.1 3.6.0-2.20157.5 16.4.248 5.0.0-alpha1.19409.1 From bd272433641980346cffc5c7c0aadbac7b0e6805 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 3 Apr 2020 18:15:17 -0700 Subject: [PATCH 43/50] Update BatchFixAllProvider to support nested code actions Fixes #43044 --- .../FixAllOccurrences/BatchFixAllProvider.cs | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs index 44a9f35ee79e7..0c893741f0492 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs @@ -171,14 +171,27 @@ private async Task GetFixAsync( private static Action> GetRegisterCodeFixAction( FixAllState fixAllState, ConcurrentBag<(Diagnostic diagnostic, CodeAction action)> result) - => (action, diagnostics) => - { - if (action != null && action.EquivalenceKey == fixAllState.CodeActionEquivalenceKey) - { - result.Add((diagnostics.First(), action)); - } - }; + { + return (action, diagnostics) => + { + using var _ = ArrayBuilder.GetInstance(out var builder); + builder.Push(action); + while (builder.Count > 0) + { + var currentAction = builder.Pop(); + if (currentAction is { EquivalenceKey: var equivalenceKey } + && equivalenceKey == fixAllState.CodeActionEquivalenceKey) + { + result.Add((diagnostics.First(), currentAction)); + } + foreach (var nestedAction in currentAction.NestedCodeActions) + { + builder.Push(nestedAction); + } + } + }; + } protected virtual Task AddProjectFixesAsync( Project project, ImmutableArray diagnostics, From 7ade38964198b9dfc218b17fbfa8d4e82291f930 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 5 Apr 2020 21:02:10 -0700 Subject: [PATCH 44/50] Add tests for BatchFixAllProvider handling of nested code actions --- .../Roslyn.Services.Test.Utilities.csproj | 2 - .../CoreTest/BatchFixAllProviderTests.cs | 175 ++++++++++++++++++ ...Roslyn.Services.UnitTests.Utilities.csproj | 2 + 3 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 src/Workspaces/CoreTest/BatchFixAllProviderTests.cs diff --git a/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj b/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj index 8f6d7a998072a..cdd902115bb1d 100644 --- a/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj +++ b/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj @@ -57,8 +57,6 @@ - - diff --git a/src/Workspaces/CoreTest/BatchFixAllProviderTests.cs b/src/Workspaces/CoreTest/BatchFixAllProviderTests.cs new file mode 100644 index 0000000000000..7596e7595c0f8 --- /dev/null +++ b/src/Workspaces/CoreTest/BatchFixAllProviderTests.cs @@ -0,0 +1,175 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.CodeAnalysis.Text; +using Xunit; + +namespace Microsoft.CodeAnalysis.UnitTests +{ + public class BatchFixAllProviderTests + { + [Fact] + public async Task TestDefaultSelectionNestedFixers() + { + var testCode = @" +class TestClass { + int field = [|0|]; +} +"; + var fixedCode = $@" +class TestClass {{ + int field = 1; +}} +"; + + // Three CodeFixProviders provide three actions + var codeFixes = ImmutableArray.Create( + ImmutableArray.Create(1), + ImmutableArray.Create(2), + ImmutableArray.Create(3)); + await new CSharpTest(codeFixes, nested: true) + { + TestCode = testCode, + FixedCode = fixedCode, + }.RunAsync(); + } + + [DiagnosticAnalyzer(LanguageNames.CSharp)] + private class LiteralZeroAnalyzer : DiagnosticAnalyzer + { + internal static readonly DiagnosticDescriptor Descriptor = + new DiagnosticDescriptor("LiteralZero", "title", "message", "category", DiagnosticSeverity.Warning, isEnabledByDefault: true); + + public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(Descriptor); + + public override void Initialize(AnalysisContext context) + { + context.EnableConcurrentExecution(); + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + + context.RegisterSyntaxNodeAction(HandleNumericLiteralExpression, SyntaxKind.NumericLiteralExpression); + } + + private void HandleNumericLiteralExpression(SyntaxNodeAnalysisContext context) + { + var node = (LiteralExpressionSyntax)context.Node; + if (node.Token.ValueText == "0") + { + context.ReportDiagnostic(Diagnostic.Create(Descriptor, node.Token.GetLocation())); + } + } + } + + private class ReplaceZeroFix : CodeFixProvider + { + private readonly ImmutableArray _replacements; + private readonly bool _nested; + + public ReplaceZeroFix(ImmutableArray replacements, bool nested) + { + Debug.Assert(replacements.All(replacement => replacement >= 0), $"Assertion failed: {nameof(replacements)}.All(replacement => replacement >= 0)"); + _replacements = replacements; + _nested = nested; + } + + public override ImmutableArray FixableDiagnosticIds => ImmutableArray.Create(LiteralZeroAnalyzer.Descriptor.Id); + + public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer; + + public override Task RegisterCodeFixesAsync(CodeFixContext context) + { + foreach (var diagnostic in context.Diagnostics) + { + var fixes = new List(); + foreach (var replacement in _replacements) + { + fixes.Add(CodeAction.Create( + "ThisToBase", + cancellationToken => CreateChangedDocument(context.Document, diagnostic.Location.SourceSpan, replacement, cancellationToken), + $"{nameof(ReplaceZeroFix)}_{replacement}")); + } + + if (_nested) + { +#if NETCOREAPP2_0 || NET472 + fixes = new List { CodeAction.Create("Container", fixes.ToImmutableArray(), isInlinable: false) }; +#else + throw new NotSupportedException("Nested code actions are not supported on this framework."); +#endif + } + + foreach (var fix in fixes) + { + context.RegisterCodeFix(fix, diagnostic); + } + } + + return Task.CompletedTask; + } + + private async Task CreateChangedDocument(Document document, TextSpan sourceSpan, int replacement, CancellationToken cancellationToken) + { + var tree = await document.GetSyntaxTreeAsync(cancellationToken); + var root = await tree.GetRootAsync(cancellationToken); + var token = root.FindToken(sourceSpan.Start); + var newToken = SyntaxFactory.Literal(token.LeadingTrivia, replacement.ToString(), replacement, token.TrailingTrivia); + return document.WithSyntaxRoot(root.ReplaceToken(token, newToken)); + } + } + + private class CSharpTest : CodeFixTest + { + private readonly ImmutableArray> _replacementGroups; + private readonly bool _nested; + + public CSharpTest(ImmutableArray> replacementGroups, bool nested = false) + { + _replacementGroups = replacementGroups; + _nested = nested; + } + + public override string Language => LanguageNames.CSharp; + + public override Type SyntaxKindType => typeof(SyntaxKind); + + protected override string DefaultFileExt => "cs"; + + protected override CompilationOptions CreateCompilationOptions() + { + return new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); + } + + protected override ParseOptions CreateParseOptions() + { + return new CSharpParseOptions(LanguageVersion.Default, DocumentationMode.Diagnose); + } + + protected override IEnumerable GetCodeFixProviders() + { + foreach (var replacementGroup in _replacementGroups) + { + yield return new ReplaceZeroFix(replacementGroup, _nested); + } + } + + protected override IEnumerable GetDiagnosticAnalyzers() + { + yield return new LiteralZeroAnalyzer(); + } + } + } +} diff --git a/src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj b/src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj index a4b2c92fb9fd5..9eb0a7601e548 100644 --- a/src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj +++ b/src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj @@ -23,6 +23,8 @@ + + From 430ce46a0b9da62175dcd3ca803caa70649195d1 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 5 Apr 2020 23:02:23 -0700 Subject: [PATCH 45/50] Use Regex.IsMatch instead of Regex.Match when no groups are needed --- .../CommandLine/AnalyzerConfig.SectionNameMatching.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.SectionNameMatching.cs b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.SectionNameMatching.cs index 665d23f9dbfe7..08227de4c6cf5 100644 --- a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.SectionNameMatching.cs +++ b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.SectionNameMatching.cs @@ -31,6 +31,11 @@ internal SectionNameMatcher( public bool IsMatch(string s) { + if (_numberRangePairs.IsEmpty) + { + return Regex.IsMatch(s); + } + var match = Regex.Match(s); if (!match.Success) { From 1875bd78ebaeaa073175bc43e010e32d039f145e Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Mon, 6 Apr 2020 06:45:11 -0700 Subject: [PATCH 46/50] Move extension methods down to shared analyzer layer --- .../Extensions/ExpressionSyntaxExtensions.vb | 122 ++++++++++++++++++ .../Extensions/ExpressionSyntaxExtensions.vb | 122 ------------------ 2 files changed, 122 insertions(+), 122 deletions(-) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb index 711cf977e1e1b..65bbb1f3a2b86 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb @@ -219,5 +219,127 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return OperatorPrecedence.PrecedenceNone End Select End Function + + + Public Function IsInOutContext(expression As ExpressionSyntax) As Boolean + ' NOTE(cyrusn): VB has no concept of an out context. Even when a parameter has an + ' '' attribute on it, it's still treated as ref by VB. So we always return false + ' here. + Return False + End Function + + + Public Function IsInRefContext(expression As ExpressionSyntax, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Boolean + Dim simpleArgument = TryCast(expression?.Parent, SimpleArgumentSyntax) + + If simpleArgument Is Nothing Then + Return False + ElseIf simpleArgument.IsNamed Then + Dim info = semanticModel.GetSymbolInfo(simpleArgument.NameColonEquals.Name, cancellationToken) + + Dim parameter = TryCast(info.GetAnySymbol(), IParameterSymbol) + Return parameter IsNot Nothing AndAlso parameter.RefKind <> RefKind.None + + Else + Dim argumentList = TryCast(simpleArgument.Parent, ArgumentListSyntax) + + If argumentList IsNot Nothing Then + Dim parent = argumentList.Parent + Dim index = argumentList.Arguments.IndexOf(simpleArgument) + + Dim info = semanticModel.GetSymbolInfo(parent, cancellationToken) + Dim symbol = info.GetAnySymbol() + + If TypeOf symbol Is IMethodSymbol Then + Dim method = DirectCast(symbol, IMethodSymbol) + If index < method.Parameters.Length Then + Return method.Parameters(index).RefKind <> RefKind.None + End If + ElseIf TypeOf symbol Is IPropertySymbol Then + Dim prop = DirectCast(symbol, IPropertySymbol) + If index < prop.Parameters.Length Then + Return prop.Parameters(index).RefKind <> RefKind.None + End If + End If + End If + + End If + + Return False + End Function + + + Public Function IsInInContext(expression As ExpressionSyntax) As Boolean + ' NOTE: VB does not support in parameters. Always return False here. + Return False + End Function + + + Public Function IsOnlyWrittenTo(expression As ExpressionSyntax) As Boolean + If expression.IsRightSideOfDot() Then + expression = TryCast(expression.Parent, ExpressionSyntax) + End If + + If expression IsNot Nothing Then + If expression.IsInOutContext() Then + Return True + End If + + If expression.IsParentKind(SyntaxKind.SimpleAssignmentStatement) Then + Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax) + If expression Is assignmentStatement.Left Then + Return True + End If + End If + + If expression.IsParentKind(SyntaxKind.NameColonEquals) AndAlso + expression.Parent.IsParentKind(SyntaxKind.SimpleArgument) Then + + ' + ' this is only a write to Prop + Return True + End If + + If expression.IsChildNode(Of NamedFieldInitializerSyntax)(Function(n) n.Name) Then + Return True + End If + + Return False + End If + + Return False + End Function + + + Public Function IsWrittenTo(expression As ExpressionSyntax, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Boolean + If IsOnlyWrittenTo(expression) Then + Return True + End If + + If expression.IsRightSideOfDot() Then + expression = TryCast(expression.Parent, ExpressionSyntax) + End If + + If expression IsNot Nothing Then + If expression.IsInRefContext(semanticModel, cancellationToken) Then + Return True + End If + + If TypeOf expression.Parent Is AssignmentStatementSyntax Then + Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax) + If expression Is assignmentStatement.Left Then + Return True + End If + End If + + If expression.IsChildNode(Of NamedFieldInitializerSyntax)(Function(n) n.Name) Then + Return True + End If + + Return False + End If + + Return False + End Function End Module End Namespace diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb index c9b8cd9b44697..745a4116756e0 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb @@ -213,128 +213,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions DirectCast(expression, ObjectCreationExpressionSyntax).ArgumentList Is Nothing End Function - - Public Function IsInOutContext(expression As ExpressionSyntax) As Boolean - ' NOTE(cyrusn): VB has no concept of an out context. Even when a parameter has an - ' '' attribute on it, it's still treated as ref by VB. So we always return false - ' here. - Return False - End Function - - - Public Function IsInRefContext(expression As ExpressionSyntax, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Boolean - Dim simpleArgument = TryCast(expression?.Parent, SimpleArgumentSyntax) - - If simpleArgument Is Nothing Then - Return False - ElseIf simpleArgument.IsNamed Then - Dim info = semanticModel.GetSymbolInfo(simpleArgument.NameColonEquals.Name, cancellationToken) - - Dim parameter = TryCast(info.GetAnySymbol(), IParameterSymbol) - Return parameter IsNot Nothing AndAlso parameter.RefKind <> RefKind.None - - Else - Dim argumentList = TryCast(simpleArgument.Parent, ArgumentListSyntax) - - If argumentList IsNot Nothing Then - Dim parent = argumentList.Parent - Dim index = argumentList.Arguments.IndexOf(simpleArgument) - - Dim info = semanticModel.GetSymbolInfo(parent, cancellationToken) - Dim symbol = info.GetAnySymbol() - - If TypeOf symbol Is IMethodSymbol Then - Dim method = DirectCast(symbol, IMethodSymbol) - If index < method.Parameters.Length Then - Return method.Parameters(index).RefKind <> RefKind.None - End If - ElseIf TypeOf symbol Is IPropertySymbol Then - Dim prop = DirectCast(symbol, IPropertySymbol) - If index < prop.Parameters.Length Then - Return prop.Parameters(index).RefKind <> RefKind.None - End If - End If - End If - - End If - - Return False - End Function - - - Public Function IsInInContext(expression As ExpressionSyntax) As Boolean - ' NOTE: VB does not support in parameters. Always return False here. - Return False - End Function - - - Public Function IsOnlyWrittenTo(expression As ExpressionSyntax) As Boolean - If expression.IsRightSideOfDot() Then - expression = TryCast(expression.Parent, ExpressionSyntax) - End If - - If expression IsNot Nothing Then - If expression.IsInOutContext() Then - Return True - End If - - If expression.IsParentKind(SyntaxKind.SimpleAssignmentStatement) Then - Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax) - If expression Is assignmentStatement.Left Then - Return True - End If - End If - - If expression.IsParentKind(SyntaxKind.NameColonEquals) AndAlso - expression.Parent.IsParentKind(SyntaxKind.SimpleArgument) Then - - ' - ' this is only a write to Prop - Return True - End If - - If expression.IsChildNode(Of NamedFieldInitializerSyntax)(Function(n) n.Name) Then - Return True - End If - - Return False - End If - - Return False - End Function - - - Public Function IsWrittenTo(expression As ExpressionSyntax, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Boolean - If IsOnlyWrittenTo(expression) Then - Return True - End If - - If expression.IsRightSideOfDot() Then - expression = TryCast(expression.Parent, ExpressionSyntax) - End If - - If expression IsNot Nothing Then - If expression.IsInRefContext(semanticModel, cancellationToken) Then - Return True - End If - - If TypeOf expression.Parent Is AssignmentStatementSyntax Then - Dim assignmentStatement = DirectCast(expression.Parent, AssignmentStatementSyntax) - If expression Is assignmentStatement.Left Then - Return True - End If - End If - - If expression.IsChildNode(Of NamedFieldInitializerSyntax)(Function(n) n.Name) Then - Return True - End If - - Return False - End If - - Return False - End Function - Public Function IsMeMyBaseOrMyClass(expression As ExpressionSyntax) As Boolean If expression Is Nothing Then From 0f8eda3d8f09b8655dbee0cdfbdfd52a8b65fc5c Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Mon, 6 Apr 2020 06:47:01 -0700 Subject: [PATCH 47/50] Port UseAutoProperty analyzer and tests to shared layer. Porting the code fix is blocked by #43091 --- src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems | 1 + .../UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs | 0 .../CSharp/Tests/CSharpAnalyzers.UnitTests.projitems | 1 + .../CSharp/Tests}/UseAutoProperty/UseAutoPropertyTests.cs | 2 +- src/Analyzers/Core/Analyzers/Analyzers.projitems | 1 + .../UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs | 4 ++-- .../VisualBasic/Analyzers}/UseAutoProperty/Utilities.vb | 0 .../UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb | 2 +- .../VisualBasic/Analyzers/VisualBasicAnalyzers.projitems | 2 ++ .../Tests}/UseAutoProperty/UseAutoPropertyTests.vb | 2 +- .../Tests/VisualBasicAnalyzers.UnitTests.projitems | 1 + .../AbstractDiagnosticProviderBasedUserDiagnosticTest.cs | 8 ++++++++ .../AbstractUseAutoPropertyCodeFixProvider.cs | 4 ++-- 13 files changed, 21 insertions(+), 7 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs (100%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/UseAutoProperty/UseAutoPropertyTests.cs (99%) rename src/{Features/Core/Portable => Analyzers/Core/Analyzers}/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs (98%) rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/Analyzers}/UseAutoProperty/Utilities.vb (100%) rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/Analyzers}/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb (98%) rename src/{EditorFeatures/VisualBasicTest => Analyzers/VisualBasic/Tests}/UseAutoProperty/UseAutoPropertyTests.vb (99%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index b098d8577794f..59d6797ff1281 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -35,6 +35,7 @@ + diff --git a/src/Features/CSharp/Portable/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs similarity index 100% rename from src/Features/CSharp/Portable/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index b136fcae4927b..3e7f5b5670388 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -21,6 +21,7 @@ + diff --git a/src/EditorFeatures/CSharpTest/UseAutoProperty/UseAutoPropertyTests.cs b/src/Analyzers/CSharp/Tests/UseAutoProperty/UseAutoPropertyTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/UseAutoProperty/UseAutoPropertyTests.cs rename to src/Analyzers/CSharp/Tests/UseAutoProperty/UseAutoPropertyTests.cs index 1e1e46f6f5768..62eb6973eb9d5 100644 --- a/src/EditorFeatures/CSharpTest/UseAutoProperty/UseAutoPropertyTests.cs +++ b/src/Analyzers/CSharp/Tests/UseAutoProperty/UseAutoPropertyTests.cs @@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.UseAutoProperty public class UseAutoPropertyTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest { internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace) - => (new CSharpUseAutoPropertyAnalyzer(), new CSharpUseAutoPropertyCodeFixProvider()); + => (new CSharpUseAutoPropertyAnalyzer(), GetCSharpUseAutoPropertyCodeFixProvider()); [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)] public async Task TestSingleGetterFromField() diff --git a/src/Analyzers/Core/Analyzers/Analyzers.projitems b/src/Analyzers/Core/Analyzers/Analyzers.projitems index c198a0748106c..3684c2471dc55 100644 --- a/src/Analyzers/Core/Analyzers/Analyzers.projitems +++ b/src/Analyzers/Core/Analyzers/Analyzers.projitems @@ -47,6 +47,7 @@ + diff --git a/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs similarity index 98% rename from src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs rename to src/Analyzers/Core/Analyzers/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs index bbb0a401c6a9f..094bacf67fb3b 100644 --- a/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs @@ -20,8 +20,8 @@ internal abstract class AbstractUseAutoPropertyAnalyzer< where TExpression : SyntaxNode { private static readonly LocalizableString s_title = - new LocalizableResourceString(nameof(FeaturesResources.Use_auto_property), - FeaturesResources.ResourceManager, typeof(FeaturesResources)); + new LocalizableResourceString(nameof(AnalyzersResources.Use_auto_property), + AnalyzersResources.ResourceManager, typeof(AnalyzersResources)); protected AbstractUseAutoPropertyAnalyzer() : base(IDEDiagnosticIds.UseAutoPropertyDiagnosticId, CodeStyleOptions2.PreferAutoProperties, s_title, s_title) diff --git a/src/Features/VisualBasic/Portable/UseAutoProperty/Utilities.vb b/src/Analyzers/VisualBasic/Analyzers/UseAutoProperty/Utilities.vb similarity index 100% rename from src/Features/VisualBasic/Portable/UseAutoProperty/Utilities.vb rename to src/Analyzers/VisualBasic/Analyzers/UseAutoProperty/Utilities.vb diff --git a/src/Features/VisualBasic/Portable/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb b/src/Analyzers/VisualBasic/Analyzers/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb similarity index 98% rename from src/Features/VisualBasic/Portable/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb rename to src/Analyzers/VisualBasic/Analyzers/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb index 208615e8e3186..04643aae93d09 100644 --- a/src/Features/VisualBasic/Portable/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb +++ b/src/Analyzers/VisualBasic/Analyzers/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb @@ -203,7 +203,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseAutoProperty If node.Kind() = SyntaxKind.IdentifierName Then Dim symbolInfo = semanticModel.GetSymbolInfo(node) If field.Equals(symbolInfo.Symbol) Then - If VisualBasicSemanticFactsService.Instance.IsWrittenTo(semanticModel, node, cancellationToken) Then + If DirectCast(node, ExpressionSyntax).IsWrittenTo(semanticModel, cancellationToken) Then Return True End If End If diff --git a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems index 33fdc5bced9e4..b849a18aa9733 100644 --- a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems +++ b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems @@ -28,6 +28,8 @@ + + diff --git a/src/EditorFeatures/VisualBasicTest/UseAutoProperty/UseAutoPropertyTests.vb b/src/Analyzers/VisualBasic/Tests/UseAutoProperty/UseAutoPropertyTests.vb similarity index 99% rename from src/EditorFeatures/VisualBasicTest/UseAutoProperty/UseAutoPropertyTests.vb rename to src/Analyzers/VisualBasic/Tests/UseAutoProperty/UseAutoPropertyTests.vb index d5fc588f83512..a3921c1fd9cd1 100644 --- a/src/EditorFeatures/VisualBasicTest/UseAutoProperty/UseAutoPropertyTests.vb +++ b/src/Analyzers/VisualBasic/Tests/UseAutoProperty/UseAutoPropertyTests.vb @@ -13,7 +13,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.UseAutoProperty Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace) As (DiagnosticAnalyzer, CodeFixProvider) - Return (New VisualBasicUseAutoPropertyAnalyzer(), New VisualBasicUseAutoPropertyCodeFixProvider()) + Return (New VisualBasicUseAutoPropertyAnalyzer(), GetVisualBasicUseAutoPropertyCodeFixProvider()) End Function diff --git a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems index 0cc6c8c979947..f1cbba47f6e7f 100644 --- a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems +++ b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems @@ -30,6 +30,7 @@ + diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs index 0783856819ff1..56ce2ac511b24 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs @@ -10,11 +10,13 @@ using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic; +using Microsoft.CodeAnalysis.CSharp.UseAutoProperty; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests.Diagnostics; +using Microsoft.CodeAnalysis.VisualBasic.UseAutoProperty; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; @@ -238,6 +240,12 @@ private void AssertNoAnalyzerExceptionDiagnostics(IEnumerable diagno // https://github.com/dotnet/roslyn/issues/43056 blocks porting the fixer to CodeStyle layer. protected static CodeFixProvider GetMakeLocalFunctionStaticCodeFixProvider() => new MakeLocalFunctionStaticCodeFixProvider(); + // https://github.com/dotnet/roslyn/issues/43091 blocks porting the fixer to CodeStyle layer. + protected static CodeFixProvider GetCSharpUseAutoPropertyCodeFixProvider() => new CSharpUseAutoPropertyCodeFixProvider(); + + // https://github.com/dotnet/roslyn/issues/43091 blocks porting the fixer to CodeStyle layer. + protected static CodeFixProvider GetVisualBasicUseAutoPropertyCodeFixProvider() => new VisualBasicUseAutoPropertyCodeFixProvider(); + #endregion } } diff --git a/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyCodeFixProvider.cs b/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyCodeFixProvider.cs index bce391fefa882..227d2c0be09e4 100644 --- a/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyCodeFixProvider.cs +++ b/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyCodeFixProvider.cs @@ -55,7 +55,7 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix( new UseAutoPropertyCodeAction( - FeaturesResources.Use_auto_property, + AnalyzersResources.Use_auto_property, c => ProcessResultAsync(context, diagnostic, c), priority), diagnostic); @@ -334,7 +334,7 @@ private static bool IsWrittenToOutsideOfConstructorOrProperty( return true; } - private class UseAutoPropertyCodeAction : CodeAction.SolutionChangeAction + private class UseAutoPropertyCodeAction : CustomCodeActions.SolutionChangeAction { public UseAutoPropertyCodeAction(string title, Func> createChangedSolution, CodeActionPriority priority) : base(title, createChangedSolution, title) From 808da9fcbe4e6932e9f7b74832f3dbe4879c4059 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Mon, 6 Apr 2020 06:47:09 -0700 Subject: [PATCH 48/50] xlf and resx file changes --- src/Analyzers/Core/Analyzers/AnalyzersResources.resx | 3 +++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf | 5 +++++ .../Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf | 5 +++++ src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf | 5 +++++ .../Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf | 5 +++++ .../Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf | 5 +++++ src/Features/Core/Portable/FeaturesResources.resx | 3 --- src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.de.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.es.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.it.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 5 ----- 28 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/Analyzers/Core/Analyzers/AnalyzersResources.resx b/src/Analyzers/Core/Analyzers/AnalyzersResources.resx index 92bc8c7b5634a..f043c1ef3b20a 100644 --- a/src/Analyzers/Core/Analyzers/AnalyzersResources.resx +++ b/src/Analyzers/Core/Analyzers/AnalyzersResources.resx @@ -277,6 +277,9 @@ Use null propagation + + Use auto property + Format string contains invalid placeholder diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf index 0602b871aaa9e..e46fe7f78cf08 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf index 5c66de0c38e22..4532f45f1c1a7 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf index 2dbdf2efcbe1a..875fe930be3f6 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf index 52d47926cf7d4..d2b94d84d5b1b 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf index a60565429d12a..7e437daa88869 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf index 712ff4dec8529..c2de060559807 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf index bd87341de835d..69d75e23ea708 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf index 4cfd07329b3d3..a763fa547b7e0 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf index 187469f24da65..e3ef971a8ab2b 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf index cc63674d3c364..a86919711df1e 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf index e066a1c832420..5414790241e59 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf index 8da7c01b2acf5..57d199ef14116 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf index 64ef51a016dbd..3c43ea97cae07 100644 --- a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf @@ -257,6 +257,11 @@ Use 'System.HashCode' + + Use auto property + Use auto property + + Use coalesce expression Use coalesce expression diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 63ccb6befb600..8d56816216db3 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -816,9 +816,6 @@ Do you want to continue? attribute - - Use auto property - Replace '{0}' and '{1}' with property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index 08502c0045fe7..ecf0449132ea5 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -1683,11 +1683,6 @@ Chcete pokračovat? atribut - - Use auto property - Použít automatickou vlastnost - - Replace '{0}' and '{1}' with property Nahradit {0} a {1} vlastností diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 86bd8b2e93715..693f75165b349 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -1683,11 +1683,6 @@ Möchten Sie fortfahren? Attribut - - Use auto property - Automatisch generierte Eigenschaft verwenden - - Replace '{0}' and '{1}' with property "{0}" und "{1}" durch Eigenschaft ersetzen diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index 21deb00787ab3..915760513dac1 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -1683,11 +1683,6 @@ Do you want to continue? atributo - - Use auto property - Usar propiedad automática - - Replace '{0}' and '{1}' with property Reemplazar '{0}' y '{1}' por la propiedad diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index a64604bef4def..787780f5d89e4 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -1683,11 +1683,6 @@ Voulez-vous continuer ? attribut - - Use auto property - Utiliser auto-property - - Replace '{0}' and '{1}' with property Remplacer '{0}' et '{1}' par une propriété diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index 85ddfbf829a97..4761afb03d8ef 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -1683,11 +1683,6 @@ Continuare? attributo - - Use auto property - Usa la proprietà automatica - - Replace '{0}' and '{1}' with property Sostituisci '{0}' e '{1}' con la proprietà diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index 9486fd3b89860..a3a0ef9f3b0bc 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -1683,11 +1683,6 @@ Do you want to continue? 属性 - - Use auto property - 自動プロパティを使用する - - Replace '{0}' and '{1}' with property {0}' および '{1}' をプロパティと置換する diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index b81da35212037..bb549d10126e0 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -1683,11 +1683,6 @@ Do you want to continue? 특성 - - Use auto property - auto 속성 사용 - - Replace '{0}' and '{1}' with property 속성으로 '{0}' 및 '{1}' 바꾸기 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index c8f4f07497108..deec1c5cb22d7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -1683,11 +1683,6 @@ Czy chcesz kontynuować? atrybut - - Use auto property - Użyj właściwości automatycznej - - Replace '{0}' and '{1}' with property Zastąp elementy „{0}” i „{1}” właściwością diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 1409e8d461128..2557777f95f2b 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -1683,11 +1683,6 @@ Deseja continuar? atributo - - Use auto property - Usar a propriedade auto - - Replace '{0}' and '{1}' with property Substituir "{0}" e "{1}" por propriedades diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 98c93f39ca77b..e19a88530b8eb 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -1683,11 +1683,6 @@ Do you want to continue? атрибут - - Use auto property - Использовать свойство auto - - Replace '{0}' and '{1}' with property Заменить "{0}" и "{1}" свойством diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index a87ca95862207..0472c37e2295d 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -1683,11 +1683,6 @@ Devam etmek istiyor musunuz? öznitelik - - Use auto property - Otomatik özellik kullan - - Replace '{0}' and '{1}' with property {0}' ve '{1}' öğesini özellikle değiştir diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index d017be9f851be..5bab026ca3681 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -1683,11 +1683,6 @@ Do you want to continue? 属性 - - Use auto property - 使用自动属性 - - Replace '{0}' and '{1}' with property 使用属性替代“{0}”和“{1}” diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index 577b3d2489c91..c150a94c79007 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -1683,11 +1683,6 @@ Do you want to continue? 屬性 - - Use auto property - 使用 Auto 屬性 - - Replace '{0}' and '{1}' with property 以屬性取代 '{0}' 和 '{1}' From 66ed21be4e5b36bfe079320b2829c356d004f5b4 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Mon, 6 Apr 2020 10:52:39 -0700 Subject: [PATCH 49/50] Inline variable --- .../SignatureHelpAfterCompletionCommandHandler.cs | 2 +- .../SignatureHelpBeforeCompletionCommandHandler.cs | 2 +- .../Extensibility/Commands/PredefinedCommandHandlerNames.cs | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/EditorFeatures/Core/CommandHandlers/SignatureHelpAfterCompletionCommandHandler.cs b/src/EditorFeatures/Core/CommandHandlers/SignatureHelpAfterCompletionCommandHandler.cs index 143c9e2e4f580..32f2fba1fe818 100644 --- a/src/EditorFeatures/Core/CommandHandlers/SignatureHelpAfterCompletionCommandHandler.cs +++ b/src/EditorFeatures/Core/CommandHandlers/SignatureHelpAfterCompletionCommandHandler.cs @@ -40,7 +40,7 @@ namespace Microsoft.CodeAnalysis.Editor.CommandHandlers [Order(After = PredefinedCompletionNames.CompletionCommandHandler)] // Ensure roslyn comes after LSP to allow them to provide results. // https://github.com/dotnet/roslyn/issues/42338 - [Order(After = PredefinedCommandHandlerNames.LSPSignatureHelp)] + [Order(After = "LSP SignatureHelpCommandHandler")] internal class SignatureHelpAfterCompletionCommandHandler : AbstractSignatureHelpCommandHandler, IChainedCommandHandler, diff --git a/src/EditorFeatures/Core/CommandHandlers/SignatureHelpBeforeCompletionCommandHandler.cs b/src/EditorFeatures/Core/CommandHandlers/SignatureHelpBeforeCompletionCommandHandler.cs index afdd96b5a9056..333b9c6123cfd 100644 --- a/src/EditorFeatures/Core/CommandHandlers/SignatureHelpBeforeCompletionCommandHandler.cs +++ b/src/EditorFeatures/Core/CommandHandlers/SignatureHelpBeforeCompletionCommandHandler.cs @@ -40,7 +40,7 @@ namespace Microsoft.CodeAnalysis.Editor.CommandHandlers [Order(Before = PredefinedCompletionNames.CompletionCommandHandler)] // Ensure roslyn comes after LSP to allow them to provide results. // https://github.com/dotnet/roslyn/issues/42338 - [Order(After = PredefinedCommandHandlerNames.LSPSignatureHelp)] + [Order(After = "LSP SignatureHelpCommandHandler")] internal class SignatureHelpBeforeCompletionCommandHandler : AbstractSignatureHelpCommandHandler, IChainedCommandHandler, diff --git a/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs b/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs index 907f1ed2c5717..c061874735ffd 100644 --- a/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs +++ b/src/EditorFeatures/Core/Extensibility/Commands/PredefinedCommandHandlerNames.cs @@ -171,10 +171,5 @@ internal static class PredefinedCommandHandlerNames /// Command handler name for Edit and Continue file save handler. /// public const string EditAndContinueFileSave = "Edit and Continue Save File Handler"; - - /// - /// Command handler name for the LSP client Signature Help command handler. - /// - public const string LSPSignatureHelp = "LSP SignatureHelpCommandHandler"; } } From af4102b87545b7b74bf4f8d52d7f0326fd2b178e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 6 Apr 2020 15:50:00 -0700 Subject: [PATCH 50/50] Update code for clarity --- .../Portable/CommandLine/AnalyzerConfigSet.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs index 04661d74ff31c..0685ae9192d83 100644 --- a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs +++ b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs @@ -191,27 +191,29 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) var analyzerOptionsBuilder = _analyzerOptionsPool.Allocate(); var diagnosticBuilder = ArrayBuilder.GetInstance(); - int sectionIndex = 0; + int sectionKeyIndex = 0; for (int analyzerConfigIndex = 0; - analyzerConfigIndex < _analyzerConfigs.Length && sectionIndex < sectionKey.Count; + analyzerConfigIndex < _analyzerConfigs.Length && sectionKeyIndex < sectionKey.Count; analyzerConfigIndex++) { AnalyzerConfig config = _analyzerConfigs[analyzerConfigIndex]; ImmutableArray matchers = _analyzerMatchers[analyzerConfigIndex]; for (int matcherIndex = 0; matcherIndex < matchers.Length; matcherIndex++) { - if (sectionKey[sectionIndex] == config.NamedSections[matcherIndex]) + if (sectionKey[sectionKeyIndex] == config.NamedSections[matcherIndex]) { addOptions( - sectionKey[sectionIndex], + sectionKey[sectionKeyIndex], treeOptionsBuilder, analyzerOptionsBuilder, diagnosticBuilder, config.PathToFile, _diagnosticIdCache); - sectionIndex++; - if (sectionIndex == sectionKey.Count) + sectionKeyIndex++; + if (sectionKeyIndex == sectionKey.Count) { + // Exit the inner 'for' loop now that work is done. The outer loop is handled by a + // top-level condition. break; } } @@ -223,11 +225,6 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) analyzerOptionsBuilder.Count > 0 ? analyzerOptionsBuilder.ToImmutable() : AnalyzerConfigOptions.EmptyDictionary, diagnosticBuilder.ToImmutableAndFree()); - treeOptionsBuilder.Clear(); - analyzerOptionsBuilder.Clear(); - _treeOptionsPool.Free(treeOptionsBuilder); - _analyzerOptionsPool.Free(analyzerOptionsBuilder); - if (_optionsCache.TryAdd(sectionKey, result)) { // Release the pooled object to be used as a key @@ -237,6 +234,11 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) { freeKey(sectionKey, _sectionKeyPool); } + + treeOptionsBuilder.Clear(); + analyzerOptionsBuilder.Clear(); + _treeOptionsPool.Free(treeOptionsBuilder); + _analyzerOptionsPool.Free(analyzerOptionsBuilder); } else {