From f18cea779b857ad5cb2a28837155b5f3bcdf370b Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 29 Jan 2020 09:47:21 -0800 Subject: [PATCH 01/26] Analyzer and code fixes refactoring --- Roslyn.sln | 102 +++ .../Analyzers/CSharpAnalyzers.projitems | 14 + .../CSharp/Analyzers/CSharpAnalyzers.shproj | 13 + ...rpRemoveUnusedMembersDiagnosticAnalyzer.cs | 0 .../CodeFixes/CSharpCodeFixes.projitems | 14 + .../CSharp/CodeFixes/CSharpCodeFixes.shproj | 13 + ...SharpRemoveUnusedMembersCodeFixProvider.cs | 0 .../Tests/CSharpAnalyzers.UnitTests.projitems | 14 + .../Tests/CSharpAnalyzers.UnitTests.shproj | 13 + .../RemoveUnusedMembersTests.cs | 8 +- ...tractBuiltInCodeStyleDiagnosticAnalyzer.cs | 6 + .../AbstractCodeQualityDiagnosticAnalyzer.cs | 7 +- .../AbstractCodeStyleDiagnosticAnalyzer.cs | 0 .../Core/Analyzers/Analyzers.projitems | 28 + src/Analyzers/Core/Analyzers/Analyzers.shproj | 13 + .../Analyzers}/DiagnosticAnalyzerCategory.cs | 0 .../Core/Analyzers}/DiagnosticCategory.cs | 0 .../Core/Analyzers}/DiagnosticCustomTags.cs | 0 .../DeserializationConstructorCheck.cs | 0 .../Analyzers/Helpers}/DiagnosticHelper.cs | 3 +- .../Core/Analyzers}/IBuiltInAnalyzer.cs | 8 +- .../IDEDiagnosticIdToOptionMappingHelper.cs | 0 .../Core}/Analyzers/IDEDiagnosticIds.cs | 0 ...ctRemoveUnusedMembersDiagnosticAnalyzer.cs | 18 +- .../Core/CodeFixes/CodeFixes.projitems | 15 + src/Analyzers/Core/CodeFixes/CodeFixes.shproj | 13 + .../PredefinedCodeFixProviderNames.cs | 0 ...tractRemoveUnusedMembersCodeFixProvider.cs | 11 +- .../Core/Tests/Analyzers.UnitTests.projitems | 11 + .../Core/Tests/Analyzers.UnitTests.shproj | 13 + ...icRemoveUnusedMembersDiagnosticAnalyzer.vb | 0 .../Analyzers/VisualBasicAnalyzers.projitems | 14 + .../Analyzers/VisualBasicAnalyzers.shproj | 13 + ...BasicRemoveUnusedMembersCodeFixProvider.vb | 0 .../CodeFixes/VisualBasicCodeFixes.projitems | 14 + .../CodeFixes/VisualBasicCodeFixes.shproj | 13 + .../RemoveUnusedMembersTests.vb | 0 .../VisualBasicAnalyzers.UnitTests.projitems | 24 + .../VisualBasicAnalyzers.UnitTests.shproj | 13 + src/CodeStyle/BannedSymbols.txt | 2 + ...osoft.CodeAnalysis.CSharp.CodeStyle.csproj | 7 +- .../CSharpCodeStyleFixesResources.Designer.cs | 11 +- .../CSharpCodeStyleFixesResources.resx | 5 +- ...CodeAnalysis.CSharp.CodeStyle.Fixes.csproj | 18 +- .../xlf/CSharpCodeStyleFixesResources.cs.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.de.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.es.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.fr.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.it.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.ja.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.ko.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.pl.xlf | 8 +- .../CSharpCodeStyleFixesResources.pt-BR.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.ru.xlf | 8 +- .../xlf/CSharpCodeStyleFixesResources.tr.xlf | 8 +- .../CSharpCodeStyleFixesResources.zh-Hans.xlf | 8 +- .../CSharpCodeStyleFixesResources.zh-Hant.xlf | 8 +- ...Analysis.CSharp.CodeStyle.UnitTests.csproj | 11 +- .../Analyzers/CodeStyleResources.Designer.cs | 130 ++- .../Core/Analyzers/CodeStyleResources.resx | 42 + .../Core/Analyzers/DiagnosticCategory.cs | 11 - .../Core/Analyzers/Formatting/Formatter.cs | 3 +- .../Analyzers/FormattingAnalyzerHelper.cs | 3 +- .../Microsoft.CodeAnalysis.CodeStyle.csproj | 57 +- .../Analyzers/xlf/CodeStyleResources.cs.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.de.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.es.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.fr.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.it.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.ja.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.ko.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.pl.xlf | 70 ++ .../xlf/CodeStyleResources.pt-BR.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.ru.xlf | 70 ++ .../Analyzers/xlf/CodeStyleResources.tr.xlf | 70 ++ .../xlf/CodeStyleResources.zh-Hans.xlf | 70 ++ .../xlf/CodeStyleResources.zh-Hant.xlf | 70 ++ .../Core/Analyzers/xlf/Resource1.cs.xlf | 12 + .../Core/Analyzers/xlf/Resource1.de.xlf | 12 + .../Core/Analyzers/xlf/Resource1.es.xlf | 12 + .../Core/Analyzers/xlf/Resource1.fr.xlf | 12 + .../Core/Analyzers/xlf/Resource1.it.xlf | 12 + .../Core/Analyzers/xlf/Resource1.ja.xlf | 12 + .../Core/Analyzers/xlf/Resource1.ko.xlf | 12 + .../Core/Analyzers/xlf/Resource1.pl.xlf | 12 + .../Core/Analyzers/xlf/Resource1.pt-BR.xlf | 12 + .../Core/Analyzers/xlf/Resource1.ru.xlf | 12 + .../Core/Analyzers/xlf/Resource1.tr.xlf | 12 + .../Core/Analyzers/xlf/Resource1.zh-Hans.xlf | 12 + .../Core/Analyzers/xlf/Resource1.zh-Hant.xlf | 12 + .../CodeStyleFixesResources.Designer.cs | 65 +- .../CodeFixes/CodeStyleFixesResources.resx | 23 +- .../Core/CodeFixes/FormattingCodeFixHelper.cs | 2 +- .../CodeFixes/FormattingCodeFixProvider.cs | 8 +- ...tLanguageServices.MefHostExportProvider.cs | 70 ++ .../Host/Mef/CodeStyleHostLanguageServices.cs | 46 ++ ...ceFactory.SemanticModelWorkspaceService.cs | 24 + ...rosoft.CodeAnalysis.CodeStyle.Fixes.csproj | 3 +- .../xlf/CodeStyleFixesResources.cs.xlf | 38 +- .../xlf/CodeStyleFixesResources.de.xlf | 38 +- .../xlf/CodeStyleFixesResources.es.xlf | 38 +- .../xlf/CodeStyleFixesResources.fr.xlf | 38 +- .../xlf/CodeStyleFixesResources.it.xlf | 38 +- .../xlf/CodeStyleFixesResources.ja.xlf | 38 +- .../xlf/CodeStyleFixesResources.ko.xlf | 38 +- .../xlf/CodeStyleFixesResources.pl.xlf | 38 +- .../xlf/CodeStyleFixesResources.pt-BR.xlf | 38 +- .../xlf/CodeStyleFixesResources.ru.xlf | 38 +- .../xlf/CodeStyleFixesResources.tr.xlf | 38 +- .../xlf/CodeStyleFixesResources.zh-Hans.xlf | 38 +- .../xlf/CodeStyleFixesResources.zh-Hant.xlf | 38 +- ...ft.CodeAnalysis.CodeStyle.UnitTests.csproj | 18 +- src/CodeStyle/Directory.Build.targets | 4 + ....CodeAnalysis.VisualBasic.CodeStyle.vbproj | 5 +- ...nalysis.VisualBasic.CodeStyle.Fixes.vbproj | 18 +- ...sis.VisualBasic.CodeStyle.UnitTests.vbproj | 12 + .../InternalUtilities/EncodingExtensions.cs | 4 +- .../Portable/Serialization/ObjectReader.cs | 2 + .../Portable/Serialization/ObjectWriter.cs | 3 + .../CSharpTest/AddUsing/AddUsingTests.cs | 4 +- .../EncapsulateField/EncapsulateFieldTests.cs | 4 +- .../ExtractLocalFunctionTests.cs | 30 +- .../ExtractMethod/ExtractMethodTests.cs | 32 +- .../OverrideCompletionProviderTests.cs | 4 +- .../SpeculativeTCompletionProviderTests.cs | 6 +- .../SymbolCompletionProviderTests.cs | 10 +- .../GenerateDefaultConstructorsTests.cs | 4 +- .../ImplementInterfaceTests.cs | 10 +- ...sis.CSharp.EditorFeatures.UnitTests.csproj | 2 + .../PullMemberUp/CSharpPullMemberUpTests.cs | 3 +- .../CodeFixes/CodeFixService.cs | 2 +- .../AbstractChangeSignatureTests.cs | 2 +- .../ChangeSignatureTestState.cs | 0 .../AbstractCodeActionOrUserDiagnosticTest.cs | 198 +---- ...ionOrUserDiagnosticTest_TestAddDocument.cs | 153 ++++ .../CodeActions/AbstractCodeActionTest.cs | 5 +- ...agnosticProviderBasedUserDiagnosticTest.cs | 70 +- ...edUserDiagnosticTest_ParenthesesOptions.cs | 66 ++ .../AbstractSuppressionAllCodeTests.cs | 0 .../AbstractSuppressionDiagnosticTest.cs | 0 ...iagnosticTest.FixAllDiagnosticProvider.cs} | 1 - .../Diagnostics/AbstractUserDiagnosticTest.cs | 174 +--- ...ctUserDiagnosticTest_GenerateTypeDialog.cs | 176 ++++ ...deAnalysis.EditorFeatures.UnitTests.csproj | 1 + .../AbstractMoveToNamespaceTests.TestState.cs | 0 .../AbstractMoveToNamespaceTests.cs | 0 .../MoveType/AbstractMoveTypeTest.cs | 0 .../PullMemberUpCodeActionTest.cs | 27 - .../Roslyn.Services.Test.Utilities.csproj | 6 + .../ExtractMethod/ExtractMethodTests.vb | 12 +- .../Diagnostics/AddImport/AddImportTests.vb | 5 +- ...isualBasic.EditorFeatures.UnitTests.vbproj | 4 +- src/EditorFeatures/VisualBasicTest/Utils.vb | 2 + .../CSharpAddImportFeatureService.cs | 10 +- ...tractAssignOutParametersCodeFixProvider.cs | 4 +- .../CSharpDeclareAsNullableCodeFixProvider.cs | 6 +- .../CSharpSuppressionCodeFixProvider.cs | 2 + ...rosoft.CodeAnalysis.CSharp.Features.csproj | 2 + .../CSharpParameterWrapper.cs | 3 +- .../AddRequiredParenthesesCodeFixProvider.cs | 4 +- ...stractAliasAmbiguousTypeCodeFixProvider.cs | 2 +- .../FixAllOccurrences/FixSomeCodeAction.cs | 4 +- ...ppressionCodeFixProvider.FixAllProvider.cs | 2 +- ...rovider.GlobalSuppressMessageCodeAction.cs | 5 +- ...r.GlobalSuppressMessageFixAllCodeAction.cs | 5 +- .../AbstractSuppressionCodeFixProvider.cs | 2 + .../AbstractChangeNamespaceService.cs | 3 +- .../AbstractImportCompletionProvider.cs | 3 +- .../Microsoft.CodeAnalysis.Features.csproj | 3 +- .../PreferFrameworkTypeCodeFixProvider.cs | 2 +- ...stractRemoveUnusedValuesCodeFixProvider.cs | 6 +- .../VisualBasicAddImportFeatureService.vb | 8 +- .../VisualBasicSuppressionCodeFixProvider.vb | 2 + ...t.CodeAnalysis.VisualBasic.Features.vbproj | 2 + ...ualBasicSimplifyThisOrMeCodeFixProvider.vb | 8 +- .../VisualBasicParameterWrapper.vb | 2 +- ...rosoft.CodeAnalysis.InteractiveHost.csproj | 12 +- .../Portable/Roslyn.Test.Utilities.csproj | 8 +- .../Impl/Snippets/SnippetExpansionClient.cs | 4 +- .../CSharpCodeGenerationService.cs | 2 +- .../CodeGeneration/CSharpSyntaxGenerator.cs | 40 +- ...ntaxTokenExtensions_SharedWithCodeStyle.cs | 18 - .../MemberAccessExpressionSyntaxExtensions.cs | 4 +- .../Extensions/SemanticModelExtensions.cs | 456 ----------- .../Rules/TokenBasedFormattingRule.cs | 1 - ...soft.CodeAnalysis.CSharp.Workspaces.csproj | 5 + .../CSharpRenameRewriterLanguageService.cs | 4 +- .../CSharpCompilationFactoryService.cs | 0 ...rpSyntaxTreeFactory.PathSyntaxReference.cs | 0 ...xTreeFactoryService.NullSyntaxReference.cs | 0 ...actoryService.PositionalSyntaxReference.cs | 0 ...reeFactoryService.RecoverableSyntaxTree.cs | 0 .../CSharpSyntaxTreeFactoryService.cs | 0 .../Host/Mef/MSBuildMefHostServices.cs | 2 +- .../Core/Portable/CodeFixes/CodeFix.cs | 1 + .../FixAllOccurrences/BatchFixAllProvider.cs | 9 +- .../FixAllContext.DiagnosticProvider.cs | 33 +- .../FixAllOccurrences/FixAllProvider.cs | 14 - .../Portable/Editing/ImportAdderService.cs | 10 +- .../Extensions/ReportDiagnosticExtensions.cs | 24 - ...bstractDeclaredSymbolInfoFactoryService.cs | 111 +++ .../Microsoft.CodeAnalysis.Workspaces.csproj | 232 +----- ...eFactory.SemanticModelWorkspaceService.cs} | 13 +- .../Shared/Extensions/DocumentExtensions.cs | 155 ---- .../Extensions/IMethodSymbolExtensions.cs | 98 +-- .../Extensions/INamedTypeSymbolExtensions.cs | 584 -------------- .../Extensions/IParameterSymbolExtensions.cs | 14 +- .../Shared/Extensions/ISolutionExtensions.cs | 21 - .../Shared/Extensions/ISymbolExtensions.cs | 749 +---------------- .../Extensions/ITypeSymbolExtensions.cs | 693 ---------------- .../Shared/Extensions/OperationExtensions.cs | 17 - .../Shared/Extensions/ProjectExtensions.cs | 103 +-- .../Extensions/SemanticModelExtensions.cs | 111 +-- .../Core/Portable/Utilities/SpellChecker.cs | 189 ----- .../Workspace/Host/Mef/MefHostServices.cs | 42 +- .../Portable/xlf/WorkspacesResources.cs.xlf | 40 +- .../Portable/xlf/WorkspacesResources.de.xlf | 40 +- .../Portable/xlf/WorkspacesResources.es.xlf | 40 +- .../Portable/xlf/WorkspacesResources.fr.xlf | 40 +- .../Portable/xlf/WorkspacesResources.it.xlf | 40 +- .../Portable/xlf/WorkspacesResources.ja.xlf | 40 +- .../Portable/xlf/WorkspacesResources.ko.xlf | 40 +- .../Portable/xlf/WorkspacesResources.pl.xlf | 40 +- .../xlf/WorkspacesResources.pt-BR.xlf | 40 +- .../Portable/xlf/WorkspacesResources.ru.xlf | 40 +- .../Portable/xlf/WorkspacesResources.tr.xlf | 40 +- .../xlf/WorkspacesResources.zh-Hans.xlf | 40 +- .../xlf/WorkspacesResources.zh-Hant.xlf | 40 +- .../CSharp/CSharpCompilerExtensions.projitems | 21 + .../CSharp/CSharpCompilerExtensions.shproj | 13 + ...clarationSyntaxExtensions_GetAttributes.cs | 0 .../Extensions/SymbolDisplayPartExtensions.cs | 0 .../Extensions/SyntaxKindExtensions.cs | 0 .../Extensions/SyntaxListExtensions.cs | 0 ...yntaxNodeExtensions_SharedWithCodeStyle.cs | 26 + ...ntaxTokenExtensions_SharedWithCodeStyle.cs | 9 +- .../Extensions/SyntaxTriviaExtensions.cs | 1 - .../Extensions/SyntaxTriviaListExtensions.cs | 0 .../AccessibilityModifiersRequired.cs | 0 .../Core/CodeStyle}/AddImportPlacement.cs | 0 .../Core}/CodeStyle/CodeStyleHelpers.cs | 0 .../CodeStyle}/EditorConfigSeverityStrings.cs | 0 .../CodeStyle/ExpressionBodyPreference.cs | 0 ...OperatorPlacementWhenWrappingPreference.cs | 0 .../Core}/CodeStyle/ParenthesesPreference.cs | 0 .../CodeStyle/UnusedParametersPreference.cs | 0 .../Core}/CodeStyle/UnusedValuePreference.cs | 0 .../Core/CompilerExtensions.projitems | 302 +++++++ .../Compiler/Core/CompilerExtensions.shproj | 13 + .../Extensions/AccessibilityUtilities.cs | 0 .../Core}/Extensions/BasicBlockExtensions.cs | 0 .../Extensions/ChildSyntaxListExtensions.cs | 0 .../Extensions/ControlFlowGraphExtensions.cs | 1 - .../Extensions/ControlFlowRegionExtensions.cs | 0 .../DiagnosticSeverityExtensions.cs | 32 + .../Extensions/IAssemblySymbolExtensions.cs | 0 .../Core}/Extensions/ICollectionExtensions.cs | 0 .../Extensions/ICompilationExtensions.cs | 2 +- .../Extensions/IMethodSymbolExtensions.cs | 108 +++ .../Extensions/INamedTypeSymbolExtensions.cs | 596 ++++++++++++++ .../INamespaceOrTypeSymbolExtensions.cs | 0 .../Extensions/IParameterSymbolExtensions.cs | 23 + .../ISymbolExtensions.IsUnsafeVisitor.cs | 0 .../Core/Extensions/ISymbolExtensions.cs | 752 ++++++++++++++++++ .../ISymbolExtensions_Accessibility.cs | 0 ...lExtensions.MinimalAccessibilityVisitor.cs | 0 .../Core/Extensions/ITypeSymbolExtensions.cs | 730 +++++++++++++++++ .../Extensions}/ImmutableArrayExtensions.cs | 0 .../Core}/Extensions/LinkedListExtensions.cs | 0 .../Core}/Extensions/LocationExtensions.cs | 0 .../Core}/Extensions/MethodKindExtensions.cs | 0 .../NotificationOptionExtensions.cs | 2 + .../Extensions/ObjectExtensions.TypeSwitch.cs | 0 .../Core}/Extensions/ObjectExtensions.cs | 0 .../Core}/Extensions/OperationExtensions.cs | 7 + ...ParenthesizedExpressionSyntaxExtensions.cs | 0 .../Extensions/PredefinedTypeExtensions.cs | 0 .../Extensions/ReportDiagnosticExtensions.cs} | 29 +- .../Extensions/SemanticModelExtensions.cs | 123 +++ .../SimpleIntervalTreeExtensions.cs | 0 ...ourceTextExtensions_SharedWithCodeStyle.cs | 0 .../Core}/Extensions/SpecialTypeExtensions.cs | 0 .../Core}/Extensions/StackExtensions.cs | 0 .../Core}/Extensions/StringExtensions.cs | 0 .../Extensions/SymbolDisplayPartExtensions.cs | 0 .../Core}/Extensions/SymbolInfoExtensions.cs | 0 .../Core}/Extensions/SymbolUsageInfo.cs | 0 .../Core}/Extensions/SyntaxNodeExtensions.cs | 0 .../Extensions/SyntaxNodeOrTokenExtensions.cs | 0 .../Core}/Extensions/SyntaxTokenExtensions.cs | 0 .../Extensions/SyntaxTokenListExtensions.cs | 0 ...yntaxTreeExtensions_SharedWithCodeStyle.cs | 0 .../Extensions/SyntaxTriviaExtensions.cs | 0 .../Extensions/SyntaxTriviaListExtensions.cs | 0 .../Core}/Extensions/TextLineExtensions.cs | 0 .../Core}/Extensions/TextSpanExtensions.cs | 0 .../Extensions/TypeOrNamespaceUsageInfo.cs | 0 .../Core}/Extensions/ValueUsageInfo.cs | 0 .../Core}/ObjectPools/ArrayBuilder.cs | 0 .../Compiler/Core}/ObjectPools/Extensions.cs | 0 .../Compiler/Core}/ObjectPools/IPooled.cs | 0 .../Core}/ObjectPools/PooledDisposer.cs | 0 .../Core}/ObjectPools/PooledHashSet.cs | 0 .../Core}/ObjectPools/PooledObject.cs | 0 .../Core}/ObjectPools/PooledStringBuilder.cs | 0 .../Compiler/Core}/ObjectPools/SharedPools.cs | 0 .../Core}/Utilities/AnnotationTable.cs | 0 .../Compiler/Core}/Utilities/AsyncLazy`1.cs | 0 .../Core}/Utilities/BKTree.Builder.cs | 0 .../Compiler/Core}/Utilities/BKTree.Edge.cs | 0 .../Compiler/Core}/Utilities/BKTree.Node.cs | 0 .../Core}/Utilities/BKTree.Serialization.cs | 0 .../Compiler/Core}/Utilities/BKTree.cs | 2 +- .../Core}/Utilities/BidirectionalMap.cs | 0 .../Core}/Utilities/CancellableLazy.cs | 0 .../Core}/Utilities/CancellableLazy`1.cs | 0 .../Core}/Utilities/ComparerWithState.cs | 0 .../CompilerPathUtilities.cs | 8 +- .../ImmutableDictionaryExtensions.cs | 0 .../CompilerUtilities/ImmutableHashMap.cs | 9 +- .../ImmutableHashMapExtensions.cs | 0 .../Core}/Utilities/ConcatImmutableArray`1.cs | 0 .../Compiler/Core}/Utilities/Contract.cs | 0 .../Compiler/Core}/Utilities/EditDistance.cs | 2 +- .../Compiler/Core}/Utilities/EventMap.cs | 0 .../Core}/Utilities/IBidirectionalMap.cs | 0 .../Compiler/Core}/Utilities/ICacheEntry.cs | 0 .../Core}/Utilities/ICollectionExtensions.cs | 0 .../Core}/Utilities/IDictionaryExtensions.cs | 0 .../Core}/Utilities/IGroupingExtensions.cs | 0 .../IReadOnlyDictionaryExtensions.cs | 0 .../Utilities/IReadOnlyListExtensions.cs | 0 .../Utilities/IReferenceCountedDisposable.cs | 0 .../Core}/Utilities/LazyInitialization.cs | 0 .../Core}/Utilities/NonReentrantLock.cs | 0 .../Utilities/PooledBuilderExtensions.cs | 0 .../Core/Utilities}/PredefinedOperator.cs | 0 .../Core/Utilities}/PredefinedType.cs | 0 .../Utilities/ReferenceCountedDisposable.cs | 0 .../ReferenceCountedDisposableCache.cs | 0 .../RestrictedInternalsVisibleToAttribute.cs | 0 .../Core}/Utilities/SemaphoreSlimFactory.cs | 0 .../Core}/Utilities/SerializableBytes.cs | 0 .../Core}/Utilities/SimpleTaskQueue.cs | 0 .../Core}/Utilities/SoftCrashException.cs | 0 .../Core}/Utilities/SpecializedTasks.cs | 0 .../Core}/Utilities/StringEscapeEncoder.cs | 0 .../Compiler/Core}/Utilities/StringSlice.cs | 0 .../Core/Utilities}/SymbolDisplayFormats.cs | 0 ...olEquivalenceComparer.AssemblyComparers.cs | 0 ...lEquivalenceComparer.EquivalenceVisitor.cs | 5 +- ...lEquivalenceComparer.GetHashCodeVisitor.cs | 0 ...omparer.ParameterSymbolEqualityComparer.cs | 0 ....SignatureTypeSymbolEquivalenceComparer.cs | 0 .../Utilities/SymbolEquivalenceComparer.cs | 0 .../Core}/Utilities/SymbolVisibility.cs | 0 .../Compiler/Core}/Utilities/SyntaxPath.cs | 0 .../Core}/Utilities/TaskExtensions.cs | 0 .../Core}/Utilities/TaskFactoryExtensions.cs | 0 .../Core}/Utilities/TopologicalSorter.cs | 0 .../ValuesSources/ConstantValueSource.cs | 0 .../Utilities/ValuesSources/ValueSource.cs | 0 .../ValuesSources/WeakValueSource.cs | 0 .../WeaklyCachedRecoverableValueSource.cs | 0 .../ValuesSources/WeaklyCachedValueSource.cs | 0 .../Compiler/Core}/Utilities/VoidResult.cs | 0 .../Core}/Utilities/WeakEventHandler.cs | 0 .../Core/Utilities/WordSimilarityChecker.cs | 199 +++++ ...ntaxTokenExtensions_SharedWithCodeStyle.vb | 0 ...yntaxTreeExtensions_SharedWithCodeStyle.vb | 2 +- .../Extensions/SyntaxTriviaExtensions.vb | 0 .../VisualBasicCompilerExtensions.projitems | 24 + .../VisualBasicCompilerExtensions.shproj | 13 + .../CSharpWorkspaceExtensions.projitems | 85 ++ .../CSharp/CSharpWorkspaceExtensions.shproj | 13 + .../Extensions/ArgumentSyntaxExtensions.cs | 0 .../ArrowExpressionClauseSyntaxExtensions.cs | 0 .../AssignmentExpressionSyntaxExtensions.cs | 0 .../AttributeArgumentSyntaxExtensions.cs | 0 .../BaseArgumentListSyntaxExtensions.cs | 0 ...BasePropertyDeclarationSyntaxExtensions.cs | 0 .../Extensions/BlockSyntaxExtensions.cs | 0 .../CastExpressionSyntaxExtensions.cs | 0 .../CompilationUnitSyntaxExtensions.cs | 0 .../ContextQuery/CSharpSyntaxContext.cs | 0 .../ContextQuery/SyntaxNodeExtensions.cs | 0 .../ContextQuery/SyntaxTokenExtensions.cs | 0 .../ContextQuery/SyntaxTreeExtensions.cs | 2 +- .../Extensions/ConversionExtensions.cs | 0 ...DirectiveSyntaxExtensions.DirectiveInfo.cs | 0 ...ensions.DirectiveSyntaxEqualityComparer.cs | 0 ...rectiveSyntaxExtensions.DirectiveWalker.cs | 0 .../Extensions/DirectiveSyntaxExtensions.cs | 0 .../DocumentationCommentExtensions.cs | 0 .../Extensions/ExpressionSyntaxExtensions.cs | 2 + .../ForEachStatementSyntaxExtensions.cs | 0 .../Extensions/ILocalSymbolExtensions.cs | 0 .../ITypeParameterSymbolExtensions.cs | 0 ...nsions.ExpressionSyntaxGeneratorVisitor.cs | 0 ...olExtensions.TypeSyntaxGeneratorVisitor.cs | 8 +- .../Extensions/ITypeSymbolExtensions.cs | 0 ...ationSyntaxExtensions.DeclarationFinder.cs | 0 ...ionSyntaxExtensions.LocalDeclarationMap.cs | 0 .../MemberDeclarationSyntaxExtensions.cs | 0 .../Extensions/NameSyntaxExtensions.cs | 0 .../NamespaceDeclarationSyntaxExtensions.cs | 0 .../CSharp}/Extensions/OperatorPrecedence.cs | 0 ...ParenthesizedExpressionSyntaxExtensions.cs | 0 .../QueryExpressionSyntaxExtensions.cs | 0 .../Extensions/SemanticModelExtensions.cs | 477 +++++++++++ .../SeparatedSyntaxListExtensions.cs | 0 .../Extensions/SimpleNameSyntaxExtensions.cs | 0 .../Extensions/StatementSyntaxExtensions.cs | 0 .../CSharp}/Extensions/StringExtensions.cs | 0 ...SyntaxNodeExtensions.SingleLineRewriter.cs | 0 .../Extensions/SyntaxNodeExtensions.cs | 0 .../Extensions/SyntaxTokenExtensions.cs | 0 .../Extensions/SyntaxTokenListExtensions.cs | 0 .../Extensions/SyntaxTreeExtensions.cs | 8 +- .../TypeDeclarationSyntaxExtensions.cs | 0 .../Extensions/TypeSyntaxExtensions.cs | 0 .../UsingDirectiveSyntaxExtensions.cs | 0 .../VariableDeclaratorExtensions.cs | 0 .../CSharpAddImportsService.cs | 4 +- .../CSharpCommandLineParserService.cs | 0 .../CSharpDocumentationCommentService.cs | 0 .../CSharpGeneratedCodeRecognitionService.cs | 0 .../CSharpPrecedenceService.cs | 0 .../CSharpSemanticFactsService.cs | 0 .../CSharpSemanticFactsServiceFactory.cs | 0 .../CSharpSymbolDeclarationService.cs | 0 .../CSharpSyntaxFactsService.cs | 5 +- .../CSharpSyntaxFactsServiceFactory.cs | 0 .../CSharpSyntaxKindsService.cs | 0 .../CSharpSyntaxKindsServiceFactory.cs | 0 ...CSharpTypeInferenceService.TypeInferrer.cs | 19 +- .../CSharpTypeInferenceService.cs | 0 .../Utilities/CSharpSimplificationHelpers.cs | 87 ++ .../CSharp}/Utilities/NameSyntaxComparer.cs | 0 .../CSharp}/Utilities/NameSyntaxIterator.cs | 0 .../NullableHelpers/NullableExtensions.cs | 12 +- .../CSharp}/Utilities/SpeculationAnalyzer.cs | 0 .../CSharp}/Utilities/SyntaxKindSet.cs | 0 .../CSharp}/Utilities/TokenComparer.cs | 0 .../CSharp}/Utilities/TypeSyntaxComparer.cs | 0 ...UsingsAndExternAliasesDirectiveComparer.cs | 0 .../UsingsAndExternAliasesOrganizer.cs | 0 .../Core}/CodeFixes/CodeFixCategory.cs | 0 .../Core/CodeFixes/CustomCodeActions.cs | 62 ++ .../CodeFixes/DocumentBasedFixAllProvider.cs | 54 +- ...xAllState.FixMultipleDiagnosticProvider.cs | 36 +- .../Core/CodeFixes/FixAll}/FixAllState.cs | 52 +- .../Core/CodeFixes/FixAllContextHelper.cs | 56 +- ...itorBasedCodeFixProvider.FixAllProvider.cs | 42 +- .../SyntaxEditorBasedCodeFixProvider.cs | 4 +- .../Extensions/ContextQuery/SyntaxContext.cs | 4 +- .../Core/Extensions/DocumentExtensions.cs | 189 +++++ .../HostWorkspaceServicesExtensions.cs | 32 + .../Core/Extensions/ISolutionExtensions.cs | 34 + .../ITypeInferenceServiceExtensions.cs | 0 .../Core/Extensions/ProjectExtensions.cs | 136 ++++ .../Extensions/SyntaxEditorExtensions.cs | 0 .../Core}/Extensions/SyntaxTreeExtensions.cs | 0 .../Extensions/TextDocumentExtensions.cs | 0 .../Core/Helpers/MefHostServicesHelpers.cs | 55 ++ .../AddImports/AbstractAddImportsService.cs | 15 +- .../AddImports/AddImportHelpers.cs | 0 .../AddImports/IAddImportsService.cs | 10 +- .../CommandLine/ICommandLineParserService.cs | 0 ...AbstractGeneratedCodeRecognitionService.cs | 13 + .../IGeneratedCodeRecognitionService.cs | 5 + .../Precedence/IPrecedenceService.cs | 0 .../Precedence/PrecedenceKind.cs | 0 .../AbstractSemanticFactsService.cs | 1 - .../SemanticsFactsService/ForEachSymbols.cs | 0 .../ISemanticFactsService.cs | 0 .../Simplification/AliasAnnotation.cs | 0 .../DoNotAddImportsAnnotation.cs | 0 .../Simplification/DoNotAllowVarAnnotation.cs | 0 .../Simplification/SimplificationHelpers.cs | 3 +- .../Simplification/SpecialTypeAnnotation.cs | 0 .../Simplification/SymbolAnnotation.cs | 0 .../ISymbolDeclarationService.cs | 1 - .../AbstractDocumentationCommentService.cs | 0 .../AbstractSyntaxFactsService.cs | 92 --- .../SyntaxFactsService/ExternalSourceInfo.cs | 0 .../IDocumentationCommentService.cs | 0 .../SyntaxFactsService/ISyntaxFactsService.cs | 0 .../ISyntaxFactsServiceExtensions.cs | 0 .../SyntaxFactsService/ISyntaxKindsService.cs | 0 ...peInferenceService.AbstractTypeInferrer.cs | 6 +- .../AbstractTypeInferenceService.cs | 0 .../ITypeInferenceService.cs | 0 .../Core}/Log/AbstractLogAggregator.cs | 0 .../Workspace/Core}/Log/LogAggregator.cs | 0 .../Annotations/RenameActionAnnotation.cs | 0 .../Rename}/Annotations/RenameAnnotation.cs | 0 .../RenameDeclarationLocationReference.cs | 0 .../RenameInvalidIdentifierAnnotation.cs | 0 .../RenameNodeSimplificationAnnotation.cs | 0 .../RenameTokenSimplificationAnnotation.cs | 0 .../Utilities/AbstractSpeculationAnalyzer.cs | 0 .../Core}/Utilities/Matcher.ChoiceMatcher.cs | 0 .../Core}/Utilities/Matcher.RepeatMatcher.cs | 0 .../Utilities/Matcher.SequenceMatcher.cs | 0 .../Core}/Utilities/Matcher.SingleMatcher.cs | 0 .../Workspace/Core}/Utilities/Matcher.cs | 0 .../Workspace/Core}/Utilities/Matcher`1.cs | 0 .../Core}/Utilities/NameGenerator.cs | 0 .../Core/Utilities}/SemanticDocument.cs | 0 .../Core/Utilities}/SyntacticDocument.cs | 0 .../Core}/Utilities/TextReaderWithLength.cs | 0 .../Mef/CodeChangeProviderMetadata.cs | 0 .../Workspace}/Mef/FileExtensionsMetadata.cs | 0 .../Core/Workspace}/Mef/ILanguageMetadata.cs | 0 .../Core/Workspace}/Mef/ILanguagesMetadata.cs | 0 .../Workspace}/Mef/IMefHostExportProvider.cs | 0 .../Core/Workspace}/Mef/LanguageMetadata.cs | 0 .../Workspace}/Mef/LanguageServiceMetadata.cs | 0 .../Workspace}/Mef/MefLanguageServices.cs | 0 .../Workspace}/Mef/MefWorkspaceServices.cs | 5 +- .../Mef/OrderableLanguageMetadata.cs | 0 .../Core/Workspace/Mef}/OrderableMetadata.cs | 0 .../Workspace}/Mef/WorkspaceKindMetadata.cs | 0 .../Mef/WorkspaceServiceMetadata.cs | 0 .../Core/WorkspaceExtensions.projitems | 96 +++ .../Workspace/Core/WorkspaceExtensions.shproj | 12 + .../ISemanticModelService.cs | 0 .../SemanticModelWorkspaceServiceFactory.cs | 26 + .../ArgumentListSyntaxExtensions.vb | 0 .../Extensions/ArgumentSyntaxExtensions.vb | 0 .../CallStatementSyntaxExtensions.vb | 0 .../VisualBasic}/Extensions/CastAnalyzer.vb | 0 .../CastExpressionSyntaxExtensions.vb | 0 .../CompilationUnitSyntaxExtensions.vb | 0 .../IsStatementTerminatingTokenVisitor.vb | 0 .../ContextQuery/SyntaxTokenExtensions.vb | 0 .../ContextQuery/SyntaxTreeExtensions.vb | 0 .../ContextQuery/VisualBasicSyntaxContext.vb | 1 + .../VisualBasicSyntaxContextExtensions.vb | 0 .../Extensions/DirectiveSyntaxExtensions.vb | 0 .../Extensions/ExpressionSyntaxExtensions.vb | 1 + .../ExpressionSyntaxGeneratorVisitor.vb | 0 .../Extensions/IMethodSymbolExtensions.vb | 0 .../INamespaceOrTypeSymbolExtensions.vb | 0 .../Extensions/ITypeSymbolExtensions.vb | 0 .../InvocationExpressionSyntaxExtensions.vb | 0 .../MemberAccessExpressionSyntaxExtensions.vb | 7 +- .../Extensions/NameSyntaxExtensions.vb | 0 .../ObjectCreationExpressionExtensions.vb | 0 .../Extensions/OperatorPrecedence.vb | 3 - .../Extensions/ParameterSyntaxExtensions.vb | 0 ...ParenthesizedExpressionSyntaxExtensions.vb | 0 .../Extensions/SemanticModelExtensions.vb | 285 +++++++ .../Extensions/SimpleNameSyntaxExtensions.vb | 0 .../Extensions/SingleLineRewriter.vb | 0 .../Extensions/StatementSyntaxExtensions.vb | 0 .../Extensions/StringExtensions.vb | 0 .../Extensions/SymbolDisplayPartExtensions.vb | 0 .../Extensions/SymbolExtensions.vb | 0 .../Extensions/SyntaxKindExtensions.vb | 0 .../Extensions/SyntaxListExtensions.vb | 0 .../Extensions/SyntaxNodeExtensions.vb | 110 +++ .../Extensions/SyntaxTokenExtensions.vb | 0 .../Extensions/SyntaxTreeExtensions.vb | 0 .../Extensions/SyntaxTriviaListExtensions.vb | 0 .../Extensions/TypeBlockSyntaxExtensions.vb | 0 .../Extensions/TypeSyntaxGeneratorVisitor.vb | 0 .../VariableDeclaratorSyntaxExtensions.vb | 0 .../VisualBasicAddImportsService.vb | 4 +- .../VisualBasicCommandLineParserService.vb | 0 .../VisualBasicDocumentationCommentService.vb | 0 ...ualBasicGeneratedCodeRecognitionService.vb | 0 .../VisualBasicPrecedenceService.vb | 1 + .../VisualBasicSemanticFactsService.vb | 2 + .../VisualBasicSymbolDeclarationService.vb | 0 .../VisualBasicSyntaxFactsService.vb | 4 +- .../VisualBasicSyntaxFactsServiceFactory.vb | 0 .../VisualBasicSyntaxKindsService.vb | 0 .../VisualBasicSyntaxKindsServiceFactory.vb | 0 ...lBasicTypeInferenceService.TypeInferrer.vb | 0 .../VisualBasicTypeInferenceService.vb | 0 .../DirectiveSyntaxEqualityComparer.vb | 0 .../VisualBasic}/Utilities/DirectiveWalker.vb | 0 .../Utilities/ImportsClauseComparer.vb | 0 .../Utilities/ImportsOrganizer.vb | 0 .../Utilities/ImportsStatementComparer.vb | 0 .../Utilities/ModifierCollectionFacts.vb | 0 .../Utilities/NameSyntaxComparer.vb | 0 .../Utilities/NameSyntaxIterator.vb | 0 .../Utilities/PossibleDeclarationTypes.vb | 0 .../Utilities/SpeculationAnalyzer.vb | 6 +- .../Utilities/SymbolExtensions.vb | 0 .../VisualBasic}/Utilities/SyntaxKindSet.vb | 0 .../VisualBasic}/Utilities/TokenComparer.vb | 0 .../Utilities/TypeSyntaxComparer.vb | 0 .../VisualBasicSimplificationHelpers.vb | 33 + .../VisualBasicWorkspaceExtensions.projitems | 89 +++ .../VisualBasicWorkspaceExtensions.shproj | 13 + .../VisualBasicSyntaxGenerator.vb | 116 +-- .../Extensions/SemanticModelExtensions.vb | 270 +------ .../Formatting/DefaultOperationProvider.vb | 1 - .../TriviaDataFactory.TriviaRewriter.vb | 10 - .../Trivia/VisualBasicTriviaFormatter.vb | 6 - ...CodeAnalysis.VisualBasic.Workspaces.vbproj | 11 +- ...isualBasicRenameRewriterLanguageService.vb | 4 +- .../Simplifiers/ExpressionSimplifier.vb | 6 +- .../Simplifiers/NameSimplifier.vb | 10 +- ...sualBasicSimplificationService.Expander.vb | 12 +- .../VisualBasicSimplificationService.vb | 25 +- .../VisualBasicCompilationFactoryService.vb | 0 ...xTreeFactoryService.NullSyntaxReference.vb | 0 ...xTreeFactoryService.PathSyntaxReference.vb | 0 ...actoryService.PositionalSyntaxReference.vb | 0 ...reeFactoryService.RecoverableSyntaxTree.vb | 0 .../VisualBasicSyntaxTreeFactoryService.vb | 0 616 files changed, 8618 insertions(+), 5330 deletions(-) create mode 100644 src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems create mode 100644 src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.shproj rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs (100%) create mode 100644 src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems create mode 100644 src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.shproj rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/RemoveUnusedMembers/CSharpRemoveUnusedMembersCodeFixProvider.cs (100%) create mode 100644 src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems create mode 100644 src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.shproj rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/RemoveUnusedMembers/RemoveUnusedMembersTests.cs (99%) rename src/{Features/Core/Portable/CodeStyle => Analyzers/Core/Analyzers}/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs (98%) rename src/{Features/Core/Portable/CodeQuality => Analyzers/Core/Analyzers}/AbstractCodeQualityDiagnosticAnalyzer.cs (95%) rename src/{CodeStyle => Analyzers}/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs (100%) create mode 100644 src/Analyzers/Core/Analyzers/Analyzers.projitems create mode 100644 src/Analyzers/Core/Analyzers/Analyzers.shproj rename src/{Features/Core/Portable/Diagnostics => Analyzers/Core/Analyzers}/DiagnosticAnalyzerCategory.cs (100%) rename src/{Features/Core/Portable/Diagnostics => Analyzers/Core/Analyzers}/DiagnosticCategory.cs (100%) rename src/{Features/Core/Portable/Diagnostics => Analyzers/Core/Analyzers}/DiagnosticCustomTags.cs (100%) rename src/{Features/Core/Portable/Shared/Utilities => Analyzers/Core/Analyzers/Helpers}/DeserializationConstructorCheck.cs (100%) rename src/{Features/Core/Portable/Diagnostics => Analyzers/Core/Analyzers/Helpers}/DiagnosticHelper.cs (98%) rename src/{Features/Core/Portable/Diagnostics => Analyzers/Core/Analyzers}/IBuiltInAnalyzer.cs (92%) rename src/{Features/Core/Portable/Diagnostics => Analyzers/Core}/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs (100%) rename src/{Features/Core/Portable/Diagnostics => Analyzers/Core}/Analyzers/IDEDiagnosticIds.cs (100%) rename src/{Features/Core/Portable => Analyzers/Core/Analyzers}/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (97%) create mode 100644 src/Analyzers/Core/CodeFixes/CodeFixes.projitems create mode 100644 src/Analyzers/Core/CodeFixes/CodeFixes.shproj rename src/{Features/Core/Portable => Analyzers/Core}/CodeFixes/PredefinedCodeFixProviderNames.cs (100%) rename src/{Features/Core/Portable => Analyzers/Core/CodeFixes}/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs (95%) create mode 100644 src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems create mode 100644 src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/Analyzers}/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb (100%) create mode 100644 src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems create mode 100644 src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.shproj rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/CodeFixes}/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersCodeFixProvider.vb (100%) create mode 100644 src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems create mode 100644 src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.shproj rename src/{EditorFeatures/VisualBasicTest => Analyzers/VisualBasic/Tests}/RemoveUnusedMembers/RemoveUnusedMembersTests.vb (100%) create mode 100644 src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems create mode 100644 src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.shproj create mode 100644 src/CodeStyle/BannedSymbols.txt delete mode 100644 src/CodeStyle/Core/Analyzers/DiagnosticCategory.cs create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hans.xlf create mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hant.xlf create mode 100644 src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.MefHostExportProvider.cs create mode 100644 src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.cs create mode 100644 src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs rename src/EditorFeatures/{TestUtilities => Test}/ChangeSignature/AbstractChangeSignatureTests.cs (99%) rename src/EditorFeatures/{TestUtilities => Test}/ChangeSignature/ChangeSignatureTestState.cs (100%) rename src/EditorFeatures/{TestUtilities => Test}/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs (78%) create mode 100644 src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs rename src/EditorFeatures/{TestUtilities => Test}/CodeActions/AbstractCodeActionTest.cs (97%) rename src/EditorFeatures/{TestUtilities => Test}/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs (75%) create mode 100644 src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs rename src/EditorFeatures/{TestUtilities => Test}/Diagnostics/AbstractSuppressionAllCodeTests.cs (100%) rename src/EditorFeatures/{TestUtilities => Test}/Diagnostics/AbstractSuppressionDiagnosticTest.cs (100%) rename src/EditorFeatures/{TestUtilities/Diagnostics/FixAllDiagnosticProvider.cs => Test/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs} (98%) rename src/EditorFeatures/{TestUtilities => Test}/Diagnostics/AbstractUserDiagnosticTest.cs (61%) create mode 100644 src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs rename src/EditorFeatures/{TestUtilities => Test}/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs (100%) rename src/EditorFeatures/{TestUtilities => Test}/MoveToNamespace/AbstractMoveToNamespaceTests.cs (100%) rename src/EditorFeatures/{TestUtilities => Test}/MoveType/AbstractMoveTypeTest.cs (100%) delete mode 100644 src/EditorFeatures/TestUtilities/PullMemberUp/PullMemberUpCodeActionTest.cs delete mode 100644 src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTokenExtensions_SharedWithCodeStyle.cs rename src/Workspaces/CSharp/Portable/{ => Workspace}/LanguageServices/CSharpCompilationFactoryService.cs (100%) rename src/Workspaces/CSharp/Portable/{ => Workspace}/LanguageServices/CSharpSyntaxTreeFactory.PathSyntaxReference.cs (100%) rename src/Workspaces/CSharp/Portable/{ => Workspace}/LanguageServices/CSharpSyntaxTreeFactoryService.NullSyntaxReference.cs (100%) rename src/Workspaces/CSharp/Portable/{ => Workspace}/LanguageServices/CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.cs (100%) rename src/Workspaces/CSharp/Portable/{ => Workspace}/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs (100%) rename src/Workspaces/CSharp/Portable/{ => Workspace}/LanguageServices/CSharpSyntaxTreeFactoryService.cs (100%) delete mode 100644 src/Workspaces/Core/Portable/Extensions/ReportDiagnosticExtensions.cs create mode 100644 src/Workspaces/Core/Portable/LanguageServices/DeclaredSymbolFactoryService/AbstractDeclaredSymbolInfoFactoryService.cs rename src/Workspaces/Core/Portable/SemanticModelWorkspaceService/{SemanticModelWorkspaceServiceFactory.cs => SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs} (98%) delete mode 100644 src/Workspaces/Core/Portable/Shared/Extensions/OperationExtensions.cs create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.shproj rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/Extensions/MemberDeclarationSyntaxExtensions_GetAttributes.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/Extensions/SymbolDisplayPartExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/Extensions/SyntaxKindExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/Extensions/SyntaxListExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs (84%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs (88%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/Extensions/SyntaxTriviaExtensions.cs (99%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/Extensions/SyntaxTriviaListExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/CodeStyle/AccessibilityModifiersRequired.cs (100%) rename src/Workspaces/{Core/Portable/AddImports => SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle}/AddImportPlacement.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/CodeStyle/CodeStyleHelpers.cs (100%) rename src/Workspaces/{Core/Portable/NamingStyles/EditorConfig => SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle}/EditorConfigSeverityStrings.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/CodeStyle/ExpressionBodyPreference.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/CodeStyle/OperatorPlacementWhenWrappingPreference.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/CodeStyle/ParenthesesPreference.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/CodeStyle/UnusedParametersPreference.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/CodeStyle/UnusedValuePreference.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.shproj rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/AccessibilityUtilities.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/BasicBlockExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ChildSyntaxListExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ControlFlowGraphExtensions.cs (96%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ControlFlowRegionExtensions.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/DiagnosticSeverityExtensions.cs rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/IAssemblySymbolExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ICollectionExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ICompilationExtensions.cs (98%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IMethodSymbolExtensions.cs create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/INamedTypeSymbolExtensions.cs rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/INamespaceOrTypeSymbolExtensions.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IParameterSymbolExtensions.cs rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ISymbolExtensions.IsUnsafeVisitor.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ISymbolExtensions_Accessibility.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ITypeSymbolExtensions.MinimalAccessibilityVisitor.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.cs rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core/Extensions}/ImmutableArrayExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/LinkedListExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/LocationExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/MethodKindExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/NotificationOptionExtensions.cs (91%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ObjectExtensions.TypeSwitch.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ObjectExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/OperationExtensions.cs (97%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ParenthesizedExpressionSyntaxExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/PredefinedTypeExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Diagnostics/Extensions_SharedWithCodeStyle.cs => SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ReportDiagnosticExtensions.cs} (72%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SemanticModelExtensions.cs rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SimpleIntervalTreeExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SourceTextExtensions_SharedWithCodeStyle.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SpecialTypeExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/StackExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/StringExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SymbolDisplayPartExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SymbolInfoExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SymbolUsageInfo.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SyntaxNodeExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SyntaxNodeOrTokenExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SyntaxTokenExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SyntaxTokenListExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SyntaxTriviaExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/SyntaxTriviaListExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/TextLineExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/TextSpanExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/TypeOrNamespaceUsageInfo.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Extensions/ValueUsageInfo.cs (100%) rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core}/ObjectPools/ArrayBuilder.cs (100%) rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core}/ObjectPools/Extensions.cs (100%) rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core}/ObjectPools/IPooled.cs (100%) rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core}/ObjectPools/PooledDisposer.cs (100%) rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core}/ObjectPools/PooledHashSet.cs (100%) rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core}/ObjectPools/PooledObject.cs (100%) rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core}/ObjectPools/PooledStringBuilder.cs (100%) rename src/Workspaces/{Core/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/Core}/ObjectPools/SharedPools.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/AnnotationTable.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/AsyncLazy`1.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/BKTree.Builder.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/BKTree.Edge.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/BKTree.Node.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/BKTree.Serialization.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/BKTree.cs (99%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/BidirectionalMap.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/CancellableLazy.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/CancellableLazy`1.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ComparerWithState.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/CompilerUtilities/CompilerPathUtilities.cs (75%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/CompilerUtilities/ImmutableDictionaryExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/CompilerUtilities/ImmutableHashMap.cs (99%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/CompilerUtilities/ImmutableHashMapExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ConcatImmutableArray`1.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/Contract.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/EditDistance.cs (99%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/EventMap.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/IBidirectionalMap.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ICacheEntry.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ICollectionExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/IDictionaryExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/IGroupingExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/IReadOnlyDictionaryExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/IReadOnlyListExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/IReferenceCountedDisposable.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/LazyInitialization.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/NonReentrantLock.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/PooledBuilderExtensions.cs (100%) rename src/Workspaces/{Core/Portable/LanguageServices/SyntaxFactsService => SharedUtilitiesAndExtensions/Compiler/Core/Utilities}/PredefinedOperator.cs (100%) rename src/Workspaces/{Core/Portable/LanguageServices/SyntaxFactsService => SharedUtilitiesAndExtensions/Compiler/Core/Utilities}/PredefinedType.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ReferenceCountedDisposable.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ReferenceCountedDisposableCache.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/RestrictedInternalsVisibleToAttribute.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SemaphoreSlimFactory.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SerializableBytes.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SimpleTaskQueue.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SoftCrashException.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SpecializedTasks.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/StringEscapeEncoder.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/StringSlice.cs (100%) rename src/Workspaces/{Core/Portable/Shared/Extensions => SharedUtilitiesAndExtensions/Compiler/Core/Utilities}/SymbolDisplayFormats.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SymbolEquivalenceComparer.AssemblyComparers.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SymbolEquivalenceComparer.EquivalenceVisitor.cs (99%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SymbolEquivalenceComparer.GetHashCodeVisitor.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SymbolEquivalenceComparer.ParameterSymbolEqualityComparer.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SymbolEquivalenceComparer.SignatureTypeSymbolEquivalenceComparer.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SymbolEquivalenceComparer.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SymbolVisibility.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/SyntaxPath.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/TaskExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/TaskFactoryExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/TopologicalSorter.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ValuesSources/ConstantValueSource.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ValuesSources/ValueSource.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ValuesSources/WeakValueSource.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ValuesSources/WeaklyCachedRecoverableValueSource.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/ValuesSources/WeaklyCachedValueSource.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/VoidResult.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Compiler/Core}/Utilities/WeakEventHandler.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/WordSimilarityChecker.cs rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Compiler/VisualBasic}/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Compiler/VisualBasic}/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.vb (99%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Compiler/VisualBasic}/Extensions/SyntaxTriviaExtensions.vb (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.shproj create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.shproj rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ArgumentSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ArrowExpressionClauseSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/AssignmentExpressionSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/AttributeArgumentSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/BaseArgumentListSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/BasePropertyDeclarationSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/BlockSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/CastExpressionSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/CompilationUnitSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ContextQuery/CSharpSyntaxContext.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ContextQuery/SyntaxNodeExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ContextQuery/SyntaxTokenExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ContextQuery/SyntaxTreeExtensions.cs (99%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ConversionExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/DirectiveSyntaxExtensions.DirectiveInfo.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/DirectiveSyntaxExtensions.DirectiveSyntaxEqualityComparer.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/DirectiveSyntaxExtensions.DirectiveWalker.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/DirectiveSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/DocumentationCommentExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ExpressionSyntaxExtensions.cs (99%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ForEachStatementSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ILocalSymbolExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ITypeParameterSymbolExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ITypeSymbolExtensions.ExpressionSyntaxGeneratorVisitor.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs (97%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ITypeSymbolExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/MemberDeclarationSyntaxExtensions.DeclarationFinder.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/MemberDeclarationSyntaxExtensions.LocalDeclarationMap.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/MemberDeclarationSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/NameSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/NamespaceDeclarationSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/OperatorPrecedence.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/ParenthesizedExpressionSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/QueryExpressionSyntaxExtensions.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SemanticModelExtensions.cs rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/SeparatedSyntaxListExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/SimpleNameSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/StatementSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/StringExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/SyntaxNodeExtensions.SingleLineRewriter.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/SyntaxNodeExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/SyntaxTokenExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/SyntaxTokenListExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/SyntaxTreeExtensions.cs (99%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/TypeDeclarationSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/TypeSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/UsingDirectiveSyntaxExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Extensions/VariableDeclaratorExtensions.cs (100%) rename src/Workspaces/{CSharp/Portable/AddImports => SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices}/CSharpAddImportsService.cs (98%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpCommandLineParserService.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpDocumentationCommentService.cs (100%) rename src/Workspaces/{CSharp/Portable/GeneratedCodeRecognition => SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices}/CSharpGeneratedCodeRecognitionService.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpPrecedenceService.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpSemanticFactsService.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpSemanticFactsServiceFactory.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpSymbolDeclarationService.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpSyntaxFactsService.cs (99%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpSyntaxFactsServiceFactory.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpSyntaxKindsService.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpSyntaxKindsServiceFactory.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs (99%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/LanguageServices/CSharpTypeInferenceService.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/CSharpSimplificationHelpers.cs rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/NameSyntaxComparer.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/NameSyntaxIterator.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/NullableHelpers/NullableExtensions.cs (55%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/SpeculationAnalyzer.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/SyntaxKindSet.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/TokenComparer.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/TypeSyntaxComparer.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/UsingsAndExternAliasesDirectiveComparer.cs (100%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Workspace/CSharp}/Utilities/UsingsAndExternAliasesOrganizer.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/CodeFixes/CodeFixCategory.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CustomCodeActions.cs rename src/{CodeStyle => Workspaces/SharedUtilitiesAndExtensions/Workspace}/Core/CodeFixes/DocumentBasedFixAllProvider.cs (68%) rename src/Workspaces/{Core/Portable/CodeFixes/FixAllOccurrences => SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll}/FixAllState.FixMultipleDiagnosticProvider.cs (64%) rename src/Workspaces/{Core/Portable/CodeFixes/FixAllOccurrences => SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll}/FixAllState.cs (77%) rename src/{CodeStyle => Workspaces/SharedUtilitiesAndExtensions/Workspace}/Core/CodeFixes/FixAllContextHelper.cs (73%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs (64%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs (94%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Extensions/ContextQuery/SyntaxContext.cs (96%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/HostWorkspaceServicesExtensions.cs create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Extensions/ITypeInferenceServiceExtensions.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ProjectExtensions.cs rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Extensions/SyntaxEditorExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Extensions/SyntaxTreeExtensions.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Extensions/TextDocumentExtensions.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Helpers/MefHostServicesHelpers.cs rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/AddImports/AbstractAddImportsService.cs (94%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/AddImports/AddImportHelpers.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/AddImports/IAddImportsService.cs (75%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/CommandLine/ICommandLineParserService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/GeneratedCodeRecognition/AbstractGeneratedCodeRecognitionService.cs (72%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/GeneratedCodeRecognition/IGeneratedCodeRecognitionService.cs (76%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/Precedence/IPrecedenceService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/Precedence/PrecedenceKind.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs (99%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SemanticsFactsService/ForEachSymbols.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SemanticsFactsService/ISemanticFactsService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/Simplification/AliasAnnotation.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/Simplification/DoNotAddImportsAnnotation.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/Simplification/DoNotAllowVarAnnotation.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/Simplification/SimplificationHelpers.cs (99%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/Simplification/SpecialTypeAnnotation.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/Simplification/SymbolAnnotation.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SymbolDeclarationService/ISymbolDeclarationService.cs (95%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SyntaxFactsService/AbstractDocumentationCommentService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs (85%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SyntaxFactsService/ExternalSourceInfo.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SyntaxFactsService/IDocumentationCommentService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SyntaxFactsService/ISyntaxFactsServiceExtensions.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/SyntaxFactsService/ISyntaxKindsService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.AbstractTypeInferrer.cs (95%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/LanguageServices/TypeInferenceService/ITypeInferenceService.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/Log/AbstractLogAggregator.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/Log/LogAggregator.cs (100%) rename src/Workspaces/{Core/Portable/Rename/ConflictEngine => SharedUtilitiesAndExtensions/Workspace/Core/Rename}/Annotations/RenameActionAnnotation.cs (100%) rename src/Workspaces/{Core/Portable/Rename/ConflictEngine => SharedUtilitiesAndExtensions/Workspace/Core/Rename}/Annotations/RenameAnnotation.cs (100%) rename src/Workspaces/{Core/Portable/Rename/ConflictEngine => SharedUtilitiesAndExtensions/Workspace/Core/Rename}/Annotations/RenameDeclarationLocationReference.cs (100%) rename src/Workspaces/{Core/Portable/Rename/ConflictEngine => SharedUtilitiesAndExtensions/Workspace/Core/Rename}/Annotations/RenameInvalidIdentifierAnnotation.cs (100%) rename src/Workspaces/{Core/Portable/Rename/ConflictEngine => SharedUtilitiesAndExtensions/Workspace/Core/Rename}/Annotations/RenameNodeSimplificationAnnotation.cs (100%) rename src/Workspaces/{Core/Portable/Rename/ConflictEngine => SharedUtilitiesAndExtensions/Workspace/Core/Rename}/Annotations/RenameTokenSimplificationAnnotation.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/AbstractSpeculationAnalyzer.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/Matcher.ChoiceMatcher.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/Matcher.RepeatMatcher.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/Matcher.SequenceMatcher.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/Matcher.SingleMatcher.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/Matcher.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/Matcher`1.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/NameGenerator.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Solution => SharedUtilitiesAndExtensions/Workspace/Core/Utilities}/SemanticDocument.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Solution => SharedUtilitiesAndExtensions/Workspace/Core/Utilities}/SyntacticDocument.cs (100%) rename src/Workspaces/{Core/Portable/Shared => SharedUtilitiesAndExtensions/Workspace/Core}/Utilities/TextReaderWithLength.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/CodeChangeProviderMetadata.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/FileExtensionsMetadata.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/ILanguageMetadata.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/ILanguagesMetadata.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/IMefHostExportProvider.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/LanguageMetadata.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/LanguageServiceMetadata.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/MefLanguageServices.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/MefWorkspaceServices.cs (96%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/OrderableLanguageMetadata.cs (100%) rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef}/OrderableMetadata.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/WorkspaceKindMetadata.cs (100%) rename src/Workspaces/{Core/Portable/Workspace/Host => SharedUtilitiesAndExtensions/Workspace/Core/Workspace}/Mef/WorkspaceServiceMetadata.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.shproj rename src/Workspaces/{Core/Portable => SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceServices}/SemanticModelWorkspaceService/ISemanticModelService.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ArgumentListSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ArgumentSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/CallStatementSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/CastAnalyzer.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/CastExpressionSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/CompilationUnitSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ContextQuery/IsStatementTerminatingTokenVisitor.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ContextQuery/SyntaxTokenExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ContextQuery/SyntaxTreeExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ContextQuery/VisualBasicSyntaxContext.vb (99%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ContextQuery/VisualBasicSyntaxContextExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/DirectiveSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ExpressionSyntaxExtensions.vb (99%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ExpressionSyntaxGeneratorVisitor.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/IMethodSymbolExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/INamespaceOrTypeSymbolExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ITypeSymbolExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/InvocationExpressionSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/MemberAccessExpressionSyntaxExtensions.vb (96%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/NameSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ObjectCreationExpressionExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/OperatorPrecedence.vb (83%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ParameterSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/ParenthesizedExpressionSyntaxExtensions.vb (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SemanticModelExtensions.vb rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SimpleNameSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SingleLineRewriter.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/StatementSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/StringExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SymbolDisplayPartExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SymbolExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SyntaxKindExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SyntaxListExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SyntaxNodeExtensions.vb (87%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SyntaxTokenExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SyntaxTreeExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/SyntaxTriviaListExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/TypeBlockSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/TypeSyntaxGeneratorVisitor.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Extensions/VariableDeclaratorSyntaxExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable/AddImports => SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices}/VisualBasicAddImportsService.vb (97%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicCommandLineParserService.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicDocumentationCommentService.vb (100%) rename src/Workspaces/{VisualBasic/Portable/GeneratedCodeRecognition => SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices}/VisualBasicGeneratedCodeRecognitionService.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicPrecedenceService.vb (97%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicSemanticFactsService.vb (99%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicSymbolDeclarationService.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicSyntaxFactsService.vb (99%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicSyntaxFactsServiceFactory.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicSyntaxKindsService.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicSyntaxKindsServiceFactory.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/LanguageServices/VisualBasicTypeInferenceService.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/DirectiveSyntaxEqualityComparer.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/DirectiveWalker.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/ImportsClauseComparer.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/ImportsOrganizer.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/ImportsStatementComparer.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/ModifierCollectionFacts.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/NameSyntaxComparer.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/NameSyntaxIterator.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/PossibleDeclarationTypes.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/SpeculationAnalyzer.vb (99%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/SymbolExtensions.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/SyntaxKindSet.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/TokenComparer.vb (100%) rename src/Workspaces/{VisualBasic/Portable => SharedUtilitiesAndExtensions/Workspace/VisualBasic}/Utilities/TypeSyntaxComparer.vb (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/VisualBasicSimplificationHelpers.vb create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.shproj rename src/Workspaces/VisualBasic/Portable/{ => Workspace}/LanguageServices/VisualBasicCompilationFactoryService.vb (100%) rename src/Workspaces/VisualBasic/Portable/{ => Workspace}/LanguageServices/VisualBasicSyntaxTreeFactoryService.NullSyntaxReference.vb (100%) rename src/Workspaces/VisualBasic/Portable/{ => Workspace}/LanguageServices/VisualBasicSyntaxTreeFactoryService.PathSyntaxReference.vb (100%) rename src/Workspaces/VisualBasic/Portable/{ => Workspace}/LanguageServices/VisualBasicSyntaxTreeFactoryService.PositionalSyntaxReference.vb (100%) rename src/Workspaces/VisualBasic/Portable/{ => Workspace}/LanguageServices/VisualBasicSyntaxTreeFactoryService.RecoverableSyntaxTree.vb (100%) rename src/Workspaces/VisualBasic/Portable/{ => Workspace}/LanguageServices/VisualBasicSyntaxTreeFactoryService.vb (100%) diff --git a/Roslyn.sln b/Roslyn.sln index 6f27a2d84dbde..c40ef4fe370f5 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -422,26 +422,101 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompilersIOperationGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\IOperationGenerator\CompilersIOperationGenerator.csproj", "{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzers", "Analyzers", "{4A49D526-1644-4819-AA4F-95B348D447D4}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.shproj", "{EC946164-1E17-410B-B7D9-7DE7E6268D63}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "WorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.shproj", "{99F594B1-3916-471D-A761-A6731FC50E9A}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Analyzers.UnitTests", "src\Analyzers\Core\Tests\Analyzers.UnitTests.shproj", "{0C9A3C46-C74B-4528-AF62-7288AE131AF3}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpCompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.shproj", "{699FEA05-AEA7-403D-827E-53CF4E826955}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpWorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.shproj", "{438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzers.UnitTests", "src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.shproj", "{58969243-7F59-4236-93D0-C93B81F569B3}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicCompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.shproj", "{CEC0DCE7-8D52-45C3-9295-FC7B16BD2451}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicWorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.shproj", "{E9DBFA41-7A9C-49BE-BD36-FD71B31AA9FE}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicAnalyzers.UnitTests", "src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.shproj", "{7B7F4153-AE93-4908-B8F0-430871589F83}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Analyzers", "src\Analyzers\Core\Analyzers\Analyzers.shproj", "{76E96966-4780-4040-8197-BDE2879516F4}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CodeFixes", "src\Analyzers\Core\CodeFixes\CodeFixes.shproj", "{1B6C4A1A-413B-41FB-9F85-5C09118E541B}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzers", "src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.shproj", "{EAFFCA55-335B-4860-BB99-EFCEAD123199}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpCodeFixes", "src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.shproj", "{DA973826-C985-4128-9948-0B445E638BDB}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicAnalyzers", "src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.shproj", "{94FAF461-2E74-4DBB-9813-6B2CDE6F1880}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "VisualBasicCodeFixes", "src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.shproj", "{9F9CCC78-7487-4127-9D46-DB23E501F001}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedUtilitiesAndExtensions", "SharedUtilitiesAndExtensions", "{DF17AF27-AA02-482B-8946-5CA8A50D5A2B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compiler", "Compiler", "{7A69EA65-4411-4CD0-B439-035E720C1BD3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspace", "Workspace", "{9C1BE25C-5926-4E56-84AE-D2242CB0627E}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution + src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 + src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{0be66736-cdaa-4989-88b1-b3f46ebdca4a}*SharedItemsImports = 5 + src\Analyzers\Core\Tests\Analyzers.UnitTests.projitems*{0c9a3c46-c74b-4528-af62-7288ae131af3}*SharedItemsImports = 13 + src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{1b6c4a1a-413b-41fb-9f85-5c09118e541b}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 5 + src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{2531a8c4-97dd-47bc-a79c-b7846051e137}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{2531a8c4-97dd-47bc-a79c-b7846051e137}*SharedItemsImports = 5 + src\Analyzers\Core\Analyzers\Analyzers.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e35}*SharedItemsImports = 13 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e36}*SharedItemsImports = 13 + src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 + src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{438db8af-f3f0-4ed9-80b5-13fddd5b8787}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 5 + src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{5018d049-5870-465a-889b-c742ce1e31cb}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{54e08bf5-f819-404f-a18d-0ab9ea81ea04}*SharedItemsImports = 13 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 + src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{58969243-7f59-4236-93d0-c93b81f569b3}*SharedItemsImports = 13 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 + src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{5ff1e493-69cc-4d0b-83f2-039f469a04e1}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{5ff1e493-69cc-4d0b-83f2-039f469a04e1}*SharedItemsImports = 5 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{60db272a-21c9-4e8d-9803-ff4e132392c8}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{699fea05-aea7-403d-827e-53cf4e826955}*SharedItemsImports = 13 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{76242a2d-2600-49dd-8c15-fea07ecb1842}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{76242a2d-2600-49dd-8c15-fea07ecb1843}*SharedItemsImports = 5 + src\Analyzers\Core\Analyzers\Analyzers.projitems*{76e96966-4780-4040-8197-bde2879516f4}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 5 + src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{7b7f4153-ae93-4908-b8f0-430871589f83}*SharedItemsImports = 13 + src\Analyzers\Core\Tests\Analyzers.UnitTests.projitems*{8cee3609-a5a9-4a9b-86d7-33118f5d6b33}*SharedItemsImports = 5 + src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{94faf461-2e74-4dbb-9813-6b2cde6f1880}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{99f594b1-3916-471d-a761-a6731fc50e9a}*SharedItemsImports = 13 + src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{9f9ccc78-7487-4127-9d46-db23e501f001}*SharedItemsImports = 13 + src\Analyzers\Core\Tests\Analyzers.UnitTests.projitems*{9ff1205f-1d7c-4ee4-b038-3456fe6ebeaf}*SharedItemsImports = 5 + src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 + src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 + src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 + src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{aa87bfed-089a-4096-b8d5-690bdc7d5b24}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{aa87bfed-089a-4096-b8d5-690bdc7d5b24}*SharedItemsImports = 5 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{abdbac1e-350e-4dc3-bb45-3504404545ee}*SharedItemsImports = 5 + src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{ac2bcefb-9298-4621-ac48-1ff5e639e48d}*SharedItemsImports = 5 src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{ace53515-482c-4c6a-e2d2-4242a687dfee}*SharedItemsImports = 5 src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 5 @@ -450,10 +525,18 @@ Global src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d3}*SharedItemsImports = 5 src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d4}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{cec0dce7-8d52-45c3-9295-fc7b16bd2451}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13 + src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{da973826-c985-4128-9948-0b445e638bdb}*SharedItemsImports = 13 + src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{e512c6c1-f085-4ad7-b0d9-e8f1a0a2a510}*SharedItemsImports = 5 src\Compilers\Core\CommandLine\CommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{e8f0baa5-7327-43d1-9a51-644e81ae55f1}*SharedItemsImports = 13 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{e9dbfa41-7a9c-49be-bd36-fd71b31aa9fe}*SharedItemsImports = 13 + src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{eaffca55-335b-4860-bb99-efcead123199}*SharedItemsImports = 13 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{ec946164-1e17-410b-b7d9-7de7e6268d63}*SharedItemsImports = 13 + src\Analyzers\Core\Analyzers\Analyzers.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 + src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5 src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{fa0e905d-ec46-466d-b7b2-3b5557f9428c}*SharedItemsImports = 5 @@ -1318,6 +1401,25 @@ Global {CE7F7553-DB2D-4839-92E3-F042E4261B4E} = {8DBA5174-B0AA-4561-82B1-A46607697753} {FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} {D55FB2BD-CC9E-454B-9654-94AF5D910BF7} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC} + {4A49D526-1644-4819-AA4F-95B348D447D4} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} + {EC946164-1E17-410B-B7D9-7DE7E6268D63} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} + {99F594B1-3916-471D-A761-A6731FC50E9A} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} + {0C9A3C46-C74B-4528-AF62-7288AE131AF3} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {699FEA05-AEA7-403D-827E-53CF4E826955} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} + {438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} + {58969243-7F59-4236-93D0-C93B81F569B3} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {CEC0DCE7-8D52-45C3-9295-FC7B16BD2451} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} + {E9DBFA41-7A9C-49BE-BD36-FD71B31AA9FE} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} + {7B7F4153-AE93-4908-B8F0-430871589F83} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {76E96966-4780-4040-8197-BDE2879516F4} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {1B6C4A1A-413B-41FB-9F85-5C09118E541B} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {EAFFCA55-335B-4860-BB99-EFCEAD123199} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {DA973826-C985-4128-9948-0B445E638BDB} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {94FAF461-2E74-4DBB-9813-6B2CDE6F1880} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {9F9CCC78-7487-4127-9D46-DB23E501F001} = {4A49D526-1644-4819-AA4F-95B348D447D4} + {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} + {7A69EA65-4411-4CD0-B439-035E720C1BD3} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} + {9C1BE25C-5926-4E56-84AE-D2242CB0627E} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29} diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems new file mode 100644 index 0000000000000..d26a3f56df98b --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.CSharp.Analyzers + + + + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.shproj b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.shproj new file mode 100644 index 0000000000000..00d26033fcc99 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.shproj @@ -0,0 +1,13 @@ + + + + {EAFFCA55-335B-4860-BB99-EFCEAD123199} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs similarity index 100% rename from src/Features/CSharp/Portable/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems new file mode 100644 index 0000000000000..322fd9537163d --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.CSharp.CodeFixes + + + + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.shproj b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.shproj new file mode 100644 index 0000000000000..10556433768c2 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.shproj @@ -0,0 +1,13 @@ + + + + {DA973826-C985-4128-9948-0B445E638BDB} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/RemoveUnusedMembers/CSharpRemoveUnusedMembersCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveUnusedMembers/CSharpRemoveUnusedMembersCodeFixProvider.cs similarity index 100% rename from src/Features/CSharp/Portable/RemoveUnusedMembers/CSharpRemoveUnusedMembersCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/RemoveUnusedMembers/CSharpRemoveUnusedMembersCodeFixProvider.cs diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems new file mode 100644 index 0000000000000..37af92b661875 --- /dev/null +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests + + + + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.shproj b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.shproj new file mode 100644 index 0000000000000..0446cbcd50890 --- /dev/null +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.shproj @@ -0,0 +1,13 @@ + + + + {58969243-7F59-4236-93D0-C93B81F569B3} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs b/src/Analyzers/CSharp/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs rename to src/Analyzers/CSharp/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.cs index 20670aa4b59f9..1eb7fff6064c8 100644 --- a/src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs +++ b/src/Analyzers/CSharp/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.cs @@ -16,6 +16,12 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.RemoveUnusedMembers { +#if CODE_STYLE + using AnalyzerResources = CodeStyleResources; +#else + using AnalyzerResources = FeaturesResources; +#endif + public class RemoveUnusedMembersTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest { internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace) @@ -1096,7 +1102,7 @@ public void M() using var workspace = CreateWorkspaceFromOptions(source, testParameters); var diagnostics = await GetDiagnosticsAsync(workspace, testParameters).ConfigureAwait(false); diagnostics.Verify(Diagnostic("IDE0052", "P").WithLocation(3, 17)); - var expectedMessage = string.Format(FeaturesResources.Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked, "MyClass.P"); + var expectedMessage = string.Format(AnalyzerResources.Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked, "MyClass.P"); Assert.Equal(expectedMessage, diagnostics.Single().GetMessage()); } diff --git a/src/Features/Core/Portable/CodeStyle/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs similarity index 98% rename from src/Features/Core/Portable/CodeStyle/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs rename to src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs index 467e3ada0737b..43d99c62b8eae 100644 --- a/src/Features/Core/Portable/CodeStyle/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs @@ -10,6 +10,12 @@ namespace Microsoft.CodeAnalysis.CodeStyle { +#if CODE_STYLE + using OptionSet = AnalyzerConfigOptions; +#else + using OptionSet = Options.OptionSet; +#endif + internal abstract class AbstractBuiltInCodeStyleDiagnosticAnalyzer : AbstractCodeStyleDiagnosticAnalyzer, IBuiltInAnalyzer { /// diff --git a/src/Features/Core/Portable/CodeQuality/AbstractCodeQualityDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs similarity index 95% rename from src/Features/Core/Portable/CodeQuality/AbstractCodeQualityDiagnosticAnalyzer.cs rename to src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs index 45c9f3f4c8daf..87213aa4bd507 100644 --- a/src/Features/Core/Portable/CodeQuality/AbstractCodeQualityDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs @@ -4,10 +4,15 @@ using System.Collections.Immutable; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Options; namespace Microsoft.CodeAnalysis.CodeQuality { +#if CODE_STYLE + using OptionSet = AnalyzerConfigOptions; +#else + using OptionSet = Options.OptionSet; +#endif + internal abstract class AbstractCodeQualityDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer { private readonly GeneratedCodeAnalysisFlags _generatedCodeAnalysisFlags; diff --git a/src/CodeStyle/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs similarity index 100% rename from src/CodeStyle/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs rename to src/Analyzers/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs diff --git a/src/Analyzers/Core/Analyzers/Analyzers.projitems b/src/Analyzers/Core/Analyzers/Analyzers.projitems new file mode 100644 index 0000000000000..f0f48dbc53d7a --- /dev/null +++ b/src/Analyzers/Core/Analyzers/Analyzers.projitems @@ -0,0 +1,28 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.Analyzers + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/Analyzers.shproj b/src/Analyzers/Core/Analyzers/Analyzers.shproj new file mode 100644 index 0000000000000..9c9875de04fb7 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/Analyzers.shproj @@ -0,0 +1,13 @@ + + + + {76E96966-4780-4040-8197-BDE2879516F4} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Features/Core/Portable/Diagnostics/DiagnosticAnalyzerCategory.cs b/src/Analyzers/Core/Analyzers/DiagnosticAnalyzerCategory.cs similarity index 100% rename from src/Features/Core/Portable/Diagnostics/DiagnosticAnalyzerCategory.cs rename to src/Analyzers/Core/Analyzers/DiagnosticAnalyzerCategory.cs diff --git a/src/Features/Core/Portable/Diagnostics/DiagnosticCategory.cs b/src/Analyzers/Core/Analyzers/DiagnosticCategory.cs similarity index 100% rename from src/Features/Core/Portable/Diagnostics/DiagnosticCategory.cs rename to src/Analyzers/Core/Analyzers/DiagnosticCategory.cs diff --git a/src/Features/Core/Portable/Diagnostics/DiagnosticCustomTags.cs b/src/Analyzers/Core/Analyzers/DiagnosticCustomTags.cs similarity index 100% rename from src/Features/Core/Portable/Diagnostics/DiagnosticCustomTags.cs rename to src/Analyzers/Core/Analyzers/DiagnosticCustomTags.cs diff --git a/src/Features/Core/Portable/Shared/Utilities/DeserializationConstructorCheck.cs b/src/Analyzers/Core/Analyzers/Helpers/DeserializationConstructorCheck.cs similarity index 100% rename from src/Features/Core/Portable/Shared/Utilities/DeserializationConstructorCheck.cs rename to src/Analyzers/Core/Analyzers/Helpers/DeserializationConstructorCheck.cs diff --git a/src/Features/Core/Portable/Diagnostics/DiagnosticHelper.cs b/src/Analyzers/Core/Analyzers/Helpers/DiagnosticHelper.cs similarity index 98% rename from src/Features/Core/Portable/Diagnostics/DiagnosticHelper.cs rename to src/Analyzers/Core/Analyzers/Helpers/DiagnosticHelper.cs index 23047b9a9a867..0c9c410009b62 100644 --- a/src/Features/Core/Portable/Diagnostics/DiagnosticHelper.cs +++ b/src/Analyzers/Core/Analyzers/Helpers/DiagnosticHelper.cs @@ -10,7 +10,6 @@ using System.Runtime.Serialization.Json; using System.Text; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.CodeAnalysis.RemoveUnnecessaryParentheses; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Diagnostics @@ -74,7 +73,7 @@ public static Diagnostic Create( /// /// /// a map of location tag to index in additional locations. - /// for an example of usage. + /// see AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer for an example of usage. /// /// Arguments to the message of the diagnostic. /// The instance. diff --git a/src/Features/Core/Portable/Diagnostics/IBuiltInAnalyzer.cs b/src/Analyzers/Core/Analyzers/IBuiltInAnalyzer.cs similarity index 92% rename from src/Features/Core/Portable/Diagnostics/IBuiltInAnalyzer.cs rename to src/Analyzers/Core/Analyzers/IBuiltInAnalyzer.cs index 4113fdb398894..58b3342a2440d 100644 --- a/src/Features/Core/Portable/Diagnostics/IBuiltInAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/IBuiltInAnalyzer.cs @@ -2,10 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.CodeAnalysis.Options; - namespace Microsoft.CodeAnalysis.Diagnostics { +#if CODE_STYLE + using OptionSet = AnalyzerConfigOptions; +#else + using OptionSet = Options.OptionSet; +#endif + /// /// This interface is a marker for all the analyzers that are built in. /// We will record non-fatal-watson if any analyzer with this interface throws an exception. diff --git a/src/Features/Core/Portable/Diagnostics/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs b/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs similarity index 100% rename from src/Features/Core/Portable/Diagnostics/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs rename to src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs diff --git a/src/Features/Core/Portable/Diagnostics/Analyzers/IDEDiagnosticIds.cs b/src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs similarity index 100% rename from src/Features/Core/Portable/Diagnostics/Analyzers/IDEDiagnosticIds.cs rename to src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs diff --git a/src/Features/Core/Portable/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs similarity index 97% rename from src/Features/Core/Portable/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs rename to src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs index e2d98ece72a82..aef4b84c780f8 100644 --- a/src/Features/Core/Portable/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs @@ -17,6 +17,12 @@ namespace Microsoft.CodeAnalysis.RemoveUnusedMembers { +#if CODE_STYLE + using Resources = CodeStyleResources; +#else + using Resources = FeaturesResources; +#endif + internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer : AbstractCodeQualityDiagnosticAnalyzer where TDocumentationCommentTriviaSyntax : SyntaxNode @@ -25,15 +31,15 @@ internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.CodeFixes + + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/CodeFixes.shproj b/src/Analyzers/Core/CodeFixes/CodeFixes.shproj new file mode 100644 index 0000000000000..6958e00273177 --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/CodeFixes.shproj @@ -0,0 +1,13 @@ + + + + {1B6C4A1A-413B-41FB-9F85-5C09118E541B} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Features/Core/Portable/CodeFixes/PredefinedCodeFixProviderNames.cs b/src/Analyzers/Core/CodeFixes/PredefinedCodeFixProviderNames.cs similarity index 100% rename from src/Features/Core/Portable/CodeFixes/PredefinedCodeFixProviderNames.cs rename to src/Analyzers/Core/CodeFixes/PredefinedCodeFixProviderNames.cs diff --git a/src/Features/Core/Portable/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs similarity index 95% rename from src/Features/Core/Portable/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs rename to src/Analyzers/Core/CodeFixes/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs index 7efd256298e83..1494cc7355063 100644 --- a/src/Features/Core/Portable/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs +++ b/src/Analyzers/Core/CodeFixes/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs @@ -19,6 +19,12 @@ namespace Microsoft.CodeAnalysis.RemoveUnusedMembers { +#if CODE_STYLE + using Resources = CodeStyleFixesResources; +#else + using Resources = FeaturesResources; +#endif + internal abstract class AbstractRemoveUnusedMembersCodeFixProvider : SyntaxEditorBasedCodeFixProvider where TFieldDeclarationSyntax : SyntaxNode { @@ -123,12 +129,13 @@ protected static void AdjustAndAddAppropriateDeclaratorsToRemove(SyntaxNode pare } } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(FeaturesResources.Remove_unused_member, createChangedDocument) + : base(Resources.Remove_unused_member, createChangedDocument) { } } } } + diff --git a/src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems b/src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems new file mode 100644 index 0000000000000..016b07d950552 --- /dev/null +++ b/src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems @@ -0,0 +1,11 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.Analyzers.UnitTests + + \ No newline at end of file diff --git a/src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj b/src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj new file mode 100644 index 0000000000000..fac6264b5b558 --- /dev/null +++ b/src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj @@ -0,0 +1,13 @@ + + + + {0C9A3C46-C74B-4528-AF62-7288AE131AF3} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Features/VisualBasic/Portable/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb b/src/Analyzers/VisualBasic/Analyzers/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb similarity index 100% rename from src/Features/VisualBasic/Portable/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb rename to src/Analyzers/VisualBasic/Analyzers/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb diff --git a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems new file mode 100644 index 0000000000000..2898a4029907c --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.VisualBasic.Analyzers + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.shproj b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.shproj new file mode 100644 index 0000000000000..d98dbd57ecb42 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.shproj @@ -0,0 +1,13 @@ + + + + {94FAF461-2E74-4DBB-9813-6B2CDE6F1880} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Features/VisualBasic/Portable/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersCodeFixProvider.vb b/src/Analyzers/VisualBasic/CodeFixes/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersCodeFixProvider.vb similarity index 100% rename from src/Features/VisualBasic/Portable/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersCodeFixProvider.vb rename to src/Analyzers/VisualBasic/CodeFixes/RemoveUnusedMembers/VisualBasicRemoveUnusedMembersCodeFixProvider.vb diff --git a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems new file mode 100644 index 0000000000000..4d491da212f9b --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.VisualBasic.CodeFixes + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.shproj b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.shproj new file mode 100644 index 0000000000000..b104a8cac68a4 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.shproj @@ -0,0 +1,13 @@ + + + + {9F9CCC78-7487-4127-9D46-DB23E501F001} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/EditorFeatures/VisualBasicTest/RemoveUnusedMembers/RemoveUnusedMembersTests.vb b/src/Analyzers/VisualBasic/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.vb similarity index 100% rename from src/EditorFeatures/VisualBasicTest/RemoveUnusedMembers/RemoveUnusedMembersTests.vb rename to src/Analyzers/VisualBasic/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.vb diff --git a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems new file mode 100644 index 0000000000000..e7acc0bf7b114 --- /dev/null +++ b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems @@ -0,0 +1,24 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.VisualBasic.Analyzers.UnitTests + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.shproj b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.shproj new file mode 100644 index 0000000000000..71f4f7624d4d3 --- /dev/null +++ b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.shproj @@ -0,0 +1,13 @@ + + + + {7B7F4153-AE93-4908-B8F0-430871589F83} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/CodeStyle/BannedSymbols.txt b/src/CodeStyle/BannedSymbols.txt new file mode 100644 index 0000000000000..20394b89bbe11 --- /dev/null +++ b/src/CodeStyle/BannedSymbols.txt @@ -0,0 +1,2 @@ +P:Microsoft.CodeAnalysis.Project.LanguageServices; Use 'GetExtendedLanguageServices' instead +M:Microsoft.CodeAnalysis.Host.HostWorkspaceServices.GetLanguageServices(System.String); Use 'GetExtendedLanguageServices' or directly get the language service by invoking 'GetLanguageService' or 'GetRequiredLanguageService' diff --git a/src/CodeStyle/CSharp/Analyzers/Microsoft.CodeAnalysis.CSharp.CodeStyle.csproj b/src/CodeStyle/CSharp/Analyzers/Microsoft.CodeAnalysis.CSharp.CodeStyle.csproj index 05df67c2a7b94..e43000b2dd28a 100644 --- a/src/CodeStyle/CSharp/Analyzers/Microsoft.CodeAnalysis.CSharp.CodeStyle.csproj +++ b/src/CodeStyle/CSharp/Analyzers/Microsoft.CodeAnalysis.CSharp.CodeStyle.csproj @@ -19,11 +19,6 @@ - - - - - @@ -76,4 +71,6 @@ + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs index 6326dd3c354e1..409a081cb20eb 100644 --- a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs +++ b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs @@ -10,7 +10,6 @@ namespace Microsoft.CodeAnalysis.CSharp { using System; - using System.Reflection; /// @@ -20,7 +19,7 @@ namespace Microsoft.CodeAnalysis.CSharp { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class CSharpCodeStyleFixesResources { @@ -40,7 +39,7 @@ internal CSharpCodeStyleFixesResources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleFixesResources", typeof(CSharpCodeStyleFixesResources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleFixesResources", typeof(CSharpCodeStyleFixesResources).Assembly); resourceMan = temp; } return resourceMan; @@ -62,11 +61,11 @@ internal CSharpCodeStyleFixesResources() { } /// - /// Looks up a localized string similar to Remove this value when another is added.. + /// Looks up a localized string similar to Expected string or char literal. /// - internal static string EmptyResource { + internal static string Expected_string_or_char_literal { get { - return ResourceManager.GetString("EmptyResource", resourceCulture); + return ResourceManager.GetString("Expected_string_or_char_literal", resourceCulture); } } } diff --git a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx index 14ed010cf9ebb..98c8b413e306f 100644 --- a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx +++ b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx @@ -117,8 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Remove this value when another is added. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj b/src/CodeStyle/CSharp/CodeFixes/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj index a49e406c61086..b7de97127a4c9 100644 --- a/src/CodeStyle/CSharp/CodeFixes/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj +++ b/src/CodeStyle/CSharp/CodeFixes/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj @@ -22,14 +22,14 @@ - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.CodeStyle\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CSharp.CodeStyle.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CodeStyle.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CodeStyle.Fixes.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.CodeStyle\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CSharp.CodeStyle.resources.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.resources.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CodeStyle.resources.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CodeStyle.Fixes.resources.dll"/> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.CodeStyle\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CSharp.CodeStyle.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CodeStyle.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CodeStyle.Fixes.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.CodeStyle\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CSharp.CodeStyle.resources.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.resources.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CodeStyle.resources.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CodeStyle.Fixes.resources.dll" /> @@ -63,4 +63,6 @@ + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf index 6eef083c31512..39146d45d209b 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Odebrat tuto hodnotu, když se přidá jiná - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf index b119ad5a5e8c0..18a9a30d8be0f 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Dieser Wert wird entfernt, wenn ein anderer hinzugefügt wird. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf index 1b4fa23371d84..26bf74c96ffa0 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Quite este valor cuando se agregue otro. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf index 7e6ae49c0448c..3b95b05aac8b1 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Supprimer cette valeur quand une autre est ajoutée. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf index 63c2bde38d7c9..0f4d7644333c7 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Rimuovere questo valore quando ne viene aggiunto un altro. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf index f4006c0f79c55..ad88830d4a9c6 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 別の値が追加されたら、この値を削除します。 - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf index 340f9c313b082..b00636dc3fa5f 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 다른 값을 추가할 때 이 값을 제거하세요. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf index 8e6d438112ac1..3bbd74588e939 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Usuń tę wartość, gdy dodawana jest kolejna. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf index afcd0a6e16671..dca3e55064999 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Remover este valor quando outro for adicionado. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf index c048734bdb588..20970585e1c9d 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Удалите это значение при добавлении другого значения. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf index 294e6c4b454e9..ad42489520643 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Başka bir değer eklendiğinde bu değeri kaldırın. - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf index be6877b951bb0..9c28fdf16fcb6 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 在添加其他值时删除此值。 - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf index 8daad74a19618..4a8c4907b89f9 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 當新增另一個值時移除此值。 - https://github.com/Microsoft/msbuild/issues/1661 + + Expected string or char literal + Expected string or char literal + diff --git a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj index 2d20c0f9c0867..fe10a2f60487b 100644 --- a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj @@ -4,13 +4,13 @@ Library Microsoft.CodeAnalysis.CSharp + $(DefineConstants),CODE_STYLE net472 true - @@ -18,5 +18,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs b/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs index b45192537c472..d87795edef782 100644 --- a/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs +++ b/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs @@ -10,7 +10,6 @@ namespace Microsoft.CodeAnalysis { using System; - using System.Reflection; /// @@ -40,7 +39,7 @@ internal CodeStyleResources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CodeStyleResources", typeof(CodeStyleResources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CodeStyleResources", typeof(CodeStyleResources).Assembly); resourceMan = temp; } return resourceMan; @@ -79,6 +78,51 @@ internal static string A_language_name_must_be_specified_for_this_option { } } + /// + /// Looks up a localized string similar to Absolute path expected.. + /// + internal static string Absolute_path_expected { + get { + return ResourceManager.GetString("Absolute_path_expected", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to An element with the same key but a different value already exists.. + /// + internal static string An_element_with_the_same_key_but_a_different_value_already_exists { + get { + return ResourceManager.GetString("An_element_with_the_same_key_but_a_different_value_already_exists", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Arrays with more than one dimension cannot be serialized.. + /// + internal static string Arrays_with_more_than_one_dimension_cannot_be_serialized { + get { + return ResourceManager.GetString("Arrays_with_more_than_one_dimension_cannot_be_serialized", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cannot serialize type '{0}'.. + /// + internal static string Cannot_serialize_type_0 { + get { + return ResourceManager.GetString("Cannot_serialize_type_0", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deserialization reader for '{0}' read incorrect number of values.. + /// + internal static string Deserialization_reader_for_0_read_incorrect_number_of_values { + get { + return ResourceManager.GetString("Deserialization_reader_for_0_read_incorrect_number_of_values", resourceCulture); + } + } + /// /// Looks up a localized string similar to Error. /// @@ -124,6 +168,43 @@ internal static string None { } } + /// + /// Looks up a localized string similar to Private member '{0}' can be removed as the value assigned to it is never read.. + /// + internal static string Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read { + get { + return ResourceManager.GetString("Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Private member '{0}' is unused.. + /// + internal static string Private_member_0_is_unused { + get { + return ResourceManager.GetString("Private_member_0_is_unused", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Private method '{0}' can be removed as it is never invoked.. + /// + internal static string Private_method_0_can_be_removed_as_it_is_never_invoked { + get { + return ResourceManager.GetString("Private_method_0_can_be_removed_as_it_is_never_invoked", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Private property '{0}' can be converted to a method as its get accessor is never invoked.. + /// + internal static string Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked { + get { + return ResourceManager.GetString("Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invo" + + "ked", resourceCulture); + } + } + /// /// Looks up a localized string similar to Refactoring Only. /// @@ -133,6 +214,33 @@ internal static string Refactoring_Only { } } + /// + /// Looks up a localized string similar to Remove unread private members. + /// + internal static string Remove_unread_private_members { + get { + return ResourceManager.GetString("Remove_unread_private_members", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Remove unused private members. + /// + internal static string Remove_unused_private_members { + get { + return ResourceManager.GetString("Remove_unused_private_members", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Stream is too long.. + /// + internal static string Stream_is_too_long { + get { + return ResourceManager.GetString("Stream_is_too_long", resourceCulture); + } + } + /// /// Looks up a localized string similar to Suggestion. /// @@ -142,6 +250,24 @@ internal static string Suggestion { } } + /// + /// Looks up a localized string similar to The type '{0}' is not understood by the serialization binder.. + /// + internal static string The_type_0_is_not_understood_by_the_serialization_binder { + get { + return ResourceManager.GetString("The_type_0_is_not_understood_by_the_serialization_binder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value too large to be represented as a 30 bit unsigned integer.. + /// + internal static string Value_too_large_to_be_represented_as_a_30_bit_unsigned_integer { + get { + return ResourceManager.GetString("Value_too_large_to_be_represented_as_a_30_bit_unsigned_integer", resourceCulture); + } + } + /// /// Looks up a localized string similar to Warning. /// diff --git a/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx b/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx index 87700f4197021..d0a0eae7d5f55 100644 --- a/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx +++ b/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx @@ -147,4 +147,46 @@ Warning + + Arrays with more than one dimension cannot be serialized. + + + Value too large to be represented as a 30 bit unsigned integer. + + + The type '{0}' is not understood by the serialization binder. + + + Cannot serialize type '{0}'. + + + Deserialization reader for '{0}' read incorrect number of values. + + + Stream is too long. + + + Absolute path expected. + + + An element with the same key but a different value already exists. + + + Private member '{0}' is unused. + + + Remove unused private members + + + Remove unread private members + + + Private member '{0}' can be removed as the value assigned to it is never read. + + + Private method '{0}' can be removed as it is never invoked. + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/DiagnosticCategory.cs b/src/CodeStyle/Core/Analyzers/DiagnosticCategory.cs deleted file mode 100644 index 056c7c6893115..0000000000000 --- a/src/CodeStyle/Core/Analyzers/DiagnosticCategory.cs +++ /dev/null @@ -1,11 +0,0 @@ -// 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. - -namespace Microsoft.CodeAnalysis.CodeStyle -{ - internal static class DiagnosticCategory - { - public const string Style = nameof(Style); - } -} diff --git a/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs b/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs index bc62a7993cda9..6a056e9f13923 100644 --- a/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs +++ b/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs @@ -6,12 +6,13 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; -namespace Microsoft.CodeAnalysis.Formatting +namespace Microsoft.CodeAnalysis.CodeStyle.Formatting { /// /// Formats whitespace in documents or syntax trees. diff --git a/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs b/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs index f2623226cc4e1..cf7d6896bfdee 100644 --- a/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs +++ b/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs @@ -3,14 +3,15 @@ // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Text; #if CODE_STYLE +using Microsoft.CodeAnalysis.CodeStyle.Formatting; using FormatterState = Microsoft.CodeAnalysis.Formatting.ISyntaxFormattingService; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; #else using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Formatting; using FormatterState = Microsoft.CodeAnalysis.Workspace; #endif diff --git a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj index d0c3372e2c499..121ccf765fc9f 100644 --- a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj +++ b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj @@ -26,40 +26,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -134,7 +102,6 @@ - @@ -154,31 +121,9 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -199,4 +144,6 @@ + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf index 5ca2079dc79d4..677e25209dca0 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf @@ -12,6 +12,31 @@ Pro tuto možnost se musí zadat název jazyka. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Chyba @@ -37,16 +62,61 @@ žádné + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Pouze refaktoring + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Návrh + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Upozornění diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf index b7e3ceb8cb06a..1bb38721fb30d 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf @@ -12,6 +12,31 @@ Für diese Option muss ein Sprachenname angegeben werden. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Fehler @@ -37,16 +62,61 @@ NONE + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Nur Refactoring + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Vorschlag + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Warnung diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf index a970537212c4a..9aa521ca2efe1 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf @@ -12,6 +12,31 @@ Se debe especificar un nombre de lenguaje para esta opción. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Error @@ -37,16 +62,61 @@ NONE + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Solo refactorización + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Sugerencia + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Advertencia diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf index d1efa4fa9a5cc..51cabba1ab0f9 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf @@ -12,6 +12,31 @@ Un nom de langage doit être spécifié pour cette option. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Erreur @@ -37,16 +62,61 @@ Aucun(e) + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Refactoring Only + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Suggestion + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Avertissement diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf index 1e1ef632fc6b7..efcc91a7c6aa8 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf @@ -12,6 +12,31 @@ È necessario specificare un nome di linguaggio per questa opzione. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Errore @@ -37,16 +62,61 @@ Nessuno + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Refactoring Only + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Suggerimento + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Avviso diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf index 0bdbec723a638..14e6213ab8285 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf @@ -12,6 +12,31 @@ このオプションの言語名を指定する必要があります。 + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error エラー @@ -37,16 +62,61 @@ なし + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only リファクタリングのみ + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion 提案事項 + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning 警告 diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf index 37c63bb0a35f2..ccd78b71ef82e 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf @@ -12,6 +12,31 @@ 이 옵션에 대한 언어 이름을 지정해야 합니다. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error 오류 @@ -37,16 +62,61 @@ None + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only 리팩터링만 + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion 제안 + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning 경고 diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf index 93dcee17d8c20..e0993cbd39dba 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf @@ -12,6 +12,31 @@ Nazwa języka musi zostać określona dla tej opcji. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Błąd @@ -37,16 +62,61 @@ brak + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Tylko refaktoryzacja + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Sugestia + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Ostrzeżenie diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf index 44bcad92f9f41..4c53e7c6dba00 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf @@ -12,6 +12,31 @@ Um nome de idioma deve ser especificado para esta opção. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Erro @@ -37,16 +62,61 @@ NENHUM + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Somente Refatoração + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Sugestão + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Aviso diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf index 5a2df33d169bb..fcc4936d07cc5 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf @@ -12,6 +12,31 @@ Для данного параметра необходимо указать имя языка. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Ошибка @@ -37,16 +62,61 @@ NONE + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Только рефакторинг + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Рекомендация + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Предупреждение diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf index e1d8344e04ee6..25a0295c18457 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf @@ -12,6 +12,31 @@ Bu seçenek için bir dil adı belirtilmelidir. + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error Hata @@ -37,16 +62,61 @@ yok + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only Sadece Yeniden Düzenlenme + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion Öneri + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning Uyarı diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf index cd9ad3d92f886..41b79037b1f78 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf @@ -12,6 +12,31 @@ 必须为此选项指定语言名称。 + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error 错误 @@ -37,16 +62,61 @@ + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only 仅重构 + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion 建议 + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning 警告 diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf index 12e9be98286ec..daccbae8631af 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf @@ -12,6 +12,31 @@ 必須指定此選項的語言名稱。 + + Absolute path expected. + Absolute path expected. + + + + An element with the same key but a different value already exists. + An element with the same key but a different value already exists. + + + + Arrays with more than one dimension cannot be serialized. + Arrays with more than one dimension cannot be serialized. + + + + Cannot serialize type '{0}'. + Cannot serialize type '{0}'. + + + + Deserialization reader for '{0}' read incorrect number of values. + Deserialization reader for '{0}' read incorrect number of values. + + Error 錯誤 @@ -37,16 +62,61 @@ + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Refactoring Only 僅重構 + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + Stream is too long. + Stream is too long. + + Suggestion 建議 + + The type '{0}' is not understood by the serialization binder. + The type '{0}' is not understood by the serialization binder. + + + + Value too large to be represented as a 30 bit unsigned integer. + Value too large to be represented as a 30 bit unsigned integer. + + Warning 警告 diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf new file mode 100644 index 0000000000000..734bfa216be5b --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf new file mode 100644 index 0000000000000..98b02ae2b71ae --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf new file mode 100644 index 0000000000000..4f199594fc154 --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf new file mode 100644 index 0000000000000..45bbac7b66029 --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf new file mode 100644 index 0000000000000..1e18cf210a5d2 --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf new file mode 100644 index 0000000000000..cebf12e83dded --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf new file mode 100644 index 0000000000000..d3fc7046a9f56 --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf new file mode 100644 index 0000000000000..10fb669a87adb --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf new file mode 100644 index 0000000000000..b98d9fc6a08e7 --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf new file mode 100644 index 0000000000000..e15b0a4f7e31d --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf new file mode 100644 index 0000000000000..a57f23d4c86dc --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hans.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hans.xlf new file mode 100644 index 0000000000000..042f4608614e1 --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hant.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hant.xlf new file mode 100644 index 0000000000000..fd863bcc718c7 --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.Designer.cs b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.Designer.cs index b9e6d374a23ff..70277b73a44f3 100644 --- a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.Designer.cs +++ b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.Designer.cs @@ -10,7 +10,6 @@ namespace Microsoft.CodeAnalysis { using System; - using System.Reflection; /// @@ -20,7 +19,7 @@ namespace Microsoft.CodeAnalysis { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class CodeStyleFixesResources { @@ -40,7 +39,7 @@ internal CodeStyleFixesResources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CodeStyleFixesResources", typeof(CodeStyleFixesResources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CodeStyleFixesResources", typeof(CodeStyleFixesResources).Assembly); resourceMan = temp; } return resourceMan; @@ -62,11 +61,65 @@ internal CodeStyleFixesResources() { } /// - /// Looks up a localized string similar to Remove this value when another is added.. + /// Looks up a localized string similar to Compilation is required to accomplish the task but is not supported by project {0}.. /// - internal static string EmptyResource { + internal static string Compilation_is_required_to_accomplish_the_task_but_is_not_supported_by_project_0 { get { - return ResourceManager.GetString("EmptyResource", resourceCulture); + return ResourceManager.GetString("Compilation_is_required_to_accomplish_the_task_but_is_not_supported_by_project_0", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fix all '{0}'. + /// + internal static string Fix_all_0 { + get { + return ResourceManager.GetString("Fix_all_0", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fix all '{0}' in '{1}'. + /// + internal static string Fix_all_0_in_1 { + get { + return ResourceManager.GetString("Fix_all_0_in_1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fix all '{0}' in Solution. + /// + internal static string Fix_all_0_in_Solution { + get { + return ResourceManager.GetString("Fix_all_0_in_Solution", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Remove unused member. + /// + internal static string Remove_unused_member { + get { + return ResourceManager.GetString("Remove_unused_member", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Supplied diagnostic cannot be null.. + /// + internal static string Supplied_diagnostic_cannot_be_null { + get { + return ResourceManager.GetString("Supplied_diagnostic_cannot_be_null", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Syntax tree is required to accomplish the task but is not supported by document {0}.. + /// + internal static string SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0 { + get { + return ResourceManager.GetString("SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0", resourceCulture); } } } diff --git a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx index 14ed010cf9ebb..aa9f45d59bb4e 100644 --- a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx +++ b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx @@ -117,8 +117,25 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Remove this value when another is added. - https://github.com/Microsoft/msbuild/issues/1661 + + Supplied diagnostic cannot be null. + + + Fix all '{0}' + + + Fix all '{0}' in '{1}' + + + Fix all '{0}' in Solution + + + Compilation is required to accomplish the task but is not supported by project {0}. + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + + + Remove unused member \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs index 428404b7fa002..da79ab2051a94 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Text; #if CODE_STYLE -using Formatter = CodeStyle::Microsoft.CodeAnalysis.Formatting.Formatter; +using Formatter = CodeStyle::Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; using FormatterState = Microsoft.CodeAnalysis.Formatting.ISyntaxFormattingService; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; #else diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs index 9e197ebe0da8b..ab782ff6fadcb 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs @@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.CodeStyle { extern alias CodeStyle; - using Formatter = CodeStyle::Microsoft.CodeAnalysis.Formatting.Formatter; + using Formatter = CodeStyle::Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; using ISyntaxFormattingService = ISyntaxFormattingService; internal abstract class AbstractFormattingCodeFixProvider : CodeFixProvider @@ -77,14 +77,14 @@ public FixAll(AbstractFormattingCodeFixProvider formattingCodeFixProvider) _formattingCodeFixProvider = formattingCodeFixProvider; } - protected override string CodeActionTitle => CodeStyleResources.Fix_formatting; + protected override string GetCodeActionTitle(FixAllContext fixAllContext) => CodeStyleResources.Fix_formatting; - protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) { var options = await _formattingCodeFixProvider.GetOptionsAsync(document, fixAllContext.CancellationToken).ConfigureAwait(false); var syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); var updatedSyntaxRoot = Formatter.Format(syntaxRoot, _formattingCodeFixProvider.SyntaxFormattingService, options, fixAllContext.CancellationToken); - return updatedSyntaxRoot; + return document.WithSyntaxRoot(updatedSyntaxRoot); } } } diff --git a/src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.MefHostExportProvider.cs b/src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.MefHostExportProvider.cs new file mode 100644 index 0000000000000..d7c3af1bdd1b1 --- /dev/null +++ b/src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.MefHostExportProvider.cs @@ -0,0 +1,70 @@ +// 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.Composition; +using System.Composition.Hosting; +using System.Linq; +using System.Reflection; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.PooledObjects; + +namespace Microsoft.CodeAnalysis.Host +{ + internal sealed partial class CodeStyleHostLanguageServices : HostLanguageServices + { + private sealed class MefHostExportProvider : IMefHostExportProvider + { + private readonly CompositionHost _compositionContext; + + public MefHostExportProvider(string languageName) + { + var assemblies = CreateAssemblies(languageName); + var compositionConfiguration = new ContainerConfiguration().WithAssemblies(assemblies); + _compositionContext = compositionConfiguration.CreateContainer(); + } + + private static ImmutableArray CreateAssemblies(string languageName) + { + using var disposer = ArrayBuilder.GetInstance(out var assemblyNames); + + assemblyNames.Add("Microsoft.CodeAnalysis.CodeStyle.Fixes"); + switch (languageName) + { + case LanguageNames.CSharp: + assemblyNames.Add("Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes"); + break; + + case LanguageNames.VisualBasic: + assemblyNames.Add("Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes"); + break; + } + + return MefHostServices.DefaultAssemblies.Concat( + MefHostServicesHelpers.LoadNearbyAssemblies(assemblyNames)); + } + + + IEnumerable> IMefHostExportProvider.GetExports() + { + return _compositionContext.GetExports().Select(e => new Lazy(() => e)); + } + + IEnumerable> IMefHostExportProvider.GetExports() + { + var importer = new WithMetadataImporter(); + _compositionContext.SatisfyImports(importer); + return importer.Exports; + } + + private class WithMetadataImporter + { + [ImportMany] + public IEnumerable> Exports { get; set; } + } + } + } +} diff --git a/src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.cs b/src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.cs new file mode 100644 index 0000000000000..46f7f32f77eb2 --- /dev/null +++ b/src/CodeStyle/Core/CodeFixes/Host/Mef/CodeStyleHostLanguageServices.cs @@ -0,0 +1,46 @@ +// 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.Concurrent; +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.CodeAnalysis.Host +{ + internal sealed partial class CodeStyleHostLanguageServices : HostLanguageServices + { + private static readonly ConcurrentDictionary s_mappedLanguageServices = + new ConcurrentDictionary(); + + private readonly HostLanguageServices _hostLanguageServices; + private readonly HostLanguageServices _codeStyleLanguageServices; + + private CodeStyleHostLanguageServices(HostLanguageServices hostLanguageServices) + { + _hostLanguageServices = hostLanguageServices; + + var exportProvider = new MefHostExportProvider(hostLanguageServices.Language); + _codeStyleLanguageServices = new MefWorkspaceServices(exportProvider, hostLanguageServices.WorkspaceServices.Workspace) + .GetLanguageServices(hostLanguageServices.Language); + } + + public static CodeStyleHostLanguageServices? GetMappedCodeStyleLanguageServices(HostLanguageServices? hostLanguageServices) + => hostLanguageServices != null ? s_mappedLanguageServices.GetOrAdd(hostLanguageServices, Create) : null; + public static CodeStyleHostLanguageServices GetRequiredMappedCodeStyleLanguageServices(HostLanguageServices hostLanguageServices) + => s_mappedLanguageServices.GetOrAdd(hostLanguageServices, Create); + private static CodeStyleHostLanguageServices Create(HostLanguageServices hostLanguageServices) + => new CodeStyleHostLanguageServices(hostLanguageServices); + + public override HostWorkspaceServices WorkspaceServices => _hostLanguageServices.WorkspaceServices; + public override string Language => _hostLanguageServices.Language; + + [return: MaybeNull] + public override TLanguageService GetService() + { + return _codeStyleLanguageServices.GetService() ?? _hostLanguageServices.GetService(); + } + } +} diff --git a/src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs b/src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs new file mode 100644 index 0000000000000..e32b6a7ebabd4 --- /dev/null +++ b/src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs @@ -0,0 +1,24 @@ +// 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.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.CodeAnalysis.SemanticModelWorkspaceService +{ + internal partial class SemanticModelWorkspaceServiceFactory : IWorkspaceServiceFactory + { + private sealed class SemanticModelService : ISemanticModelService + { + public Task GetSemanticModelForNodeAsync(Document document, SyntaxNode node, CancellationToken cancellationToken = default) + { + // get the base one + return document.GetSemanticModelAsync(cancellationToken); + } + } + } +} diff --git a/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj b/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj index 522e17ca7338c..5db18622b63fc 100644 --- a/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj +++ b/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj @@ -8,7 +8,6 @@ $(DefineConstants),CODE_STYLE - @@ -42,4 +41,6 @@ + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf index 559726ff639c6..8c55eec8ef625 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Odebrat tuto hodnotu, když se přidá jiná - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf index d5a6d6aaca6f7..e0e1cc514ca11 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Dieser Wert wird entfernt, wenn ein anderer hinzugefügt wird. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf index 2d94e4f72ae08..9202d3e4de20e 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Quite este valor cuando se agregue otro. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf index d090cec024319..7e1fd990a2912 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Supprimer cette valeur quand une autre est ajoutée. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf index 39117266e3829..6212d308851d4 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Rimuovere questo valore quando ne viene aggiunto un altro. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf index c6f9b412ca04e..e461127223a1e 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - 別の値が追加されたら、この値を削除します。 - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf index 2fdb94976762d..991a11dff4db2 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - 다른 값을 추가할 때 이 값을 제거하세요. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf index 676ecc024083f..301ee0f5b9883 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Usuń tę wartość, gdy dodawana jest kolejna. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf index 4b35061ad6e5c..0f5b73bdb74ef 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Remover este valor quando outro for adicionado. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf index a5527cc1adace..633c7bb03ea8b 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Удалите это значение при добавлении другого значения. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf index 65ac78f824b91..4e38524d221db 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - Başka bir değer eklendiğinde bu değeri kaldırın. - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf index 1a6295ceca776..4e3cefa35a416 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - 在添加其他值时删除此值。 - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf index 47e57451acb6b..d06b543d92842 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf @@ -2,10 +2,40 @@ - - Remove this value when another is added. - 當新增另一個值時移除此值。 - https://github.com/Microsoft/msbuild/issues/1661 + + Compilation is required to accomplish the task but is not supported by project {0}. + Compilation is required to accomplish the task but is not supported by project {0}. + + + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + + + Remove unused member + Remove unused member + + + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + + + Syntax tree is required to accomplish the task but is not supported by document {0}. + Syntax tree is required to accomplish the task but is not supported by document {0}. + diff --git a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj index f3ad82b08a20d..37f7ce6140c2c 100644 --- a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj @@ -4,14 +4,28 @@ Library Microsoft.CodeAnalysis + $(DefineConstants),CODE_STYLE net472 + + + + + + + + + + + + - - + + + \ No newline at end of file diff --git a/src/CodeStyle/Directory.Build.targets b/src/CodeStyle/Directory.Build.targets index 42e78817dd243..ea7a40b91b495 100644 --- a/src/CodeStyle/Directory.Build.targets +++ b/src/CodeStyle/Directory.Build.targets @@ -3,5 +3,9 @@ + + + + \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/Analyzers/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.vbproj b/src/CodeStyle/VisualBasic/Analyzers/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.vbproj index 59d8fe57142b9..81d6c219e26ab 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.vbproj +++ b/src/CodeStyle/VisualBasic/Analyzers/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.vbproj @@ -9,9 +9,6 @@ Microsoft.CodeAnalysis.VisualBasic.CodeStyle.NewNameSinceWeReferenceTheAnalyzersAndNuGetCannotFigureItOut - - - @@ -71,4 +68,6 @@ + + \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj b/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj index a5e0ad4e8a69f..c09ee580b474f 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj +++ b/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj @@ -21,14 +21,14 @@ - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.CodeStyle\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CodeStyle.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CodeStyle.Fixes.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.CodeStyle\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.resources.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.resources.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CodeStyle.resources.dll"/> - <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CodeStyle.Fixes.resources.dll"/> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.CodeStyle\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CodeStyle.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\Microsoft.CodeAnalysis.CodeStyle.Fixes.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.CodeStyle\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.resources.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.resources.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CodeStyle.resources.dll" /> + <_File Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.CodeStyle.Fixes\$(Configuration)\$(TargetFramework)\**\Microsoft.CodeAnalysis.CodeStyle.Fixes.resources.dll" /> @@ -63,4 +63,6 @@ + + \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj index be0dc47c205e0..aaeab1e0243f7 100644 --- a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj +++ b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj @@ -5,6 +5,7 @@ Library net472 + $(DefineConstants),CODE_STYLE true @@ -18,5 +19,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Compilers/Core/Portable/InternalUtilities/EncodingExtensions.cs b/src/Compilers/Core/Portable/InternalUtilities/EncodingExtensions.cs index 09027ec37ccd1..272e28fbb9556 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/EncodingExtensions.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/EncodingExtensions.cs @@ -28,7 +28,9 @@ internal static int GetMaxCharCountOrThrowIfHuge(this Encoding encoding, Stream return maxCharCount; } -#if WORKSPACE +#if CODE_STYLE + throw new IOException(CodeStyleResources.Stream_is_too_long); +#elif WORKSPACE throw new IOException(WorkspacesResources.Stream_is_too_long); #else throw new IOException(CodeAnalysisResources.StreamIsTooLong); diff --git a/src/Compilers/Core/Portable/Serialization/ObjectReader.cs b/src/Compilers/Core/Portable/Serialization/ObjectReader.cs index 49b271825c5a9..f4a7796fd1ed1 100644 --- a/src/Compilers/Core/Portable/Serialization/ObjectReader.cs +++ b/src/Compilers/Core/Portable/Serialization/ObjectReader.cs @@ -16,6 +16,8 @@ namespace Roslyn.Utilities { #if COMPILERCORE using Resources = CodeAnalysisResources; +#elif CODE_STYLE + using Resources = CodeStyleResources; #else using Resources = WorkspacesResources; #endif diff --git a/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs b/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs index 8e9fae9776dfe..b7ed033140b33 100644 --- a/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs +++ b/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs @@ -17,8 +17,11 @@ namespace Roslyn.Utilities { using System.Collections.Immutable; using System.Threading.Tasks; + #if COMPILERCORE using Resources = CodeAnalysisResources; +#elif CODE_STYLE + using Resources = CodeStyleResources; #else using Resources = WorkspacesResources; #endif diff --git a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs index 81e9d97a059f8..848b179c7ee60 100644 --- a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs +++ b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs @@ -59,8 +59,8 @@ internal async Task TestAsync( bool outOfProcess) { await TestInRegularAndScript1Async( - initialMarkup, expectedMarkup, index, priority, - parameters: new TestParameters(options: options, fixProviderData: outOfProcess)); + initialMarkup, expectedMarkup, index, + parameters: new TestParameters(options: options, fixProviderData: outOfProcess, priority: priority)); } } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs index 6c36e83082ba9..d647c212c0f84 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs @@ -1387,7 +1387,7 @@ public int I }", options: Option(CodeStyleOptions.QualifyFieldAccess, true, NotificationOption.Error)); } - [Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTuple() { var text = @" @@ -1430,7 +1430,7 @@ await TestAllOptionsOffAsync( text, expected, index: 1); } - [Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), CompilerTrait(CompilerFeature.Tuples)] public async Task TupleWithNames() { var text = @" diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs index 33ed2a8d94db9..28632b3ce8518 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs @@ -931,7 +931,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTupleDeclarationWithNames() { await TestInRegularAndScriptAsync( @@ -958,7 +958,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTupleDeclarationWithSomeNames() { await TestInRegularAndScriptAsync( @@ -985,7 +985,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTupleWith1Arity() { await TestInRegularAndScriptAsync( @@ -1014,7 +1014,7 @@ static void NewMethod(ValueTuple y) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTupleLiteralWithNames() { await TestInRegularAndScriptAsync( @@ -1041,7 +1041,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTupleDeclarationAndLiteralWithNames() { await TestInRegularAndScriptAsync( @@ -1068,7 +1068,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTupleIntoVar() { await TestInRegularAndScriptAsync( @@ -1095,7 +1095,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task RefactorWithoutSystemValueTuple() { await TestInRegularAndScriptAsync( @@ -1122,7 +1122,7 @@ static void Main(string[] args) }", CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTupleWithNestedNamedTuple() { // This is not the best refactoring, but this is an edge case @@ -1150,7 +1150,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestDeconstruction() { await TestInRegularAndScriptAsync( @@ -1177,7 +1177,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestDeconstruction2() { await TestInRegularAndScriptAsync( @@ -1207,7 +1207,7 @@ static int NewMethod() } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.OutVar)] + [CompilerTrait(CompilerFeature.OutVar)] public async Task TestOutVar() { await TestInRegularAndScriptAsync( @@ -1238,7 +1238,7 @@ static void NewMethod(int i, out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] + [CompilerTrait(CompilerFeature.Patterns)] public async Task TestIsPattern() { await TestInRegularAndScriptAsync( @@ -1269,7 +1269,7 @@ static void NewMethod(int i, out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] + [CompilerTrait(CompilerFeature.Patterns)] public async Task TestOutVarAndIsPattern() { await TestInRegularAndScriptAsync( @@ -1300,7 +1300,7 @@ static void NewMethod(out int r, out int y, out int z) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] + [CompilerTrait(CompilerFeature.Patterns)] public async Task ConflictingOutVarLocals() { await TestInRegularAndScriptAsync( @@ -1341,7 +1341,7 @@ static void NewMethod(out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] + [CompilerTrait(CompilerFeature.Patterns)] public async Task ConflictingPatternLocals() { await TestInRegularAndScriptAsync( diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs index ec77c4483edf8..17825a860902e 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs @@ -919,7 +919,7 @@ private static void NewMethod(out Construct obj1, out Construct obj2, out Constr }"); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTuple() { @@ -947,7 +947,7 @@ private static (int, int) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleDeclarationWithNames() { @@ -975,7 +975,7 @@ private static (int a, int b) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleDeclarationWithSomeNames() { @@ -1003,7 +1003,7 @@ private static (int a, int) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")] public async Task TestTupleWith1Arity() { @@ -1033,7 +1033,7 @@ private static void NewMethod(ValueTuple y) }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleLiteralWithNames() { @@ -1061,7 +1061,7 @@ private static (int, int) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleDeclarationAndLiteralWithNames() { @@ -1089,7 +1089,7 @@ private static (int a, int b) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleIntoVar() { @@ -1117,7 +1117,7 @@ private static (int c, int d) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task RefactorWithoutSystemValueTuple() { @@ -1145,7 +1145,7 @@ private static (int c, int d) NewMethod() }"); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleWithNestedNamedTuple() { @@ -1174,7 +1174,7 @@ private static (int, int, int, int, int, int, int, string, string) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] public async Task TestDeconstruction() { await TestInRegularAndScriptAsync( @@ -1201,7 +1201,7 @@ private static (int, int) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] public async Task TestDeconstruction2() { await TestInRegularAndScriptAsync( @@ -1231,7 +1231,7 @@ private static int NewMethod() } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.OutVar)] + [CompilerTrait(CompilerFeature.OutVar)] public async Task TestOutVar() { await TestInRegularAndScriptAsync( @@ -1262,7 +1262,7 @@ private static void NewMethod(int i, out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] + [CompilerTrait(CompilerFeature.Patterns)] public async Task TestIsPattern() { await TestInRegularAndScriptAsync( @@ -1293,7 +1293,7 @@ private static void NewMethod(int i, out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] + [CompilerTrait(CompilerFeature.Patterns)] public async Task TestOutVarAndIsPattern() { await TestInRegularAndScriptAsync( @@ -1324,7 +1324,7 @@ private static void NewMethod(out int r, out int y, out int z) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] + [CompilerTrait(CompilerFeature.Patterns)] public async Task ConflictingOutVarLocals() { await TestInRegularAndScriptAsync( @@ -1365,7 +1365,7 @@ private static void NewMethod(out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] + [CompilerTrait(CompilerFeature.Patterns)] public async Task ConflictingPatternLocals() { await TestInRegularAndScriptAsync( diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs index 674c1d5c48fcf..8569241ce49d6 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs @@ -2903,7 +2903,7 @@ public virtual void Bar() {} // CompilationExtensions is in the Microsoft.CodeAnalysis.Test.Utilities namespace // which has a "Traits" type that conflicts with the one in Roslyn.Test.Utilities - var reference = MetadataReference.CreateFromImage(Test.Utilities.CompilationExtensions.EmitToArray(compilation)); + var reference = MetadataReference.CreateFromImage(CompilationExtensions.EmitToArray(compilation)); var p1 = workspace.CurrentSolution.Projects.First(p => p.Name == "P1"); var updatedP1 = p1.AddMetadataReference(reference); workspace.ChangeSolution(updatedP1.Solution); @@ -2954,7 +2954,7 @@ public override void M(in int x) var origComp = await workspace.CurrentSolution.Projects.Single().GetCompilationAsync(); var options = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Latest); var libComp = origComp.RemoveAllSyntaxTrees().AddSyntaxTrees(CSharpSyntaxTree.ParseText(before, options: options)); - var libRef = MetadataReference.CreateFromImage(Test.Utilities.CompilationExtensions.EmitToArray(libComp)); + var libRef = MetadataReference.CreateFromImage(CompilationExtensions.EmitToArray(libComp)); var project = workspace.CurrentSolution.Projects.Single(); var updatedProject = project.AddMetadataReference(libRef); diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs index f298d7c414117..9fd5d7e550bd7 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs @@ -927,7 +927,7 @@ async Task<$$> [WorkItem(13480, "https://github.com/dotnet/roslyn/issues/13480")] [Fact] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] + [CompilerTrait(CompilerFeature.LocalFunctions)] public async Task LocalFunctionReturnType() { var markup = @" @@ -942,7 +942,7 @@ public void M() } [Fact(Skip = "https://github.com/dotnet/roslyn/issues/14525")] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] + [CompilerTrait(CompilerFeature.LocalFunctions)] public async Task LocalFunctionAfterAyncTask() { var markup = @" @@ -957,7 +957,7 @@ async Task<$$> } [Fact(Skip = "https://github.com/dotnet/roslyn/issues/14525")] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] + [CompilerTrait(CompilerFeature.LocalFunctions)] public async Task LocalFunctionAfterAsync() { var markup = @" diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs index 876733b5f9790..981ae68f8771a 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs @@ -9623,7 +9623,7 @@ void goo() [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] + [CompilerTrait(CompilerFeature.LocalFunctions)] [WorkItem(13480, "https://github.com/dotnet/roslyn/issues/13480")] public async Task NoCompletionInLocalFuncGenericParamList() { @@ -9639,7 +9639,7 @@ void M() [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] + [CompilerTrait(CompilerFeature.LocalFunctions)] [WorkItem(13480, "https://github.com/dotnet/roslyn/issues/13480")] public async Task CompletionForAwaitWithoutAsync() { @@ -9743,7 +9743,7 @@ void M() [WorkItem(14163, "https://github.com/dotnet/roslyn/issues/14163")] [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] + [CompilerTrait(CompilerFeature.LocalFunctions)] public async Task LocalFunctionDescription() { await VerifyItemExistsAsync(@" @@ -9761,7 +9761,7 @@ void Local() { } [WorkItem(14163, "https://github.com/dotnet/roslyn/issues/14163")] [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] + [CompilerTrait(CompilerFeature.LocalFunctions)] public async Task LocalFunctionDescription2() { await VerifyItemExistsAsync(@" @@ -10548,7 +10548,7 @@ public void M(string s) [WorkItem(38074, "https://github.com/dotnet/roslyn/issues/38074")] [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] + [CompilerTrait(CompilerFeature.LocalFunctions)] public async Task LocalFunctionInStaticMethod() { await VerifyItemExistsAsync(@" diff --git a/src/EditorFeatures/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs b/src/EditorFeatures/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs index 178989372228c..bcd3c9f4a4e2b 100644 --- a/src/EditorFeatures/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs +++ b/src/EditorFeatures/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs @@ -750,7 +750,7 @@ static void Main(string[] args) index: 2); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), CompilerTrait(CompilerFeature.Tuples)] public async Task Tuple() { await TestInRegularAndScriptAsync( @@ -779,7 +779,7 @@ public B((int, string) x) }"); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), CompilerTrait(CompilerFeature.Tuples)] public async Task TupleWithNames() { await TestInRegularAndScriptAsync( diff --git a/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs b/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs index 1be39a5d88ded..0ff606464e710 100644 --- a/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs +++ b/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs @@ -235,7 +235,7 @@ public sealed class TupleElementNamesAttribute : Attribute { } } "; - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] public async Task TupleWithNamesInMethod() { await TestWithAllCodeStyleOptionsOffAsync( @@ -264,7 +264,7 @@ class Class : IInterface " + s_tupleElementNamesAttribute); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] public async Task TupleWithNamesInMethod_Explicitly() { await TestWithAllCodeStyleOptionsOffAsync( @@ -294,7 +294,7 @@ class Class : IInterface index: 1); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] public async Task TupleWithNamesInProperty() { await TestWithAllCodeStyleOptionsOffAsync( @@ -331,7 +331,7 @@ class Class : IInterface " + s_tupleElementNamesAttribute); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] public async Task TupleWithNamesInEvent() { await TestWithAllCodeStyleOptionsOffAsync( @@ -6733,7 +6733,7 @@ IEnumerator IEnumerable.GetEnumerator() index: 1); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] public async Task LongTuple() { await TestWithAllCodeStyleOptionsOffAsync( diff --git a/src/EditorFeatures/CSharpTest/Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj b/src/EditorFeatures/CSharpTest/Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj index 961af4af7928a..66f5a33d7dabd 100644 --- a/src/EditorFeatures/CSharpTest/Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj +++ b/src/EditorFeatures/CSharpTest/Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj @@ -27,6 +27,7 @@ + @@ -84,5 +85,6 @@ + \ No newline at end of file diff --git a/src/EditorFeatures/CSharpTest/PullMemberUp/CSharpPullMemberUpTests.cs b/src/EditorFeatures/CSharpTest/PullMemberUp/CSharpPullMemberUpTests.cs index 907d1beff88b5..875c75dd2e255 100644 --- a/src/EditorFeatures/CSharpTest/PullMemberUp/CSharpPullMemberUpTests.cs +++ b/src/EditorFeatures/CSharpTest/PullMemberUp/CSharpPullMemberUpTests.cs @@ -1433,14 +1433,13 @@ internal Task TestWithPullMemberDialogAsync( IEnumerable<(string name, bool makeAbstract)> selection = null, string destinationName = null, int index = 0, - CodeActionPriority? priority = null, TestParameters parameters = default) { var service = new TestPullMemberUpService(selection, destinationName); return TestInRegularAndScript1Async( initialMarkUp, expectedResult, - index, priority, + index, parameters.WithFixProviderData(service)); } diff --git a/src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs b/src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs index 293d698916302..e5aa81108d76a 100644 --- a/src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs +++ b/src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs @@ -255,7 +255,7 @@ public async Task ApplyCodeFixesForSpecificDiagnosticIdAsync(Document var fixAllService = document.Project.Solution.Workspace.Services.GetRequiredService(); var solution = await fixAllService.GetFixAllChangedSolutionAsync( - fixCollection.FixAllState.CreateFixAllContext(progressTracker, cancellationToken)).ConfigureAwait(false); + new FixAllContext(fixCollection.FixAllState, progressTracker, cancellationToken)).ConfigureAwait(false); return solution.GetDocument(document.Id) ?? throw new NotSupportedException(EditorFeaturesResources.Removal_of_document_not_supported); } diff --git a/src/EditorFeatures/TestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs b/src/EditorFeatures/Test/ChangeSignature/AbstractChangeSignatureTests.cs similarity index 99% rename from src/EditorFeatures/TestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs rename to src/EditorFeatures/Test/ChangeSignature/AbstractChangeSignatureTests.cs index 66db009cf9612..c7c86ad58599c 100644 --- a/src/EditorFeatures/TestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs +++ b/src/EditorFeatures/Test/ChangeSignature/AbstractChangeSignatureTests.cs @@ -161,7 +161,7 @@ private string GetSignatureDescriptionString(int[] signature, int? totalParamete /// described above. public async Task TestAllSignatureChangesAsync(string languageName, string markup, int[] signaturePartCounts, ParseOptions parseOptions = null) { - Assert.Equal(signaturePartCounts.Length, 4); + Assert.Equal(4, signaturePartCounts.Length); Assert.True(signaturePartCounts[0] == 0 || signaturePartCounts[0] == 1); Assert.True(signaturePartCounts[3] == 0 || signaturePartCounts[3] == 1); diff --git a/src/EditorFeatures/TestUtilities/ChangeSignature/ChangeSignatureTestState.cs b/src/EditorFeatures/Test/ChangeSignature/ChangeSignatureTestState.cs similarity index 100% rename from src/EditorFeatures/TestUtilities/ChangeSignature/ChangeSignatureTestState.cs rename to src/EditorFeatures/Test/ChangeSignature/ChangeSignatureTestState.cs diff --git a/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs similarity index 78% rename from src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs rename to src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs index c6bc6a7f648aa..4ec5d606e466a 100644 --- a/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs +++ b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs @@ -2,6 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +extern alias Workspaces; +#endif + using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -11,23 +15,33 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; -using Microsoft.CodeAnalysis.CodeStyle; -using Microsoft.CodeAnalysis.Editor.Implementation.Preview; using Microsoft.CodeAnalysis.Editor.UnitTests.Extensions; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests; using Roslyn.Test.Utilities; -using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions { +#if CODE_STYLE + using Workspaces::Roslyn.Utilities; + using OptionKey = Workspaces::Microsoft.CodeAnalysis.Options.OptionKey; + using CodeActionPriority = Workspaces::Microsoft.CodeAnalysis.CodeActions.CodeActionPriority; + using NotificationOption = Workspaces::Microsoft.CodeAnalysis.CodeStyle.NotificationOption; + using Options = Workspaces::Microsoft.CodeAnalysis.Options; + using CodeStyle = Workspaces::Microsoft.CodeAnalysis.CodeStyle; +#else + using Microsoft.CodeAnalysis.Options; + using Microsoft.CodeAnalysis.CodeStyle; + using Roslyn.Utilities; + using Options = CodeAnalysis.Options; +#endif + [UseExportProvider] - public abstract class AbstractCodeActionOrUserDiagnosticTest + public abstract partial class AbstractCodeActionOrUserDiagnosticTest { public struct TestParameters { @@ -199,138 +213,6 @@ protected async Task TestActionCountAsync( } } - protected async Task TestAddDocumentInRegularAndScriptAsync( - string initialMarkup, string expectedMarkup, - ImmutableArray expectedContainers, - string expectedDocumentName, - TestParameters parameters = default) - { - await TestAddDocument( - initialMarkup, expectedMarkup, - expectedContainers, expectedDocumentName, - WithRegularOptions(parameters)); - await TestAddDocument( - initialMarkup, expectedMarkup, - expectedContainers, expectedDocumentName, - WithScriptOptions(parameters)); - } - - protected async Task> TestAddDocumentAsync( - TestParameters parameters, - TestWorkspace workspace, - string expectedMarkup, - string expectedDocumentName, - ImmutableArray expectedContainers) - { - var (_, action) = await GetCodeActionsAsync(workspace, parameters); - return await TestAddDocument( - workspace, expectedMarkup, expectedContainers, - expectedDocumentName, action); - } - - protected async Task TestAddDocument( - string initialMarkup, - string expectedMarkup, - ImmutableArray expectedContainers, - string expectedDocumentName, - TestParameters parameters = default) - { - using (var workspace = CreateWorkspaceFromOptions(initialMarkup, parameters)) - { - var (_, action) = await GetCodeActionsAsync(workspace, parameters); - await TestAddDocument( - workspace, expectedMarkup, expectedContainers, - expectedDocumentName, action); - } - } - - private async Task> TestAddDocument( - TestWorkspace workspace, - string expectedMarkup, - ImmutableArray expectedFolders, - string expectedDocumentName, - CodeAction action) - { - var operations = await VerifyActionAndGetOperationsAsync(workspace, action, default); - return await TestAddDocument( - workspace, - expectedMarkup, - operations, - hasProjectChange: false, - modifiedProjectId: null, - expectedFolders: expectedFolders, - expectedDocumentName: expectedDocumentName); - } - - protected async Task> TestAddDocument( - TestWorkspace workspace, - string expected, - ImmutableArray operations, - bool hasProjectChange, - ProjectId modifiedProjectId, - ImmutableArray expectedFolders, - string expectedDocumentName) - { - var appliedChanges = ApplyOperationsAndGetSolution(workspace, operations); - var oldSolution = appliedChanges.Item1; - var newSolution = appliedChanges.Item2; - - Document addedDocument = null; - if (!hasProjectChange) - { - addedDocument = SolutionUtilities.GetSingleAddedDocument(oldSolution, newSolution); - } - else - { - Assert.NotNull(modifiedProjectId); - addedDocument = newSolution.GetProject(modifiedProjectId).Documents.SingleOrDefault(doc => doc.Name == expectedDocumentName); - } - - Assert.NotNull(addedDocument); - - AssertEx.Equal(expectedFolders, addedDocument.Folders); - Assert.Equal(expectedDocumentName, addedDocument.Name); - Assert.Equal(expected, (await addedDocument.GetTextAsync()).ToString()); - - var editHandler = workspace.ExportProvider.GetExportedValue(); - if (!hasProjectChange) - { - // If there is just one document change then we expect the preview to be a WpfTextView - var content = (await editHandler.GetPreviews(workspace, operations, CancellationToken.None).GetPreviewsAsync())[0]; - using (var diffView = content as DifferenceViewerPreview) - { - Assert.NotNull(diffView.Viewer); - } - } - else - { - // If there are more changes than just the document we need to browse all the changes and get the document change - var contents = editHandler.GetPreviews(workspace, operations, CancellationToken.None); - var hasPreview = false; - var previews = await contents.GetPreviewsAsync(); - if (previews != null) - { - foreach (var preview in previews) - { - if (preview != null) - { - var diffView = preview as DifferenceViewerPreview; - if (diffView?.Viewer != null) - { - hasPreview = true; - diffView.Dispose(); - break; - } - } - } - } - - Assert.True(hasPreview); - } - - return Tuple.Create(oldSolution, newSolution); - } - internal Task TestInRegularAndScriptAsync( string initialMarkup, string expectedMarkup, @@ -343,20 +225,19 @@ internal Task TestInRegularAndScriptAsync( string title = null) { return TestInRegularAndScript1Async( - initialMarkup, expectedMarkup, index, priority, - new TestParameters(parseOptions, compilationOptions, options, fixProviderData, index, title: title)); + initialMarkup, expectedMarkup, index, + new TestParameters(parseOptions, compilationOptions, options, fixProviderData, index, priority, title: title)); } internal async Task TestInRegularAndScript1Async( string initialMarkup, string expectedMarkup, int index = 0, - CodeActionPriority? priority = null, TestParameters parameters = default) { parameters = parameters.WithIndex(index); - await TestAsync(initialMarkup, expectedMarkup, priority, WithRegularOptions(parameters)); - await TestAsync(initialMarkup, expectedMarkup, priority, WithScriptOptions(parameters)); + await TestAsync(initialMarkup, expectedMarkup, WithRegularOptions(parameters)); + await TestAsync(initialMarkup, expectedMarkup, WithScriptOptions(parameters)); } internal Task TestAsync( @@ -369,15 +250,14 @@ internal Task TestAsync( { return TestAsync( initialMarkup, - expectedMarkup, priority, + expectedMarkup, new TestParameters( - parseOptions, compilationOptions, options, fixProviderData, index)); + parseOptions, compilationOptions, options, fixProviderData, index, priority)); } private async Task TestAsync( string initialMarkup, string expectedMarkup, - CodeActionPriority? priority, TestParameters parameters) { MarkupTestFile.GetSpans( @@ -712,40 +592,40 @@ protected static ImmutableArray FlattenActions(ImmutableArray GetNestedActions(ImmutableArray codeActions) => codeActions.SelectMany(a => a.NestedCodeActions).ToImmutableArray(); - internal (OptionKey, object) SingleOption(Option option, T enabled) + internal (OptionKey, object) SingleOption(Options.Option option, T enabled) => (new OptionKey(option), enabled); - protected (OptionKey, object) SingleOption(PerLanguageOption option, T value) + protected (OptionKey, object) SingleOption(Options.PerLanguageOption option, T value) => (new OptionKey(option, this.GetLanguage()), value); - protected (OptionKey, object) SingleOption(Option> option, T enabled, NotificationOption notification) - => SingleOption(option, new CodeStyleOption(enabled, notification)); + protected (OptionKey, object) SingleOption(Options.Option> option, T enabled, NotificationOption notification) + => SingleOption(option, new CodeStyle.CodeStyleOption(enabled, notification)); - protected (OptionKey, object) SingleOption(Option> option, CodeStyleOption codeStyle) + protected (OptionKey, object) SingleOption(Options.Option> option, CodeStyle.CodeStyleOption codeStyle) => (new OptionKey(option), codeStyle); - protected (OptionKey, object) SingleOption(PerLanguageOption> option, T enabled, NotificationOption notification) - => SingleOption(option, new CodeStyleOption(enabled, notification)); + protected (OptionKey, object) SingleOption(Options.PerLanguageOption> option, T enabled, NotificationOption notification) + => SingleOption(option, new CodeStyle.CodeStyleOption(enabled, notification)); - protected (OptionKey, object) SingleOption(PerLanguageOption> option, CodeStyleOption codeStyle) + protected (OptionKey, object) SingleOption(Options.PerLanguageOption> option, CodeStyle.CodeStyleOption codeStyle) => SingleOption(option, codeStyle, language: GetLanguage()); - protected static (OptionKey, object) SingleOption(PerLanguageOption> option, CodeStyleOption codeStyle, string language) + protected static (OptionKey, object) SingleOption(Options.PerLanguageOption> option, CodeStyle.CodeStyleOption codeStyle, string language) => (new OptionKey(option, language), codeStyle); - protected IDictionary Option(Option> option, T enabled, NotificationOption notification) + protected IDictionary Option(Options.Option> option, T enabled, NotificationOption notification) => OptionsSet(SingleOption(option, enabled, notification)); - protected IDictionary Option(Option> option, CodeStyleOption codeStyle) + protected IDictionary Option(Options.Option> option, CodeStyle.CodeStyleOption codeStyle) => OptionsSet(SingleOption(option, codeStyle)); - protected IDictionary Option(PerLanguageOption> option, T enabled, NotificationOption notification) + protected IDictionary Option(Options.PerLanguageOption> option, T enabled, NotificationOption notification) => OptionsSet(SingleOption(option, enabled, notification)); - protected IDictionary Option(PerLanguageOption option, T value) + protected IDictionary Option(Options.PerLanguageOption option, T value) => OptionsSet(SingleOption(option, value)); - protected IDictionary Option(PerLanguageOption> option, CodeStyleOption codeStyle) + protected IDictionary Option(Options.PerLanguageOption> option, CodeStyle.CodeStyleOption codeStyle) => OptionsSet(SingleOption(option, codeStyle)); internal static IDictionary OptionsSet( diff --git a/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs new file mode 100644 index 0000000000000..592d6b2fe9f88 --- /dev/null +++ b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs @@ -0,0 +1,153 @@ +// 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.Immutable; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.Editor.Implementation.Preview; +using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; +using Microsoft.CodeAnalysis.UnitTests; +using Roslyn.Test.Utilities; +using Xunit; + +namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions +{ + public abstract partial class AbstractCodeActionOrUserDiagnosticTest + { + protected async Task TestAddDocumentInRegularAndScriptAsync( + string initialMarkup, string expectedMarkup, + ImmutableArray expectedContainers, + string expectedDocumentName, + TestParameters parameters = default) + { + await TestAddDocument( + initialMarkup, expectedMarkup, + expectedContainers, expectedDocumentName, + WithRegularOptions(parameters)); + await TestAddDocument( + initialMarkup, expectedMarkup, + expectedContainers, expectedDocumentName, + WithScriptOptions(parameters)); + } + + protected async Task> TestAddDocumentAsync( + TestParameters parameters, + TestWorkspace workspace, + string expectedMarkup, + string expectedDocumentName, + ImmutableArray expectedContainers) + { + var (_, action) = await GetCodeActionsAsync(workspace, parameters); + return await TestAddDocument( + workspace, expectedMarkup, expectedContainers, + expectedDocumentName, action); + } + + protected async Task TestAddDocument( + string initialMarkup, + string expectedMarkup, + ImmutableArray expectedContainers, + string expectedDocumentName, + TestParameters parameters = default) + { + using (var workspace = CreateWorkspaceFromOptions(initialMarkup, parameters)) + { + var (_, action) = await GetCodeActionsAsync(workspace, parameters); + await TestAddDocument( + workspace, expectedMarkup, expectedContainers, + expectedDocumentName, action); + } + } + + private async Task> TestAddDocument( + TestWorkspace workspace, + string expectedMarkup, + ImmutableArray expectedFolders, + string expectedDocumentName, + CodeAction action) + { + var operations = await VerifyActionAndGetOperationsAsync(workspace, action, default); + return await TestAddDocument( + workspace, + expectedMarkup, + operations, + hasProjectChange: false, + modifiedProjectId: null, + expectedFolders: expectedFolders, + expectedDocumentName: expectedDocumentName); + } + + protected async Task> TestAddDocument( + TestWorkspace workspace, + string expected, + ImmutableArray operations, + bool hasProjectChange, + ProjectId modifiedProjectId, + ImmutableArray expectedFolders, + string expectedDocumentName) + { + var appliedChanges = ApplyOperationsAndGetSolution(workspace, operations); + var oldSolution = appliedChanges.Item1; + var newSolution = appliedChanges.Item2; + + Document addedDocument = null; + if (!hasProjectChange) + { + addedDocument = SolutionUtilities.GetSingleAddedDocument(oldSolution, newSolution); + } + else + { + Assert.NotNull(modifiedProjectId); + addedDocument = newSolution.GetProject(modifiedProjectId).Documents.SingleOrDefault(doc => doc.Name == expectedDocumentName); + } + + Assert.NotNull(addedDocument); + + AssertEx.Equal(expectedFolders, addedDocument.Folders); + Assert.Equal(expectedDocumentName, addedDocument.Name); + Assert.Equal(expected, (await addedDocument.GetTextAsync()).ToString()); + + var editHandler = workspace.ExportProvider.GetExportedValue(); + if (!hasProjectChange) + { + // If there is just one document change then we expect the preview to be a WpfTextView + var content = (await editHandler.GetPreviews(workspace, operations, CancellationToken.None).GetPreviewsAsync())[0]; + using (var diffView = content as DifferenceViewerPreview) + { + Assert.NotNull(diffView.Viewer); + } + } + else + { + // If there are more changes than just the document we need to browse all the changes and get the document change + var contents = editHandler.GetPreviews(workspace, operations, CancellationToken.None); + var hasPreview = false; + var previews = await contents.GetPreviewsAsync(); + if (previews != null) + { + foreach (var preview in previews) + { + if (preview != null) + { + var diffView = preview as DifferenceViewerPreview; + if (diffView?.Viewer != null) + { + hasPreview = true; + diffView.Dispose(); + break; + } + } + } + } + + Assert.True(hasPreview); + } + + return Tuple.Create(oldSolution, newSolution); + } + } +} diff --git a/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionTest.cs b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionTest.cs similarity index 97% rename from src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionTest.cs rename to src/EditorFeatures/Test/CodeActions/AbstractCodeActionTest.cs index ec304ac871736..f1ff9d4cb98e4 100644 --- a/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionTest.cs +++ b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionTest.cs @@ -23,7 +23,7 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions { - public abstract class AbstractCodeActionTest : AbstractCodeActionOrUserDiagnosticTest + public abstract partial class AbstractCodeActionTest : AbstractCodeActionOrUserDiagnosticTest { protected abstract CodeRefactoringProvider CreateCodeRefactoringProvider( Workspace workspace, TestParameters parameters); @@ -167,13 +167,12 @@ internal Task TestWithPickMembersDialogAsync( string[] chosenSymbols, Action> optionsCallback = null, int index = 0, - CodeActionPriority? priority = null, TestParameters parameters = default) { var pickMembersService = new TestPickMembersService(chosenSymbols.AsImmutableOrNull(), optionsCallback); return TestInRegularAndScript1Async( initialMarkup, expectedMarkup, - index, priority, + index, parameters.WithFixProviderData(pickMembersService)); } } diff --git a/src/EditorFeatures/TestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs similarity index 75% rename from src/EditorFeatures/TestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs rename to src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs index 74fffdf3e5074..d4e2527d9ad7f 100644 --- a/src/EditorFeatures/TestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs +++ b/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs @@ -2,7 +2,10 @@ // 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; +#if CODE_STYLE +extern alias Workspaces; +#endif + using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; @@ -10,19 +13,25 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests.Diagnostics; using Roslyn.Test.Utilities; -using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics { - public abstract class AbstractDiagnosticProviderBasedUserDiagnosticTest : AbstractUserDiagnosticTest +#if CODE_STYLE + using OptionKey = Workspaces::Microsoft.CodeAnalysis.Options.OptionKey; + using Workspaces::Roslyn.Utilities; + using static Workspaces::Microsoft.CodeAnalysis.ImmutableArrayExtensions; +#else + using Microsoft.CodeAnalysis.Options; + using Roslyn.Utilities; +#endif + + public abstract partial class AbstractDiagnosticProviderBasedUserDiagnosticTest : AbstractUserDiagnosticTest { private readonly ConcurrentDictionary _analyzerAndFixerMap = new ConcurrentDictionary(); @@ -224,56 +233,5 @@ private void AssertNoAnalyzerExceptionDiagnostics(IEnumerable diagno var analyzerExceptionDiagnostics = diagnostics.Where(diag => diag.Descriptor.CustomTags.Contains(WellKnownDiagnosticTags.AnalyzerException)); AssertEx.Empty(analyzerExceptionDiagnostics, "Found analyzer exception diagnostics"); } - - #region Parentheses options - - private static readonly CodeStyleOption IgnorePreference = - new CodeStyleOption(ParenthesesPreference.AlwaysForClarity, NotificationOption.None); - - private static readonly CodeStyleOption RequireForPrecedenceClarityPreference = - new CodeStyleOption(ParenthesesPreference.AlwaysForClarity, NotificationOption.Suggestion); - - private static readonly CodeStyleOption RemoveIfUnnecessaryPreference = - new CodeStyleOption(ParenthesesPreference.NeverIfUnnecessary, NotificationOption.Suggestion); - - private static IEnumerable>> GetAllExceptOtherParenthesesOptions() - { - yield return CodeStyleOptions.ArithmeticBinaryParentheses; - yield return CodeStyleOptions.RelationalBinaryParentheses; - yield return CodeStyleOptions.OtherBinaryParentheses; - } - - protected IDictionary RequireArithmeticBinaryParenthesesForClarity - => GetSingleRequireOption(CodeStyleOptions.ArithmeticBinaryParentheses); - - protected IDictionary RequireRelationalBinaryParenthesesForClarity - => GetSingleRequireOption(CodeStyleOptions.RelationalBinaryParentheses); - - protected IDictionary RequireOtherBinaryParenthesesForClarity - => GetSingleRequireOption(CodeStyleOptions.OtherBinaryParentheses); - - private IEnumerable>> GetAllParenthesesOptions() - => GetAllExceptOtherParenthesesOptions().Concat(CodeStyleOptions.OtherParentheses); - - protected IDictionary IgnoreAllParentheses - => OptionsSet(GetAllParenthesesOptions().Select( - o => SingleOption(o, IgnorePreference)).ToArray()); - - protected IDictionary RemoveAllUnnecessaryParentheses - => OptionsSet(GetAllParenthesesOptions().Select( - o => SingleOption(o, RemoveIfUnnecessaryPreference)).ToArray()); - - protected IDictionary RequireAllParenthesesForClarity - => OptionsSet(GetAllExceptOtherParenthesesOptions() - .Select(o => SingleOption(o, RequireForPrecedenceClarityPreference)) - .Concat(SingleOption(CodeStyleOptions.OtherParentheses, RemoveIfUnnecessaryPreference)).ToArray()); - - private IDictionary GetSingleRequireOption(PerLanguageOption> option) - => OptionsSet(GetAllParenthesesOptions() - .Where(o => o != option) - .Select(o => SingleOption(o, RemoveIfUnnecessaryPreference)) - .Concat(SingleOption(option, RequireForPrecedenceClarityPreference)).ToArray()); - - #endregion } } diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs b/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs new file mode 100644 index 0000000000000..f8c83823fc3c1 --- /dev/null +++ b/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs @@ -0,0 +1,66 @@ +// 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.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.Options; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics +{ + public abstract partial class AbstractDiagnosticProviderBasedUserDiagnosticTest : AbstractUserDiagnosticTest + { + #region Parentheses options + + private static readonly CodeStyleOption IgnorePreference = + new CodeStyleOption(ParenthesesPreference.AlwaysForClarity, NotificationOption.None); + + private static readonly CodeStyleOption RequireForPrecedenceClarityPreference = + new CodeStyleOption(ParenthesesPreference.AlwaysForClarity, NotificationOption.Suggestion); + + private static readonly CodeStyleOption RemoveIfUnnecessaryPreference = + new CodeStyleOption(ParenthesesPreference.NeverIfUnnecessary, NotificationOption.Suggestion); + + private static IEnumerable>> GetAllExceptOtherParenthesesOptions() + { + yield return CodeStyleOptions.ArithmeticBinaryParentheses; + yield return CodeStyleOptions.RelationalBinaryParentheses; + yield return CodeStyleOptions.OtherBinaryParentheses; + } + + protected IDictionary RequireArithmeticBinaryParenthesesForClarity + => GetSingleRequireOption(CodeStyleOptions.ArithmeticBinaryParentheses); + + protected IDictionary RequireRelationalBinaryParenthesesForClarity + => GetSingleRequireOption(CodeStyleOptions.RelationalBinaryParentheses); + + protected IDictionary RequireOtherBinaryParenthesesForClarity + => GetSingleRequireOption(CodeStyleOptions.OtherBinaryParentheses); + + private IEnumerable>> GetAllParenthesesOptions() + => GetAllExceptOtherParenthesesOptions().Concat(CodeStyleOptions.OtherParentheses); + + protected IDictionary IgnoreAllParentheses + => OptionsSet(GetAllParenthesesOptions().Select( + o => SingleOption(o, IgnorePreference)).ToArray()); + + protected IDictionary RemoveAllUnnecessaryParentheses + => OptionsSet(GetAllParenthesesOptions().Select( + o => SingleOption(o, RemoveIfUnnecessaryPreference)).ToArray()); + + protected IDictionary RequireAllParenthesesForClarity + => OptionsSet(GetAllExceptOtherParenthesesOptions() + .Select(o => SingleOption(o, RequireForPrecedenceClarityPreference)) + .Concat(SingleOption(CodeStyleOptions.OtherParentheses, RemoveIfUnnecessaryPreference)).ToArray()); + + private IDictionary GetSingleRequireOption(PerLanguageOption> option) + => OptionsSet(GetAllParenthesesOptions() + .Where(o => o != option) + .Select(o => SingleOption(o, RemoveIfUnnecessaryPreference)) + .Concat(SingleOption(option, RequireForPrecedenceClarityPreference)).ToArray()); + + #endregion + } +} diff --git a/src/EditorFeatures/TestUtilities/Diagnostics/AbstractSuppressionAllCodeTests.cs b/src/EditorFeatures/Test/Diagnostics/AbstractSuppressionAllCodeTests.cs similarity index 100% rename from src/EditorFeatures/TestUtilities/Diagnostics/AbstractSuppressionAllCodeTests.cs rename to src/EditorFeatures/Test/Diagnostics/AbstractSuppressionAllCodeTests.cs diff --git a/src/EditorFeatures/TestUtilities/Diagnostics/AbstractSuppressionDiagnosticTest.cs b/src/EditorFeatures/Test/Diagnostics/AbstractSuppressionDiagnosticTest.cs similarity index 100% rename from src/EditorFeatures/TestUtilities/Diagnostics/AbstractSuppressionDiagnosticTest.cs rename to src/EditorFeatures/Test/Diagnostics/AbstractSuppressionDiagnosticTest.cs diff --git a/src/EditorFeatures/TestUtilities/Diagnostics/FixAllDiagnosticProvider.cs b/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs similarity index 98% rename from src/EditorFeatures/TestUtilities/Diagnostics/FixAllDiagnosticProvider.cs rename to src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs index d57e439688a90..90b6c2b7629ac 100644 --- a/src/EditorFeatures/TestUtilities/Diagnostics/FixAllDiagnosticProvider.cs +++ b/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs @@ -8,7 +8,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.UnitTests.Diagnostics; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics diff --git a/src/EditorFeatures/TestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs b/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs similarity index 61% rename from src/EditorFeatures/TestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs rename to src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs index 2d4d825f9147b..f139cd696fd41 100644 --- a/src/EditorFeatures/TestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs +++ b/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs @@ -2,6 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +extern alias Workspaces; +#endif + using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -11,25 +15,26 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CodeFixes.Suppression; -using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; -using Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics.GenerateType; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; -using Microsoft.CodeAnalysis.GenerateType; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.UnitTests; using Microsoft.CodeAnalysis.UnitTests.Diagnostics; using Roslyn.Test.Utilities; -using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics { +#if CODE_STYLE + using OptionKey = Workspaces::Microsoft.CodeAnalysis.Options.OptionKey; + using FixAllState = Workspaces::Microsoft.CodeAnalysis.CodeFixes.FixAllState; + using Workspaces::Roslyn.Utilities; +#else + using Roslyn.Utilities; +#endif + public abstract partial class AbstractUserDiagnosticTest : AbstractCodeActionOrUserDiagnosticTest { internal abstract Task<(ImmutableArray, ImmutableArray, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( @@ -207,7 +212,7 @@ protected Document GetDocumentAndAnnotatedSpan(TestWorkspace workspace, out stri var fixAllState = GetFixAllState( fixAllProvider, diagnostics, fixer, testDriver, document, scope.Value, equivalenceKey); - var fixAllContext = fixAllState.CreateFixAllContext(new ProgressTracker(), CancellationToken.None); + var fixAllContext = new FixAllContext(fixAllState, new ProgressTracker(), CancellationToken.None); var fixAllFix = await fixAllProvider.GetFixAsync(fixAllContext); // We have collapsed the fixes down to the single fix-all fix, so we just let our @@ -293,158 +298,5 @@ internal async Task TestSpansAsync( Assert.True(expectedTextSpans.SetEquals(actualTextSpans)); } - - internal async Task TestWithMockedGenerateTypeDialog( - string initial, - string languageName, - string typeName, - string expected = null, - bool isMissing = false, - Accessibility accessibility = Accessibility.NotApplicable, - TypeKind typeKind = TypeKind.Class, - string projectName = null, - bool isNewFile = false, - string existingFilename = null, - ImmutableArray newFileFolderContainers = default, - string fullFilePath = null, - string newFileName = null, - string assertClassName = null, - bool checkIfUsingsIncluded = false, - bool checkIfUsingsNotIncluded = false, - string expectedTextWithUsings = null, - string defaultNamespace = "", - bool areFoldersValidIdentifiers = true, - GenerateTypeDialogOptions assertGenerateTypeDialogOptions = null, - IList assertTypeKindPresent = null, - IList assertTypeKindAbsent = null, - bool isCancelled = false) - { - using var testState = GenerateTypeTestState.Create(initial, projectName, typeName, existingFilename, languageName); - - // Initialize the viewModel values - testState.TestGenerateTypeOptionsService.SetGenerateTypeOptions( - accessibility: accessibility, - typeKind: typeKind, - typeName: testState.TypeName, - project: testState.ProjectToBeModified, - isNewFile: isNewFile, - newFileName: newFileName, - folders: newFileFolderContainers, - fullFilePath: fullFilePath, - existingDocument: testState.ExistingDocument, - areFoldersValidIdentifiers: areFoldersValidIdentifiers, - isCancelled: isCancelled); - - testState.TestProjectManagementService.SetDefaultNamespace( - defaultNamespace: defaultNamespace); - - var testOptions = new TestParameters(); - var (diagnostics, actions, _) = await GetDiagnosticAndFixesAsync(testState.Workspace, testOptions); - var generateTypeDiagFixes = diagnostics.SingleOrDefault(df => GenerateTypeTestState.FixIds.Contains(df.Id)); - - if (isMissing) - { - Assert.Empty(actions); - return; - } - - var fixActions = MassageActions(actions); - Assert.NotNull(fixActions); - - // Since the dialog option is always fed as the last CodeAction - var index = fixActions.Count() - 1; - var action = fixActions.ElementAt(index); - - Assert.Equal(action.Title, FeaturesResources.Generate_new_type); - var operations = await action.GetOperationsAsync(CancellationToken.None); - Tuple oldSolutionAndNewSolution = null; - - if (!isNewFile) - { - oldSolutionAndNewSolution = await TestOperationsAsync( - testState.Workspace, expected, operations, - conflictSpans: ImmutableArray.Empty, - renameSpans: ImmutableArray.Empty, - warningSpans: ImmutableArray.Empty, - navigationSpans: ImmutableArray.Empty, - expectedChangedDocumentId: testState.ExistingDocument.Id); - } - else - { - oldSolutionAndNewSolution = await TestAddDocument( - testState.Workspace, - expected, - operations, - projectName != null, - testState.ProjectToBeModified.Id, - newFileFolderContainers, - newFileName); - } - - if (checkIfUsingsIncluded) - { - Assert.NotNull(expectedTextWithUsings); - await TestOperationsAsync(testState.Workspace, expectedTextWithUsings, operations, - conflictSpans: ImmutableArray.Empty, - renameSpans: ImmutableArray.Empty, - warningSpans: ImmutableArray.Empty, - navigationSpans: ImmutableArray.Empty, - expectedChangedDocumentId: testState.InvocationDocument.Id); - } - - if (checkIfUsingsNotIncluded) - { - var oldSolution = oldSolutionAndNewSolution.Item1; - var newSolution = oldSolutionAndNewSolution.Item2; - var changedDocumentIds = SolutionUtilities.GetChangedDocuments(oldSolution, newSolution); - - Assert.False(changedDocumentIds.Contains(testState.InvocationDocument.Id)); - } - - // Added into a different project than the triggering project - if (projectName != null) - { - var appliedChanges = ApplyOperationsAndGetSolution(testState.Workspace, operations); - var newSolution = appliedChanges.Item2; - var triggeredProject = newSolution.GetProject(testState.TriggeredProject.Id); - - // Make sure the Project reference is present - Assert.True(triggeredProject.ProjectReferences.Any(pr => pr.ProjectId == testState.ProjectToBeModified.Id)); - } - - // Assert Option Calculation - if (assertClassName != null) - { - Assert.True(assertClassName == testState.TestGenerateTypeOptionsService.ClassName); - } - - if (assertGenerateTypeDialogOptions != null || assertTypeKindPresent != null || assertTypeKindAbsent != null) - { - var generateTypeDialogOptions = testState.TestGenerateTypeOptionsService.GenerateTypeDialogOptions; - - if (assertGenerateTypeDialogOptions != null) - { - Assert.True(assertGenerateTypeDialogOptions.IsPublicOnlyAccessibility == generateTypeDialogOptions.IsPublicOnlyAccessibility); - Assert.True(assertGenerateTypeDialogOptions.TypeKindOptions == generateTypeDialogOptions.TypeKindOptions); - Assert.True(assertGenerateTypeDialogOptions.IsAttribute == generateTypeDialogOptions.IsAttribute); - } - - if (assertTypeKindPresent != null) - { - foreach (var typeKindPresentEach in assertTypeKindPresent) - { - Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) != 0); - } - } - - if (assertTypeKindAbsent != null) - { - foreach (var typeKindPresentEach in assertTypeKindAbsent) - { - Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) == 0); - } - } - } - } } } diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs b/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs new file mode 100644 index 0000000000000..c521b86eaf07e --- /dev/null +++ b/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs @@ -0,0 +1,176 @@ +// 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.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; +using Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics.GenerateType; +using Microsoft.CodeAnalysis.GenerateType; +using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.UnitTests; +using Roslyn.Utilities; +using Xunit; + +namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics +{ + public abstract partial class AbstractUserDiagnosticTest : AbstractCodeActionOrUserDiagnosticTest + { + internal async Task TestWithMockedGenerateTypeDialog( + string initial, + string languageName, + string typeName, + string expected = null, + bool isMissing = false, + Accessibility accessibility = Accessibility.NotApplicable, + TypeKind typeKind = TypeKind.Class, + string projectName = null, + bool isNewFile = false, + string existingFilename = null, + ImmutableArray newFileFolderContainers = default, + string fullFilePath = null, + string newFileName = null, + string assertClassName = null, + bool checkIfUsingsIncluded = false, + bool checkIfUsingsNotIncluded = false, + string expectedTextWithUsings = null, + string defaultNamespace = "", + bool areFoldersValidIdentifiers = true, + GenerateTypeDialogOptions assertGenerateTypeDialogOptions = null, + IList assertTypeKindPresent = null, + IList assertTypeKindAbsent = null, + bool isCancelled = false) + { + using var testState = GenerateTypeTestState.Create(initial, projectName, typeName, existingFilename, languageName); + + // Initialize the viewModel values + testState.TestGenerateTypeOptionsService.SetGenerateTypeOptions( + accessibility: accessibility, + typeKind: typeKind, + typeName: testState.TypeName, + project: testState.ProjectToBeModified, + isNewFile: isNewFile, + newFileName: newFileName, + folders: newFileFolderContainers, + fullFilePath: fullFilePath, + existingDocument: testState.ExistingDocument, + areFoldersValidIdentifiers: areFoldersValidIdentifiers, + isCancelled: isCancelled); + + testState.TestProjectManagementService.SetDefaultNamespace( + defaultNamespace: defaultNamespace); + + var testOptions = new TestParameters(); + var (diagnostics, actions, _) = await GetDiagnosticAndFixesAsync(testState.Workspace, testOptions); + var generateTypeDiagFixes = diagnostics.SingleOrDefault(df => GenerateTypeTestState.FixIds.Contains(df.Id)); + + if (isMissing) + { + Assert.Empty(actions); + return; + } + + var fixActions = MassageActions(actions); + Assert.False(fixActions.IsDefault); + + // Since the dialog option is always fed as the last CodeAction + var index = fixActions.Count() - 1; + var action = fixActions.ElementAt(index); + + Assert.Equal(action.Title, FeaturesResources.Generate_new_type); + var operations = await action.GetOperationsAsync(CancellationToken.None); + Tuple oldSolutionAndNewSolution = null; + + if (!isNewFile) + { + oldSolutionAndNewSolution = await TestOperationsAsync( + testState.Workspace, expected, operations, + conflictSpans: ImmutableArray.Empty, + renameSpans: ImmutableArray.Empty, + warningSpans: ImmutableArray.Empty, + navigationSpans: ImmutableArray.Empty, + expectedChangedDocumentId: testState.ExistingDocument.Id); + } + else + { + oldSolutionAndNewSolution = await TestAddDocument( + testState.Workspace, + expected, + operations, + projectName != null, + testState.ProjectToBeModified.Id, + newFileFolderContainers, + newFileName); + } + + if (checkIfUsingsIncluded) + { + Assert.NotNull(expectedTextWithUsings); + await TestOperationsAsync(testState.Workspace, expectedTextWithUsings, operations, + conflictSpans: ImmutableArray.Empty, + renameSpans: ImmutableArray.Empty, + warningSpans: ImmutableArray.Empty, + navigationSpans: ImmutableArray.Empty, + expectedChangedDocumentId: testState.InvocationDocument.Id); + } + + if (checkIfUsingsNotIncluded) + { + var oldSolution = oldSolutionAndNewSolution.Item1; + var newSolution = oldSolutionAndNewSolution.Item2; + var changedDocumentIds = SolutionUtilities.GetChangedDocuments(oldSolution, newSolution); + + Assert.False(changedDocumentIds.Contains(testState.InvocationDocument.Id)); + } + + // Added into a different project than the triggering project + if (projectName != null) + { + var appliedChanges = ApplyOperationsAndGetSolution(testState.Workspace, operations); + var newSolution = appliedChanges.Item2; + var triggeredProject = newSolution.GetProject(testState.TriggeredProject.Id); + + // Make sure the Project reference is present + Assert.True(triggeredProject.ProjectReferences.Any(pr => pr.ProjectId == testState.ProjectToBeModified.Id)); + } + + // Assert Option Calculation + if (assertClassName != null) + { + Assert.True(assertClassName == testState.TestGenerateTypeOptionsService.ClassName); + } + + if (assertGenerateTypeDialogOptions != null || assertTypeKindPresent != null || assertTypeKindAbsent != null) + { + var generateTypeDialogOptions = testState.TestGenerateTypeOptionsService.GenerateTypeDialogOptions; + + if (assertGenerateTypeDialogOptions != null) + { + Assert.True(assertGenerateTypeDialogOptions.IsPublicOnlyAccessibility == generateTypeDialogOptions.IsPublicOnlyAccessibility); + Assert.True(assertGenerateTypeDialogOptions.TypeKindOptions == generateTypeDialogOptions.TypeKindOptions); + Assert.True(assertGenerateTypeDialogOptions.IsAttribute == generateTypeDialogOptions.IsAttribute); + } + + if (assertTypeKindPresent != null) + { + foreach (var typeKindPresentEach in assertTypeKindPresent) + { + Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) != 0); + } + } + + if (assertTypeKindAbsent != null) + { + foreach (var typeKindPresentEach in assertTypeKindAbsent) + { + Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) == 0); + } + } + } + } + } +} diff --git a/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj b/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj index 537b1b4702545..9e7a177233ee8 100644 --- a/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj +++ b/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj @@ -78,4 +78,5 @@ + \ No newline at end of file diff --git a/src/EditorFeatures/TestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs b/src/EditorFeatures/Test/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs similarity index 100% rename from src/EditorFeatures/TestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs rename to src/EditorFeatures/Test/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs diff --git a/src/EditorFeatures/TestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs b/src/EditorFeatures/Test/MoveToNamespace/AbstractMoveToNamespaceTests.cs similarity index 100% rename from src/EditorFeatures/TestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs rename to src/EditorFeatures/Test/MoveToNamespace/AbstractMoveToNamespaceTests.cs diff --git a/src/EditorFeatures/TestUtilities/MoveType/AbstractMoveTypeTest.cs b/src/EditorFeatures/Test/MoveType/AbstractMoveTypeTest.cs similarity index 100% rename from src/EditorFeatures/TestUtilities/MoveType/AbstractMoveTypeTest.cs rename to src/EditorFeatures/Test/MoveType/AbstractMoveTypeTest.cs diff --git a/src/EditorFeatures/TestUtilities/PullMemberUp/PullMemberUpCodeActionTest.cs b/src/EditorFeatures/TestUtilities/PullMemberUp/PullMemberUpCodeActionTest.cs deleted file mode 100644 index db345d237a8c0..0000000000000 --- a/src/EditorFeatures/TestUtilities/PullMemberUp/PullMemberUpCodeActionTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis.CodeActions; -using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; - -namespace Microsoft.CodeAnalysis.Test.Utilities.PullMemberUp -{ - public abstract class PullMemberUpCodeActionTest : AbstractCodeActionTest - { - internal Task TestWithPullMemberDialogAsync( - string initialMarkUp, - string expectedResult, - IEnumerable<(string memberName, bool makeAbstract)> selection = null, - string target = null, - int index = 0, - CodeActionPriority? priority = null, - TestParameters parameters = default) - { - var service = new TestPullMemberUpService(selection, target); - - return TestInRegularAndScript1Async( - initialMarkUp, expectedResult, - index, priority, - parameters.WithFixProviderData(service)); - } - } -} diff --git a/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj b/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj index 8919fc867ad40..11769c6bd20f6 100644 --- a/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj +++ b/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj @@ -108,6 +108,12 @@ + + + + + + diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb index 78dfa4c7cda3e..d7a1eb4a077dd 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb @@ -438,7 +438,7 @@ End Class .Value.Replace(vbLf, vbCrLf)) End Function - + Public Async Function TestTuples() As Task @@ -475,7 +475,7 @@ End Namespace") End Function - + Public Async Function TestTupleDeclarationWithNames() As Task @@ -507,7 +507,7 @@ End Namespace") End Function - + Public Async Function TestTupleDeclarationWithSomeNames() As Task @@ -539,7 +539,7 @@ End Namespace") End Function - + Public Async Function TestTupleWith1Arity() As Task @@ -573,7 +573,7 @@ End Structure") End Function - + Public Async Function TestTupleWithInferredNames() As Task Await TestAsync( "Class Program @@ -605,7 +605,7 @@ End Namespace", TestOptions.Regular.WithLanguageVersion(LanguageVersion.VisualBa End Function - + Public Async Function TestTupleWithInferredNames_WithVB15() As Task Await TestAsync( "Class Program diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb index 87e75428a4b81..264681165516e 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb @@ -32,10 +32,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp placeSystemFirst As Boolean, outOfProcess As Boolean) As Task Await TestInRegularAndScript1Async( - initialMarkup, expectedMarkup, index, priority, + initialMarkup, expectedMarkup, index, parameters:=New TestParameters( options:=[Option](GenerationOptions.PlaceSystemNamespaceFirst, placeSystemFirst), - fixProviderData:=outOfProcess)) + fixProviderData:=outOfProcess, + priority:=priority)) End Function End Class diff --git a/src/EditorFeatures/VisualBasicTest/Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj b/src/EditorFeatures/VisualBasicTest/Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj index cdf1c520d4428..fcc1d2d9aa5ff 100644 --- a/src/EditorFeatures/VisualBasicTest/Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj +++ b/src/EditorFeatures/VisualBasicTest/Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj @@ -37,6 +37,7 @@ + @@ -77,10 +78,11 @@ - + + \ No newline at end of file diff --git a/src/EditorFeatures/VisualBasicTest/Utils.vb b/src/EditorFeatures/VisualBasicTest/Utils.vb index d9ba459a327ed..a323d9d310eeb 100644 --- a/src/EditorFeatures/VisualBasicTest/Utils.vb +++ b/src/EditorFeatures/VisualBasicTest/Utils.vb @@ -112,8 +112,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests Private ReadOnly _node As T Sub New(syntaxTree As SyntaxTree, node As T) +#If Not CODE_STYLE Then Contract.ThrowIfNull(syntaxTree) Contract.ThrowIfNull(node) +#End If _tree = syntaxTree _node = node End Sub diff --git a/src/Features/CSharp/Portable/AddImport/CSharpAddImportFeatureService.cs b/src/Features/CSharp/Portable/AddImport/CSharpAddImportFeatureService.cs index 7de530e5853e2..c9048d5bf3d9b 100644 --- a/src/Features/CSharp/Portable/AddImport/CSharpAddImportFeatureService.cs +++ b/src/Features/CSharp/Portable/AddImport/CSharpAddImportFeatureService.cs @@ -15,6 +15,7 @@ using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServices; @@ -374,8 +375,9 @@ private async Task AddImportWorkerAsync( } var addImportService = document.GetLanguageService(); + var generator = SyntaxGenerator.GetGenerator(document); var newRoot = addImportService.AddImports( - semanticModel.Compilation, root, contextNode, newImports, placeSystemNamespaceFirst, cancellationToken); + semanticModel.Compilation, root, contextNode, newImports, generator, placeSystemNamespaceFirst, cancellationToken); return (CompilationUnitSyntax)newRoot; } finally @@ -395,8 +397,9 @@ protected override async Task AddImportAsync( var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); var service = document.GetLanguageService(); + var generator = SyntaxGenerator.GetGenerator(document); var newRoot = service.AddImport( - compilation, root, contextNode, usingDirective, placeSystemNamespaceFirst, cancellationToken); + compilation, root, contextNode, usingDirective, generator, placeSystemNamespaceFirst, cancellationToken); return document.WithSyntaxRoot(newRoot); } @@ -439,6 +442,7 @@ private static (ExternAliasDirectiveSyntax, bool hasExistingImport) GetExternAli SyntaxNode contextNode) { var addImportService = document.GetLanguageService(); + var generator = SyntaxGenerator.GetGenerator(document); var nameSyntax = namespaceOrTypeSymbol.GenerateNameSyntax(); @@ -484,7 +488,7 @@ private static (ExternAliasDirectiveSyntax, bool hasExistingImport) GetExternAli ? usingDirective : usingDirective.WithStaticKeyword(SyntaxFactory.Token(SyntaxKind.StaticKeyword)); - return (usingDirective, addImportService.HasExistingImport(semanticModel.Compilation, root, contextNode, usingDirective)); + return (usingDirective, addImportService.HasExistingImport(semanticModel.Compilation, root, contextNode, usingDirective, generator)); } private NameSyntax RemoveGlobalAliasIfUnnecessary( diff --git a/src/Features/CSharp/Portable/AssignOutParameters/AbstractAssignOutParametersCodeFixProvider.cs b/src/Features/CSharp/Portable/AssignOutParameters/AbstractAssignOutParametersCodeFixProvider.cs index 04c82ecbf8082..f76ec467fc85d 100644 --- a/src/Features/CSharp/Portable/AssignOutParameters/AbstractAssignOutParametersCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/AssignOutParameters/AbstractAssignOutParametersCodeFixProvider.cs @@ -84,7 +84,7 @@ private static SyntaxNode GetContainer(SyntaxNode node) { for (var current = node; current != null; current = current.Parent) { - var parameterList = CSharpSyntaxGenerator.GetParameterList(current); + var parameterList = current.GetParameterList(); if (parameterList != null) { return current; @@ -109,7 +109,7 @@ private static SyntaxNode GetContainer(SyntaxNode node) { var container = group.Key; - var parameterList = CSharpSyntaxGenerator.GetParameterList(container); + var parameterList = container.GetParameterList(); var outParameters = parameterList.Parameters.Select(p => semanticModel.GetDeclaredSymbol(p, cancellationToken)) .Where(p => p?.RefKind == RefKind.Out) diff --git a/src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs b/src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs index 31f9e3cec5981..7c15ecbd3e765 100644 --- a/src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs @@ -77,10 +77,10 @@ protected override Task FixAllAsync( return Task.CompletedTask; } - protected override bool IncludeDiagnosticDuringFixAll(FixAllState state, Diagnostic diagnostic, CancellationToken cancellationToken) + protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) { - var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); - return state.CodeActionEquivalenceKey == GetEquivalenceKey(node); + var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, fixAllContext.CancellationToken); + return fixAllContext.CodeActionEquivalenceKey == GetEquivalenceKey(node); } private static void MakeDeclarationNullable(SyntaxEditor editor, SyntaxNode node, HashSet alreadyHandled) diff --git a/src/Features/CSharp/Portable/CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs b/src/Features/CSharp/Portable/CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs index 9b6fdde883f22..68e330644833a 100644 --- a/src/Features/CSharp/Portable/CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/CodeFixes/Suppression/CSharpSuppressionCodeFixProvider.cs @@ -13,6 +13,7 @@ using Microsoft.CodeAnalysis.CSharp.CodeGeneration; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Simplification; using Microsoft.CodeAnalysis.Text; @@ -97,6 +98,7 @@ protected override SyntaxNode AddGlobalSuppressMessageAttribute( Workspace workspace, Compilation compilation, IAddImportsService addImportsService, + SyntaxGenerator generator, CancellationToken cancellationToken) { var compilationRoot = (CompilationUnitSyntax)newRoot; diff --git a/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj b/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj index 50510663f468b..f34a6e41dc567 100644 --- a/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj +++ b/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj @@ -72,4 +72,6 @@ + + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/Wrapping/SeparatedSyntaxList/CSharpParameterWrapper.cs b/src/Features/CSharp/Portable/Wrapping/SeparatedSyntaxList/CSharpParameterWrapper.cs index e4f7587aa2f8c..9f96c2dd14627 100644 --- a/src/Features/CSharp/Portable/Wrapping/SeparatedSyntaxList/CSharpParameterWrapper.cs +++ b/src/Features/CSharp/Portable/Wrapping/SeparatedSyntaxList/CSharpParameterWrapper.cs @@ -4,6 +4,7 @@ using System.Linq; using Microsoft.CodeAnalysis.CSharp.CodeGeneration; +using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Utilities; @@ -27,7 +28,7 @@ protected override SeparatedSyntaxList GetListItems(BaseParamet => listSyntax.Parameters; protected override BaseParameterListSyntax TryGetApplicableList(SyntaxNode node) - => CSharpSyntaxGenerator.GetParameterList(node); + => node.GetParameterList(); protected override bool PositionIsApplicable( SyntaxNode root, int position, SyntaxNode declaration, BaseParameterListSyntax listSyntax) diff --git a/src/Features/Core/Portable/AddRequiredParentheses/AddRequiredParenthesesCodeFixProvider.cs b/src/Features/Core/Portable/AddRequiredParentheses/AddRequiredParenthesesCodeFixProvider.cs index cb2ac6c8a3b94..a846525dac55b 100644 --- a/src/Features/Core/Portable/AddRequiredParentheses/AddRequiredParenthesesCodeFixProvider.cs +++ b/src/Features/Core/Portable/AddRequiredParentheses/AddRequiredParenthesesCodeFixProvider.cs @@ -29,9 +29,9 @@ public override ImmutableArray FixableDiagnosticIds internal sealed override CodeFixCategory CodeFixCategory => CodeFixCategory.CodeStyle; - protected override bool IncludeDiagnosticDuringFixAll(FixAllState state, Diagnostic diagnostic, CancellationToken cancellationToken) + protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) => diagnostic.Properties.ContainsKey(AddRequiredParenthesesConstants.IncludeInFixAll) && - diagnostic.Properties[AddRequiredParenthesesConstants.EquivalenceKey] == state.CodeActionEquivalenceKey; + diagnostic.Properties[AddRequiredParenthesesConstants.EquivalenceKey] == fixAllContext.CodeActionEquivalenceKey; public override Task RegisterCodeFixesAsync(CodeFixContext context) { diff --git a/src/Features/Core/Portable/AliasAmbiguousType/AbstractAliasAmbiguousTypeCodeFixProvider.cs b/src/Features/Core/Portable/AliasAmbiguousType/AbstractAliasAmbiguousTypeCodeFixProvider.cs index 1e67544827158..4688c2d4d6174 100644 --- a/src/Features/Core/Portable/AliasAmbiguousType/AbstractAliasAmbiguousTypeCodeFixProvider.cs +++ b/src/Features/Core/Portable/AliasAmbiguousType/AbstractAliasAmbiguousTypeCodeFixProvider.cs @@ -54,7 +54,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) codeActionsBuilder.Add(new MyCodeAction(codeActionPreviewText, c => { var aliasDirective = syntaxGenerator.AliasImportDeclaration(typeName, symbol); - var newRoot = addImportService.AddImport(compilation, root, diagnosticNode, aliasDirective, placeSystemNamespaceFirst, cancellationToken); + var newRoot = addImportService.AddImport(compilation, root, diagnosticNode, aliasDirective, syntaxGenerator, placeSystemNamespaceFirst, cancellationToken); return Task.FromResult(document.WithSyntaxRoot(newRoot)); })); } diff --git a/src/Features/Core/Portable/CodeFixes/FixAllOccurrences/FixSomeCodeAction.cs b/src/Features/Core/Portable/CodeFixes/FixAllOccurrences/FixSomeCodeAction.cs index 0de673ffb3e2d..9d854810b1bbf 100644 --- a/src/Features/Core/Portable/CodeFixes/FixAllOccurrences/FixSomeCodeAction.cs +++ b/src/Features/Core/Portable/CodeFixes/FixAllOccurrences/FixSomeCodeAction.cs @@ -42,7 +42,7 @@ internal override Task> ComputeOperationsAsy // Use the new cancellation token instead of the stale one present inside _fixAllContext. return service.GetFixAllOperationsAsync( - FixAllState.CreateFixAllContext(progressTracker, cancellationToken), + new FixAllContext(FixAllState, progressTracker, cancellationToken), _showPreviewChangesDialog); } @@ -56,7 +56,7 @@ internal async override Task GetChangedSolutionAsync( // Use the new cancellation token instead of the stale one present inside _fixAllContext. return await service.GetFixAllChangedSolutionAsync( - FixAllState.CreateFixAllContext(progressTracker, cancellationToken)).ConfigureAwait(false); + new FixAllContext(FixAllState, progressTracker, cancellationToken)).ConfigureAwait(false); } private static bool IsInternalCodeFixProvider(CodeFixProvider fixer) diff --git a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.FixAllProvider.cs b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.FixAllProvider.cs index 1717acec042ac..fbb5791c50aad 100644 --- a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.FixAllProvider.cs +++ b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.FixAllProvider.cs @@ -26,7 +26,7 @@ public async override Task GetFixAsync(FixAllContext fixAllContext) return null; } - var batchFixer = WellKnownFixAllProviders.BatchFixer; + var batchFixer = BatchFixAllProvider.Instance; var suppressionFixer = (AbstractSuppressionCodeFixProvider)((WrapperCodeFixProvider)fixAllContext.CodeFixProvider).SuppressionFixProvider; var isGlobalSuppression = NestedSuppressionCodeAction.IsEquivalenceKeyForGlobalSuppression(fixAllContext.CodeActionEquivalenceKey); if (!isGlobalSuppression) diff --git a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageCodeAction.cs b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageCodeAction.cs index dd2ceb561ebff..bdd37b11ee275 100644 --- a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageCodeAction.cs +++ b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageCodeAction.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.AddImports; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Shared.Extensions; namespace Microsoft.CodeAnalysis.CodeFixes.Suppression @@ -35,9 +36,9 @@ protected override async Task GetChangedSuppressionDocumentAsync(Cance var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var compilation = await suppressionsDoc.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); var addImportsService = suppressionsDoc.GetRequiredLanguageService(); - + var generator = suppressionsDoc.GetRequiredLanguageService(); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute( - suppressionsRoot, _targetSymbol, _suppressMessageAttribute, _diagnostic, workspace, compilation, addImportsService, cancellationToken); + suppressionsRoot, _targetSymbol, _suppressMessageAttribute, _diagnostic, workspace, compilation, addImportsService, generator, cancellationToken); return suppressionsDoc.WithSyntaxRoot(suppressionsRoot); } diff --git a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs index af9f3c024751d..8c0be721adc3c 100644 --- a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs +++ b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs @@ -11,6 +11,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.AddImports; using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; @@ -123,7 +124,7 @@ protected override async Task GetChangedSuppressionDocumentAsync(Cance var suppressionsRoot = await suppressionsDoc.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var compilation = await suppressionsDoc.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); var addImportsService = suppressionsDoc.GetRequiredLanguageService(); - + var generator = suppressionsDoc.GetRequiredLanguageService(); foreach (var kvp in _diagnosticsBySymbol) { var targetSymbol = kvp.Key; @@ -134,7 +135,7 @@ protected override async Task GetChangedSuppressionDocumentAsync(Cance Contract.ThrowIfFalse(!diagnostic.IsSuppressed); suppressionsRoot = Fixer.AddGlobalSuppressMessageAttribute( suppressionsRoot, targetSymbol, _suppressMessageAttribute, diagnostic, - workspace, compilation, addImportsService, cancellationToken); + workspace, compilation, addImportsService, generator, cancellationToken); } } diff --git a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs index c4073ce67f87f..23a656727224c 100644 --- a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs +++ b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionCodeFixProvider.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.AddImports; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.PooledObjects; @@ -55,6 +56,7 @@ protected abstract SyntaxNode AddGlobalSuppressMessageAttribute( Workspace workspace, Compilation compilation, IAddImportsService addImportsService, + SyntaxGenerator generator, CancellationToken cancellationToken); protected abstract SyntaxNode AddLocalSuppressMessageAttribute( diff --git a/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs b/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs index 4923e042dfad4..98a1f06ca3424 100644 --- a/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs +++ b/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs @@ -781,7 +781,8 @@ private async Task AddImportsInContainersAsync( var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - root = addImportService.AddImports(compilation, root, contextLocation, imports, placeSystemNamespaceFirst, cancellationToken); + var generator = document.GetLanguageService(); + root = addImportService.AddImports(compilation, root, contextLocation, imports, generator, placeSystemNamespaceFirst, cancellationToken); document = document.WithSyntaxRoot(root); } diff --git a/src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/AbstractImportCompletionProvider.cs b/src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/AbstractImportCompletionProvider.cs index 1602f7b470f37..6f83f15c933d3 100644 --- a/src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/AbstractImportCompletionProvider.cs +++ b/src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/AbstractImportCompletionProvider.cs @@ -122,12 +122,13 @@ internal override async Task GetChangeAsync(Document document, // Add required using/imports directive. var addImportService = document.GetRequiredLanguageService(); + var generator = document.GetRequiredLanguageService(); var optionSet = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); var placeSystemNamespaceFirst = optionSet.GetOption(GenerationOptions.PlaceSystemNamespaceFirst, document.Project.Language); var compilation = await document.Project.GetRequiredCompilationAsync(cancellationToken).ConfigureAwait(false); var importNode = CreateImport(document, containingNamespace); - var rootWithImport = addImportService.AddImport(compilation, root, addImportContextNode!, importNode, placeSystemNamespaceFirst, cancellationToken); + var rootWithImport = addImportService.AddImport(compilation, root, addImportContextNode!, importNode, generator, placeSystemNamespaceFirst, cancellationToken); var documentWithImport = document.WithSyntaxRoot(rootWithImport); // This only formats the annotated import we just added, not the entire document. var formattedDocumentWithImport = await Formatter.FormatAsync(documentWithImport, Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false); diff --git a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj index 199ee65651c0d..5ce0dcfb2f205 100644 --- a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj +++ b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj @@ -95,7 +95,6 @@ - @@ -124,4 +123,6 @@ + + diff --git a/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeCodeFixProvider.cs b/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeCodeFixProvider.cs index bfe607e9dbfae..e211752069104 100644 --- a/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeCodeFixProvider.cs +++ b/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeCodeFixProvider.cs @@ -63,7 +63,7 @@ protected override async Task FixAllAsync( } } - protected override bool IncludeDiagnosticDuringFixAll(FixAllState state, Diagnostic diagnostic, CancellationToken cancellationToken) + protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) => diagnostic.Properties.ContainsKey(PreferFrameworkTypeConstants.PreferFrameworkType); private class PreferFrameworkTypeCodeAction : CodeAction.DocumentChangeAction diff --git a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs index 4f11337906abf..d9a9bdc618ca3 100644 --- a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs +++ b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs @@ -199,10 +199,10 @@ private static string GetEquivalenceKey(Diagnostic diagnostic) private static bool NeedsToMoveNewLocalDeclarationsNearReference(string diagnosticId) => diagnosticId == IDEDiagnosticIds.ValueAssignedIsUnusedDiagnosticId; - protected override bool IncludeDiagnosticDuringFixAll(FixAllState fixAllState, Diagnostic diagnostic, CancellationToken cancellationToken) + protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) { - return fixAllState.CodeActionEquivalenceKey == GetEquivalenceKey(diagnostic) && - !IsForEachIterationVariableDiagnostic(diagnostic, fixAllState.Document, cancellationToken); + return fixAllContext.CodeActionEquivalenceKey == GetEquivalenceKey(diagnostic) && + !IsForEachIterationVariableDiagnostic(diagnostic, fixAllContext.Document, fixAllContext.CancellationToken); } private IEnumerable> GetDiagnosticsGroupedByMember( diff --git a/src/Features/VisualBasic/Portable/AddImport/VisualBasicAddImportFeatureService.vb b/src/Features/VisualBasic/Portable/AddImport/VisualBasicAddImportFeatureService.vb index 3cf43f0e17be7..f4fd6386a68ca 100644 --- a/src/Features/VisualBasic/Portable/AddImport/VisualBasicAddImportFeatureService.vb +++ b/src/Features/VisualBasic/Portable/AddImport/VisualBasicAddImportFeatureService.vb @@ -8,6 +8,7 @@ Imports Microsoft.CodeAnalysis.AddImport Imports Microsoft.CodeAnalysis.AddImports Imports Microsoft.CodeAnalysis.CaseCorrection Imports Microsoft.CodeAnalysis.Diagnostics +Imports Microsoft.CodeAnalysis.Editing Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageServices @@ -187,9 +188,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.AddImport Dim importsStatement = GetImportsStatement(symbol) Dim addImportService = document.GetLanguageService(Of IAddImportsService) - + Dim generator = SyntaxGenerator.GetGenerator(document) Return ($"Imports {symbol.ToDisplayString()}", - addImportService.HasExistingImport(semanticModel.Compilation, root, root, importsStatement)) + addImportService.HasExistingImport(semanticModel.Compilation, root, root, importsStatement, generator)) End Function Private Function GetImportsStatement(symbol As INamespaceOrTypeSymbol) As ImportsStatementSyntax @@ -288,9 +289,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.AddImport Dim compilation = Await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(False) Dim importService = document.GetLanguageService(Of IAddImportsService) + Dim generator = SyntaxGenerator.GetGenerator(document) Dim root = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False) - Dim newRoot = importService.AddImport(compilation, root, contextNode, importsStatement, placeSystemNamespaceFirst, cancellationToken) + Dim newRoot = importService.AddImport(compilation, root, contextNode, importsStatement, generator, placeSystemNamespaceFirst, cancellationToken) newRoot = newRoot.WithAdditionalAnnotations(CaseCorrector.Annotation, Formatter.Annotation) Dim newDocument = document.WithSyntaxRoot(newRoot) diff --git a/src/Features/VisualBasic/Portable/CodeFixes/Suppression/VisualBasicSuppressionCodeFixProvider.vb b/src/Features/VisualBasic/Portable/CodeFixes/Suppression/VisualBasicSuppressionCodeFixProvider.vb index c5ef04818a959..e9267703ad346 100644 --- a/src/Features/VisualBasic/Portable/CodeFixes/Suppression/VisualBasicSuppressionCodeFixProvider.vb +++ b/src/Features/VisualBasic/Portable/CodeFixes/Suppression/VisualBasicSuppressionCodeFixProvider.vb @@ -8,6 +8,7 @@ Imports System.Threading Imports Microsoft.CodeAnalysis.AddImports Imports Microsoft.CodeAnalysis.CodeFixes Imports Microsoft.CodeAnalysis.CodeFixes.Suppression +Imports Microsoft.CodeAnalysis.Editing Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Simplification Imports Microsoft.CodeAnalysis.Text @@ -137,6 +138,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Suppression workspace As Workspace, compilation As Compilation, addImportsService As IAddImportsService, + generator As SyntaxGenerator, cancellationToken As CancellationToken) As SyntaxNode Dim compilationRoot = DirectCast(newRoot, CompilationUnitSyntax) Dim isFirst = Not compilationRoot.Attributes.Any() diff --git a/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj b/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj index a072b2722024f..446144358e19d 100644 --- a/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj +++ b/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj @@ -75,4 +75,6 @@ + + \ No newline at end of file diff --git a/src/Features/VisualBasic/Portable/SimplifyThisOrMe/VisualBasicSimplifyThisOrMeCodeFixProvider.vb b/src/Features/VisualBasic/Portable/SimplifyThisOrMe/VisualBasicSimplifyThisOrMeCodeFixProvider.vb index 5a8d6d0157580..5c58aea44f901 100644 --- a/src/Features/VisualBasic/Portable/SimplifyThisOrMe/VisualBasicSimplifyThisOrMeCodeFixProvider.vb +++ b/src/Features/VisualBasic/Portable/SimplifyThisOrMe/VisualBasicSimplifyThisOrMeCodeFixProvider.vb @@ -23,24 +23,22 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SimplifyThisOrMe End Function Protected Overrides Function Rewrite(semanticModel As SemanticModel, root As SyntaxNode, memberAccessNodes As ISet(Of MemberAccessExpressionSyntax)) As SyntaxNode - Dim rewriter = New Rewriter(semanticModel, memberAccessNodes) + Dim rewriter = New Rewriter(memberAccessNodes) Return rewriter.Visit(root) End Function Private Class Rewriter Inherits VisualBasicSyntaxRewriter - Private ReadOnly semanticModel As SemanticModel Private ReadOnly memberAccessNodes As ISet(Of MemberAccessExpressionSyntax) - Public Sub New(semanticModel As SemanticModel, memberAccessNodes As ISet(Of MemberAccessExpressionSyntax)) - Me.semanticModel = semanticModel + Public Sub New(memberAccessNodes As ISet(Of MemberAccessExpressionSyntax)) Me.memberAccessNodes = memberAccessNodes End Sub Public Overrides Function VisitMemberAccessExpression(node As MemberAccessExpressionSyntax) As SyntaxNode Return If(memberAccessNodes.Contains(node), - node.GetNameWithTriviaMoved(semanticModel), + node.GetNameWithTriviaMoved(), MyBase.VisitMemberAccessExpression(node)) End Function End Class diff --git a/src/Features/VisualBasic/Portable/Wrapping/SeparatedSyntaxList/VisualBasicParameterWrapper.vb b/src/Features/VisualBasic/Portable/Wrapping/SeparatedSyntaxList/VisualBasicParameterWrapper.vb index 644b8ced3ce08..a79bf96d4a2db 100644 --- a/src/Features/VisualBasic/Portable/Wrapping/SeparatedSyntaxList/VisualBasicParameterWrapper.vb +++ b/src/Features/VisualBasic/Portable/Wrapping/SeparatedSyntaxList/VisualBasicParameterWrapper.vb @@ -25,7 +25,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Wrapping.SeparatedSyntaxList End Function Protected Overrides Function TryGetApplicableList(node As SyntaxNode) As ParameterListSyntax - Return VisualBasicSyntaxGenerator.GetParameterList(node) + Return node.GetParameterList() End Function Protected Overrides Function PositionIsApplicable( diff --git a/src/Interactive/Host/Microsoft.CodeAnalysis.InteractiveHost.csproj b/src/Interactive/Host/Microsoft.CodeAnalysis.InteractiveHost.csproj index 077b928866be9..745d0e2280fec 100644 --- a/src/Interactive/Host/Microsoft.CodeAnalysis.InteractiveHost.csproj +++ b/src/Interactive/Host/Microsoft.CodeAnalysis.InteractiveHost.csproj @@ -36,12 +36,12 @@ - - - - - - + + + + + + diff --git a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj index 312b6858f5fd5..7309918b4ed2f 100644 --- a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj +++ b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj @@ -59,6 +59,12 @@ + + + + + + @@ -68,7 +74,7 @@ True TestResource.resx - + diff --git a/src/VisualStudio/CSharp/Impl/Snippets/SnippetExpansionClient.cs b/src/VisualStudio/CSharp/Impl/Snippets/SnippetExpansionClient.cs index b25e1e7bbbee8..8f0cc8eeccc45 100644 --- a/src/VisualStudio/CSharp/Impl/Snippets/SnippetExpansionClient.cs +++ b/src/VisualStudio/CSharp/Impl/Snippets/SnippetExpansionClient.cs @@ -12,6 +12,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Formatting; @@ -112,8 +113,9 @@ internal override Document AddImports( } var addImportService = document.GetLanguageService(); + var generator = document.GetLanguageService(); var compilation = document.Project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken); - var newRoot = addImportService.AddImports(compilation, root, contextLocation, newUsingDirectives, placeSystemNamespaceFirst, cancellationToken); + var newRoot = addImportService.AddImports(compilation, root, contextLocation, newUsingDirectives, generator, placeSystemNamespaceFirst, cancellationToken); var newDocument = document.WithSyntaxRoot(newRoot); diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs index c2d7538c86f97..23af33ee9e1d8 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs @@ -275,7 +275,7 @@ public override TDeclarationNode AddParameters( CodeGenerationOptions options, CancellationToken cancellationToken) { - var currentParameterList = CSharpSyntaxGenerator.GetParameterList(destination); + var currentParameterList = destination.GetParameterList(); if (currentParameterList == null) { diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs index c23bcf1737d97..bf1ac0dff9428 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs @@ -932,7 +932,7 @@ public override IReadOnlyList GetAttributes(SyntaxNode declaration) { if (!s_declAttributes.TryGetValue(declaration, out var attrs)) { - var tmp = Flatten(GetAttributeLists(declaration).Where(al => !IsReturnAttribute(al)).ToImmutableReadOnlyListOrEmpty()); + var tmp = Flatten(declaration.GetAttributeLists().Where(al => !IsReturnAttribute(al)).ToImmutableReadOnlyListOrEmpty()); attrs = s_declAttributes.GetValue(declaration, _d => tmp); } @@ -946,7 +946,7 @@ public override IReadOnlyList GetReturnAttributes(SyntaxNode declara { if (!s_declReturnAttributes.TryGetValue(declaration, out var attrs)) { - var tmp = Flatten(GetAttributeLists(declaration).Where(al => IsReturnAttribute(al)).ToImmutableReadOnlyListOrEmpty()); + var tmp = Flatten(declaration.GetAttributeLists().Where(al => IsReturnAttribute(al)).ToImmutableReadOnlyListOrEmpty()); attrs = s_declReturnAttributes.GetValue(declaration, _d => tmp); } @@ -978,7 +978,7 @@ private SyntaxNode InsertAttributesInternal(SyntaxNode declaration, int index, I } else { - var lists = GetAttributeLists(declaration); + var lists = declaration.GetAttributeLists(); var newList = lists.AddRange(newAttributes); return WithAttributeLists(declaration, newList); } @@ -1013,7 +1013,7 @@ private SyntaxNode InsertReturnAttributesInternal(SyntaxNode d, int index, IEnum } else { - var lists = GetAttributeLists(d); + var lists = d.GetAttributeLists(); var newList = lists.AddRange(newAttributes); return WithAttributeLists(d, newList); } @@ -1117,16 +1117,6 @@ private static SyntaxNode WithAttributeArgumentList(SyntaxNode declaration, Attr return declaration; } - internal static SyntaxList GetAttributeLists(SyntaxNode declaration) - => declaration switch - { - MemberDeclarationSyntax memberDecl => memberDecl.AttributeLists, - AccessorDeclarationSyntax accessor => accessor.AttributeLists, - ParameterSyntax parameter => parameter.AttributeLists, - CompilationUnitSyntax compilationUnit => compilationUnit.AttributeLists, - _ => default, - }; - private static SyntaxNode WithAttributeLists(SyntaxNode declaration, SyntaxList attributeLists) => declaration switch { @@ -2292,7 +2282,7 @@ private SyntaxNode AsNodeLike(SyntaxNode existingNode, SyntaxNode newNode) public override IReadOnlyList GetParameters(SyntaxNode declaration) { - var list = GetParameterList(declaration); + var list = declaration.GetParameterList(); return list != null ? list.Parameters : declaration is SimpleLambdaExpressionSyntax simpleLambda @@ -2304,7 +2294,7 @@ public override SyntaxNode InsertParameters(SyntaxNode declaration, int index, I { var newParameters = AsParameterList(parameters); - var currentList = GetParameterList(declaration); + var currentList = declaration.GetParameterList(); if (currentList == null) { currentList = declaration.IsKind(SyntaxKind.IndexerDeclaration) @@ -2374,23 +2364,7 @@ public override SyntaxToken VisitToken(SyntaxToken token) } internal override SyntaxNode GetParameterListNode(SyntaxNode declaration) - => GetParameterList(declaration); - - internal static BaseParameterListSyntax GetParameterList(SyntaxNode declaration) - => declaration.Kind() switch - { - SyntaxKind.DelegateDeclaration => ((DelegateDeclarationSyntax)declaration).ParameterList, - SyntaxKind.MethodDeclaration => ((MethodDeclarationSyntax)declaration).ParameterList, - SyntaxKind.OperatorDeclaration => ((OperatorDeclarationSyntax)declaration).ParameterList, - SyntaxKind.ConversionOperatorDeclaration => ((ConversionOperatorDeclarationSyntax)declaration).ParameterList, - SyntaxKind.ConstructorDeclaration => ((ConstructorDeclarationSyntax)declaration).ParameterList, - SyntaxKind.DestructorDeclaration => ((DestructorDeclarationSyntax)declaration).ParameterList, - SyntaxKind.IndexerDeclaration => ((IndexerDeclarationSyntax)declaration).ParameterList, - SyntaxKind.ParenthesizedLambdaExpression => ((ParenthesizedLambdaExpressionSyntax)declaration).ParameterList, - SyntaxKind.LocalFunctionStatement => ((LocalFunctionStatementSyntax)declaration).ParameterList, - SyntaxKind.AnonymousMethodExpression => ((AnonymousMethodExpressionSyntax)declaration).ParameterList, - _ => (BaseParameterListSyntax)null, - }; + => declaration.GetParameterList(); private static SyntaxNode WithParameterList(SyntaxNode declaration, BaseParameterListSyntax list) { diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTokenExtensions_SharedWithCodeStyle.cs b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTokenExtensions_SharedWithCodeStyle.cs deleted file mode 100644 index baad90b19b9cd..0000000000000 --- a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTokenExtensions_SharedWithCodeStyle.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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 Microsoft.CodeAnalysis.Shared.Extensions; - -namespace Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery -{ - internal static partial class SyntaxTokenExtensions - { - public static bool IsLastTokenOfNode(this SyntaxToken token) - where T : SyntaxNode - { - var node = token.GetAncestor(); - return node != null && token == node.GetLastToken(includeZeroWidth: true); - } - } -} diff --git a/src/Workspaces/CSharp/Portable/Extensions/MemberAccessExpressionSyntaxExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/MemberAccessExpressionSyntaxExtensions.cs index 191b542d3afe2..841eb6d060231 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/MemberAccessExpressionSyntaxExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/MemberAccessExpressionSyntaxExtensions.cs @@ -1,4 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// 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.Collections.Generic; using System.Linq; diff --git a/src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs index b167426c1c466..497f5c423b22c 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs @@ -18,275 +18,6 @@ namespace Microsoft.CodeAnalysis.CSharp.Extensions { internal static partial class SemanticModelExtensions { - public static IEnumerable LookupTypeRegardlessOfArity( - this SemanticModel semanticModel, - SyntaxToken name, - CancellationToken cancellationToken) - { - if (name.Parent is ExpressionSyntax expression) - { - var results = semanticModel.LookupName(expression, namespacesAndTypesOnly: true, cancellationToken: cancellationToken); - if (results.Length > 0) - { - return results.OfType(); - } - } - - return SpecializedCollections.EmptyEnumerable(); - } - - public static ImmutableArray LookupName( - this SemanticModel semanticModel, - SyntaxToken name, - bool namespacesAndTypesOnly, - CancellationToken cancellationToken) - { - if (name.Parent is ExpressionSyntax expression) - { - return semanticModel.LookupName(expression, namespacesAndTypesOnly, cancellationToken); - } - - return ImmutableArray.Create(); - } - - /// - /// Decomposes a name or member access expression into its component parts. - /// - /// The name or member access expression. - /// The qualifier (or left-hand-side) of the name expression. This may be null if there is no qualifier. - /// The name of the expression. - /// The number of generic type parameters. - private static void DecomposeName(ExpressionSyntax expression, out ExpressionSyntax qualifier, out string name, out int arity) - { - switch (expression.Kind()) - { - case SyntaxKind.SimpleMemberAccessExpression: - case SyntaxKind.PointerMemberAccessExpression: - var max = (MemberAccessExpressionSyntax)expression; - qualifier = max.Expression; - name = max.Name.Identifier.ValueText; - arity = max.Name.Arity; - break; - case SyntaxKind.QualifiedName: - var qn = (QualifiedNameSyntax)expression; - qualifier = qn.Left; - name = qn.Right.Identifier.ValueText; - arity = qn.Arity; - break; - case SyntaxKind.AliasQualifiedName: - var aq = (AliasQualifiedNameSyntax)expression; - qualifier = aq.Alias; - name = aq.Name.Identifier.ValueText; - arity = aq.Name.Arity; - break; - case SyntaxKind.GenericName: - var gx = (GenericNameSyntax)expression; - qualifier = null; - name = gx.Identifier.ValueText; - arity = gx.Arity; - break; - case SyntaxKind.IdentifierName: - var nx = (IdentifierNameSyntax)expression; - qualifier = null; - name = nx.Identifier.ValueText; - arity = 0; - break; - default: - qualifier = null; - name = null; - arity = 0; - break; - } - } - - public static ImmutableArray LookupName( - this SemanticModel semanticModel, - ExpressionSyntax expression, - bool namespacesAndTypesOnly, - CancellationToken cancellationToken) - { - var expr = SyntaxFactory.GetStandaloneExpression(expression); - DecomposeName(expr, out var qualifier, out var name, out var arity); - - INamespaceOrTypeSymbol symbol = null; - if (qualifier != null) - { - var typeInfo = semanticModel.GetTypeInfo(qualifier, cancellationToken); - var symbolInfo = semanticModel.GetSymbolInfo(qualifier, cancellationToken); - if (typeInfo.Type != null) - { - symbol = typeInfo.Type; - } - else if (symbolInfo.Symbol != null) - { - symbol = symbolInfo.Symbol as INamespaceOrTypeSymbol; - } - } - - return semanticModel.LookupSymbols(expr.SpanStart, container: symbol, name: name, includeReducedExtensionMethods: true); - } - - public static SymbolInfo GetSymbolInfo(this SemanticModel semanticModel, SyntaxToken token) - { - if (!CanBindToken(token)) - { - return default; - } - - switch (token.Parent) - { - case ExpressionSyntax expression: - return semanticModel.GetSymbolInfo(expression); - case AttributeSyntax attribute: - return semanticModel.GetSymbolInfo(attribute); - case ConstructorInitializerSyntax constructorInitializer: - return semanticModel.GetSymbolInfo(constructorInitializer); - } - - return default; - } - - private static bool CanBindToken(SyntaxToken token) - { - // Add more token kinds if necessary; - switch (token.Kind()) - { - case SyntaxKind.CommaToken: - case SyntaxKind.DelegateKeyword: - return false; - } - - return true; - } - - /// - /// Given an argument node, tries to generate an appropriate name that can be used for that - /// argument. - /// - public static string GenerateNameForArgument( - this SemanticModel semanticModel, ArgumentSyntax argument, CancellationToken cancellationToken) - { - // If it named argument then we use the name provided. - if (argument.NameColon != null) - { - return argument.NameColon.Name.Identifier.ValueText; - } - - return semanticModel.GenerateNameForExpression( - argument.Expression, capitalize: false, cancellationToken: cancellationToken); - } - - public static string GenerateNameForArgument( - this SemanticModel semanticModel, AttributeArgumentSyntax argument, CancellationToken cancellationToken) - { - // If it named argument then we use the name provided. - if (argument.NameEquals != null) - { - return argument.NameEquals.Name.Identifier.ValueText; - } - - return semanticModel.GenerateNameForExpression( - argument.Expression, capitalize: false, cancellationToken: cancellationToken); - } - - /// - /// Given an expression node, tries to generate an appropriate name that can be used for - /// that expression. - /// - public static string GenerateNameForExpression( - this SemanticModel semanticModel, ExpressionSyntax expression, - bool capitalize, CancellationToken cancellationToken) - { - // Try to find a usable name node that we can use to name the - // parameter. If we have an expression that has a name as part of it - // then we try to use that part. - var current = expression; - while (true) - { - current = current.WalkDownParentheses(); - - if (current.Kind() == SyntaxKind.IdentifierName) - { - return ((IdentifierNameSyntax)current).Identifier.ValueText.ToCamelCase(); - } - else if (current is MemberAccessExpressionSyntax memberAccess) - { - return memberAccess.Name.Identifier.ValueText.ToCamelCase(); - } - else if (current is MemberBindingExpressionSyntax memberBinding) - { - return memberBinding.Name.Identifier.ValueText.ToCamelCase(); - } - else if (current is ConditionalAccessExpressionSyntax conditionalAccess) - { - current = conditionalAccess.WhenNotNull; - } - else if (current is CastExpressionSyntax castExpression) - { - current = castExpression.Expression; - } - else if (current is DeclarationExpressionSyntax decl) - { - if (!(decl.Designation is SingleVariableDesignationSyntax name)) - { - break; - } - - return name.Identifier.ValueText.ToCamelCase(); - } - else - { - break; - } - } - - // there was nothing in the expression to signify a name. If we're in an argument - // location, then try to choose a name based on the argument name. - var argumentName = TryGenerateNameForArgumentExpression( - semanticModel, expression, cancellationToken); - if (argumentName != null) - { - return capitalize ? argumentName.ToPascalCase() : argumentName.ToCamelCase(); - } - - // Otherwise, figure out the type of the expression and generate a name from that - // instead. - var info = semanticModel.GetTypeInfo(expression, cancellationToken); - - // If we can't determine the type, then fallback to some placeholders. - var type = info.Type; - return type.CreateParameterName(capitalize); - } - - private static string TryGenerateNameForArgumentExpression( - SemanticModel semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken) - { - var topExpression = expression.WalkUpParentheses(); - if (topExpression.IsParentKind(SyntaxKind.Argument)) - { - var argument = (ArgumentSyntax)topExpression.Parent; - if (argument.NameColon != null) - { - return argument.NameColon.Name.Identifier.ValueText; - } - - if (argument.Parent is BaseArgumentListSyntax argumentList) - { - var index = argumentList.Arguments.IndexOf(argument); - if (semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken).Symbol is IMethodSymbol member && index < member.Parameters.Length) - { - var parameter = member.Parameters[index]; - if (parameter.Type.OriginalDefinition.TypeKind != TypeKind.TypeParameter) - { - return parameter.Name; - } - } - } - } - - return null; - } - public static ImmutableArray GenerateParameterNames( this SemanticModel semanticModel, ArgumentListSyntax argumentList, @@ -388,192 +119,5 @@ public static ImmutableArray GenerateParameterNames( return GenerateNames(reservedNames, isFixed, parameterNames, parameterNamingRule); } - - public static ISet GetUsingNamespacesInScope(this SemanticModel semanticModel, SyntaxNode location) - { - // Avoiding linq here for perf reasons. This is used heavily in the AddImport service - var result = new HashSet(); - - foreach (var @using in location.GetEnclosingUsingDirectives()) - { - if (@using.Alias == null) - { - var symbolInfo = semanticModel.GetSymbolInfo(@using.Name); - if (symbolInfo.Symbol != null && symbolInfo.Symbol.Kind == SymbolKind.Namespace) - { - result ??= new HashSet(); - result.Add((INamespaceSymbol)symbolInfo.Symbol); - } - } - } - - return result; - } - - public static Accessibility DetermineAccessibilityConstraint( - this SemanticModel semanticModel, - TypeSyntax type, - CancellationToken cancellationToken) - { - if (type == null) - { - return Accessibility.Private; - } - - type = GetOutermostType(type); - - // Interesting cases based on 3.5.4 Accessibility constraints in the language spec. - // If any of the below hold, then we will override the default accessibility if the - // constraint wants the type to be more accessible. i.e. if by default we generate - // 'internal', but a constraint makes us 'public', then be public. - - // 1) The direct base class of a class type must be at least as accessible as the - // class type itself. - // - // 2) The explicit base interfaces of an interface type must be at least as accessible - // as the interface type itself. - if (type != null) - { - if (type.Parent is BaseTypeSyntax && type.Parent.IsParentKind(SyntaxKind.BaseList) && ((BaseTypeSyntax)type.Parent).Type == type) - { - var containingType = semanticModel.GetDeclaredSymbol(type.GetAncestor(), cancellationToken) as INamedTypeSymbol; - if (containingType != null && containingType.TypeKind == TypeKind.Interface) - { - return containingType.DeclaredAccessibility; - } - else if (((BaseListSyntax)type.Parent.Parent).Types[0] == type.Parent) - { - return containingType.DeclaredAccessibility; - } - } - } - - // 4) The type of a constant must be at least as accessible as the constant itself. - // 5) The type of a field must be at least as accessible as the field itself. - if (type.IsParentKind(SyntaxKind.VariableDeclaration) && - type.Parent.IsParentKind(SyntaxKind.FieldDeclaration)) - { - var variableDeclaration = (VariableDeclarationSyntax)type.Parent; - return semanticModel.GetDeclaredSymbol( - variableDeclaration.Variables[0], cancellationToken).DeclaredAccessibility; - } - - // Also do the same check if we are in an object creation expression - if (type.IsParentKind(SyntaxKind.ObjectCreationExpression) && - type.Parent.IsParentKind(SyntaxKind.EqualsValueClause) && - type.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclarator) && - type.Parent.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclaration) && - type.Parent.Parent.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration)) - { - var variableDeclaration = (VariableDeclarationSyntax)type.Parent.Parent.Parent.Parent; - return semanticModel.GetDeclaredSymbol( - variableDeclaration.Variables[0], cancellationToken).DeclaredAccessibility; - } - - // 3) The return type of a delegate type must be at least as accessible as the - // delegate type itself. - // 6) The return type of a method must be at least as accessible as the method - // itself. - // 7) The type of a property must be at least as accessible as the property itself. - // 8) The type of an event must be at least as accessible as the event itself. - // 9) The type of an indexer must be at least as accessible as the indexer itself. - // 10) The return type of an operator must be at least as accessible as the operator - // itself. - if (type.IsParentKind(SyntaxKind.DelegateDeclaration) || - type.IsParentKind(SyntaxKind.MethodDeclaration) || - type.IsParentKind(SyntaxKind.PropertyDeclaration) || - type.IsParentKind(SyntaxKind.EventDeclaration) || - type.IsParentKind(SyntaxKind.IndexerDeclaration) || - type.IsParentKind(SyntaxKind.OperatorDeclaration)) - { - return semanticModel.GetDeclaredSymbol( - type.Parent, cancellationToken).DeclaredAccessibility; - } - - // 3) The parameter types of a delegate type must be at least as accessible as the - // delegate type itself. - // 6) The parameter types of a method must be at least as accessible as the method - // itself. - // 9) The parameter types of an indexer must be at least as accessible as the - // indexer itself. - // 10) The parameter types of an operator must be at least as accessible as the - // operator itself. - // 11) The parameter types of an instance constructor must be at least as accessible - // as the instance constructor itself. - if (type.IsParentKind(SyntaxKind.Parameter) && type.Parent.IsParentKind(SyntaxKind.ParameterList)) - { - if (type.Parent.Parent.IsParentKind(SyntaxKind.DelegateDeclaration) || - type.Parent.Parent.IsParentKind(SyntaxKind.MethodDeclaration) || - type.Parent.Parent.IsParentKind(SyntaxKind.IndexerDeclaration) || - type.Parent.Parent.IsParentKind(SyntaxKind.OperatorDeclaration)) - { - return semanticModel.GetDeclaredSymbol( - type.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility; - } - - if (type.Parent.Parent.IsParentKind(SyntaxKind.ConstructorDeclaration)) - { - var symbol = semanticModel.GetDeclaredSymbol(type.Parent.Parent.Parent, cancellationToken); - if (!symbol.IsStatic) - { - return symbol.DeclaredAccessibility; - } - } - } - - // 8) The type of an event must be at least as accessible as the event itself. - if (type.IsParentKind(SyntaxKind.VariableDeclaration) && - type.Parent.IsParentKind(SyntaxKind.EventFieldDeclaration)) - { - var variableDeclaration = (VariableDeclarationSyntax)type.Parent; - var symbol = semanticModel.GetDeclaredSymbol(variableDeclaration.Variables[0], cancellationToken); - if (symbol != null) - { - return symbol.DeclaredAccessibility; - } - } - - // Type constraint must be at least as accessible as the declaring member (class, interface, delegate, method) - if (type.IsParentKind(SyntaxKind.TypeConstraint)) - { - return AllContainingTypesArePublicOrProtected(semanticModel, type, cancellationToken) - ? Accessibility.Public - : Accessibility.Internal; - } - - return Accessibility.Private; - } - - public static bool AllContainingTypesArePublicOrProtected( - this SemanticModel semanticModel, - TypeSyntax type, - CancellationToken cancellationToken) - { - if (type == null) - { - return false; - } - - var typeDeclarations = type.GetAncestors(); - - foreach (var typeDeclaration in typeDeclarations) - { - var symbol = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken); - - if (symbol.DeclaredAccessibility == Accessibility.Private || - symbol.DeclaredAccessibility == Accessibility.ProtectedAndInternal || - symbol.DeclaredAccessibility == Accessibility.Internal) - { - return false; - } - } - - return true; - } - - private static TypeSyntax GetOutermostType(TypeSyntax type) - { - return type.GetAncestorsOrThis().Last(); - } } } diff --git a/src/Workspaces/CSharp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs b/src/Workspaces/CSharp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs index 0584957dfee21..e5f76c7155f8d 100644 --- a/src/Workspaces/CSharp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs +++ b/src/Workspaces/CSharp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CSharp.Extensions; -using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Formatting.Rules; diff --git a/src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj b/src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj index 67d7f0a4236be..3b5166a34b459 100644 --- a/src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj +++ b/src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj @@ -62,4 +62,9 @@ + + + + + \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs index 6af0a1d14542f..bf6b9119e31d2 100644 --- a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs +++ b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs @@ -13,6 +13,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; +using Microsoft.CodeAnalysis.CSharp.Simplification; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Utilities; @@ -629,8 +630,7 @@ private SyntaxToken RenameToken(SyntaxToken oldToken, SyntaxToken newToken, stri } else { - var semanticModel = GetSemanticModelForNode(parent, _speculativeModel ?? _semanticModel); - newToken = Simplification.CSharpSimplificationService.TryEscapeIdentifierToken(newToken, parent, semanticModel); + newToken = CSharpSimplificationHelpers.TryEscapeIdentifierToken(newToken, parent); } } diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpCompilationFactoryService.cs b/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpCompilationFactoryService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpCompilationFactoryService.cs rename to src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpCompilationFactoryService.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactory.PathSyntaxReference.cs b/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactory.PathSyntaxReference.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactory.PathSyntaxReference.cs rename to src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactory.PathSyntaxReference.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.NullSyntaxReference.cs b/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactoryService.NullSyntaxReference.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.NullSyntaxReference.cs rename to src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactoryService.NullSyntaxReference.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.cs b/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.cs rename to src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs b/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs rename to src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.cs b/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactoryService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.cs rename to src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpSyntaxTreeFactoryService.cs diff --git a/src/Workspaces/Core/MSBuild/Host/Mef/MSBuildMefHostServices.cs b/src/Workspaces/Core/MSBuild/Host/Mef/MSBuildMefHostServices.cs index 69cfcc1357d52..0da41f02bb1c0 100644 --- a/src/Workspaces/Core/MSBuild/Host/Mef/MSBuildMefHostServices.cs +++ b/src/Workspaces/Core/MSBuild/Host/Mef/MSBuildMefHostServices.cs @@ -46,7 +46,7 @@ private static ImmutableArray CreateDefaultAssemblies() }; return MefHostServices.DefaultAssemblies.Concat( - MefHostServices.LoadNearbyAssemblies(assemblyNames)); + MefHostServicesHelpers.LoadNearbyAssemblies(assemblyNames)); } } } diff --git a/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs b/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs index 928ba3c1a6221..26e0c69bc9521 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs @@ -17,6 +17,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes /// Represents a single fix. This is essentially a tuple /// that holds on to a and the set of /// s that this will fix. + /// /// internal sealed class CodeFix { diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs index dea314a82ca85..9c802dd4bb67d 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs @@ -11,6 +11,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Collections; @@ -24,7 +25,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes /// internal partial class BatchFixAllProvider : FixAllProvider { - public static readonly FixAllProvider Instance = new BatchFixAllProvider(); + public static readonly BatchFixAllProvider Instance = new BatchFixAllProvider(); protected BatchFixAllProvider() { } @@ -46,7 +47,7 @@ public override async Task GetFixAsync(FixAllContext fixAllContext) #endregion - internal override async Task GetFixAsync( + internal async Task GetFixAsync( ImmutableDictionary> documentsAndDiagnosticsToFixMap, FixAllState fixAllState, CancellationToken cancellationToken) { @@ -131,7 +132,7 @@ protected async virtual Task AddDocumentFixesAsync( await Task.WhenAll(fixerTasks).ConfigureAwait(false); } - internal override async Task GetFixAsync( + internal async Task GetFixAsync( ImmutableDictionary> projectsAndDiagnosticsToFixMap, FixAllState fixAllState, CancellationToken cancellationToken) { @@ -217,7 +218,7 @@ public virtual async Task TryGetMergedFixAsync( public virtual string GetFixAllTitle(FixAllState fixAllState) { - return fixAllState.GetDefaultFixAllTitle(); + return FixAllContextHelper.GetDefaultFixAllTitle(fixAllState.Scope, fixAllState.DiagnosticIds, fixAllState.Document, fixAllState.Project); } public virtual async Task TryMergeFixesAsync( diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs index bcf560b95e510..637620051026e 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.GeneratedCodeRecognition; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; @@ -24,8 +25,6 @@ public partial class FixAllContext /// public abstract class DiagnosticProvider { - internal virtual bool IsFixMultiple => false; - /// /// Gets all the diagnostics to fix in the given document in a . /// @@ -42,27 +41,29 @@ public abstract class DiagnosticProvider /// public abstract Task> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken); - internal async Task>> GetDocumentDiagnosticsToFixAsync( - FixAllContext fixAllContext) + internal async Task>> GetDocumentDiagnosticsToFixAsync(FixAllContext fixAllContext) { var result = await GetDocumentDiagnosticsToFixWorkerAsync(fixAllContext).ConfigureAwait(false); // Filter out any documents that we don't have any diagnostics for. return result.Where(kvp => !kvp.Value.IsDefaultOrEmpty).ToImmutableDictionary(); - } - internal virtual async Task>> GetDocumentDiagnosticsToFixWorkerAsync( - FixAllContext fixAllContext) - { - using (Logger.LogBlock( - FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Diagnostics, - FixAllLogger.CreateCorrelationLogMessage(fixAllContext.State.CorrelationId), - fixAllContext.CancellationToken)) + static async Task>> GetDocumentDiagnosticsToFixWorkerAsync(FixAllContext fixAllContext) { - return await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync( - fixAllContext, - fixAllContext.ProgressTracker, - (document, cancellationToken) => document.IsGeneratedCode(cancellationToken)).ConfigureAwait(false); + if (fixAllContext.State.DiagnosticProvider is FixAllState.FixMultipleDiagnosticProvider fixMultipleDiagnosticProvider) + { + return fixMultipleDiagnosticProvider.DocumentDiagnosticsMap; + } + + using (Logger.LogBlock( + FunctionId.CodeFixes_FixAllOccurrencesComputation_Document_Diagnostics, + FixAllLogger.CreateCorrelationLogMessage(fixAllContext.State.CorrelationId), + fixAllContext.CancellationToken)) + { + return await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync( + fixAllContext, + fixAllContext.ProgressTracker).ConfigureAwait(false); + } } } diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllProvider.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllProvider.cs index 633b5ade22e59..1172c4ac27bef 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllProvider.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllProvider.cs @@ -42,19 +42,5 @@ public virtual IEnumerable GetSupportedFixAllDiagnosticIds(CodeFixProvid /// Gets fix all occurrences fix for the given fixAllContext. /// public abstract Task GetFixAsync(FixAllContext fixAllContext); - - internal virtual Task GetFixAsync( - ImmutableDictionary> documentsAndDiagnosticsToFixMap, - FixAllState fixAllState, CancellationToken cancellationToken) - { - return Task.FromResult(null); - } - - internal virtual Task GetFixAsync( - ImmutableDictionary> projectsAndDiagnosticsToFixMap, - FixAllState fixAllState, CancellationToken cancellationToken) - { - return Task.FromResult(null); - } } } diff --git a/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs b/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs index b7ae55e2c0602..d9476c332fe8e 100644 --- a/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs +++ b/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs @@ -44,8 +44,8 @@ public async Task AddImportsAsync( var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(model); var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false); - var addImportsService = document.Project.LanguageServices.GetRequiredService(); - var generator = SyntaxGenerator.GetGenerator(document); + var addImportsService = document.GetRequiredLanguageService(); + var generator = document.GetRequiredLanguageService(); // Create a simple interval tree for simplification spans. var spansTree = new SimpleIntervalTree(new TextSpanIntervalIntrospector(), spans); @@ -90,7 +90,7 @@ public async Task AddImportsAsync( var placeSystemNamespaceFirst = options.GetOption(GenerationOptions.PlaceSystemNamespaceFirst, document.Project.Language); - root = addImportsService.AddImports(model.Compilation, root, context, importDirectivesToAdd, placeSystemNamespaceFirst, cancellationToken); + root = addImportsService.AddImports(model.Compilation, root, context, importDirectivesToAdd, generator, placeSystemNamespaceFirst, cancellationToken); return document.WithSyntaxRoot(root); @@ -173,7 +173,7 @@ CancellationToken cancellationToken var namespaceSyntax = GenerateNamespaceImportDeclaration(namespaceSymbol, generator); - if (addImportsService.HasExistingImport(model.Compilation, root, node, namespaceSyntax)) + if (addImportsService.HasExistingImport(model.Compilation, root, node, namespaceSyntax, generator)) { continue; } @@ -256,7 +256,7 @@ CancellationToken cancellationToken var namespaceSyntax = GenerateNamespaceImportDeclaration(namespaceSymbol, generator); - if (addImportsService.HasExistingImport(model.Compilation, root, annotatedNode, namespaceSyntax)) + if (addImportsService.HasExistingImport(model.Compilation, root, annotatedNode, namespaceSyntax, generator)) { continue; } diff --git a/src/Workspaces/Core/Portable/Extensions/ReportDiagnosticExtensions.cs b/src/Workspaces/Core/Portable/Extensions/ReportDiagnosticExtensions.cs deleted file mode 100644 index dc4c8780d00ef..0000000000000 --- a/src/Workspaces/Core/Portable/Extensions/ReportDiagnosticExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -// 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 Roslyn.Utilities; - -namespace Microsoft.CodeAnalysis -{ - internal static class ReportDiagnosticExtensions - { - public static string ToEditorConfigString(this ReportDiagnostic reportDiagnostic) - { - return reportDiagnostic switch - { - ReportDiagnostic.Suppress => EditorConfigSeverityStrings.None, - ReportDiagnostic.Hidden => EditorConfigSeverityStrings.Silent, - ReportDiagnostic.Info => EditorConfigSeverityStrings.Suggestion, - ReportDiagnostic.Warn => EditorConfigSeverityStrings.Warning, - ReportDiagnostic.Error => EditorConfigSeverityStrings.Error, - _ => throw ExceptionUtilities.UnexpectedValue(reportDiagnostic) - }; - } - } -} diff --git a/src/Workspaces/Core/Portable/LanguageServices/DeclaredSymbolFactoryService/AbstractDeclaredSymbolInfoFactoryService.cs b/src/Workspaces/Core/Portable/LanguageServices/DeclaredSymbolFactoryService/AbstractDeclaredSymbolInfoFactoryService.cs new file mode 100644 index 0000000000000..1a02acd6c6d4c --- /dev/null +++ b/src/Workspaces/Core/Portable/LanguageServices/DeclaredSymbolFactoryService/AbstractDeclaredSymbolInfoFactoryService.cs @@ -0,0 +1,111 @@ +// 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.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading; +using Microsoft.CodeAnalysis.FindSymbols; +using Microsoft.CodeAnalysis.PooledObjects; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Text; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.LanguageServices +{ + internal abstract class AbstractDeclaredSymbolInfoFactoryService : IDeclaredSymbolInfoFactoryService + { + private const string GenericTypeNameManglingString = "`"; + private static readonly string[] s_aritySuffixesOneToNine = { "`1", "`2", "`3", "`4", "`5", "`6", "`7", "`8", "`9" }; + + private readonly static ObjectPool>> s_aliasMapListPool + = SharedPools.Default>>(); + + // Note: these names are stored case insensitively. That way the alias mapping works + // properly for VB. It will mean that our inheritance maps may store more links in them + // for C#. However, that's ok. It will be rare in practice, and all it means is that + // we'll end up examining slightly more types (likely 0) when doing operations like + // Find all references. + private readonly static ObjectPool> s_aliasMapPool + = SharedPools.StringIgnoreCaseDictionary(); + + protected static List> AllocateAliasMapList() + => s_aliasMapListPool.Allocate(); + + protected static void FreeAliasMapList(List> list) + { + if (list != null) + { + foreach (var aliasMap in list) + { + FreeAliasMap(aliasMap); + } + + s_aliasMapListPool.ClearAndFree(list); + } + } + + protected static void FreeAliasMap(Dictionary aliasMap) + { + if (aliasMap != null) + { + s_aliasMapPool.ClearAndFree(aliasMap); + } + } + + protected static Dictionary AllocateAliasMap() + => s_aliasMapPool.Allocate(); + + protected static void AppendTokens(SyntaxNode node, StringBuilder builder) + { + foreach (var child in node.ChildNodesAndTokens()) + { + if (child.IsToken) + { + builder.Append(child.AsToken().Text); + } + else + { + AppendTokens(child.AsNode(), builder); + } + } + } + + protected static void Intern(StringTable stringTable, ArrayBuilder builder) + { + for (int i = 0, n = builder.Count; i < n; i++) + { + builder[i] = stringTable.Add(builder[i]); + } + } + + public static string GetMetadataAritySuffix(int arity) + { + Debug.Assert(arity > 0); + return (arity <= s_aritySuffixesOneToNine.Length) + ? s_aritySuffixesOneToNine[arity - 1] + : string.Concat(GenericTypeNameManglingString, arity.ToString(CultureInfo.InvariantCulture)); + } + + public abstract bool TryGetDeclaredSymbolInfo(StringTable stringTable, SyntaxNode node, string rootNamespace, out DeclaredSymbolInfo declaredSymbolInfo); + + /// + /// Get the name of the target type of specified extension method declaration. + /// The node provided must be an extension method declaration, i.e. calling `TryGetDeclaredSymbolInfo()` + /// on `node` should return a `DeclaredSymbolInfo` of kind `ExtensionMethod`. + /// If the return value is null, then it means this is a "complex" method (as described at ). + /// + public abstract string GetTargetTypeName(SyntaxNode node); + + public abstract bool TryGetAliasesFromUsingDirective(SyntaxNode node, out ImmutableArray<(string aliasName, string name)> aliases); + + public abstract string GetRootNamespace(CompilationOptions compilationOptions); + } +} diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index 524bc035d673b..34f770f14d901 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -26,221 +26,6 @@ - - - Execution\Desktop\DesktopAnalyzerAssemblyLoader.cs - - - Collections\ArrayBuilderExtensions.cs - - - InternalUtilities\BitVector.cs - - - InternalUtilities\Boxes.cs - - - InternalUtilities\ImmutableArrayExtensions.cs - - - Utilities\CompilerUtilities\OrderPreservingMultiDictionary.cs - - - InternalUtilities\AnalyzerAssemblyLoader.cs - - - InternalUtilities\EncodedStringText.cs - - - InternalUtilities\RelativePathResolver.cs - - - InternalUtilities\AssemblyIdentityUtils.cs - - - InternalUtilities\BitArithmeticUtilities.cs - - - InternalUtilities\ArrayExtensions.cs - - - InternalUtilities\CompilerOptionParseUtilities.cs - - - InternalUtilities\ConcurrentSet.cs - - - InternalUtilities\ConsList`1.cs - - - InternalUtilities\Debug.cs - - - InternalUtilities\DecimalUtilities.cs - - - InternalUtilities\DocumentationCommentXmlNames.cs - - - InternalUtilities\EncodingExtensions.cs - - - InternalUtilities\EnumerableExtensions.cs - - - InternalUtilities\EnumUtilties.cs - - - InternalUtilities\FailFast.cs - - - InternalUtilities\FatalError.cs - - - InternalUtilities\FileNameUtilities.cs - - - InternalUtilities\GeneratedCodeUtilities.cs - - - InternalUtilities\Hash.cs - - - InternalUtilities\ImmutableListExtensions.cs - - - InternalUtilities\Index.cs - - - InternalUtilities\ISetExtensions.cs - - - InternalUtilities\KeyValuePairUtil.cs - - - InternalUtilities\MultiDictionary.cs - - - InternalUtilities\OrderedMultiDictionary.cs - - - InternalUtilities\SetWithInsertionOrder.cs - - - InternalUtilities\IReadOnlySet.cs - - - InternalUtilities\PathKind.cs - - - InternalUtilities\ExceptionUtilities.cs - - - InternalUtilities\OneOrMany.cs - - - InternalUtilities\PerformanceSensitiveAttribute.cs - - - InternalUtilities\PlatformInformation.cs - - - InternalUtilities\Range.cs - - - InternalUtilities\ReaderWriterLockSlimExtensions.cs - - - InternalUtilities\ReferenceEqualityComparer.cs - - - InternalUtilities\RoslynString.cs - - - InternalUtilities\SemaphoreSlimExtensions.cs - - - InternalUtilities\SpecializedCollections.cs - - - InternalUtilities\SpecializedCollections.Empty.Collection.cs - - - InternalUtilities\SpecializedCollections.Empty.Dictionary.cs - - - InternalUtilities\SpecializedCollections.Empty.Enumerable.cs - - - InternalUtilities\SpecializedCollections.Empty.Enumerator.cs - - - InternalUtilities\SpecializedCollections.Empty.Enumerator`1.cs - - - InternalUtilities\SpecializedCollections.Empty.List.cs - - - InternalUtilities\SpecializedCollections.Empty.Set.cs - - - InternalUtilities\SpecializedCollections.ReadOnly.Collection.cs - - - InternalUtilities\SpecializedCollections.ReadOnly.Enumerable`1.cs - - - InternalUtilities\SpecializedCollections.ReadOnly.Enumerable`2.cs - - - InternalUtilities\SpecializedCollections.ReadOnly.Set.cs - - - InternalUtilities\SpecializedCollections.Singleton.Collection`1.cs - - - InternalUtilities\SpecializedCollections.Singleton.Enumerator`1.cs - - - InternalUtilities\StackGuard.cs - - - InternalUtilities\StreamExtensions.cs - - - InternalUtilities\StringExtensions.cs - - - - InternalUtilities\TextChangeRangeExtensions.cs - - - InternalUtilities\WeakReferenceExtensions.cs - - - InternalUtilities\FileUtilities.cs - - - InternalUtilities\PathUtilities.cs - - - InternalUtilities\ReflectionUtilities.cs - - - Serialization\ObjectBinderSnapshot.cs - - - Serialization\ObjectReader.cs - - - Serialization\ObjectWriter.cs - - - InternalUtilities\SyntaxTreeExtensions.cs - - - InternalUtilities\NullableAttributes.cs - @@ -338,15 +123,12 @@ - - InternalUtilities\UnicodeCharacterUtilities.cs - - - Serialization\IObjectWritable.cs - - - Serialization\ObjectBinder.cs - + + + + + + True True @@ -365,4 +147,6 @@ + + diff --git a/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs b/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs similarity index 98% rename from src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs rename to src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs index db7219cb7cece..2bfce78a7fb32 100644 --- a/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs +++ b/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs @@ -21,19 +21,8 @@ namespace Microsoft.CodeAnalysis.SemanticModelWorkspaceService { - [ExportWorkspaceServiceFactory(typeof(ISemanticModelService), ServiceLayer.Default), Shared] - internal class SemanticModelWorkspaceServiceFactory : IWorkspaceServiceFactory + internal partial class SemanticModelWorkspaceServiceFactory : IWorkspaceServiceFactory { - [ImportingConstructor] - public SemanticModelWorkspaceServiceFactory() - { - } - - public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) - { - return new SemanticModelService(); - } - private sealed class SemanticModelService : ISemanticModelService { private static readonly ConditionalWeakTable>> s_map = diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/DocumentExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/DocumentExtensions.cs index 2118540023f0f..d1ecd7c89ca94 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/DocumentExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/DocumentExtensions.cs @@ -8,161 +8,18 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.FindSymbols; -using Microsoft.CodeAnalysis.GeneratedCodeRecognition; -using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.SemanticModelWorkspaceService; -using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Shared.Extensions { internal static partial class DocumentExtensions { - // ⚠ Verify IVTs do not use this method before removing it. - public static TLanguageService? GetLanguageService(this Document? document) where TLanguageService : class, ILanguageService - => document?.Project?.LanguageServices?.GetService(); - - public static TLanguageService GetRequiredLanguageService(this Document document) where TLanguageService : class, ILanguageService - => document.Project.LanguageServices.GetRequiredService(); - - public static async Task GetRequiredSemanticModelAsync(this Document document, CancellationToken cancellationToken) - { - var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); - return semanticModel ?? throw new InvalidOperationException(string.Format(WorkspacesResources.SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0, document.Name)); - } - - public static async Task GetRequiredSyntaxTreeAsync(this Document document, CancellationToken cancellationToken) - { - var syntaxTree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); - return syntaxTree ?? throw new InvalidOperationException(string.Format(WorkspacesResources.SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0, document.Name)); - } - - public static async Task GetRequiredSyntaxRootAsync(this Document document, CancellationToken cancellationToken) - { - var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - return root ?? throw new InvalidOperationException(string.Format(WorkspacesResources.SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0, document.Name)); - } - - - public static bool IsOpen(this Document document) - { - var workspace = document.Project.Solution.Workspace as Workspace; - return workspace != null && workspace.IsDocumentOpen(document.Id); - } - - /// - /// this will return either regular semantic model or speculative semantic based on context. - /// any feature that is involved in typing or run on UI thread should use this to take advantage of speculative semantic model - /// whenever possible automatically. - /// - /// when using this API, semantic model should only be used to ask node inside of the given span. - /// otherwise, it might throw if semantic model returned by this API is a speculative semantic model. - /// - /// also, symbols from the semantic model returned by this API might have out of date location information. - /// if exact location (not relative location) is needed from symbol, regular GetSemanticModel should be used. - /// - public static async Task GetSemanticModelForSpanAsync(this Document document, TextSpan span, CancellationToken cancellationToken) - { - Contract.ThrowIfFalse(document.SupportsSemanticModel); - - var syntaxFactService = document.GetLanguageService(); - var semanticModelService = document.Project.Solution.Workspace.Services.GetService(); - if (semanticModelService == null || syntaxFactService == null) - { - return (await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false))!; - } - - var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - Contract.ThrowIfNull(root, "We shouldn't have a null root if the document supports semantic models"); - var token = root.FindToken(span.Start); - if (token.Parent == null) - { - return (await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false))!; - } - - var node = token.Parent.AncestorsAndSelf().First(a => a.FullSpan.Contains(span)); - return await GetSemanticModelForNodeAsync(semanticModelService, syntaxFactService, document, node, span, cancellationToken).ConfigureAwait(false); - } - - /// - /// this will return either regular semantic model or speculative semantic based on context. - /// any feature that is involved in typing or run on UI thread should use this to take advantage of speculative semantic model - /// whenever possible automatically. - /// - /// when using this API, semantic model should only be used to ask node inside of the given node except ones that belong to - /// member signature. otherwise, it might throw if semantic model returned by this API is a speculative semantic model. - /// - /// also, symbols from the semantic model returned by this API might have out of date location information. - /// if exact location (not relative location) is needed from symbol, regular GetSemanticModel should be used. - /// - public static Task GetSemanticModelForNodeAsync(this Document document, SyntaxNode? node, CancellationToken cancellationToken) - { - var syntaxFactService = document.GetLanguageService(); - var semanticModelService = document.Project.Solution.Workspace.Services.GetService(); - if (semanticModelService == null || syntaxFactService == null || node == null) - { - return document.GetSemanticModelAsync(cancellationToken)!; - } - - return GetSemanticModelForNodeAsync(semanticModelService, syntaxFactService, document, node, node.FullSpan, cancellationToken); - } - - private static Task GetSemanticModelForNodeAsync( - ISemanticModelService semanticModelService, ISyntaxFactsService syntaxFactService, - Document document, SyntaxNode node, TextSpan span, CancellationToken cancellationToken) - { - // check whether given span is a valid span to do speculative binding - var speculativeBindingSpan = syntaxFactService.GetMemberBodySpanForSpeculativeBinding(node); - if (!speculativeBindingSpan.Contains(span)) - { - return document.GetSemanticModelAsync(cancellationToken)!; - } - - return semanticModelService.GetSemanticModelForNodeAsync(document, node, cancellationToken); - } - -#if DEBUG - public static async Task HasAnyErrorsAsync(this Document document, CancellationToken cancellationToken, List? ignoreErrorCode = null) - { - var errors = await GetErrorsAsync(document, cancellationToken, ignoreErrorCode).ConfigureAwait(false); - return errors.Length > 0; - } - - public static async Task> GetErrorsAsync(this Document document, CancellationToken cancellationToken, IList? ignoreErrorCode = null) - { - if (!document.SupportsSemanticModel) - { - return ImmutableArray.Empty; - } - - ignoreErrorCode ??= SpecializedCollections.EmptyList(); - var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); - return semanticModel!.GetDiagnostics(cancellationToken: cancellationToken).WhereAsArray( - diag => diag.Severity == DiagnosticSeverity.Error && !ignoreErrorCode.Contains(diag.Id)); - } - - /// - /// Debug only extension method to verify no errors were introduced by formatting, pretty listing and other related document altering service in error-free code. - /// - public static async Task VerifyNoErrorsAsync(this Document newDocument, string message, CancellationToken cancellationToken, List? ignoreErrorCodes = null) - { - var errors = await newDocument.GetErrorsAsync(cancellationToken, ignoreErrorCodes).ConfigureAwait(false); - if (errors.Length > 0) - { - var diagnostics = string.Join(", ", errors.Select(d => d.ToString())); - Debug.Assert(false, message + ". " + diagnostics); - } - } -#endif - public static bool IsFromPrimaryBranch(this Document document) { return document.Project.Solution.BranchId == document.Project.Solution.Workspace.PrimaryBranchId; @@ -222,18 +79,6 @@ public static Task GetSyntaxTreeIndexAsync(this Document docume } } - public static bool IsGeneratedCode(this Document document, CancellationToken cancellationToken) - { - var generatedCodeRecognitionService = document.GetLanguageService(); - return generatedCodeRecognitionService?.IsGeneratedCode(document, cancellationToken) == true; - } - - public static async Task RequireSemanticModelAsync(this Document document, CancellationToken cancellationToken) - { - var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); - return model ?? throw new InvalidOperationException(); - } - internal static Document WithSolutionOptions(this Document document, OptionSet options) => document.Project.Solution.WithOptions(options).GetDocument(document.Id)!; } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs index fa227d5017be2..a53e8eb0968e9 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs @@ -8,19 +8,16 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeGeneration; using Microsoft.CodeAnalysis.LanguageServices; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Utilities; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Shared.Extensions { - internal static class IMethodSymbolExtensions + internal static partial class IMethodSymbolExtensions { public static bool CompatibleSignatureToDelegate(this IMethodSymbol method, INamedTypeSymbol delegateType) { @@ -267,98 +264,5 @@ bool shouldRemoveAttribute(AttributeData a) => p2 = method2.OriginalDefinition.Parameters; return p1.Select(p => p.Type).ToList().AreMoreSpecificThan(p2.Select(p => p.Type).ToList()); } - - public static bool TryGetPredefinedComparisonOperator(this IMethodSymbol symbol, out PredefinedOperator op) - { - if (symbol.MethodKind == MethodKind.BuiltinOperator) - { - op = symbol.GetPredefinedOperator(); - switch (op) - { - case PredefinedOperator.Equality: - case PredefinedOperator.Inequality: - case PredefinedOperator.GreaterThanOrEqual: - case PredefinedOperator.LessThanOrEqual: - case PredefinedOperator.GreaterThan: - case PredefinedOperator.LessThan: - return true; - } - } - else - { - op = PredefinedOperator.None; - } - - return false; - } - - public static PredefinedOperator GetPredefinedOperator(this IMethodSymbol symbol) - { - switch (symbol.Name) - { - case "op_Addition": - case "op_UnaryPlus": - return PredefinedOperator.Addition; - case "op_BitwiseAnd": - return PredefinedOperator.BitwiseAnd; - case "op_BitwiseOr": - return PredefinedOperator.BitwiseOr; - case "op_Concatenate": - return PredefinedOperator.Concatenate; - case "op_Decrement": - return PredefinedOperator.Decrement; - case "op_Division": - return PredefinedOperator.Division; - case "op_Equality": - return PredefinedOperator.Equality; - case "op_ExclusiveOr": - return PredefinedOperator.ExclusiveOr; - case "op_Exponent": - return PredefinedOperator.Exponent; - case "op_GreaterThan": - return PredefinedOperator.GreaterThan; - case "op_GreaterThanOrEqual": - return PredefinedOperator.GreaterThanOrEqual; - case "op_Increment": - return PredefinedOperator.Increment; - case "op_Inequality": - return PredefinedOperator.Inequality; - case "op_IntegerDivision": - return PredefinedOperator.IntegerDivision; - case "op_LeftShift": - return PredefinedOperator.LeftShift; - case "op_LessThan": - return PredefinedOperator.LessThan; - case "op_LessThanOrEqual": - return PredefinedOperator.LessThanOrEqual; - case "op_Like": - return PredefinedOperator.Like; - case "op_LogicalNot": - case "op_OnesComplement": - return PredefinedOperator.Complement; - case "op_Modulus": - return PredefinedOperator.Modulus; - case "op_Multiply": - return PredefinedOperator.Multiplication; - case "op_RightShift": - return PredefinedOperator.RightShift; - case "op_Subtraction": - case "op_UnaryNegation": - return PredefinedOperator.Subtraction; - default: - return PredefinedOperator.None; - } - } - - /// - /// Returns true for void returning methods with two parameters, where - /// the first parameter is of type and the second - /// parameter inherits from or equals type. - /// - public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType) - => eventArgsType != null && - method.Parameters.Length == 2 && - method.Parameters[0].Type.SpecialType == SpecialType.System_Object && - method.Parameters[1].Type.InheritsFromOrEquals(eventArgsType); } } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/INamedTypeSymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/INamedTypeSymbolExtensions.cs index a8cf72653abb5..8f13f7c4cd713 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/INamedTypeSymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/INamedTypeSymbolExtensions.cs @@ -4,487 +4,12 @@ #nullable enable -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Threading; -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeGeneration; -using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Shared.Extensions { internal static partial class INamedTypeSymbolExtensions { - public static IEnumerable GetBaseTypesAndThis(this INamedTypeSymbol? namedType) - { - var current = namedType; - while (current != null) - { - yield return current; - current = current.BaseType; - } - } - - public static IEnumerable GetAllTypeParameters(this INamedTypeSymbol? symbol) - { - var stack = GetContainmentStack(symbol); - return stack.SelectMany(n => n.TypeParameters); - } - - public static IEnumerable GetAllTypeArguments(this INamedTypeSymbol? symbol) - { - var stack = GetContainmentStack(symbol); - return stack.SelectMany(n => n.TypeArguments); - } - - private static Stack GetContainmentStack(INamedTypeSymbol? symbol) - { - var stack = new Stack(); - for (var current = symbol; current != null; current = current.ContainingType) - { - stack.Push(current); - } - - return stack; - } - - public static bool IsContainedWithin([NotNullWhen(returnValue: true)] this INamedTypeSymbol? symbol, INamedTypeSymbol outer) - { - // TODO(cyrusn): Should we be using OriginalSymbol here? - for (var current = symbol; current != null; current = current.ContainingType) - { - if (current.Equals(outer)) - { - return true; - } - } - - return false; - } - - public static ISymbol? FindImplementationForAbstractMember(this INamedTypeSymbol? type, ISymbol symbol) - { - if (symbol.IsAbstract) - { - return type.GetBaseTypesAndThis().SelectMany(t => t.GetMembers(symbol.Name)) - .FirstOrDefault(s => symbol.Equals(GetOverriddenMember(s))); - } - - return null; - } - - internal static ISymbol? GetOverriddenMember(this ISymbol? symbol) - { - switch (symbol) - { - case IMethodSymbol method: return method.OverriddenMethod; - case IPropertySymbol property: return property.OverriddenProperty; - case IEventSymbol @event: return @event.OverriddenEvent; - } - - return null; - } - - private static bool ImplementationExists(INamedTypeSymbol classOrStructType, ISymbol member) - { - return classOrStructType.FindImplementationForInterfaceMember(member) != null; - } - - private static bool IsImplemented( - this INamedTypeSymbol classOrStructType, - ISymbol member, - Func isValidImplementation, - CancellationToken cancellationToken) - { - if (member.ContainingType.TypeKind == TypeKind.Interface) - { - if (member.Kind == SymbolKind.Property) - { - return IsInterfacePropertyImplemented(classOrStructType, (IPropertySymbol)member); - } - else - { - return isValidImplementation(classOrStructType, member); - } - } - - if (member.IsAbstract) - { - if (member.Kind == SymbolKind.Property) - { - return IsAbstractPropertyImplemented(classOrStructType, (IPropertySymbol)member); - } - else - { - return classOrStructType.FindImplementationForAbstractMember(member) != null; - } - } - - return true; - } - - private static bool IsInterfacePropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol) - { - // A property is only fully implemented if both it's setter and getter is implemented. - - return IsAccessorImplemented(propertySymbol.GetMethod, classOrStructType) && IsAccessorImplemented(propertySymbol.SetMethod, classOrStructType); - - // local functions - - static bool IsAccessorImplemented(IMethodSymbol? accessor, INamedTypeSymbol classOrStructType) - { - return accessor == null || !IsImplementable(accessor) || classOrStructType.FindImplementationForInterfaceMember(accessor) != null; - } - } - - private static bool IsAbstractPropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol) - { - // A property is only fully implemented if both it's setter and getter is implemented. - if (propertySymbol.GetMethod != null) - { - if (classOrStructType.FindImplementationForAbstractMember(propertySymbol.GetMethod) == null) - { - return false; - } - } - - if (propertySymbol.SetMethod != null) - { - if (classOrStructType.FindImplementationForAbstractMember(propertySymbol.SetMethod) == null) - { - return false; - } - } - - return true; - } - - private static bool IsExplicitlyImplemented( - this INamedTypeSymbol classOrStructType, - ISymbol member, - Func isValid, - CancellationToken cancellationToken) - { - var implementation = classOrStructType.FindImplementationForInterfaceMember(member); - - if (implementation?.ContainingType.TypeKind == TypeKind.Interface) - { - // Treat all implementations in interfaces as explicit, even the original declaration with implementation. - // There are no implicit interface implementations in derived interfaces and it feels reasonable to treat - // original declaration with implementation as an explicit implementation as well, the implementation is - // explicitly provided after all. All implementations in interfaces will be treated uniformly. - return true; - } - - switch (implementation) - { - case IEventSymbol @event: return @event.ExplicitInterfaceImplementations.Length > 0; - case IMethodSymbol method: return method.ExplicitInterfaceImplementations.Length > 0; - case IPropertySymbol property: return property.ExplicitInterfaceImplementations.Length > 0; - default: return false; - } - } - - public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedMembers( - this INamedTypeSymbol classOrStructType, - IEnumerable interfacesOrAbstractClasses, - CancellationToken cancellationToken) - { - return classOrStructType.GetAllUnimplementedMembers( - interfacesOrAbstractClasses, - IsImplemented, - ImplementationExists, - (INamedTypeSymbol type, ISymbol within) => - { - if (type.TypeKind == TypeKind.Interface) - { - return type.GetMembers().WhereAsArray(m => m.DeclaredAccessibility == Accessibility.Public && - m.Kind != SymbolKind.NamedType && IsImplementable(m) && - !IsPropertyWithNonPublicImplementableAccessor(m)); - } - - return type.GetMembers(); - }, - allowReimplementation: false, - cancellationToken: cancellationToken); - - // local functions - - static bool IsPropertyWithNonPublicImplementableAccessor(ISymbol member) - { - if (member.Kind != SymbolKind.Property) - { - return false; - } - - var property = (IPropertySymbol)member; - - return IsNonPublicImplementableAccessor(property.GetMethod) || IsNonPublicImplementableAccessor(property.SetMethod); - } - - static bool IsNonPublicImplementableAccessor(IMethodSymbol? accessor) - { - return accessor != null && IsImplementable(accessor) && accessor.DeclaredAccessibility != Accessibility.Public; - } - } - - private static bool IsImplementable(ISymbol m) - { - return m.IsVirtual || m.IsAbstract; - } - - public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedMembersInThis( - this INamedTypeSymbol classOrStructType, - IEnumerable interfacesOrAbstractClasses, - CancellationToken cancellationToken) - { - return classOrStructType.GetAllUnimplementedMembers( - interfacesOrAbstractClasses, - IsImplemented, - (t, m) => - { - var implementation = classOrStructType.FindImplementationForInterfaceMember(m); - return implementation != null && Equals(implementation.ContainingType, classOrStructType); - }, - GetMembers, - allowReimplementation: true, - cancellationToken: cancellationToken); - } - - public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedMembersInThis( - this INamedTypeSymbol classOrStructType, - IEnumerable interfacesOrAbstractClasses, - Func> interfaceMemberGetter, - CancellationToken cancellationToken) - { - return classOrStructType.GetAllUnimplementedMembers( - interfacesOrAbstractClasses, - IsImplemented, - (t, m) => - { - var implementation = classOrStructType.FindImplementationForInterfaceMember(m); - return implementation != null && Equals(implementation.ContainingType, classOrStructType); - }, - interfaceMemberGetter, - allowReimplementation: true, - cancellationToken: cancellationToken); - } - - public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedExplicitMembers( - this INamedTypeSymbol classOrStructType, - IEnumerable interfaces, - CancellationToken cancellationToken) - { - return classOrStructType.GetAllUnimplementedMembers( - interfaces, - IsExplicitlyImplemented, - ImplementationExists, - (INamedTypeSymbol type, ISymbol within) => - { - if (type.TypeKind == TypeKind.Interface) - { - return type.GetMembers().WhereAsArray(m => m.Kind != SymbolKind.NamedType && - IsImplementable(m) && m.IsAccessibleWithin(within) && - !IsPropertyWithInaccessibleImplementableAccessor(m, within)); - } - - return type.GetMembers(); - }, - allowReimplementation: false, - cancellationToken: cancellationToken); - - // local functions - - static bool IsPropertyWithInaccessibleImplementableAccessor(ISymbol member, ISymbol within) - { - if (member.Kind != SymbolKind.Property) - { - return false; - } - - var property = (IPropertySymbol)member; - - return IsInaccessibleImplementableAccessor(property.GetMethod, within) || IsInaccessibleImplementableAccessor(property.SetMethod, within); - } - - static bool IsInaccessibleImplementableAccessor(IMethodSymbol? accessor, ISymbol within) - { - return accessor != null && IsImplementable(accessor) && !accessor.IsAccessibleWithin(within); - } - } - - private static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedMembers( - this INamedTypeSymbol classOrStructType, - IEnumerable interfacesOrAbstractClasses, - Func, CancellationToken, bool> isImplemented, - Func isValidImplementation, - Func> interfaceMemberGetter, - bool allowReimplementation, - CancellationToken cancellationToken) - { - Contract.ThrowIfNull(classOrStructType); - Contract.ThrowIfNull(interfacesOrAbstractClasses); - Contract.ThrowIfNull(isImplemented); - - if (classOrStructType.TypeKind != TypeKind.Class && classOrStructType.TypeKind != TypeKind.Struct) - { - return ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)>.Empty; - } - - if (!interfacesOrAbstractClasses.Any()) - { - return ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)>.Empty; - } - - if (!interfacesOrAbstractClasses.All(i => i.TypeKind == TypeKind.Interface) && - !interfacesOrAbstractClasses.All(i => i.IsAbstractClass())) - { - return ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)>.Empty; - } - - var typesToImplement = GetTypesToImplement(classOrStructType, interfacesOrAbstractClasses, allowReimplementation, cancellationToken); - return typesToImplement.SelectAsArray(s => (s, members: GetUnimplementedMembers(classOrStructType, s, isImplemented, isValidImplementation, interfaceMemberGetter, cancellationToken))) - .WhereAsArray(t => t.members.Length > 0); - } - - private static ImmutableArray GetTypesToImplement( - INamedTypeSymbol classOrStructType, - IEnumerable interfacesOrAbstractClasses, - bool allowReimplementation, - CancellationToken cancellationToken) - { - return interfacesOrAbstractClasses.First().TypeKind == TypeKind.Interface - ? GetInterfacesToImplement(classOrStructType, interfacesOrAbstractClasses, allowReimplementation, cancellationToken) - : GetAbstractClassesToImplement(classOrStructType, interfacesOrAbstractClasses); - } - - private static ImmutableArray GetAbstractClassesToImplement( - INamedTypeSymbol classOrStructType, - IEnumerable abstractClasses) - { - return abstractClasses.SelectMany(a => a.GetBaseTypesAndThis()) - .Where(t => t.IsAbstractClass()) - .ToImmutableArray(); - } - - private static ImmutableArray GetInterfacesToImplement( - INamedTypeSymbol classOrStructType, - IEnumerable interfaces, - bool allowReimplementation, - CancellationToken cancellationToken) - { - // We need to not only implement the specified interface, but also everything it - // inherits from. - cancellationToken.ThrowIfCancellationRequested(); - var interfacesToImplement = new List( - interfaces.SelectMany(i => i.GetAllInterfacesIncludingThis()).Distinct()); - - // However, there's no need to re-implement any interfaces that our base types already - // implement. By definition they must contain all the necessary methods. - var baseType = classOrStructType.BaseType; - var alreadyImplementedInterfaces = baseType == null || allowReimplementation - ? SpecializedCollections.EmptyEnumerable() - : baseType.AllInterfaces; - - cancellationToken.ThrowIfCancellationRequested(); - interfacesToImplement.RemoveRange(alreadyImplementedInterfaces); - return interfacesToImplement.ToImmutableArray(); - } - - private static ImmutableArray GetUnimplementedMembers( - this INamedTypeSymbol classOrStructType, - INamedTypeSymbol interfaceType, - Func, CancellationToken, bool> isImplemented, - Func isValidImplementation, - Func> interfaceMemberGetter, - CancellationToken cancellationToken) - { - var q = from m in interfaceMemberGetter(interfaceType, classOrStructType) - where m.Kind != SymbolKind.NamedType - where m.Kind != SymbolKind.Method || ((IMethodSymbol)m).MethodKind == MethodKind.Ordinary - where m.Kind != SymbolKind.Property || ((IPropertySymbol)m).IsIndexer || ((IPropertySymbol)m).CanBeReferencedByName - where m.Kind != SymbolKind.Event || ((IEventSymbol)m).CanBeReferencedByName - where !isImplemented(classOrStructType, m, isValidImplementation, cancellationToken) - select m; - - return q.ToImmutableArray(); - } - - public static IEnumerable GetAttributeNamedParameters( - this INamedTypeSymbol attributeSymbol, - Compilation compilation, - ISymbol within) - { - var systemAttributeType = compilation.AttributeType(); - - foreach (var type in attributeSymbol.GetBaseTypesAndThis()) - { - if (type.Equals(systemAttributeType)) - { - break; - } - - foreach (var member in type.GetMembers()) - { - var namedParameter = IsAttributeNamedParameter(member, within ?? compilation.Assembly); - if (namedParameter != null) - { - yield return namedParameter; - } - } - } - } - - private static ISymbol? IsAttributeNamedParameter( - ISymbol symbol, - ISymbol within) - { - if (!symbol.CanBeReferencedByName || - !symbol.IsAccessibleWithin(within)) - { - return null; - } - - switch (symbol.Kind) - { - case SymbolKind.Field: - var fieldSymbol = (IFieldSymbol)symbol; - if (!fieldSymbol.IsConst && - !fieldSymbol.IsReadOnly && - !fieldSymbol.IsStatic) - { - return fieldSymbol; - } - - break; - - case SymbolKind.Property: - var propertySymbol = (IPropertySymbol)symbol; - if (!propertySymbol.IsReadOnly && - !propertySymbol.IsWriteOnly && - !propertySymbol.IsStatic && - propertySymbol.GetMethod != null && - propertySymbol.SetMethod != null && - propertySymbol.GetMethod.IsAccessibleWithin(within) && - propertySymbol.SetMethod.IsAccessibleWithin(within)) - { - return propertySymbol; - } - - break; - } - - return null; - } - - private static ImmutableArray GetMembers(INamedTypeSymbol type, ISymbol within) - { - return type.GetMembers(); - } - public static INamespaceOrTypeSymbol GenerateRootNamespaceOrType(this INamedTypeSymbol namedType, string[] containers) { INamespaceOrTypeSymbol currentSymbol = namedType; @@ -496,114 +21,5 @@ public static INamespaceOrTypeSymbol GenerateRootNamespaceOrType(this INamedType return currentSymbol; } - - /// - /// Gets the set of members in the inheritance chain of that - /// are overridable. The members will be returned in furthest-base type to closest-base - /// type order. i.e. the overridable members of will be at the start - /// of the list, and the members of the direct parent type of - /// will be at the end of the list. - /// - /// If a member has already been overridden (in or any base type) - /// it will not be included in the list. - /// - public static ImmutableArray GetOverridableMembers( - this INamedTypeSymbol containingType, CancellationToken cancellationToken) - { - // Keep track of the symbols we've seen and what order we saw them in. The - // order allows us to produce the symbols in the end from the furthest base-type - // to the closest base-type - var result = new Dictionary(); - var index = 0; - - if (containingType != null && - !containingType.IsScriptClass && - !containingType.IsImplicitClass && - !containingType.IsStatic) - { - if (containingType.TypeKind == TypeKind.Class || containingType.TypeKind == TypeKind.Struct) - { - var baseTypes = containingType.GetBaseTypes().Reverse(); - foreach (var type in baseTypes) - { - cancellationToken.ThrowIfCancellationRequested(); - - // Prefer overrides in derived classes - RemoveOverriddenMembers(result, type, cancellationToken); - - // Retain overridable methods - AddOverridableMembers(result, containingType, type, ref index, cancellationToken); - } - - // Don't suggest already overridden members - RemoveOverriddenMembers(result, containingType, cancellationToken); - } - } - - return result.Keys.OrderBy(s => result[s]).ToImmutableArray(); - } - - private static void AddOverridableMembers( - Dictionary result, INamedTypeSymbol containingType, - INamedTypeSymbol type, ref int index, CancellationToken cancellationToken) - { - foreach (var member in type.GetMembers()) - { - cancellationToken.ThrowIfCancellationRequested(); - - if (IsOverridable(member, containingType)) - { - result[member] = index++; - } - } - } - - private static bool IsOverridable(ISymbol member, INamedTypeSymbol containingType) - { - if (member.IsAbstract || member.IsVirtual || member.IsOverride) - { - if (member.IsSealed) - { - return false; - } - - if (!member.IsAccessibleWithin(containingType)) - { - return false; - } - - switch (member.Kind) - { - case SymbolKind.Event: - return true; - case SymbolKind.Method: - return ((IMethodSymbol)member).MethodKind == MethodKind.Ordinary; - case SymbolKind.Property: - return !((IPropertySymbol)member).IsWithEvents; - } - } - - return false; - } - - private static void RemoveOverriddenMembers( - Dictionary result, INamedTypeSymbol containingType, CancellationToken cancellationToken) - { - foreach (var member in containingType.GetMembers()) - { - cancellationToken.ThrowIfCancellationRequested(); - - var overriddenMember = member.OverriddenMember(); - if (overriddenMember != null) - { - result.Remove(overriddenMember); - } - } - } - - public static INamedTypeSymbol TryConstruct(this INamedTypeSymbol type, ITypeSymbol[] typeArguments) - { - return typeArguments.Length > 0 ? type.Construct(typeArguments) : type; - } } } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/IParameterSymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/IParameterSymbolExtensions.cs index 2d8f6931b7d3b..57d9d8b7345f7 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/IParameterSymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/IParameterSymbolExtensions.cs @@ -11,20 +11,8 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions { - internal static class IParameterSymbolExtensions + internal static partial class IParameterSymbolExtensions { - public static bool IsRefOrOut(this IParameterSymbol symbol) - { - switch (symbol.RefKind) - { - case RefKind.Ref: - case RefKind.Out: - return true; - default: - return false; - } - } - public static IParameterSymbol RenameParameter(this IParameterSymbol parameter, string parameterName) { return parameter.Name == parameterName diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ISolutionExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/ISolutionExtensions.cs index 5b426ba583190..3c3dafceb2ce9 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ISolutionExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/ISolutionExtensions.cs @@ -39,27 +39,6 @@ public static async Task> GetGlobalNamespacesAs return results.ToImmutableAndFree(); } - public static IEnumerable GetChangedDocuments(this Solution? newSolution, Solution oldSolution) - { - if (newSolution != null) - { - var solutionChanges = newSolution.GetChanges(oldSolution); - - foreach (var projectChanges in solutionChanges.GetProjectChanges()) - { - foreach (var documentId in projectChanges.GetChangedDocuments()) - { - yield return documentId; - } - } - } - } - - public static TextDocument? GetTextDocument(this Solution solution, DocumentId? documentId) - { - return solution.GetDocument(documentId) ?? solution.GetAdditionalDocument(documentId) ?? solution.GetAnalyzerConfigDocument(documentId); - } - public static TextDocumentKind? GetDocumentKind(this Solution solution, DocumentId documentId) { return solution.GetTextDocument(documentId)?.Kind; diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.cs index d472e93ce80eb..1fa463bc82b80 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.cs @@ -10,7 +10,6 @@ using System.Collections.Immutable; using System.ComponentModel; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Threading; @@ -18,7 +17,6 @@ using System.Xml.Linq; using System.Xml.XPath; using Microsoft.CodeAnalysis.Editing; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Utilities; using Roslyn.Utilities; @@ -26,620 +24,15 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions { internal static partial class ISymbolExtensions { - public static string ToNameDisplayString(this ISymbol symbol) - { - return symbol.ToDisplayString(SymbolDisplayFormats.NameFormat); - } - - public static string ToSignatureDisplayString(this ISymbol symbol) - { - return symbol.ToDisplayString(SymbolDisplayFormats.SignatureFormat); - } - - public static bool HasPublicResultantVisibility(this ISymbol symbol) - => symbol.GetResultantVisibility() == SymbolVisibility.Public; - - public static SymbolVisibility GetResultantVisibility(this ISymbol symbol) - { - // Start by assuming it's visible. - var visibility = SymbolVisibility.Public; - - switch (symbol.Kind) - { - case SymbolKind.Alias: - // Aliases are uber private. They're only visible in the same file that they - // were declared in. - return SymbolVisibility.Private; - - case SymbolKind.Parameter: - // Parameters are only as visible as their containing symbol - return GetResultantVisibility(symbol.ContainingSymbol); - - case SymbolKind.TypeParameter: - // Type Parameters are private. - return SymbolVisibility.Private; - } - - while (symbol != null && symbol.Kind != SymbolKind.Namespace) - { - switch (symbol.DeclaredAccessibility) - { - // If we see anything private, then the symbol is private. - case Accessibility.NotApplicable: - case Accessibility.Private: - return SymbolVisibility.Private; - - // If we see anything internal, then knock it down from public to - // internal. - case Accessibility.Internal: - case Accessibility.ProtectedAndInternal: - visibility = SymbolVisibility.Internal; - break; - - // For anything else (Public, Protected, ProtectedOrInternal), the - // symbol stays at the level we've gotten so far. - } - - symbol = symbol.ContainingSymbol; - } - - return visibility; - } - - public static ISymbol? OverriddenMember(this ISymbol symbol) - { - switch (symbol.Kind) - { - case SymbolKind.Event: - return ((IEventSymbol)symbol).OverriddenEvent; - - case SymbolKind.Method: - return ((IMethodSymbol)symbol).OverriddenMethod; - - case SymbolKind.Property: - return ((IPropertySymbol)symbol).OverriddenProperty; - } - - return null; - } - - public static ImmutableArray ExplicitInterfaceImplementations(this ISymbol symbol) - => symbol switch - { - IEventSymbol @event => ImmutableArray.CastUp(@event.ExplicitInterfaceImplementations), - IMethodSymbol method => ImmutableArray.CastUp(method.ExplicitInterfaceImplementations), - IPropertySymbol property => ImmutableArray.CastUp(property.ExplicitInterfaceImplementations), - _ => ImmutableArray.Create(), - }; - - public static ImmutableArray ExplicitOrImplicitInterfaceImplementations(this ISymbol symbol) - { - var containingType = symbol.ContainingType; - var query = from iface in containingType.AllInterfaces - from interfaceMember in iface.GetMembers() - let impl = containingType.FindImplementationForInterfaceMember(interfaceMember) - where symbol.Equals(impl) - select interfaceMember; - return query.ToImmutableArray(); - } - - public static ImmutableArray ImplicitInterfaceImplementations(this ISymbol symbol) - => symbol.ExplicitOrImplicitInterfaceImplementations().Except(symbol.ExplicitInterfaceImplementations()).ToImmutableArray(); - - public static bool IsOverridable([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - // Members can only have overrides if they are virtual, abstract or override and is not - // sealed. - return symbol?.ContainingType?.TypeKind == TypeKind.Class && - (symbol.IsVirtual || symbol.IsAbstract || symbol.IsOverride) && - !symbol.IsSealed; - } - - public static bool IsImplementableMember([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - if (symbol != null && - symbol.ContainingType != null && - symbol.ContainingType.TypeKind == TypeKind.Interface) - { - if (symbol.Kind == SymbolKind.Event) - { - return true; - } - - if (symbol.Kind == SymbolKind.Property) - { - return true; - } - - if (symbol.Kind == SymbolKind.Method) - { - var methodSymbol = (IMethodSymbol)symbol; - if (methodSymbol.MethodKind == MethodKind.Ordinary || - methodSymbol.MethodKind == MethodKind.PropertyGet || - methodSymbol.MethodKind == MethodKind.PropertySet) - { - return true; - } - } - } - - return false; - } - - public static INamedTypeSymbol? GetContainingTypeOrThis(this ISymbol symbol) - { - if (symbol is INamedTypeSymbol namedType) - { - return namedType; - } - - return symbol.ContainingType; - } - - public static bool IsPointerType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol is IPointerTypeSymbol; - } - - public static bool IsErrorType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - => (symbol as ITypeSymbol)?.TypeKind == TypeKind.Error; - - public static bool IsModuleType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as ITypeSymbol)?.IsModuleType() == true; - } - - public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as ITypeSymbol)?.IsInterfaceType() == true; - } - - public static bool IsArrayType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol?.Kind == SymbolKind.ArrayType; - } - - public static bool IsTupleType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as ITypeSymbol)?.IsTupleType ?? false; - } - - public static bool IsAnonymousFunction([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IMethodSymbol)?.MethodKind == MethodKind.AnonymousFunction; - } - - public static bool IsKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, SymbolKind kind) - { - return symbol.MatchesKind(kind); - } - - public static bool MatchesKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, SymbolKind kind) - { - return symbol?.Kind == kind; - } - - public static bool MatchesKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, SymbolKind kind1, SymbolKind kind2) - { - return symbol != null - && (symbol.Kind == kind1 || symbol.Kind == kind2); - } - - public static bool MatchesKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, SymbolKind kind1, SymbolKind kind2, SymbolKind kind3) - { - return symbol != null - && (symbol.Kind == kind1 || symbol.Kind == kind2 || symbol.Kind == kind3); - } - - public static bool MatchesKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, params SymbolKind[] kinds) - { - return symbol != null - && kinds.Contains(symbol.Kind); - } - - public static bool IsReducedExtension([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol is IMethodSymbol && ((IMethodSymbol)symbol).MethodKind == MethodKind.ReducedExtension; - } - - public static bool IsEnumMember([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol?.Kind == SymbolKind.Field && symbol.ContainingType.IsEnumType(); - } - - public static bool IsExtensionMethod(this ISymbol symbol) - { - return symbol.Kind == SymbolKind.Method && ((IMethodSymbol)symbol).IsExtensionMethod; - } - - public static bool IsLocalFunction([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol != null && symbol.Kind == SymbolKind.Method && ((IMethodSymbol)symbol).MethodKind == MethodKind.LocalFunction; - } - - public static bool IsModuleMember([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol != null && symbol.ContainingSymbol is INamedTypeSymbol && symbol.ContainingType.TypeKind == TypeKind.Module; - } - - public static bool IsConstructor([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Constructor; - } - - public static bool IsStaticConstructor([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IMethodSymbol)?.MethodKind == MethodKind.StaticConstructor; - } - - public static bool IsDestructor([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Destructor; - } - - public static bool IsUserDefinedOperator([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IMethodSymbol)?.MethodKind == MethodKind.UserDefinedOperator; - } - - public static bool IsConversion([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Conversion; - } - - public static bool IsOrdinaryMethod([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Ordinary; - } - - public static bool IsOrdinaryMethodOrLocalFunction([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - if (!(symbol is IMethodSymbol method)) - { - return false; - } - - return method.MethodKind == MethodKind.Ordinary - || method.MethodKind == MethodKind.LocalFunction; - } - - public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol is ITypeSymbol && ((ITypeSymbol)symbol).TypeKind == TypeKind.Delegate; - } - - public static bool IsAnonymousType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol is INamedTypeSymbol && ((INamedTypeSymbol)symbol).IsAnonymousType; - } - - public static bool IsNormalAnonymousType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol.IsAnonymousType() && !symbol.IsDelegateType(); - } - - public static bool IsAnonymousDelegateType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol.IsAnonymousType() && symbol.IsDelegateType(); - } - - public static bool IsAnonymousTypeProperty([NotNullWhen(returnValue: true)] this ISymbol? symbol) - => symbol is IPropertySymbol && symbol.ContainingType.IsNormalAnonymousType(); - - public static bool IsTupleField([NotNullWhen(returnValue: true)] this ISymbol? symbol) - => symbol is IFieldSymbol && symbol.ContainingType.IsTupleType; - - public static bool IsIndexer([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IPropertySymbol)?.IsIndexer == true; - } - - public static bool IsWriteableFieldOrProperty([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - switch (symbol) - { - case IFieldSymbol fieldSymbol: - return !fieldSymbol.IsReadOnly && !fieldSymbol.IsConst; - case IPropertySymbol propertySymbol: - return !propertySymbol.IsReadOnly; - } - - return false; - } - - public static ITypeSymbol? GetMemberType(this ISymbol symbol) - { - switch (symbol) - { - case IFieldSymbol fieldSymbol: - return fieldSymbol.Type; - case IPropertySymbol propertySymbol: - return propertySymbol.Type; - case IMethodSymbol methodSymbol: - return methodSymbol.ReturnType; - case IEventSymbol eventSymbol: - return eventSymbol.Type; - } - - return null; - } - - public static int GetArity(this ISymbol symbol) - { - switch (symbol.Kind) - { - case SymbolKind.NamedType: - return ((INamedTypeSymbol)symbol).Arity; - case SymbolKind.Method: - return ((IMethodSymbol)symbol).Arity; - default: - return 0; - } - } - - [return: NotNullIfNotNull(parameterName: "symbol")] - public static ISymbol? GetOriginalUnreducedDefinition(this ISymbol? symbol) - { - if (symbol.IsTupleField()) - { - return symbol; - } - - if (symbol.IsReducedExtension()) - { - // note: ReducedFrom is only a method definition and includes no type arguments. - symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom(); - } - - if (symbol.IsFunctionValue()) - { - if (symbol.ContainingSymbol is IMethodSymbol method) - { - symbol = method; - - if (method.AssociatedSymbol != null) - { - symbol = method.AssociatedSymbol; - } - } - } - - if (symbol.IsNormalAnonymousType() || symbol.IsAnonymousTypeProperty()) - { - return symbol; - } - - if (symbol is IParameterSymbol parameter) - { - var method = parameter.ContainingSymbol as IMethodSymbol; - if (method?.IsReducedExtension() == true) - { - symbol = method.GetConstructedReducedFrom().Parameters[parameter.Ordinal + 1]; - } - } - - return symbol?.OriginalDefinition; - } - - public static bool IsFunctionValue([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol is ILocalSymbol && ((ILocalSymbol)symbol).IsFunctionValue; - } - - public static bool IsThisParameter([NotNullWhen(returnValue: true)] this ISymbol? symbol) - => symbol?.Kind == SymbolKind.Parameter && ((IParameterSymbol)symbol).IsThis; - - [return: NotNullIfNotNull(parameterName: "symbol")] - public static ISymbol? ConvertThisParameterToType(this ISymbol? symbol) - { - if (symbol.IsThisParameter()) - { - return ((IParameterSymbol)symbol).Type; - } - - return symbol; - } - - public static bool IsParams([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - var parameters = symbol.GetParameters(); - return parameters.Length > 0 && parameters[parameters.Length - 1].IsParams; - } - - public static ImmutableArray GetParameters(this ISymbol? symbol) - { - switch (symbol) - { - case IMethodSymbol m: return m.Parameters; - case IPropertySymbol nt: return nt.Parameters; - default: return ImmutableArray.Empty; - } - } - - public static ImmutableArray GetTypeParameters(this ISymbol? symbol) - { - switch (symbol) - { - case IMethodSymbol m: return m.TypeParameters; - case INamedTypeSymbol nt: return nt.TypeParameters; - default: return ImmutableArray.Empty; - } - } - - public static ImmutableArray GetAllTypeParameters(this ISymbol? symbol) - { - var results = ArrayBuilder.GetInstance(); - - while (symbol != null) - { - results.AddRange(symbol.GetTypeParameters()); - symbol = symbol.ContainingType; - } - - return results.ToImmutableAndFree(); - } - - public static ImmutableArray GetTypeArguments(this ISymbol? symbol) - { - switch (symbol) - { - case IMethodSymbol m: return m.TypeArguments; - case INamedTypeSymbol nt: return nt.TypeArguments; - default: return ImmutableArray.Create(); - } - } - - public static ImmutableArray GetAllTypeArguments(this ISymbol symbol) - { - var results = ArrayBuilder.GetInstance(); - results.AddRange(symbol.GetTypeArguments()); - - var containingType = symbol.ContainingType; - while (containingType != null) - { - results.AddRange(containingType.GetTypeArguments()); - containingType = containingType.ContainingType; - } - - return results.ToImmutableAndFree(); - } - - public static bool IsAttribute([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as ITypeSymbol)?.IsAttribute() == true; - } - - /// - /// Returns true if this symbol contains anything unsafe within it. for example - /// List<int*[]> is unsafe, as it "int* Goo { get; }" - /// - public static bool IsUnsafe([NotNullWhen(returnValue: true)] this ISymbol? member) - { - // TODO(cyrusn): Defer to compiler code to handle this once it can. - return member?.Accept(new IsUnsafeVisitor()) == true; - } - - public static ITypeSymbol ConvertToType( - this ISymbol? symbol, - Compilation compilation, - bool extensionUsedAsInstance = false) - { - if (symbol is ITypeSymbol type) - { - return type; - } - - if (symbol is IMethodSymbol method && method.Parameters.All(p => p.RefKind == RefKind.None)) - { - var count = extensionUsedAsInstance ? Math.Max(0, method.Parameters.Length - 1) : method.Parameters.Length; - var skip = extensionUsedAsInstance ? 1 : 0; - - string WithArity(string typeName, int arity) => arity > 0 ? typeName + '`' + arity : typeName; - - // Convert the symbol to Func<...> or Action<...> - var delegateType = compilation.GetTypeByMetadataName(method.ReturnsVoid - ? WithArity("System.Action", count) - : WithArity("System.Func", count + 1)); - - if (delegateType != null) - { - var types = method.Parameters - .Skip(skip) - .Select(p => (p.Type ?? compilation.GetSpecialType(SpecialType.System_Object)).WithNullableAnnotation(p.NullableAnnotation)); - - if (!method.ReturnsVoid) - { - // +1 for the return type. - types = types.Concat((method.ReturnType ?? compilation.GetSpecialType(SpecialType.System_Object)).WithNullableAnnotation(method.ReturnNullableAnnotation)); - } - - return delegateType.TryConstruct(types.ToArray()); - } - } - - // Otherwise, just default to object. - return compilation.ObjectType; - } - - public static bool IsStaticType([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol != null && symbol.Kind == SymbolKind.NamedType && symbol.IsStatic; - } - - public static bool IsNamespace([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol?.Kind == SymbolKind.Namespace; - } - - public static bool IsOrContainsAccessibleAttribute( - [NotNullWhen(returnValue: true)] this ISymbol? symbol, ISymbol withinType, IAssemblySymbol withinAssembly, CancellationToken cancellationToken) - { - var namespaceOrType = symbol is IAliasSymbol alias ? alias.Target : symbol as INamespaceOrTypeSymbol; - if (namespaceOrType == null) - { - return false; - } - - // PERF: Avoid allocating a lambda capture - foreach (var type in namespaceOrType.GetAllTypes(cancellationToken)) - { - if (type.IsAttribute() && type.IsAccessibleWithin(withinType ?? withinAssembly)) - { - return true; - } - } - - return false; - } - - public static IEnumerable GetValidAnonymousTypeProperties(this ISymbol symbol) - { - Contract.ThrowIfFalse(symbol.IsNormalAnonymousType()); - return ((INamedTypeSymbol)symbol).GetMembers().OfType().Where(p => p.CanBeReferencedByName); - } - - public static Accessibility ComputeResultantAccessibility(this ISymbol? symbol, ITypeSymbol finalDestination) - { - if (symbol == null) - { - return Accessibility.Private; - } - - switch (symbol.DeclaredAccessibility) - { - default: - return symbol.DeclaredAccessibility; - case Accessibility.ProtectedAndInternal: - return symbol.ContainingAssembly.GivesAccessTo(finalDestination.ContainingAssembly) - ? Accessibility.ProtectedAndInternal - : Accessibility.Internal; - case Accessibility.ProtectedOrInternal: - return symbol.ContainingAssembly.GivesAccessTo(finalDestination.ContainingAssembly) - ? Accessibility.ProtectedOrInternal - : Accessibility.Protected; - } - } - - /// - /// Returns true if symbol is a local variable and its declaring syntax node is - /// after the current position, false otherwise (including for non-local symbols) - /// - public static bool IsInaccessibleLocal(this ISymbol symbol, int position) + public static DeclarationModifiers GetSymbolModifiers(this ISymbol symbol) { - if (symbol.Kind != SymbolKind.Local) - { - return false; - } - - // Implicitly declared locals (with Option Explicit Off in VB) are scoped to the entire - // method and should always be considered accessible from within the same method. - if (symbol.IsImplicitlyDeclared) - { - return false; - } - - var declarationSyntax = symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault(); - return declarationSyntax != null && position < declarationSyntax.SpanStart; + return new DeclarationModifiers( + isStatic: symbol.IsStatic, + isAbstract: symbol.IsAbstract, + isUnsafe: symbol.IsUnsafe(), + isVirtual: symbol.IsVirtual, + isOverride: symbol.IsOverride, + isSealed: symbol.IsSealed); } /// @@ -847,61 +240,6 @@ private static bool IsBrowsingProhibitedByTypeLibAttributeWorker( return false; } - public static bool IsAccessor([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return symbol.IsPropertyAccessor() || symbol.IsEventAccessor(); - } - - public static bool IsPropertyAccessor([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - return (symbol as IMethodSymbol)?.MethodKind.IsPropertyAccessor() == true; - } - - public static bool IsEventAccessor([NotNullWhen(returnValue: true)] this ISymbol? symbol) - { - var method = symbol as IMethodSymbol; - return method != null && - (method.MethodKind == MethodKind.EventAdd || - method.MethodKind == MethodKind.EventRaise || - method.MethodKind == MethodKind.EventRemove); - } - - public static bool IsFromSource(this ISymbol symbol) - => symbol.Locations.Any() && symbol.Locations.All(location => location.IsInSource); - - public static bool IsNonImplicitAndFromSource(this ISymbol symbol) - => !symbol.IsImplicitlyDeclared && symbol.IsFromSource(); - - public static DeclarationModifiers GetSymbolModifiers(this ISymbol symbol) - { - return new DeclarationModifiers( - isStatic: symbol.IsStatic, - isAbstract: symbol.IsAbstract, - isUnsafe: symbol.IsUnsafe(), - isVirtual: symbol.IsVirtual, - isOverride: symbol.IsOverride, - isSealed: symbol.IsSealed); - } - - public static ITypeSymbol? GetSymbolType(this ISymbol? symbol) - { - switch (symbol) - { - case ILocalSymbol localSymbol: - return localSymbol.Type; - case IFieldSymbol fieldSymbol: - return fieldSymbol.Type; - case IPropertySymbol propertySymbol: - return propertySymbol.Type; - case IParameterSymbol parameterSymbol: - return parameterSymbol.Type; - case IAliasSymbol aliasSymbol: - return aliasSymbol.Target as ITypeSymbol; - } - - return symbol as ITypeSymbol; - } - public static DocumentationComment GetDocumentationComment(this ISymbol symbol, Compilation compilation, CultureInfo? preferredCulture = null, bool expandIncludes = false, bool expandInheritdoc = false, CancellationToken cancellationToken = default) { return GetDocumentationComment(symbol, visitedSymbols: null, compilation, preferredCulture, expandIncludes, expandInheritdoc, cancellationToken); @@ -1287,77 +625,6 @@ private static bool ElementNameIs(XElement element, string name) return string.IsNullOrEmpty(element.Name.NamespaceName) && DocumentationCommentXmlNames.ElementEquals(element.Name.LocalName, name); } - /// - /// If the is a method symbol, returns if the method's return type is "awaitable", but not if it's . - /// If the is a type symbol, returns if that type is "awaitable". - /// An "awaitable" is any type that exposes a GetAwaiter method which returns a valid "awaiter". This GetAwaiter method may be an instance method or an extension method. - /// - public static bool IsAwaitableNonDynamic([NotNullWhen(returnValue: true)] this ISymbol? symbol, SemanticModel semanticModel, int position) - { - var methodSymbol = symbol as IMethodSymbol; - ITypeSymbol? typeSymbol = null; - - if (methodSymbol == null) - { - typeSymbol = symbol as ITypeSymbol; - if (typeSymbol == null) - { - return false; - } - } - else - { - if (methodSymbol.ReturnType == null) - { - return false; - } - } - - // otherwise: needs valid GetAwaiter - var potentialGetAwaiters = semanticModel.LookupSymbols(position, - container: typeSymbol ?? methodSymbol!.ReturnType.OriginalDefinition, - name: WellKnownMemberNames.GetAwaiter, - includeReducedExtensionMethods: true); - var getAwaiters = potentialGetAwaiters.OfType().Where(x => !x.Parameters.Any()); - return getAwaiters.Any(VerifyGetAwaiter); - } - - public static bool IsValidGetAwaiter(this IMethodSymbol symbol) - => symbol.Name == WellKnownMemberNames.GetAwaiter && - VerifyGetAwaiter(symbol); - - private static bool VerifyGetAwaiter(IMethodSymbol getAwaiter) - { - var returnType = getAwaiter.ReturnType; - if (returnType == null) - { - return false; - } - - // bool IsCompleted { get } - if (!returnType.GetMembers().OfType().Any(p => p.Name == WellKnownMemberNames.IsCompleted && p.Type.SpecialType == SpecialType.System_Boolean && p.GetMethod != null)) - { - return false; - } - - var methods = returnType.GetMembers().OfType(); - - // NOTE: (vladres) The current version of C# Spec, §7.7.7.3 'Runtime evaluation of await expressions', requires that - // NOTE: the interface method INotifyCompletion.OnCompleted or ICriticalNotifyCompletion.UnsafeOnCompleted is invoked - // NOTE: (rather than any OnCompleted method conforming to a certain pattern). - // NOTE: Should this code be updated to match the spec? - - // void OnCompleted(Action) - // Actions are delegates, so we'll just check for delegates. - if (!methods.Any(x => x.Name == WellKnownMemberNames.OnCompleted && x.ReturnsVoid && x.Parameters.Length == 1 && x.Parameters.First().Type.TypeKind == TypeKind.Delegate)) - { - return false; - } - - // void GetResult() || T GetResult() - return methods.Any(m => m.Name == WellKnownMemberNames.GetResult && !m.Parameters.Any()); - } - /// /// First, remove symbols from the set if they are overridden by other symbols in the set. /// If a symbol is overridden only by symbols outside of the set, then it is not removed. diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs index a284b7f877af8..5124aa03305f8 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs @@ -4,13 +4,10 @@ #nullable enable -using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -24,78 +21,6 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions { internal static partial class ITypeSymbolExtensions { - private const string DefaultParameterName = "p"; - private const string DefaultBuiltInParameterName = "v"; - - public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type) - => type != null && (type.IsReferenceType || type.IsNullable()); - - public static IList GetAllInterfacesIncludingThis(this ITypeSymbol type) - { - var allInterfaces = type.AllInterfaces; - if (type is INamedTypeSymbol namedType && namedType.TypeKind == TypeKind.Interface && !allInterfaces.Contains(namedType)) - { - var result = new List(allInterfaces.Length + 1); - result.Add(namedType); - result.AddRange(allInterfaces); - return result; - } - - return allInterfaces; - } - - public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - return symbol?.TypeKind == TypeKind.Class && symbol.IsAbstract; - } - - public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - return symbol?.SpecialType == SpecialType.System_Void; - } - - public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - => symbol?.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T; - - public static bool IsNullable( - [NotNullWhen(true)] this ITypeSymbol? symbol, - [NotNullWhen(true)] out ITypeSymbol? underlyingType) - { - if (IsNullable(symbol)) - { - underlyingType = ((INamedTypeSymbol)symbol).TypeArguments[0]; - return true; - } - - underlyingType = null; - return false; - } - - public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - return symbol?.TypeKind == TypeKind.Module; - } - - public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - return symbol?.TypeKind == TypeKind.Interface; - } - - public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - return symbol?.TypeKind == TypeKind.Delegate; - } - - public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - return symbol?.TypeKind == TypeKind.Struct; - } - - public static bool IsAnonymousType([NotNullWhen(returnValue: true)] this INamedTypeSymbol? symbol) - { - return symbol?.IsAnonymousType == true; - } - [return: NotNullIfNotNull(parameterName: "symbol")] public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol) { @@ -241,21 +166,6 @@ public static async Task> FindImplementations } - private static HashSet GetOriginalInterfacesAndTheirBaseInterfaces( - this ITypeSymbol type, - HashSet? symbols = null) - { - symbols ??= new HashSet(SymbolEquivalenceComparer.Instance); - - foreach (var interfaceType in type.Interfaces) - { - symbols.Add(interfaceType.OriginalDefinition); - symbols.AddRange(interfaceType.AllInterfaces.Select(i => i.OriginalDefinition)); - } - - return symbols; - } - public static ISymbol? FindImplementations( this ITypeSymbol typeSymbol, ISymbol constructedInterfaceMember, @@ -311,147 +221,6 @@ from member in baseType.GetMembers(constructedInterfaceMember.Name).OfType GetBaseTypesAndThis(this ITypeSymbol? type) - { - var current = type; - while (current != null) - { - yield return current; - current = current.BaseType; - } - } - - public static IEnumerable GetBaseTypes(this ITypeSymbol type) - { - var current = type.BaseType; - while (current != null) - { - yield return current; - current = current.BaseType; - } - } - - public static IEnumerable GetContainingTypesAndThis(this ITypeSymbol? type) - { - var current = type; - while (current != null) - { - yield return current; - current = current.ContainingType; - } - } - - public static IEnumerable GetContainingTypes(this ITypeSymbol type) - { - var current = type.ContainingType; - while (current != null) - { - yield return current; - current = current.ContainingType; - } - } - - // Determine if "type" inherits from "baseType", ignoring constructed types, optionally including interfaces, - // dealing only with original types. - public static bool InheritsFromOrEquals( - this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces) - { - if (!includeInterfaces) - { - return InheritsFromOrEquals(type, baseType); - } - - return type.GetBaseTypesAndThis().Concat(type.AllInterfaces).Contains(t => SymbolEquivalenceComparer.Instance.Equals(t, baseType)); - } - - // Determine if "type" inherits from "baseType", ignoring constructed types and interfaces, dealing - // only with original types. - public static bool InheritsFromOrEquals( - this ITypeSymbol type, ITypeSymbol baseType) - { - return type.GetBaseTypesAndThis().Contains(t => SymbolEquivalenceComparer.Instance.Equals(t, baseType)); - } - - // Determine if "type" inherits from or implements "baseType", ignoring constructed types, and dealing - // only with original types. - public static bool InheritsFromOrImplementsOrEqualsIgnoringConstruction( - this ITypeSymbol type, ITypeSymbol baseType) - { - var originalBaseType = baseType.OriginalDefinition; - type = type.OriginalDefinition; - - if (SymbolEquivalenceComparer.Instance.Equals(type, originalBaseType)) - { - return true; - } - - IEnumerable baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes(); - return baseTypes.Contains(t => SymbolEquivalenceComparer.Instance.Equals(t.OriginalDefinition, originalBaseType)); - } - - // Determine if "type" inherits from "baseType", ignoring constructed types, and dealing - // only with original types. - public static bool InheritsFromIgnoringConstruction( - this ITypeSymbol type, ITypeSymbol baseType) - { - var originalBaseType = baseType.OriginalDefinition; - - // We could just call GetBaseTypes and foreach over it, but this - // is a hot path in Find All References. This avoid the allocation - // of the enumerator type. - var currentBaseType = type.BaseType; - while (currentBaseType != null) - { - if (SymbolEquivalenceComparer.Instance.Equals(currentBaseType.OriginalDefinition, originalBaseType)) - { - return true; - } - - currentBaseType = currentBaseType.BaseType; - } - - return false; - } - - public static bool ImplementsIgnoringConstruction( - this ITypeSymbol type, ITypeSymbol interfaceType) - { - var originalInterfaceType = interfaceType.OriginalDefinition; - return type.AllInterfaces.Any(t => SymbolEquivalenceComparer.Instance.Equals(t.OriginalDefinition, originalInterfaceType)); - } - - public static bool Implements( - this ITypeSymbol type, ITypeSymbol interfaceType) - { - return type.AllInterfaces.Contains(t => SymbolEquivalenceComparer.Instance.Equals(t, interfaceType)); - } - - public static bool IsAttribute(this ITypeSymbol symbol) - { - for (var b = symbol.BaseType; b != null; b = b.BaseType) - { - if (b.MetadataName == "Attribute" && - b.ContainingType == null && - b.ContainingNamespace != null && - b.ContainingNamespace.Name == "System" && - b.ContainingNamespace.ContainingNamespace != null && - b.ContainingNamespace.ContainingNamespace.IsGlobalNamespace) - { - return true; - } - } - - return false; - } - - public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - return symbol?.MetadataName == "FormattableString" - && symbol.ContainingType == null - && symbol.ContainingNamespace?.Name == "System" - && symbol.ContainingNamespace.ContainingNamespace?.IsGlobalNamespace == true; - } - [return: NotNullIfNotNull(parameterName: "type")] public static ITypeSymbol? RemoveUnavailableTypeParameters( this ITypeSymbol? type, @@ -534,467 +303,5 @@ public static IList GetReferencedTypeParameters( { return type?.Accept(new SubstituteTypesVisitor(mapping, typeGenerator)); } - - public static bool IsUnexpressibleTypeParameterConstraint(this ITypeSymbol typeSymbol) - { - if (typeSymbol.IsSealed || typeSymbol.IsValueType) - { - return true; - } - - switch (typeSymbol.TypeKind) - { - case TypeKind.Array: - case TypeKind.Delegate: - return true; - } - - switch (typeSymbol.SpecialType) - { - case SpecialType.System_Array: - case SpecialType.System_Delegate: - case SpecialType.System_MulticastDelegate: - case SpecialType.System_Enum: - case SpecialType.System_ValueType: - return true; - } - - return false; - } - - public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type) - { - if (type != null) - { - switch (type.SpecialType) - { - case SpecialType.System_Byte: - case SpecialType.System_SByte: - case SpecialType.System_Int16: - case SpecialType.System_UInt16: - case SpecialType.System_Int32: - case SpecialType.System_UInt32: - case SpecialType.System_Int64: - case SpecialType.System_UInt64: - case SpecialType.System_Single: - case SpecialType.System_Double: - case SpecialType.System_Decimal: - return true; - } - } - - return false; - } - - public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol) - { - return typeSymbol.Accept(MinimalAccessibilityVisitor.Instance); - } - - public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - switch (symbol) - { - case IArrayTypeSymbol a: return ContainsAnonymousType(a.ElementType); - case IPointerTypeSymbol p: return ContainsAnonymousType(p.PointedAtType); - case INamedTypeSymbol n: return ContainsAnonymousType(n); - default: return false; - } - } - - private static bool ContainsAnonymousType(INamedTypeSymbol type) - { - if (type.IsAnonymousType) - { - return true; - } - - foreach (var typeArg in type.GetAllTypeArguments()) - { - if (ContainsAnonymousType(typeArg)) - { - return true; - } - } - - return false; - } - - public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false) - { - while (true) - { - switch (type) - { - case IArrayTypeSymbol arrayType: - type = arrayType.ElementType; - continue; - case IPointerTypeSymbol pointerType: - type = pointerType.PointedAtType; - continue; - } - - break; - } - - var shortName = GetParameterName(type); - return capitalize ? shortName.ToPascalCase() : shortName.ToCamelCase(); - } - - private static string GetParameterName(ITypeSymbol? type) - { - if (type == null || type.IsAnonymousType() || type.IsTupleType) - { - return DefaultParameterName; - } - - if (type.IsSpecialType() || type.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T) - { - return DefaultBuiltInParameterName; - } - - var shortName = type.GetShortName(); - return shortName.Length == 0 - ? DefaultParameterName - : shortName; - } - - public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) - { - if (symbol != null) - { - switch (symbol.SpecialType) - { - case SpecialType.System_Object: - case SpecialType.System_Void: - case SpecialType.System_Boolean: - case SpecialType.System_SByte: - case SpecialType.System_Byte: - case SpecialType.System_Decimal: - case SpecialType.System_Single: - case SpecialType.System_Double: - case SpecialType.System_Int16: - case SpecialType.System_Int32: - case SpecialType.System_Int64: - case SpecialType.System_Char: - case SpecialType.System_String: - case SpecialType.System_UInt16: - case SpecialType.System_UInt32: - case SpecialType.System_UInt64: - return true; - } - } - - return false; - } - - public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within) - { - return - typeSymbol.AllInterfaces.Any(i => i.SpecialType == SpecialType.System_Collections_IEnumerable) && - typeSymbol.GetBaseTypesAndThis() - .Union(typeSymbol.GetOriginalInterfacesAndTheirBaseInterfaces()) - .SelectAccessibleMembers(WellKnownMemberNames.CollectionInitializerAddMethodName, within ?? typeSymbol) - .OfType() - .Any(m => m.Parameters.Any()); - } - - public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation) - { - if (typeSymbol != null) - { - var expressionOfT = compilation.ExpressionOfTType(); - if (typeSymbol.OriginalDefinition.Equals(expressionOfT)) - { - var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0]; - return typeArgument as INamedTypeSymbol; - } - - if (typeSymbol.IsDelegateType()) - { - return typeSymbol as INamedTypeSymbol; - } - } - - return null; - } - - public static IEnumerable GetAccessibleMembersInBaseTypes(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol - { - if (containingType == null) - { - return SpecializedCollections.EmptyEnumerable(); - } - - var types = containingType.GetBaseTypes(); - return types.SelectMany(x => x.GetMembers().OfType().Where(m => m.IsAccessibleWithin(within))); - } - - public static ImmutableArray GetAccessibleMembersInThisAndBaseTypes(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol - { - if (containingType == null) - { - return ImmutableArray.Empty; - } - - return containingType.GetBaseTypesAndThis().SelectAccessibleMembers(within).ToImmutableArray(); - } - - public static bool? AreMoreSpecificThan(this IList t1, IList t2) - { - if (t1.Count != t2.Count) - { - return null; - } - - // For t1 to be more specific than t2, it has to be not less specific in every member, - // and more specific in at least one. - - bool? result = null; - for (var i = 0; i < t1.Count; ++i) - { - var r = t1[i].IsMoreSpecificThan(t2[i]); - if (r == null) - { - // We learned nothing. Do nothing. - } - else if (result == null) - { - // We have found the first more specific type. See if - // all the rest on this side are not less specific. - result = r; - } - else if (result != r) - { - // We have more specific types on both left and right, so we - // cannot succeed in picking a better type list. Bail out now. - return null; - } - } - - return result; - } - - private static IEnumerable SelectAccessibleMembers(this IEnumerable? types, ISymbol within) where T : class, ISymbol - { - if (types == null) - { - return ImmutableArray.Empty; - } - - return types.SelectMany(x => x.GetMembers().OfType().Where(m => m.IsAccessibleWithin(within))); - } - - private static IEnumerable SelectAccessibleMembers(this IEnumerable? types, string memberName, ISymbol within) where T : class, ISymbol - { - if (types == null) - { - return ImmutableArray.Empty; - } - - return types.SelectMany(x => x.GetMembers(memberName).OfType().Where(m => m.IsAccessibleWithin(within))); - } - - private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2) - { - // SPEC: A type parameter is less specific than a non-type parameter. - - var isTypeParameter1 = t1 is ITypeParameterSymbol; - var isTypeParameter2 = t2 is ITypeParameterSymbol; - - if (isTypeParameter1 && !isTypeParameter2) - { - return false; - } - - if (!isTypeParameter1 && isTypeParameter2) - { - return true; - } - - if (isTypeParameter1) - { - Debug.Assert(isTypeParameter2); - return null; - } - - if (t1.TypeKind != t2.TypeKind) - { - return null; - } - - // There is an identity conversion between the types and they are both substitutions on type parameters. - // They had better be the same kind. - - // UNDONE: Strip off the dynamics. - - // SPEC: An array type is more specific than another - // SPEC: array type (with the same number of dimensions) - // SPEC: if the element type of the first is - // SPEC: more specific than the element type of the second. - - if (t1 is IArrayTypeSymbol) - { - var arr1 = (IArrayTypeSymbol)t1; - var arr2 = (IArrayTypeSymbol)t2; - - // We should not have gotten here unless there were identity conversions - // between the two types. - - return arr1.ElementType.IsMoreSpecificThan(arr2.ElementType); - } - - // SPEC EXTENSION: We apply the same rule to pointer types. - - if (t1 is IPointerTypeSymbol) - { - var p1 = (IPointerTypeSymbol)t1; - var p2 = (IPointerTypeSymbol)t2; - return p1.PointedAtType.IsMoreSpecificThan(p2.PointedAtType); - } - - // SPEC: A constructed type is more specific than another - // SPEC: constructed type (with the same number of type arguments) if at least one type - // SPEC: argument is more specific and no type argument is less specific than the - // SPEC: corresponding type argument in the other. - - var n1 = t1 as INamedTypeSymbol; - var n2 = t2 as INamedTypeSymbol; - - if (n1 == null) - { - return null; - } - - // We should not have gotten here unless there were identity conversions between the - // two types. - - var allTypeArgs1 = n1.GetAllTypeArguments().ToList(); - var allTypeArgs2 = n2.GetAllTypeArguments().ToList(); - - return allTypeArgs1.AreMoreSpecificThan(allTypeArgs2); - } - - public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation) - { - if (type != null) - { - switch (type.Kind) - { - case SymbolKind.NamedType: - foreach (var baseType in type.GetBaseTypesAndThis()) - { - if (baseType.Equals(compilation.ExceptionType())) - { - return true; - } - } - - break; - - case SymbolKind.TypeParameter: - foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes) - { - if (constraint.IsOrDerivesFromExceptionType(compilation)) - { - return true; - } - } - - break; - } - } - - return false; - } - - public static bool IsEnumType(this ITypeSymbol type) - { - return type.IsValueType && type.TypeKind == TypeKind.Enum; - } - - public static bool? IsMutableValueType(this ITypeSymbol type) - { - if (type.IsNullable()) - { - // Nullable can only be mutable if T is mutable. This case ensures types like 'int?' are treated as - // immutable. - type = type.GetTypeArguments()[0]; - } - - switch (type.SpecialType) - { - case SpecialType.System_Boolean: - case SpecialType.System_Char: - case SpecialType.System_SByte: - case SpecialType.System_Byte: - case SpecialType.System_Int16: - case SpecialType.System_UInt16: - case SpecialType.System_Int32: - case SpecialType.System_UInt32: - case SpecialType.System_Int64: - case SpecialType.System_UInt64: - case SpecialType.System_Decimal: - case SpecialType.System_Single: - case SpecialType.System_Double: - return false; - - case SpecialType.System_IntPtr: - case SpecialType.System_UIntPtr: - return false; - - case SpecialType.System_DateTime: - return false; - - default: - break; - } - - if (type.IsErrorType()) - { - return null; - } - - if (type.TypeKind != TypeKind.Struct) - { - return false; - } - - var hasPrivateField = false; - foreach (var member in type.GetMembers()) - { - if (!(member is IFieldSymbol fieldSymbol)) - { - continue; - } - - hasPrivateField |= fieldSymbol.DeclaredAccessibility == Accessibility.Private; - if (!fieldSymbol.IsConst && !fieldSymbol.IsReadOnly && !fieldSymbol.IsStatic) - { - return true; - } - } - - if (!hasPrivateField) - { - // Some reference assemblies omit information about private fields. If we can't be sure the field is - // immutable, treat it as potentially mutable. - foreach (var attributeData in type.ContainingAssembly.GetAttributes()) - { - if (attributeData.AttributeClass.Name == nameof(ReferenceAssemblyAttribute) - && attributeData.AttributeClass.ToNameDisplayString() == typeof(ReferenceAssemblyAttribute).FullName) - { - return null; - } - } - } - - return false; - } - - public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType) - => iDisposableType != null && - (Equals(iDisposableType, type) || - type?.AllInterfaces.Contains(iDisposableType) == true); } } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/OperationExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/OperationExtensions.cs deleted file mode 100644 index eb75fa9799e4d..0000000000000 --- a/src/Workspaces/Core/Portable/Shared/Extensions/OperationExtensions.cs +++ /dev/null @@ -1,17 +0,0 @@ -// 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 Microsoft.CodeAnalysis.Operations; - -namespace Microsoft.CodeAnalysis.Shared.Extensions -{ - internal static class OperationExtensions - { - public static bool IsNumericLiteral(this IOperation operation) - => operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); - - public static bool IsNullLiteral(this IOperation operand) - => operand is ILiteralOperation { ConstantValue: { HasValue: true, Value: null } }; - } -} diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ProjectExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/ProjectExtensions.cs index e7a4e029a9c7f..95f683814ddb4 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ProjectExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/ProjectExtensions.cs @@ -4,18 +4,13 @@ #nullable enable -using System; -using System.Collections.Immutable; -using System.Diagnostics; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Options; -using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Shared.Extensions { - internal static class ProjectExtensions + internal static partial class ProjectExtensions { public static bool IsFromPrimaryBranch(this Project project) { @@ -41,102 +36,6 @@ public static async Task IsForkedProjectWithSemanticChangesAsync(this Proj return !semanticVersion.Equals(currentSemanticVersion); } - public static async Task GetVersionAsync(this Project project, CancellationToken cancellationToken) - { - var version = project.Version; - var latestVersion = await project.GetLatestDocumentVersionAsync(cancellationToken).ConfigureAwait(false); - - return version.GetNewerVersion(latestVersion); - } - - public static string? TryGetAnalyzerConfigPathForProjectConfiguration(this Project project) - => TryGetAnalyzerConfigPathForProjectOrDiagnosticConfiguration(project, diagnostic: null); - - public static string? TryGetAnalyzerConfigPathForDiagnosticConfiguration(this Project project, Diagnostic diagnostic) - { - Debug.Assert(diagnostic != null); - return TryGetAnalyzerConfigPathForProjectOrDiagnosticConfiguration(project, diagnostic); - } - - private static string? TryGetAnalyzerConfigPathForProjectOrDiagnosticConfiguration(Project project, Diagnostic? diagnostic) - { - if (project.AnalyzerConfigDocuments.Any()) - { - var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath); - if (!PathUtilities.IsAbsolute(diagnosticFilePath)) - { - return null; - } - - // Currently, we use a simple heuristic to find existing .editorconfig file. - // We start from the directory of the source file where the diagnostic was reported and walk up - // the directory tree to find an .editorconfig file. - // In future, we might change this algorithm, or allow end users to customize it based on options. - - var bestPath = string.Empty; - AnalyzerConfigDocument? bestAnalyzerConfigDocument = null; - foreach (var analyzerConfigDocument in project.AnalyzerConfigDocuments) - { - var analyzerConfigDirectory = PathUtilities.GetDirectoryName(analyzerConfigDocument.FilePath); - if (diagnosticFilePath.StartsWith(analyzerConfigDirectory) && - analyzerConfigDirectory.Length > bestPath.Length) - { - bestPath = analyzerConfigDirectory; - bestAnalyzerConfigDocument = analyzerConfigDocument; - } - } - - if (bestAnalyzerConfigDocument != null) - { - return bestAnalyzerConfigDocument.FilePath; - } - } - - // Did not find any existing .editorconfig, so create one at root of the solution, if one exists. - // If project is not part of a solution, then use project path. - var solutionOrProjectFilePath = project.Solution?.FilePath ?? project.FilePath; - if (!PathUtilities.IsAbsolute(solutionOrProjectFilePath)) - { - return null; - } - - var solutionOrProjectDirectoryPath = PathUtilities.GetDirectoryName(solutionOrProjectFilePath); - return PathUtilities.CombineAbsoluteAndRelativePaths(solutionOrProjectDirectoryPath, ".editorconfig"); - } - - public static AnalyzerConfigDocument? TryGetExistingAnalyzerConfigDocumentAtPath(this Project project, string analyzerConfigPath) - { - Debug.Assert(analyzerConfigPath != null); - Debug.Assert(PathUtilities.IsAbsolute(analyzerConfigPath)); - - return project.AnalyzerConfigDocuments.FirstOrDefault(d => d.FilePath == analyzerConfigPath); - } - - public static AnalyzerConfigDocument? GetOrCreateAnalyzerConfigDocument(this Project project, string analyzerConfigPath) - { - var existingAnalyzerConfigDocument = project.TryGetExistingAnalyzerConfigDocumentAtPath(analyzerConfigPath); - if (existingAnalyzerConfigDocument != null) - { - return existingAnalyzerConfigDocument; - } - - var id = DocumentId.CreateNewId(project.Id); - var documentInfo = DocumentInfo.Create(id, ".editorconfig", filePath: analyzerConfigPath); - var newSolution = project.Solution.AddAnalyzerConfigDocuments(ImmutableArray.Create(documentInfo)); - return newSolution.GetProject(project.Id)?.GetAnalyzerConfigDocument(id); - } - - public static async Task GetRequiredCompilationAsync(this Project project, CancellationToken cancellationToken) - { - var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - if (compilation == null) - { - throw new InvalidOperationException(string.Format(WorkspacesResources.Compilation_is_required_to_accomplish_the_task_but_is_not_supported_by_project_0, project.Name)); - } - - return compilation; - } - internal static Project WithSolutionOptions(this Project project, OptionSet options) => project.Solution.WithOptions(options).GetProject(project.Id)!; } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SemanticModelExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/SemanticModelExtensions.cs index 4843eab5c6193..97f6d0bde2ae5 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/SemanticModelExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/SemanticModelExtensions.cs @@ -5,70 +5,22 @@ #nullable enable using System; -using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.LanguageServices; -using Microsoft.CodeAnalysis.Operations; using Microsoft.CodeAnalysis.Shared.Utilities; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Shared.Extensions { - internal static class SemanticModelExtensions + internal static partial class SemanticModelExtensions { public static SemanticMap GetSemanticMap(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) { return SemanticMap.From(semanticModel, node, cancellationToken); } - /// - /// Gets semantic information, such as type, symbols, and diagnostics, about the parent of a token. - /// - /// The SemanticModel object to get semantic information - /// from. - /// The token to get semantic information from. This must be part of the - /// syntax tree associated with the binding. - /// A cancellation token. - public static SymbolInfo GetSymbolInfo(this SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken) - { - return semanticModel.GetSymbolInfo(token.Parent!, cancellationToken); - } - - public static TSymbol? GetEnclosingSymbol(this SemanticModel semanticModel, int position, CancellationToken cancellationToken) - where TSymbol : class, ISymbol - { - for (var symbol = semanticModel.GetEnclosingSymbol(position, cancellationToken); - symbol != null; - symbol = symbol.ContainingSymbol) - { - if (symbol is TSymbol tSymbol) - { - return tSymbol; - } - } - - return default; - } - - public static ISymbol GetEnclosingNamedTypeOrAssembly(this SemanticModel semanticModel, int position, CancellationToken cancellationToken) - { - return semanticModel.GetEnclosingSymbol(position, cancellationToken) ?? - (ISymbol)semanticModel.Compilation.Assembly; - } - - public static INamedTypeSymbol? GetEnclosingNamedType(this SemanticModel semanticModel, int position, CancellationToken cancellationToken) - { - return semanticModel.GetEnclosingSymbol(position, cancellationToken); - } - - public static INamespaceSymbol? GetEnclosingNamespace(this SemanticModel semanticModel, int position, CancellationToken cancellationToken) - { - return semanticModel.GetEnclosingSymbol(position, cancellationToken); - } - /// /// Fetches the ITypeSymbol that should be used if we were generating a parameter or local that would accept . If /// expression is a type, that's returned; otherwise this will see if it's something like a method group and then choose an appropriate delegate. @@ -222,66 +174,5 @@ public static TokenSemanticInfo GetSemanticInfo( return new TokenSemanticInfo(declaredSymbol, aliasSymbol, allSymbols, type, convertedType, token.Span); } - - public static SemanticModel GetOriginalSemanticModel(this SemanticModel semanticModel) - { - if (!semanticModel.IsSpeculativeSemanticModel) - { - return semanticModel; - } - - Contract.ThrowIfNull(semanticModel.ParentModel); - Contract.ThrowIfTrue(semanticModel.ParentModel.IsSpeculativeSemanticModel); - Contract.ThrowIfTrue(semanticModel.ParentModel.ParentModel != null); - return semanticModel.ParentModel; - } - - public static HashSet GetAllDeclaredSymbols( - this SemanticModel semanticModel, SyntaxNode? container, CancellationToken cancellationToken, Func? filter = null) - { - var symbols = new HashSet(); - if (container != null) - { - GetAllDeclaredSymbols(semanticModel, container, symbols, cancellationToken, filter); - } - - return symbols; - } - - public static IEnumerable GetExistingSymbols( - this SemanticModel semanticModel, SyntaxNode? container, CancellationToken cancellationToken, Func? descendInto = null) - { - // Ignore an anonymous type property or tuple field. It's ok if they have a name that - // matches the name of the local we're introducing. - return semanticModel.GetAllDeclaredSymbols(container, cancellationToken, descendInto) - .Where(s => !s.IsAnonymousTypeProperty() && !s.IsTupleField()); - } - - private static void GetAllDeclaredSymbols( - SemanticModel semanticModel, SyntaxNode node, - HashSet symbols, CancellationToken cancellationToken, Func? descendInto = null) - { - var symbol = semanticModel.GetDeclaredSymbol(node, cancellationToken); - - if (symbol != null) - { - symbols.Add(symbol); - } - - foreach (var child in node.ChildNodesAndTokens()) - { - if (child.IsNode) - { - var childNode = child.AsNode()!; - if (ShouldDescendInto(childNode, descendInto)) - { - GetAllDeclaredSymbols(semanticModel, childNode, symbols, cancellationToken, descendInto); - } - } - } - - static bool ShouldDescendInto(SyntaxNode node, Func? filter) - => filter != null ? filter(node) : true; - } } } diff --git a/src/Workspaces/Core/Portable/Utilities/SpellChecker.cs b/src/Workspaces/Core/Portable/Utilities/SpellChecker.cs index 5e415ee16acbe..7fae5f748f879 100644 --- a/src/Workspaces/Core/Portable/Utilities/SpellChecker.cs +++ b/src/Workspaces/Core/Portable/Utilities/SpellChecker.cs @@ -77,193 +77,4 @@ internal static SpellChecker TryReadFrom(ObjectReader reader) return null; } } - - internal class WordSimilarityChecker - { - private struct CacheResult - { - public readonly string CandidateText; - public readonly bool AreSimilar; - public readonly double SimilarityWeight; - - public CacheResult(string candidate, bool areSimilar, double similarityWeight) - { - CandidateText = candidate; - AreSimilar = areSimilar; - SimilarityWeight = similarityWeight; - } - } - - // Cache the result of the last call to AreSimilar. We'll often be called with the same - // value multiple times in a row, so we can avoid expensive computation by returning the - // same value immediately. - private CacheResult _lastAreSimilarResult; - - private string _source; - private EditDistance _editDistance; - private int _threshold; - - /// - /// Whether or words should be considered similar if one is contained within the other - /// (regardless of edit distance). For example if is true then IService would be considered - /// similar to IServiceFactory despite the edit distance being quite high at 7. - /// - private bool _substringsAreSimilar; - - private static readonly object s_poolGate = new object(); - private static readonly Stack s_pool = new Stack(); - - public static WordSimilarityChecker Allocate(string text, bool substringsAreSimilar) - { - WordSimilarityChecker checker; - lock (s_poolGate) - { - checker = s_pool.Count > 0 - ? s_pool.Pop() - : new WordSimilarityChecker(); - } - - checker.Initialize(text, substringsAreSimilar); - return checker; - } - - private WordSimilarityChecker() - { - } - - private void Initialize(string text, bool substringsAreSimilar) - { - _source = text ?? throw new ArgumentNullException(nameof(text)); - _threshold = GetThreshold(_source); - _editDistance = new EditDistance(text); - _substringsAreSimilar = substringsAreSimilar; - } - - public void Free() - { - _editDistance?.Dispose(); - _source = null; - _editDistance = null; - _lastAreSimilarResult = default; - lock (s_poolGate) - { - s_pool.Push(this); - } - } - - public static bool AreSimilar(string originalText, string candidateText) - => AreSimilar(originalText, candidateText, substringsAreSimilar: false); - - public static bool AreSimilar(string originalText, string candidateText, bool substringsAreSimilar) - => AreSimilar(originalText, candidateText, substringsAreSimilar, out var unused); - - public static bool AreSimilar(string originalText, string candidateText, out double similarityWeight) - { - return AreSimilar( - originalText, candidateText, - substringsAreSimilar: false, similarityWeight: out similarityWeight); - } - - /// - /// Returns true if 'originalText' and 'candidateText' are likely a misspelling of each other. - /// Returns false otherwise. If it is a likely misspelling a similarityWeight is provided - /// to help rank the match. Lower costs mean it was a better match. - /// - public static bool AreSimilar(string originalText, string candidateText, bool substringsAreSimilar, out double similarityWeight) - { - var checker = Allocate(originalText, substringsAreSimilar); - var result = checker.AreSimilar(candidateText, out similarityWeight); - checker.Free(); - - return result; - } - - internal static int GetThreshold(string value) - => value.Length <= 4 ? 1 : 2; - - public bool AreSimilar(string candidateText) - => AreSimilar(candidateText, out var similarityWeight); - - public bool AreSimilar(string candidateText, out double similarityWeight) - { - if (_source.Length < 3) - { - // If we're comparing strings that are too short, we'll find - // far too many spurious hits. Don't even bother in this case. - similarityWeight = double.MaxValue; - return false; - } - - if (_lastAreSimilarResult.CandidateText == candidateText) - { - similarityWeight = _lastAreSimilarResult.SimilarityWeight; - return _lastAreSimilarResult.AreSimilar; - } - - var result = AreSimilarWorker(candidateText, out similarityWeight); - _lastAreSimilarResult = new CacheResult(candidateText, result, similarityWeight); - return result; - } - - private bool AreSimilarWorker(string candidateText, out double similarityWeight) - { - similarityWeight = double.MaxValue; - - // If the two strings differ by more characters than the cost threshold, then there's - // no point in even computing the edit distance as it would necessarily take at least - // that many additions/deletions. - if (Math.Abs(_source.Length - candidateText.Length) <= _threshold) - { - similarityWeight = _editDistance.GetEditDistance(candidateText, _threshold); - } - - if (similarityWeight > _threshold) - { - // it had a high cost. However, the string the user typed was contained - // in the string we're currently looking at. That's enough to consider it - // although we place it just at the threshold (i.e. it's worse than all - // other matches). - if (_substringsAreSimilar && candidateText.IndexOf(_source, StringComparison.OrdinalIgnoreCase) >= 0) - { - similarityWeight = _threshold; - } - else - { - return false; - } - } - - Debug.Assert(similarityWeight <= _threshold); - - similarityWeight += Penalty(candidateText, _source); - return true; - } - - private static double Penalty(string candidateText, string originalText) - { - var lengthDifference = Math.Abs(originalText.Length - candidateText.Length); - if (lengthDifference != 0) - { - // For all items of the same edit cost, we penalize those that are - // much longer than the original text versus those that are only - // a little longer. - // - // Note: even with this penalty, all matches of cost 'X' will all still - // cost less than matches of cost 'X + 1'. i.e. the penalty is in the - // range [0, 1) and only serves to order matches of the same cost. - // - // Here's the relation of the first few values of length diff and penalty: - // LengthDiff -> Penalty - // 1 -> .5 - // 2 -> .66 - // 3 -> .75 - // 4 -> .8 - // And so on and so forth. - var penalty = 1.0 - (1.0 / (lengthDifference + 1)); - return penalty; - } - - return 0; - } - } } diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/MefHostServices.cs b/src/Workspaces/Core/Portable/Workspace/Host/Mef/MefHostServices.cs index 0249e715da952..8140546792ecc 100644 --- a/src/Workspaces/Core/Portable/Workspace/Host/Mef/MefHostServices.cs +++ b/src/Workspaces/Core/Portable/Workspace/Host/Mef/MefHostServices.cs @@ -134,47 +134,7 @@ internal static bool IsDefaultAssembly(Assembly assembly) private static ImmutableArray LoadDefaultAssemblies() { - return LoadNearbyAssemblies(s_defaultAssemblyNames); - } - - internal static ImmutableArray LoadNearbyAssemblies(string[] assemblyNames) - { - var assemblies = new List(); - - foreach (var assemblyName in assemblyNames) - { - var assembly = TryLoadNearbyAssembly(assemblyName); - if (assembly != null) - { - assemblies.Add(assembly); - } - } - - return assemblies.ToImmutableArray(); - } - - private static Assembly TryLoadNearbyAssembly(string assemblySimpleName) - { - var thisAssemblyName = typeof(MefHostServices).GetTypeInfo().Assembly.GetName(); - var assemblyShortName = thisAssemblyName.Name; - var assemblyVersion = thisAssemblyName.Version; - var publicKeyToken = thisAssemblyName.GetPublicKeyToken().Aggregate(string.Empty, (s, b) => s + b.ToString("x2")); - - if (string.IsNullOrEmpty(publicKeyToken)) - { - publicKeyToken = "null"; - } - - var assemblyName = new AssemblyName(string.Format("{0}, Version={1}, Culture=neutral, PublicKeyToken={2}", assemblySimpleName, assemblyVersion, publicKeyToken)); - - try - { - return Assembly.Load(assemblyName); - } - catch (Exception) - { - return null; - } + return MefHostServicesHelpers.LoadNearbyAssemblies(s_defaultAssemblyNames); } #endregion diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf index 3b9bba885af96..935f8cbae6810 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf @@ -67,6 +67,21 @@ Předvolby polí + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Odsazení a mezery @@ -1257,6 +1272,11 @@ Pozitivní kontrolní výrazy zpětného vyhledávání s nulovou délkou se obv Odebírání dokumentů konfigurace analyzátoru se nepodporuje. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. Symbol {0} nepochází ze zdroje. @@ -1637,21 +1657,6 @@ Pozitivní kontrolní výrazy zpětného vyhledávání s nulovou délkou se obv Přidáno: - - Fix all '{0}' - Opravit vše ({0}) - - - - Fix all '{0}' in '{1}' - Opravit vše ({0}) v: {1} - - - - Fix all '{0}' in Solution - Opravit vše ({0}) v řešení - - After: Po: @@ -1742,11 +1747,6 @@ Pozitivní kontrolní výrazy zpětného vyhledávání s nulovou délkou se obv Ke splnění úkolu se vyžaduje služba typu {0}, není ale z pracovního prostoru dostupná. - - Supplied diagnostic cannot be null. - Zadaná diagnostika nemůže být null. - - At least one diagnostic must be supplied. Musí se zadat aspoň jedna diagnostika. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf index e7667b6fc7e03..ca42add249a69 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf @@ -67,6 +67,21 @@ Einstellungen für Felder + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Einzüge und Abstände @@ -1257,6 +1272,11 @@ Positive Lookbehindassertionen mit Nullbreite werden normalerweise am Anfang reg Das Entfernen von Konfigurationsdokumenten des Analysetools wird nicht unterstützt. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. Symbol "{0}" ist nicht aus Quelle. @@ -1637,21 +1657,6 @@ Positive Lookbehindassertionen mit Nullbreite werden normalerweise am Anfang reg Hinzugefügt: - - Fix all '{0}' - Alle '{0}' reparieren - - - - Fix all '{0}' in '{1}' - Alle '{0}' in '{1}' reparieren - - - - Fix all '{0}' in Solution - Alle '{0}' in Lösung reparieren - - After: Nach: @@ -1742,11 +1747,6 @@ Positive Lookbehindassertionen mit Nullbreite werden normalerweise am Anfang reg Ein Dienst vom Typ "{0}" ist zum Ausführen der Aufgabe erforderlich, steht aber im Arbeitsbereich nicht zur Verfügung. - - Supplied diagnostic cannot be null. - Bereitgestellte Diagnose darf nicht null sein. - - At least one diagnostic must be supplied. Es muss mindestens eine Diagnose bereitgestellt sein. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf index 2dc8f8a0006a4..8ab4d8915e33c 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf @@ -67,6 +67,21 @@ Preferencias de campo + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Sangría y espaciado @@ -1257,6 +1272,11 @@ Las aserciones de búsqueda retrasada (lookbehind) positivas de ancho cero se us No se permite quitar documentos de configuración del analizador. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. El símbolo "{0}" no procede del código fuente. @@ -1637,21 +1657,6 @@ Las aserciones de búsqueda retrasada (lookbehind) positivas de ancho cero se us Agregado: - - Fix all '{0}' - Corregir todo '{0}' - - - - Fix all '{0}' in '{1}' - Corregir todo '{0}' en '{1}' - - - - Fix all '{0}' in Solution - Corregir todo '{0}' en solución - - After: Después: @@ -1742,11 +1747,6 @@ Las aserciones de búsqueda retrasada (lookbehind) positivas de ancho cero se us El servicio de tipo '{0}' es necesario para realizar la tarea, pero no está disponibles desde el área de trabajo. - - Supplied diagnostic cannot be null. - El diagnóstico suministrado no puede ser nulo. - - At least one diagnostic must be supplied. Se debe suministrar al menos un diagnóstico. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf index 6366d269351a4..91395155aa4ad 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf @@ -67,6 +67,21 @@ Préférences de champ + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Indentation et espacement @@ -1257,6 +1272,11 @@ Les assertions arrière positives de largeur nulle sont généralement utilisée La suppression de documents de configuration de l'analyseur n'est pas prise en charge. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. Le symbole "{0}" ne provient pas de la source. @@ -1637,21 +1657,6 @@ Les assertions arrière positives de largeur nulle sont généralement utilisée Ajouté : - - Fix all '{0}' - Corriger tous les '{0}' - - - - Fix all '{0}' in '{1}' - Pour toutes les '{0}' dans '{1}' - - - - Fix all '{0}' in Solution - Corriger tous les '{0}' dans la solution - - After: Après : @@ -1742,11 +1747,6 @@ Les assertions arrière positives de largeur nulle sont généralement utilisée Le service de type '{0}' est nécessaire pour accomplir la tâche mais n'est pas disponible dans l'espace de travail. - - Supplied diagnostic cannot be null. - Le diagnostic fourni ne peut pas être null. - - At least one diagnostic must be supplied. Au moins un diagnostic doit être fourni. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf index 992057b2a0a6e..cb1c9845ca047 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf @@ -67,6 +67,21 @@ Preferenze per campi + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Rientro e spaziatura @@ -1257,6 +1272,11 @@ Le asserzioni lookbehind positive di larghezza zero vengono usate in genere all' La rimozione di documenti di configurazione dell'analizzatore non è supportata. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. Il simbolo "{0}" non proviene dall'origine. @@ -1637,21 +1657,6 @@ Le asserzioni lookbehind positive di larghezza zero vengono usate in genere all' Aggiunto: - - Fix all '{0}' - Correggi tutti '{0}' - - - - Fix all '{0}' in '{1}' - Correggi tutti '{0}' in '{1}' - - - - Fix all '{0}' in Solution - Correggi tutti '{0}' nella soluzione - - After: Dopo: @@ -1742,11 +1747,6 @@ Le asserzioni lookbehind positive di larghezza zero vengono usate in genere all' Per eseguire l'attività, è necessario il servizio di tipo '{0}', che però non è disponibile dall'area di lavoro. - - Supplied diagnostic cannot be null. - La diagnostica specificata non può essere Null. - - At least one diagnostic must be supplied. È necessario specificare almeno una diagnostica. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf index 709decdd11594..d7736a13e766b 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf @@ -67,6 +67,21 @@ フィールド設定 + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing インデントと間隔 @@ -1257,6 +1272,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of アナライザー構成ドキュメントの削除はサポートされていません。 + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. シンボル "{0}" は、ソースからではありません。 @@ -1637,21 +1657,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 追加済み: - - Fix all '{0}' - すべての '{0}' を修正します - - - - Fix all '{0}' in '{1}' - {1}' に含まれているすべての '{0}' を修正します - - - - Fix all '{0}' in Solution - ソリューションに含まれているすべての '{0}' を修正します - - After: 後: @@ -1742,11 +1747,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 型 '{0}' のサービスはタスクの実行に必要ですが、このワークスペースからは利用できません。 - - Supplied diagnostic cannot be null. - 診断に null は指定できません。 - - At least one diagnostic must be supplied. 1 つ以上の診断を指定しなければなりません。 diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf index a1a331dbf0b73..736d09926d679 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf @@ -67,6 +67,21 @@ 필드 기본 설정 + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing 들여쓰기 및 간격 @@ -1257,6 +1272,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 분석기 구성 문서 제거는 지원되지 않습니다. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. "{0}" 기호가 소스에 없습니다. @@ -1637,21 +1657,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 추가됨: - - Fix all '{0}' - 모든 '{0}' 수정 - - - - Fix all '{0}' in '{1}' - {1}'의 모든 '{0}' 수정 - - - - Fix all '{0}' in Solution - 솔루션의 모든 '{0}' 수정 - - After: 이후: @@ -1742,11 +1747,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of {0}' 유형의 서비스가 작업을 수행하는 데 필요하지만 작업 영역에서 사용할 수 없습니다. - - Supplied diagnostic cannot be null. - 제공된 진단은 null일 수 없습니다. - - At least one diagnostic must be supplied. 하나 이상의 진단을 제공해야 합니다. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf index 85413a88a5fb7..e398a8d9ce774 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf @@ -67,6 +67,21 @@ Preferencje pól + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Wcięcia i odstępy @@ -1257,6 +1272,11 @@ Pozytywne asercje wsteczne o zerowej szerokości są zwykle używane na początk Usuwanie dokumentów z konfiguracją analizatora nie jest obsługiwane. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. Symbol „{0}” nie pochodzi ze źródła. @@ -1637,21 +1657,6 @@ Pozytywne asercje wsteczne o zerowej szerokości są zwykle używane na początk Dodano: - - Fix all '{0}' - Napraw wszystkie wystąpienia elementu „{0}” - - - - Fix all '{0}' in '{1}' - Napraw wszystkie wystąpienia elementu „{0}” w zakresie „{1}” - - - - Fix all '{0}' in Solution - Napraw wszystkie wystąpienia elementu „{0}” w rozwiązaniu - - After: Po: @@ -1742,11 +1747,6 @@ Pozytywne asercje wsteczne o zerowej szerokości są zwykle używane na początk Usługa typu „{0}” jest wymagana do wykonania zadania, lecz nie jest dostępna w obszarze roboczym. - - Supplied diagnostic cannot be null. - Podane informacje diagnostyczne nie mogą mieć wartości null. - - At least one diagnostic must be supplied. Należy podać co najmniej jedną informację diagnostyczną. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf index efba3cf52c999..f9e1de84c8d26 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf @@ -67,6 +67,21 @@ Preferências de campo + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Recuo e espaçamento @@ -1257,6 +1272,11 @@ As declarações de lookbehind positivas de largura zero normalmente são usadas Não há suporte para a remoção de documentos da configuração do analisador. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. Símbolo "{0}" não é da fonte. @@ -1637,21 +1657,6 @@ As declarações de lookbehind positivas de largura zero normalmente são usadas Adicionado: - - Fix all '{0}' - Corrigir todos os '{0}' - - - - Fix all '{0}' in '{1}' - Corrigir todos os '{0}' em '{1}' - - - - Fix all '{0}' in Solution - Corrigir todos os '{0}' na Solução - - After: Após: @@ -1742,11 +1747,6 @@ As declarações de lookbehind positivas de largura zero normalmente são usadas O serviço do tipo '{0}' é necessário para realizar a tarefa, mas não está disponível no workspace. - - Supplied diagnostic cannot be null. - O diagnóstico fornecido não pode ser nulo. - - At least one diagnostic must be supplied. No mínimo um diagnóstico deve ser fornecido. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf index d611c72e4a43c..916a4b4827e18 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf @@ -67,6 +67,21 @@ Предпочтения для полей + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Отступы и интервалы @@ -1257,6 +1272,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Удаление документов конфигурации анализатора не поддерживается. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. Символ "{0}" не из источника. @@ -1637,21 +1657,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Добавлены: - - Fix all '{0}' - Исправить все "{0}" - - - - Fix all '{0}' in '{1}' - Исправить все "{0}" в "{1}" - - - - Fix all '{0}' in Solution - Исправить все "{0}" в решении - - After: После: @@ -1742,11 +1747,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Служба типа "{0}" необходима для выполнения задачи, но она недоступна из рабочей области. - - Supplied diagnostic cannot be null. - Указанная диагностика не может быть NULL. - - At least one diagnostic must be supplied. Необходимо указать по крайней мере одну диагностику. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf index ca1c870db2fd7..fc7f46f33a779 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf @@ -67,6 +67,21 @@ Alan tercihleri + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing Girinti ve aralığı @@ -1257,6 +1272,11 @@ Sıfır genişlikli pozitif geri yönlü onaylamalar genellikle normal ifadeleri Çözümleyici yapılandırma belgelerinin kaldırılması desteklenmiyor. + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. "{0}" sembolü kaynağa ait değil. @@ -1637,21 +1657,6 @@ Sıfır genişlikli pozitif geri yönlü onaylamalar genellikle normal ifadeleri Eklendi: - - Fix all '{0}' - Geçtiği her yerde '{0}' ifadesini düzelt - - - - Fix all '{0}' in '{1}' - {1}' içinde geçtiği her yerde '{0}' ifadesini düzelt - - - - Fix all '{0}' in Solution - Çözüm'de geçtiği her yerde '{0}' ifadesini düzelt - - After: Önce: @@ -1742,11 +1747,6 @@ Sıfır genişlikli pozitif geri yönlü onaylamalar genellikle normal ifadeleri Görevi gerçekleştirmek için '{0}' türünde hizmet gerekli, ancak bu hizmet çalışma alanında yok. - - Supplied diagnostic cannot be null. - Sağlanan tanı null olamaz. - - At least one diagnostic must be supplied. En az bir tanı sağlanmalıdır. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf index 225821301e63f..91faf055fec4a 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf @@ -67,6 +67,21 @@ 字段首选项 + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing 缩进和间距 @@ -1257,6 +1272,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 不支持删除分析器配置文档。 + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. 符号“{0}”不是来自源。 @@ -1637,21 +1657,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 添加项: - - Fix all '{0}' - 修复所有“{0}” - - - - Fix all '{0}' in '{1}' - 修复“{1}”中的所有“{0}” - - - - Fix all '{0}' in Solution - 修复解决方案中的所有“{0}” - - After: 在此之后: @@ -1742,11 +1747,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 完成任务需要“{0}”类型的服务,但无法从工作区中使用这样的服务。 - - Supplied diagnostic cannot be null. - 提供的诊断不能为 null。 - - At least one diagnostic must be supplied. 必须提供至少一个诊断。 diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf index 09b881e8dbc14..1eaa0df6f733c 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf @@ -67,6 +67,21 @@ 欄位喜好設定 + + Fix all '{0}' + Fix all '{0}' + + + + Fix all '{0}' in '{1}' + Fix all '{0}' in '{1}' + + + + Fix all '{0}' in Solution + Fix all '{0}' in Solution + + Indentation and spacing 縮排和間距 @@ -1257,6 +1272,11 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 不支援移除分析器組態文件。 + + Supplied diagnostic cannot be null. + Supplied diagnostic cannot be null. + + Symbol "{0}" is not from source. 符號 "{0}" 非來自來源。 @@ -1637,21 +1657,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 已加入: - - Fix all '{0}' - 修正所有 '{0}' - - - - Fix all '{0}' in '{1}' - 修正 '{1}' 中的所有 '{0}' - - - - Fix all '{0}' in Solution - 修正方案中的所有 '{0}' - - After: 之後: @@ -1742,11 +1747,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 完成工作需要 '{0}' 類型的服務,但是無法從工作區取得。 - - Supplied diagnostic cannot be null. - 提供的診斷不可為 null。 - - At least one diagnostic must be supplied. 至少必須提供一項診斷。 diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems new file mode 100644 index 0000000000000..6507f283d7914 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems @@ -0,0 +1,21 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.CSharp.Shared + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.shproj b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.shproj new file mode 100644 index 0000000000000..565d3f2908b97 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.shproj @@ -0,0 +1,13 @@ + + + + {699FEA05-AEA7-403D-827E-53CF4E826955} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions_GetAttributes.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/MemberDeclarationSyntaxExtensions_GetAttributes.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions_GetAttributes.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/MemberDeclarationSyntaxExtensions_GetAttributes.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SymbolDisplayPartExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SymbolDisplayPartExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SymbolDisplayPartExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SymbolDisplayPartExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxKindExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxKindExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxKindExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxKindExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxListExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxListExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs similarity index 84% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs index e58178ecf69d3..2a848399fe5f1 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs @@ -219,5 +219,31 @@ node is UsingStatementSyntax || WhileStatementSyntax n => n.Statement, _ => null, }; + + public static BaseParameterListSyntax? GetParameterList(this SyntaxNode declaration) + => declaration.Kind() switch + { + SyntaxKind.DelegateDeclaration => ((DelegateDeclarationSyntax)declaration).ParameterList, + SyntaxKind.MethodDeclaration => ((MethodDeclarationSyntax)declaration).ParameterList, + SyntaxKind.OperatorDeclaration => ((OperatorDeclarationSyntax)declaration).ParameterList, + SyntaxKind.ConversionOperatorDeclaration => ((ConversionOperatorDeclarationSyntax)declaration).ParameterList, + SyntaxKind.ConstructorDeclaration => ((ConstructorDeclarationSyntax)declaration).ParameterList, + SyntaxKind.DestructorDeclaration => ((DestructorDeclarationSyntax)declaration).ParameterList, + SyntaxKind.IndexerDeclaration => ((IndexerDeclarationSyntax)declaration).ParameterList, + SyntaxKind.ParenthesizedLambdaExpression => ((ParenthesizedLambdaExpressionSyntax)declaration).ParameterList, + SyntaxKind.LocalFunctionStatement => ((LocalFunctionStatementSyntax)declaration).ParameterList, + SyntaxKind.AnonymousMethodExpression => ((AnonymousMethodExpressionSyntax)declaration).ParameterList, + _ => null, + }; + + public static SyntaxList GetAttributeLists(this SyntaxNode declaration) + => declaration switch + { + MemberDeclarationSyntax memberDecl => memberDecl.AttributeLists, + AccessorDeclarationSyntax accessor => accessor.AttributeLists, + ParameterSyntax parameter => parameter.AttributeLists, + CompilationUnitSyntax compilationUnit => compilationUnit.AttributeLists, + _ => default, + }; } } diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs similarity index 88% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs index 258241585db83..880454bc2807f 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs @@ -2,12 +2,19 @@ // 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.Linq; +using Microsoft.CodeAnalysis.Shared.Extensions; namespace Microsoft.CodeAnalysis.CSharp.Extensions { internal static partial class SyntaxTokenExtensions { + public static bool IsLastTokenOfNode(this SyntaxToken token) + where T : SyntaxNode + { + var node = token.GetAncestor(); + return node != null && token == node.GetLastToken(includeZeroWidth: true); + } + public static bool IsKindOrHasMatchingText(this SyntaxToken token, SyntaxKind kind) { return token.Kind() == kind || token.HasMatchingText(kind); diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTriviaExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTriviaExtensions.cs similarity index 99% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxTriviaExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTriviaExtensions.cs index 4f254aea925b0..5b52179ba7d26 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTriviaExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTriviaExtensions.cs @@ -8,7 +8,6 @@ using System.Text; using System.Threading; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTriviaListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTriviaListExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxTriviaListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTriviaListExtensions.cs diff --git a/src/Workspaces/Core/Portable/CodeStyle/AccessibilityModifiersRequired.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/AccessibilityModifiersRequired.cs similarity index 100% rename from src/Workspaces/Core/Portable/CodeStyle/AccessibilityModifiersRequired.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/AccessibilityModifiersRequired.cs diff --git a/src/Workspaces/Core/Portable/AddImports/AddImportPlacement.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/AddImportPlacement.cs similarity index 100% rename from src/Workspaces/Core/Portable/AddImports/AddImportPlacement.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/AddImportPlacement.cs diff --git a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/CodeStyleHelpers.cs similarity index 100% rename from src/Workspaces/Core/Portable/CodeStyle/CodeStyleHelpers.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/CodeStyleHelpers.cs diff --git a/src/Workspaces/Core/Portable/NamingStyles/EditorConfig/EditorConfigSeverityStrings.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/EditorConfigSeverityStrings.cs similarity index 100% rename from src/Workspaces/Core/Portable/NamingStyles/EditorConfig/EditorConfigSeverityStrings.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/EditorConfigSeverityStrings.cs diff --git a/src/Workspaces/Core/Portable/CodeStyle/ExpressionBodyPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ExpressionBodyPreference.cs similarity index 100% rename from src/Workspaces/Core/Portable/CodeStyle/ExpressionBodyPreference.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ExpressionBodyPreference.cs diff --git a/src/Workspaces/Core/Portable/CodeStyle/OperatorPlacementWhenWrappingPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/OperatorPlacementWhenWrappingPreference.cs similarity index 100% rename from src/Workspaces/Core/Portable/CodeStyle/OperatorPlacementWhenWrappingPreference.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/OperatorPlacementWhenWrappingPreference.cs diff --git a/src/Workspaces/Core/Portable/CodeStyle/ParenthesesPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ParenthesesPreference.cs similarity index 100% rename from src/Workspaces/Core/Portable/CodeStyle/ParenthesesPreference.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ParenthesesPreference.cs diff --git a/src/Workspaces/Core/Portable/CodeStyle/UnusedParametersPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedParametersPreference.cs similarity index 100% rename from src/Workspaces/Core/Portable/CodeStyle/UnusedParametersPreference.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedParametersPreference.cs diff --git a/src/Workspaces/Core/Portable/CodeStyle/UnusedValuePreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedValuePreference.cs similarity index 100% rename from src/Workspaces/Core/Portable/CodeStyle/UnusedValuePreference.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedValuePreference.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems new file mode 100644 index 0000000000000..9c7830dcaba27 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -0,0 +1,302 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.Shared + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Execution\Desktop\DesktopAnalyzerAssemblyLoader.cs + + + Collections\ArrayBuilderExtensions.cs + + + InternalUtilities\Boxes.cs + + + Utilities\CompilerUtilities\OrderPreservingMultiDictionary.cs + + + InternalUtilities\AnalyzerAssemblyLoader.cs + + + InternalUtilities\EncodedStringText.cs + + + InternalUtilities\RelativePathResolver.cs + + + InternalUtilities\AssemblyIdentityUtils.cs + + + InternalUtilities\BitArithmeticUtilities.cs + + + InternalUtilities\ArrayExtensions.cs + + + InternalUtilities\CompilerOptionParseUtilities.cs + + + InternalUtilities\ConcurrentSet.cs + + + InternalUtilities\ConsList`1.cs + + + InternalUtilities\DecimalUtilities.cs + + + InternalUtilities\DocumentationCommentXmlNames.cs + + + InternalUtilities\EncodingExtensions.cs + + + InternalUtilities\EnumUtilties.cs + + + InternalUtilities\FailFast.cs + + + InternalUtilities\FatalError.cs + + + InternalUtilities\FileNameUtilities.cs + + + InternalUtilities\ImmutableListExtensions.cs + + + InternalUtilities\Index.cs + + + InternalUtilities\ISetExtensions.cs + + + InternalUtilities\MultiDictionary.cs + + + InternalUtilities\OrderedMultiDictionary.cs + + + InternalUtilities\SetWithInsertionOrder.cs + + + InternalUtilities\PathKind.cs + + + InternalUtilities\OneOrMany.cs + + + InternalUtilities\PlatformInformation.cs + + + InternalUtilities\Range.cs + + + InternalUtilities\ReaderWriterLockSlimExtensions.cs + + + InternalUtilities\SemaphoreSlimExtensions.cs + + + InternalUtilities\StackGuard.cs + + + InternalUtilities\StreamExtensions.cs + + + + InternalUtilities\TextChangeRangeExtensions.cs + + + InternalUtilities\WeakReferenceExtensions.cs + + + InternalUtilities\FileUtilities.cs + + + InternalUtilities\PathUtilities.cs + + + InternalUtilities\ReflectionUtilities.cs + + + InternalUtilities\UnicodeCharacterUtilities.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.shproj b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.shproj new file mode 100644 index 0000000000000..e5b2f24b86db4 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.shproj @@ -0,0 +1,13 @@ + + + + ec946164-1e17-410b-b7d9-7de7e6268d63 + 14.0 + + + + + + + + diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/AccessibilityUtilities.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/AccessibilityUtilities.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/AccessibilityUtilities.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/AccessibilityUtilities.cs diff --git a/src/Workspaces/Core/Portable/Extensions/BasicBlockExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/BasicBlockExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Extensions/BasicBlockExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/BasicBlockExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ChildSyntaxListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ChildSyntaxListExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ChildSyntaxListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ChildSyntaxListExtensions.cs diff --git a/src/Workspaces/Core/Portable/Extensions/ControlFlowGraphExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ControlFlowGraphExtensions.cs similarity index 96% rename from src/Workspaces/Core/Portable/Extensions/ControlFlowGraphExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ControlFlowGraphExtensions.cs index 0aa6ccf13ddc4..8633c001e6664 100644 --- a/src/Workspaces/Core/Portable/Extensions/ControlFlowGraphExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ControlFlowGraphExtensions.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using Microsoft.CodeAnalysis.Utilities; namespace Microsoft.CodeAnalysis.FlowAnalysis { diff --git a/src/Workspaces/Core/Portable/Extensions/ControlFlowRegionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ControlFlowRegionExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Extensions/ControlFlowRegionExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ControlFlowRegionExtensions.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/DiagnosticSeverityExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/DiagnosticSeverityExtensions.cs new file mode 100644 index 0000000000000..b36cff99e26c5 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/DiagnosticSeverityExtensions.cs @@ -0,0 +1,32 @@ +// 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 Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Diagnostics +{ + internal static partial class DiagnosticSeverityExtensions + { + /// + /// Returns the equivalent for a value. + /// + /// The value. + /// + /// The equivalent for the value. + /// + /// + /// If is not one of the expected values. + /// + public static ReportDiagnostic ToReportDiagnostic(this DiagnosticSeverity diagnosticSeverity) + => diagnosticSeverity switch + { + DiagnosticSeverity.Hidden => ReportDiagnostic.Hidden, + DiagnosticSeverity.Info => ReportDiagnostic.Info, + DiagnosticSeverity.Warning => ReportDiagnostic.Warn, + DiagnosticSeverity.Error => ReportDiagnostic.Error, + _ => throw ExceptionUtilities.UnexpectedValue(diagnosticSeverity), + }; + } +} diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/IAssemblySymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IAssemblySymbolExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/IAssemblySymbolExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IAssemblySymbolExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ICollectionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ICollectionExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ICollectionExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ICollectionExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ICompilationExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ICompilationExtensions.cs similarity index 98% rename from src/Workspaces/Core/Portable/Shared/Extensions/ICompilationExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ICompilationExtensions.cs index ecac8cee001e7..c4f003f07c9c4 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ICompilationExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ICompilationExtensions.cs @@ -181,7 +181,7 @@ public static ImmutableArray GetReferencedAssemblySymbols(this => compilation.GetTypeByMetadataName(typeof(ObsoleteAttribute).FullName); public static INamedTypeSymbol? SystemCompositionImportingConstructorAttribute(this Compilation compilation) - => compilation.GetTypeByMetadataName(typeof(System.Composition.ImportingConstructorAttribute).FullName); + => compilation.GetTypeByMetadataName("System.Composition.ImportingConstructorAttribute"); public static INamedTypeSymbol? SystemComponentModelCompositionImportingConstructorAttribute(this Compilation compilation) => compilation.GetTypeByMetadataName("System.ComponentModel.Composition.ImportingConstructorAttribute"); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IMethodSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IMethodSymbolExtensions.cs new file mode 100644 index 0000000000000..365d4c9a2deb2 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IMethodSymbolExtensions.cs @@ -0,0 +1,108 @@ +// 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; +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis.LanguageServices; + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ + internal static partial class IMethodSymbolExtensions + { + /// + /// Returns true for void returning methods with two parameters, where + /// the first parameter is of type and the second + /// parameter inherits from or equals type. + /// + public static bool HasEventHandlerSignature(this IMethodSymbol method, [NotNullWhen(returnValue: true)] INamedTypeSymbol? eventArgsType) + => eventArgsType != null && + method.Parameters.Length == 2 && + method.Parameters[0].Type.SpecialType == SpecialType.System_Object && + method.Parameters[1].Type.InheritsFromOrEquals(eventArgsType); + + public static bool TryGetPredefinedComparisonOperator(this IMethodSymbol symbol, out PredefinedOperator op) + { + if (symbol.MethodKind == MethodKind.BuiltinOperator) + { + op = symbol.GetPredefinedOperator(); + switch (op) + { + case PredefinedOperator.Equality: + case PredefinedOperator.Inequality: + case PredefinedOperator.GreaterThanOrEqual: + case PredefinedOperator.LessThanOrEqual: + case PredefinedOperator.GreaterThan: + case PredefinedOperator.LessThan: + return true; + } + } + else + { + op = PredefinedOperator.None; + } + + return false; + } + + public static PredefinedOperator GetPredefinedOperator(this IMethodSymbol symbol) + { + switch (symbol.Name) + { + case "op_Addition": + case "op_UnaryPlus": + return PredefinedOperator.Addition; + case "op_BitwiseAnd": + return PredefinedOperator.BitwiseAnd; + case "op_BitwiseOr": + return PredefinedOperator.BitwiseOr; + case "op_Concatenate": + return PredefinedOperator.Concatenate; + case "op_Decrement": + return PredefinedOperator.Decrement; + case "op_Division": + return PredefinedOperator.Division; + case "op_Equality": + return PredefinedOperator.Equality; + case "op_ExclusiveOr": + return PredefinedOperator.ExclusiveOr; + case "op_Exponent": + return PredefinedOperator.Exponent; + case "op_GreaterThan": + return PredefinedOperator.GreaterThan; + case "op_GreaterThanOrEqual": + return PredefinedOperator.GreaterThanOrEqual; + case "op_Increment": + return PredefinedOperator.Increment; + case "op_Inequality": + return PredefinedOperator.Inequality; + case "op_IntegerDivision": + return PredefinedOperator.IntegerDivision; + case "op_LeftShift": + return PredefinedOperator.LeftShift; + case "op_LessThan": + return PredefinedOperator.LessThan; + case "op_LessThanOrEqual": + return PredefinedOperator.LessThanOrEqual; + case "op_Like": + return PredefinedOperator.Like; + case "op_LogicalNot": + case "op_OnesComplement": + return PredefinedOperator.Complement; + case "op_Modulus": + return PredefinedOperator.Modulus; + case "op_Multiply": + return PredefinedOperator.Multiplication; + case "op_RightShift": + return PredefinedOperator.RightShift; + case "op_Subtraction": + case "op_UnaryNegation": + return PredefinedOperator.Subtraction; + default: + return PredefinedOperator.None; + } + } + } +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/INamedTypeSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/INamedTypeSymbolExtensions.cs new file mode 100644 index 0000000000000..52904b1255f10 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/INamedTypeSymbolExtensions.cs @@ -0,0 +1,596 @@ +// 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; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Threading; +using Microsoft.CodeAnalysis; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ + internal static partial class INamedTypeSymbolExtensions + { + public static IEnumerable GetBaseTypesAndThis(this INamedTypeSymbol? namedType) + { + var current = namedType; + while (current != null) + { + yield return current; + current = current.BaseType; + } + } + + public static IEnumerable GetAllTypeParameters(this INamedTypeSymbol? symbol) + { + var stack = GetContainmentStack(symbol); + return stack.SelectMany(n => n.TypeParameters); + } + + public static IEnumerable GetAllTypeArguments(this INamedTypeSymbol? symbol) + { + var stack = GetContainmentStack(symbol); + return stack.SelectMany(n => n.TypeArguments); + } + + private static Stack GetContainmentStack(INamedTypeSymbol? symbol) + { + var stack = new Stack(); + for (var current = symbol; current != null; current = current.ContainingType) + { + stack.Push(current); + } + + return stack; + } + + public static bool IsContainedWithin([NotNullWhen(returnValue: true)] this INamedTypeSymbol? symbol, INamedTypeSymbol outer) + { + // TODO(cyrusn): Should we be using OriginalSymbol here? + for (var current = symbol; current != null; current = current.ContainingType) + { + if (current.Equals(outer)) + { + return true; + } + } + + return false; + } + + public static ISymbol? FindImplementationForAbstractMember(this INamedTypeSymbol? type, ISymbol symbol) + { + if (symbol.IsAbstract) + { + return type.GetBaseTypesAndThis().SelectMany(t => t.GetMembers(symbol.Name)) + .FirstOrDefault(s => symbol.Equals(GetOverriddenMember(s))); + } + + return null; + } + + internal static ISymbol? GetOverriddenMember(this ISymbol? symbol) + { + switch (symbol) + { + case IMethodSymbol method: return method.OverriddenMethod; + case IPropertySymbol property: return property.OverriddenProperty; + case IEventSymbol @event: return @event.OverriddenEvent; + } + + return null; + } + + private static bool ImplementationExists(INamedTypeSymbol classOrStructType, ISymbol member) + { + return classOrStructType.FindImplementationForInterfaceMember(member) != null; + } + + private static bool IsImplemented( + this INamedTypeSymbol classOrStructType, + ISymbol member, + Func isValidImplementation, + CancellationToken cancellationToken) + { + if (member.ContainingType.TypeKind == TypeKind.Interface) + { + if (member.Kind == SymbolKind.Property) + { + return IsInterfacePropertyImplemented(classOrStructType, (IPropertySymbol)member); + } + else + { + return isValidImplementation(classOrStructType, member); + } + } + + if (member.IsAbstract) + { + if (member.Kind == SymbolKind.Property) + { + return IsAbstractPropertyImplemented(classOrStructType, (IPropertySymbol)member); + } + else + { + return classOrStructType.FindImplementationForAbstractMember(member) != null; + } + } + + return true; + } + + private static bool IsInterfacePropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol) + { + // A property is only fully implemented if both it's setter and getter is implemented. + + return IsAccessorImplemented(propertySymbol.GetMethod, classOrStructType) && IsAccessorImplemented(propertySymbol.SetMethod, classOrStructType); + + // local functions + + static bool IsAccessorImplemented(IMethodSymbol? accessor, INamedTypeSymbol classOrStructType) + { + return accessor == null || !IsImplementable(accessor) || classOrStructType.FindImplementationForInterfaceMember(accessor) != null; + } + } + + private static bool IsAbstractPropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol) + { + // A property is only fully implemented if both it's setter and getter is implemented. + if (propertySymbol.GetMethod != null) + { + if (classOrStructType.FindImplementationForAbstractMember(propertySymbol.GetMethod) == null) + { + return false; + } + } + + if (propertySymbol.SetMethod != null) + { + if (classOrStructType.FindImplementationForAbstractMember(propertySymbol.SetMethod) == null) + { + return false; + } + } + + return true; + } + + private static bool IsExplicitlyImplemented( + this INamedTypeSymbol classOrStructType, + ISymbol member, + Func isValid, + CancellationToken cancellationToken) + { + var implementation = classOrStructType.FindImplementationForInterfaceMember(member); + + if (implementation?.ContainingType.TypeKind == TypeKind.Interface) + { + // Treat all implementations in interfaces as explicit, even the original declaration with implementation. + // There are no implicit interface implementations in derived interfaces and it feels reasonable to treat + // original declaration with implementation as an explicit implementation as well, the implementation is + // explicitly provided after all. All implementations in interfaces will be treated uniformly. + return true; + } + + switch (implementation) + { + case IEventSymbol @event: return @event.ExplicitInterfaceImplementations.Length > 0; + case IMethodSymbol method: return method.ExplicitInterfaceImplementations.Length > 0; + case IPropertySymbol property: return property.ExplicitInterfaceImplementations.Length > 0; + default: return false; + } + } + + public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedMembers( + this INamedTypeSymbol classOrStructType, + IEnumerable interfacesOrAbstractClasses, + CancellationToken cancellationToken) + { + return classOrStructType.GetAllUnimplementedMembers( + interfacesOrAbstractClasses, + IsImplemented, + ImplementationExists, + (INamedTypeSymbol type, ISymbol within) => + { + if (type.TypeKind == TypeKind.Interface) + { + return type.GetMembers().WhereAsArray(m => m.DeclaredAccessibility == Accessibility.Public && + m.Kind != SymbolKind.NamedType && IsImplementable(m) && + !IsPropertyWithNonPublicImplementableAccessor(m)); + } + + return type.GetMembers(); + }, + allowReimplementation: false, + cancellationToken: cancellationToken); + + // local functions + + static bool IsPropertyWithNonPublicImplementableAccessor(ISymbol member) + { + if (member.Kind != SymbolKind.Property) + { + return false; + } + + var property = (IPropertySymbol)member; + + return IsNonPublicImplementableAccessor(property.GetMethod) || IsNonPublicImplementableAccessor(property.SetMethod); + } + + static bool IsNonPublicImplementableAccessor(IMethodSymbol? accessor) + { + return accessor != null && IsImplementable(accessor) && accessor.DeclaredAccessibility != Accessibility.Public; + } + } + + private static bool IsImplementable(ISymbol m) + { + return m.IsVirtual || m.IsAbstract; + } + + public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedMembersInThis( + this INamedTypeSymbol classOrStructType, + IEnumerable interfacesOrAbstractClasses, + CancellationToken cancellationToken) + { + return classOrStructType.GetAllUnimplementedMembers( + interfacesOrAbstractClasses, + IsImplemented, + (t, m) => + { + var implementation = classOrStructType.FindImplementationForInterfaceMember(m); + return implementation != null && Equals(implementation.ContainingType, classOrStructType); + }, + GetMembers, + allowReimplementation: true, + cancellationToken: cancellationToken); + } + + public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedMembersInThis( + this INamedTypeSymbol classOrStructType, + IEnumerable interfacesOrAbstractClasses, + Func> interfaceMemberGetter, + CancellationToken cancellationToken) + { + return classOrStructType.GetAllUnimplementedMembers( + interfacesOrAbstractClasses, + IsImplemented, + (t, m) => + { + var implementation = classOrStructType.FindImplementationForInterfaceMember(m); + return implementation != null && Equals(implementation.ContainingType, classOrStructType); + }, + interfaceMemberGetter, + allowReimplementation: true, + cancellationToken: cancellationToken); + } + + public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedExplicitMembers( + this INamedTypeSymbol classOrStructType, + IEnumerable interfaces, + CancellationToken cancellationToken) + { + return classOrStructType.GetAllUnimplementedMembers( + interfaces, + IsExplicitlyImplemented, + ImplementationExists, + (INamedTypeSymbol type, ISymbol within) => + { + if (type.TypeKind == TypeKind.Interface) + { + return type.GetMembers().WhereAsArray(m => m.Kind != SymbolKind.NamedType && + IsImplementable(m) && m.IsAccessibleWithin(within) && + !IsPropertyWithInaccessibleImplementableAccessor(m, within)); + } + + return type.GetMembers(); + }, + allowReimplementation: false, + cancellationToken: cancellationToken); + + // local functions + + static bool IsPropertyWithInaccessibleImplementableAccessor(ISymbol member, ISymbol within) + { + if (member.Kind != SymbolKind.Property) + { + return false; + } + + var property = (IPropertySymbol)member; + + return IsInaccessibleImplementableAccessor(property.GetMethod, within) || IsInaccessibleImplementableAccessor(property.SetMethod, within); + } + + static bool IsInaccessibleImplementableAccessor(IMethodSymbol? accessor, ISymbol within) + { + return accessor != null && IsImplementable(accessor) && !accessor.IsAccessibleWithin(within); + } + } + + private static ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)> GetAllUnimplementedMembers( + this INamedTypeSymbol classOrStructType, + IEnumerable interfacesOrAbstractClasses, + Func, CancellationToken, bool> isImplemented, + Func isValidImplementation, + Func> interfaceMemberGetter, + bool allowReimplementation, + CancellationToken cancellationToken) + { + Contract.ThrowIfNull(classOrStructType); + Contract.ThrowIfNull(interfacesOrAbstractClasses); + Contract.ThrowIfNull(isImplemented); + + if (classOrStructType.TypeKind != TypeKind.Class && classOrStructType.TypeKind != TypeKind.Struct) + { + return ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)>.Empty; + } + + if (!interfacesOrAbstractClasses.Any()) + { + return ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)>.Empty; + } + + if (!interfacesOrAbstractClasses.All(i => i.TypeKind == TypeKind.Interface) && + !interfacesOrAbstractClasses.All(i => i.IsAbstractClass())) + { + return ImmutableArray<(INamedTypeSymbol type, ImmutableArray members)>.Empty; + } + + var typesToImplement = GetTypesToImplement(classOrStructType, interfacesOrAbstractClasses, allowReimplementation, cancellationToken); + return typesToImplement.SelectAsArray(s => (s, members: GetUnimplementedMembers(classOrStructType, s, isImplemented, isValidImplementation, interfaceMemberGetter, cancellationToken))) + .WhereAsArray(t => t.members.Length > 0); + } + + private static ImmutableArray GetTypesToImplement( + INamedTypeSymbol classOrStructType, + IEnumerable interfacesOrAbstractClasses, + bool allowReimplementation, + CancellationToken cancellationToken) + { + return interfacesOrAbstractClasses.First().TypeKind == TypeKind.Interface + ? GetInterfacesToImplement(classOrStructType, interfacesOrAbstractClasses, allowReimplementation, cancellationToken) + : GetAbstractClassesToImplement(classOrStructType, interfacesOrAbstractClasses); + } + + private static ImmutableArray GetAbstractClassesToImplement( + INamedTypeSymbol classOrStructType, + IEnumerable abstractClasses) + { + return abstractClasses.SelectMany(a => a.GetBaseTypesAndThis()) + .Where(t => t.IsAbstractClass()) + .ToImmutableArray(); + } + + private static ImmutableArray GetInterfacesToImplement( + INamedTypeSymbol classOrStructType, + IEnumerable interfaces, + bool allowReimplementation, + CancellationToken cancellationToken) + { + // We need to not only implement the specified interface, but also everything it + // inherits from. + cancellationToken.ThrowIfCancellationRequested(); + var interfacesToImplement = new List( + interfaces.SelectMany(i => i.GetAllInterfacesIncludingThis()).Distinct()); + + // However, there's no need to re-implement any interfaces that our base types already + // implement. By definition they must contain all the necessary methods. + var baseType = classOrStructType.BaseType; + var alreadyImplementedInterfaces = baseType == null || allowReimplementation + ? SpecializedCollections.EmptyEnumerable() + : baseType.AllInterfaces; + + cancellationToken.ThrowIfCancellationRequested(); + interfacesToImplement.RemoveRange(alreadyImplementedInterfaces); + return interfacesToImplement.ToImmutableArray(); + } + + private static ImmutableArray GetUnimplementedMembers( + this INamedTypeSymbol classOrStructType, + INamedTypeSymbol interfaceType, + Func, CancellationToken, bool> isImplemented, + Func isValidImplementation, + Func> interfaceMemberGetter, + CancellationToken cancellationToken) + { + var q = from m in interfaceMemberGetter(interfaceType, classOrStructType) + where m.Kind != SymbolKind.NamedType + where m.Kind != SymbolKind.Method || ((IMethodSymbol)m).MethodKind == MethodKind.Ordinary + where m.Kind != SymbolKind.Property || ((IPropertySymbol)m).IsIndexer || ((IPropertySymbol)m).CanBeReferencedByName + where m.Kind != SymbolKind.Event || ((IEventSymbol)m).CanBeReferencedByName + where !isImplemented(classOrStructType, m, isValidImplementation, cancellationToken) + select m; + + return q.ToImmutableArray(); + } + + public static IEnumerable GetAttributeNamedParameters( + this INamedTypeSymbol attributeSymbol, + Compilation compilation, + ISymbol within) + { + var systemAttributeType = compilation.AttributeType(); + + foreach (var type in attributeSymbol.GetBaseTypesAndThis()) + { + if (type.Equals(systemAttributeType)) + { + break; + } + + foreach (var member in type.GetMembers()) + { + var namedParameter = IsAttributeNamedParameter(member, within ?? compilation.Assembly); + if (namedParameter != null) + { + yield return namedParameter; + } + } + } + } + + private static ISymbol? IsAttributeNamedParameter( + ISymbol symbol, + ISymbol within) + { + if (!symbol.CanBeReferencedByName || + !symbol.IsAccessibleWithin(within)) + { + return null; + } + + switch (symbol.Kind) + { + case SymbolKind.Field: + var fieldSymbol = (IFieldSymbol)symbol; + if (!fieldSymbol.IsConst && + !fieldSymbol.IsReadOnly && + !fieldSymbol.IsStatic) + { + return fieldSymbol; + } + + break; + + case SymbolKind.Property: + var propertySymbol = (IPropertySymbol)symbol; + if (!propertySymbol.IsReadOnly && + !propertySymbol.IsWriteOnly && + !propertySymbol.IsStatic && + propertySymbol.GetMethod != null && + propertySymbol.SetMethod != null && + propertySymbol.GetMethod.IsAccessibleWithin(within) && + propertySymbol.SetMethod.IsAccessibleWithin(within)) + { + return propertySymbol; + } + + break; + } + + return null; + } + + private static ImmutableArray GetMembers(INamedTypeSymbol type, ISymbol within) + { + return type.GetMembers(); + } + + /// + /// Gets the set of members in the inheritance chain of that + /// are overridable. The members will be returned in furthest-base type to closest-base + /// type order. i.e. the overridable members of will be at the start + /// of the list, and the members of the direct parent type of + /// will be at the end of the list. + /// + /// If a member has already been overridden (in or any base type) + /// it will not be included in the list. + /// + public static ImmutableArray GetOverridableMembers( + this INamedTypeSymbol containingType, CancellationToken cancellationToken) + { + // Keep track of the symbols we've seen and what order we saw them in. The + // order allows us to produce the symbols in the end from the furthest base-type + // to the closest base-type + var result = new Dictionary(); + var index = 0; + + if (containingType != null && + !containingType.IsScriptClass && + !containingType.IsImplicitClass && + !containingType.IsStatic) + { + if (containingType.TypeKind == TypeKind.Class || containingType.TypeKind == TypeKind.Struct) + { + var baseTypes = containingType.GetBaseTypes().Reverse(); + foreach (var type in baseTypes) + { + cancellationToken.ThrowIfCancellationRequested(); + + // Prefer overrides in derived classes + RemoveOverriddenMembers(result, type, cancellationToken); + + // Retain overridable methods + AddOverridableMembers(result, containingType, type, ref index, cancellationToken); + } + + // Don't suggest already overridden members + RemoveOverriddenMembers(result, containingType, cancellationToken); + } + } + + return result.Keys.OrderBy(s => result[s]).ToImmutableArray(); + } + + private static void AddOverridableMembers( + Dictionary result, INamedTypeSymbol containingType, + INamedTypeSymbol type, ref int index, CancellationToken cancellationToken) + { + foreach (var member in type.GetMembers()) + { + cancellationToken.ThrowIfCancellationRequested(); + + if (IsOverridable(member, containingType)) + { + result[member] = index++; + } + } + } + + private static bool IsOverridable(ISymbol member, INamedTypeSymbol containingType) + { + if (member.IsAbstract || member.IsVirtual || member.IsOverride) + { + if (member.IsSealed) + { + return false; + } + + if (!member.IsAccessibleWithin(containingType)) + { + return false; + } + + switch (member.Kind) + { + case SymbolKind.Event: + return true; + case SymbolKind.Method: + return ((IMethodSymbol)member).MethodKind == MethodKind.Ordinary; + case SymbolKind.Property: + return !((IPropertySymbol)member).IsWithEvents; + } + } + + return false; + } + + private static void RemoveOverriddenMembers( + Dictionary result, INamedTypeSymbol containingType, CancellationToken cancellationToken) + { + foreach (var member in containingType.GetMembers()) + { + cancellationToken.ThrowIfCancellationRequested(); + + var overriddenMember = member.OverriddenMember(); + if (overriddenMember != null) + { + result.Remove(overriddenMember); + } + } + } + + public static INamedTypeSymbol TryConstruct(this INamedTypeSymbol type, ITypeSymbol[] typeArguments) + { + return typeArguments.Length > 0 ? type.Construct(typeArguments) : type; + } + } +} diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/INamespaceOrTypeSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/INamespaceOrTypeSymbolExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/INamespaceOrTypeSymbolExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/INamespaceOrTypeSymbolExtensions.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IParameterSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IParameterSymbolExtensions.cs new file mode 100644 index 0000000000000..069f83696f849 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/IParameterSymbolExtensions.cs @@ -0,0 +1,23 @@ +// 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 + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ + internal static partial class IParameterSymbolExtensions + { + public static bool IsRefOrOut(this IParameterSymbol symbol) + { + switch (symbol.RefKind) + { + case RefKind.Ref: + case RefKind.Out: + return true; + default: + return false; + } + } + } +} diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.IsUnsafeVisitor.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.IsUnsafeVisitor.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions.IsUnsafeVisitor.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.IsUnsafeVisitor.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs new file mode 100644 index 0000000000000..56c7d3fc07591 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs @@ -0,0 +1,752 @@ +// 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; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Threading; +using Microsoft.CodeAnalysis.PooledObjects; +using Microsoft.CodeAnalysis.Shared.Utilities; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ + internal static partial class ISymbolExtensions + { + public static string ToNameDisplayString(this ISymbol symbol) + { + return symbol.ToDisplayString(SymbolDisplayFormats.NameFormat); + } + + public static string ToSignatureDisplayString(this ISymbol symbol) + { + return symbol.ToDisplayString(SymbolDisplayFormats.SignatureFormat); + } + + public static bool HasPublicResultantVisibility(this ISymbol symbol) + => symbol.GetResultantVisibility() == SymbolVisibility.Public; + + public static SymbolVisibility GetResultantVisibility(this ISymbol symbol) + { + // Start by assuming it's visible. + var visibility = SymbolVisibility.Public; + + switch (symbol.Kind) + { + case SymbolKind.Alias: + // Aliases are uber private. They're only visible in the same file that they + // were declared in. + return SymbolVisibility.Private; + + case SymbolKind.Parameter: + // Parameters are only as visible as their containing symbol + return GetResultantVisibility(symbol.ContainingSymbol); + + case SymbolKind.TypeParameter: + // Type Parameters are private. + return SymbolVisibility.Private; + } + + while (symbol != null && symbol.Kind != SymbolKind.Namespace) + { + switch (symbol.DeclaredAccessibility) + { + // If we see anything private, then the symbol is private. + case Accessibility.NotApplicable: + case Accessibility.Private: + return SymbolVisibility.Private; + + // If we see anything internal, then knock it down from public to + // internal. + case Accessibility.Internal: + case Accessibility.ProtectedAndInternal: + visibility = SymbolVisibility.Internal; + break; + + // For anything else (Public, Protected, ProtectedOrInternal), the + // symbol stays at the level we've gotten so far. + } + + symbol = symbol.ContainingSymbol; + } + + return visibility; + } + + public static ISymbol? OverriddenMember(this ISymbol symbol) + { + switch (symbol.Kind) + { + case SymbolKind.Event: + return ((IEventSymbol)symbol).OverriddenEvent; + + case SymbolKind.Method: + return ((IMethodSymbol)symbol).OverriddenMethod; + + case SymbolKind.Property: + return ((IPropertySymbol)symbol).OverriddenProperty; + } + + return null; + } + + public static ImmutableArray ExplicitInterfaceImplementations(this ISymbol symbol) + => symbol switch + { + IEventSymbol @event => ImmutableArray.CastUp(@event.ExplicitInterfaceImplementations), + IMethodSymbol method => ImmutableArray.CastUp(method.ExplicitInterfaceImplementations), + IPropertySymbol property => ImmutableArray.CastUp(property.ExplicitInterfaceImplementations), + _ => ImmutableArray.Create(), + }; + + public static ImmutableArray ExplicitOrImplicitInterfaceImplementations(this ISymbol symbol) + { + var containingType = symbol.ContainingType; + var query = from iface in containingType.AllInterfaces + from interfaceMember in iface.GetMembers() + let impl = containingType.FindImplementationForInterfaceMember(interfaceMember) + where symbol.Equals(impl) + select interfaceMember; + return query.ToImmutableArray(); + } + + public static ImmutableArray ImplicitInterfaceImplementations(this ISymbol symbol) + => symbol.ExplicitOrImplicitInterfaceImplementations().Except(symbol.ExplicitInterfaceImplementations()).ToImmutableArray(); + + public static bool IsOverridable([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + // Members can only have overrides if they are virtual, abstract or override and is not + // sealed. + return symbol?.ContainingType?.TypeKind == TypeKind.Class && + (symbol.IsVirtual || symbol.IsAbstract || symbol.IsOverride) && + !symbol.IsSealed; + } + + public static bool IsImplementableMember([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + if (symbol != null && + symbol.ContainingType != null && + symbol.ContainingType.TypeKind == TypeKind.Interface) + { + if (symbol.Kind == SymbolKind.Event) + { + return true; + } + + if (symbol.Kind == SymbolKind.Property) + { + return true; + } + + if (symbol.Kind == SymbolKind.Method) + { + var methodSymbol = (IMethodSymbol)symbol; + if (methodSymbol.MethodKind == MethodKind.Ordinary || + methodSymbol.MethodKind == MethodKind.PropertyGet || + methodSymbol.MethodKind == MethodKind.PropertySet) + { + return true; + } + } + } + + return false; + } + + public static INamedTypeSymbol? GetContainingTypeOrThis(this ISymbol symbol) + { + if (symbol is INamedTypeSymbol namedType) + { + return namedType; + } + + return symbol.ContainingType; + } + + public static bool IsPointerType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol is IPointerTypeSymbol; + } + + public static bool IsErrorType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + => (symbol as ITypeSymbol)?.TypeKind == TypeKind.Error; + + public static bool IsModuleType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as ITypeSymbol)?.IsModuleType() == true; + } + + public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as ITypeSymbol)?.IsInterfaceType() == true; + } + + public static bool IsArrayType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol?.Kind == SymbolKind.ArrayType; + } + + public static bool IsTupleType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as ITypeSymbol)?.IsTupleType ?? false; + } + + public static bool IsAnonymousFunction([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IMethodSymbol)?.MethodKind == MethodKind.AnonymousFunction; + } + + public static bool IsKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, SymbolKind kind) + { + return symbol.MatchesKind(kind); + } + + public static bool MatchesKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, SymbolKind kind) + { + return symbol?.Kind == kind; + } + + public static bool MatchesKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, SymbolKind kind1, SymbolKind kind2) + { + return symbol != null + && (symbol.Kind == kind1 || symbol.Kind == kind2); + } + + public static bool MatchesKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, SymbolKind kind1, SymbolKind kind2, SymbolKind kind3) + { + return symbol != null + && (symbol.Kind == kind1 || symbol.Kind == kind2 || symbol.Kind == kind3); + } + + public static bool MatchesKind([NotNullWhen(returnValue: true)] this ISymbol? symbol, params SymbolKind[] kinds) + { + return symbol != null + && kinds.Contains(symbol.Kind); + } + + public static bool IsReducedExtension([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol is IMethodSymbol && ((IMethodSymbol)symbol).MethodKind == MethodKind.ReducedExtension; + } + + public static bool IsEnumMember([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol?.Kind == SymbolKind.Field && symbol.ContainingType.IsEnumType(); + } + + public static bool IsExtensionMethod(this ISymbol symbol) + { + return symbol.Kind == SymbolKind.Method && ((IMethodSymbol)symbol).IsExtensionMethod; + } + + public static bool IsLocalFunction([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol != null && symbol.Kind == SymbolKind.Method && ((IMethodSymbol)symbol).MethodKind == MethodKind.LocalFunction; + } + + public static bool IsModuleMember([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol != null && symbol.ContainingSymbol is INamedTypeSymbol && symbol.ContainingType.TypeKind == TypeKind.Module; + } + + public static bool IsConstructor([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Constructor; + } + + public static bool IsStaticConstructor([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IMethodSymbol)?.MethodKind == MethodKind.StaticConstructor; + } + + public static bool IsDestructor([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Destructor; + } + + public static bool IsUserDefinedOperator([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IMethodSymbol)?.MethodKind == MethodKind.UserDefinedOperator; + } + + public static bool IsConversion([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Conversion; + } + + public static bool IsOrdinaryMethod([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IMethodSymbol)?.MethodKind == MethodKind.Ordinary; + } + + public static bool IsOrdinaryMethodOrLocalFunction([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + if (!(symbol is IMethodSymbol method)) + { + return false; + } + + return method.MethodKind == MethodKind.Ordinary + || method.MethodKind == MethodKind.LocalFunction; + } + + public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol is ITypeSymbol && ((ITypeSymbol)symbol).TypeKind == TypeKind.Delegate; + } + + public static bool IsAnonymousType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol is INamedTypeSymbol && ((INamedTypeSymbol)symbol).IsAnonymousType; + } + + public static bool IsNormalAnonymousType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol.IsAnonymousType() && !symbol.IsDelegateType(); + } + + public static bool IsAnonymousDelegateType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol.IsAnonymousType() && symbol.IsDelegateType(); + } + + public static bool IsAnonymousTypeProperty([NotNullWhen(returnValue: true)] this ISymbol? symbol) + => symbol is IPropertySymbol && symbol.ContainingType.IsNormalAnonymousType(); + + public static bool IsTupleField([NotNullWhen(returnValue: true)] this ISymbol? symbol) + => symbol is IFieldSymbol && symbol.ContainingType.IsTupleType; + + public static bool IsIndexer([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IPropertySymbol)?.IsIndexer == true; + } + + public static bool IsWriteableFieldOrProperty([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + switch (symbol) + { + case IFieldSymbol fieldSymbol: + return !fieldSymbol.IsReadOnly && !fieldSymbol.IsConst; + case IPropertySymbol propertySymbol: + return !propertySymbol.IsReadOnly; + } + + return false; + } + + public static ITypeSymbol? GetMemberType(this ISymbol symbol) + { + switch (symbol) + { + case IFieldSymbol fieldSymbol: + return fieldSymbol.Type; + case IPropertySymbol propertySymbol: + return propertySymbol.Type; + case IMethodSymbol methodSymbol: + return methodSymbol.ReturnType; + case IEventSymbol eventSymbol: + return eventSymbol.Type; + } + + return null; + } + + public static int GetArity(this ISymbol symbol) + { + switch (symbol.Kind) + { + case SymbolKind.NamedType: + return ((INamedTypeSymbol)symbol).Arity; + case SymbolKind.Method: + return ((IMethodSymbol)symbol).Arity; + default: + return 0; + } + } + + [return: NotNullIfNotNull(parameterName: "symbol")] + public static ISymbol? GetOriginalUnreducedDefinition(this ISymbol? symbol) + { + if (symbol.IsTupleField()) + { + return symbol; + } + + if (symbol.IsReducedExtension()) + { + // note: ReducedFrom is only a method definition and includes no type arguments. + symbol = ((IMethodSymbol)symbol).GetConstructedReducedFrom(); + } + + if (symbol.IsFunctionValue()) + { + if (symbol.ContainingSymbol is IMethodSymbol method) + { + symbol = method; + + if (method.AssociatedSymbol != null) + { + symbol = method.AssociatedSymbol; + } + } + } + + if (symbol.IsNormalAnonymousType() || symbol.IsAnonymousTypeProperty()) + { + return symbol; + } + + if (symbol is IParameterSymbol parameter) + { + var method = parameter.ContainingSymbol as IMethodSymbol; + if (method?.IsReducedExtension() == true) + { + symbol = method.GetConstructedReducedFrom().Parameters[parameter.Ordinal + 1]; + } + } + + return symbol?.OriginalDefinition; + } + + public static bool IsFunctionValue([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol is ILocalSymbol && ((ILocalSymbol)symbol).IsFunctionValue; + } + + public static bool IsThisParameter([NotNullWhen(returnValue: true)] this ISymbol? symbol) + => symbol?.Kind == SymbolKind.Parameter && ((IParameterSymbol)symbol).IsThis; + + [return: NotNullIfNotNull(parameterName: "symbol")] + public static ISymbol? ConvertThisParameterToType(this ISymbol? symbol) + { + if (symbol.IsThisParameter()) + { + return ((IParameterSymbol)symbol).Type; + } + + return symbol; + } + + public static bool IsParams([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + var parameters = symbol.GetParameters(); + return parameters.Length > 0 && parameters[parameters.Length - 1].IsParams; + } + + public static ImmutableArray GetParameters(this ISymbol? symbol) + { + switch (symbol) + { + case IMethodSymbol m: return m.Parameters; + case IPropertySymbol nt: return nt.Parameters; + default: return ImmutableArray.Empty; + } + } + + public static ImmutableArray GetTypeParameters(this ISymbol? symbol) + { + switch (symbol) + { + case IMethodSymbol m: return m.TypeParameters; + case INamedTypeSymbol nt: return nt.TypeParameters; + default: return ImmutableArray.Empty; + } + } + + public static ImmutableArray GetAllTypeParameters(this ISymbol? symbol) + { + var results = ArrayBuilder.GetInstance(); + + while (symbol != null) + { + results.AddRange(symbol.GetTypeParameters()); + symbol = symbol.ContainingType; + } + + return results.ToImmutableAndFree(); + } + + public static ImmutableArray GetTypeArguments(this ISymbol? symbol) + { + switch (symbol) + { + case IMethodSymbol m: return m.TypeArguments; + case INamedTypeSymbol nt: return nt.TypeArguments; + default: return ImmutableArray.Create(); + } + } + + public static ImmutableArray GetAllTypeArguments(this ISymbol symbol) + { + var results = ArrayBuilder.GetInstance(); + results.AddRange(symbol.GetTypeArguments()); + + var containingType = symbol.ContainingType; + while (containingType != null) + { + results.AddRange(containingType.GetTypeArguments()); + containingType = containingType.ContainingType; + } + + return results.ToImmutableAndFree(); + } + + public static bool IsAttribute([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as ITypeSymbol)?.IsAttribute() == true; + } + + /// + /// Returns true if this symbol contains anything unsafe within it. for example + /// List<int*[]> is unsafe, as it "int* Goo { get; }" + /// + public static bool IsUnsafe([NotNullWhen(returnValue: true)] this ISymbol? member) + { + // TODO(cyrusn): Defer to compiler code to handle this once it can. + return member?.Accept(new IsUnsafeVisitor()) == true; + } + + public static ITypeSymbol ConvertToType( + this ISymbol? symbol, + Compilation compilation, + bool extensionUsedAsInstance = false) + { + if (symbol is ITypeSymbol type) + { + return type; + } + + if (symbol is IMethodSymbol method && method.Parameters.All(p => p.RefKind == RefKind.None)) + { + var count = extensionUsedAsInstance ? Math.Max(0, method.Parameters.Length - 1) : method.Parameters.Length; + var skip = extensionUsedAsInstance ? 1 : 0; + + string WithArity(string typeName, int arity) => arity > 0 ? typeName + '`' + arity : typeName; + + // Convert the symbol to Func<...> or Action<...> + var delegateType = compilation.GetTypeByMetadataName(method.ReturnsVoid + ? WithArity("System.Action", count) + : WithArity("System.Func", count + 1)); + + if (delegateType != null) + { + var types = method.Parameters + .Skip(skip) + .Select(p => (p.Type ?? compilation.GetSpecialType(SpecialType.System_Object)).WithNullableAnnotation(p.NullableAnnotation)); + + if (!method.ReturnsVoid) + { + // +1 for the return type. + types = types.Concat((method.ReturnType ?? compilation.GetSpecialType(SpecialType.System_Object)).WithNullableAnnotation(method.ReturnNullableAnnotation)); + } + + return delegateType.TryConstruct(types.ToArray()); + } + } + + // Otherwise, just default to object. + return compilation.ObjectType; + } + + public static bool IsStaticType([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol != null && symbol.Kind == SymbolKind.NamedType && symbol.IsStatic; + } + + public static bool IsNamespace([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol?.Kind == SymbolKind.Namespace; + } + + public static bool IsOrContainsAccessibleAttribute( + [NotNullWhen(returnValue: true)] this ISymbol? symbol, ISymbol withinType, IAssemblySymbol withinAssembly, CancellationToken cancellationToken) + { + var namespaceOrType = symbol is IAliasSymbol alias ? alias.Target : symbol as INamespaceOrTypeSymbol; + if (namespaceOrType == null) + { + return false; + } + + // PERF: Avoid allocating a lambda capture + foreach (var type in namespaceOrType.GetAllTypes(cancellationToken)) + { + if (type.IsAttribute() && type.IsAccessibleWithin(withinType ?? withinAssembly)) + { + return true; + } + } + + return false; + } + + public static IEnumerable GetValidAnonymousTypeProperties(this ISymbol symbol) + { + Contract.ThrowIfFalse(symbol.IsNormalAnonymousType()); + return ((INamedTypeSymbol)symbol).GetMembers().OfType().Where(p => p.CanBeReferencedByName); + } + + public static Accessibility ComputeResultantAccessibility(this ISymbol? symbol, ITypeSymbol finalDestination) + { + if (symbol == null) + { + return Accessibility.Private; + } + + switch (symbol.DeclaredAccessibility) + { + default: + return symbol.DeclaredAccessibility; + case Accessibility.ProtectedAndInternal: + return symbol.ContainingAssembly.GivesAccessTo(finalDestination.ContainingAssembly) + ? Accessibility.ProtectedAndInternal + : Accessibility.Internal; + case Accessibility.ProtectedOrInternal: + return symbol.ContainingAssembly.GivesAccessTo(finalDestination.ContainingAssembly) + ? Accessibility.ProtectedOrInternal + : Accessibility.Protected; + } + } + + /// + /// Returns true if symbol is a local variable and its declaring syntax node is + /// after the current position, false otherwise (including for non-local symbols) + /// + public static bool IsInaccessibleLocal(this ISymbol symbol, int position) + { + if (symbol.Kind != SymbolKind.Local) + { + return false; + } + + // Implicitly declared locals (with Option Explicit Off in VB) are scoped to the entire + // method and should always be considered accessible from within the same method. + if (symbol.IsImplicitlyDeclared) + { + return false; + } + + var declarationSyntax = symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault(); + return declarationSyntax != null && position < declarationSyntax.SpanStart; + } + + public static bool IsAccessor([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return symbol.IsPropertyAccessor() || symbol.IsEventAccessor(); + } + + public static bool IsPropertyAccessor([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + return (symbol as IMethodSymbol)?.MethodKind.IsPropertyAccessor() == true; + } + + public static bool IsEventAccessor([NotNullWhen(returnValue: true)] this ISymbol? symbol) + { + var method = symbol as IMethodSymbol; + return method != null && + (method.MethodKind == MethodKind.EventAdd || + method.MethodKind == MethodKind.EventRaise || + method.MethodKind == MethodKind.EventRemove); + } + + public static bool IsFromSource(this ISymbol symbol) + => symbol.Locations.Any() && symbol.Locations.All(location => location.IsInSource); + + public static bool IsNonImplicitAndFromSource(this ISymbol symbol) + => !symbol.IsImplicitlyDeclared && symbol.IsFromSource(); + + public static ITypeSymbol? GetSymbolType(this ISymbol? symbol) + { + switch (symbol) + { + case ILocalSymbol localSymbol: + return localSymbol.Type; + case IFieldSymbol fieldSymbol: + return fieldSymbol.Type; + case IPropertySymbol propertySymbol: + return propertySymbol.Type; + case IParameterSymbol parameterSymbol: + return parameterSymbol.Type; + case IAliasSymbol aliasSymbol: + return aliasSymbol.Target as ITypeSymbol; + } + + return symbol as ITypeSymbol; + } + + /// + /// If the is a method symbol, returns if the method's return type is "awaitable", but not if it's . + /// If the is a type symbol, returns if that type is "awaitable". + /// An "awaitable" is any type that exposes a GetAwaiter method which returns a valid "awaiter". This GetAwaiter method may be an instance method or an extension method. + /// + public static bool IsAwaitableNonDynamic([NotNullWhen(returnValue: true)] this ISymbol? symbol, SemanticModel semanticModel, int position) + { + var methodSymbol = symbol as IMethodSymbol; + ITypeSymbol? typeSymbol = null; + + if (methodSymbol == null) + { + typeSymbol = symbol as ITypeSymbol; + if (typeSymbol == null) + { + return false; + } + } + else + { + if (methodSymbol.ReturnType == null) + { + return false; + } + } + + // otherwise: needs valid GetAwaiter + var potentialGetAwaiters = semanticModel.LookupSymbols(position, + container: typeSymbol ?? methodSymbol!.ReturnType.OriginalDefinition, + name: WellKnownMemberNames.GetAwaiter, + includeReducedExtensionMethods: true); + var getAwaiters = potentialGetAwaiters.OfType().Where(x => !x.Parameters.Any()); + return getAwaiters.Any(VerifyGetAwaiter); + } + + public static bool IsValidGetAwaiter(this IMethodSymbol symbol) + => symbol.Name == WellKnownMemberNames.GetAwaiter && + VerifyGetAwaiter(symbol); + + private static bool VerifyGetAwaiter(IMethodSymbol getAwaiter) + { + var returnType = getAwaiter.ReturnType; + if (returnType == null) + { + return false; + } + + // bool IsCompleted { get } + if (!returnType.GetMembers().OfType().Any(p => p.Name == WellKnownMemberNames.IsCompleted && p.Type.SpecialType == SpecialType.System_Boolean && p.GetMethod != null)) + { + return false; + } + + var methods = returnType.GetMembers().OfType(); + + // NOTE: (vladres) The current version of C# Spec, §7.7.7.3 'Runtime evaluation of await expressions', requires that + // NOTE: the interface method INotifyCompletion.OnCompleted or ICriticalNotifyCompletion.UnsafeOnCompleted is invoked + // NOTE: (rather than any OnCompleted method conforming to a certain pattern). + // NOTE: Should this code be updated to match the spec? + + // void OnCompleted(Action) + // Actions are delegates, so we'll just check for delegates. + if (!methods.Any(x => x.Name == WellKnownMemberNames.OnCompleted && x.ReturnsVoid && x.Parameters.Length == 1 && x.Parameters.First().Type.TypeKind == TypeKind.Delegate)) + { + return false; + } + + // void GetResult() || T GetResult() + return methods.Any(m => m.Name == WellKnownMemberNames.GetResult && !m.Parameters.Any()); + } + } +} diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions_Accessibility.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions_Accessibility.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ISymbolExtensions_Accessibility.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions_Accessibility.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.MinimalAccessibilityVisitor.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.MinimalAccessibilityVisitor.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.MinimalAccessibilityVisitor.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.MinimalAccessibilityVisitor.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.cs new file mode 100644 index 0000000000000..004e62345414a --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.cs @@ -0,0 +1,730 @@ +// 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; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Runtime.CompilerServices; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Shared.Utilities; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ + internal static partial class ITypeSymbolExtensions + { + private const string DefaultParameterName = "p"; + private const string DefaultBuiltInParameterName = "v"; + + public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type) + => type != null && (type.IsReferenceType || type.IsNullable()); + + public static IList GetAllInterfacesIncludingThis(this ITypeSymbol type) + { + var allInterfaces = type.AllInterfaces; + if (type is INamedTypeSymbol namedType && namedType.TypeKind == TypeKind.Interface && !allInterfaces.Contains(namedType)) + { + var result = new List(allInterfaces.Length + 1); + result.Add(namedType); + result.AddRange(allInterfaces); + return result; + } + + return allInterfaces; + } + + public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + return symbol?.TypeKind == TypeKind.Class && symbol.IsAbstract; + } + + public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + return symbol?.SpecialType == SpecialType.System_Void; + } + + public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + => symbol?.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T; + + public static bool IsNullable( + [NotNullWhen(true)] this ITypeSymbol? symbol, + [NotNullWhen(true)] out ITypeSymbol? underlyingType) + { + if (IsNullable(symbol)) + { + underlyingType = ((INamedTypeSymbol)symbol).TypeArguments[0]; + return true; + } + + underlyingType = null; + return false; + } + + public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + return symbol?.TypeKind == TypeKind.Module; + } + + public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + return symbol?.TypeKind == TypeKind.Interface; + } + + public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + return symbol?.TypeKind == TypeKind.Delegate; + } + + public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + return symbol?.TypeKind == TypeKind.Struct; + } + + public static bool IsAnonymousType([NotNullWhen(returnValue: true)] this INamedTypeSymbol? symbol) + { + return symbol?.IsAnonymousType == true; + } + + private static HashSet GetOriginalInterfacesAndTheirBaseInterfaces( + this ITypeSymbol type, + HashSet? symbols = null) + { + symbols ??= new HashSet(SymbolEquivalenceComparer.Instance); + + foreach (var interfaceType in type.Interfaces) + { + symbols.Add(interfaceType.OriginalDefinition); + symbols.AddRange(interfaceType.AllInterfaces.Select(i => i.OriginalDefinition)); + } + + return symbols; + } + + public static IEnumerable GetBaseTypesAndThis(this ITypeSymbol? type) + { + var current = type; + while (current != null) + { + yield return current; + current = current.BaseType; + } + } + + public static IEnumerable GetBaseTypes(this ITypeSymbol type) + { + var current = type.BaseType; + while (current != null) + { + yield return current; + current = current.BaseType; + } + } + + public static IEnumerable GetContainingTypesAndThis(this ITypeSymbol? type) + { + var current = type; + while (current != null) + { + yield return current; + current = current.ContainingType; + } + } + + public static IEnumerable GetContainingTypes(this ITypeSymbol type) + { + var current = type.ContainingType; + while (current != null) + { + yield return current; + current = current.ContainingType; + } + } + + // Determine if "type" inherits from "baseType", ignoring constructed types, optionally including interfaces, + // dealing only with original types. + public static bool InheritsFromOrEquals( + this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces) + { + if (!includeInterfaces) + { + return InheritsFromOrEquals(type, baseType); + } + + return type.GetBaseTypesAndThis().Concat(type.AllInterfaces).Contains(t => SymbolEquivalenceComparer.Instance.Equals(t, baseType)); + } + + // Determine if "type" inherits from "baseType", ignoring constructed types and interfaces, dealing + // only with original types. + public static bool InheritsFromOrEquals( + this ITypeSymbol type, ITypeSymbol baseType) + { + return type.GetBaseTypesAndThis().Contains(t => SymbolEquivalenceComparer.Instance.Equals(t, baseType)); + } + + // Determine if "type" inherits from or implements "baseType", ignoring constructed types, and dealing + // only with original types. + public static bool InheritsFromOrImplementsOrEqualsIgnoringConstruction( + this ITypeSymbol type, ITypeSymbol baseType) + { + var originalBaseType = baseType.OriginalDefinition; + type = type.OriginalDefinition; + + if (SymbolEquivalenceComparer.Instance.Equals(type, originalBaseType)) + { + return true; + } + + IEnumerable baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes(); + return baseTypes.Contains(t => SymbolEquivalenceComparer.Instance.Equals(t.OriginalDefinition, originalBaseType)); + } + + // Determine if "type" inherits from "baseType", ignoring constructed types, and dealing + // only with original types. + public static bool InheritsFromIgnoringConstruction( + this ITypeSymbol type, ITypeSymbol baseType) + { + var originalBaseType = baseType.OriginalDefinition; + + // We could just call GetBaseTypes and foreach over it, but this + // is a hot path in Find All References. This avoid the allocation + // of the enumerator type. + var currentBaseType = type.BaseType; + while (currentBaseType != null) + { + if (SymbolEquivalenceComparer.Instance.Equals(currentBaseType.OriginalDefinition, originalBaseType)) + { + return true; + } + + currentBaseType = currentBaseType.BaseType; + } + + return false; + } + + public static bool ImplementsIgnoringConstruction( + this ITypeSymbol type, ITypeSymbol interfaceType) + { + var originalInterfaceType = interfaceType.OriginalDefinition; + return type.AllInterfaces.Any(t => SymbolEquivalenceComparer.Instance.Equals(t.OriginalDefinition, originalInterfaceType)); + } + + public static bool Implements( + this ITypeSymbol type, ITypeSymbol interfaceType) + { + return type.AllInterfaces.Contains(t => SymbolEquivalenceComparer.Instance.Equals(t, interfaceType)); + } + + public static bool IsAttribute(this ITypeSymbol symbol) + { + for (var b = symbol.BaseType; b != null; b = b.BaseType) + { + if (b.MetadataName == "Attribute" && + b.ContainingType == null && + b.ContainingNamespace != null && + b.ContainingNamespace.Name == "System" && + b.ContainingNamespace.ContainingNamespace != null && + b.ContainingNamespace.ContainingNamespace.IsGlobalNamespace) + { + return true; + } + } + + return false; + } + + public static bool IsFormattableString([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + return symbol?.MetadataName == "FormattableString" + && symbol.ContainingType == null + && symbol.ContainingNamespace?.Name == "System" + && symbol.ContainingNamespace.ContainingNamespace?.IsGlobalNamespace == true; + } + + public static bool IsUnexpressibleTypeParameterConstraint(this ITypeSymbol typeSymbol) + { + if (typeSymbol.IsSealed || typeSymbol.IsValueType) + { + return true; + } + + switch (typeSymbol.TypeKind) + { + case TypeKind.Array: + case TypeKind.Delegate: + return true; + } + + switch (typeSymbol.SpecialType) + { + case SpecialType.System_Array: + case SpecialType.System_Delegate: + case SpecialType.System_MulticastDelegate: + case SpecialType.System_Enum: + case SpecialType.System_ValueType: + return true; + } + + return false; + } + + public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type) + { + if (type != null) + { + switch (type.SpecialType) + { + case SpecialType.System_Byte: + case SpecialType.System_SByte: + case SpecialType.System_Int16: + case SpecialType.System_UInt16: + case SpecialType.System_Int32: + case SpecialType.System_UInt32: + case SpecialType.System_Int64: + case SpecialType.System_UInt64: + case SpecialType.System_Single: + case SpecialType.System_Double: + case SpecialType.System_Decimal: + return true; + } + } + + return false; + } + + public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol) + { + return typeSymbol.Accept(MinimalAccessibilityVisitor.Instance); + } + + public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + switch (symbol) + { + case IArrayTypeSymbol a: return ContainsAnonymousType(a.ElementType); + case IPointerTypeSymbol p: return ContainsAnonymousType(p.PointedAtType); + case INamedTypeSymbol n: return ContainsAnonymousType(n); + default: return false; + } + } + + private static bool ContainsAnonymousType(INamedTypeSymbol type) + { + if (type.IsAnonymousType) + { + return true; + } + + foreach (var typeArg in type.GetAllTypeArguments()) + { + if (ContainsAnonymousType(typeArg)) + { + return true; + } + } + + return false; + } + + public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false) + { + while (true) + { + switch (type) + { + case IArrayTypeSymbol arrayType: + type = arrayType.ElementType; + continue; + case IPointerTypeSymbol pointerType: + type = pointerType.PointedAtType; + continue; + } + + break; + } + + var shortName = GetParameterName(type); + return capitalize ? shortName.ToPascalCase() : shortName.ToCamelCase(); + } + + private static string GetParameterName(ITypeSymbol? type) + { + if (type == null || type.IsAnonymousType() || type.IsTupleType) + { + return DefaultParameterName; + } + + if (type.IsSpecialType() || type.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T) + { + return DefaultBuiltInParameterName; + } + + var shortName = type.GetShortName(); + return shortName.Length == 0 + ? DefaultParameterName + : shortName; + } + + public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol) + { + if (symbol != null) + { + switch (symbol.SpecialType) + { + case SpecialType.System_Object: + case SpecialType.System_Void: + case SpecialType.System_Boolean: + case SpecialType.System_SByte: + case SpecialType.System_Byte: + case SpecialType.System_Decimal: + case SpecialType.System_Single: + case SpecialType.System_Double: + case SpecialType.System_Int16: + case SpecialType.System_Int32: + case SpecialType.System_Int64: + case SpecialType.System_Char: + case SpecialType.System_String: + case SpecialType.System_UInt16: + case SpecialType.System_UInt32: + case SpecialType.System_UInt64: + return true; + } + } + + return false; + } + + public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within) + { + return + typeSymbol.AllInterfaces.Any(i => i.SpecialType == SpecialType.System_Collections_IEnumerable) && + typeSymbol.GetBaseTypesAndThis() + .Union(typeSymbol.GetOriginalInterfacesAndTheirBaseInterfaces()) + .SelectAccessibleMembers(WellKnownMemberNames.CollectionInitializerAddMethodName, within ?? typeSymbol) + .OfType() + .Any(m => m.Parameters.Any()); + } + + public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation) + { + if (typeSymbol != null) + { + var expressionOfT = compilation.ExpressionOfTType(); + if (typeSymbol.OriginalDefinition.Equals(expressionOfT)) + { + var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0]; + return typeArgument as INamedTypeSymbol; + } + + if (typeSymbol.IsDelegateType()) + { + return typeSymbol as INamedTypeSymbol; + } + } + + return null; + } + + public static IEnumerable GetAccessibleMembersInBaseTypes(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol + { + if (containingType == null) + { + return SpecializedCollections.EmptyEnumerable(); + } + + var types = containingType.GetBaseTypes(); + return types.SelectMany(x => x.GetMembers().OfType().Where(m => m.IsAccessibleWithin(within))); + } + + public static ImmutableArray GetAccessibleMembersInThisAndBaseTypes(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol + { + if (containingType == null) + { + return ImmutableArray.Empty; + } + + return containingType.GetBaseTypesAndThis().SelectAccessibleMembers(within).ToImmutableArray(); + } + + public static bool? AreMoreSpecificThan(this IList t1, IList t2) + { + if (t1.Count != t2.Count) + { + return null; + } + + // For t1 to be more specific than t2, it has to be not less specific in every member, + // and more specific in at least one. + + bool? result = null; + for (var i = 0; i < t1.Count; ++i) + { + var r = t1[i].IsMoreSpecificThan(t2[i]); + if (r == null) + { + // We learned nothing. Do nothing. + } + else if (result == null) + { + // We have found the first more specific type. See if + // all the rest on this side are not less specific. + result = r; + } + else if (result != r) + { + // We have more specific types on both left and right, so we + // cannot succeed in picking a better type list. Bail out now. + return null; + } + } + + return result; + } + + private static IEnumerable SelectAccessibleMembers(this IEnumerable? types, ISymbol within) where T : class, ISymbol + { + if (types == null) + { + return ImmutableArray.Empty; + } + + return types.SelectMany(x => x.GetMembers().OfType().Where(m => m.IsAccessibleWithin(within))); + } + + private static IEnumerable SelectAccessibleMembers(this IEnumerable? types, string memberName, ISymbol within) where T : class, ISymbol + { + if (types == null) + { + return ImmutableArray.Empty; + } + + return types.SelectMany(x => x.GetMembers(memberName).OfType().Where(m => m.IsAccessibleWithin(within))); + } + + private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2) + { + // SPEC: A type parameter is less specific than a non-type parameter. + + var isTypeParameter1 = t1 is ITypeParameterSymbol; + var isTypeParameter2 = t2 is ITypeParameterSymbol; + + if (isTypeParameter1 && !isTypeParameter2) + { + return false; + } + + if (!isTypeParameter1 && isTypeParameter2) + { + return true; + } + + if (isTypeParameter1) + { + Debug.Assert(isTypeParameter2); + return null; + } + + if (t1.TypeKind != t2.TypeKind) + { + return null; + } + + // There is an identity conversion between the types and they are both substitutions on type parameters. + // They had better be the same kind. + + // UNDONE: Strip off the dynamics. + + // SPEC: An array type is more specific than another + // SPEC: array type (with the same number of dimensions) + // SPEC: if the element type of the first is + // SPEC: more specific than the element type of the second. + + if (t1 is IArrayTypeSymbol) + { + var arr1 = (IArrayTypeSymbol)t1; + var arr2 = (IArrayTypeSymbol)t2; + + // We should not have gotten here unless there were identity conversions + // between the two types. + + return arr1.ElementType.IsMoreSpecificThan(arr2.ElementType); + } + + // SPEC EXTENSION: We apply the same rule to pointer types. + + if (t1 is IPointerTypeSymbol) + { + var p1 = (IPointerTypeSymbol)t1; + var p2 = (IPointerTypeSymbol)t2; + return p1.PointedAtType.IsMoreSpecificThan(p2.PointedAtType); + } + + // SPEC: A constructed type is more specific than another + // SPEC: constructed type (with the same number of type arguments) if at least one type + // SPEC: argument is more specific and no type argument is less specific than the + // SPEC: corresponding type argument in the other. + + var n1 = t1 as INamedTypeSymbol; + var n2 = t2 as INamedTypeSymbol; + + if (n1 == null) + { + return null; + } + + // We should not have gotten here unless there were identity conversions between the + // two types. + + var allTypeArgs1 = n1.GetAllTypeArguments().ToList(); + var allTypeArgs2 = n2.GetAllTypeArguments().ToList(); + + return allTypeArgs1.AreMoreSpecificThan(allTypeArgs2); + } + + public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation) + { + if (type != null) + { + switch (type.Kind) + { + case SymbolKind.NamedType: + foreach (var baseType in type.GetBaseTypesAndThis()) + { + if (baseType.Equals(compilation.ExceptionType())) + { + return true; + } + } + + break; + + case SymbolKind.TypeParameter: + foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes) + { + if (constraint.IsOrDerivesFromExceptionType(compilation)) + { + return true; + } + } + + break; + } + } + + return false; + } + + public static bool IsEnumType(this ITypeSymbol type) + { + return type.IsValueType && type.TypeKind == TypeKind.Enum; + } + + public static bool? IsMutableValueType(this ITypeSymbol type) + { + if (type.IsNullable()) + { + // Nullable can only be mutable if T is mutable. This case ensures types like 'int?' are treated as + // immutable. + type = type.GetTypeArguments()[0]; + } + + switch (type.SpecialType) + { + case SpecialType.System_Boolean: + case SpecialType.System_Char: + case SpecialType.System_SByte: + case SpecialType.System_Byte: + case SpecialType.System_Int16: + case SpecialType.System_UInt16: + case SpecialType.System_Int32: + case SpecialType.System_UInt32: + case SpecialType.System_Int64: + case SpecialType.System_UInt64: + case SpecialType.System_Decimal: + case SpecialType.System_Single: + case SpecialType.System_Double: + return false; + + case SpecialType.System_IntPtr: + case SpecialType.System_UIntPtr: + return false; + + case SpecialType.System_DateTime: + return false; + + default: + break; + } + + if (type.IsErrorType()) + { + return null; + } + + if (type.TypeKind != TypeKind.Struct) + { + return false; + } + + var hasPrivateField = false; + foreach (var member in type.GetMembers()) + { + if (!(member is IFieldSymbol fieldSymbol)) + { + continue; + } + + hasPrivateField |= fieldSymbol.DeclaredAccessibility == Accessibility.Private; + if (!fieldSymbol.IsConst && !fieldSymbol.IsReadOnly && !fieldSymbol.IsStatic) + { + return true; + } + } + + if (!hasPrivateField) + { + // Some reference assemblies omit information about private fields. If we can't be sure the field is + // immutable, treat it as potentially mutable. + foreach (var attributeData in type.ContainingAssembly.GetAttributes()) + { + if (attributeData.AttributeClass.Name == nameof(ReferenceAssemblyAttribute) + && attributeData.AttributeClass.ToNameDisplayString() == typeof(ReferenceAssemblyAttribute).FullName) + { + return null; + } + } + } + + return false; + } + + public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType) + => iDisposableType != null && + (Equals(iDisposableType, type) || + type?.AllInterfaces.Contains(iDisposableType) == true); + + public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation) + { +#if CODE_STYLE // TODO: Remove this #if once 'WithNullableAnnotation' and 'NullableAnnotation' are available in CodeStyle layer. + return type; +#else + return type.WithNullableAnnotation(symbolForNullableAnnotation.NullableAnnotation); +#endif + } + + public static ITypeSymbol WithNullableAnnotation(this ITypeSymbol type, NullableAnnotation nullableAnnotation) + { +#if CODE_STYLE // TODO: Remove this #if once 'WithNullableAnnotation' is available in CodeStyle layer. + return type; +#else + return type.WithNullableAnnotation(nullableAnnotation); +#endif + } + } +} diff --git a/src/Workspaces/Core/Portable/Utilities/ImmutableArrayExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ImmutableArrayExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ImmutableArrayExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ImmutableArrayExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/LinkedListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/LinkedListExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/LinkedListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/LinkedListExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/LocationExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/LocationExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/LocationExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/LocationExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/MethodKindExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/MethodKindExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/MethodKindExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/MethodKindExtensions.cs diff --git a/src/Workspaces/Core/Portable/Extensions/NotificationOptionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/NotificationOptionExtensions.cs similarity index 91% rename from src/Workspaces/Core/Portable/Extensions/NotificationOptionExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/NotificationOptionExtensions.cs index 5e16b30914e3a..d1214fed96a68 100644 --- a/src/Workspaces/Core/Portable/Extensions/NotificationOptionExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/NotificationOptionExtensions.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.CodeAnalysis.Diagnostics; + namespace Microsoft.CodeAnalysis.CodeStyle { internal static class NotificationOptionExtensions diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ObjectExtensions.TypeSwitch.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ObjectExtensions.TypeSwitch.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ObjectExtensions.TypeSwitch.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ObjectExtensions.TypeSwitch.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ObjectExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ObjectExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ObjectExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ObjectExtensions.cs diff --git a/src/Workspaces/Core/Portable/Extensions/OperationExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/OperationExtensions.cs similarity index 97% rename from src/Workspaces/Core/Portable/Extensions/OperationExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/OperationExtensions.cs index 968d5c0d61958..8faa3de0231ab 100644 --- a/src/Workspaces/Core/Portable/Extensions/OperationExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/OperationExtensions.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using Microsoft.CodeAnalysis.FlowAnalysis; using Microsoft.CodeAnalysis.Operations; +using Microsoft.CodeAnalysis.Shared.Extensions; namespace Microsoft.CodeAnalysis { @@ -305,5 +306,11 @@ public static bool HasAnyOperationDescendant(this ImmutableArray ope { return operationBlocks.HasAnyOperationDescendant(predicate: operation => operation.Kind == kind); } + + public static bool IsNumericLiteral(this IOperation operation) + => operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); + + public static bool IsNullLiteral(this IOperation operand) + => operand is ILiteralOperation { ConstantValue: { HasValue: true, Value: null } }; } } diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ParenthesizedExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ParenthesizedExpressionSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ParenthesizedExpressionSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ParenthesizedExpressionSyntaxExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/PredefinedTypeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/PredefinedTypeExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/PredefinedTypeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/PredefinedTypeExtensions.cs diff --git a/src/Workspaces/Core/Portable/Diagnostics/Extensions_SharedWithCodeStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ReportDiagnosticExtensions.cs similarity index 72% rename from src/Workspaces/Core/Portable/Diagnostics/Extensions_SharedWithCodeStyle.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ReportDiagnosticExtensions.cs index e31c87c240199..e5c2f7d0d53b8 100644 --- a/src/Workspaces/Core/Portable/Diagnostics/Extensions_SharedWithCodeStyle.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ReportDiagnosticExtensions.cs @@ -7,7 +7,7 @@ namespace Microsoft.CodeAnalysis.Diagnostics { - internal static partial class Extensions + internal static partial class ReportDiagnosticExtensions { /// /// Returns the equivalent for a value. @@ -67,24 +67,17 @@ public static ReportDiagnostic WithDefaultSeverity(this ReportDiagnostic reportD return defaultSeverity.ToReportDiagnostic(); } - /// - /// Returns the equivalent for a value. - /// - /// The value. - /// - /// The equivalent for the value. - /// - /// - /// If is not one of the expected values. - /// - public static ReportDiagnostic ToReportDiagnostic(this DiagnosticSeverity diagnosticSeverity) - => diagnosticSeverity switch + public static string ToEditorConfigString(this ReportDiagnostic reportDiagnostic) + { + return reportDiagnostic switch { - DiagnosticSeverity.Hidden => ReportDiagnostic.Hidden, - DiagnosticSeverity.Info => ReportDiagnostic.Info, - DiagnosticSeverity.Warning => ReportDiagnostic.Warn, - DiagnosticSeverity.Error => ReportDiagnostic.Error, - _ => throw ExceptionUtilities.UnexpectedValue(diagnosticSeverity), + ReportDiagnostic.Suppress => EditorConfigSeverityStrings.None, + ReportDiagnostic.Hidden => EditorConfigSeverityStrings.Silent, + ReportDiagnostic.Info => EditorConfigSeverityStrings.Suggestion, + ReportDiagnostic.Warn => EditorConfigSeverityStrings.Warning, + ReportDiagnostic.Error => EditorConfigSeverityStrings.Error, + _ => throw ExceptionUtilities.UnexpectedValue(reportDiagnostic) }; + } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SemanticModelExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SemanticModelExtensions.cs new file mode 100644 index 0000000000000..67e9286ae88ca --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SemanticModelExtensions.cs @@ -0,0 +1,123 @@ +// 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; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ + internal static partial class SemanticModelExtensions + { + /// + /// Gets semantic information, such as type, symbols, and diagnostics, about the parent of a token. + /// + /// The SemanticModel object to get semantic information + /// from. + /// The token to get semantic information from. This must be part of the + /// syntax tree associated with the binding. + /// A cancellation token. + public static SymbolInfo GetSymbolInfo(this SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken) + { + return semanticModel.GetSymbolInfo(token.Parent!, cancellationToken); + } + + public static TSymbol? GetEnclosingSymbol(this SemanticModel semanticModel, int position, CancellationToken cancellationToken) + where TSymbol : class, ISymbol + { + for (var symbol = semanticModel.GetEnclosingSymbol(position, cancellationToken); + symbol != null; + symbol = symbol.ContainingSymbol) + { + if (symbol is TSymbol tSymbol) + { + return tSymbol; + } + } + + return default; + } + + public static ISymbol GetEnclosingNamedTypeOrAssembly(this SemanticModel semanticModel, int position, CancellationToken cancellationToken) + { + return semanticModel.GetEnclosingSymbol(position, cancellationToken) ?? + (ISymbol)semanticModel.Compilation.Assembly; + } + + public static INamedTypeSymbol? GetEnclosingNamedType(this SemanticModel semanticModel, int position, CancellationToken cancellationToken) + { + return semanticModel.GetEnclosingSymbol(position, cancellationToken); + } + + public static INamespaceSymbol? GetEnclosingNamespace(this SemanticModel semanticModel, int position, CancellationToken cancellationToken) + { + return semanticModel.GetEnclosingSymbol(position, cancellationToken); + } + + public static IEnumerable GetExistingSymbols( + this SemanticModel semanticModel, SyntaxNode? container, CancellationToken cancellationToken, Func? descendInto = null) + { + // Ignore an anonymous type property or tuple field. It's ok if they have a name that + // matches the name of the local we're introducing. + return semanticModel.GetAllDeclaredSymbols(container, cancellationToken, descendInto) + .Where(s => !s.IsAnonymousTypeProperty() && !s.IsTupleField()); + } + + public static SemanticModel GetOriginalSemanticModel(this SemanticModel semanticModel) + { + if (!semanticModel.IsSpeculativeSemanticModel) + { + return semanticModel; + } + + Contract.ThrowIfNull(semanticModel.ParentModel); + Contract.ThrowIfTrue(semanticModel.ParentModel.IsSpeculativeSemanticModel); + Contract.ThrowIfTrue(semanticModel.ParentModel.ParentModel != null); + return semanticModel.ParentModel; + } + + public static HashSet GetAllDeclaredSymbols( + this SemanticModel semanticModel, SyntaxNode? container, CancellationToken cancellationToken, Func? filter = null) + { + var symbols = new HashSet(); + if (container != null) + { + GetAllDeclaredSymbols(semanticModel, container, symbols, cancellationToken, filter); + } + + return symbols; + } + + private static void GetAllDeclaredSymbols( + SemanticModel semanticModel, SyntaxNode node, + HashSet symbols, CancellationToken cancellationToken, Func? descendInto = null) + { + var symbol = semanticModel.GetDeclaredSymbol(node, cancellationToken); + + if (symbol != null) + { + symbols.Add(symbol); + } + + foreach (var child in node.ChildNodesAndTokens()) + { + if (child.IsNode) + { + var childNode = child.AsNode()!; + if (ShouldDescendInto(childNode, descendInto)) + { + GetAllDeclaredSymbols(semanticModel, childNode, symbols, cancellationToken, descendInto); + } + } + } + + static bool ShouldDescendInto(SyntaxNode node, Func? filter) + => filter != null ? filter(node) : true; + } + } +} diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SimpleIntervalTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SimpleIntervalTreeExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SimpleIntervalTreeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SimpleIntervalTreeExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SourceTextExtensions_SharedWithCodeStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SourceTextExtensions_SharedWithCodeStyle.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SourceTextExtensions_SharedWithCodeStyle.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SourceTextExtensions_SharedWithCodeStyle.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SpecialTypeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SpecialTypeExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SpecialTypeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SpecialTypeExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/StackExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/StackExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/StackExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/StackExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/StringExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/StringExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/StringExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/StringExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SymbolDisplayPartExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolDisplayPartExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SymbolDisplayPartExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolDisplayPartExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SymbolInfoExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolInfoExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SymbolInfoExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolInfoExtensions.cs diff --git a/src/Workspaces/Core/Portable/Extensions/SymbolUsageInfo.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolUsageInfo.cs similarity index 100% rename from src/Workspaces/Core/Portable/Extensions/SymbolUsageInfo.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolUsageInfo.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxNodeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxNodeExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxNodeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxNodeExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxNodeOrTokenExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxNodeOrTokenExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxNodeOrTokenExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxNodeOrTokenExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTokenExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTokenExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTokenExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTokenExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTokenListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTokenListExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTokenListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTokenListExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTriviaExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTriviaExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTriviaExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTriviaExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTriviaListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTriviaListExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTriviaListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTriviaListExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/TextLineExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/TextLineExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/TextLineExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/TextLineExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/TextSpanExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/TextSpanExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/TextSpanExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/TextSpanExtensions.cs diff --git a/src/Workspaces/Core/Portable/Extensions/TypeOrNamespaceUsageInfo.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/TypeOrNamespaceUsageInfo.cs similarity index 100% rename from src/Workspaces/Core/Portable/Extensions/TypeOrNamespaceUsageInfo.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/TypeOrNamespaceUsageInfo.cs diff --git a/src/Workspaces/Core/Portable/Extensions/ValueUsageInfo.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ValueUsageInfo.cs similarity index 100% rename from src/Workspaces/Core/Portable/Extensions/ValueUsageInfo.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ValueUsageInfo.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ObjectPools/ArrayBuilder.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/ArrayBuilder.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ObjectPools/ArrayBuilder.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/ArrayBuilder.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ObjectPools/Extensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/Extensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ObjectPools/Extensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/Extensions.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ObjectPools/IPooled.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/IPooled.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ObjectPools/IPooled.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/IPooled.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledDisposer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledDisposer.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledDisposer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledDisposer.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledHashSet.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledHashSet.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledHashSet.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledHashSet.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledObject.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledObject.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledObject.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledObject.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledStringBuilder.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledStringBuilder.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledStringBuilder.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/PooledStringBuilder.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ObjectPools/SharedPools.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/SharedPools.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ObjectPools/SharedPools.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/ObjectPools/SharedPools.cs diff --git a/src/Workspaces/Core/Portable/Utilities/AnnotationTable.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/AnnotationTable.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/AnnotationTable.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/AnnotationTable.cs diff --git a/src/Workspaces/Core/Portable/Utilities/AsyncLazy`1.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/AsyncLazy`1.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/AsyncLazy`1.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/AsyncLazy`1.cs diff --git a/src/Workspaces/Core/Portable/Utilities/BKTree.Builder.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.Builder.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/BKTree.Builder.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.Builder.cs diff --git a/src/Workspaces/Core/Portable/Utilities/BKTree.Edge.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.Edge.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/BKTree.Edge.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.Edge.cs diff --git a/src/Workspaces/Core/Portable/Utilities/BKTree.Node.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.Node.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/BKTree.Node.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.Node.cs diff --git a/src/Workspaces/Core/Portable/Utilities/BKTree.Serialization.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.Serialization.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/BKTree.Serialization.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.Serialization.cs diff --git a/src/Workspaces/Core/Portable/Utilities/BKTree.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.cs similarity index 99% rename from src/Workspaces/Core/Portable/Utilities/BKTree.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.cs index 87d1049bfadcb..2b879e77c9282 100644 --- a/src/Workspaces/Core/Portable/Utilities/BKTree.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BKTree.cs @@ -13,7 +13,7 @@ namespace Roslyn.Utilities { /// /// NOTE: Only use if you truly need a BK-tree. If you just want to compare words, use - /// the type instead. + /// the 'SpellChecker' type instead. /// /// An implementation of a Burkhard-Keller tree. Introduced in: /// diff --git a/src/Workspaces/Core/Portable/Utilities/BidirectionalMap.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BidirectionalMap.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/BidirectionalMap.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/BidirectionalMap.cs diff --git a/src/Workspaces/Core/Portable/Utilities/CancellableLazy.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CancellableLazy.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/CancellableLazy.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CancellableLazy.cs diff --git a/src/Workspaces/Core/Portable/Utilities/CancellableLazy`1.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CancellableLazy`1.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/CancellableLazy`1.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CancellableLazy`1.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ComparerWithState.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ComparerWithState.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ComparerWithState.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ComparerWithState.cs diff --git a/src/Workspaces/Core/Portable/Utilities/CompilerUtilities/CompilerPathUtilities.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/CompilerPathUtilities.cs similarity index 75% rename from src/Workspaces/Core/Portable/Utilities/CompilerUtilities/CompilerPathUtilities.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/CompilerPathUtilities.cs index 4051924ecf1dd..54ab7ad70f7ad 100644 --- a/src/Workspaces/Core/Portable/Utilities/CompilerUtilities/CompilerPathUtilities.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/CompilerPathUtilities.cs @@ -7,6 +7,12 @@ namespace Roslyn.Utilities { +#if CODE_STYLE + using Resources = CodeStyleResources; +#else + using Resources = WorkspacesResources; +#endif + internal static class CompilerPathUtilities { internal static void RequireAbsolutePath(string path, string argumentName) @@ -18,7 +24,7 @@ internal static void RequireAbsolutePath(string path, string argumentName) if (!PathUtilities.IsAbsolute(path)) { - throw new ArgumentException(WorkspacesResources.Absolute_path_expected, argumentName); + throw new ArgumentException(Resources.Absolute_path_expected, argumentName); } } } diff --git a/src/Workspaces/Core/Portable/Utilities/CompilerUtilities/ImmutableDictionaryExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/ImmutableDictionaryExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/CompilerUtilities/ImmutableDictionaryExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/ImmutableDictionaryExtensions.cs diff --git a/src/Workspaces/Core/Portable/Utilities/CompilerUtilities/ImmutableHashMap.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/ImmutableHashMap.cs similarity index 99% rename from src/Workspaces/Core/Portable/Utilities/CompilerUtilities/ImmutableHashMap.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/ImmutableHashMap.cs index 14713756249f3..87cb6c7b02ce8 100644 --- a/src/Workspaces/Core/Portable/Utilities/CompilerUtilities/ImmutableHashMap.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/ImmutableHashMap.cs @@ -11,11 +11,18 @@ using System.Diagnostics.Contracts; using System.Linq; using System.Text; +using Microsoft.CodeAnalysis; using Roslyn.Utilities; using Contract = System.Diagnostics.Contracts.Contract; namespace Roslyn.Collections.Immutable { +#if CODE_STYLE + using Resources = CodeStyleResources; +#else + using Resources = WorkspacesResources; +#endif + /// /// An immutable unordered hash map implementation. /// @@ -1155,7 +1162,7 @@ public static void Range(bool condition, string parameterName, string message = private static class Strings { - public static string DuplicateKey => Microsoft.CodeAnalysis.WorkspacesResources.An_element_with_the_same_key_but_a_different_value_already_exists; + public static string DuplicateKey => Resources.An_element_with_the_same_key_but_a_different_value_already_exists; } } } diff --git a/src/Workspaces/Core/Portable/Utilities/CompilerUtilities/ImmutableHashMapExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/ImmutableHashMapExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/CompilerUtilities/ImmutableHashMapExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/CompilerUtilities/ImmutableHashMapExtensions.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ConcatImmutableArray`1.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ConcatImmutableArray`1.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ConcatImmutableArray`1.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ConcatImmutableArray`1.cs diff --git a/src/Workspaces/Core/Portable/Utilities/Contract.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/Contract.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs diff --git a/src/Workspaces/Core/Portable/Utilities/EditDistance.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/EditDistance.cs similarity index 99% rename from src/Workspaces/Core/Portable/Utilities/EditDistance.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/EditDistance.cs index ccb04f81a2331..27662e8520416 100644 --- a/src/Workspaces/Core/Portable/Utilities/EditDistance.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/EditDistance.cs @@ -13,7 +13,7 @@ namespace Roslyn.Utilities { /// /// NOTE: Only use if you truly need an edit distance. If you just want to compare words, use - /// the type instead. + /// the 'SpellChecker' type instead. /// /// Implementation of the Damerau-Levenshtein edit distance algorithm from: /// An Extension of the String-to-String Correction Problem: diff --git a/src/Workspaces/Core/Portable/Utilities/EventMap.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/EventMap.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/EventMap.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/EventMap.cs diff --git a/src/Workspaces/Core/Portable/Utilities/IBidirectionalMap.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IBidirectionalMap.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/IBidirectionalMap.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IBidirectionalMap.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ICacheEntry.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ICacheEntry.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ICacheEntry.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ICacheEntry.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ICollectionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ICollectionExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ICollectionExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ICollectionExtensions.cs diff --git a/src/Workspaces/Core/Portable/Utilities/IDictionaryExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IDictionaryExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/IDictionaryExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IDictionaryExtensions.cs diff --git a/src/Workspaces/Core/Portable/Utilities/IGroupingExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IGroupingExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/IGroupingExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IGroupingExtensions.cs diff --git a/src/Workspaces/Core/Portable/Utilities/IReadOnlyDictionaryExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IReadOnlyDictionaryExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/IReadOnlyDictionaryExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IReadOnlyDictionaryExtensions.cs diff --git a/src/Workspaces/Core/Portable/Utilities/IReadOnlyListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IReadOnlyListExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/IReadOnlyListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IReadOnlyListExtensions.cs diff --git a/src/Workspaces/Core/Portable/Utilities/IReferenceCountedDisposable.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IReferenceCountedDisposable.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/IReferenceCountedDisposable.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IReferenceCountedDisposable.cs diff --git a/src/Workspaces/Core/Portable/Utilities/LazyInitialization.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/LazyInitialization.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/LazyInitialization.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/LazyInitialization.cs diff --git a/src/Workspaces/Core/Portable/Utilities/NonReentrantLock.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/NonReentrantLock.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/NonReentrantLock.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/NonReentrantLock.cs diff --git a/src/Workspaces/Core/Portable/Utilities/PooledBuilderExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PooledBuilderExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/PooledBuilderExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PooledBuilderExtensions.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/PredefinedOperator.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PredefinedOperator.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/PredefinedOperator.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PredefinedOperator.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/PredefinedType.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PredefinedType.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/PredefinedType.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PredefinedType.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ReferenceCountedDisposable.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposable.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ReferenceCountedDisposable.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposable.cs diff --git a/src/Workspaces/Core/Portable/Utilities/ReferenceCountedDisposableCache.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposableCache.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/ReferenceCountedDisposableCache.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposableCache.cs diff --git a/src/Workspaces/Core/Portable/Utilities/RestrictedInternalsVisibleToAttribute.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RestrictedInternalsVisibleToAttribute.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/RestrictedInternalsVisibleToAttribute.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RestrictedInternalsVisibleToAttribute.cs diff --git a/src/Workspaces/Core/Portable/Utilities/SemaphoreSlimFactory.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SemaphoreSlimFactory.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/SemaphoreSlimFactory.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SemaphoreSlimFactory.cs diff --git a/src/Workspaces/Core/Portable/Utilities/SerializableBytes.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SerializableBytes.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/SerializableBytes.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SerializableBytes.cs diff --git a/src/Workspaces/Core/Portable/Utilities/SimpleTaskQueue.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SimpleTaskQueue.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/SimpleTaskQueue.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SimpleTaskQueue.cs diff --git a/src/Workspaces/Core/Portable/Utilities/SoftCrashException.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SoftCrashException.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/SoftCrashException.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SoftCrashException.cs diff --git a/src/Workspaces/Core/Portable/Utilities/SpecializedTasks.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SpecializedTasks.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/SpecializedTasks.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SpecializedTasks.cs diff --git a/src/Workspaces/Core/Portable/Utilities/StringEscapeEncoder.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/StringEscapeEncoder.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/StringEscapeEncoder.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/StringEscapeEncoder.cs diff --git a/src/Workspaces/Core/Portable/Utilities/StringSlice.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/StringSlice.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/StringSlice.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/StringSlice.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SymbolDisplayFormats.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SymbolDisplayFormats.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SymbolDisplayFormats.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SymbolDisplayFormats.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/SymbolEquivalenceComparer.AssemblyComparers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SymbolEquivalenceComparer.AssemblyComparers.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/SymbolEquivalenceComparer.AssemblyComparers.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SymbolEquivalenceComparer.AssemblyComparers.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/SymbolEquivalenceComparer.EquivalenceVisitor.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SymbolEquivalenceComparer.EquivalenceVisitor.cs similarity index 99% rename from src/Workspaces/Core/Portable/Shared/Utilities/SymbolEquivalenceComparer.EquivalenceVisitor.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SymbolEquivalenceComparer.EquivalenceVisitor.cs index a9dcfa2dfb5bc..95c7604378d3e 100644 --- a/src/Workspaces/Core/Portable/Shared/Utilities/SymbolEquivalenceComparer.EquivalenceVisitor.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SymbolEquivalenceComparer.EquivalenceVisitor.cs @@ -45,17 +45,18 @@ public bool AreEquivalent(ISymbol x, ISymbol y, Dictionary + /// Whether or words should be considered similar if one is contained within the other + /// (regardless of edit distance). For example if is true then IService would be considered + /// similar to IServiceFactory despite the edit distance being quite high at 7. + /// + private bool _substringsAreSimilar; + + private static readonly object s_poolGate = new object(); + private static readonly Stack s_pool = new Stack(); + + public static WordSimilarityChecker Allocate(string text, bool substringsAreSimilar) + { + WordSimilarityChecker checker; + lock (s_poolGate) + { + checker = s_pool.Count > 0 + ? s_pool.Pop() + : new WordSimilarityChecker(); + } + + checker.Initialize(text, substringsAreSimilar); + return checker; + } + + private WordSimilarityChecker() + { + } + + private void Initialize(string text, bool substringsAreSimilar) + { + _source = text ?? throw new ArgumentNullException(nameof(text)); + _threshold = GetThreshold(_source); + _editDistance = new EditDistance(text); + _substringsAreSimilar = substringsAreSimilar; + } + + public void Free() + { + _editDistance?.Dispose(); + _source = null; + _editDistance = null; + _lastAreSimilarResult = default; + lock (s_poolGate) + { + s_pool.Push(this); + } + } + + public static bool AreSimilar(string originalText, string candidateText) + => AreSimilar(originalText, candidateText, substringsAreSimilar: false); + + public static bool AreSimilar(string originalText, string candidateText, bool substringsAreSimilar) + => AreSimilar(originalText, candidateText, substringsAreSimilar, out var unused); + + public static bool AreSimilar(string originalText, string candidateText, out double similarityWeight) + { + return AreSimilar( + originalText, candidateText, + substringsAreSimilar: false, similarityWeight: out similarityWeight); + } + + /// + /// Returns true if 'originalText' and 'candidateText' are likely a misspelling of each other. + /// Returns false otherwise. If it is a likely misspelling a similarityWeight is provided + /// to help rank the match. Lower costs mean it was a better match. + /// + public static bool AreSimilar(string originalText, string candidateText, bool substringsAreSimilar, out double similarityWeight) + { + var checker = Allocate(originalText, substringsAreSimilar); + var result = checker.AreSimilar(candidateText, out similarityWeight); + checker.Free(); + + return result; + } + + internal static int GetThreshold(string value) + => value.Length <= 4 ? 1 : 2; + + public bool AreSimilar(string candidateText) + => AreSimilar(candidateText, out var similarityWeight); + + public bool AreSimilar(string candidateText, out double similarityWeight) + { + if (_source.Length < 3) + { + // If we're comparing strings that are too short, we'll find + // far too many spurious hits. Don't even bother in this case. + similarityWeight = double.MaxValue; + return false; + } + + if (_lastAreSimilarResult.CandidateText == candidateText) + { + similarityWeight = _lastAreSimilarResult.SimilarityWeight; + return _lastAreSimilarResult.AreSimilar; + } + + var result = AreSimilarWorker(candidateText, out similarityWeight); + _lastAreSimilarResult = new CacheResult(candidateText, result, similarityWeight); + return result; + } + + private bool AreSimilarWorker(string candidateText, out double similarityWeight) + { + similarityWeight = double.MaxValue; + + // If the two strings differ by more characters than the cost threshold, then there's + // no point in even computing the edit distance as it would necessarily take at least + // that many additions/deletions. + if (Math.Abs(_source.Length - candidateText.Length) <= _threshold) + { + similarityWeight = _editDistance.GetEditDistance(candidateText, _threshold); + } + + if (similarityWeight > _threshold) + { + // it had a high cost. However, the string the user typed was contained + // in the string we're currently looking at. That's enough to consider it + // although we place it just at the threshold (i.e. it's worse than all + // other matches). + if (_substringsAreSimilar && candidateText.IndexOf(_source, StringComparison.OrdinalIgnoreCase) >= 0) + { + similarityWeight = _threshold; + } + else + { + return false; + } + } + + Debug.Assert(similarityWeight <= _threshold); + + similarityWeight += Penalty(candidateText, _source); + return true; + } + + private static double Penalty(string candidateText, string originalText) + { + var lengthDifference = Math.Abs(originalText.Length - candidateText.Length); + if (lengthDifference != 0) + { + // For all items of the same edit cost, we penalize those that are + // much longer than the original text versus those that are only + // a little longer. + // + // Note: even with this penalty, all matches of cost 'X' will all still + // cost less than matches of cost 'X + 1'. i.e. the penalty is in the + // range [0, 1) and only serves to order matches of the same cost. + // + // Here's the relation of the first few values of length diff and penalty: + // LengthDiff -> Penalty + // 1 -> .5 + // 2 -> .66 + // 3 -> .75 + // 4 -> .8 + // And so on and so forth. + var penalty = 1.0 - (1.0 / (lengthDifference + 1)); + return penalty; + } + + return 0; + } + } +} diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.vb similarity index 99% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.vb index f378700b86a5f..d7618376920e8 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/SyntaxTreeExtensions_SharedWithCodeStyle.vb @@ -3,9 +3,9 @@ ' See the LICENSE file in the project root for more information. Imports System.Runtime.CompilerServices -Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.VisualBasic Imports Microsoft.CodeAnalysis.VisualBasic.Syntax +Imports Roslyn.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Partial Friend Module SyntaxTreeExtensions diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTriviaExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/SyntaxTriviaExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTriviaExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/SyntaxTriviaExtensions.vb diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems new file mode 100644 index 0000000000000..5dfe47addd944 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems @@ -0,0 +1,24 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.VisualBasic.Shared + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.shproj b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.shproj new file mode 100644 index 0000000000000..b230998bdfbf0 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.shproj @@ -0,0 +1,13 @@ + + + + {CEC0DCE7-8D52-45C3-9295-FC7B16BD2451} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems new file mode 100644 index 0000000000000..02f6a224c054f --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems @@ -0,0 +1,85 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.CSharp.Shared + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.shproj b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.shproj new file mode 100644 index 0000000000000..5f99ce9c893d3 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.shproj @@ -0,0 +1,13 @@ + + + + {438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/Extensions/ArgumentSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ArgumentSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ArgumentSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ArgumentSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ArrowExpressionClauseSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ArrowExpressionClauseSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ArrowExpressionClauseSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ArrowExpressionClauseSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/AssignmentExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/AssignmentExpressionSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/AssignmentExpressionSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/AssignmentExpressionSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/AttributeArgumentSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/AttributeArgumentSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/AttributeArgumentSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/AttributeArgumentSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/BaseArgumentListSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BaseArgumentListSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/BaseArgumentListSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BaseArgumentListSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/BasePropertyDeclarationSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BasePropertyDeclarationSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/BasePropertyDeclarationSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BasePropertyDeclarationSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/BlockSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BlockSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/BlockSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BlockSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/CastExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/CastExpressionSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/CastExpressionSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/CastExpressionSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/CompilationUnitSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/CompilationUnitSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/CompilationUnitSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/CompilationUnitSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxNodeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxNodeExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxNodeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxNodeExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTokenExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTokenExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTokenExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTokenExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs similarity index 99% rename from src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs index 983302c7e152c..1593c2a229c9a 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery { - internal static class SyntaxTreeExtensions + internal static partial class SyntaxTreeExtensions { public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken) { diff --git a/src/Workspaces/CSharp/Portable/Extensions/ConversionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ConversionExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ConversionExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ConversionExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.DirectiveInfo.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DirectiveSyntaxExtensions.DirectiveInfo.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.DirectiveInfo.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DirectiveSyntaxExtensions.DirectiveInfo.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.DirectiveSyntaxEqualityComparer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DirectiveSyntaxExtensions.DirectiveSyntaxEqualityComparer.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.DirectiveSyntaxEqualityComparer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DirectiveSyntaxExtensions.DirectiveSyntaxEqualityComparer.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.DirectiveWalker.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DirectiveSyntaxExtensions.DirectiveWalker.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.DirectiveWalker.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DirectiveSyntaxExtensions.DirectiveWalker.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DirectiveSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/DirectiveSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DirectiveSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/DocumentationCommentExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/DocumentationCommentExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/DocumentationCommentExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs similarity index 99% rename from src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs index 465b52bf00c72..bc9ae3ba3cf79 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs @@ -14,6 +14,8 @@ namespace Microsoft.CodeAnalysis.CSharp.Extensions { + using OptionSet = Options.OptionSet; + internal static partial class ExpressionSyntaxExtensions { public static ExpressionSyntax WalkUpParentheses(this ExpressionSyntax expression) diff --git a/src/Workspaces/CSharp/Portable/Extensions/ForEachStatementSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ForEachStatementSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ForEachStatementSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ForEachStatementSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ILocalSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ILocalSymbolExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ILocalSymbolExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ILocalSymbolExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ITypeParameterSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeParameterSymbolExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ITypeParameterSymbolExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeParameterSymbolExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.ExpressionSyntaxGeneratorVisitor.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.ExpressionSyntaxGeneratorVisitor.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.ExpressionSyntaxGeneratorVisitor.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.ExpressionSyntaxGeneratorVisitor.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs similarity index 97% rename from src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs index e4ea4d2b78d5e..2ea70226d04d2 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs @@ -70,6 +70,7 @@ public override TypeSyntax VisitArrayType(IArrayTypeSymbol symbol) { underlyingType = innerArray.ElementType; +#if !CODE_STYLE // TODO: Remove the #if once NullableAnnotation is available. if (underlyingType.NullableAnnotation == NullableAnnotation.Annotated) { // If the inner array we just moved to is also nullable, then @@ -88,6 +89,7 @@ public override TypeSyntax VisitArrayType(IArrayTypeSymbol symbol) break; } +#endif } var elementTypeSyntax = underlyingType.GenerateTypeSyntax(); @@ -104,10 +106,12 @@ public override TypeSyntax VisitArrayType(IArrayTypeSymbol symbol) TypeSyntax arrayTypeSyntax = SyntaxFactory.ArrayType(elementTypeSyntax, ranks.ToSyntaxList()); +#if !CODE_STYLE // TODO: Remove the #if once NullableAnnotation is available. if (symbol.NullableAnnotation == NullableAnnotation.Annotated) { arrayTypeSyntax = SyntaxFactory.NullableType(arrayTypeSyntax); } +#endif return AddInformationTo(arrayTypeSyntax, symbol); } @@ -255,10 +259,12 @@ public override TypeSyntax VisitNamedType(INamedTypeSymbol symbol) } } +#if !CODE_STYLE // TODO: Remove the #if once NullableAnnotation is available. if (symbol.NullableAnnotation == NullableAnnotation.Annotated) { typeSyntax = AddInformationTo(SyntaxFactory.NullableType(typeSyntax), symbol); } +#endif return typeSyntax; } @@ -287,7 +293,7 @@ public override TypeSyntax VisitNamespace(INamespaceSymbol symbol) /// /// We always unilaterally add "global::" to all named types/namespaces. This /// will then be trimmed off if possible by calls to - /// + /// /// private TypeSyntax AddGlobalAlias(INamespaceOrTypeSymbol symbol, SimpleNameSyntax syntax) { diff --git a/src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.DeclarationFinder.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/MemberDeclarationSyntaxExtensions.DeclarationFinder.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.DeclarationFinder.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/MemberDeclarationSyntaxExtensions.DeclarationFinder.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.LocalDeclarationMap.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/MemberDeclarationSyntaxExtensions.LocalDeclarationMap.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.LocalDeclarationMap.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/MemberDeclarationSyntaxExtensions.LocalDeclarationMap.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/NameSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/NameSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/NameSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/NameSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/NamespaceDeclarationSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/NamespaceDeclarationSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/NamespaceDeclarationSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/NamespaceDeclarationSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/OperatorPrecedence.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/OperatorPrecedence.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/OperatorPrecedence.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/OperatorPrecedence.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/ParenthesizedExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ParenthesizedExpressionSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/ParenthesizedExpressionSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ParenthesizedExpressionSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/QueryExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/QueryExpressionSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/QueryExpressionSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/QueryExpressionSyntaxExtensions.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SemanticModelExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SemanticModelExtensions.cs new file mode 100644 index 0000000000000..fef4fa140afeb --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SemanticModelExtensions.cs @@ -0,0 +1,477 @@ +// 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.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles; +using Microsoft.CodeAnalysis.PooledObjects; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Utilities; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.CSharp.Extensions +{ + internal static partial class SemanticModelExtensions + { + public static IEnumerable LookupTypeRegardlessOfArity( + this SemanticModel semanticModel, + SyntaxToken name, + CancellationToken cancellationToken) + { + if (name.Parent is ExpressionSyntax expression) + { + var results = semanticModel.LookupName(expression, namespacesAndTypesOnly: true, cancellationToken: cancellationToken); + if (results.Length > 0) + { + return results.OfType(); + } + } + + return SpecializedCollections.EmptyEnumerable(); + } + + public static ImmutableArray LookupName( + this SemanticModel semanticModel, + SyntaxToken name, + bool namespacesAndTypesOnly, + CancellationToken cancellationToken) + { + if (name.Parent is ExpressionSyntax expression) + { + return semanticModel.LookupName(expression, namespacesAndTypesOnly, cancellationToken); + } + + return ImmutableArray.Create(); + } + + /// + /// Decomposes a name or member access expression into its component parts. + /// + /// The name or member access expression. + /// The qualifier (or left-hand-side) of the name expression. This may be null if there is no qualifier. + /// The name of the expression. + /// The number of generic type parameters. + private static void DecomposeName(ExpressionSyntax expression, out ExpressionSyntax qualifier, out string name, out int arity) + { + switch (expression.Kind()) + { + case SyntaxKind.SimpleMemberAccessExpression: + case SyntaxKind.PointerMemberAccessExpression: + var max = (MemberAccessExpressionSyntax)expression; + qualifier = max.Expression; + name = max.Name.Identifier.ValueText; + arity = max.Name.Arity; + break; + case SyntaxKind.QualifiedName: + var qn = (QualifiedNameSyntax)expression; + qualifier = qn.Left; + name = qn.Right.Identifier.ValueText; + arity = qn.Arity; + break; + case SyntaxKind.AliasQualifiedName: + var aq = (AliasQualifiedNameSyntax)expression; + qualifier = aq.Alias; + name = aq.Name.Identifier.ValueText; + arity = aq.Name.Arity; + break; + case SyntaxKind.GenericName: + var gx = (GenericNameSyntax)expression; + qualifier = null; + name = gx.Identifier.ValueText; + arity = gx.Arity; + break; + case SyntaxKind.IdentifierName: + var nx = (IdentifierNameSyntax)expression; + qualifier = null; + name = nx.Identifier.ValueText; + arity = 0; + break; + default: + qualifier = null; + name = null; + arity = 0; + break; + } + } + + public static ImmutableArray LookupName( + this SemanticModel semanticModel, + ExpressionSyntax expression, + bool namespacesAndTypesOnly, + CancellationToken cancellationToken) + { + var expr = SyntaxFactory.GetStandaloneExpression(expression); + DecomposeName(expr, out var qualifier, out var name, out var arity); + + INamespaceOrTypeSymbol symbol = null; + if (qualifier != null) + { + var typeInfo = semanticModel.GetTypeInfo(qualifier, cancellationToken); + var symbolInfo = semanticModel.GetSymbolInfo(qualifier, cancellationToken); + if (typeInfo.Type != null) + { + symbol = typeInfo.Type; + } + else if (symbolInfo.Symbol != null) + { + symbol = symbolInfo.Symbol as INamespaceOrTypeSymbol; + } + } + + return semanticModel.LookupSymbols(expr.SpanStart, container: symbol, name: name, includeReducedExtensionMethods: true); + } + + public static SymbolInfo GetSymbolInfo(this SemanticModel semanticModel, SyntaxToken token) + { + if (!CanBindToken(token)) + { + return default; + } + + switch (token.Parent) + { + case ExpressionSyntax expression: + return semanticModel.GetSymbolInfo(expression); + case AttributeSyntax attribute: + return semanticModel.GetSymbolInfo(attribute); + case ConstructorInitializerSyntax constructorInitializer: + return semanticModel.GetSymbolInfo(constructorInitializer); + } + + return default; + } + + private static bool CanBindToken(SyntaxToken token) + { + // Add more token kinds if necessary; + switch (token.Kind()) + { + case SyntaxKind.CommaToken: + case SyntaxKind.DelegateKeyword: + return false; + } + + return true; + } + + /// + /// Given an argument node, tries to generate an appropriate name that can be used for that + /// argument. + /// + public static string GenerateNameForArgument( + this SemanticModel semanticModel, ArgumentSyntax argument, CancellationToken cancellationToken) + { + // If it named argument then we use the name provided. + if (argument.NameColon != null) + { + return argument.NameColon.Name.Identifier.ValueText; + } + + return semanticModel.GenerateNameForExpression( + argument.Expression, capitalize: false, cancellationToken: cancellationToken); + } + + public static string GenerateNameForArgument( + this SemanticModel semanticModel, AttributeArgumentSyntax argument, CancellationToken cancellationToken) + { + // If it named argument then we use the name provided. + if (argument.NameEquals != null) + { + return argument.NameEquals.Name.Identifier.ValueText; + } + + return semanticModel.GenerateNameForExpression( + argument.Expression, capitalize: false, cancellationToken: cancellationToken); + } + + /// + /// Given an expression node, tries to generate an appropriate name that can be used for + /// that expression. + /// + public static string GenerateNameForExpression( + this SemanticModel semanticModel, ExpressionSyntax expression, + bool capitalize, CancellationToken cancellationToken) + { + // Try to find a usable name node that we can use to name the + // parameter. If we have an expression that has a name as part of it + // then we try to use that part. + var current = expression; + while (true) + { + current = current.WalkDownParentheses(); + + if (current.Kind() == SyntaxKind.IdentifierName) + { + return ((IdentifierNameSyntax)current).Identifier.ValueText.ToCamelCase(); + } + else if (current is MemberAccessExpressionSyntax memberAccess) + { + return memberAccess.Name.Identifier.ValueText.ToCamelCase(); + } + else if (current is MemberBindingExpressionSyntax memberBinding) + { + return memberBinding.Name.Identifier.ValueText.ToCamelCase(); + } + else if (current is ConditionalAccessExpressionSyntax conditionalAccess) + { + current = conditionalAccess.WhenNotNull; + } + else if (current is CastExpressionSyntax castExpression) + { + current = castExpression.Expression; + } + else if (current is DeclarationExpressionSyntax decl) + { + if (!(decl.Designation is SingleVariableDesignationSyntax name)) + { + break; + } + + return name.Identifier.ValueText.ToCamelCase(); + } + else + { + break; + } + } + + // there was nothing in the expression to signify a name. If we're in an argument + // location, then try to choose a name based on the argument name. + var argumentName = TryGenerateNameForArgumentExpression( + semanticModel, expression, cancellationToken); + if (argumentName != null) + { + return capitalize ? argumentName.ToPascalCase() : argumentName.ToCamelCase(); + } + + // Otherwise, figure out the type of the expression and generate a name from that + // instead. + var info = semanticModel.GetTypeInfo(expression, cancellationToken); + + // If we can't determine the type, then fallback to some placeholders. + var type = info.Type; + return type.CreateParameterName(capitalize); + } + + private static string TryGenerateNameForArgumentExpression( + SemanticModel semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken) + { + var topExpression = expression.WalkUpParentheses(); + if (topExpression.IsParentKind(SyntaxKind.Argument)) + { + var argument = (ArgumentSyntax)topExpression.Parent; + if (argument.NameColon != null) + { + return argument.NameColon.Name.Identifier.ValueText; + } + + if (argument.Parent is BaseArgumentListSyntax argumentList) + { + var index = argumentList.Arguments.IndexOf(argument); + if (semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken).Symbol is IMethodSymbol member && index < member.Parameters.Length) + { + var parameter = member.Parameters[index]; + if (parameter.Type.OriginalDefinition.TypeKind != TypeKind.TypeParameter) + { + return parameter.Name; + } + } + } + } + + return null; + } + + public static ISet GetUsingNamespacesInScope(this SemanticModel semanticModel, SyntaxNode location) + { + // Avoiding linq here for perf reasons. This is used heavily in the AddImport service + var result = new HashSet(); + + foreach (var @using in location.GetEnclosingUsingDirectives()) + { + if (@using.Alias == null) + { + var symbolInfo = semanticModel.GetSymbolInfo(@using.Name); + if (symbolInfo.Symbol != null && symbolInfo.Symbol.Kind == SymbolKind.Namespace) + { + result ??= new HashSet(); + result.Add((INamespaceSymbol)symbolInfo.Symbol); + } + } + } + + return result; + } + + public static Accessibility DetermineAccessibilityConstraint( + this SemanticModel semanticModel, + TypeSyntax type, + CancellationToken cancellationToken) + { + if (type == null) + { + return Accessibility.Private; + } + + type = GetOutermostType(type); + + // Interesting cases based on 3.5.4 Accessibility constraints in the language spec. + // If any of the below hold, then we will override the default accessibility if the + // constraint wants the type to be more accessible. i.e. if by default we generate + // 'internal', but a constraint makes us 'public', then be public. + + // 1) The direct base class of a class type must be at least as accessible as the + // class type itself. + // + // 2) The explicit base interfaces of an interface type must be at least as accessible + // as the interface type itself. + if (type != null) + { + if (type.Parent is BaseTypeSyntax && type.Parent.IsParentKind(SyntaxKind.BaseList) && ((BaseTypeSyntax)type.Parent).Type == type) + { + var containingType = semanticModel.GetDeclaredSymbol(type.GetAncestor(), cancellationToken) as INamedTypeSymbol; + if (containingType != null && containingType.TypeKind == TypeKind.Interface) + { + return containingType.DeclaredAccessibility; + } + else if (((BaseListSyntax)type.Parent.Parent).Types[0] == type.Parent) + { + return containingType.DeclaredAccessibility; + } + } + } + + // 4) The type of a constant must be at least as accessible as the constant itself. + // 5) The type of a field must be at least as accessible as the field itself. + if (type.IsParentKind(SyntaxKind.VariableDeclaration) && + type.Parent.IsParentKind(SyntaxKind.FieldDeclaration)) + { + var variableDeclaration = (VariableDeclarationSyntax)type.Parent; + return semanticModel.GetDeclaredSymbol( + variableDeclaration.Variables[0], cancellationToken).DeclaredAccessibility; + } + + // Also do the same check if we are in an object creation expression + if (type.IsParentKind(SyntaxKind.ObjectCreationExpression) && + type.Parent.IsParentKind(SyntaxKind.EqualsValueClause) && + type.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclarator) && + type.Parent.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclaration) && + type.Parent.Parent.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration)) + { + var variableDeclaration = (VariableDeclarationSyntax)type.Parent.Parent.Parent.Parent; + return semanticModel.GetDeclaredSymbol( + variableDeclaration.Variables[0], cancellationToken).DeclaredAccessibility; + } + + // 3) The return type of a delegate type must be at least as accessible as the + // delegate type itself. + // 6) The return type of a method must be at least as accessible as the method + // itself. + // 7) The type of a property must be at least as accessible as the property itself. + // 8) The type of an event must be at least as accessible as the event itself. + // 9) The type of an indexer must be at least as accessible as the indexer itself. + // 10) The return type of an operator must be at least as accessible as the operator + // itself. + if (type.IsParentKind(SyntaxKind.DelegateDeclaration) || + type.IsParentKind(SyntaxKind.MethodDeclaration) || + type.IsParentKind(SyntaxKind.PropertyDeclaration) || + type.IsParentKind(SyntaxKind.EventDeclaration) || + type.IsParentKind(SyntaxKind.IndexerDeclaration) || + type.IsParentKind(SyntaxKind.OperatorDeclaration)) + { + return semanticModel.GetDeclaredSymbol( + type.Parent, cancellationToken).DeclaredAccessibility; + } + + // 3) The parameter types of a delegate type must be at least as accessible as the + // delegate type itself. + // 6) The parameter types of a method must be at least as accessible as the method + // itself. + // 9) The parameter types of an indexer must be at least as accessible as the + // indexer itself. + // 10) The parameter types of an operator must be at least as accessible as the + // operator itself. + // 11) The parameter types of an instance constructor must be at least as accessible + // as the instance constructor itself. + if (type.IsParentKind(SyntaxKind.Parameter) && type.Parent.IsParentKind(SyntaxKind.ParameterList)) + { + if (type.Parent.Parent.IsParentKind(SyntaxKind.DelegateDeclaration) || + type.Parent.Parent.IsParentKind(SyntaxKind.MethodDeclaration) || + type.Parent.Parent.IsParentKind(SyntaxKind.IndexerDeclaration) || + type.Parent.Parent.IsParentKind(SyntaxKind.OperatorDeclaration)) + { + return semanticModel.GetDeclaredSymbol( + type.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility; + } + + if (type.Parent.Parent.IsParentKind(SyntaxKind.ConstructorDeclaration)) + { + var symbol = semanticModel.GetDeclaredSymbol(type.Parent.Parent.Parent, cancellationToken); + if (!symbol.IsStatic) + { + return symbol.DeclaredAccessibility; + } + } + } + + // 8) The type of an event must be at least as accessible as the event itself. + if (type.IsParentKind(SyntaxKind.VariableDeclaration) && + type.Parent.IsParentKind(SyntaxKind.EventFieldDeclaration)) + { + var variableDeclaration = (VariableDeclarationSyntax)type.Parent; + var symbol = semanticModel.GetDeclaredSymbol(variableDeclaration.Variables[0], cancellationToken); + if (symbol != null) + { + return symbol.DeclaredAccessibility; + } + } + + // Type constraint must be at least as accessible as the declaring member (class, interface, delegate, method) + if (type.IsParentKind(SyntaxKind.TypeConstraint)) + { + return AllContainingTypesArePublicOrProtected(semanticModel, type, cancellationToken) + ? Accessibility.Public + : Accessibility.Internal; + } + + return Accessibility.Private; + } + + public static bool AllContainingTypesArePublicOrProtected( + this SemanticModel semanticModel, + TypeSyntax type, + CancellationToken cancellationToken) + { + if (type == null) + { + return false; + } + + var typeDeclarations = type.GetAncestors(); + + foreach (var typeDeclaration in typeDeclarations) + { + var symbol = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken); + + if (symbol.DeclaredAccessibility == Accessibility.Private || + symbol.DeclaredAccessibility == Accessibility.ProtectedAndInternal || + symbol.DeclaredAccessibility == Accessibility.Internal) + { + return false; + } + } + + return true; + } + + private static TypeSyntax GetOutermostType(TypeSyntax type) + { + return type.GetAncestorsOrThis().Last(); + } + } +} diff --git a/src/Workspaces/CSharp/Portable/Extensions/SeparatedSyntaxListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SeparatedSyntaxListExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SeparatedSyntaxListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SeparatedSyntaxListExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SimpleNameSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SimpleNameSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SimpleNameSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SimpleNameSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/StatementSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/StatementSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/StatementSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/StatementSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/StringExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/StringExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/StringExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/StringExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.SingleLineRewriter.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.SingleLineRewriter.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.SingleLineRewriter.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.SingleLineRewriter.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTokenExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTokenExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenListExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTokenListExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenListExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTokenListExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTreeExtensions.cs similarity index 99% rename from src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTreeExtensions.cs index c11c2bc3e90a1..d89ef0814370b 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTreeExtensions.cs @@ -17,6 +17,12 @@ namespace Microsoft.CodeAnalysis.CSharp.Extensions { +#if CODE_STYLE + using Resources = CSharpCodeStyleFixesResources; +#else + using Resources = CSharpWorkspaceResources; +#endif + internal static partial class SyntaxTreeExtensions { public static ISet GetPrecedingModifiers( @@ -375,7 +381,7 @@ private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int { if (!token.IsKind(SyntaxKind.StringLiteralToken, SyntaxKind.CharacterLiteralToken)) { - throw new ArgumentException(CSharpWorkspaceResources.Expected_string_or_char_literal, nameof(token)); + throw new ArgumentException(Resources.Expected_string_or_char_literal, nameof(token)); } var startLength = 1; diff --git a/src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/TypeSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/TypeSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/UsingDirectiveSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/UsingDirectiveSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/UsingDirectiveSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/UsingDirectiveSyntaxExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/Extensions/VariableDeclaratorExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/VariableDeclaratorExtensions.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Extensions/VariableDeclaratorExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/VariableDeclaratorExtensions.cs diff --git a/src/Workspaces/CSharp/Portable/AddImports/CSharpAddImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpAddImportsService.cs similarity index 98% rename from src/Workspaces/CSharp/Portable/AddImports/CSharpAddImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpAddImportsService.cs index 4193509db7a87..2d5494b2cd50a 100644 --- a/src/Workspaces/CSharp/Portable/AddImports/CSharpAddImportsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpAddImportsService.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.AddImports; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.CSharp.Utilities; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Host.Mef; using Roslyn.Utilities; @@ -26,7 +26,7 @@ public CSharpAddImportsService() } // C# doesn't have global imports. - protected override ImmutableArray GetGlobalImports(Compilation compilation) + protected override ImmutableArray GetGlobalImports(Compilation compilation, SyntaxGenerator generator) => ImmutableArray.Empty; protected override SyntaxNode? GetAlias(UsingDirectiveSyntax usingOrAlias) diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpCommandLineParserService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpCommandLineParserService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpCommandLineParserService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpCommandLineParserService.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpDocumentationCommentService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpDocumentationCommentService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpDocumentationCommentService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpDocumentationCommentService.cs diff --git a/src/Workspaces/CSharp/Portable/GeneratedCodeRecognition/CSharpGeneratedCodeRecognitionService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpGeneratedCodeRecognitionService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/GeneratedCodeRecognition/CSharpGeneratedCodeRecognitionService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpGeneratedCodeRecognitionService.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpPrecedenceService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpPrecedenceService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpPrecedenceService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpPrecedenceService.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSemanticFactsService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSemanticFactsService.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsServiceFactory.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSemanticFactsServiceFactory.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsServiceFactory.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSemanticFactsServiceFactory.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSymbolDeclarationService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSymbolDeclarationService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSymbolDeclarationService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSymbolDeclarationService.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxFactsService.cs similarity index 99% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxFactsService.cs index c0c23843afff6..23238a4afb048 100644 --- a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxFactsService.cs @@ -10,7 +10,6 @@ using System.Linq; using System.Text; using System.Threading; -using Microsoft.CodeAnalysis.CSharp.CodeGeneration; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery; using Microsoft.CodeAnalysis.CSharp.LanguageServices; @@ -191,7 +190,7 @@ public SyntaxNode GetDefaultOfParameter(SyntaxNode node) => (node as ParameterSyntax)?.Default; public SyntaxNode GetParameterList(SyntaxNode node) - => CSharpSyntaxGenerator.GetParameterList(node); + => node.GetParameterList(); public bool IsSkippedTokensTrivia(SyntaxNode node) => node is SkippedTokensTriviaSyntax; @@ -1956,6 +1955,6 @@ public void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out S } public override SyntaxList GetAttributeLists(SyntaxNode node) - => CSharpSyntaxGenerator.GetAttributeLists(node); + => node.GetAttributeLists(); } } diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsServiceFactory.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxFactsServiceFactory.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsServiceFactory.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxFactsServiceFactory.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxKindsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxKindsService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxKindsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxKindsService.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxKindsServiceFactory.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxKindsServiceFactory.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxKindsServiceFactory.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxKindsServiceFactory.cs diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs similarity index 99% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs index a551c4a42fd8c..0bdce817563dd 100644 --- a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs @@ -1102,7 +1102,12 @@ static ITypeSymbol MakeNullable(ITypeSymbol symbol, Compilation compilation) } else if (symbol.IsReferenceType) { +#if CODE_STYLE + // TODO: Remove the #if once WithNullableAnnotation is available. + return symbol; +#else return symbol.WithNullableAnnotation(NullableAnnotation.Annotated); +#endif } else // it's neither a value nor reference type, so is an unconstrained generic { @@ -1536,7 +1541,7 @@ private IEnumerable GetTypesForRecursivePattern(RecursivePatt // Pass the nullable annotations explicitly to work around https://github.com/dotnet/roslyn/issues/40105 var elementTypes = elementTypesBuilder.ToImmutableAndFree(); var type = Compilation.CreateTupleTypeSymbol( - elementTypes, elementNamesBuilder.ToImmutableAndFree(), elementNullableAnnotations: elementTypes.SelectAsArray(e => e.NullableAnnotation)); + elementTypes, elementNamesBuilder.ToImmutableAndFree(), elementNullableAnnotations: GetNullableAnnotations(elementTypes)); return CreateResult(type); } } @@ -1544,6 +1549,16 @@ private IEnumerable GetTypesForRecursivePattern(RecursivePatt return SpecializedCollections.EmptyEnumerable(); } + private static ImmutableArray GetNullableAnnotations(ImmutableArray elementTypes) + { + return +#if CODE_STYLE // TODO: Remove the #if once NullableAnnotation is available. + default; +#else + elementTypes.SelectAsArray(e => e.NullableAnnotation); +#endif + } + private IEnumerable InferTypeInLockStatement(LockStatementSyntax lockStatement, SyntaxToken? previousToken = null) { // If we're position based, then we have to be after the "lock(" @@ -2136,7 +2151,7 @@ private ITypeSymbol GetTupleType( } // Pass the nullable annotations explicitly to work around https://github.com/dotnet/roslyn/issues/40105 - return Compilation.CreateTupleTypeSymbol(elementTypes, elementNames, elementNullableAnnotations: elementTypes.SelectAsArray(e => e.NullableAnnotation)); + return Compilation.CreateTupleTypeSymbol(elementTypes, elementNames, elementNullableAnnotations: GetNullableAnnotations(elementTypes)); } private bool TryGetTupleTypesAndNames( diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpTypeInferenceService.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/CSharpSimplificationHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/CSharpSimplificationHelpers.cs new file mode 100644 index 0000000000000..e9459180ae031 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/CSharpSimplificationHelpers.cs @@ -0,0 +1,87 @@ +// 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 Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Formatting; +using Microsoft.CodeAnalysis.Simplification; + +namespace Microsoft.CodeAnalysis.CSharp.Simplification +{ + internal static class CSharpSimplificationHelpers + { + public static SyntaxToken TryEscapeIdentifierToken(SyntaxToken syntaxToken, SyntaxNode parentOfToken) + { + // do not escape an already escaped identifier + if (syntaxToken.IsVerbatimIdentifier()) + { + return syntaxToken; + } + + if (SyntaxFacts.GetKeywordKind(syntaxToken.ValueText) == SyntaxKind.None && SyntaxFacts.GetContextualKeywordKind(syntaxToken.ValueText) == SyntaxKind.None) + { + return syntaxToken; + } + + if (SyntaxFacts.GetContextualKeywordKind(syntaxToken.ValueText) == SyntaxKind.UnderscoreToken) + { + return syntaxToken; + } + + var parent = parentOfToken.Parent; + if (parentOfToken is SimpleNameSyntax && parent.Kind() == SyntaxKind.XmlNameAttribute) + { + // do not try to escape XML name attributes + return syntaxToken; + } + + // do not escape global in a namespace qualified name + if (parent.Kind() == SyntaxKind.AliasQualifiedName && + syntaxToken.ValueText == "global") + { + return syntaxToken; + } + + // safe to escape identifier + return syntaxToken.CopyAnnotationsTo( + SyntaxFactory.VerbatimIdentifier( + syntaxToken.LeadingTrivia, + syntaxToken.ToString(), + syntaxToken.ValueText, + syntaxToken.TrailingTrivia)) + .WithAdditionalAnnotations(Simplifier.Annotation); + } + + public static T AppendElasticTriviaIfNecessary(T rewrittenNode, T originalNode) where T : SyntaxNode + { + var firstRewrittenToken = rewrittenNode.GetFirstToken(true, false, true, true); + var firstOriginalToken = originalNode.GetFirstToken(true, false, true, true); + if (TryAddLeadingElasticTriviaIfNecessary(firstRewrittenToken, firstOriginalToken, out var rewrittenTokenWithLeadingElasticTrivia)) + { + return rewrittenNode.ReplaceToken(firstRewrittenToken, rewrittenTokenWithLeadingElasticTrivia); + } + + return rewrittenNode; + } + + public static bool TryAddLeadingElasticTriviaIfNecessary(SyntaxToken token, SyntaxToken originalToken, out SyntaxToken tokenWithLeadingWhitespace) + { + tokenWithLeadingWhitespace = default; + + if (token.HasLeadingTrivia) + { + return false; + } + + var previousToken = originalToken.GetPreviousToken(); + + if (previousToken.HasTrailingTrivia) + { + return false; + } + + tokenWithLeadingWhitespace = token.WithLeadingTrivia(SyntaxFactory.ElasticMarker).WithAdditionalAnnotations(Formatter.Annotation); + return true; + } + } +} diff --git a/src/Workspaces/CSharp/Portable/Utilities/NameSyntaxComparer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/NameSyntaxComparer.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Utilities/NameSyntaxComparer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/NameSyntaxComparer.cs diff --git a/src/Workspaces/CSharp/Portable/Utilities/NameSyntaxIterator.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/NameSyntaxIterator.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Utilities/NameSyntaxIterator.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/NameSyntaxIterator.cs diff --git a/src/Workspaces/Core/Portable/Utilities/NullableHelpers/NullableExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/NullableHelpers/NullableExtensions.cs similarity index 55% rename from src/Workspaces/Core/Portable/Utilities/NullableHelpers/NullableExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/NullableHelpers/NullableExtensions.cs index 63b3afe778ad7..3968067ec0350 100644 --- a/src/Workspaces/Core/Portable/Utilities/NullableHelpers/NullableExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/NullableHelpers/NullableExtensions.cs @@ -11,9 +11,17 @@ namespace Microsoft.CodeAnalysis internal static partial class NullableExtensions { public static ITypeSymbol? GetConvertedTypeWithAnnotatedNullability(this TypeInfo typeInfo) - => typeInfo.ConvertedType?.WithNullableAnnotation(typeInfo.ConvertedNullability.Annotation); + => typeInfo.ConvertedType +#if !CODE_STYLE // TODO: Remove the #if once WithNullableAnnotation is available. + ?.WithNullableAnnotation(typeInfo.ConvertedNullability.Annotation) +#endif + ; public static ITypeSymbol? GetTypeWithAnnotatedNullability(this TypeInfo typeInfo) - => typeInfo.Type?.WithNullableAnnotation(typeInfo.Nullability.Annotation); + => typeInfo.Type +#if !CODE_STYLE // TODO: Remove the #if once WithNullableAnnotation is available. + ?.WithNullableAnnotation(typeInfo.Nullability.Annotation) +#endif + ; } } diff --git a/src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/SpeculationAnalyzer.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/SpeculationAnalyzer.cs diff --git a/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/SyntaxKindSet.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/SyntaxKindSet.cs diff --git a/src/Workspaces/CSharp/Portable/Utilities/TokenComparer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/TokenComparer.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Utilities/TokenComparer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/TokenComparer.cs diff --git a/src/Workspaces/CSharp/Portable/Utilities/TypeSyntaxComparer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/TypeSyntaxComparer.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Utilities/TypeSyntaxComparer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/TypeSyntaxComparer.cs diff --git a/src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesDirectiveComparer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/UsingsAndExternAliasesDirectiveComparer.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesDirectiveComparer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/UsingsAndExternAliasesDirectiveComparer.cs diff --git a/src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesOrganizer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/UsingsAndExternAliasesOrganizer.cs similarity index 100% rename from src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesOrganizer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Utilities/UsingsAndExternAliasesOrganizer.cs diff --git a/src/Workspaces/Core/Portable/CodeFixes/CodeFixCategory.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeFixCategory.cs similarity index 100% rename from src/Workspaces/Core/Portable/CodeFixes/CodeFixCategory.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CodeFixCategory.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CustomCodeActions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CustomCodeActions.cs new file mode 100644 index 0000000000000..cf0e559752f27 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CustomCodeActions.cs @@ -0,0 +1,62 @@ +// 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.Threading; +using System.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.CodeActions +{ + internal static class CustomCodeActions + { + internal abstract class SimpleCodeAction : CodeAction + { + public SimpleCodeAction(string title, string equivalenceKey) + { + Title = title; + EquivalenceKey = equivalenceKey; + } + + public sealed override string Title { get; } + public sealed override string EquivalenceKey { get; } + + protected override Task GetChangedDocumentAsync(CancellationToken cancellationToken) + { + return Task.FromResult(null); + } + } + + internal class DocumentChangeAction : SimpleCodeAction + { + private readonly Func> _createChangedDocument; + + public DocumentChangeAction(string title, Func> createChangedDocument, string equivalenceKey = null) + : base(title, equivalenceKey) + { + _createChangedDocument = createChangedDocument; + } + + protected override Task GetChangedDocumentAsync(CancellationToken cancellationToken) + { + return _createChangedDocument(cancellationToken); + } + } + + internal class SolutionChangeAction : SimpleCodeAction + { + private readonly Func> _createChangedSolution; + + public SolutionChangeAction(string title, Func> createChangedSolution, string equivalenceKey = null) + : base(title, equivalenceKey) + { + _createChangedSolution = createChangedSolution; + } + + protected override Task GetChangedSolutionAsync(CancellationToken cancellationToken) + { + return _createChangedSolution(cancellationToken); + } + } + } +} diff --git a/src/CodeStyle/Core/CodeFixes/DocumentBasedFixAllProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs similarity index 68% rename from src/CodeStyle/Core/CodeFixes/DocumentBasedFixAllProvider.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs index c525b9daa1703..21e9d82d1aa55 100644 --- a/src/CodeStyle/Core/CodeFixes/DocumentBasedFixAllProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs @@ -9,6 +9,8 @@ using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; +#pragma warning disable RS0005 // Do not use generic CodeAction.Create to create CodeAction + namespace Microsoft.CodeAnalysis.CodeStyle { /// @@ -16,10 +18,7 @@ namespace Microsoft.CodeAnalysis.CodeStyle /// internal abstract class DocumentBasedFixAllProvider : FixAllProvider { - protected abstract string CodeActionTitle - { - get; - } + protected abstract string GetCodeActionTitle(FixAllContext fixAllContext); public override Task GetFixAsync(FixAllContext fixAllContext) { @@ -28,21 +27,21 @@ public override Task GetFixAsync(FixAllContext fixAllContext) { case FixAllScope.Document: fixAction = CodeAction.Create( - CodeActionTitle, + GetCodeActionTitle(fixAllContext), cancellationToken => GetDocumentFixesAsync(fixAllContext.WithCancellationToken(cancellationToken)), nameof(DocumentBasedFixAllProvider)); break; case FixAllScope.Project: fixAction = CodeAction.Create( - CodeActionTitle, + GetCodeActionTitle(fixAllContext), cancellationToken => GetProjectFixesAsync(fixAllContext.WithCancellationToken(cancellationToken), fixAllContext.Project), nameof(DocumentBasedFixAllProvider)); break; case FixAllScope.Solution: fixAction = CodeAction.Create( - CodeActionTitle, + GetCodeActionTitle(fixAllContext), cancellationToken => GetSolutionFixesAsync(fixAllContext.WithCancellationToken(cancellationToken)), nameof(DocumentBasedFixAllProvider)); break; @@ -62,56 +61,39 @@ public override Task GetFixAsync(FixAllContext fixAllContext) /// The context for the Fix All operation. /// The document to fix. /// The diagnostics to fix in the document. - /// - /// The new representing the root of the fixed document. - /// -or- - /// , if no changes were made to the document. - /// - protected abstract Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics); + /// New fixed or original document if no changes were made to the document. + protected abstract Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics); private async Task GetDocumentFixesAsync(FixAllContext fixAllContext) { - var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext, progressTrackerOpt: null, (document, cancellationToken) => false).ConfigureAwait(false); + var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext, progressTrackerOpt: null).ConfigureAwait(false); if (!documentDiagnosticsToFix.TryGetValue(fixAllContext.Document, out var diagnostics)) { return fixAllContext.Document; } - var newRoot = await FixAllInDocumentAsync(fixAllContext, fixAllContext.Document, diagnostics).ConfigureAwait(false); - if (newRoot == null) - { - return fixAllContext.Document; - } - - return fixAllContext.Document.WithSyntaxRoot(newRoot); + return await FixAllInDocumentAsync(fixAllContext, fixAllContext.Document, diagnostics).ConfigureAwait(false); } private async Task GetSolutionFixesAsync(FixAllContext fixAllContext, ImmutableArray documents) { - var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext, progressTrackerOpt: null, (document, cancellationToken) => false).ConfigureAwait(false); + var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext, progressTrackerOpt: null).ConfigureAwait(false); var solution = fixAllContext.Solution; - var newDocuments = new List>(documents.Length); + var newDocuments = new Dictionary>(documents.Length); foreach (var document in documents) { - if (!documentDiagnosticsToFix.TryGetValue(document, out var diagnostics)) + if (documentDiagnosticsToFix.TryGetValue(document, out var diagnostics)) { - newDocuments.Add(document.GetSyntaxRootAsync(fixAllContext.CancellationToken)); - continue; + newDocuments.Add(document.Id, FixAllInDocumentAsync(fixAllContext, document, diagnostics)); } - - newDocuments.Add(FixAllInDocumentAsync(fixAllContext, document, diagnostics)); } - for (var i = 0; i < documents.Length; i++) + foreach (var documentIdAndTask in newDocuments) { - var newDocumentRoot = await newDocuments[i].ConfigureAwait(false); - if (newDocumentRoot == null) - { - continue; - } - - solution = solution.WithDocumentSyntaxRoot(documents[i].Id, newDocumentRoot); + var newDocument = await documentIdAndTask.Value.ConfigureAwait(false); + var newDocumentRoot = await newDocument.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); + solution = solution.WithDocumentSyntaxRoot(documentIdAndTask.Key, newDocumentRoot); } return solution; diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.FixMultipleDiagnosticProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.FixMultipleDiagnosticProvider.cs similarity index 64% rename from src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.FixMultipleDiagnosticProvider.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.FixMultipleDiagnosticProvider.cs index 30303557b419e..91aa1a9489a33 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.FixMultipleDiagnosticProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.FixMultipleDiagnosticProvider.cs @@ -18,51 +18,37 @@ internal partial class FixAllState /// internal sealed class FixMultipleDiagnosticProvider : FixAllContext.DiagnosticProvider { - internal override bool IsFixMultiple => true; - - private readonly ImmutableDictionary> _documentDiagnosticsMap; - private readonly ImmutableDictionary> _projectDiagnosticsMap; + public ImmutableDictionary> DocumentDiagnosticsMap { get; } + public ImmutableDictionary> ProjectDiagnosticsMap { get; } public FixMultipleDiagnosticProvider(ImmutableDictionary> diagnosticsMap) { - _documentDiagnosticsMap = diagnosticsMap; - _projectDiagnosticsMap = ImmutableDictionary>.Empty; + DocumentDiagnosticsMap = diagnosticsMap; + ProjectDiagnosticsMap = ImmutableDictionary>.Empty; } public FixMultipleDiagnosticProvider(ImmutableDictionary> diagnosticsMap) { - _projectDiagnosticsMap = diagnosticsMap; - _documentDiagnosticsMap = ImmutableDictionary>.Empty; - } - - internal override Task>> GetDocumentDiagnosticsToFixWorkerAsync( - FixAllContext context) - { - return Task.FromResult(_documentDiagnosticsMap); - } - - internal override Task>> GetProjectDiagnosticsToFixAsync( - FixAllContext context) - { - return Task.FromResult(_projectDiagnosticsMap); + ProjectDiagnosticsMap = diagnosticsMap; + DocumentDiagnosticsMap = ImmutableDictionary>.Empty; } public override Task> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) { var allDiagnosticsBuilder = ArrayBuilder.GetInstance(); ImmutableArray diagnostics; - if (!_documentDiagnosticsMap.IsEmpty) + if (!DocumentDiagnosticsMap.IsEmpty) { foreach (var document in project.Documents) { - if (_documentDiagnosticsMap.TryGetValue(document, out diagnostics)) + if (DocumentDiagnosticsMap.TryGetValue(document, out diagnostics)) { allDiagnosticsBuilder.AddRange(diagnostics); } } } - if (_projectDiagnosticsMap.TryGetValue(project, out diagnostics)) + if (ProjectDiagnosticsMap.TryGetValue(project, out diagnostics)) { allDiagnosticsBuilder.AddRange(diagnostics); } @@ -72,7 +58,7 @@ public override Task> GetAllDiagnosticsAsync(Project pro public override Task> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken) { - if (_documentDiagnosticsMap.TryGetValue(document, out var diagnostics)) + if (DocumentDiagnosticsMap.TryGetValue(document, out var diagnostics)) { return Task.FromResult>(diagnostics); } @@ -82,7 +68,7 @@ public override Task> GetDocumentDiagnosticsAsync(Docume public override Task> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken) { - if (_projectDiagnosticsMap.TryGetValue(project, out var diagnostics)) + if (ProjectDiagnosticsMap.TryGetValue(project, out var diagnostics)) { return Task.FromResult>(diagnostics); } diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.cs similarity index 77% rename from src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.cs index 63f0908eaa70e..7d51f7b1d59e8 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllState.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.cs @@ -6,13 +6,17 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using System.Threading; using Microsoft.CodeAnalysis.Internal.Log; -using Microsoft.CodeAnalysis.Shared.Utilities; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CodeFixes { +#if CODE_STYLE + using Resources = CodeStyleFixesResources; +#else + using Resources = WorkspacesResources; +#endif + internal partial class FixAllState { internal readonly int CorrelationId = LogAggregator.GetNextId(); @@ -78,7 +82,7 @@ private FixAllState( if (diagnosticIds.Any(d => d == null)) { - throw new ArgumentException(WorkspacesResources.Supplied_diagnostic_cannot_be_null, nameof(diagnosticIds)); + throw new ArgumentException(Resources.Supplied_diagnostic_cannot_be_null, nameof(diagnosticIds)); } this.FixAllProvider = fixAllProvider; @@ -91,7 +95,7 @@ private FixAllState( this.DiagnosticProvider = fixAllDiagnosticProvider ?? throw new ArgumentNullException(nameof(fixAllDiagnosticProvider)); } - internal bool IsFixMultiple => this.DiagnosticProvider.IsFixMultiple; + internal bool IsFixMultiple => this.DiagnosticProvider is FixMultipleDiagnosticProvider; public FixAllState WithScopeAndEquivalenceKey(FixAllScope scope, string codeActionEquivalenceKey) { @@ -107,46 +111,6 @@ public FixAllState WithScopeAndEquivalenceKey(FixAllScope scope, string codeActi this.DiagnosticIds, this.DiagnosticProvider); } - public FixAllContext CreateFixAllContext( - IProgressTracker progressTracker, CancellationToken cancellationToken) - { - return new FixAllContext(this, progressTracker, cancellationToken); - } - - internal string GetDefaultFixAllTitle() - { - var diagnosticIds = this.DiagnosticIds; - string diagnosticId; - if (diagnosticIds.Count == 1) - { - diagnosticId = diagnosticIds.Single(); - } - else - { - diagnosticId = string.Join(",", diagnosticIds.ToArray()); - } - - switch (this.Scope) - { - case FixAllScope.Custom: - return string.Format(WorkspacesResources.Fix_all_0, diagnosticId); - - case FixAllScope.Document: - var document = this.Document; - return string.Format(WorkspacesResources.Fix_all_0_in_1, diagnosticId, document.Name); - - case FixAllScope.Project: - var project = this.Project; - return string.Format(WorkspacesResources.Fix_all_0_in_1, diagnosticId, project.Name); - - case FixAllScope.Solution: - return string.Format(WorkspacesResources.Fix_all_0_in_Solution, diagnosticId); - - default: - throw ExceptionUtilities.UnexpectedValue(this.Scope); - } - } - #region FixMultiple internal static FixAllState Create( diff --git a/src/CodeStyle/Core/CodeFixes/FixAllContextHelper.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAllContextHelper.cs similarity index 73% rename from src/CodeStyle/Core/CodeFixes/FixAllContextHelper.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAllContextHelper.cs index 02695422cb407..4a034bdc3cafc 100644 --- a/src/CodeStyle/Core/CodeFixes/FixAllContextHelper.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAllContextHelper.cs @@ -9,16 +9,23 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.Utilities; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CodeStyle { +#if CODE_STYLE + using Resources = CodeStyleFixesResources; +#else + using Resources = WorkspacesResources; +#endif + internal static class FixAllContextHelper { public static async Task>> GetDocumentDiagnosticsToFixAsync( FixAllContext fixAllContext, - IProgressTracker progressTrackerOpt, - Func isGeneratedCode) + IProgressTracker progressTrackerOpt) { var cancellationToken = fixAllContext.CancellationToken; @@ -31,7 +38,7 @@ public static async Task>.Empty.SetItem(document, documentDiagnostics); @@ -76,13 +83,12 @@ public static async Task>> GetDocumentDiagnosticsToFixAsync( ImmutableArray diagnostics, ImmutableArray projects, - Func isGeneratedCode, CancellationToken cancellationToken) { var treeToDocumentMap = await GetTreeToDocumentMapAsync(projects, cancellationToken).ConfigureAwait(false); @@ -92,7 +98,7 @@ private static async Task GetDefaultFixAllTitle(fixAllContext.Scope, fixAllContext.DiagnosticIds, fixAllContext.Document, fixAllContext.Project); + + public static string GetDefaultFixAllTitle( + FixAllScope fixAllScope, + ImmutableHashSet diagnosticIds, + Document triggerDocument, + Project triggerProject) + { + string diagnosticId; + if (diagnosticIds.Count == 1) + { + diagnosticId = diagnosticIds.Single(); + } + else + { + diagnosticId = string.Join(",", diagnosticIds.ToArray()); + } + + switch (fixAllScope) + { + case FixAllScope.Custom: + return string.Format(Resources.Fix_all_0, diagnosticId); + + case FixAllScope.Document: + return string.Format(Resources.Fix_all_0_in_1, diagnosticId, triggerDocument.Name); + + case FixAllScope.Project: + return string.Format(Resources.Fix_all_0_in_1, diagnosticId, triggerProject.Name); + + case FixAllScope.Solution: + return string.Format(Resources.Fix_all_0_in_Solution, diagnosticId); + + default: + throw ExceptionUtilities.UnexpectedValue(fixAllScope); + } + } } } diff --git a/src/Workspaces/Core/Portable/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs similarity index 64% rename from src/Workspaces/Core/Portable/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs index 73df860c64989..25ec9dd7124a1 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs @@ -8,6 +8,9 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.GeneratedCodeRecognition; +using Microsoft.CodeAnalysis.Shared.Extensions; namespace Microsoft.CodeAnalysis.CodeFixes { @@ -30,21 +33,36 @@ public SyntaxEditorBasedFixAllProvider(SyntaxEditorBasedCodeFixProvider codeFixP public sealed override async Task GetFixAsync(FixAllContext fixAllContext) { - var documentsAndDiagnosticsToFixMap = await fixAllContext.GetDocumentDiagnosticsToFixAsync().ConfigureAwait(false); - return await GetFixAsync(documentsAndDiagnosticsToFixMap, fixAllContext.State, fixAllContext.CancellationToken).ConfigureAwait(false); + var documentsAndDiagnosticsToFixMap = await GetDocumentDiagnosticsToFixAsync(fixAllContext).ConfigureAwait(false); + return await GetFixAsync(documentsAndDiagnosticsToFixMap, fixAllContext).ConfigureAwait(false); } - internal sealed override async Task GetFixAsync( + private async Task>> GetDocumentDiagnosticsToFixAsync(FixAllContext fixAllContext) + { + var result = await GetDocumentDiagnosticsToFixWorkerAsync(fixAllContext).ConfigureAwait(false); + + // Filter out any documents that we don't have any diagnostics for. + return result.Where(kvp => !kvp.Value.IsDefaultOrEmpty).ToImmutableDictionary(); + + static async Task>> GetDocumentDiagnosticsToFixWorkerAsync(FixAllContext fixAllContext) + { + return await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync( + fixAllContext, + progressTrackerOpt: null).ConfigureAwait(false); + } + } + + private async Task GetFixAsync( ImmutableDictionary> documentsAndDiagnosticsToFixMap, - FixAllState fixAllState, CancellationToken cancellationToken) + FixAllContext fixAllContext) { // Process all documents in parallel. var updatedDocumentTasks = documentsAndDiagnosticsToFixMap.Select( - kvp => FixDocumentAsync(fixAllState, kvp.Key, kvp.Value, cancellationToken)); + kvp => FixDocumentAsync(kvp.Key, kvp.Value, fixAllContext)); await Task.WhenAll(updatedDocumentTasks).ConfigureAwait(false); - var currentSolution = fixAllState.Solution; + var currentSolution = fixAllContext.Solution; foreach (var task in updatedDocumentTasks) { // 'await' the tasks so that if any completed in a canceled manner then we'll @@ -53,15 +71,15 @@ internal sealed override async Task GetFixAsync( var updatedDocument = await task.ConfigureAwait(false); currentSolution = currentSolution.WithDocumentSyntaxRoot( updatedDocument.Id, - await updatedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false)); + await updatedDocument.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false)); } - var title = fixAllState.GetDefaultFixAllTitle(); - return new CodeAction.SolutionChangeAction(title, _ => Task.FromResult(currentSolution)); + var title = FixAllContextHelper.GetDefaultFixAllTitle(fixAllContext); + return new CustomCodeActions.SolutionChangeAction(title, _ => Task.FromResult(currentSolution)); } private async Task FixDocumentAsync( - FixAllState fixAllState, Document document, ImmutableArray diagnostics, CancellationToken cancellationToken) + Document document, ImmutableArray diagnostics, FixAllContext fixAllContext) { // Ensure that diagnostics for this document are always in document location // order. This provides a consistent and deterministic order for fixers @@ -69,7 +87,7 @@ private async Task FixDocumentAsync( // Also ensure that we do not pass in duplicates by invoking Distinct. // See https://github.com/dotnet/roslyn/issues/31381, that seems to be causing duplicate diagnostics. var filteredDiagnostics = diagnostics.Distinct() - .WhereAsArray(d => _codeFixProvider.IncludeDiagnosticDuringFixAll(fixAllState, d, cancellationToken)) + .WhereAsArray(d => _codeFixProvider.IncludeDiagnosticDuringFixAll(d, fixAllContext)) .Sort((d1, d2) => d1.Location.SourceSpan.Start - d2.Location.SourceSpan.Start); // PERF: Do not invoke FixAllAsync on the code fix provider if there are no diagnostics to be fixed. @@ -78,7 +96,7 @@ private async Task FixDocumentAsync( return document; } - return await _codeFixProvider.FixAllAsync(document, filteredDiagnostics, cancellationToken).ConfigureAwait(false); + return await _codeFixProvider.FixAllAsync(document, filteredDiagnostics, fixAllContext.CancellationToken).ConfigureAwait(false); } } } diff --git a/src/Workspaces/Core/Portable/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs similarity index 94% rename from src/Workspaces/Core/Portable/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs index e5d042803595d..58bdc4ff8449f 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs @@ -69,7 +69,7 @@ protected abstract Task FixAllAsync( /// Only one of these two overloads needs to be overridden if you want to customize /// behavior. /// - protected virtual bool IncludeDiagnosticDuringFixAll(FixAllState fixAllState, Diagnostic diagnostic, CancellationToken cancellationToken) + protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) => IncludeDiagnosticDuringFixAll(diagnostic); /// @@ -83,7 +83,7 @@ protected virtual bool IncludeDiagnosticDuringFixAll(FixAllState fixAllState, Di /// here. If only the diagnostic needs to be queried to make this determination, only this /// overload needs to be overridden. However, if information from /// is needed (for example ), then + /// cref="IncludeDiagnosticDuringFixAll(Diagnostic, FixAllContext)"/> /// should be overridden instead. /// /// Only one of these two overloads needs to be overridden if you want to customize diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ContextQuery/SyntaxContext.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ContextQuery/SyntaxContext.cs similarity index 96% rename from src/Workspaces/Core/Portable/Shared/Extensions/ContextQuery/SyntaxContext.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ContextQuery/SyntaxContext.cs index 95630bd7a08a0..c720b9ef4e9bd 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ContextQuery/SyntaxContext.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ContextQuery/SyntaxContext.cs @@ -116,7 +116,7 @@ protected ImmutableArray ComputeInferredTypes(Workspace workspace, int position, CancellationToken cancellationToken) { - var typeInferenceService = workspace?.Services.GetLanguageServices(semanticModel.Language).GetService() + var typeInferenceService = workspace?.Services.GetLanguageService(semanticModel.Language) ?? GetTypeInferenceServiceWithoutWorkspace(); return typeInferenceService.InferTypes(semanticModel, position, cancellationToken); } @@ -135,7 +135,7 @@ public ISet GetOuterTypes(CancellationToken cancellationToken) public TService GetLanguageService() where TService : class, ILanguageService { - return this.Workspace.Services.GetLanguageServices(this.SemanticModel.Language).GetService(); + return this.Workspace.Services.GetLanguageService(this.SemanticModel.Language); } public TService GetWorkspaceService() where TService : class, IWorkspaceService diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs new file mode 100644 index 0000000000000..629473773bf1b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs @@ -0,0 +1,189 @@ +// 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; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.GeneratedCodeRecognition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.LanguageServices; +using Microsoft.CodeAnalysis.SemanticModelWorkspaceService; +using Microsoft.CodeAnalysis.Text; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ +#if CODE_STYLE + using Resources = CodeStyleFixesResources; +#else + using Resources = WorkspacesResources; +#endif + + internal static partial class DocumentExtensions + { + // ⚠ Verify IVTs do not use this method before removing it. + public static TLanguageService? GetLanguageService(this Document? document) where TLanguageService : class, ILanguageService + => document?.Project?.GetLanguageService(); + + public static TLanguageService GetRequiredLanguageService(this Document document) where TLanguageService : class, ILanguageService + => document.Project.GetRequiredLanguageService(); + + public static async Task GetRequiredSemanticModelAsync(this Document document, CancellationToken cancellationToken) + { + var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); + return semanticModel ?? throw new InvalidOperationException(string.Format(Resources.SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0, document.Name)); + } + + public static async Task GetRequiredSyntaxTreeAsync(this Document document, CancellationToken cancellationToken) + { + var syntaxTree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); + return syntaxTree ?? throw new InvalidOperationException(string.Format(Resources.SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0, document.Name)); + } + + public static async Task GetRequiredSyntaxRootAsync(this Document document, CancellationToken cancellationToken) + { + var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + return root ?? throw new InvalidOperationException(string.Format(Resources.SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0, document.Name)); + } + + + public static bool IsOpen(this Document document) + { + var workspace = document.Project.Solution.Workspace as Workspace; + return workspace != null && workspace.IsDocumentOpen(document.Id); + } + + /// + /// this will return either regular semantic model or speculative semantic based on context. + /// any feature that is involved in typing or run on UI thread should use this to take advantage of speculative semantic model + /// whenever possible automatically. + /// + /// when using this API, semantic model should only be used to ask node inside of the given span. + /// otherwise, it might throw if semantic model returned by this API is a speculative semantic model. + /// + /// also, symbols from the semantic model returned by this API might have out of date location information. + /// if exact location (not relative location) is needed from symbol, regular GetSemanticModel should be used. + /// + public static async Task GetSemanticModelForSpanAsync(this Document document, TextSpan span, CancellationToken cancellationToken) + { + Contract.ThrowIfFalse(document.SupportsSemanticModel); + + var syntaxFactService = document.GetLanguageService(); + var semanticModelService = document.Project.Solution.Workspace.Services.GetService(); + if (semanticModelService == null || syntaxFactService == null) + { + return (await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false))!; + } + + var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + Contract.ThrowIfNull(root, "We shouldn't have a null root if the document supports semantic models"); + var token = root.FindToken(span.Start); + if (token.Parent == null) + { + return (await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false))!; + } + + var node = token.Parent.AncestorsAndSelf().First(a => a.FullSpan.Contains(span)); + return await GetSemanticModelForNodeAsync(semanticModelService, syntaxFactService, document, node, span, cancellationToken).ConfigureAwait(false); + } + + /// + /// this will return either regular semantic model or speculative semantic based on context. + /// any feature that is involved in typing or run on UI thread should use this to take advantage of speculative semantic model + /// whenever possible automatically. + /// + /// when using this API, semantic model should only be used to ask node inside of the given node except ones that belong to + /// member signature. otherwise, it might throw if semantic model returned by this API is a speculative semantic model. + /// + /// also, symbols from the semantic model returned by this API might have out of date location information. + /// if exact location (not relative location) is needed from symbol, regular GetSemanticModel should be used. + /// + public static Task GetSemanticModelForNodeAsync(this Document document, SyntaxNode? node, CancellationToken cancellationToken) + { + var syntaxFactService = document.GetLanguageService(); + var semanticModelService = document.Project.Solution.Workspace.Services.GetService(); + if (semanticModelService == null || syntaxFactService == null || node == null) + { + return document.GetSemanticModelAsync(cancellationToken)!; + } + + return GetSemanticModelForNodeAsync(semanticModelService, syntaxFactService, document, node, node.FullSpan, cancellationToken); + } + + private static Task GetSemanticModelForNodeAsync( + ISemanticModelService semanticModelService, ISyntaxFactsService syntaxFactService, + Document document, SyntaxNode node, TextSpan span, CancellationToken cancellationToken) + { + // check whether given span is a valid span to do speculative binding + var speculativeBindingSpan = syntaxFactService.GetMemberBodySpanForSpeculativeBinding(node); + if (!speculativeBindingSpan.Contains(span)) + { + return document.GetSemanticModelAsync(cancellationToken)!; + } + + return semanticModelService.GetSemanticModelForNodeAsync(document, node, cancellationToken); + } + +#if DEBUG + public static async Task HasAnyErrorsAsync(this Document document, CancellationToken cancellationToken, List? ignoreErrorCode = null) + { + var errors = await GetErrorsAsync(document, cancellationToken, ignoreErrorCode).ConfigureAwait(false); + return errors.Length > 0; + } + + public static async Task> GetErrorsAsync(this Document document, CancellationToken cancellationToken, IList? ignoreErrorCode = null) + { + if (!document.SupportsSemanticModel) + { + return ImmutableArray.Empty; + } + + ignoreErrorCode ??= SpecializedCollections.EmptyList(); + var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); + return semanticModel!.GetDiagnostics(cancellationToken: cancellationToken).WhereAsArray( + diag => diag.Severity == DiagnosticSeverity.Error && !ignoreErrorCode.Contains(diag.Id)); + } + + /// + /// Debug only extension method to verify no errors were introduced by formatting, pretty listing and other related document altering service in error-free code. + /// + public static async Task VerifyNoErrorsAsync(this Document newDocument, string message, CancellationToken cancellationToken, List? ignoreErrorCodes = null) + { + var errors = await newDocument.GetErrorsAsync(cancellationToken, ignoreErrorCodes).ConfigureAwait(false); + if (errors.Length > 0) + { + var diagnostics = string.Join(", ", errors.Select(d => d.ToString())); + Debug.Assert(false, message + ". " + diagnostics); + } + } +#endif + +#if !CODE_STYLE + public static bool IsGeneratedCode(this Document document, CancellationToken cancellationToken) + { + var generatedCodeRecognitionService = document.GetLanguageService(); + return generatedCodeRecognitionService?.IsGeneratedCode(document, cancellationToken) == true; + } +#endif + + public async static Task IsGeneratedCodeAsync(this Document document, CancellationToken cancellationToken) + { + var generatedCodeRecognitionService = document.GetLanguageService(); + return generatedCodeRecognitionService != null && + await generatedCodeRecognitionService.IsGeneratedCodeAsync(document, cancellationToken).ConfigureAwait(false); + } + + public static async Task RequireSemanticModelAsync(this Document document, CancellationToken cancellationToken) + { + var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); + return model ?? throw new InvalidOperationException(); + } + } +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/HostWorkspaceServicesExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/HostWorkspaceServicesExtensions.cs new file mode 100644 index 0000000000000..826954099b56f --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/HostWorkspaceServicesExtensions.cs @@ -0,0 +1,32 @@ +// 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 + +namespace Microsoft.CodeAnalysis.Host +{ + internal static class HostWorkspaceServicesExtensions + { + public static TLanguageService? GetLanguageService(this HostWorkspaceServices hostWorkspaceServices, string languageName) where TLanguageService : class, ILanguageService + => hostWorkspaceServices?.GetExtendedLanguageServices(languageName).GetService(); + + public static TLanguageService GetRequiredLanguageService(this HostWorkspaceServices hostWorkspaceServices, string languageName) where TLanguageService : class, ILanguageService + => hostWorkspaceServices.GetExtendedLanguageServices(languageName).GetRequiredService(); + +#pragma warning disable RS0030 // Do not used banned API 'GetLanguageServices', use 'GetExtendedLanguageServices' instead - allow in this helper which computes the extended language services. + /// + /// Gets extended host language services, which includes language services from . + /// + public static HostLanguageServices GetExtendedLanguageServices(this HostWorkspaceServices hostWorkspaceServices, string languageName) + { + var languageServices = hostWorkspaceServices.GetLanguageServices(languageName); + +#if CODE_STYLE + languageServices = CodeStyleHostLanguageServices.GetRequiredMappedCodeStyleLanguageServices(languageServices); +#endif + return languageServices; + } +#pragma warning restore RS0030 // Do not used banned APIs + } +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs new file mode 100644 index 0000000000000..92299c83f44bb --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs @@ -0,0 +1,34 @@ +// 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.Generic; + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ + internal static partial class ISolutionExtensions + { + public static IEnumerable GetChangedDocuments(this Solution? newSolution, Solution oldSolution) + { + if (newSolution != null) + { + var solutionChanges = newSolution.GetChanges(oldSolution); + + foreach (var projectChanges in solutionChanges.GetProjectChanges()) + { + foreach (var documentId in projectChanges.GetChangedDocuments()) + { + yield return documentId; + } + } + } + } + + public static TextDocument? GetTextDocument(this Solution solution, DocumentId? documentId) + { + return solution.GetDocument(documentId) ?? solution.GetAdditionalDocument(documentId) ?? solution.GetAnalyzerConfigDocument(documentId); + } + } +} diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ITypeInferenceServiceExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ITypeInferenceServiceExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/ITypeInferenceServiceExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ITypeInferenceServiceExtensions.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ProjectExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ProjectExtensions.cs new file mode 100644 index 0000000000000..3c3dc59a8297c --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ProjectExtensions.cs @@ -0,0 +1,136 @@ +// 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; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Host; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Shared.Extensions +{ +#if CODE_STYLE + using Resources = CodeStyleFixesResources; +#else + using Resources = WorkspacesResources; +#endif + + internal static partial class ProjectExtensions + { + public static TLanguageService? GetLanguageService(this Project? project) where TLanguageService : class, ILanguageService + => project?.GetExtendedLanguageServices().GetService(); + + public static TLanguageService GetRequiredLanguageService(this Project project) where TLanguageService : class, ILanguageService + => project.GetExtendedLanguageServices().GetRequiredService(); + +#pragma warning disable RS0030 // Do not used banned API 'Project.LanguageServices', use 'GetExtendedLanguageServices' instead - allow in this helper. + /// + /// Gets extended host language services, which includes language services from . + /// + public static HostLanguageServices GetExtendedLanguageServices(this Project project) + => project.Solution.Workspace.Services.GetExtendedLanguageServices(project.Language); +#pragma warning restore RS0030 // Do not used banned APIs + + public static async Task GetVersionAsync(this Project project, CancellationToken cancellationToken) + { + var version = project.Version; + var latestVersion = await project.GetLatestDocumentVersionAsync(cancellationToken).ConfigureAwait(false); + + return version.GetNewerVersion(latestVersion); + } + + public static string? TryGetAnalyzerConfigPathForProjectConfiguration(this Project project) + => TryGetAnalyzerConfigPathForProjectOrDiagnosticConfiguration(project, diagnostic: null); + + public static string? TryGetAnalyzerConfigPathForDiagnosticConfiguration(this Project project, Diagnostic diagnostic) + { + Debug.Assert(diagnostic != null); + return TryGetAnalyzerConfigPathForProjectOrDiagnosticConfiguration(project, diagnostic); + } + + private static string? TryGetAnalyzerConfigPathForProjectOrDiagnosticConfiguration(Project project, Diagnostic? diagnostic) + { + if (project.AnalyzerConfigDocuments.Any()) + { + var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath); + if (!PathUtilities.IsAbsolute(diagnosticFilePath)) + { + return null; + } + + // Currently, we use a simple heuristic to find existing .editorconfig file. + // We start from the directory of the source file where the diagnostic was reported and walk up + // the directory tree to find an .editorconfig file. + // In future, we might change this algorithm, or allow end users to customize it based on options. + + var bestPath = string.Empty; + AnalyzerConfigDocument? bestAnalyzerConfigDocument = null; + foreach (var analyzerConfigDocument in project.AnalyzerConfigDocuments) + { + var analyzerConfigDirectory = PathUtilities.GetDirectoryName(analyzerConfigDocument.FilePath); + if (diagnosticFilePath.StartsWith(analyzerConfigDirectory) && + analyzerConfigDirectory.Length > bestPath.Length) + { + bestPath = analyzerConfigDirectory; + bestAnalyzerConfigDocument = analyzerConfigDocument; + } + } + + if (bestAnalyzerConfigDocument != null) + { + return bestAnalyzerConfigDocument.FilePath; + } + } + + // Did not find any existing .editorconfig, so create one at root of the solution, if one exists. + // If project is not part of a solution, then use project path. + var solutionOrProjectFilePath = project.Solution?.FilePath ?? project.FilePath; + if (!PathUtilities.IsAbsolute(solutionOrProjectFilePath)) + { + return null; + } + + var solutionOrProjectDirectoryPath = PathUtilities.GetDirectoryName(solutionOrProjectFilePath); + return PathUtilities.CombineAbsoluteAndRelativePaths(solutionOrProjectDirectoryPath, ".editorconfig"); + } + + public static AnalyzerConfigDocument? TryGetExistingAnalyzerConfigDocumentAtPath(this Project project, string analyzerConfigPath) + { + Debug.Assert(analyzerConfigPath != null); + Debug.Assert(PathUtilities.IsAbsolute(analyzerConfigPath)); + + return project.AnalyzerConfigDocuments.FirstOrDefault(d => d.FilePath == analyzerConfigPath); + } + + public static AnalyzerConfigDocument? GetOrCreateAnalyzerConfigDocument(this Project project, string analyzerConfigPath) + { + var existingAnalyzerConfigDocument = project.TryGetExistingAnalyzerConfigDocumentAtPath(analyzerConfigPath); + if (existingAnalyzerConfigDocument != null) + { + return existingAnalyzerConfigDocument; + } + + var id = DocumentId.CreateNewId(project.Id); + var documentInfo = DocumentInfo.Create(id, ".editorconfig", filePath: analyzerConfigPath); + var newSolution = project.Solution.AddAnalyzerConfigDocuments(ImmutableArray.Create(documentInfo)); + return newSolution.GetProject(project.Id)?.GetAnalyzerConfigDocument(id); + } + + public static async Task GetRequiredCompilationAsync(this Project project, CancellationToken cancellationToken) + { + var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + if (compilation == null) + { + throw new InvalidOperationException(string.Format(Resources.Compilation_is_required_to_accomplish_the_task_but_is_not_supported_by_project_0, project.Name)); + } + + return compilation; + } + } +} diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxEditorExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxEditorExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxEditorExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxEditorExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxTreeExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTreeExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/SyntaxTreeExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/TextDocumentExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/TextDocumentExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/TextDocumentExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/TextDocumentExtensions.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Helpers/MefHostServicesHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Helpers/MefHostServicesHelpers.cs new file mode 100644 index 0000000000000..feaea255e8fdb --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Helpers/MefHostServicesHelpers.cs @@ -0,0 +1,55 @@ +// 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.Linq; +using System.Reflection; + +namespace Microsoft.CodeAnalysis.Host.Mef +{ + internal static class MefHostServicesHelpers + { + public static ImmutableArray LoadNearbyAssemblies(IEnumerable assemblyNames) + { + var assemblies = new List(); + + foreach (var assemblyName in assemblyNames) + { + var assembly = TryLoadNearbyAssembly(assemblyName); + if (assembly != null) + { + assemblies.Add(assembly); + } + } + + return assemblies.ToImmutableArray(); + } + + private static Assembly TryLoadNearbyAssembly(string assemblySimpleName) + { + var thisAssemblyName = typeof(MefHostServicesHelpers).GetTypeInfo().Assembly.GetName(); + var assemblyShortName = thisAssemblyName.Name; + var assemblyVersion = thisAssemblyName.Version; + var publicKeyToken = thisAssemblyName.GetPublicKeyToken().Aggregate(string.Empty, (s, b) => s + b.ToString("x2")); + + if (string.IsNullOrEmpty(publicKeyToken)) + { + publicKeyToken = "null"; + } + + var assemblyName = new AssemblyName(string.Format("{0}, Version={1}, Culture=neutral, PublicKeyToken={2}", assemblySimpleName, assemblyVersion, publicKeyToken)); + + try + { + return Assembly.Load(assemblyName); + } + catch (Exception) + { + return null; + } + } + } +} diff --git a/src/Workspaces/Core/Portable/AddImports/AbstractAddImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/AbstractAddImportsService.cs similarity index 94% rename from src/Workspaces/Core/Portable/AddImports/AbstractAddImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/AbstractAddImportsService.cs index 387412a9e9773..4bcf5634d6cb3 100644 --- a/src/Workspaces/Core/Portable/AddImports/AbstractAddImportsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/AbstractAddImportsService.cs @@ -9,6 +9,7 @@ using System.Collections.Immutable; using System.Linq; using System.Threading; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Shared.Extensions; namespace Microsoft.CodeAnalysis.AddImports @@ -25,7 +26,7 @@ protected AbstractAddImportsService() } protected abstract SyntaxNode? GetAlias(TUsingOrAliasSyntax usingOrAlias); - protected abstract ImmutableArray GetGlobalImports(Compilation compilation); + protected abstract ImmutableArray GetGlobalImports(Compilation compilation, SyntaxGenerator generator); protected abstract SyntaxList GetUsingsAndAliases(SyntaxNode node); protected abstract SyntaxList GetExterns(SyntaxNode node); protected abstract bool IsStaticUsing(TUsingOrAliasSyntax usingOrAlias); @@ -39,10 +40,13 @@ protected AbstractAddImportsService() private bool HasAnyImports(SyntaxNode node) => GetUsingsAndAliases(node).Any() || GetExterns(node).Any(); public bool HasExistingImport( - Compilation compilation, SyntaxNode root, - SyntaxNode? contextLocation, SyntaxNode import) + Compilation compilation, + SyntaxNode root, + SyntaxNode? contextLocation, + SyntaxNode import, + SyntaxGenerator generator) { - var globalImports = GetGlobalImports(compilation); + var globalImports = GetGlobalImports(compilation, generator); var containers = GetAllContainers(root, contextLocation); return HasExistingImport(import, containers, globalImports); } @@ -115,12 +119,13 @@ public SyntaxNode AddImports( SyntaxNode root, SyntaxNode? contextLocation, IEnumerable newImports, + SyntaxGenerator generator, bool placeSystemNamespaceFirst, CancellationToken cancellationToken) { contextLocation ??= root; - var globalImports = GetGlobalImports(compilation); + var globalImports = GetGlobalImports(compilation, generator); var containers = GetAllContainers(root, contextLocation); var filteredImports = newImports.Where(i => !HasExistingImport(i, containers, globalImports)).ToArray(); diff --git a/src/Workspaces/Core/Portable/AddImports/AddImportHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/AddImportHelpers.cs similarity index 100% rename from src/Workspaces/Core/Portable/AddImports/AddImportHelpers.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/AddImportHelpers.cs diff --git a/src/Workspaces/Core/Portable/AddImports/IAddImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/IAddImportsService.cs similarity index 75% rename from src/Workspaces/Core/Portable/AddImports/IAddImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/IAddImportsService.cs index fa5d83209aaf2..443431f9b0b91 100644 --- a/src/Workspaces/Core/Portable/AddImports/IAddImportsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/AddImports/IAddImportsService.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Threading; +using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Host; using Roslyn.Utilities; @@ -18,7 +19,7 @@ internal interface IAddImportsService : ILanguageService /// in scope at . This includes /// global imports for VB. /// - bool HasExistingImport(Compilation compilation, SyntaxNode root, SyntaxNode? contextLocation, SyntaxNode import); + bool HasExistingImport(Compilation compilation, SyntaxNode root, SyntaxNode? contextLocation, SyntaxNode import, SyntaxGenerator generator); /// /// Given a context location in a provided syntax tree, returns the appropriate container @@ -28,17 +29,18 @@ internal interface IAddImportsService : ILanguageService SyntaxNode AddImports( Compilation compilation, SyntaxNode root, SyntaxNode? contextLocation, - IEnumerable newImports, bool placeSystemNamespaceFirst, CancellationToken cancellationToken); + IEnumerable newImports, SyntaxGenerator generator, + bool placeSystemNamespaceFirst, CancellationToken cancellationToken); } internal static class IAddImportServiceExtensions { public static SyntaxNode AddImport( this IAddImportsService service, Compilation compilation, SyntaxNode root, - SyntaxNode contextLocation, SyntaxNode newImport, bool placeSystemNamespaceFirst, CancellationToken cancellationToken) + SyntaxNode contextLocation, SyntaxNode newImport, SyntaxGenerator generator, bool placeSystemNamespaceFirst, CancellationToken cancellationToken) { return service.AddImports(compilation, root, contextLocation, - SpecializedCollections.SingletonEnumerable(newImport), placeSystemNamespaceFirst, cancellationToken); + SpecializedCollections.SingletonEnumerable(newImport), generator, placeSystemNamespaceFirst, cancellationToken); } } } diff --git a/src/Workspaces/Core/Portable/Workspace/Host/CommandLine/ICommandLineParserService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/CommandLine/ICommandLineParserService.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/CommandLine/ICommandLineParserService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/CommandLine/ICommandLineParserService.cs diff --git a/src/Workspaces/Core/Portable/GeneratedCodeRecognition/AbstractGeneratedCodeRecognitionService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/GeneratedCodeRecognition/AbstractGeneratedCodeRecognitionService.cs similarity index 72% rename from src/Workspaces/Core/Portable/GeneratedCodeRecognition/AbstractGeneratedCodeRecognitionService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/GeneratedCodeRecognition/AbstractGeneratedCodeRecognitionService.cs index 54d963aba1b2a..5f11ef9b750b4 100644 --- a/src/Workspaces/Core/Portable/GeneratedCodeRecognition/AbstractGeneratedCodeRecognitionService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/GeneratedCodeRecognition/AbstractGeneratedCodeRecognitionService.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; @@ -11,10 +12,22 @@ namespace Microsoft.CodeAnalysis.GeneratedCodeRecognition { internal abstract class AbstractGeneratedCodeRecognitionService : IGeneratedCodeRecognitionService { +#if !CODE_STYLE public bool IsGeneratedCode(Document document, CancellationToken cancellationToken) { var syntaxTree = document.GetSyntaxTreeSynchronously(cancellationToken); + return IsGeneratedCode(syntaxTree, document, cancellationToken); + } +#endif + public async Task IsGeneratedCodeAsync(Document document, CancellationToken cancellationToken) + { + var syntaxTree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); + return IsGeneratedCode(syntaxTree, document, cancellationToken); + } + + private static bool IsGeneratedCode(SyntaxTree syntaxTree, Document document, CancellationToken cancellationToken) + { // First check if user has configured "generated_code = true | false" in .editorconfig var analyzerOptions = document.Project.AnalyzerOptions.AnalyzerConfigOptionsProvider.GetOptions(syntaxTree); var isUserConfiguredGeneratedCode = GeneratedCodeUtilities.GetIsGeneratedCodeFromOptions(analyzerOptions); diff --git a/src/Workspaces/Core/Portable/GeneratedCodeRecognition/IGeneratedCodeRecognitionService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/GeneratedCodeRecognition/IGeneratedCodeRecognitionService.cs similarity index 76% rename from src/Workspaces/Core/Portable/GeneratedCodeRecognition/IGeneratedCodeRecognitionService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/GeneratedCodeRecognition/IGeneratedCodeRecognitionService.cs index be0de1ee6f665..467b1add78f21 100644 --- a/src/Workspaces/Core/Portable/GeneratedCodeRecognition/IGeneratedCodeRecognitionService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/GeneratedCodeRecognition/IGeneratedCodeRecognitionService.cs @@ -3,12 +3,17 @@ // See the LICENSE file in the project root for more information. using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.GeneratedCodeRecognition { internal interface IGeneratedCodeRecognitionService : ILanguageService { +#if !CODE_STYLE bool IsGeneratedCode(Document document, CancellationToken cancellationToken); +#endif + + Task IsGeneratedCodeAsync(Document document, CancellationToken cancellationToken); } } diff --git a/src/Workspaces/Core/Portable/LanguageServices/Precedence/IPrecedenceService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Precedence/IPrecedenceService.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/Precedence/IPrecedenceService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Precedence/IPrecedenceService.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/Precedence/PrecedenceKind.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Precedence/PrecedenceKind.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/Precedence/PrecedenceKind.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Precedence/PrecedenceKind.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs similarity index 99% rename from src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs index 8a235a4efb630..f098e007a5f4a 100644 --- a/src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading; diff --git a/src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/ForEachSymbols.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/ForEachSymbols.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/ForEachSymbols.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/ForEachSymbols.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/ISemanticFactsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/ISemanticFactsService.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/ISemanticFactsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/ISemanticFactsService.cs diff --git a/src/Workspaces/Core/Portable/Simplification/AliasAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/AliasAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Simplification/AliasAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/AliasAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Simplification/DoNotAddImportsAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/DoNotAddImportsAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Simplification/DoNotAddImportsAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/DoNotAddImportsAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Simplification/DoNotAllowVarAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/DoNotAllowVarAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Simplification/DoNotAllowVarAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/DoNotAllowVarAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Simplification/SimplificationHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs similarity index 99% rename from src/Workspaces/Core/Portable/Simplification/SimplificationHelpers.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs index 14cc163aff5e6..9a378d8afb235 100644 --- a/src/Workspaces/Core/Portable/Simplification/SimplificationHelpers.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs @@ -4,12 +4,13 @@ using System.Linq; using Microsoft.CodeAnalysis.CodeStyle; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Simplification { + using OptionSet = Options.OptionSet; + internal static class SimplificationHelpers { public static readonly SyntaxAnnotation DontSimplifyAnnotation = new SyntaxAnnotation(); diff --git a/src/Workspaces/Core/Portable/Simplification/SpecialTypeAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SpecialTypeAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Simplification/SpecialTypeAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SpecialTypeAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Simplification/SymbolAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SymbolAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Simplification/SymbolAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SymbolAnnotation.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SymbolDeclarationService/ISymbolDeclarationService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SymbolDeclarationService/ISymbolDeclarationService.cs similarity index 95% rename from src/Workspaces/Core/Portable/LanguageServices/SymbolDeclarationService/ISymbolDeclarationService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SymbolDeclarationService/ISymbolDeclarationService.cs index 4aa2dd0d2dacf..966e024e3f0d5 100644 --- a/src/Workspaces/Core/Portable/LanguageServices/SymbolDeclarationService/ISymbolDeclarationService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SymbolDeclarationService/ISymbolDeclarationService.cs @@ -2,7 +2,6 @@ // 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.Collections.Generic; using System.Collections.Immutable; using Microsoft.CodeAnalysis.Host; diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractDocumentationCommentService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/AbstractDocumentationCommentService.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractDocumentationCommentService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/AbstractDocumentationCommentService.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs similarity index 85% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs index d7d6dfa889499..63a221d7666b4 100644 --- a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs @@ -7,11 +7,8 @@ using System.Collections.Immutable; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.Linq; -using System.Text; using System.Threading; -using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.Utilities; @@ -20,95 +17,6 @@ namespace Microsoft.CodeAnalysis.LanguageServices { - internal abstract class AbstractDeclaredSymbolInfoFactoryService : IDeclaredSymbolInfoFactoryService - { - private const string GenericTypeNameManglingString = "`"; - private static readonly string[] s_aritySuffixesOneToNine = { "`1", "`2", "`3", "`4", "`5", "`6", "`7", "`8", "`9" }; - - private readonly static ObjectPool>> s_aliasMapListPool - = SharedPools.Default>>(); - - // Note: these names are stored case insensitively. That way the alias mapping works - // properly for VB. It will mean that our inheritance maps may store more links in them - // for C#. However, that's ok. It will be rare in practice, and all it means is that - // we'll end up examining slightly more types (likely 0) when doing operations like - // Find all references. - private readonly static ObjectPool> s_aliasMapPool - = SharedPools.StringIgnoreCaseDictionary(); - - protected static List> AllocateAliasMapList() - => s_aliasMapListPool.Allocate(); - - protected static void FreeAliasMapList(List> list) - { - if (list != null) - { - foreach (var aliasMap in list) - { - FreeAliasMap(aliasMap); - } - - s_aliasMapListPool.ClearAndFree(list); - } - } - - protected static void FreeAliasMap(Dictionary aliasMap) - { - if (aliasMap != null) - { - s_aliasMapPool.ClearAndFree(aliasMap); - } - } - - protected static Dictionary AllocateAliasMap() - => s_aliasMapPool.Allocate(); - - protected static void AppendTokens(SyntaxNode node, StringBuilder builder) - { - foreach (var child in node.ChildNodesAndTokens()) - { - if (child.IsToken) - { - builder.Append(child.AsToken().Text); - } - else - { - AppendTokens(child.AsNode(), builder); - } - } - } - - protected static void Intern(StringTable stringTable, ArrayBuilder builder) - { - for (int i = 0, n = builder.Count; i < n; i++) - { - builder[i] = stringTable.Add(builder[i]); - } - } - - public static string GetMetadataAritySuffix(int arity) - { - Debug.Assert(arity > 0); - return (arity <= s_aritySuffixesOneToNine.Length) - ? s_aritySuffixesOneToNine[arity - 1] - : string.Concat(GenericTypeNameManglingString, arity.ToString(CultureInfo.InvariantCulture)); - } - - public abstract bool TryGetDeclaredSymbolInfo(StringTable stringTable, SyntaxNode node, string rootNamespace, out DeclaredSymbolInfo declaredSymbolInfo); - - /// - /// Get the name of the target type of specified extension method declaration. - /// The node provided must be an extension method declaration, i.e. calling `TryGetDeclaredSymbolInfo()` - /// on `node` should return a `DeclaredSymbolInfo` of kind `ExtensionMethod`. - /// If the return value is null, then it means this is a "complex" method (as described at ). - /// - public abstract string GetTargetTypeName(SyntaxNode node); - - public abstract bool TryGetAliasesFromUsingDirective(SyntaxNode node, out ImmutableArray<(string aliasName, string name)> aliases); - - public abstract string GetRootNamespace(CompilationOptions compilationOptions); - } - internal abstract class AbstractSyntaxFactsService { private readonly static ObjectPool> s_stackPool diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ExternalSourceInfo.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/ExternalSourceInfo.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ExternalSourceInfo.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/ExternalSourceInfo.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/IDocumentationCommentService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/IDocumentationCommentService.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/IDocumentationCommentService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/IDocumentationCommentService.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsServiceExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/ISyntaxFactsServiceExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsServiceExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/ISyntaxFactsServiceExtensions.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxKindsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/ISyntaxKindsService.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxKindsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxFactsService/ISyntaxKindsService.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.AbstractTypeInferrer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.AbstractTypeInferrer.cs similarity index 95% rename from src/Workspaces/Core/Portable/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.AbstractTypeInferrer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.AbstractTypeInferrer.cs index 9fee7939f8214..8f12cf91b967e 100644 --- a/src/Workspaces/Core/Portable/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.AbstractTypeInferrer.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.AbstractTypeInferrer.cs @@ -79,7 +79,11 @@ private ImmutableArray Filter(IEnumerable } protected IEnumerable CreateResult(SpecialType type, NullableAnnotation nullableAnnotation = NullableAnnotation.None) - => CreateResult(Compilation.GetSpecialType(type).WithNullableAnnotation(nullableAnnotation)); + => CreateResult(Compilation.GetSpecialType(type) +#if !CODE_STYLE // TODO: remove this #if directive once the below public API is available in CodeStyle layer. + .WithNullableAnnotation(nullableAnnotation) +#endif + ); protected IEnumerable CreateResult(ITypeSymbol type) => type == null diff --git a/src/Workspaces/Core/Portable/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/TypeInferenceService/AbstractTypeInferenceService.cs diff --git a/src/Workspaces/Core/Portable/LanguageServices/TypeInferenceService/ITypeInferenceService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/TypeInferenceService/ITypeInferenceService.cs similarity index 100% rename from src/Workspaces/Core/Portable/LanguageServices/TypeInferenceService/ITypeInferenceService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/TypeInferenceService/ITypeInferenceService.cs diff --git a/src/Workspaces/Core/Portable/Log/AbstractLogAggregator.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Log/AbstractLogAggregator.cs similarity index 100% rename from src/Workspaces/Core/Portable/Log/AbstractLogAggregator.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Log/AbstractLogAggregator.cs diff --git a/src/Workspaces/Core/Portable/Log/LogAggregator.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Log/LogAggregator.cs similarity index 100% rename from src/Workspaces/Core/Portable/Log/LogAggregator.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Log/LogAggregator.cs diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameActionAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameActionAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameActionAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameActionAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameDeclarationLocationReference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameDeclarationLocationReference.cs similarity index 100% rename from src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameDeclarationLocationReference.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameDeclarationLocationReference.cs diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameInvalidIdentifierAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameInvalidIdentifierAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameInvalidIdentifierAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameInvalidIdentifierAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameNodeSimplificationAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameNodeSimplificationAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameNodeSimplificationAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameNodeSimplificationAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameTokenSimplificationAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameTokenSimplificationAnnotation.cs similarity index 100% rename from src/Workspaces/Core/Portable/Rename/ConflictEngine/Annotations/RenameTokenSimplificationAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Rename/Annotations/RenameTokenSimplificationAnnotation.cs diff --git a/src/Workspaces/Core/Portable/Utilities/AbstractSpeculationAnalyzer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/AbstractSpeculationAnalyzer.cs similarity index 100% rename from src/Workspaces/Core/Portable/Utilities/AbstractSpeculationAnalyzer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/AbstractSpeculationAnalyzer.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/Matcher.ChoiceMatcher.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.ChoiceMatcher.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/Matcher.ChoiceMatcher.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.ChoiceMatcher.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/Matcher.RepeatMatcher.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.RepeatMatcher.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/Matcher.RepeatMatcher.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.RepeatMatcher.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/Matcher.SequenceMatcher.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.SequenceMatcher.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/Matcher.SequenceMatcher.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.SequenceMatcher.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/Matcher.SingleMatcher.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.SingleMatcher.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/Matcher.SingleMatcher.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.SingleMatcher.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/Matcher.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/Matcher.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/Matcher`1.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher`1.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/Matcher`1.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/Matcher`1.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/NameGenerator.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/NameGenerator.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/NameGenerator.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/NameGenerator.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SemanticDocument.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/SemanticDocument.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Solution/SemanticDocument.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/SemanticDocument.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SyntacticDocument.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/SyntacticDocument.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Solution/SyntacticDocument.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/SyntacticDocument.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/TextReaderWithLength.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/TextReaderWithLength.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/TextReaderWithLength.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/TextReaderWithLength.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/CodeChangeProviderMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/CodeChangeProviderMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/CodeChangeProviderMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/CodeChangeProviderMetadata.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/FileExtensionsMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/FileExtensionsMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/FileExtensionsMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/FileExtensionsMetadata.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/ILanguageMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/ILanguageMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/ILanguageMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/ILanguageMetadata.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/ILanguagesMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/ILanguagesMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/ILanguagesMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/ILanguagesMetadata.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/IMefHostExportProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/IMefHostExportProvider.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/IMefHostExportProvider.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/IMefHostExportProvider.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/LanguageMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/LanguageMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/LanguageMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/LanguageMetadata.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/LanguageServiceMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/LanguageServiceMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/LanguageServiceMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/LanguageServiceMetadata.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/MefLanguageServices.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/MefLanguageServices.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/MefLanguageServices.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/MefLanguageServices.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/MefWorkspaceServices.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/MefWorkspaceServices.cs similarity index 96% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/MefWorkspaceServices.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/MefWorkspaceServices.cs index acf7512695307..fd7c75642f64c 100644 --- a/src/Workspaces/Core/Portable/Workspace/Host/Mef/MefWorkspaceServices.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/MefWorkspaceServices.cs @@ -123,8 +123,7 @@ private IEnumerable GetSupportedLanguages() { var list = _exportProvider.GetExports().Select(lz => lz.Metadata.Language).Concat( _exportProvider.GetExports().Select(lz => lz.Metadata.Language)) - .Distinct() - .ToImmutableArray(); + .Distinct(); Interlocked.CompareExchange(ref _languages, list, null); } @@ -157,7 +156,9 @@ public override HostLanguageServices GetLanguageServices(string languageName) else { // throws exception +#pragma warning disable RS0030 // Do not used banned API 'GetLanguageServices', use 'GetExtendedLanguageServices' instead - allowed in this context. return base.GetLanguageServices(languageName); +#pragma warning restore RS0030 // Do not used banned APIs } } diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/OrderableLanguageMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/OrderableLanguageMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/OrderableLanguageMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/OrderableLanguageMetadata.cs diff --git a/src/Workspaces/Core/Portable/OrderableMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/OrderableMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/OrderableMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/OrderableMetadata.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/WorkspaceKindMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/WorkspaceKindMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/WorkspaceKindMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/WorkspaceKindMetadata.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Host/Mef/WorkspaceServiceMetadata.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/WorkspaceServiceMetadata.cs similarity index 100% rename from src/Workspaces/Core/Portable/Workspace/Host/Mef/WorkspaceServiceMetadata.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Workspace/Mef/WorkspaceServiceMetadata.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems new file mode 100644 index 0000000000000..907033503e0bc --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems @@ -0,0 +1,96 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.Shared + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.shproj b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.shproj new file mode 100644 index 0000000000000..fea1e18fd4757 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.shproj @@ -0,0 +1,12 @@ + + + + {99F594B1-3916-471D-A761-A6731FC50E9A} + 14.0 + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/ISemanticModelService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceServices/SemanticModelWorkspaceService/ISemanticModelService.cs similarity index 100% rename from src/Workspaces/Core/Portable/SemanticModelWorkspaceService/ISemanticModelService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceServices/SemanticModelWorkspaceService/ISemanticModelService.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs new file mode 100644 index 0000000000000..4060dee7b4f9d --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs @@ -0,0 +1,26 @@ +// 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.Composition; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.CodeAnalysis.SemanticModelWorkspaceService +{ + [ExportWorkspaceServiceFactory(typeof(ISemanticModelService), ServiceLayer.Default), Shared] + internal partial class SemanticModelWorkspaceServiceFactory : IWorkspaceServiceFactory + { + [ImportingConstructor] + public SemanticModelWorkspaceServiceFactory() + { + } + + public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) + { + return new SemanticModelService(); + } + } +} diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ArgumentListSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ArgumentListSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ArgumentListSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ArgumentListSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ArgumentSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ArgumentSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ArgumentSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ArgumentSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/CallStatementSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CallStatementSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/CallStatementSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CallStatementSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/CastAnalyzer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CastAnalyzer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/CastAnalyzer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CastAnalyzer.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/CastExpressionSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CastExpressionSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/CastExpressionSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CastExpressionSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/CompilationUnitSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CompilationUnitSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/CompilationUnitSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CompilationUnitSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/IsStatementTerminatingTokenVisitor.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/IsStatementTerminatingTokenVisitor.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/IsStatementTerminatingTokenVisitor.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/IsStatementTerminatingTokenVisitor.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/SyntaxTokenExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/SyntaxTokenExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/SyntaxTokenExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/SyntaxTokenExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/SyntaxTreeExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/SyntaxTreeExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/VisualBasicSyntaxContext.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/VisualBasicSyntaxContext.vb similarity index 99% rename from src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/VisualBasicSyntaxContext.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/VisualBasicSyntaxContext.vb index 507b77434c0e4..174861af4f9ad 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/VisualBasicSyntaxContext.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/VisualBasicSyntaxContext.vb @@ -7,6 +7,7 @@ Imports Microsoft.CodeAnalysis.LanguageServices Imports Microsoft.CodeAnalysis.Shared.Extensions.ContextQuery Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.CodeAnalysis.VisualBasic.Utilities +Imports Roslyn.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery ''' diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/VisualBasicSyntaxContextExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/VisualBasicSyntaxContextExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/VisualBasicSyntaxContextExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ContextQuery/VisualBasicSyntaxContextExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/DirectiveSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/DirectiveSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/DirectiveSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/DirectiveSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb similarity index 99% rename from src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb index ace041bdc6f1b..aa3f472821d6a 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb @@ -12,6 +12,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.CodeAnalysis.VisualBasic.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions + Friend Module ExpressionSyntaxExtensions Public ReadOnly typeNameFormatWithGenerics As New SymbolDisplayFormat( diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxGeneratorVisitor.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxGeneratorVisitor.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxGeneratorVisitor.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxGeneratorVisitor.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/IMethodSymbolExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/IMethodSymbolExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/IMethodSymbolExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/IMethodSymbolExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/INamespaceOrTypeSymbolExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/INamespaceOrTypeSymbolExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/INamespaceOrTypeSymbolExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/INamespaceOrTypeSymbolExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ITypeSymbolExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ITypeSymbolExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ITypeSymbolExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ITypeSymbolExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/InvocationExpressionSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/InvocationExpressionSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/InvocationExpressionSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/InvocationExpressionSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/MemberAccessExpressionSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/MemberAccessExpressionSyntaxExtensions.vb similarity index 96% rename from src/Workspaces/VisualBasic/Portable/Extensions/MemberAccessExpressionSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/MemberAccessExpressionSyntaxExtensions.vb index 2b351653f27cc..72d43079f7586 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/MemberAccessExpressionSyntaxExtensions.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/MemberAccessExpressionSyntaxExtensions.vb @@ -128,13 +128,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions End Function - Public Function GetNameWithTriviaMoved(memberAccess As MemberAccessExpressionSyntax, - semanticModel As SemanticModel) As SimpleNameSyntax + Public Function GetNameWithTriviaMoved(memberAccess As MemberAccessExpressionSyntax) As SimpleNameSyntax Dim replacementNode = memberAccess.Name replacementNode = DirectCast(replacementNode, SimpleNameSyntax) _ - .WithIdentifier(VisualBasicSimplificationService.TryEscapeIdentifierToken( - memberAccess.Name.Identifier, - semanticModel)) _ + .WithIdentifier(TryEscapeIdentifierToken(memberAccess.Name.Identifier)) _ .WithLeadingTrivia(GetLeadingTriviaForSimplifiedMemberAccess(memberAccess)) _ .WithTrailingTrivia(memberAccess.GetTrailingTrivia()) diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/NameSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/NameSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/NameSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/NameSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ObjectCreationExpressionExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ObjectCreationExpressionExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ObjectCreationExpressionExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ObjectCreationExpressionExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/OperatorPrecedence.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/OperatorPrecedence.vb similarity index 83% rename from src/Workspaces/VisualBasic/Portable/Extensions/OperatorPrecedence.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/OperatorPrecedence.vb index df81cdf832b42..9e54a81aff47d 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/OperatorPrecedence.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/OperatorPrecedence.vb @@ -2,9 +2,6 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports Microsoft.CodeAnalysis.Text -Imports Microsoft.CodeAnalysis.VisualBasic.Symbols -Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Friend Enum OperatorPrecedence PrecedenceNone = 0 diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ParameterSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ParameterSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ParameterSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ParameterSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ParenthesizedExpressionSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ParenthesizedExpressionSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/ParenthesizedExpressionSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ParenthesizedExpressionSyntaxExtensions.vb diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SemanticModelExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SemanticModelExtensions.vb new file mode 100644 index 0000000000000..58f6121f2fc7d --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SemanticModelExtensions.vb @@ -0,0 +1,285 @@ +' 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. + +Imports System.Collections.Immutable +Imports System.Runtime.CompilerServices +Imports System.Threading +Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles +Imports Microsoft.CodeAnalysis.PooledObjects +Imports Microsoft.CodeAnalysis.Utilities +Imports Microsoft.CodeAnalysis.VisualBasic.Syntax + +Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions + Partial Friend Module SemanticModelExtensions + + Private Const s_defaultParameterName = "p" + Private Const s_defaultBuiltInParameterName = "v" + + + Public Function LookupTypeRegardlessOfArity(semanticModel As SemanticModel, + name As SyntaxToken, + cancellationToken As CancellationToken) As IList(Of ITypeSymbol) + Dim expression = TryCast(name.Parent, ExpressionSyntax) + If expression IsNot Nothing Then + Dim results = semanticModel.LookupName(expression, namespacesAndTypesOnly:=True, cancellationToken:=cancellationToken) + If results.Count > 0 Then + Return results.OfType(Of ITypeSymbol)().ToList() + End If + End If + Return SpecializedCollections.EmptyList(Of ITypeSymbol)() + End Function + + + Public Function LookupName(semanticModel As SemanticModel, name As SyntaxToken, + namespacesAndTypesOnly As Boolean, + cancellationToken As CancellationToken) As IList(Of ISymbol) + Dim expression = TryCast(name.Parent, ExpressionSyntax) + If expression IsNot Nothing Then + Return semanticModel.LookupName(expression, namespacesAndTypesOnly, cancellationToken) + End If + Return SpecializedCollections.EmptyList(Of ISymbol)() + End Function + + + Public Function LookupName(semanticModel As SemanticModel, + expression As ExpressionSyntax, + namespacesAndTypesOnly As Boolean, + cancellationToken As CancellationToken) As IList(Of ISymbol) + Dim expr = SyntaxFactory.GetStandaloneExpression(expression) + + Dim qualifier As ExpressionSyntax = Nothing + Dim name As String = Nothing + Dim arity As Integer = Nothing + expr.DecomposeName(qualifier, name, arity) + + Dim symbol As INamespaceOrTypeSymbol = Nothing + If qualifier IsNot Nothing AndAlso TypeOf qualifier Is TypeSyntax Then + Dim typeInfo = semanticModel.GetTypeInfo(qualifier, cancellationToken) + Dim symbolInfo = semanticModel.GetSymbolInfo(qualifier, cancellationToken) + + If typeInfo.Type IsNot Nothing Then + symbol = typeInfo.Type + ElseIf symbolInfo.Symbol IsNot Nothing Then + symbol = TryCast(symbolInfo.Symbol, INamespaceOrTypeSymbol) + End If + End If + + Return If( + namespacesAndTypesOnly, + semanticModel.LookupNamespacesAndTypes(expr.SpanStart, container:=symbol, name:=name), + semanticModel.LookupSymbols(expr.SpanStart, container:=symbol, name:=name)) + End Function + + + Public Function GetSymbolInfo(semanticModel As SemanticModel, token As SyntaxToken) As SymbolInfo + Dim expression = TryCast(token.Parent, ExpressionSyntax) + If expression Is Nothing Then + Return Nothing + End If + + Return semanticModel.GetSymbolInfo(expression) + End Function + + + Public Function GenerateNameForArgument(semanticModel As SemanticModel, + argument As ArgumentSyntax, + cancellationToken As CancellationToken) As String + Dim result = GenerateNameForArgumentWorker(semanticModel, argument, cancellationToken) + Return If(String.IsNullOrWhiteSpace(result), s_defaultParameterName, result) + End Function + + Private Function GenerateNameForArgumentWorker(semanticModel As SemanticModel, + argument As ArgumentSyntax, + cancellationToken As CancellationToken) As String + If argument.IsNamed Then + Return DirectCast(argument, SimpleArgumentSyntax).NameColonEquals.Name.Identifier.ValueText + ElseIf Not argument.IsOmitted Then + Return semanticModel.GenerateNameForExpression( + argument.GetExpression(), capitalize:=False, cancellationToken:=cancellationToken) + Else + Return s_defaultParameterName + End If + End Function + + ''' + ''' Given an expression node, tries to generate an appropriate name that can be used for + ''' that expression. + ''' + + Public Function GenerateNameForExpression(semanticModel As SemanticModel, + expression As ExpressionSyntax, + capitalize As Boolean, + cancellationToken As CancellationToken) As String + ' Try to find a usable name node that we can use to name the + ' parameter. If we have an expression that has a name as part of it + ' then we try to use that part. + Dim current = expression + + While True + current = current.WalkDownParentheses() + If current.Kind = SyntaxKind.IdentifierName Then + Return (DirectCast(current, IdentifierNameSyntax)).Identifier.ValueText.ToCamelCase() + ElseIf TypeOf current Is MemberAccessExpressionSyntax Then + Return (DirectCast(current, MemberAccessExpressionSyntax)).Name.Identifier.ValueText.ToCamelCase() + ElseIf TypeOf current Is CastExpressionSyntax Then + current = (DirectCast(current, CastExpressionSyntax)).Expression + Else + Exit While + End If + End While + + ' there was nothing in the expression to signify a name. If we're in an argument + ' location, then try to choose a name based on the argument name. + Dim argumentName = TryGenerateNameForArgumentExpression( + semanticModel, expression, cancellationToken) + If argumentName IsNot Nothing Then + Return If(capitalize, argumentName.ToPascalCase(), argumentName.ToCamelCase()) + End If + + ' Otherwise, figure out the type of the expression and generate a name from that + ' instead. + Dim info = semanticModel.GetTypeInfo(expression, cancellationToken) + + ' If we can't determine the type, then fallback to some placeholders. + Dim [type] = info.Type + Return [type].CreateParameterName(capitalize) + End Function + + Private Function TryGenerateNameForArgumentExpression(semanticModel As SemanticModel, expression As ExpressionSyntax, cancellationToken As CancellationToken) As String + Dim topExpression = expression.WalkUpParentheses() + If TypeOf topExpression.Parent Is ArgumentSyntax Then + Dim argument = DirectCast(topExpression.Parent, ArgumentSyntax) + Dim simpleArgument = TryCast(argument, SimpleArgumentSyntax) + + If simpleArgument?.NameColonEquals IsNot Nothing Then + Return simpleArgument.NameColonEquals.Name.Identifier.ValueText + End If + + Dim argumentList = TryCast(argument.Parent, ArgumentListSyntax) + If argumentList IsNot Nothing Then + Dim index = argumentList.Arguments.IndexOf(argument) + Dim member = TryCast(semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken).Symbol, IMethodSymbol) + If member IsNot Nothing AndAlso index < member.Parameters.Length Then + Dim parameter = member.Parameters(index) + If parameter.Type.TypeKind <> TypeKind.TypeParameter Then + Return parameter.Name + End If + End If + End If + End If + + Return Nothing + End Function + + + Public Function GetImportNamespacesInScope(semanticModel As SemanticModel, location As SyntaxNode) As ISet(Of INamespaceSymbol) + Dim q = + From u In location.GetAncestorOrThis(Of CompilationUnitSyntax).Imports + From importClause In u.ImportsClauses.OfType(Of SimpleImportsClauseSyntax)() + Where importClause.Alias Is Nothing + Let info = semanticModel.GetSymbolInfo(importClause.Name) + Let ns = TryCast(info.Symbol, INamespaceSymbol) + Where ns IsNot Nothing + Select ns + + Return q.ToSet() + End Function + + + Public Function GetAliasInfo(semanticModel As SemanticModel, expression As ExpressionSyntax, cancellationToken As CancellationToken) As IAliasSymbol + Dim nameSyntax = TryCast(expression, IdentifierNameSyntax) + If nameSyntax Is Nothing Then + Return Nothing + Else + Return semanticModel.GetAliasInfo(nameSyntax, cancellationToken) + End If + End Function + + + Public Function DetermineAccessibilityConstraint(semanticModel As SemanticModel, + type As TypeSyntax, + cancellationToken As CancellationToken) As Accessibility + If type Is Nothing Then + Return Accessibility.Private + End If + + type = type.GetAncestorsOrThis(Of TypeSyntax)().Last() + + If type.IsParentKind(SyntaxKind.InheritsStatement) Then + Dim containingType = semanticModel.GetEnclosingNamedType(type.SpanStart, cancellationToken) + Return containingType.DeclaredAccessibility + End If + + ' Determine accessibility of field or event + ' Public B as B + If type.IsParentKind(SyntaxKind.SimpleAsClause) AndAlso + type.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then + If type.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration) OrElse + type.Parent.Parent.IsParentKind(SyntaxKind.EventStatement) Then + Dim variableDeclarator = DirectCast(type.Parent.Parent, VariableDeclaratorSyntax) + If variableDeclarator.Names.Count > 0 Then + Dim variableDeclaration = semanticModel.GetDeclaredSymbol(variableDeclarator.Names(0), cancellationToken) + Return variableDeclaration.DeclaredAccessibility + End If + End If + End If + + ' Determine accessibility of field or event + ' Public B as New B() + If type.IsParentKind(SyntaxKind.ObjectCreationExpression) AndAlso + type.Parent.IsParentKind(SyntaxKind.AsNewClause) AndAlso + type.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then + If type.Parent.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration) OrElse + type.Parent.Parent.Parent.IsParentKind(SyntaxKind.EventStatement) Then + Dim variableDeclarator = DirectCast(type.Parent.Parent.Parent, VariableDeclaratorSyntax) + If variableDeclarator.Names.Count > 0 Then + Dim variableDeclaration = semanticModel.GetDeclaredSymbol(variableDeclarator.Names(0), cancellationToken) + Return variableDeclaration.DeclaredAccessibility + End If + End If + End If + + If type.IsParentKind(SyntaxKind.SimpleAsClause) Then + If type.Parent.IsParentKind(SyntaxKind.DelegateFunctionStatement) OrElse + type.Parent.IsParentKind(SyntaxKind.FunctionStatement) OrElse + type.Parent.IsParentKind(SyntaxKind.PropertyStatement) OrElse + type.Parent.IsParentKind(SyntaxKind.EventStatement) OrElse + type.Parent.IsParentKind(SyntaxKind.OperatorStatement) Then + Return semanticModel.GetDeclaredSymbol( + type.Parent.Parent, cancellationToken).DeclaredAccessibility + End If + End If + + If type.IsParentKind(SyntaxKind.SimpleAsClause) AndAlso + type.Parent.IsParentKind(SyntaxKind.Parameter) AndAlso + type.Parent.Parent.IsParentKind(SyntaxKind.ParameterList) Then + If type.Parent.Parent.Parent.IsParentKind(SyntaxKind.DelegateFunctionStatement) OrElse + type.Parent.Parent.Parent.IsParentKind(SyntaxKind.FunctionStatement) OrElse + type.Parent.Parent.Parent.IsParentKind(SyntaxKind.PropertyStatement) OrElse + type.Parent.Parent.Parent.IsParentKind(SyntaxKind.OperatorStatement) OrElse + type.Parent.Parent.Parent.IsParentKind(SyntaxKind.SubNewStatement) OrElse + type.Parent.Parent.Parent.IsParentKind(SyntaxKind.SubStatement) Then + Return semanticModel.GetDeclaredSymbol( + type.Parent.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility + End If + End If + + Return Accessibility.Private + End Function + + + Public Iterator Function GetAliasSymbols(semanticModel As SemanticModel) As IEnumerable(Of IAliasSymbol) + semanticModel = DirectCast(semanticModel.GetOriginalSemanticModel(), SemanticModel) + + Dim root = semanticModel.SyntaxTree.GetCompilationUnitRoot() + For Each importsClause In root.GetAliasImportsClauses() + Dim [alias] = DirectCast(semanticModel.GetDeclaredSymbol(importsClause), IAliasSymbol) + If [alias] IsNot Nothing Then + Yield [alias] + End If + Next + End Function + End Module +End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SimpleNameSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SimpleNameSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SimpleNameSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SimpleNameSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SingleLineRewriter.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SingleLineRewriter.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SingleLineRewriter.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SingleLineRewriter.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/StatementSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/StatementSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/StatementSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/StatementSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/StringExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/StringExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/StringExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/StringExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SymbolDisplayPartExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SymbolDisplayPartExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SymbolDisplayPartExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SymbolDisplayPartExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SymbolExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SymbolExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SymbolExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SymbolExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxKindExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxKindExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxKindExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxKindExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxListExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxListExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxListExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxListExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxNodeExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxNodeExtensions.vb similarity index 87% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxNodeExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxNodeExtensions.vb index b5c489f734060..e72a7fe6a9225 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxNodeExtensions.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxNodeExtensions.vb @@ -1063,5 +1063,115 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return False End Function + + + Public Function GetParameterList(declaration As SyntaxNode) As ParameterListSyntax + Select Case declaration.Kind + Case SyntaxKind.SubBlock, + SyntaxKind.FunctionBlock + Return DirectCast(declaration, MethodBlockSyntax).BlockStatement.ParameterList + Case SyntaxKind.ConstructorBlock + Return DirectCast(declaration, ConstructorBlockSyntax).BlockStatement.ParameterList + Case SyntaxKind.OperatorBlock + Return DirectCast(declaration, OperatorBlockSyntax).BlockStatement.ParameterList + Case SyntaxKind.SubStatement, + SyntaxKind.FunctionStatement + Return DirectCast(declaration, MethodStatementSyntax).ParameterList + Case SyntaxKind.SubNewStatement + Return DirectCast(declaration, SubNewStatementSyntax).ParameterList + Case SyntaxKind.OperatorStatement + Return DirectCast(declaration, OperatorStatementSyntax).ParameterList + Case SyntaxKind.DeclareSubStatement, + SyntaxKind.DeclareFunctionStatement + Return DirectCast(declaration, DeclareStatementSyntax).ParameterList + Case SyntaxKind.DelegateSubStatement, + SyntaxKind.DelegateFunctionStatement + Return DirectCast(declaration, DelegateStatementSyntax).ParameterList + Case SyntaxKind.PropertyBlock + Return DirectCast(declaration, PropertyBlockSyntax).PropertyStatement.ParameterList + Case SyntaxKind.PropertyStatement + Return DirectCast(declaration, PropertyStatementSyntax).ParameterList + Case SyntaxKind.EventBlock + Return DirectCast(declaration, EventBlockSyntax).EventStatement.ParameterList + Case SyntaxKind.EventStatement + Return DirectCast(declaration, EventStatementSyntax).ParameterList + Case SyntaxKind.MultiLineFunctionLambdaExpression, + SyntaxKind.MultiLineSubLambdaExpression + Return DirectCast(declaration, MultiLineLambdaExpressionSyntax).SubOrFunctionHeader.ParameterList + Case SyntaxKind.SingleLineFunctionLambdaExpression, + SyntaxKind.SingleLineSubLambdaExpression + Return DirectCast(declaration, SingleLineLambdaExpressionSyntax).SubOrFunctionHeader.ParameterList + Case Else + Return Nothing + End Select + End Function + + + Public Function GetAttributeLists(node As SyntaxNode) As SyntaxList(Of AttributeListSyntax) + Select Case node.Kind + Case SyntaxKind.CompilationUnit + Return SyntaxFactory.List(DirectCast(node, CompilationUnitSyntax).Attributes.SelectMany(Function(s) s.AttributeLists)) + Case SyntaxKind.ClassBlock + Return DirectCast(node, ClassBlockSyntax).BlockStatement.AttributeLists + Case SyntaxKind.ClassStatement + Return DirectCast(node, ClassStatementSyntax).AttributeLists + Case SyntaxKind.StructureBlock + Return DirectCast(node, StructureBlockSyntax).BlockStatement.AttributeLists + Case SyntaxKind.StructureStatement + Return DirectCast(node, StructureStatementSyntax).AttributeLists + Case SyntaxKind.InterfaceBlock + Return DirectCast(node, InterfaceBlockSyntax).BlockStatement.AttributeLists + Case SyntaxKind.InterfaceStatement + Return DirectCast(node, InterfaceStatementSyntax).AttributeLists + Case SyntaxKind.EnumBlock + Return DirectCast(node, EnumBlockSyntax).EnumStatement.AttributeLists + Case SyntaxKind.EnumStatement + Return DirectCast(node, EnumStatementSyntax).AttributeLists + Case SyntaxKind.EnumMemberDeclaration + Return DirectCast(node, EnumMemberDeclarationSyntax).AttributeLists + Case SyntaxKind.DelegateFunctionStatement, + SyntaxKind.DelegateSubStatement + Return DirectCast(node, DelegateStatementSyntax).AttributeLists + Case SyntaxKind.FieldDeclaration + Return DirectCast(node, FieldDeclarationSyntax).AttributeLists + Case SyntaxKind.FunctionBlock, + SyntaxKind.SubBlock, + SyntaxKind.ConstructorBlock + Return DirectCast(node, MethodBlockBaseSyntax).BlockStatement.AttributeLists + Case SyntaxKind.FunctionStatement, + SyntaxKind.SubStatement + Return DirectCast(node, MethodStatementSyntax).AttributeLists + Case SyntaxKind.SubNewStatement + Return DirectCast(node, SubNewStatementSyntax).AttributeLists + Case SyntaxKind.Parameter + Return DirectCast(node, ParameterSyntax).AttributeLists + Case SyntaxKind.PropertyBlock + Return DirectCast(node, PropertyBlockSyntax).PropertyStatement.AttributeLists + Case SyntaxKind.PropertyStatement + Return DirectCast(node, PropertyStatementSyntax).AttributeLists + Case SyntaxKind.OperatorBlock + Return DirectCast(node, OperatorBlockSyntax).BlockStatement.AttributeLists + Case SyntaxKind.OperatorStatement + Return DirectCast(node, OperatorStatementSyntax).AttributeLists + Case SyntaxKind.EventBlock + Return DirectCast(node, EventBlockSyntax).EventStatement.AttributeLists + Case SyntaxKind.EventStatement + Return DirectCast(node, EventStatementSyntax).AttributeLists + Case SyntaxKind.GetAccessorBlock, + SyntaxKind.SetAccessorBlock, + SyntaxKind.AddHandlerAccessorBlock, + SyntaxKind.RemoveHandlerAccessorBlock, + SyntaxKind.RaiseEventAccessorBlock + Return DirectCast(node, AccessorBlockSyntax).AccessorStatement.AttributeLists + Case SyntaxKind.GetAccessorStatement, + SyntaxKind.SetAccessorStatement, + SyntaxKind.AddHandlerAccessorStatement, + SyntaxKind.RemoveHandlerAccessorStatement, + SyntaxKind.RaiseEventAccessorStatement + Return DirectCast(node, AccessorStatementSyntax).AttributeLists + Case Else + Return Nothing + End Select + End Function End Module End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTokenExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxTokenExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTokenExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxTokenExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTreeExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxTreeExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTreeExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxTreeExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTriviaListExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxTriviaListExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/SyntaxTriviaListExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/SyntaxTriviaListExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/TypeBlockSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/TypeBlockSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/TypeBlockSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/TypeBlockSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/TypeSyntaxGeneratorVisitor.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/TypeSyntaxGeneratorVisitor.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/TypeSyntaxGeneratorVisitor.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/TypeSyntaxGeneratorVisitor.vb diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/VariableDeclaratorSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/VariableDeclaratorSyntaxExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Extensions/VariableDeclaratorSyntaxExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/VariableDeclaratorSyntaxExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/AddImports/VisualBasicAddImportsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicAddImportsService.vb similarity index 97% rename from src/Workspaces/VisualBasic/Portable/AddImports/VisualBasicAddImportsService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicAddImportsService.vb index bbb7da707ed00..6d3e07c9d7626 100644 --- a/src/Workspaces/VisualBasic/Portable/AddImports/VisualBasicAddImportsService.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicAddImportsService.vb @@ -6,6 +6,7 @@ Imports System.Collections.Immutable Imports System.Composition Imports System.Threading Imports Microsoft.CodeAnalysis.AddImports +Imports Microsoft.CodeAnalysis.Editing Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.VisualBasic.CodeGeneration @@ -38,8 +39,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.AddImports End Function - Protected Overrides Function GetGlobalImports(compilation As Compilation) As ImmutableArray(Of SyntaxNode) - Dim generator = VisualBasicSyntaxGenerator.Instance + Protected Overrides Function GetGlobalImports(compilation As Compilation, generator As SyntaxGenerator) As ImmutableArray(Of SyntaxNode) Dim result = ArrayBuilder(Of SyntaxNode).GetInstance() For Each import In compilation.MemberImports() diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicCommandLineParserService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicCommandLineParserService.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicCommandLineParserService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicCommandLineParserService.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicDocumentationCommentService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicDocumentationCommentService.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicDocumentationCommentService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicDocumentationCommentService.vb diff --git a/src/Workspaces/VisualBasic/Portable/GeneratedCodeRecognition/VisualBasicGeneratedCodeRecognitionService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicGeneratedCodeRecognitionService.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/GeneratedCodeRecognition/VisualBasicGeneratedCodeRecognitionService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicGeneratedCodeRecognitionService.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicPrecedenceService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicPrecedenceService.vb similarity index 97% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicPrecedenceService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicPrecedenceService.vb index a893263fdbffc..a11d35f955896 100644 --- a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicPrecedenceService.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicPrecedenceService.vb @@ -5,6 +5,7 @@ Imports System.Composition Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageServices +Imports Microsoft.CodeAnalysis.VisualBasic.Extensions Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSemanticFactsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSemanticFactsService.vb similarity index 99% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSemanticFactsService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSemanticFactsService.vb index 23a07a8e30c36..9b17812814c22 100644 --- a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSemanticFactsService.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSemanticFactsService.vb @@ -10,6 +10,8 @@ Imports Microsoft.CodeAnalysis.Host Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageServices Imports Microsoft.CodeAnalysis.PooledObjects +Imports Microsoft.CodeAnalysis.Shared.Extensions +Imports Microsoft.CodeAnalysis.VisualBasic.Extensions Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery Imports Microsoft.CodeAnalysis.VisualBasic.Syntax diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSymbolDeclarationService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSymbolDeclarationService.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSymbolDeclarationService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSymbolDeclarationService.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxFactsService.vb similarity index 99% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxFactsService.vb index 50b2fc56fb59e..2d4f0a58283a5 100644 --- a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxFactsService.vb @@ -223,7 +223,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Function Public Function GetParameterList(node As SyntaxNode) As SyntaxNode Implements ISyntaxFactsService.GetParameterList - Return VisualBasicSyntaxGenerator.GetParameterList(node) + Return node.GetParameterList() End Function Public Function IsSkippedTokensTrivia(node As SyntaxNode) As Boolean Implements ISyntaxFactsService.IsSkippedTokensTrivia @@ -2073,7 +2073,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Function Public Overrides Function GetAttributeLists(node As SyntaxNode) As SyntaxList(Of SyntaxNode) Implements ISyntaxFactsService.GetAttributeLists - Return VisualBasicSyntaxGenerator.GetAttributeLists(node) + Return node.GetAttributeLists() End Function Private Function ISyntaxFactsService_IsExpressionStatement(node As SyntaxNode) As Boolean Implements ISyntaxFactsService.IsExpressionStatement diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsServiceFactory.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxFactsServiceFactory.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsServiceFactory.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxFactsServiceFactory.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxKindsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxKindsService.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxKindsService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxKindsService.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxKindsServiceFactory.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxKindsServiceFactory.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxKindsServiceFactory.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxKindsServiceFactory.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicTypeInferenceService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicTypeInferenceService.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicTypeInferenceService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicTypeInferenceService.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/DirectiveSyntaxEqualityComparer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/DirectiveSyntaxEqualityComparer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/DirectiveSyntaxEqualityComparer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/DirectiveSyntaxEqualityComparer.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/DirectiveWalker.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/DirectiveWalker.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/DirectiveWalker.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/DirectiveWalker.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/ImportsClauseComparer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/ImportsClauseComparer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/ImportsClauseComparer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/ImportsClauseComparer.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/ImportsOrganizer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/ImportsOrganizer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/ImportsOrganizer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/ImportsOrganizer.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/ImportsStatementComparer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/ImportsStatementComparer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/ImportsStatementComparer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/ImportsStatementComparer.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/ModifierCollectionFacts.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/ModifierCollectionFacts.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/ModifierCollectionFacts.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/ModifierCollectionFacts.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/NameSyntaxComparer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/NameSyntaxComparer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/NameSyntaxComparer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/NameSyntaxComparer.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/NameSyntaxIterator.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/NameSyntaxIterator.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/NameSyntaxIterator.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/NameSyntaxIterator.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/PossibleDeclarationTypes.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/PossibleDeclarationTypes.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/PossibleDeclarationTypes.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/PossibleDeclarationTypes.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/SpeculationAnalyzer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SpeculationAnalyzer.vb similarity index 99% rename from src/Workspaces/VisualBasic/Portable/Utilities/SpeculationAnalyzer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SpeculationAnalyzer.vb index 7ff28d50cd702..51f6810f1b189 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/SpeculationAnalyzer.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SpeculationAnalyzer.vb @@ -2,15 +2,13 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Generic Imports System.Collections.Immutable -Imports System.Diagnostics -Imports System.Linq Imports System.Threading Imports Microsoft.CodeAnalysis.VisualBasic.Extensions -Imports Microsoft.CodeAnalysis.VisualBasic.Symbols Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.CodeAnalysis.Shared.Extensions +Imports Microsoft.CodeAnalysis.Shared.Utilities +Imports Roslyn.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities ''' diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/SymbolExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SymbolExtensions.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/SymbolExtensions.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SymbolExtensions.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/SyntaxKindSet.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SyntaxKindSet.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/SyntaxKindSet.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SyntaxKindSet.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/TokenComparer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/TokenComparer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/TokenComparer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/TokenComparer.vb diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/TypeSyntaxComparer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/TypeSyntaxComparer.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/Utilities/TypeSyntaxComparer.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/TypeSyntaxComparer.vb diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/VisualBasicSimplificationHelpers.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/VisualBasicSimplificationHelpers.vb new file mode 100644 index 0000000000000..c04b54fe79b55 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/VisualBasicSimplificationHelpers.vb @@ -0,0 +1,33 @@ +' 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. + +Imports Microsoft.CodeAnalysis.Simplification +Imports Microsoft.CodeAnalysis.VisualBasic.Syntax + +Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification + Friend Module VisualBasicSimplificationHelpers + Public Function TryEscapeIdentifierToken(identifierToken As SyntaxToken) As SyntaxToken + If identifierToken.Kind <> SyntaxKind.IdentifierToken OrElse identifierToken.ValueText.Length = 0 Then + Return identifierToken + End If + + If identifierToken.IsBracketed Then + Return identifierToken + End If + + If identifierToken.GetTypeCharacter() <> TypeCharacter.None Then + Return identifierToken + End If + + Dim unescapedIdentifier = identifierToken.ValueText + If SyntaxFacts.GetKeywordKind(unescapedIdentifier) = SyntaxKind.None AndAlso SyntaxFacts.GetContextualKeywordKind(unescapedIdentifier) = SyntaxKind.None Then + Return identifierToken + End If + + Return identifierToken.CopyAnnotationsTo( + SyntaxFactory.BracketedIdentifier(identifierToken.LeadingTrivia, identifierToken.ValueText, identifierToken.TrailingTrivia) _ + .WithAdditionalAnnotations(Simplifier.Annotation)) + End Function + End Module +End Namespace diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems new file mode 100644 index 0000000000000..0829be27fce94 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems @@ -0,0 +1,89 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + ec946164-1e17-410b-b7d9-7de7e6268d63 + + + Microsoft.CodeAnalysis.VisualBasic.Shared + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.shproj b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.shproj new file mode 100644 index 0000000000000..a3b455f2da419 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.shproj @@ -0,0 +1,13 @@ + + + + {E9DBFA41-7A9C-49BE-BD36-FD71B31AA9FE} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb b/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb index 954e7ba9e9be1..863a8e0a08f73 100644 --- a/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb +++ b/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb @@ -1656,7 +1656,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration End Function Public Overrides Function GetAttributes(declaration As SyntaxNode) As IReadOnlyList(Of SyntaxNode) - Return Me.Flatten(GetAttributeLists(declaration)) + Return Me.Flatten(declaration.GetAttributeLists()) End Function Public Overrides Function InsertAttributes(declaration As SyntaxNode, index As Integer, attributes As IEnumerable(Of SyntaxNode)) As SyntaxNode @@ -1765,73 +1765,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration End Select End Function - Friend Shared Function GetAttributeLists(node As SyntaxNode) As SyntaxList(Of AttributeListSyntax) - Select Case node.Kind - Case SyntaxKind.CompilationUnit - Return SyntaxFactory.List(DirectCast(node, CompilationUnitSyntax).Attributes.SelectMany(Function(s) s.AttributeLists)) - Case SyntaxKind.ClassBlock - Return DirectCast(node, ClassBlockSyntax).BlockStatement.AttributeLists - Case SyntaxKind.ClassStatement - Return DirectCast(node, ClassStatementSyntax).AttributeLists - Case SyntaxKind.StructureBlock - Return DirectCast(node, StructureBlockSyntax).BlockStatement.AttributeLists - Case SyntaxKind.StructureStatement - Return DirectCast(node, StructureStatementSyntax).AttributeLists - Case SyntaxKind.InterfaceBlock - Return DirectCast(node, InterfaceBlockSyntax).BlockStatement.AttributeLists - Case SyntaxKind.InterfaceStatement - Return DirectCast(node, InterfaceStatementSyntax).AttributeLists - Case SyntaxKind.EnumBlock - Return DirectCast(node, EnumBlockSyntax).EnumStatement.AttributeLists - Case SyntaxKind.EnumStatement - Return DirectCast(node, EnumStatementSyntax).AttributeLists - Case SyntaxKind.EnumMemberDeclaration - Return DirectCast(node, EnumMemberDeclarationSyntax).AttributeLists - Case SyntaxKind.DelegateFunctionStatement, - SyntaxKind.DelegateSubStatement - Return DirectCast(node, DelegateStatementSyntax).AttributeLists - Case SyntaxKind.FieldDeclaration - Return DirectCast(node, FieldDeclarationSyntax).AttributeLists - Case SyntaxKind.FunctionBlock, - SyntaxKind.SubBlock, - SyntaxKind.ConstructorBlock - Return DirectCast(node, MethodBlockBaseSyntax).BlockStatement.AttributeLists - Case SyntaxKind.FunctionStatement, - SyntaxKind.SubStatement - Return DirectCast(node, MethodStatementSyntax).AttributeLists - Case SyntaxKind.SubNewStatement - Return DirectCast(node, SubNewStatementSyntax).AttributeLists - Case SyntaxKind.Parameter - Return DirectCast(node, ParameterSyntax).AttributeLists - Case SyntaxKind.PropertyBlock - Return DirectCast(node, PropertyBlockSyntax).PropertyStatement.AttributeLists - Case SyntaxKind.PropertyStatement - Return DirectCast(node, PropertyStatementSyntax).AttributeLists - Case SyntaxKind.OperatorBlock - Return DirectCast(node, OperatorBlockSyntax).BlockStatement.AttributeLists - Case SyntaxKind.OperatorStatement - Return DirectCast(node, OperatorStatementSyntax).AttributeLists - Case SyntaxKind.EventBlock - Return DirectCast(node, EventBlockSyntax).EventStatement.AttributeLists - Case SyntaxKind.EventStatement - Return DirectCast(node, EventStatementSyntax).AttributeLists - Case SyntaxKind.GetAccessorBlock, - SyntaxKind.SetAccessorBlock, - SyntaxKind.AddHandlerAccessorBlock, - SyntaxKind.RemoveHandlerAccessorBlock, - SyntaxKind.RaiseEventAccessorBlock - Return DirectCast(node, AccessorBlockSyntax).AccessorStatement.AttributeLists - Case SyntaxKind.GetAccessorStatement, - SyntaxKind.SetAccessorStatement, - SyntaxKind.AddHandlerAccessorStatement, - SyntaxKind.RemoveHandlerAccessorStatement, - SyntaxKind.RaiseEventAccessorStatement - Return DirectCast(node, AccessorStatementSyntax).AttributeLists - Case Else - Return Nothing - End Select - End Function - Private Function WithAttributeLists(node As SyntaxNode, lists As IEnumerable(Of AttributeListSyntax)) As SyntaxNode Dim arg = SyntaxFactory.List(lists) @@ -3117,14 +3050,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration End Function Public Overrides Function GetParameters(declaration As SyntaxNode) As IReadOnlyList(Of SyntaxNode) - Dim list = GetParameterList(declaration) + Dim list = declaration.GetParameterList() Return If(list IsNot Nothing, list.Parameters, SpecializedCollections.EmptyReadOnlyList(Of SyntaxNode)) End Function Public Overrides Function InsertParameters(declaration As SyntaxNode, index As Integer, parameters As IEnumerable(Of SyntaxNode)) As SyntaxNode - Dim currentList = GetParameterList(declaration) + Dim currentList = declaration.GetParameterList() Dim newList = GetParameterList(parameters) If currentList IsNot Nothing Then Return WithParameterList(declaration, currentList.WithParameters(currentList.Parameters.InsertRange(index, newList.Parameters))) @@ -3153,48 +3086,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration End Function Friend Overrides Function GetParameterListNode(declaration As SyntaxNode) As SyntaxNode - Return GetParameterList(declaration) - End Function - - Friend Shared Function GetParameterList(declaration As SyntaxNode) As ParameterListSyntax - Select Case declaration.Kind - Case SyntaxKind.SubBlock, - SyntaxKind.FunctionBlock - Return DirectCast(declaration, MethodBlockSyntax).BlockStatement.ParameterList - Case SyntaxKind.ConstructorBlock - Return DirectCast(declaration, ConstructorBlockSyntax).BlockStatement.ParameterList - Case SyntaxKind.OperatorBlock - Return DirectCast(declaration, OperatorBlockSyntax).BlockStatement.ParameterList - Case SyntaxKind.SubStatement, - SyntaxKind.FunctionStatement - Return DirectCast(declaration, MethodStatementSyntax).ParameterList - Case SyntaxKind.SubNewStatement - Return DirectCast(declaration, SubNewStatementSyntax).ParameterList - Case SyntaxKind.OperatorStatement - Return DirectCast(declaration, OperatorStatementSyntax).ParameterList - Case SyntaxKind.DeclareSubStatement, - SyntaxKind.DeclareFunctionStatement - Return DirectCast(declaration, DeclareStatementSyntax).ParameterList - Case SyntaxKind.DelegateSubStatement, - SyntaxKind.DelegateFunctionStatement - Return DirectCast(declaration, DelegateStatementSyntax).ParameterList - Case SyntaxKind.PropertyBlock - Return DirectCast(declaration, PropertyBlockSyntax).PropertyStatement.ParameterList - Case SyntaxKind.PropertyStatement - Return DirectCast(declaration, PropertyStatementSyntax).ParameterList - Case SyntaxKind.EventBlock - Return DirectCast(declaration, EventBlockSyntax).EventStatement.ParameterList - Case SyntaxKind.EventStatement - Return DirectCast(declaration, EventStatementSyntax).ParameterList - Case SyntaxKind.MultiLineFunctionLambdaExpression, - SyntaxKind.MultiLineSubLambdaExpression - Return DirectCast(declaration, MultiLineLambdaExpressionSyntax).SubOrFunctionHeader.ParameterList - Case SyntaxKind.SingleLineFunctionLambdaExpression, - SyntaxKind.SingleLineSubLambdaExpression - Return DirectCast(declaration, SingleLineLambdaExpressionSyntax).SubOrFunctionHeader.ParameterList - Case Else - Return Nothing - End Select + Return declaration.GetParameterList() End Function Private Function WithParameterList(declaration As SyntaxNode, list As ParameterListSyntax) As SyntaxNode diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/SemanticModelExtensions.vb b/src/Workspaces/VisualBasic/Portable/Extensions/SemanticModelExtensions.vb index c19d1e80a4721..12bbea4853e0a 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/SemanticModelExtensions.vb +++ b/src/Workspaces/VisualBasic/Portable/Extensions/SemanticModelExtensions.vb @@ -12,166 +12,7 @@ Imports Microsoft.CodeAnalysis.Utilities Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions - Friend Module SemanticModelExtensions - - Private Const s_defaultParameterName = "p" - Private Const s_defaultBuiltInParameterName = "v" - - - Public Function LookupTypeRegardlessOfArity(semanticModel As SemanticModel, - name As SyntaxToken, - cancellationToken As CancellationToken) As IList(Of ITypeSymbol) - Dim expression = TryCast(name.Parent, ExpressionSyntax) - If expression IsNot Nothing Then - Dim results = semanticModel.LookupName(expression, namespacesAndTypesOnly:=True, cancellationToken:=cancellationToken) - If results.Count > 0 Then - Return results.OfType(Of ITypeSymbol)().ToList() - End If - End If - Return SpecializedCollections.EmptyList(Of ITypeSymbol)() - End Function - - - Public Function LookupName(semanticModel As SemanticModel, name As SyntaxToken, - namespacesAndTypesOnly As Boolean, - cancellationToken As CancellationToken) As IList(Of ISymbol) - Dim expression = TryCast(name.Parent, ExpressionSyntax) - If expression IsNot Nothing Then - Return semanticModel.LookupName(expression, namespacesAndTypesOnly, cancellationToken) - End If - Return SpecializedCollections.EmptyList(Of ISymbol)() - End Function - - - Public Function LookupName(semanticModel As SemanticModel, - expression As ExpressionSyntax, - namespacesAndTypesOnly As Boolean, - cancellationToken As CancellationToken) As IList(Of ISymbol) - Dim expr = SyntaxFactory.GetStandaloneExpression(expression) - - Dim qualifier As ExpressionSyntax = Nothing - Dim name As String = Nothing - Dim arity As Integer = Nothing - expr.DecomposeName(qualifier, name, arity) - - Dim symbol As INamespaceOrTypeSymbol = Nothing - If qualifier IsNot Nothing AndAlso TypeOf qualifier Is TypeSyntax Then - Dim typeInfo = semanticModel.GetTypeInfo(qualifier, cancellationToken) - Dim symbolInfo = semanticModel.GetSymbolInfo(qualifier, cancellationToken) - - If typeInfo.Type IsNot Nothing Then - symbol = typeInfo.Type - ElseIf symbolInfo.Symbol IsNot Nothing Then - symbol = TryCast(symbolInfo.Symbol, INamespaceOrTypeSymbol) - End If - End If - - Return If( - namespacesAndTypesOnly, - semanticModel.LookupNamespacesAndTypes(expr.SpanStart, container:=symbol, name:=name), - semanticModel.LookupSymbols(expr.SpanStart, container:=symbol, name:=name)) - End Function - - - Public Function GetSymbolInfo(semanticModel As SemanticModel, token As SyntaxToken) As SymbolInfo - Dim expression = TryCast(token.Parent, ExpressionSyntax) - If expression Is Nothing Then - Return Nothing - End If - - Return semanticModel.GetSymbolInfo(expression) - End Function - - - Public Function GenerateNameForArgument(semanticModel As SemanticModel, - argument As ArgumentSyntax, - cancellationToken As CancellationToken) As String - Dim result = GenerateNameForArgumentWorker(semanticModel, argument, cancellationToken) - Return If(String.IsNullOrWhiteSpace(result), s_defaultParameterName, result) - End Function - - Private Function GenerateNameForArgumentWorker(semanticModel As SemanticModel, - argument As ArgumentSyntax, - cancellationToken As CancellationToken) As String - If argument.IsNamed Then - Return DirectCast(argument, SimpleArgumentSyntax).NameColonEquals.Name.Identifier.ValueText - ElseIf Not argument.IsOmitted Then - Return semanticModel.GenerateNameForExpression( - argument.GetExpression(), capitalize:=False, cancellationToken:=cancellationToken) - Else - Return s_defaultParameterName - End If - End Function - - ''' - ''' Given an expression node, tries to generate an appropriate name that can be used for - ''' that expression. - ''' - - Public Function GenerateNameForExpression(semanticModel As SemanticModel, - expression As ExpressionSyntax, - capitalize As Boolean, - cancellationToken As CancellationToken) As String - ' Try to find a usable name node that we can use to name the - ' parameter. If we have an expression that has a name as part of it - ' then we try to use that part. - Dim current = expression - - While True - current = current.WalkDownParentheses() - If current.Kind = SyntaxKind.IdentifierName Then - Return (DirectCast(current, IdentifierNameSyntax)).Identifier.ValueText.ToCamelCase() - ElseIf TypeOf current Is MemberAccessExpressionSyntax Then - Return (DirectCast(current, MemberAccessExpressionSyntax)).Name.Identifier.ValueText.ToCamelCase() - ElseIf TypeOf current Is CastExpressionSyntax Then - current = (DirectCast(current, CastExpressionSyntax)).Expression - Else - Exit While - End If - End While - - ' there was nothing in the expression to signify a name. If we're in an argument - ' location, then try to choose a name based on the argument name. - Dim argumentName = TryGenerateNameForArgumentExpression( - semanticModel, expression, cancellationToken) - If argumentName IsNot Nothing Then - Return If(capitalize, argumentName.ToPascalCase(), argumentName.ToCamelCase()) - End If - - ' Otherwise, figure out the type of the expression and generate a name from that - ' instead. - Dim info = semanticModel.GetTypeInfo(expression, cancellationToken) - - ' If we can't determine the type, then fallback to some placeholders. - Dim [type] = info.Type - Return [type].CreateParameterName(capitalize) - End Function - - Private Function TryGenerateNameForArgumentExpression(semanticModel As SemanticModel, expression As ExpressionSyntax, cancellationToken As CancellationToken) As String - Dim topExpression = expression.WalkUpParentheses() - If TypeOf topExpression.Parent Is ArgumentSyntax Then - Dim argument = DirectCast(topExpression.Parent, ArgumentSyntax) - Dim simpleArgument = TryCast(argument, SimpleArgumentSyntax) - - If simpleArgument?.NameColonEquals IsNot Nothing Then - Return simpleArgument.NameColonEquals.Name.Identifier.ValueText - End If - - Dim argumentList = TryCast(argument.Parent, ArgumentListSyntax) - If argumentList IsNot Nothing Then - Dim index = argumentList.Arguments.IndexOf(argument) - Dim member = TryCast(semanticModel.GetSymbolInfo(argumentList.Parent, cancellationToken).Symbol, IMethodSymbol) - If member IsNot Nothing AndAlso index < member.Parameters.Length Then - Dim parameter = member.Parameters(index) - If parameter.Type.TypeKind <> TypeKind.TypeParameter Then - Return parameter.Name - End If - End If - End If - End If - - Return Nothing - End Function + Partial Friend Module SemanticModelExtensions Public Function GenerateParameterNames(semanticModel As SemanticModel, @@ -255,114 +96,5 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Select(Function(name, index) New ParameterName(name, isFixed(index), parameterNamingRule)). ToImmutableArray() End Function - - - Public Function GetImportNamespacesInScope(semanticModel As SemanticModel, location As SyntaxNode) As ISet(Of INamespaceSymbol) - Dim q = - From u In location.GetAncestorOrThis(Of CompilationUnitSyntax).Imports - From importClause In u.ImportsClauses.OfType(Of SimpleImportsClauseSyntax)() - Where importClause.Alias Is Nothing - Let info = semanticModel.GetSymbolInfo(importClause.Name) - Let ns = TryCast(info.Symbol, INamespaceSymbol) - Where ns IsNot Nothing - Select ns - - Return q.ToSet() - End Function - - - Public Function GetAliasInfo(semanticModel As SemanticModel, expression As ExpressionSyntax, cancellationToken As CancellationToken) As IAliasSymbol - Dim nameSyntax = TryCast(expression, IdentifierNameSyntax) - If nameSyntax Is Nothing Then - Return Nothing - Else - Return semanticModel.GetAliasInfo(nameSyntax, cancellationToken) - End If - End Function - - - Public Function DetermineAccessibilityConstraint(semanticModel As SemanticModel, - type As TypeSyntax, - cancellationToken As CancellationToken) As Accessibility - If type Is Nothing Then - Return Accessibility.Private - End If - - type = type.GetAncestorsOrThis(Of TypeSyntax)().Last() - - If type.IsParentKind(SyntaxKind.InheritsStatement) Then - Dim containingType = semanticModel.GetEnclosingNamedType(type.SpanStart, cancellationToken) - Return containingType.DeclaredAccessibility - End If - - ' Determine accessibility of field or event - ' Public B as B - If type.IsParentKind(SyntaxKind.SimpleAsClause) AndAlso - type.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then - If type.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration) OrElse - type.Parent.Parent.IsParentKind(SyntaxKind.EventStatement) Then - Dim variableDeclarator = DirectCast(type.Parent.Parent, VariableDeclaratorSyntax) - If variableDeclarator.Names.Count > 0 Then - Dim variableDeclaration = semanticModel.GetDeclaredSymbol(variableDeclarator.Names(0), cancellationToken) - Return variableDeclaration.DeclaredAccessibility - End If - End If - End If - - ' Determine accessibility of field or event - ' Public B as New B() - If type.IsParentKind(SyntaxKind.ObjectCreationExpression) AndAlso - type.Parent.IsParentKind(SyntaxKind.AsNewClause) AndAlso - type.Parent.Parent.IsParentKind(SyntaxKind.VariableDeclarator) Then - If type.Parent.Parent.Parent.IsParentKind(SyntaxKind.FieldDeclaration) OrElse - type.Parent.Parent.Parent.IsParentKind(SyntaxKind.EventStatement) Then - Dim variableDeclarator = DirectCast(type.Parent.Parent.Parent, VariableDeclaratorSyntax) - If variableDeclarator.Names.Count > 0 Then - Dim variableDeclaration = semanticModel.GetDeclaredSymbol(variableDeclarator.Names(0), cancellationToken) - Return variableDeclaration.DeclaredAccessibility - End If - End If - End If - - If type.IsParentKind(SyntaxKind.SimpleAsClause) Then - If type.Parent.IsParentKind(SyntaxKind.DelegateFunctionStatement) OrElse - type.Parent.IsParentKind(SyntaxKind.FunctionStatement) OrElse - type.Parent.IsParentKind(SyntaxKind.PropertyStatement) OrElse - type.Parent.IsParentKind(SyntaxKind.EventStatement) OrElse - type.Parent.IsParentKind(SyntaxKind.OperatorStatement) Then - Return semanticModel.GetDeclaredSymbol( - type.Parent.Parent, cancellationToken).DeclaredAccessibility - End If - End If - - If type.IsParentKind(SyntaxKind.SimpleAsClause) AndAlso - type.Parent.IsParentKind(SyntaxKind.Parameter) AndAlso - type.Parent.Parent.IsParentKind(SyntaxKind.ParameterList) Then - If type.Parent.Parent.Parent.IsParentKind(SyntaxKind.DelegateFunctionStatement) OrElse - type.Parent.Parent.Parent.IsParentKind(SyntaxKind.FunctionStatement) OrElse - type.Parent.Parent.Parent.IsParentKind(SyntaxKind.PropertyStatement) OrElse - type.Parent.Parent.Parent.IsParentKind(SyntaxKind.OperatorStatement) OrElse - type.Parent.Parent.Parent.IsParentKind(SyntaxKind.SubNewStatement) OrElse - type.Parent.Parent.Parent.IsParentKind(SyntaxKind.SubStatement) Then - Return semanticModel.GetDeclaredSymbol( - type.Parent.Parent.Parent.Parent, cancellationToken).DeclaredAccessibility - End If - End If - - Return Accessibility.Private - End Function - - - Public Iterator Function GetAliasSymbols(semanticModel As SemanticModel) As IEnumerable(Of IAliasSymbol) - semanticModel = DirectCast(semanticModel.GetOriginalSemanticModel(), SemanticModel) - - Dim root = semanticModel.SyntaxTree.GetCompilationUnitRoot() - For Each importsClause In root.GetAliasImportsClauses() - Dim [alias] = DirectCast(semanticModel.GetDeclaredSymbol(importsClause), IAliasSymbol) - If [alias] IsNot Nothing Then - Yield [alias] - End If - Next - End Function End Module End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb b/src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb index 2b98425f79e01..de4b5f0b42cf6 100644 --- a/src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb +++ b/src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb @@ -3,7 +3,6 @@ ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules Imports Microsoft.CodeAnalysis.VisualBasic.Syntax diff --git a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.TriviaRewriter.vb b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.TriviaRewriter.vb index faea0c9f74bdd..1f42b5f043e5e 100644 --- a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.TriviaRewriter.vb +++ b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.TriviaRewriter.vb @@ -2,21 +2,11 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System -Imports System.Collections.Generic -Imports System.Linq -Imports System.Text Imports System.Threading -Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Shared.Collections -Imports Microsoft.CodeAnalysis.Shared.Extensions -Imports Microsoft.CodeAnalysis.Shared.Utilities Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic -Imports Microsoft.CodeAnalysis.VisualBasic.Extensions -Imports Microsoft.CodeAnalysis.VisualBasic.Symbols -Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting Friend Class TriviaDataFactory diff --git a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/VisualBasicTriviaFormatter.vb b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/VisualBasicTriviaFormatter.vb index 97d154acf2b9f..d23777119fe8f 100644 --- a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/VisualBasicTriviaFormatter.vb +++ b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/VisualBasicTriviaFormatter.vb @@ -2,18 +2,12 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System -Imports System.Collections.Generic -Imports System.Diagnostics Imports System.Threading Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic -Imports Microsoft.CodeAnalysis.VisualBasic.Extensions -Imports Microsoft.CodeAnalysis.VisualBasic.Symbols Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -Imports Microsoft.VisualBasic Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting Partial Friend Class VisualBasicTriviaFormatter diff --git a/src/Workspaces/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj b/src/Workspaces/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj index 6fe551d802688..fc7287b21bfb8 100644 --- a/src/Workspaces/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj +++ b/src/Workspaces/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj @@ -47,14 +47,6 @@ VBWorkspaceResources.resx - - - - - - - - Microsoft.CodeAnalysis.VisualBasic.VBWorkspaceResources @@ -63,10 +55,13 @@ + + + \ No newline at end of file diff --git a/src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb b/src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb index 4c58fc5355ef6..67d2f79720ff4 100644 --- a/src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb +++ b/src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb @@ -14,6 +14,7 @@ Imports Microsoft.CodeAnalysis.Rename Imports Microsoft.CodeAnalysis.Rename.ConflictEngine Imports Microsoft.CodeAnalysis.Simplification Imports Microsoft.CodeAnalysis.Text +Imports Microsoft.CodeAnalysis.VisualBasic.Simplification Imports Microsoft.CodeAnalysis.VisualBasic.Symbols Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.CodeAnalysis.VisualBasic.Utilities @@ -565,8 +566,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename ' or the replacement itself is escaped. newToken = newToken.WithAdditionalAnnotations(Simplifier.Annotation) Else - Dim semanticModel = GetSemanticModelForNode(parent, If(Me._speculativeModel, Me._semanticModel)) - newToken = Simplification.VisualBasicSimplificationService.TryEscapeIdentifierToken(newToken, semanticModel, oldToken) + newToken = TryEscapeIdentifierToken(newToken) End If End If diff --git a/src/Workspaces/VisualBasic/Portable/Simplification/Simplifiers/ExpressionSimplifier.vb b/src/Workspaces/VisualBasic/Portable/Simplification/Simplifiers/ExpressionSimplifier.vb index aa743a61f334d..2df42e37eed7c 100644 --- a/src/Workspaces/VisualBasic/Portable/Simplification/Simplifiers/ExpressionSimplifier.vb +++ b/src/Workspaces/VisualBasic/Portable/Simplification/Simplifiers/ExpressionSimplifier.vb @@ -107,9 +107,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification.Simplifiers aliasReplacement.Name, memberAccess.GetTrailingTrivia()) - identifierToken = VisualBasicSimplificationService.TryEscapeIdentifierToken( - identifierToken, - semanticModel) + identifierToken = TryEscapeIdentifierToken(identifierToken) replacementNode = SyntaxFactory.IdentifierName(identifierToken) issueSpan = memberAccess.Span @@ -150,7 +148,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification.Simplifiers End If End If - replacementNode = memberAccess.GetNameWithTriviaMoved(semanticModel) + replacementNode = memberAccess.GetNameWithTriviaMoved() issueSpan = memberAccess.Expression.Span If CanReplaceWithReducedName(memberAccess, replacementNode, semanticModel, symbol, cancellationToken) Then diff --git a/src/Workspaces/VisualBasic/Portable/Simplification/Simplifiers/NameSimplifier.vb b/src/Workspaces/VisualBasic/Portable/Simplification/Simplifiers/NameSimplifier.vb index d4ca3b008b497..7ca9c6fdbc046 100644 --- a/src/Workspaces/VisualBasic/Portable/Simplification/Simplifiers/NameSimplifier.vb +++ b/src/Workspaces/VisualBasic/Portable/Simplification/Simplifiers/NameSimplifier.vb @@ -77,9 +77,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification.Simplifiers aliasReplacement.Name, name.GetTrailingTrivia()) - identifierToken = VisualBasicSimplificationService.TryEscapeIdentifierToken( - identifierToken, - semanticModel) + identifierToken = TryEscapeIdentifierToken(identifierToken) replacementNode = SyntaxFactory.IdentifierName(identifierToken) @@ -226,9 +224,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification.Simplifiers replacementNode = qualifiedName.Right.WithLeadingTrivia(name.GetLeadingTrivia()) replacementNode = DirectCast(replacementNode, SimpleNameSyntax) _ - .WithIdentifier(VisualBasicSimplificationService.TryEscapeIdentifierToken( - DirectCast(replacementNode, SimpleNameSyntax).Identifier, - semanticModel)) + .WithIdentifier(TryEscapeIdentifierToken(DirectCast(replacementNode, SimpleNameSyntax).Identifier)) issueSpan = qualifiedName.Left.Span @@ -385,7 +381,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification.Simplifiers identifierToken.LeadingTrivia, newIdentifierText, identifierToken.TrailingTrivia)) - newIdentifierToken = VisualBasicSimplificationService.TryEscapeIdentifierToken(newIdentifierToken, semanticModel) + newIdentifierToken = TryEscapeIdentifierToken(newIdentifierToken) replacementNode = SyntaxFactory.IdentifierName(newIdentifierToken).WithLeadingTrivia(name.GetLeadingTrivia()) Return True End If diff --git a/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.Expander.vb b/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.Expander.vb index a2dbb080bd37b..eb37ddd342dc3 100644 --- a/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.Expander.vb +++ b/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.Expander.vb @@ -303,7 +303,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification Dim inferredName = node.Expression.TryGetInferredMemberName() If CanMakeNameExplicitInTuple(tuple, inferredName) Then Dim identifier = SyntaxFactory.Identifier(inferredName) - identifier = TryEscapeIdentifierToken(identifier, _semanticModel) + identifier = TryEscapeIdentifierToken(identifier) newSimpleArgument = newSimpleArgument. WithLeadingTrivia(). @@ -378,7 +378,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification Dim inferredName = node.Expression.TryGetInferredMemberName() If inferredName IsNot Nothing Then Dim identifier = SyntaxFactory.Identifier(inferredName) - identifier = TryEscapeIdentifierToken(identifier, _semanticModel) + identifier = TryEscapeIdentifierToken(identifier) Return SyntaxFactory.NamedFieldInitializer(SyntaxFactory.IdentifierName(identifier), newInitializer.Expression.WithoutLeadingTrivia()). WithLeadingTrivia(node.GetLeadingTrivia()). @@ -425,7 +425,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification ' .. Dim moduleIdentifierToken = SyntaxFactory.Identifier(symbolForQualifiedName.ContainingType.Name) - moduleIdentifierToken = TryEscapeIdentifierToken(moduleIdentifierToken, _semanticModel) + moduleIdentifierToken = TryEscapeIdentifierToken(moduleIdentifierToken) Dim qualifiedNameWithModuleName = rewrittenQualifiedName.CopyAnnotationsTo(SyntaxFactory.QualifiedName( SyntaxFactory.QualifiedName(DirectCast(rewrittenQualifiedName, QualifiedNameSyntax).Left, SyntaxFactory.IdentifierName(moduleIdentifierToken)) _ @@ -455,7 +455,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification ' .. Dim moduleIdentifierToken = SyntaxFactory.Identifier(symbolForMemberAccess.ContainingType.Name) - moduleIdentifierToken = TryEscapeIdentifierToken(moduleIdentifierToken, _semanticModel) + moduleIdentifierToken = TryEscapeIdentifierToken(moduleIdentifierToken) Dim memberAccessWithModuleName = rewrittenMemberAccess.CopyAnnotationsTo( SyntaxFactory.SimpleMemberAccessExpression( @@ -596,7 +596,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification ' ' 3. Always try to escape keyword identifiers ' - identifier = TryEscapeIdentifierToken(identifier, Me._semanticModel) + identifier = TryEscapeIdentifierToken(identifier) If identifier <> rewrittenSimpleName.Identifier Then Select Case newNode.Kind Case SyntaxKind.IdentifierName, @@ -814,7 +814,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification Dim newLabelStatement = DirectCast(MyBase.VisitLabelStatement(node), LabelStatementSyntax) - Dim escapedLabelToken = TryEscapeIdentifierToken(newLabelStatement.LabelToken, Me._semanticModel) + Dim escapedLabelToken = TryEscapeIdentifierToken(newLabelStatement.LabelToken) If newLabelStatement.LabelToken <> escapedLabelToken Then newLabelStatement = newLabelStatement.WithLabelToken(escapedLabelToken) End If diff --git a/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.vb b/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.vb index 6d9b16374acd5..0479df592a8d4 100644 --- a/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.vb +++ b/src/Workspaces/VisualBasic/Portable/Simplification/VisualBasicSimplificationService.vb @@ -57,33 +57,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification Public Overrides Function Expand(token As SyntaxToken, semanticModel As SemanticModel, expandInsideNode As Func(Of SyntaxNode, Boolean), cancellationToken As CancellationToken) As SyntaxToken Using Logger.LogBlock(FunctionId.Simplifier_ExpandToken, cancellationToken) Dim rewriter = New Expander(semanticModel, expandInsideNode, cancellationToken) - Return TryEscapeIdentifierToken(rewriter.VisitToken(token), semanticModel) + Return TryEscapeIdentifierToken(rewriter.VisitToken(token)) End Using End Function - Public Shared Function TryEscapeIdentifierToken(identifierToken As SyntaxToken, semanticModel As SemanticModel, Optional oldIdentifierToken As SyntaxToken? = Nothing) As SyntaxToken - If identifierToken.Kind <> SyntaxKind.IdentifierToken OrElse identifierToken.ValueText.Length = 0 Then - Return identifierToken - End If - - If identifierToken.IsBracketed Then - Return identifierToken - End If - - If identifierToken.GetTypeCharacter() <> TypeCharacter.None Then - Return identifierToken - End If - - Dim unescapedIdentifier = identifierToken.ValueText - If SyntaxFacts.GetKeywordKind(unescapedIdentifier) = SyntaxKind.None AndAlso SyntaxFacts.GetContextualKeywordKind(unescapedIdentifier) = SyntaxKind.None Then - Return identifierToken - End If - - Return identifierToken.CopyAnnotationsTo( - SyntaxFactory.BracketedIdentifier(identifierToken.LeadingTrivia, identifierToken.ValueText, identifierToken.TrailingTrivia) _ - .WithAdditionalAnnotations(Simplifier.Annotation)) - End Function - Protected Overrides Function GetSpeculativeSemanticModel(ByRef nodeToSpeculate As SyntaxNode, originalSemanticModel As SemanticModel, originalNode As SyntaxNode) As SemanticModel Contract.ThrowIfNull(nodeToSpeculate) Contract.ThrowIfNull(originalNode) diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicCompilationFactoryService.vb b/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicCompilationFactoryService.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicCompilationFactoryService.vb rename to src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicCompilationFactoryService.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.NullSyntaxReference.vb b/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.NullSyntaxReference.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.NullSyntaxReference.vb rename to src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.NullSyntaxReference.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.PathSyntaxReference.vb b/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.PathSyntaxReference.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.PathSyntaxReference.vb rename to src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.PathSyntaxReference.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.PositionalSyntaxReference.vb b/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.PositionalSyntaxReference.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.PositionalSyntaxReference.vb rename to src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.PositionalSyntaxReference.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.RecoverableSyntaxTree.vb b/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.RecoverableSyntaxTree.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.RecoverableSyntaxTree.vb rename to src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.RecoverableSyntaxTree.vb diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.vb b/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.vb similarity index 100% rename from src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxTreeFactoryService.vb rename to src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicSyntaxTreeFactoryService.vb From c3ecec53b9a704bcfb6c9b25f60e3dd8b944e992 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 31 Jan 2020 00:22:45 -0800 Subject: [PATCH 02/26] Port CSharpMakeStructFieldsWritableDiagnosticAnalyzer and fixer --- .../CSharp/Analyzers/CSharpAnalyzers.projitems | 1 + ...rpMakeStructFieldsWritableDiagnosticAnalyzer.cs | 10 ++++++++-- .../CSharp/CodeFixes/CSharpCodeFixes.projitems | 1 + ...SharpMakeStructFieldsWritableCodeFixProvider.cs | 10 ++++++++-- .../Tests/CSharpAnalyzers.UnitTests.projitems | 1 + .../MakeStructFieldsWritableTests.cs | 0 .../Analyzers/CSharpCodeStyleResources.Designer.cs | 14 +++++++++++--- .../CSharp/Analyzers/CSharpCodeStyleResources.resx | 4 ++++ .../Analyzers/xlf/CSharpCodeStyleResources.cs.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.de.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.es.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.fr.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.it.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.ja.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.ko.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.pl.xlf | 5 +++++ .../xlf/CSharpCodeStyleResources.pt-BR.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.ru.xlf | 5 +++++ .../Analyzers/xlf/CSharpCodeStyleResources.tr.xlf | 5 +++++ .../xlf/CSharpCodeStyleResources.zh-Hans.xlf | 5 +++++ .../xlf/CSharpCodeStyleResources.zh-Hant.xlf | 5 +++++ 21 files changed, 99 insertions(+), 7 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (92%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs (91%) 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 d26a3f56df98b..cb7292d7c64f3 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -9,6 +9,7 @@ Microsoft.CodeAnalysis.CSharp.Analyzers + \ No newline at end of file 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 7f946fbdd7a47..65a55d69cf820 100644 --- a/src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs @@ -10,13 +10,19 @@ namespace Microsoft.CodeAnalysis.CSharp.MakeStructFieldsWritable { +#if CODE_STYLE + using Resources = CSharpCodeStyleResources; +#else + using Resources = FeaturesResources; +#endif + [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpMakeStructFieldsWritableDiagnosticAnalyzer : AbstractCodeQualityDiagnosticAnalyzer { 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.Make_readonly_fields_writable), FeaturesResources.ResourceManager, typeof(FeaturesResources)), + new LocalizableResourceString(nameof(Resources.Make_readonly_fields_writable), Resources.ResourceManager, typeof(Resources)), + new LocalizableResourceString(nameof(Resources.Make_readonly_fields_writable), Resources.ResourceManager, typeof(Resources)), isUnneccessary: false); public CSharpMakeStructFieldsWritableDiagnosticAnalyzer() diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index 322fd9537163d..555a9ae537f0a 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -9,6 +9,7 @@ Microsoft.CodeAnalysis.CSharp.CodeFixes + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs similarity index 91% rename from src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs index ca5d6ead8a516..caa560c344bb3 100644 --- a/src/Features/CSharp/Portable/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs @@ -17,6 +17,12 @@ namespace Microsoft.CodeAnalysis.CSharp.MakeStructFieldsWritable { +#if CODE_STYLE + using Resources = CSharpCodeStyleResources; +#else + using Resources = FeaturesResources; +#endif + [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.MakeStructFieldsWritable), Shared] internal class CSharpMakeStructFieldsWritableCodeFixProvider : SyntaxEditorBasedCodeFixProvider { @@ -72,10 +78,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(Resources.Make_readonly_fields_writable, createChangedDocument) { } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index 37af92b661875..a8daee8cede6f 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -9,6 +9,7 @@ Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests + \ No newline at end of file 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 diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs index 10a27950593c6..021b0a9161d2e 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs @@ -10,7 +10,6 @@ namespace Microsoft.CodeAnalysis.CSharp { using System; - using System.Reflection; /// @@ -20,7 +19,7 @@ namespace Microsoft.CodeAnalysis.CSharp { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class CSharpCodeStyleResources { @@ -40,7 +39,7 @@ internal CSharpCodeStyleResources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources", typeof(CSharpCodeStyleResources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources", typeof(CSharpCodeStyleResources).Assembly); resourceMan = temp; } return resourceMan; @@ -70,6 +69,15 @@ internal static string Indentation_preferences { } } + /// + /// Looks up a localized string similar to Make readonly fields writable. + /// + internal static string Make_readonly_fields_writable { + get { + return ResourceManager.GetString("Make_readonly_fields_writable", resourceCulture); + } + } + /// /// Looks up a localized string similar to Space preferences. /// diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx index 4ba473044c43d..260f0d725d50f 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx @@ -126,4 +126,8 @@ Wrapping preferences + + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf index 2d96a25c0d3c4..fbb6eb465f94e 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf @@ -7,6 +7,11 @@ Předvolby odsazení + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Předvolby mezer diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf index 0d83ba440a00e..e04b687302ed3 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf @@ -7,6 +7,11 @@ Einstellungen für Einrückung + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Einstellungen für Abstände diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf index 77af241413a49..483d7593a7d25 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf @@ -7,6 +7,11 @@ Preferencias de indentación + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Preferencias de espacio diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf index 8fa3b735f7686..7fcbc79d4b017 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf @@ -7,6 +7,11 @@ Préférences de mise en retrait + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Préférences d'espace diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf index 27c12bd4e0b95..98889f7199ade 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf @@ -7,6 +7,11 @@ Preferenze per rientro + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Preferenze per spazi diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf index 83fe539cd4cb7..dad188cf24cd8 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf @@ -7,6 +7,11 @@ インデント設定 + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences スペース設定 diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf index 31c5055f766bf..1a471e08f96c3 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf @@ -7,6 +7,11 @@ 들여쓰기 기본 설정 + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences 공간 기본 설정 diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf index a5b06c9301fa7..ea677f367fb1b 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf @@ -7,6 +7,11 @@ Preferencje wcięć + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Preferencje dotyczące odstępów diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf index c5d3f65ea7a49..b35cb6cb023b6 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf @@ -7,6 +7,11 @@ Preferências de recuo + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Preferências de espaço diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf index 2f8dba0638db7..234cc8c7c34ed 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf @@ -7,6 +7,11 @@ Параметры отступов + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Предпочтения для интервалов diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf index 494145da415f3..edf3e1aa8b0b2 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf @@ -7,6 +7,11 @@ Girinti tercihleri + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences Boşluk tercihleri diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf index 1a9702dd40ad3..857d28a3dcee3 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf @@ -7,6 +7,11 @@ 缩进首选项 + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences 空格键首选项 diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf index 0135365fa24e6..2e42b0cb9420a 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf @@ -7,6 +7,11 @@ 縮排喜好設定 + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + Space preferences 空格喜好設定 From 2e32204e08a630a8512f84886f16aac087071734 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 31 Jan 2020 17:41:49 -0800 Subject: [PATCH 03/26] Port ConvertSwitchStatementToExpression to CodeStyle layer --- .../Analyzers/CSharpAnalyzers.projitems | 3 + ...ertSwitchStatementToExpressionConstants.cs | 0 ...ToExpressionDiagnosticAnalyzer.Analyzer.cs | 0 ...StatementToExpressionDiagnosticAnalyzer.cs | 20 ++- .../CodeFixes/CSharpCodeFixes.projitems | 2 + ...entToExpressionCodeFixProvider.Rewriter.cs | 0 ...tchStatementToExpressionCodeFixProvider.cs | 9 +- .../Tests/CSharpAnalyzers.UnitTests.projitems | 2 + ...tSwitchStatementToExpressionFixAllTests.cs | 0 ...ConvertSwitchStatementToExpressionTests.cs | 10 +- ...tractBuiltInCodeStyleDiagnosticAnalyzer.cs | 4 +- .../IDEDiagnosticIdToOptionMappingHelper.cs | 5 + src/CodeStyle/BannedSymbols.txt | 10 +- .../CSharpCodeStyleResources.Designer.cs | 72 +++++++++ .../Analyzers/CSharpCodeStyleResources.resx | 25 +++ .../xlf/CSharpCodeStyleResources.cs.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.de.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.es.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.fr.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.it.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.ja.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.ko.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.pl.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.pt-BR.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.ru.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.tr.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.zh-Hans.xlf | 40 +++++ .../xlf/CSharpCodeStyleResources.zh-Hant.xlf | 40 +++++ .../CSharpCodeStyleFixesResources.Designer.cs | 9 ++ .../CSharpCodeStyleFixesResources.resx | 3 + ...CodeAnalysis.CSharp.CodeStyle.Fixes.csproj | 2 +- .../xlf/CSharpCodeStyleFixesResources.cs.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.de.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.es.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.fr.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.it.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.ja.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.ko.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.pl.xlf | 5 + .../CSharpCodeStyleFixesResources.pt-BR.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.ru.xlf | 5 + .../xlf/CSharpCodeStyleFixesResources.tr.xlf | 5 + .../CSharpCodeStyleFixesResources.zh-Hans.xlf | 5 + .../CSharpCodeStyleFixesResources.zh-Hant.xlf | 5 + ...Analysis.CSharp.CodeStyle.UnitTests.csproj | 1 + .../Analyzers/CodeStyleResources.Designer.cs | 72 +++++++++ .../Core/Analyzers/CodeStyleResources.resx | 24 +++ ...ns.cs => CompilerAnalyzerConfigOptions.cs} | 0 .../Core/Analyzers/Formatting/Formatter.cs | 3 +- .../Analyzers/FormattingAnalyzerHelper.cs | 3 +- .../Microsoft.CodeAnalysis.CodeStyle.csproj | 2 +- .../AnalyzerConfigOptionsExtensions.cs | 2 +- .../Options/AnalyzerOptionsExtensions.cs | 14 ++ .../Analyzers/xlf/CodeStyleResources.cs.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.de.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.es.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.fr.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.it.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.ja.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.ko.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.pl.xlf | 40 +++++ .../xlf/CodeStyleResources.pt-BR.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.ru.xlf | 40 +++++ .../Analyzers/xlf/CodeStyleResources.tr.xlf | 40 +++++ .../xlf/CodeStyleResources.zh-Hans.xlf | 40 +++++ .../xlf/CodeStyleResources.zh-Hant.xlf | 40 +++++ .../Core/CodeFixes/FormattingCodeFixHelper.cs | 2 +- .../CodeFixes/FormattingCodeFixProvider.cs | 2 +- ...rosoft.CodeAnalysis.CodeStyle.Fixes.csproj | 1 - ...ft.CodeAnalysis.CodeStyle.UnitTests.csproj | 2 +- src/CodeStyle/Directory.Build.targets | 2 +- ....CodeAnalysis.CSharp.Test.Utilities.csproj | 1 + ...agnosticProviderBasedUserDiagnosticTest.cs | 4 +- .../AbstractCodeActionOrUserDiagnosticTest.cs | 144 ++++++++++++++---- ...agnosticProviderBasedUserDiagnosticTest.cs | 16 +- .../Diagnostics/AbstractUserDiagnosticTest.cs | 16 +- .../EditSessionActiveStatementsTests.cs | 2 +- .../TestUtilities/Workspaces/TestWorkspace.cs | 2 +- .../Workspaces/TestWorkspace_Create.cs | 37 +++-- .../Workspaces/TestWorkspace_XmlCreation.cs | 12 +- ...agnosticProviderBasedUserDiagnosticTest.vb | 8 +- .../Portable/Diagnostics/AnalyzerHelper.cs | 4 + .../Formatting/CSharpFormattingOptions.cs | 4 +- .../Engine/Trivia/CSharpTriviaFormatter.cs | 1 - .../Formatting/Rules/SpacingFormattingRule.cs | 4 +- .../Core/Portable/CodeFixes/CodeFix.cs | 3 +- .../Portable/CodeStyle/CodeStyleOption.cs | 4 + .../Portable/CodeStyle/CodeStyleOptions.cs | 31 ++-- .../Portable/CodeStyle/NotificationOption.cs | 4 +- .../AbstractSyntaxFormattingService.cs | 3 +- .../Formatting/Engine/AbstractFormatEngine.cs | 4 +- ...ctTriviaDataFactory.FormattedWhitespace.cs | 3 +- ...actTriviaDataFactory.ModifiedWhitespace.cs | 3 +- .../Engine/AbstractTriviaDataFactory.cs | 3 +- .../Portable/Formatting/FormattingOptions.cs | 4 +- .../Core/Portable/Log/FunctionIdOptions.cs | 5 + src/Workspaces/Core/Portable/Log/Logger.cs | 5 + .../EditorConfigStorageLocation.cs | 4 + .../EditorConfigStorageLocation`1.cs | 4 +- .../IEditorConfigStorageLocation.cs | 6 + .../IEditorConfigStorageLocation2.cs | 6 +- .../Core/Portable/Options/IOption.cs | 4 + .../Core/Portable/Options/IOptionWithGroup.cs | 4 + .../LocalUserProfileStorageLocation.cs | 4 + .../Core/Portable/Options/OptionGroup.cs | 4 + .../Core/Portable/Options/OptionKey.cs | 7 + .../Portable/Options/OptionStorageLocation.cs | 4 + .../Core/Portable/Options/Option`1.cs | 4 + .../Portable/Options/PerLanguageOption.cs | 4 + .../Options/RoamingProfileStorageLocation.cs | 4 + .../CSharp/CSharpCompilerExtensions.projitems | 4 + .../CodeStyle/CSharpCodeStyleOptions.cs | 29 +++- .../CSharpCodeStyleOptions_Parsing.cs | 7 +- .../CodeStyle/PreferBracesPreference.cs | 9 +- .../Extensions/StatementSyntaxExtensions.cs | 5 - .../AccessibilityModifiersRequired.cs | 4 + .../Core/CodeStyle/CodeStyleHelpers.cs | 7 +- .../CodeStyle/ExpressionBodyPreference.cs | 4 + ...OperatorPlacementWhenWrappingPreference.cs | 5 + .../Core/CodeStyle/ParenthesesPreference.cs | 4 + .../CodeStyle/UnusedParametersPreference.cs | 4 + .../Core/CodeStyle/UnusedValuePreference.cs | 4 + .../Core/CompilerExtensions.projitems | 2 +- .../NotificationOptionExtensions.cs | 4 + .../CSharpWorkspaceExtensions.projitems | 1 - .../Extensions/BlockSyntaxExtensions.cs | 6 +- .../Extensions/ExpressionSyntaxExtensions.cs | 2 - ...olExtensions.TypeSyntaxGeneratorVisitor.cs | 2 +- .../Simplification/SimplificationHelpers.cs | 9 +- 129 files changed, 1756 insertions(+), 153 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionConstants.cs (100%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (100%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs (86%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (100%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs (93%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionFixAllTests.cs (100%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionTests.cs (99%) rename src/CodeStyle/Core/Analyzers/{AnalyzerConfigOptions.cs => CompilerAnalyzerConfigOptions.cs} (100%) create mode 100644 src/CodeStyle/Core/Analyzers/Options/AnalyzerOptionsExtensions.cs rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/CodeStyle/CSharpCodeStyleOptions.cs (96%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/CodeStyle/CSharpCodeStyleOptions_Parsing.cs (97%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/CodeStyle/PreferBracesPreference.cs (96%) rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace => Compiler}/CSharp/Extensions/StatementSyntaxExtensions.cs (88%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index cb7292d7c64f3..cebb31f66df8b 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -9,6 +9,9 @@ Microsoft.CodeAnalysis.CSharp.Analyzers + + + diff --git a/src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionConstants.cs b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionConstants.cs similarity index 100% rename from src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionConstants.cs rename to src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionConstants.cs diff --git a/src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs similarity index 100% rename from src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs rename to src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs diff --git a/src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs similarity index 86% rename from src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs index 65a99d7d05f51..62e1f2082c2d3 100644 --- a/src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs @@ -6,12 +6,19 @@ using System.Globalization; using System.Linq; using Microsoft.CodeAnalysis.CodeStyle; -using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; +#if CODE_STYLE +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle; +using Resources = Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources; +#else +using Microsoft.CodeAnalysis.CSharp.CodeStyle; +using Microsoft.CodeAnalysis.Options; +using Resources = Microsoft.CodeAnalysis.CSharp.CSharpFeaturesResources; +#endif + namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression { using Constants = ConvertSwitchStatementToExpressionConstants; @@ -23,8 +30,8 @@ public ConvertSwitchStatementToExpressionDiagnosticAnalyzer() : base(IDEDiagnosticIds.ConvertSwitchStatementToExpressionDiagnosticId, CSharpCodeStyleOptions.PreferSwitchExpression, LanguageNames.CSharp, - new LocalizableResourceString(nameof(CSharpFeaturesResources.Convert_switch_statement_to_expression), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)), - new LocalizableResourceString(nameof(CSharpFeaturesResources.Use_switch_expression), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources))) + new LocalizableResourceString(nameof(Resources.Convert_switch_statement_to_expression), Resources.ResourceManager, typeof(Resources)), + new LocalizableResourceString(nameof(Resources.Use_switch_expression), Resources.ResourceManager, typeof(Resources))) { } @@ -48,7 +55,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context) var options = context.Options; var cancellationToken = context.CancellationToken; - var optionSet = options.GetDocumentOptionSetAsync(syntaxTree, cancellationToken).GetAwaiter().GetResult(); + var optionSet = options.GetOptions(syntaxTree, cancellationToken); if (optionSet == null) { return; @@ -90,9 +97,6 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context) .Add(Constants.ShouldRemoveNextStatementKey, shouldRemoveNextStatement.ToString(CultureInfo.InvariantCulture)))); } - public override bool OpenFileOnly(OptionSet options) - => false; - public override DiagnosticAnalyzerCategory GetAnalyzerCategory() => DiagnosticAnalyzerCategory.SemanticSpanAnalysis; } diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index 555a9ae537f0a..9b0af3319cf97 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -9,6 +9,8 @@ Microsoft.CodeAnalysis.CSharp.CodeFixes + + diff --git a/src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs similarity index 100% rename from src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs rename to src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs diff --git a/src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs similarity index 93% rename from src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs index 89109bac18706..e715ec7aa6936 100644 --- a/src/Features/CSharp/Portable/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs @@ -23,6 +23,11 @@ namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression { using Constants = ConvertSwitchStatementToExpressionConstants; +#if CODE_STYLE + using Resources = CSharpCodeStyleFixesResources; +#else + using Resources = CSharpFeaturesResources; +#endif [ExportCodeFixProvider(LanguageNames.CSharp), Shared] internal sealed partial class ConvertSwitchStatementToExpressionCodeFixProvider : SyntaxEditorBasedCodeFixProvider @@ -94,10 +99,10 @@ protected override async Task FixAllAsync(Document document, ImmutableArray> createChangedDocument) - : base(CSharpFeaturesResources.Convert_switch_statement_to_expression, createChangedDocument) + : base(Resources.Convert_switch_statement_to_expression, createChangedDocument) { } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index a8daee8cede6f..66e41786a642b 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -9,6 +9,8 @@ Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests + + diff --git a/src/EditorFeatures/CSharpTest/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionFixAllTests.cs b/src/Analyzers/CSharp/Tests/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionFixAllTests.cs similarity index 100% rename from src/EditorFeatures/CSharpTest/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionFixAllTests.cs rename to src/Analyzers/CSharp/Tests/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionFixAllTests.cs diff --git a/src/EditorFeatures/CSharpTest/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionTests.cs b/src/Analyzers/CSharp/Tests/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionTests.cs rename to src/Analyzers/CSharp/Tests/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionTests.cs index 3c4f7f6a796b0..df9ff295604cb 100644 --- a/src/EditorFeatures/CSharpTest/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionTests.cs +++ b/src/Analyzers/CSharp/Tests/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionTests.cs @@ -5,8 +5,6 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CodeStyle; -using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Diagnostics; @@ -15,6 +13,14 @@ using Roslyn.Test.Utilities; using Xunit; +#if CODE_STYLE +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle; +using Microsoft.CodeAnalysis.Internal.Options; +#else +using Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.CSharp.CodeStyle; +#endif + namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ConvertSwitchStatementToExpression { public partial class ConvertSwitchStatementToExpressionTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest diff --git a/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs index 43d99c62b8eae..bb4303e7ed823 100644 --- a/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs @@ -6,14 +6,14 @@ using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Options; namespace Microsoft.CodeAnalysis.CodeStyle { #if CODE_STYLE using OptionSet = AnalyzerConfigOptions; + using Microsoft.CodeAnalysis.Internal.Options; #else - using OptionSet = Options.OptionSet; + using Microsoft.CodeAnalysis.Options; #endif internal abstract class AbstractBuiltInCodeStyleDiagnosticAnalyzer : AbstractCodeStyleDiagnosticAnalyzer, IBuiltInAnalyzer diff --git a/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs b/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs index 2f3e060422969..25683466748a9 100644 --- a/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs +++ b/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs @@ -7,7 +7,12 @@ using System.Collections.Immutable; using System.Diagnostics; using System.Linq; + +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; +#else using Microsoft.CodeAnalysis.Options; +#endif namespace Microsoft.CodeAnalysis.Diagnostics { diff --git a/src/CodeStyle/BannedSymbols.txt b/src/CodeStyle/BannedSymbols.txt index 20394b89bbe11..c606990637777 100644 --- a/src/CodeStyle/BannedSymbols.txt +++ b/src/CodeStyle/BannedSymbols.txt @@ -1,2 +1,8 @@ -P:Microsoft.CodeAnalysis.Project.LanguageServices; Use 'GetExtendedLanguageServices' instead -M:Microsoft.CodeAnalysis.Host.HostWorkspaceServices.GetLanguageServices(System.String); Use 'GetExtendedLanguageServices' or directly get the language service by invoking 'GetLanguageService' or 'GetRequiredLanguageService' +P:Microsoft.CodeAnalysis.Project.LanguageServices; Use 'GetExtendedLanguageServices' instead in CodeStyle layer (preprocessor variable 'CODE_STYLE') +M:Microsoft.CodeAnalysis.Host.HostWorkspaceServices.GetLanguageServices(System.String); Use 'GetExtendedLanguageServices' or directly get the language service by invoking 'GetLanguageService' or 'GetRequiredLanguageService' in CodeStyle layer (preprocessor variable 'CODE_STYLE') +T:Microsoft.CodeAnalysis.Options.OptionSet; 'OptionSet' is not available in CodeStyle layer. Add a using/Imports statement defining 'OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions' when preprocessor variable 'CODE_STYLE' is defined +T:Microsoft.CodeAnalysis.CodeStyle.CodeStyleOption`1; Use 'Microsoft.CodeAnalysis.Internal.Options.CodeStyleOption' instead in CodeStyle layer (preprocessor variable 'CODE_STYLE') +T:Microsoft.CodeAnalysis.CodeStyle.CodeStyleOptions; Use 'Microsoft.CodeAnalysis.Internal.Options.CodeStyleOptions' instead in CodeStyle layer (preprocessor variable 'CODE_STYLE') +T:Microsoft.CodeAnalysis.Options.IOption; Use 'Microsoft.CodeAnalysis.Internal.Options.IOption' instead in CodeStyle layer (preprocessor variable 'CODE_STYLE') +T:Microsoft.CodeAnalysis.Options.OptionKey; Use 'Microsoft.CodeAnalysis.Internal.Options.OptionKey' instead in CodeStyle layer (preprocessor variable 'CODE_STYLE') +T:Microsoft.CodeAnalysis.CodeStyle.NotificationOption; Use 'Microsoft.CodeAnalysis.Internal.Options.NotificationOption' instead in CodeStyle layer (preprocessor variable 'CODE_STYLE') \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs index 021b0a9161d2e..c8d88081f12ce 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs @@ -60,6 +60,33 @@ internal CSharpCodeStyleResources() { } } + /// + /// Looks up a localized string similar to Code-block preferences. + /// + internal static string Code_block_preferences { + get { + return ResourceManager.GetString("Code_block_preferences", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Convert switch statement to expression. + /// + internal static string Convert_switch_statement_to_expression { + get { + return ResourceManager.GetString("Convert_switch_statement_to_expression", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expression-bodied members. + /// + internal static string Expression_bodied_members { + get { + return ResourceManager.GetString("Expression_bodied_members", resourceCulture); + } + } + /// /// Looks up a localized string similar to Indentation preferences. /// @@ -78,6 +105,24 @@ internal static string Make_readonly_fields_writable { } } + /// + /// Looks up a localized string similar to Null-checking preferences. + /// + internal static string Null_checking_preferences { + get { + return ResourceManager.GetString("Null_checking_preferences", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pattern matching preferences. + /// + internal static string Pattern_matching_preferences { + get { + return ResourceManager.GetString("Pattern_matching_preferences", resourceCulture); + } + } + /// /// Looks up a localized string similar to Space preferences. /// @@ -87,6 +132,33 @@ internal static string Space_preferences { } } + /// + /// Looks up a localized string similar to Use 'switch' expression. + /// + internal static string Use_switch_expression { + get { + return ResourceManager.GetString("Use_switch_expression", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 'using' directive preferences. + /// + internal static string using_directive_preferences { + get { + return ResourceManager.GetString("using_directive_preferences", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to var preferences. + /// + internal static string var_preferences { + get { + return ResourceManager.GetString("var_preferences", resourceCulture); + } + } + /// /// Looks up a localized string similar to Wrapping preferences. /// diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx index 260f0d725d50f..fdfe23b219caa 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx @@ -130,4 +130,29 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Convert switch statement to expression + + + Use 'switch' expression + + + var preferences + + + Expression-bodied members + + + Pattern matching preferences + + + Null-checking preferences + + + Code-block preferences + + + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf index fbb6eb465f94e..b083e05e82822 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Předvolby odsazení @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Předvolby mezer + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Předvolby zalamování + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf index e04b687302ed3..1a3df896ca801 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Einstellungen für Einrückung @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Einstellungen für Abstände + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Umbrucheinstellungen + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf index 483d7593a7d25..e1163cd522d41 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Preferencias de indentación @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Preferencias de espacio + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Preferencias de ajuste + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf index 7fcbc79d4b017..badfb5be91471 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Préférences de mise en retrait @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Préférences d'espace + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Préférences d'enveloppement + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf index 98889f7199ade..01fa368e5e3d0 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Preferenze per rientro @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Preferenze per spazi + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Preferenze per ritorno a capo + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf index dad188cf24cd8..73d811fd3a4cb 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences インデント設定 @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences スペース設定 + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences 折り返しの設定 + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf index 1a471e08f96c3..6163e7c8f5568 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences 들여쓰기 기본 설정 @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences 공간 기본 설정 + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences 기본 설정 래핑 + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf index ea677f367fb1b..b213a034f8a81 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Preferencje wcięć @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Preferencje dotyczące odstępów + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Preferencje zawijania + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf index b35cb6cb023b6..a02ee27e267b6 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Preferências de recuo @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Preferências de espaço + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Preferências de quebra de linha + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf index 234cc8c7c34ed..6962d0c0dd4c4 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Параметры отступов @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Предпочтения для интервалов + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Параметры переноса + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf index edf3e1aa8b0b2..ce77798ee5393 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences Girinti tercihleri @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences Boşluk tercihleri + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences Kaydırma tercihleri + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf index 857d28a3dcee3..6a9cade8e6706 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences 缩进首选项 @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences 空格键首选项 + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences 包装首选项 + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf index 2e42b0cb9420a..196239dfb6307 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf @@ -2,6 +2,21 @@ + + Code-block preferences + Code-block preferences + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Expression-bodied members + Expression-bodied members + + Indentation preferences 縮排喜好設定 @@ -12,16 +27,41 @@ Make readonly fields writable {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + Space preferences 空格喜好設定 + + Use 'switch' expression + Use 'switch' expression + + Wrapping preferences 換行喜好設定 + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs index 409a081cb20eb..c7be050ea1bc5 100644 --- a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs +++ b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs @@ -60,6 +60,15 @@ internal CSharpCodeStyleFixesResources() { } } + /// + /// Looks up a localized string similar to Convert switch statement to expression. + /// + internal static string Convert_switch_statement_to_expression { + get { + return ResourceManager.GetString("Convert_switch_statement_to_expression", resourceCulture); + } + } + /// /// Looks up a localized string similar to Expected string or char literal. /// diff --git a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx index 98c8b413e306f..bc5fcf47a3bb3 100644 --- a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx +++ b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx @@ -120,4 +120,7 @@ Expected string or char literal + + Convert switch statement to expression + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj b/src/CodeStyle/CSharp/CodeFixes/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj index b7de97127a4c9..eb028423c6224 100644 --- a/src/CodeStyle/CSharp/CodeFixes/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj +++ b/src/CodeStyle/CSharp/CodeFixes/Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj @@ -38,7 +38,7 @@ - + diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf index 39146d45d209b..0b0ab48f744d0 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf index 18a9a30d8be0f..640a769f554c2 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf index 26bf74c96ffa0..e010f3be44063 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf index 3b95b05aac8b1..ae81a4aa7d7e2 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf index 0f4d7644333c7..ef06d8f9b8933 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf index ad88830d4a9c6..1d746adf9daa8 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf index b00636dc3fa5f..cbddbdc67f77e 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf index 3bbd74588e939..9bac2da4dba1e 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf index dca3e55064999..999ade09e06f2 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf index 20970585e1c9d..8fc6598f3d694 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf index ad42489520643..b57c3e78c9bef 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf index 9c28fdf16fcb6..b672463d70243 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf index 4a8c4907b89f9..57f31f4c3a451 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf @@ -2,6 +2,11 @@ + + Convert switch statement to expression + Convert switch statement to expression + + Expected string or char literal Expected string or char literal diff --git a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj index fe10a2f60487b..a558b01c62003 100644 --- a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj @@ -23,6 +23,7 @@ + diff --git a/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs b/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs index d87795edef782..4cc76a750348a 100644 --- a/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs +++ b/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs @@ -132,6 +132,24 @@ internal static string Error { } } + /// + /// Looks up a localized string similar to Expression-level preferences. + /// + internal static string Expression_level_preferences { + get { + return ResourceManager.GetString("Expression_level_preferences", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Field preferences. + /// + internal static string Field_preferences { + get { + return ResourceManager.GetString("Field_preferences", resourceCulture); + } + } + /// /// Looks up a localized string similar to Fix formatting. /// @@ -150,6 +168,24 @@ internal static string Indentation_and_spacing { } } + /// + /// Looks up a localized string similar to Language keywords vs BCL types preferences. + /// + internal static string Language_keywords_vs_BCL_types_preferences { + get { + return ResourceManager.GetString("Language_keywords_vs_BCL_types_preferences", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Modifier preferences. + /// + internal static string Modifier_preferences { + get { + return ResourceManager.GetString("Modifier_preferences", resourceCulture); + } + } + /// /// Looks up a localized string similar to New line preferences. /// @@ -168,6 +204,33 @@ internal static string None { } } + /// + /// Looks up a localized string similar to Organize usings. + /// + internal static string Organize_usings { + get { + return ResourceManager.GetString("Organize_usings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Parameter preferences. + /// + internal static string Parameter_preferences { + get { + return ResourceManager.GetString("Parameter_preferences", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Parentheses preferences. + /// + internal static string Parentheses_preferences { + get { + return ResourceManager.GetString("Parentheses_preferences", resourceCulture); + } + } + /// /// Looks up a localized string similar to Private member '{0}' can be removed as the value assigned to it is never read.. /// @@ -259,6 +322,15 @@ internal static string The_type_0_is_not_understood_by_the_serialization_binder } } + /// + /// Looks up a localized string similar to this. and Me. preferences. + /// + internal static string this_dot_and_Me_dot_preferences { + get { + return ResourceManager.GetString("this_dot_and_Me_dot_preferences", resourceCulture); + } + } + /// /// Looks up a localized string similar to Value too large to be represented as a 30 bit unsigned integer.. /// diff --git a/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx b/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx index d0a0eae7d5f55..649d85e945b46 100644 --- a/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx +++ b/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx @@ -189,4 +189,28 @@ Private property '{0}' can be converted to a method as its get accessor is never invoked. + + Organize usings + + + this. and Me. preferences + + + Language keywords vs BCL types preferences + + + Parentheses preferences + + + Modifier preferences + + + Expression-level preferences + + + Field preferences + + + Parameter preferences + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/AnalyzerConfigOptions.cs b/src/CodeStyle/Core/Analyzers/CompilerAnalyzerConfigOptions.cs similarity index 100% rename from src/CodeStyle/Core/Analyzers/AnalyzerConfigOptions.cs rename to src/CodeStyle/Core/Analyzers/CompilerAnalyzerConfigOptions.cs diff --git a/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs b/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs index 6a056e9f13923..bc62a7993cda9 100644 --- a/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs +++ b/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs @@ -6,13 +6,12 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; -namespace Microsoft.CodeAnalysis.CodeStyle.Formatting +namespace Microsoft.CodeAnalysis.Formatting { /// /// Formats whitespace in documents or syntax trees. diff --git a/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs b/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs index cf7d6896bfdee..f2623226cc4e1 100644 --- a/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs +++ b/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs @@ -3,15 +3,14 @@ // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Text; #if CODE_STYLE -using Microsoft.CodeAnalysis.CodeStyle.Formatting; using FormatterState = Microsoft.CodeAnalysis.Formatting.ISyntaxFormattingService; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; #else using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Formatting; using FormatterState = Microsoft.CodeAnalysis.Workspace; #endif diff --git a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj index 121ccf765fc9f..a5a282e106a2e 100644 --- a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj +++ b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj @@ -21,12 +21,12 @@ - + diff --git a/src/CodeStyle/Core/Analyzers/Options/AnalyzerConfigOptionsExtensions.cs b/src/CodeStyle/Core/Analyzers/Options/AnalyzerConfigOptionsExtensions.cs index bff66da9b2c7b..8687a3dd5f07e 100644 --- a/src/CodeStyle/Core/Analyzers/Options/AnalyzerConfigOptionsExtensions.cs +++ b/src/CodeStyle/Core/Analyzers/Options/AnalyzerConfigOptionsExtensions.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Internal.Options; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; namespace Microsoft.CodeAnalysis diff --git a/src/CodeStyle/Core/Analyzers/Options/AnalyzerOptionsExtensions.cs b/src/CodeStyle/Core/Analyzers/Options/AnalyzerOptionsExtensions.cs new file mode 100644 index 0000000000000..149dff0bc7c79 --- /dev/null +++ b/src/CodeStyle/Core/Analyzers/Options/AnalyzerOptionsExtensions.cs @@ -0,0 +1,14 @@ +// 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.Threading; + +namespace Microsoft.CodeAnalysis.Diagnostics +{ + internal static partial class AnalyzerOptionsExtensions + { + public static AnalyzerConfigOptions GetOptions(this AnalyzerOptions analyzerOptions, SyntaxTree syntaxTree, CancellationToken _) + => analyzerOptions.AnalyzerConfigOptionsProvider.GetOptions(syntaxTree); + } +} diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf index 677e25209dca0..0de8394ab1ee9 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf @@ -42,6 +42,16 @@ Chyba + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Opravit formátování @@ -52,6 +62,16 @@ Odsazení a mezery + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Předvolby nových řádků @@ -62,6 +82,21 @@ žádné + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Upozornění + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf index 1bb38721fb30d..163026e34feeb 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf @@ -42,6 +42,16 @@ Fehler + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Formatierung korrigieren @@ -52,6 +62,16 @@ Einzüge und Abstände + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Einstellungen für neue Zeilen @@ -62,6 +82,21 @@ NONE + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Warnung + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf index 9aa521ca2efe1..4c78a77841195 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf @@ -42,6 +42,16 @@ Error + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Fijar formato @@ -52,6 +62,16 @@ Sangría y espaciado + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Nuevas preferencias de línea @@ -62,6 +82,21 @@ NONE + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Advertencia + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf index 51cabba1ab0f9..ca55f21d41982 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf @@ -42,6 +42,16 @@ Erreur + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Corriger la mise en forme @@ -52,6 +62,16 @@ Indentation et espacement + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Préférences de nouvelle ligne @@ -62,6 +82,21 @@ Aucun(e) + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Avertissement + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf index efcc91a7c6aa8..4468c2a5dba46 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf @@ -42,6 +42,16 @@ Errore + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Correggi formattazione @@ -52,6 +62,16 @@ Rientro e spaziatura + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Preferenze per nuova riga @@ -62,6 +82,21 @@ Nessuno + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Avviso + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf index 14e6213ab8285..587dee50933f1 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf @@ -42,6 +42,16 @@ エラー + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting 書式設定を修正 @@ -52,6 +62,16 @@ インデントと間隔 + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences 改行設定 @@ -62,6 +82,21 @@ なし + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ 警告 + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf index ccd78b71ef82e..b5b6d2627be6c 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf @@ -42,6 +42,16 @@ 오류 + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting 서식 수정 @@ -52,6 +62,16 @@ 들여쓰기 및 간격 + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences 새 줄 기본 설정 @@ -62,6 +82,21 @@ None + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ 경고 + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf index e0993cbd39dba..63be3252e2682 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf @@ -42,6 +42,16 @@ Błąd + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Napraw formatowanie @@ -52,6 +62,16 @@ Wcięcia i odstępy + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Preferencje nowego wiersza @@ -62,6 +82,21 @@ brak + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Ostrzeżenie + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf index 4c53e7c6dba00..a966ec205f654 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf @@ -42,6 +42,16 @@ Erro + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Corrigir a formatação @@ -52,6 +62,16 @@ Recuo e espaçamento + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Preferências de nova linha @@ -62,6 +82,21 @@ NENHUM + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Aviso + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf index fcc4936d07cc5..01f01fa48e427 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf @@ -42,6 +42,16 @@ Ошибка + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Исправить форматирование @@ -52,6 +62,16 @@ Отступы и интервалы + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Предпочтения для новых строк @@ -62,6 +82,21 @@ NONE + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Предупреждение + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf index 25a0295c18457..df0e5e54a1491 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf @@ -42,6 +42,16 @@ Hata + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting Biçimlendirme Düzeltme @@ -52,6 +62,16 @@ Girinti ve aralığı + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences Yeni satır tercihleri @@ -62,6 +82,21 @@ yok + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ Uyarı + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf index 41b79037b1f78..316ad22ea7ce4 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf @@ -42,6 +42,16 @@ 错误 + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting 修正格式 @@ -52,6 +62,16 @@ 缩进和间距 + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences 新行首选项 @@ -62,6 +82,21 @@ + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ 警告 + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf index daccbae8631af..2799448296a9d 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf @@ -42,6 +42,16 @@ 錯誤 + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + Fix formatting 修正格式化 @@ -52,6 +62,16 @@ 縮排和間距 + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + New line preferences 新行喜好設定 @@ -62,6 +82,21 @@ + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + Private member '{0}' can be removed as the value assigned to it is never read. Private member '{0}' can be removed as the value assigned to it is never read. @@ -122,6 +157,11 @@ 警告 + + this. and Me. preferences + this. and Me. preferences + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs index da79ab2051a94..428404b7fa002 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Text; #if CODE_STYLE -using Formatter = CodeStyle::Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; +using Formatter = CodeStyle::Microsoft.CodeAnalysis.Formatting.Formatter; using FormatterState = Microsoft.CodeAnalysis.Formatting.ISyntaxFormattingService; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; #else diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs index ab782ff6fadcb..e5d431b3605e9 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs @@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.CodeStyle { extern alias CodeStyle; - using Formatter = CodeStyle::Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; + using Formatter = CodeStyle::Microsoft.CodeAnalysis.Formatting.Formatter; using ISyntaxFormattingService = ISyntaxFormattingService; internal abstract class AbstractFormattingCodeFixProvider : CodeFixProvider diff --git a/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj b/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj index 5db18622b63fc..fd7e853fcb0f5 100644 --- a/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj +++ b/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj @@ -19,7 +19,6 @@ - diff --git a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj index 37f7ce6140c2c..73d610eab9912 100644 --- a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/CodeStyle/Directory.Build.targets b/src/CodeStyle/Directory.Build.targets index ea7a40b91b495..ee638bd401f00 100644 --- a/src/CodeStyle/Directory.Build.targets +++ b/src/CodeStyle/Directory.Build.targets @@ -6,6 +6,6 @@ - + \ No newline at end of file diff --git a/src/Compilers/Test/Utilities/CSharp/Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj b/src/Compilers/Test/Utilities/CSharp/Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj index a09ef090ff9a8..f58883ee0a429 100644 --- a/src/Compilers/Test/Utilities/CSharp/Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj +++ b/src/Compilers/Test/Utilities/CSharp/Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj @@ -31,6 +31,7 @@ + diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs index f9cb2e7c89dc0..05c2c0ad9420a 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs @@ -18,6 +18,8 @@ public abstract class AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest : protected override string GetLanguage() => LanguageNames.CSharp; protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters) - => TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions); + => CreateWorkspaceFromFile(initialMarkup, parameters, rootFilePath: null); + protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters, string rootFilePath = null) + => TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions, rootFilePath: rootFilePath); } } diff --git a/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs index 4ec5d606e466a..2b49110732cf8 100644 --- a/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs +++ b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs @@ -2,13 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if CODE_STYLE -extern alias Workspaces; -#endif - using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; using System.Threading; @@ -21,25 +19,19 @@ using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests; +using Roslyn.Utilities; using Roslyn.Test.Utilities; using Xunit; -namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions -{ #if CODE_STYLE - using Workspaces::Roslyn.Utilities; - using OptionKey = Workspaces::Microsoft.CodeAnalysis.Options.OptionKey; - using CodeActionPriority = Workspaces::Microsoft.CodeAnalysis.CodeActions.CodeActionPriority; - using NotificationOption = Workspaces::Microsoft.CodeAnalysis.CodeStyle.NotificationOption; - using Options = Workspaces::Microsoft.CodeAnalysis.Options; - using CodeStyle = Workspaces::Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.Internal.Options; #else - using Microsoft.CodeAnalysis.Options; - using Microsoft.CodeAnalysis.CodeStyle; - using Roslyn.Utilities; - using Options = CodeAnalysis.Options; +using Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.Options; #endif +namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions +{ [UseExportProvider] public abstract partial class AbstractCodeActionOrUserDiagnosticTest { @@ -102,17 +94,103 @@ public TestParameters WithIncludeDiagnosticsOutsideSelection(bool includeDiagnos protected TestWorkspace CreateWorkspaceFromOptions( string initialMarkup, TestParameters parameters) { - var workspace = TestWorkspace.IsWorkspaceElement(initialMarkup) - ? TestWorkspace.Create(initialMarkup, openDocuments: false) - : CreateWorkspaceFromFile(initialMarkup, parameters); + // For CodeStyle layer testing, we create an .editorconfig at project root + // to apply the options as workspace options are not available in CodeStyle layer. + // Otherwise, we apply the options directly to the workspace. +#if CODE_STYLE + // We need to ensure that our projects/documents are rooted for + // execution from CodeStyle layer as we will be adding a rooted .editorconfig to each project + // to apply the options. + var workspace = CreateWorkspace(rootFilePath: @"z:\"); + if (parameters.options != null) + { + AddAnalyzerConfigDocumentWithOptions(workspace, parameters.options); + } +#else + var workspace = CreateWorkspace(rootFilePath: null); workspace.ApplyOptions(parameters.options); +#endif return workspace; + + TestWorkspace CreateWorkspace(string rootFilePath) + => TestWorkspace.IsWorkspaceElement(initialMarkup) + ? TestWorkspace.Create(initialMarkup, openDocuments: false) + : CreateWorkspaceFromFile(initialMarkup, parameters, rootFilePath); + } + + private static void AddAnalyzerConfigDocumentWithOptions(TestWorkspace workspace, IDictionary options) + { + Debug.Assert(options != null); + var analyzerConfigText = GenerateAnalyzerConfigText(options); + + var newSolution = workspace.CurrentSolution; + foreach (var project in workspace.Projects) + { + Assert.True(PathUtilities.IsAbsolute(project.FilePath)); + var projectRootFilePath = PathUtilities.GetPathRoot(project.FilePath); + var documentId = DocumentId.CreateNewId(project.Id); + newSolution = newSolution.AddAnalyzerConfigDocument( + documentId, + ".editorconfig", + SourceText.From(analyzerConfigText), + filePath: Path.Combine(projectRootFilePath, ".editorconfig")); + } + + workspace.TryApplyChanges(newSolution); + return; + + static string GenerateAnalyzerConfigText(IDictionary options) + { + var textBuilder = new StringBuilder(); + foreach (var (optionKey, value) in options) + { + foreach (var location in optionKey.Option.StorageLocations) + { + if (location is IEditorConfigStorageLocation2 editorConfigStorageLocation) + { + var editorConfigString = editorConfigStorageLocation.GetEditorConfigString(value, default); + if (editorConfigString != null) + { + textBuilder.AppendLine(GetSectionHeader(optionKey)); + textBuilder.AppendLine(editorConfigString); + textBuilder.AppendLine(); + break; + } + + Assert.False(true, "Unexpected non-editorconfig option"); + } + } + } + + return textBuilder.ToString(); + + static string GetSectionHeader(OptionKey optionKey) + { + if (optionKey.Option.IsPerLanguage) + { + switch (optionKey.Language) + { + case LanguageNames.CSharp: + return "[*.cs]"; + case LanguageNames.VisualBasic: + return "[*.vb]"; + } + } + + return "[*]"; + } + } } protected abstract TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters); + protected virtual TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters, string rootFilePath = null) + { + throw new NotImplementedException(); + } + private TestParameters WithRegularOptions(TestParameters parameters) => parameters.WithParseOptions(parameters.parseOptions?.WithKind(SourceCodeKind.Regular)); @@ -592,40 +670,40 @@ protected static ImmutableArray FlattenActions(ImmutableArray GetNestedActions(ImmutableArray codeActions) => codeActions.SelectMany(a => a.NestedCodeActions).ToImmutableArray(); - internal (OptionKey, object) SingleOption(Options.Option option, T enabled) + internal (OptionKey, object) SingleOption(Option option, T enabled) => (new OptionKey(option), enabled); - protected (OptionKey, object) SingleOption(Options.PerLanguageOption option, T value) + protected (OptionKey, object) SingleOption(PerLanguageOption option, T value) => (new OptionKey(option, this.GetLanguage()), value); - protected (OptionKey, object) SingleOption(Options.Option> option, T enabled, NotificationOption notification) - => SingleOption(option, new CodeStyle.CodeStyleOption(enabled, notification)); + protected (OptionKey, object) SingleOption(Option> option, T enabled, NotificationOption notification) + => SingleOption(option, new CodeStyleOption(enabled, notification)); - protected (OptionKey, object) SingleOption(Options.Option> option, CodeStyle.CodeStyleOption codeStyle) + protected (OptionKey, object) SingleOption(Option> option, CodeStyleOption codeStyle) => (new OptionKey(option), codeStyle); - protected (OptionKey, object) SingleOption(Options.PerLanguageOption> option, T enabled, NotificationOption notification) - => SingleOption(option, new CodeStyle.CodeStyleOption(enabled, notification)); + protected (OptionKey, object) SingleOption(PerLanguageOption> option, T enabled, NotificationOption notification) + => SingleOption(option, new CodeStyleOption(enabled, notification)); - protected (OptionKey, object) SingleOption(Options.PerLanguageOption> option, CodeStyle.CodeStyleOption codeStyle) + protected (OptionKey, object) SingleOption(PerLanguageOption> option, CodeStyleOption codeStyle) => SingleOption(option, codeStyle, language: GetLanguage()); - protected static (OptionKey, object) SingleOption(Options.PerLanguageOption> option, CodeStyle.CodeStyleOption codeStyle, string language) + protected static (OptionKey, object) SingleOption(PerLanguageOption> option, CodeStyleOption codeStyle, string language) => (new OptionKey(option, language), codeStyle); - protected IDictionary Option(Options.Option> option, T enabled, NotificationOption notification) + protected IDictionary Option(Option> option, T enabled, NotificationOption notification) => OptionsSet(SingleOption(option, enabled, notification)); - protected IDictionary Option(Options.Option> option, CodeStyle.CodeStyleOption codeStyle) + protected IDictionary Option(Option> option, CodeStyleOption codeStyle) => OptionsSet(SingleOption(option, codeStyle)); - protected IDictionary Option(Options.PerLanguageOption> option, T enabled, NotificationOption notification) + protected IDictionary Option(PerLanguageOption> option, T enabled, NotificationOption notification) => OptionsSet(SingleOption(option, enabled, notification)); - protected IDictionary Option(Options.PerLanguageOption option, T value) + protected IDictionary Option(PerLanguageOption option, T value) => OptionsSet(SingleOption(option, value)); - protected IDictionary Option(Options.PerLanguageOption> option, CodeStyle.CodeStyleOption codeStyle) + protected IDictionary Option(PerLanguageOption> option, CodeStyleOption codeStyle) => OptionsSet(SingleOption(option, codeStyle)); internal static IDictionary OptionsSet( diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs index d4e2527d9ad7f..1b9c99e47a051 100644 --- a/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs +++ b/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs @@ -2,10 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if CODE_STYLE -extern alias Workspaces; -#endif - using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; @@ -18,19 +14,17 @@ using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests.Diagnostics; using Roslyn.Test.Utilities; +using Roslyn.Utilities; using Xunit; -namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics -{ #if CODE_STYLE - using OptionKey = Workspaces::Microsoft.CodeAnalysis.Options.OptionKey; - using Workspaces::Roslyn.Utilities; - using static Workspaces::Microsoft.CodeAnalysis.ImmutableArrayExtensions; +using Microsoft.CodeAnalysis.Internal.Options; #else - using Microsoft.CodeAnalysis.Options; - using Roslyn.Utilities; +using Microsoft.CodeAnalysis.Options; #endif +namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics +{ public abstract partial class AbstractDiagnosticProviderBasedUserDiagnosticTest : AbstractUserDiagnosticTest { private readonly ConcurrentDictionary _analyzerAndFixerMap = diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs b/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs index f139cd696fd41..95c66312507b3 100644 --- a/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs +++ b/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs @@ -2,10 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if CODE_STYLE -extern alias Workspaces; -#endif - using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -17,24 +13,22 @@ using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests.Diagnostics; using Roslyn.Test.Utilities; +using Roslyn.Utilities; using Xunit; -namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics -{ #if CODE_STYLE - using OptionKey = Workspaces::Microsoft.CodeAnalysis.Options.OptionKey; - using FixAllState = Workspaces::Microsoft.CodeAnalysis.CodeFixes.FixAllState; - using Workspaces::Roslyn.Utilities; +using Microsoft.CodeAnalysis.Internal.Options; #else - using Roslyn.Utilities; +using Microsoft.CodeAnalysis.Options; #endif +namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics +{ public abstract partial class AbstractUserDiagnosticTest : AbstractCodeActionOrUserDiagnosticTest { internal abstract Task<(ImmutableArray, ImmutableArray, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( diff --git a/src/EditorFeatures/Test/EditAndContinue/EditSessionActiveStatementsTests.cs b/src/EditorFeatures/Test/EditAndContinue/EditSessionActiveStatementsTests.cs index 4720545ea87c0..48a64721bb7f2 100644 --- a/src/EditorFeatures/Test/EditAndContinue/EditSessionActiveStatementsTests.cs +++ b/src/EditorFeatures/Test/EditAndContinue/EditSessionActiveStatementsTests.cs @@ -50,7 +50,7 @@ internal static ImmutableArray GetActiveStatementDebug var sourceIndex = 0; foreach (var markedSource in markedSources) { - var documentName = TestWorkspace.GetDefaultTestSourceDocumentName(sourceIndex, extension); + var documentName = TestWorkspace.GetDefaultTestSourceDocumentName(sourceIndex, extension, rootFilePath: null); var documentId = DocumentId.CreateNewId(ProjectId.CreateNewId(), documentName); var text = SourceText.From(markedSource); diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs index 35a6c8343268c..af9059ed2cbba 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs @@ -341,7 +341,7 @@ protected override void ApplyAnalyzerConfigDocumentTextChanged(DocumentId docume protected override void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) { var hostProject = this.GetTestProject(info.Id.ProjectId); - var hostDocument = new TestHostDocument(text.ToString(), info.Name, id: info.Id); + var hostDocument = new TestHostDocument(text.ToString(), info.Name, id: info.Id, filePath: info.FilePath, folders: info.Folders); hostProject.AddAnalyzerConfigDocument(hostDocument); this.OnAnalyzerConfigDocumentAdded(hostDocument.ToDocumentInfo()); } diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs index e36438d51adf6..5ca6b69253a30 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs @@ -5,14 +5,10 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; -using System.Threading; -using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.VisualStudio.Composition; -using Microsoft.VisualStudio.Text; -using Microsoft.VisualStudio.Utilities; -using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces { @@ -134,8 +130,11 @@ internal static TestWorkspace Create( return Create(language, compilationOptions, parseOptions, files, exportProvider: null, workspaceKind: workspaceKind); } - internal static string GetDefaultTestSourceDocumentName(int index, string extension) - => "test" + (index + 1) + extension; + internal static string GetDefaultTestSourceDocumentName(int index, string extension, string rootFilePath) + { + var fileName = "test" + (index + 1) + extension; + return rootFilePath != null ? Path.Combine(rootFilePath, fileName) : fileName; + } internal static TestWorkspace Create( string language, @@ -146,6 +145,7 @@ internal static TestWorkspace Create( string[] metadataReferences = null, string workspaceKind = null, string extension = null, + string rootFilePath = null, bool commonReferences = true, bool openDocuments = false) { @@ -161,7 +161,7 @@ internal static TestWorkspace Create( foreach (var file in files) { - documentElements.Add(CreateDocumentElement(file, GetDefaultTestSourceDocumentName(index++, extension), parseOptions)); + documentElements.Add(CreateDocumentElement(file, GetDefaultTestSourceDocumentName(index++, extension, rootFilePath), parseOptions)); } metadataReferences = metadataReferences ?? Array.Empty(); @@ -171,7 +171,7 @@ internal static TestWorkspace Create( } var workspaceElement = CreateWorkspaceElement( - CreateProjectElement(compilationOptions?.ModuleName ?? "Test", language, commonReferences, parseOptions, compilationOptions, documentElements)); + CreateProjectElement(compilationOptions?.ModuleName ?? "Test", language, commonReferences, parseOptions, compilationOptions, rootFilePath, documentElements)); return Create(workspaceElement, openDocuments: openDocuments, exportProvider: exportProvider, workspaceKind: workspaceKind); } @@ -181,7 +181,8 @@ internal static TestWorkspace Create( CompilationOptions compilationOptions, ParseOptions[] parseOptions, string[] files, - ExportProvider exportProvider) + ExportProvider exportProvider, + string rootFilePath = null) { Debug.Assert(parseOptions == null || (files.Length == parseOptions.Length), "Please specify a parse option for each file."); @@ -208,11 +209,11 @@ internal static TestWorkspace Create( extension = language; } - documentElements.Add(CreateDocumentElement(files[i], GetDefaultTestSourceDocumentName(index++, extension), parseOptions == null ? null : parseOptions[i])); + documentElements.Add(CreateDocumentElement(files[i], GetDefaultTestSourceDocumentName(index++, extension, rootFilePath), parseOptions == null ? null : parseOptions[i])); } var workspaceElement = CreateWorkspaceElement( - CreateProjectElement("Test", language, true, parseOptions.FirstOrDefault(), compilationOptions, documentElements)); + CreateProjectElement("Test", language, true, parseOptions.FirstOrDefault(), compilationOptions, rootFilePath, documentElements)); return Create(workspaceElement, exportProvider: exportProvider); } @@ -225,9 +226,10 @@ public static TestWorkspace CreateCSharp( CompilationOptions compilationOptions = null, ExportProvider exportProvider = null, string[] metadataReferences = null, + string rootFilePath = null, bool openDocuments = false) { - return CreateCSharp(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences, openDocuments); + return CreateCSharp(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences, rootFilePath, openDocuments); } public static TestWorkspace CreateCSharp( @@ -236,9 +238,10 @@ public static TestWorkspace CreateCSharp( CompilationOptions compilationOptions = null, ExportProvider exportProvider = null, string[] metadataReferences = null, + string rootFilePath = null, bool openDocuments = false) { - return Create(LanguageNames.CSharp, compilationOptions, parseOptions, files, exportProvider, metadataReferences, openDocuments: openDocuments); + return Create(LanguageNames.CSharp, compilationOptions, parseOptions, files, exportProvider, metadataReferences, rootFilePath: rootFilePath, openDocuments: openDocuments); } public static TestWorkspace CreateCSharp2( @@ -260,9 +263,10 @@ public static TestWorkspace CreateVisualBasic( CompilationOptions compilationOptions = null, ExportProvider exportProvider = null, string[] metadataReferences = null, + string rootFilePath = null, bool openDocuments = false) { - return CreateVisualBasic(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences, openDocuments); + return CreateVisualBasic(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences, rootFilePath, openDocuments); } public static TestWorkspace CreateVisualBasic( @@ -271,9 +275,10 @@ public static TestWorkspace CreateVisualBasic( CompilationOptions compilationOptions = null, ExportProvider exportProvider = null, string[] metadataReferences = null, + string rootFilePath = null, bool openDocuments = false) { - return Create(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider, metadataReferences, openDocuments: openDocuments); + return Create(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider, metadataReferences, openDocuments: openDocuments, rootFilePath: rootFilePath); } /// Can pass in multiple file contents with individual source kind: files will be named test1.vb, test2.vbx, etc. diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs index 65546b73a0645..f4592f567159b 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs @@ -2,9 +2,9 @@ // 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.IO; using System.Linq; using System.Xml.Linq; -using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces @@ -23,8 +23,17 @@ protected static XElement CreateProjectElement( bool commonReferences, ParseOptions parseOptions, CompilationOptions compilationOptions, + string rootFilePath, params object[] elements) { + string filePath = null; + if (rootFilePath != null) + { + filePath = Path.Combine(rootFilePath, assemblyName + + (language == LanguageNames.CSharp ? ".csproj" : + language == LanguageNames.VisualBasic ? ".vbproj" : ("." + language))); + } + return new XElement(ProjectElementName, new XAttribute(AssemblyNameAttributeName, assemblyName), new XAttribute(LanguageAttributeName, language), @@ -33,6 +42,7 @@ protected static XElement CreateProjectElement( parseOptions == null ? null : CreateDocumentationModeAttribute(parseOptions), parseOptions == null ? null : CreateFeaturesAttribute(parseOptions), compilationOptions == null ? null : CreateCompilationOptionsElement(compilationOptions), + filePath == null ? null : new XAttribute(FilePathAttributeName, filePath), elements); } diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb index b4be17b788a7d..45dbddf133956 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb @@ -2,7 +2,6 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Xml.Linq Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics Imports Microsoft.CodeAnalysis.CodeActions @@ -20,10 +19,15 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics End Function Protected Overrides Function CreateWorkspaceFromFile(initialMarkup As String, parameters As TestParameters) As TestWorkspace + Return CreateWorkspaceFromFile(initialMarkup, parameters, rootFilePath:=Nothing) + End Function + + Protected Overrides Function CreateWorkspaceFromFile(initialMarkup As String, parameters As TestParameters, Optional rootFilePath As String = Nothing) As TestWorkspace Return TestWorkspace.CreateVisualBasic( initialMarkup, parameters.parseOptions, - If(parameters.compilationOptions, New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary))) + If(parameters.compilationOptions, New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary)), + rootFilePath:=rootFilePath) End Function Friend Overloads Async Function TestAsync( diff --git a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs index 4fd18602ef437..6154bc3958291 100644 --- a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs +++ b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs @@ -92,6 +92,10 @@ public static (string analyzerId, VersionStamp version) GetAnalyzerIdAndVersion( public static string GetAnalyzerAssemblyName(this DiagnosticAnalyzer analyzer) => analyzer.GetType().Assembly.GetName().Name; + [PerformanceSensitive("https://github.com/dotnet/roslyn/issues/23582", OftenCompletesSynchronously = true)] + public static OptionSet? GetOptions(this AnalyzerOptions analyzerOptions, SyntaxTree syntaxTree, CancellationToken cancellationToken) + => analyzerOptions.GetDocumentOptionSetAsync(syntaxTree, cancellationToken).GetAwaiter().GetResult(); + [PerformanceSensitive("https://github.com/dotnet/roslyn/issues/23582", OftenCompletesSynchronously = true)] public static ValueTask GetDocumentOptionSetAsync(this AnalyzerOptions analyzerOptions, SyntaxTree syntaxTree, CancellationToken cancellationToken) { diff --git a/src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.cs b/src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.cs index 27615c20a3fa8..74c865acca872 100644 --- a/src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.cs +++ b/src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.cs @@ -4,12 +4,14 @@ using System.Collections.Immutable; using System.Diagnostics; -using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; #if CODE_STYLE using CSharpWorkspaceResources = Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources; using WorkspacesResources = Microsoft.CodeAnalysis.CodeStyleResources; +using Microsoft.CodeAnalysis.Internal.Options; +#else +using Microsoft.CodeAnalysis.Options; #endif namespace Microsoft.CodeAnalysis.CSharp.Formatting diff --git a/src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs b/src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs index 3534a7af95560..1cdc8ae54e74d 100644 --- a/src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs +++ b/src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs @@ -7,7 +7,6 @@ using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; diff --git a/src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs b/src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs index a253695849020..f9041017047ef 100644 --- a/src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs +++ b/src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs @@ -7,10 +7,12 @@ using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Formatting.Rules; -using Microsoft.CodeAnalysis.Options; #if CODE_STYLE using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +using Microsoft.CodeAnalysis.Internal.Options; +#else +using Microsoft.CodeAnalysis.Options; #endif namespace Microsoft.CodeAnalysis.CSharp.Formatting diff --git a/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs b/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs index 26e0c69bc9521..082bd6897f08d 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs @@ -17,8 +17,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes /// Represents a single fix. This is essentially a tuple /// that holds on to a and the set of /// s that this will fix. - /// - /// + // internal sealed class CodeFix { internal readonly Project Project; diff --git a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOption.cs b/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOption.cs index c74089720b38d..f3e47026ab3f2 100644 --- a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOption.cs +++ b/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOption.cs @@ -7,7 +7,11 @@ using System.Xml.Linq; using Microsoft.CodeAnalysis.Diagnostics; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { internal interface ICodeStyleOption { diff --git a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs b/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs index 3f514a21bf4a3..6ffa9630a5b12 100644 --- a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs +++ b/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs @@ -4,12 +4,25 @@ using System.Collections.Immutable; using System.Diagnostics; -using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; using static Microsoft.CodeAnalysis.CodeStyle.CodeStyleHelpers; +#if CODE_STYLE +using Resources = Microsoft.CodeAnalysis.CodeStyleResources; +#else +using Microsoft.CodeAnalysis.Options; +using Resources = Microsoft.CodeAnalysis.WorkspacesResources; +#endif + +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { + /// + /// Code style options + /// public class CodeStyleOptions { private static readonly ImmutableArray.Builder s_allOptionsBuilder = ImmutableArray.CreateBuilder(); @@ -403,13 +416,13 @@ private static string GetUnusedParametersPreferenceEditorConfigString(CodeStyleO internal static class CodeStyleOptionGroups { - public static readonly OptionGroup Usings = new OptionGroup(WorkspacesResources.Organize_usings, priority: 1); - public static readonly OptionGroup ThisOrMe = new OptionGroup(WorkspacesResources.this_dot_and_Me_dot_preferences, priority: 2); - public static readonly OptionGroup PredefinedTypeNameUsage = new OptionGroup(WorkspacesResources.Language_keywords_vs_BCL_types_preferences, priority: 3); - public static readonly OptionGroup Parentheses = new OptionGroup(WorkspacesResources.Parentheses_preferences, priority: 4); - public static readonly OptionGroup Modifier = new OptionGroup(WorkspacesResources.Modifier_preferences, priority: 5); - public static readonly OptionGroup ExpressionLevelPreferences = new OptionGroup(WorkspacesResources.Expression_level_preferences, priority: 6); - public static readonly OptionGroup Field = new OptionGroup(WorkspacesResources.Field_preferences, priority: 7); - public static readonly OptionGroup Parameter = new OptionGroup(WorkspacesResources.Parameter_preferences, priority: 8); + public static readonly OptionGroup Usings = new OptionGroup(Resources.Organize_usings, priority: 1); + public static readonly OptionGroup ThisOrMe = new OptionGroup(Resources.this_dot_and_Me_dot_preferences, priority: 2); + public static readonly OptionGroup PredefinedTypeNameUsage = new OptionGroup(Resources.Language_keywords_vs_BCL_types_preferences, priority: 3); + public static readonly OptionGroup Parentheses = new OptionGroup(Resources.Parentheses_preferences, priority: 4); + public static readonly OptionGroup Modifier = new OptionGroup(Resources.Modifier_preferences, priority: 5); + public static readonly OptionGroup ExpressionLevelPreferences = new OptionGroup(Resources.Expression_level_preferences, priority: 6); + public static readonly OptionGroup Field = new OptionGroup(Resources.Field_preferences, priority: 7); + public static readonly OptionGroup Parameter = new OptionGroup(Resources.Parameter_preferences, priority: 8); } } diff --git a/src/Workspaces/Core/Portable/CodeStyle/NotificationOption.cs b/src/Workspaces/Core/Portable/CodeStyle/NotificationOption.cs index dc9e6b9843b98..0e12008f38485 100644 --- a/src/Workspaces/Core/Portable/CodeStyle/NotificationOption.cs +++ b/src/Workspaces/Core/Portable/CodeStyle/NotificationOption.cs @@ -7,9 +7,11 @@ #if CODE_STYLE using WorkspacesResources = Microsoft.CodeAnalysis.CodeStyleResources; -#endif +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { /// /// Offers different notification styles for enforcing diff --git a/src/Workspaces/Core/Portable/Formatting/AbstractSyntaxFormattingService.cs b/src/Workspaces/Core/Portable/Formatting/AbstractSyntaxFormattingService.cs index 24e6afdc6d387..e34935543c36d 100644 --- a/src/Workspaces/Core/Portable/Formatting/AbstractSyntaxFormattingService.cs +++ b/src/Workspaces/Core/Portable/Formatting/AbstractSyntaxFormattingService.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.Formatting.Rules; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared; using Microsoft.CodeAnalysis.Shared.Collections; using Microsoft.CodeAnalysis.Shared.Utilities; @@ -16,6 +15,8 @@ #if CODE_STYLE using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +#else +using Microsoft.CodeAnalysis.Options; #endif namespace Microsoft.CodeAnalysis.Formatting diff --git a/src/Workspaces/Core/Portable/Formatting/Engine/AbstractFormatEngine.cs b/src/Workspaces/Core/Portable/Formatting/Engine/AbstractFormatEngine.cs index 3b729112cff5e..46315e375de31 100644 --- a/src/Workspaces/Core/Portable/Formatting/Engine/AbstractFormatEngine.cs +++ b/src/Workspaces/Core/Portable/Formatting/Engine/AbstractFormatEngine.cs @@ -8,7 +8,6 @@ using System.Threading; using Microsoft.CodeAnalysis.Formatting.Rules; using Microsoft.CodeAnalysis.Internal.Log; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Text; @@ -16,6 +15,9 @@ #if CODE_STYLE using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +using Microsoft.CodeAnalysis.Internal.Options; +#else +using Microsoft.CodeAnalysis.Options; #endif namespace Microsoft.CodeAnalysis.Formatting diff --git a/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.FormattedWhitespace.cs b/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.FormattedWhitespace.cs index 0bbbcdab64e02..9888e62ccf583 100644 --- a/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.FormattedWhitespace.cs +++ b/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.FormattedWhitespace.cs @@ -5,12 +5,13 @@ using System; using System.Collections.Generic; using System.Threading; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; #if CODE_STYLE using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +#else +using Microsoft.CodeAnalysis.Options; #endif namespace Microsoft.CodeAnalysis.Formatting diff --git a/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.ModifiedWhitespace.cs b/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.ModifiedWhitespace.cs index ff75885a22ebd..10fbeadbc0f9b 100644 --- a/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.ModifiedWhitespace.cs +++ b/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.ModifiedWhitespace.cs @@ -4,11 +4,12 @@ using System; using System.Threading; -using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; #if CODE_STYLE using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +#else +using Microsoft.CodeAnalysis.Options; #endif namespace Microsoft.CodeAnalysis.Formatting diff --git a/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.cs b/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.cs index a67ed32558054..b46349b1778a3 100644 --- a/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.cs +++ b/src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.cs @@ -3,11 +3,12 @@ // See the LICENSE file in the project root for more information. using System.Threading; -using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; #if CODE_STYLE using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +#else +using Microsoft.CodeAnalysis.Options; #endif namespace Microsoft.CodeAnalysis.Formatting diff --git a/src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs b/src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs index 2eb34fdd956d3..2344bb58e492f 100644 --- a/src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs +++ b/src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs @@ -4,11 +4,13 @@ using System; using System.Collections.Immutable; -using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; #if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; using WorkspacesResources = Microsoft.CodeAnalysis.CodeStyleResources; +#else +using Microsoft.CodeAnalysis.Options; #endif namespace Microsoft.CodeAnalysis.Formatting diff --git a/src/Workspaces/Core/Portable/Log/FunctionIdOptions.cs b/src/Workspaces/Core/Portable/Log/FunctionIdOptions.cs index be6303b0b0aa5..2179e564f8c60 100644 --- a/src/Workspaces/Core/Portable/Log/FunctionIdOptions.cs +++ b/src/Workspaces/Core/Portable/Log/FunctionIdOptions.cs @@ -4,7 +4,12 @@ using System; using System.Collections.Concurrent; + +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; +#else using Microsoft.CodeAnalysis.Options; +#endif namespace Microsoft.CodeAnalysis.Internal.Log { diff --git a/src/Workspaces/Core/Portable/Log/Logger.cs b/src/Workspaces/Core/Portable/Log/Logger.cs index 09a7e2ad911bc..4e6e3886d5bdf 100644 --- a/src/Workspaces/Core/Portable/Log/Logger.cs +++ b/src/Workspaces/Core/Portable/Log/Logger.cs @@ -5,7 +5,12 @@ using System; using System.Linq; using System.Threading; + +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; +#else using Microsoft.CodeAnalysis.Options; +#endif namespace Microsoft.CodeAnalysis.Internal.Log { diff --git a/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocation.cs b/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocation.cs index 764982f987601..eb345fae2d298 100644 --- a/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocation.cs +++ b/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocation.cs @@ -5,7 +5,11 @@ using System; using Microsoft.CodeAnalysis.CodeStyle; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { internal static class EditorConfigStorageLocation { diff --git a/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocation`1.cs b/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocation`1.cs index 99d97e65ede68..cc470ebfeb410 100644 --- a/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocation`1.cs +++ b/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocation`1.cs @@ -9,9 +9,11 @@ #if CODE_STYLE using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; -#endif +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { /// /// Specifies that an option should be read from an .editorconfig file. diff --git a/src/Workspaces/Core/Portable/Options/EditorConfig/IEditorConfigStorageLocation.cs b/src/Workspaces/Core/Portable/Options/EditorConfig/IEditorConfigStorageLocation.cs index 0589c03cc014f..ff32aae74cc22 100644 --- a/src/Workspaces/Core/Portable/Options/EditorConfig/IEditorConfigStorageLocation.cs +++ b/src/Workspaces/Core/Portable/Options/EditorConfig/IEditorConfigStorageLocation.cs @@ -5,9 +5,15 @@ using System; using System.Collections.Generic; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +{ + public interface IEditorConfigStorageLocation +#else namespace Microsoft.CodeAnalysis.Options { internal interface IEditorConfigStorageLocation +#endif { bool TryGetOption(IReadOnlyDictionary rawOptions, Type type, out object value); } diff --git a/src/Workspaces/Core/Portable/Options/EditorConfig/IEditorConfigStorageLocation2.cs b/src/Workspaces/Core/Portable/Options/EditorConfig/IEditorConfigStorageLocation2.cs index ce4a65dcf620f..71f8ba19d0134 100644 --- a/src/Workspaces/Core/Portable/Options/EditorConfig/IEditorConfigStorageLocation2.cs +++ b/src/Workspaces/Core/Portable/Options/EditorConfig/IEditorConfigStorageLocation2.cs @@ -4,11 +4,15 @@ #if CODE_STYLE using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; -#endif +namespace Microsoft.CodeAnalysis.Internal.Options +{ + public interface IEditorConfigStorageLocation2 : IEditorConfigStorageLocation +#else namespace Microsoft.CodeAnalysis.Options { internal interface IEditorConfigStorageLocation2 : IEditorConfigStorageLocation +#endif { /// /// Gets the editorconfig string representation for this storage location. diff --git a/src/Workspaces/Core/Portable/Options/IOption.cs b/src/Workspaces/Core/Portable/Options/IOption.cs index e515933f6158b..e34e0f10bacdb 100644 --- a/src/Workspaces/Core/Portable/Options/IOption.cs +++ b/src/Workspaces/Core/Portable/Options/IOption.cs @@ -7,7 +7,11 @@ using System; using System.Collections.Immutable; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { public interface IOption { diff --git a/src/Workspaces/Core/Portable/Options/IOptionWithGroup.cs b/src/Workspaces/Core/Portable/Options/IOptionWithGroup.cs index f14f9bc04d76f..0381b5811bb57 100644 --- a/src/Workspaces/Core/Portable/Options/IOptionWithGroup.cs +++ b/src/Workspaces/Core/Portable/Options/IOptionWithGroup.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { /// /// Group/sub-feature associated with an . diff --git a/src/Workspaces/Core/Portable/Options/LocalUserProfileStorageLocation.cs b/src/Workspaces/Core/Portable/Options/LocalUserProfileStorageLocation.cs index 0c44a1a45c797..a5c42ad82ed7e 100644 --- a/src/Workspaces/Core/Portable/Options/LocalUserProfileStorageLocation.cs +++ b/src/Workspaces/Core/Portable/Options/LocalUserProfileStorageLocation.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { /// /// Specifies that the option should be stored into the user's local registry hive. diff --git a/src/Workspaces/Core/Portable/Options/OptionGroup.cs b/src/Workspaces/Core/Portable/Options/OptionGroup.cs index e41cc18e3dee6..4fe35d7cf2c7b 100644 --- a/src/Workspaces/Core/Portable/Options/OptionGroup.cs +++ b/src/Workspaces/Core/Portable/Options/OptionGroup.cs @@ -4,7 +4,11 @@ using System; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { /// /// Group/sub-feature associated with an . diff --git a/src/Workspaces/Core/Portable/Options/OptionKey.cs b/src/Workspaces/Core/Portable/Options/OptionKey.cs index 4900d0e910b5d..4f1a22559a773 100644 --- a/src/Workspaces/Core/Portable/Options/OptionKey.cs +++ b/src/Workspaces/Core/Portable/Options/OptionKey.cs @@ -8,8 +8,15 @@ using WorkspacesResources = Microsoft.CodeAnalysis.CodeStyleResources; #endif +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { + /// + /// Option key. + /// public readonly struct OptionKey : IEquatable { public IOption Option { get; } diff --git a/src/Workspaces/Core/Portable/Options/OptionStorageLocation.cs b/src/Workspaces/Core/Portable/Options/OptionStorageLocation.cs index 14c7cf93197b0..4bd602d00ddcf 100644 --- a/src/Workspaces/Core/Portable/Options/OptionStorageLocation.cs +++ b/src/Workspaces/Core/Portable/Options/OptionStorageLocation.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { /// /// The base type of all types that specify where options are stored. diff --git a/src/Workspaces/Core/Portable/Options/Option`1.cs b/src/Workspaces/Core/Portable/Options/Option`1.cs index b2536e9e3e3a4..741949da71a8b 100644 --- a/src/Workspaces/Core/Portable/Options/Option`1.cs +++ b/src/Workspaces/Core/Portable/Options/Option`1.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Immutable; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { /// /// Marker interface for diff --git a/src/Workspaces/Core/Portable/Options/PerLanguageOption.cs b/src/Workspaces/Core/Portable/Options/PerLanguageOption.cs index 65de2989be7a8..86f6a4347a142 100644 --- a/src/Workspaces/Core/Portable/Options/PerLanguageOption.cs +++ b/src/Workspaces/Core/Portable/Options/PerLanguageOption.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Immutable; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { /// /// Marker interface for diff --git a/src/Workspaces/Core/Portable/Options/RoamingProfileStorageLocation.cs b/src/Workspaces/Core/Portable/Options/RoamingProfileStorageLocation.cs index b58886bba9aa4..dbb40b9df4c16 100644 --- a/src/Workspaces/Core/Portable/Options/RoamingProfileStorageLocation.cs +++ b/src/Workspaces/Core/Portable/Options/RoamingProfileStorageLocation.cs @@ -4,7 +4,11 @@ using System; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.Options +#endif { /// /// Specifies that the option should be stored into a roamed profile across machines. diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems index 6507f283d7914..899f375826343 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems @@ -9,7 +9,11 @@ Microsoft.CodeAnalysis.CSharp.Shared + + + + diff --git a/src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions.cs similarity index 96% rename from src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions.cs index 8c29fc9ee5505..e7b853ed60b75 100644 --- a/src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions.cs @@ -7,10 +7,23 @@ using System.Linq; using Microsoft.CodeAnalysis.AddImports; using Microsoft.CodeAnalysis.CodeStyle; + +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; +using CSharpResources = Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources; +using Resources = Microsoft.CodeAnalysis.CodeStyleResources; + +namespace Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle +{ +#else using Microsoft.CodeAnalysis.Options; +using CSharpResources = Microsoft.CodeAnalysis.CSharp.CSharpWorkspaceResources; +using Resources = Microsoft.CodeAnalysis.WorkspacesResources; namespace Microsoft.CodeAnalysis.CSharp.CodeStyle { +#endif + internal static partial class CSharpCodeStyleOptions { private static readonly ImmutableArray.Builder s_allOptionsBuilder = ImmutableArray.CreateBuilder(); @@ -330,13 +343,13 @@ public static IEnumerable>> Get internal static class CSharpCodeStyleOptionGroups { - public static readonly OptionGroup VarPreferences = new OptionGroup(CSharpWorkspaceResources.var_preferences, priority: 1); - public static readonly OptionGroup ExpressionBodiedMembers = new OptionGroup(CSharpWorkspaceResources.Expression_bodied_members, priority: 2); - public static readonly OptionGroup PatternMatching = new OptionGroup(CSharpWorkspaceResources.Pattern_matching_preferences, priority: 3); - public static readonly OptionGroup NullCheckingPreferences = new OptionGroup(CSharpWorkspaceResources.Null_checking_preferences, priority: 4); - public static readonly OptionGroup Modifier = new OptionGroup(WorkspacesResources.Modifier_preferences, priority: 5); - public static readonly OptionGroup CodeBlockPreferences = new OptionGroup(CSharpWorkspaceResources.Code_block_preferences, priority: 6); - public static readonly OptionGroup ExpressionLevelPreferences = new OptionGroup(WorkspacesResources.Expression_level_preferences, priority: 7); - public static readonly OptionGroup UsingDirectivePreferences = new OptionGroup(CSharpWorkspaceResources.using_directive_preferences, priority: 8); + public static readonly OptionGroup VarPreferences = new OptionGroup(CSharpResources.var_preferences, priority: 1); + public static readonly OptionGroup ExpressionBodiedMembers = new OptionGroup(CSharpResources.Expression_bodied_members, priority: 2); + public static readonly OptionGroup PatternMatching = new OptionGroup(CSharpResources.Pattern_matching_preferences, priority: 3); + public static readonly OptionGroup NullCheckingPreferences = new OptionGroup(CSharpResources.Null_checking_preferences, priority: 4); + public static readonly OptionGroup Modifier = new OptionGroup(Resources.Modifier_preferences, priority: 5); + public static readonly OptionGroup CodeBlockPreferences = new OptionGroup(CSharpResources.Code_block_preferences, priority: 6); + public static readonly OptionGroup ExpressionLevelPreferences = new OptionGroup(Resources.Expression_level_preferences, priority: 7); + public static readonly OptionGroup UsingDirectivePreferences = new OptionGroup(CSharpResources.using_directive_preferences, priority: 8); } } diff --git a/src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions_Parsing.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions_Parsing.cs similarity index 97% rename from src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions_Parsing.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions_Parsing.cs index 0efaca9afb543..19b015cfd65bc 100644 --- a/src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions_Parsing.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions_Parsing.cs @@ -3,13 +3,18 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics; using Microsoft.CodeAnalysis.AddImports; using Microsoft.CodeAnalysis.CodeStyle; using Roslyn.Utilities; +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; +namespace Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle +{ +#else namespace Microsoft.CodeAnalysis.CSharp.CodeStyle { +#endif internal static partial class CSharpCodeStyleOptions { public static CodeStyleOption ParseExpressionBodyPreference( diff --git a/src/Workspaces/CSharp/Portable/CodeStyle/PreferBracesPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/PreferBracesPreference.cs similarity index 96% rename from src/Workspaces/CSharp/Portable/CodeStyle/PreferBracesPreference.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/PreferBracesPreference.cs index 364fe8c6aff6e..1659fcf038ecf 100644 --- a/src/Workspaces/CSharp/Portable/CodeStyle/PreferBracesPreference.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/PreferBracesPreference.cs @@ -3,10 +3,17 @@ // See the LICENSE file in the project root for more information. using System.Xml.Linq; -using Microsoft.CodeAnalysis.CSharp.CodeStyle; +#if CODE_STYLE +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle; +namespace Microsoft.CodeAnalysis.Internal.Options +{ +#else +using Microsoft.CodeAnalysis.CSharp.CodeStyle; namespace Microsoft.CodeAnalysis.CodeStyle { +#endif + /// /// Defines the known values for . /// diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/StatementSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/StatementSyntaxExtensions.cs similarity index 88% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/StatementSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/StatementSyntaxExtensions.cs index 921259f276525..a4352efbe332a 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/StatementSyntaxExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/StatementSyntaxExtensions.cs @@ -3,13 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Linq; -using System.Threading; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Simplification; -using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.CSharp.Extensions { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/AccessibilityModifiersRequired.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/AccessibilityModifiersRequired.cs index 74d8b24866f7d..6a25c279338e5 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/AccessibilityModifiersRequired.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/AccessibilityModifiersRequired.cs @@ -3,7 +3,11 @@ // See the LICENSE file in the project root for more information. +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { internal enum AccessibilityModifiersRequired { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/CodeStyleHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/CodeStyleHelpers.cs index 5915985e7e315..1fd89bd98c768 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/CodeStyleHelpers.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/CodeStyleHelpers.cs @@ -4,9 +4,14 @@ using System.Collections.Immutable; using System.Diagnostics; -using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; +#else +using Microsoft.CodeAnalysis.Options; +#endif + namespace Microsoft.CodeAnalysis.CodeStyle { internal static class CodeStyleHelpers diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ExpressionBodyPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ExpressionBodyPreference.cs index 2a004f7a61ded..6843bf94cb254 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ExpressionBodyPreference.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ExpressionBodyPreference.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { /// /// Note: the order of this enum is important. We originally only supported two values, diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/OperatorPlacementWhenWrappingPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/OperatorPlacementWhenWrappingPreference.cs index 21ecdb8ffd6ef..9b5b937c1f649 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/OperatorPlacementWhenWrappingPreference.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/OperatorPlacementWhenWrappingPreference.cs @@ -4,7 +4,12 @@ using System; +#if CODE_STYLE +using Microsoft.CodeAnalysis.CodeStyle; +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { internal enum OperatorPlacementWhenWrappingPreference { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ParenthesesPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ParenthesesPreference.cs index bf4329b68e49e..6970e23020272 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ParenthesesPreference.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/ParenthesesPreference.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { internal enum ParenthesesPreference { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedParametersPreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedParametersPreference.cs index cd7e60efe4c66..27cd378da918d 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedParametersPreference.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedParametersPreference.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { /// /// Preferences for flagging unused parameters. diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedValuePreference.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedValuePreference.cs index 2cdfec4075136..9d3e400466788 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedValuePreference.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/UnusedValuePreference.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { /// /// Assignment preference for unused values from expression statements and assignments. diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 9c7830dcaba27..9813fff26aca7 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -165,7 +165,7 @@ InternalUtilities\ReflectionUtilities.cs - + InternalUtilities\UnicodeCharacterUtilities.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/NotificationOptionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/NotificationOptionExtensions.cs index d1214fed96a68..fae1a025fab05 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/NotificationOptionExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/NotificationOptionExtensions.cs @@ -4,7 +4,11 @@ using Microsoft.CodeAnalysis.Diagnostics; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.Internal.Options +#else namespace Microsoft.CodeAnalysis.CodeStyle +#endif { internal static class NotificationOptionExtensions { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems index 02f6a224c054f..81fbe939e47b1 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems @@ -46,7 +46,6 @@ - diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BlockSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BlockSyntaxExtensions.cs index 1f48ca6655d08..d23e8b9b86ca2 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BlockSyntaxExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/BlockSyntaxExtensions.cs @@ -2,14 +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.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; +#endif + namespace Microsoft.CodeAnalysis.CSharp.Extensions { internal static class BlockSyntaxExtensions diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs index bc9ae3ba3cf79..465b52bf00c72 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs @@ -14,8 +14,6 @@ namespace Microsoft.CodeAnalysis.CSharp.Extensions { - using OptionSet = Options.OptionSet; - internal static partial class ExpressionSyntaxExtensions { public static ExpressionSyntax WalkUpParentheses(this ExpressionSyntax expression) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs index 2ea70226d04d2..2f05905316c49 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs @@ -293,7 +293,7 @@ public override TypeSyntax VisitNamespace(INamespaceSymbol symbol) /// /// We always unilaterally add "global::" to all named types/namespaces. This /// will then be trimmed off if possible by calls to - /// + /// /// private TypeSyntax AddGlobalAlias(INamespaceOrTypeSymbol symbol, SimpleNameSyntax syntax) { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs index 9a378d8afb235..804367e724404 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs @@ -3,13 +3,18 @@ // See the LICENSE file in the project root for more information. using System.Linq; -using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Simplification { - using OptionSet = Options.OptionSet; +#if CODE_STYLE + using Microsoft.CodeAnalysis.Internal.Options; + using OptionSet = Diagnostics.AnalyzerConfigOptions; +#else + using Microsoft.CodeAnalysis.CodeStyle; + using Microsoft.CodeAnalysis.Options; +#endif internal static class SimplificationHelpers { From df116e9fea5c53d5ed1fe16a231492e3a54dd446 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Sat, 1 Feb 2020 22:25:02 -0800 Subject: [PATCH 04/26] Port C# type style analyzers (UseImplicitOrExplicitType) to code style layer --- .../Analyzers/CSharpAnalyzers.projitems | 3 + .../CSharpTypeStyleDiagnosticAnalyzerBase.cs | 13 +- ...CSharpUseExplicitTypeDiagnosticAnalyzer.cs | 10 +- ...CSharpUseImplicitTypeDiagnosticAnalyzer.cs | 10 +- .../CodeFixes/CSharpCodeFixes.projitems | 2 + .../UseExplicitTypeCodeFixProvider.cs | 12 +- .../UseImplicitTypeCodeFixProvider.cs | 12 +- .../Tests/CSharpAnalyzers.UnitTests.projitems | 4 + .../UseExplicitTypeTests.cs | 12 +- .../UseExplicitTypeTests_FixAllTests.cs | 1 - .../UseImplicitTypeTests.cs | 12 +- .../UseImplicitTypeTests_FixAllTests.cs | 1 - .../CSharpCodeStyleResources.Designer.cs | 36 + .../Analyzers/CSharpCodeStyleResources.resx | 12 + .../xlf/CSharpCodeStyleResources.cs.xlf | 20 + .../xlf/CSharpCodeStyleResources.de.xlf | 20 + .../xlf/CSharpCodeStyleResources.es.xlf | 20 + .../xlf/CSharpCodeStyleResources.fr.xlf | 20 + .../xlf/CSharpCodeStyleResources.it.xlf | 20 + .../xlf/CSharpCodeStyleResources.ja.xlf | 20 + .../xlf/CSharpCodeStyleResources.ko.xlf | 20 + .../xlf/CSharpCodeStyleResources.pl.xlf | 20 + .../xlf/CSharpCodeStyleResources.pt-BR.xlf | 20 + .../xlf/CSharpCodeStyleResources.ru.xlf | 20 + .../xlf/CSharpCodeStyleResources.tr.xlf | 20 + .../xlf/CSharpCodeStyleResources.zh-Hans.xlf | 20 + .../xlf/CSharpCodeStyleResources.zh-Hant.xlf | 20 + .../Core/Analyzers/Formatting/Formatter.cs | 3 +- .../Analyzers/FormattingAnalyzerHelper.cs | 1 + .../Core/CodeFixes/FormattingCodeFixHelper.cs | 2 +- .../CodeFixes/FormattingCodeFixProvider.cs | 2 +- ...agnosticProviderBasedUserDiagnosticTest.cs | 4 +- .../AbstractCodeActionOrUserDiagnosticTest.cs | 73 +- .../Workspaces/TestHostProject.cs | 5 +- .../TestUtilities/Workspaces/TestWorkspace.cs | 12 + .../Workspaces/TestWorkspace_Create.cs | 31 +- .../Workspaces/TestWorkspace_XmlCreation.cs | 10 - ...agnosticProviderBasedUserDiagnosticTest.vb | 7 +- .../Extensions/ITypeSymbolExtensions.cs | 11 - .../CSharp/CSharpCompilerExtensions.projitems | 15 +- .../CodeStyle/TypeStyle/TypeStyleHelper.cs | 11 +- .../CodeStyle/TypeStyle/UseVarPreference.cs} | 10 +- .../AssignmentExpressionSyntaxExtensions.cs | 0 .../Extensions/ExpressionSyntaxExtensions.cs | 897 ++++++++++++++++++ .../CSharp/Extensions/OperatorPrecedence.cs | 0 .../Extensions/SimpleNameSyntaxExtensions.cs | 0 ...thCodeStyle.cs => SyntaxNodeExtensions.cs} | 110 ++- ...hCodeStyle.cs => SyntaxTokenExtensions.cs} | 24 + .../CSharp/Extensions/TypeSyntaxExtensions.cs | 55 ++ .../TypeStyle}/CSharpTypeStyleHelper.State.cs | 13 +- .../TypeStyle}/CSharpTypeStyleHelper.cs | 6 + .../TypeStyle}/CSharpUseExplicitTypeHelper.cs | 10 +- .../TypeStyle}/CSharpUseImplicitTypeHelper.cs | 10 +- .../Core/CompilerExtensions.projitems | 5 + .../Core/Extensions/ITypeSymbolExtensions.cs | 11 + .../Core}/Simplification/AliasAnnotation.cs | 0 .../DoNotAddImportsAnnotation.cs | 0 .../Simplification/DoNotAllowVarAnnotation.cs | 0 .../Simplification/SpecialTypeAnnotation.cs | 0 .../Core}/Simplification/SymbolAnnotation.cs | 0 .../CSharpWorkspaceExtensions.projitems | 3 - .../Extensions/ExpressionSyntaxExtensions.cs | 883 +---------------- .../Extensions/ITypeSymbolExtensions.cs | 3 - .../CSharp/Extensions/SyntaxNodeExtensions.cs | 104 +- .../Extensions/SyntaxTokenExtensions.cs | 24 - .../TypeDeclarationSyntaxExtensions.cs | 1 - .../CSharp/Extensions/TypeSyntaxExtensions.cs | 46 +- .../SimplificationHelpers.cs | 0 .../Core/WorkspaceExtensions.projitems | 10 +- 69 files changed, 1636 insertions(+), 1176 deletions(-) rename src/{Features/CSharp/Portable/Diagnostics/Analyzers => Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType}/CSharpTypeStyleDiagnosticAnalyzerBase.cs (93%) rename src/{Features/CSharp/Portable/Diagnostics/Analyzers => Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType}/CSharpUseExplicitTypeDiagnosticAnalyzer.cs (71%) rename src/{Features/CSharp/Portable/Diagnostics/Analyzers => Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType}/CSharpUseImplicitTypeDiagnosticAnalyzer.cs (71%) rename src/{Features/CSharp/Portable/TypeStyle => Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType}/UseExplicitTypeCodeFixProvider.cs (95%) rename src/{Features/CSharp/Portable/TypeStyle => Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType}/UseImplicitTypeCodeFixProvider.cs (88%) rename src/{EditorFeatures/CSharpTest/Diagnostics => Analyzers/CSharp/Tests}/UseImplicitOrExplicitType/UseExplicitTypeTests.cs (99%) rename src/{EditorFeatures/CSharpTest/Diagnostics => Analyzers/CSharp/Tests}/UseImplicitOrExplicitType/UseExplicitTypeTests_FixAllTests.cs (99%) rename src/{EditorFeatures/CSharpTest/Diagnostics => Analyzers/CSharp/Tests}/UseImplicitOrExplicitType/UseImplicitTypeTests.cs (99%) rename src/{EditorFeatures/CSharpTest/Diagnostics => Analyzers/CSharp/Tests}/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs (99%) rename src/Workspaces/{CSharp/Portable => SharedUtilitiesAndExtensions/Compiler/CSharp}/CodeStyle/TypeStyle/TypeStyleHelper.cs (98%) rename src/Workspaces/{CSharp/Portable/CodeStyle/TypeStyle/TypeStyle.cs => SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/TypeStyle/UseVarPreference.cs} (73%) rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace => Compiler}/CSharp/Extensions/AssignmentExpressionSyntaxExtensions.cs (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/ExpressionSyntaxExtensions.cs rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace => Compiler}/CSharp/Extensions/OperatorPrecedence.cs (100%) rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace => Compiler}/CSharp/Extensions/SimpleNameSyntaxExtensions.cs (100%) rename src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/{SyntaxNodeExtensions_SharedWithCodeStyle.cs => SyntaxNodeExtensions.cs} (71%) rename src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/{SyntaxTokenExtensions_SharedWithCodeStyle.cs => SyntaxTokenExtensions.cs} (76%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/TypeSyntaxExtensions.cs rename src/Workspaces/{CSharp/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle}/CSharpTypeStyleHelper.State.cs (96%) rename src/Workspaces/{CSharp/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle}/CSharpTypeStyleHelper.cs (97%) rename src/Workspaces/{CSharp/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle}/CSharpUseExplicitTypeHelper.cs (97%) rename src/Workspaces/{CSharp/Portable/Utilities => SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle}/CSharpUseImplicitTypeHelper.cs (98%) rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace/Core/LanguageServices => Compiler/Core}/Simplification/AliasAnnotation.cs (100%) rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace/Core/LanguageServices => Compiler/Core}/Simplification/DoNotAddImportsAnnotation.cs (100%) rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace/Core/LanguageServices => Compiler/Core}/Simplification/DoNotAllowVarAnnotation.cs (100%) rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace/Core/LanguageServices => Compiler/Core}/Simplification/SpecialTypeAnnotation.cs (100%) rename src/Workspaces/SharedUtilitiesAndExtensions/{Workspace/Core/LanguageServices => Compiler/Core}/Simplification/SymbolAnnotation.cs (100%) rename src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/{LanguageServices/Simplification => Helpers}/SimplificationHelpers.cs (100%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index cebb31f66df8b..186569098bd22 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -12,6 +12,9 @@ + + + diff --git a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpTypeStyleDiagnosticAnalyzerBase.cs b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpTypeStyleDiagnosticAnalyzerBase.cs similarity index 93% rename from src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpTypeStyleDiagnosticAnalyzerBase.cs rename to src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpTypeStyleDiagnosticAnalyzerBase.cs index be9422d9c60fe..5a087f869cd7b 100644 --- a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpTypeStyleDiagnosticAnalyzerBase.cs +++ b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpTypeStyleDiagnosticAnalyzerBase.cs @@ -4,13 +4,20 @@ using System.Collections.Immutable; using Microsoft.CodeAnalysis.CodeStyle; -using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Utilities; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; +#if CODE_STYLE +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle; +using Microsoft.CodeAnalysis.Internal.Options; +using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +#else +using Microsoft.CodeAnalysis.CSharp.CodeStyle; +using Microsoft.CodeAnalysis.Options; +#endif + namespace Microsoft.CodeAnalysis.CSharp.Diagnostics.TypeStyle { internal abstract partial class CSharpTypeStyleDiagnosticAnalyzerBase : @@ -50,7 +57,7 @@ private void HandleVariableDeclaration(SyntaxNodeAnalysisContext context) var options = context.Options; var syntaxTree = context.Node.SyntaxTree; var cancellationToken = context.CancellationToken; - var optionSet = options.GetDocumentOptionSetAsync(syntaxTree, cancellationToken).GetAwaiter().GetResult(); + var optionSet = options.GetOptions(syntaxTree, cancellationToken); if (optionSet == null) { return; diff --git a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpUseExplicitTypeDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseExplicitTypeDiagnosticAnalyzer.cs similarity index 71% rename from src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpUseExplicitTypeDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseExplicitTypeDiagnosticAnalyzer.cs index 36f32c29e145d..4f12aba29de83 100644 --- a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpUseExplicitTypeDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseExplicitTypeDiagnosticAnalyzer.cs @@ -7,14 +7,20 @@ namespace Microsoft.CodeAnalysis.CSharp.Diagnostics.TypeStyle { +#if CODE_STYLE + using Resources = CSharpCodeStyleResources; +#else + using Resources = CSharpFeaturesResources; +#endif + [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpUseExplicitTypeDiagnosticAnalyzer : CSharpTypeStyleDiagnosticAnalyzerBase { private static readonly LocalizableString s_Title = - new LocalizableResourceString(nameof(CSharpFeaturesResources.Use_explicit_type), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)); + new LocalizableResourceString(nameof(Resources.Use_explicit_type), Resources.ResourceManager, typeof(Resources)); private static readonly LocalizableString s_Message = - new LocalizableResourceString(nameof(CSharpFeaturesResources.Use_explicit_type_instead_of_var), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)); + new LocalizableResourceString(nameof(Resources.Use_explicit_type_instead_of_var), Resources.ResourceManager, typeof(Resources)); protected override CSharpTypeStyleHelper Helper => CSharpUseExplicitTypeHelper.Instance; diff --git a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpUseImplicitTypeDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseImplicitTypeDiagnosticAnalyzer.cs similarity index 71% rename from src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpUseImplicitTypeDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseImplicitTypeDiagnosticAnalyzer.cs index 61c0b5bcec2d9..116e3fe034fbb 100644 --- a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpUseImplicitTypeDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseImplicitTypeDiagnosticAnalyzer.cs @@ -7,14 +7,20 @@ namespace Microsoft.CodeAnalysis.CSharp.Diagnostics.TypeStyle { +#if CODE_STYLE + using Resources = CSharpCodeStyleResources; +#else + using Resources = CSharpFeaturesResources; +#endif + [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpUseImplicitTypeDiagnosticAnalyzer : CSharpTypeStyleDiagnosticAnalyzerBase { private static readonly LocalizableString s_Title = - new LocalizableResourceString(nameof(CSharpFeaturesResources.Use_implicit_type), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)); + new LocalizableResourceString(nameof(Resources.Use_implicit_type), Resources.ResourceManager, typeof(Resources)); private static readonly LocalizableString s_Message = - new LocalizableResourceString(nameof(CSharpFeaturesResources.use_var_instead_of_explicit_type), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)); + new LocalizableResourceString(nameof(Resources.use_var_instead_of_explicit_type), Resources.ResourceManager, typeof(Resources)); protected override CSharpTypeStyleHelper Helper => CSharpUseImplicitTypeHelper.Instance; diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index 9b0af3319cf97..22cdb7d604eaf 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -13,5 +13,7 @@ + + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/TypeStyle/UseExplicitTypeCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs similarity index 95% rename from src/Features/CSharp/Portable/TypeStyle/UseExplicitTypeCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs index b9fc257d48219..c288c97db7ab7 100644 --- a/src/Features/CSharp/Portable/TypeStyle/UseExplicitTypeCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs @@ -20,6 +20,12 @@ namespace Microsoft.CodeAnalysis.CSharp.TypeStyle { +#if CODE_STYLE + using Resources = CSharpCodeStyleResources; +#else + using Resources = CSharpFeaturesResources; +#endif + [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseExplicitType), Shared] internal class UseExplicitTypeCodeFixProvider : SyntaxEditorBasedCodeFixProvider { @@ -158,12 +164,12 @@ private static ExpressionSyntax GenerateTupleDeclaration(ITypeSymbol typeSymbol, .WithTrailingTrivia(parensDesignation.GetTrailingTrivia()); } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(CSharpFeaturesResources.Use_explicit_type_instead_of_var, + : base(Resources.Use_explicit_type_instead_of_var, createChangedDocument, - CSharpFeaturesResources.Use_explicit_type_instead_of_var) + Resources.Use_explicit_type_instead_of_var) { } } diff --git a/src/Features/CSharp/Portable/TypeStyle/UseImplicitTypeCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseImplicitTypeCodeFixProvider.cs similarity index 88% rename from src/Features/CSharp/Portable/TypeStyle/UseImplicitTypeCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseImplicitTypeCodeFixProvider.cs index 8bb23b62b5567..c0e3da2b2542a 100644 --- a/src/Features/CSharp/Portable/TypeStyle/UseImplicitTypeCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseImplicitTypeCodeFixProvider.cs @@ -16,6 +16,12 @@ namespace Microsoft.CodeAnalysis.CSharp.TypeStyle { +#if CODE_STYLE + using Resources = CSharpCodeStyleResources; +#else + using Resources = CSharpFeaturesResources; +#endif + [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseImplicitType), Shared] internal class UseImplicitTypeCodeFixProvider : SyntaxEditorBasedCodeFixProvider { @@ -61,12 +67,12 @@ internal static void ReplaceTypeWithVar(SyntaxEditor editor, SyntaxNode node) editor.ReplaceNode(node, implicitType); } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(CSharpFeaturesResources.use_var_instead_of_explicit_type, + : base(Resources.use_var_instead_of_explicit_type, createChangedDocument, - CSharpFeaturesResources.use_var_instead_of_explicit_type) + Resources.use_var_instead_of_explicit_type) { } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index 66e41786a642b..a774dfcb82e01 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -13,5 +13,9 @@ + + + + \ No newline at end of file diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs rename to src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs index 94acae89a491f..9c3aed3b2a775 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs +++ b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs @@ -5,16 +5,22 @@ using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CodeStyle; -using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.Diagnostics.TypeStyle; using Microsoft.CodeAnalysis.CSharp.TypeStyle; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; +#if CODE_STYLE +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle; +using Microsoft.CodeAnalysis.Internal.Options; +#else +using Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.CSharp.CodeStyle; +using Microsoft.CodeAnalysis.Options; +#endif + namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.UseExplicitType { public partial class UseExplicitTypeTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests_FixAllTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests_FixAllTests.cs rename to src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests_FixAllTests.cs index cb99d76c85ac8..b2a1a8f6666ab 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests_FixAllTests.cs +++ b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests_FixAllTests.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Threading.Tasks; -using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs rename to src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests.cs index 1246727595952..c59efd6d94e35 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs +++ b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests.cs @@ -5,17 +5,23 @@ using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.CSharp.Diagnostics.TypeStyle; using Microsoft.CodeAnalysis.CSharp.TypeStyle; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; +#if CODE_STYLE +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle; +using Microsoft.CodeAnalysis.Internal.Options; +#else +using Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.CSharp.CodeStyle; +using Microsoft.CodeAnalysis.Options; +#endif + namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.UseImplicitType { public partial class UseImplicitTypeTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs similarity index 99% rename from src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs rename to src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs index 403bb3d92984d..6db867339450d 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs +++ b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Threading.Tasks; -using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs index c8d88081f12ce..130af45a508ad 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs @@ -132,6 +132,33 @@ internal static string Space_preferences { } } + /// + /// Looks up a localized string similar to Use explicit type. + /// + internal static string Use_explicit_type { + get { + return ResourceManager.GetString("Use_explicit_type", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use explicit type instead of 'var'. + /// + internal static string Use_explicit_type_instead_of_var { + get { + return ResourceManager.GetString("Use_explicit_type_instead_of_var", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use implicit type. + /// + internal static string Use_implicit_type { + get { + return ResourceManager.GetString("Use_implicit_type", resourceCulture); + } + } + /// /// Looks up a localized string similar to Use 'switch' expression. /// @@ -141,6 +168,15 @@ internal static string Use_switch_expression { } } + /// + /// Looks up a localized string similar to use 'var' instead of explicit type. + /// + internal static string use_var_instead_of_explicit_type { + get { + return ResourceManager.GetString("use_var_instead_of_explicit_type", resourceCulture); + } + } + /// /// Looks up a localized string similar to 'using' directive preferences. /// diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx index fdfe23b219caa..7ad9e4d340de1 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx @@ -155,4 +155,16 @@ 'using' directive preferences {Locked="using"} "using" is a C# keyword and should not be localized. + + Use explicit type instead of 'var' + + + Use explicit type + + + use 'var' instead of explicit type + + + Use implicit type + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf index b083e05e82822..51d1be5ed27f9 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf @@ -42,6 +42,21 @@ Předvolby mezer + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Předvolby zalamování + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf index 1a3df896ca801..03a77a2157f3b 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf @@ -42,6 +42,21 @@ Einstellungen für Abstände + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Umbrucheinstellungen + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf index e1163cd522d41..87acb180754ec 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf @@ -42,6 +42,21 @@ Preferencias de espacio + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Preferencias de ajuste + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf index badfb5be91471..c3fff48e74f1e 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf @@ -42,6 +42,21 @@ Préférences d'espace + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Préférences d'enveloppement + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf index 01fa368e5e3d0..ced68355c9fd6 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf @@ -42,6 +42,21 @@ Preferenze per spazi + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Preferenze per ritorno a capo + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf index 73d811fd3a4cb..3cf84bdca8218 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf @@ -42,6 +42,21 @@ スペース設定 + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ 折り返しの設定 + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf index 6163e7c8f5568..ad89daf9acf3d 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf @@ -42,6 +42,21 @@ 공간 기본 설정 + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ 기본 설정 래핑 + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf index b213a034f8a81..bb77e89f8236a 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf @@ -42,6 +42,21 @@ Preferencje dotyczące odstępów + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Preferencje zawijania + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf index a02ee27e267b6..9eb924bd222a3 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf @@ -42,6 +42,21 @@ Preferências de espaço + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Preferências de quebra de linha + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf index 6962d0c0dd4c4..fe0b65909b0f7 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf @@ -42,6 +42,21 @@ Предпочтения для интервалов + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Параметры переноса + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf index ce77798ee5393..a3fdbc0f608ae 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf @@ -42,6 +42,21 @@ Boşluk tercihleri + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ Kaydırma tercihleri + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf index 6a9cade8e6706..b6af58480a339 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf @@ -42,6 +42,21 @@ 空格键首选项 + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ 包装首选项 + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf index 196239dfb6307..e19fda203a786 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf @@ -42,6 +42,21 @@ 空格喜好設定 + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + Use 'switch' expression Use 'switch' expression @@ -52,6 +67,11 @@ 換行喜好設定 + + use 'var' instead of explicit type + use 'var' instead of explicit type + + 'using' directive preferences 'using' directive preferences diff --git a/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs b/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs index bc62a7993cda9..6a056e9f13923 100644 --- a/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs +++ b/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs @@ -6,12 +6,13 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting.Rules; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; -namespace Microsoft.CodeAnalysis.Formatting +namespace Microsoft.CodeAnalysis.CodeStyle.Formatting { /// /// Formats whitespace in documents or syntax trees. diff --git a/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs b/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs index f2623226cc4e1..a97a001d9c739 100644 --- a/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs +++ b/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs @@ -8,6 +8,7 @@ #if CODE_STYLE using FormatterState = Microsoft.CodeAnalysis.Formatting.ISyntaxFormattingService; +using Formatter = Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; #else using Microsoft.CodeAnalysis.Options; diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs index 428404b7fa002..f327a831ef84c 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Text; #if CODE_STYLE -using Formatter = CodeStyle::Microsoft.CodeAnalysis.Formatting.Formatter; +using Formatter = Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; using FormatterState = Microsoft.CodeAnalysis.Formatting.ISyntaxFormattingService; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; #else diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs index e5d431b3605e9..7977af5cd312f 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs @@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.CodeStyle { extern alias CodeStyle; - using Formatter = CodeStyle::Microsoft.CodeAnalysis.Formatting.Formatter; + using Formatter = Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; using ISyntaxFormattingService = ISyntaxFormattingService; internal abstract class AbstractFormattingCodeFixProvider : CodeFixProvider diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs index 05c2c0ad9420a..f9cb2e7c89dc0 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs @@ -18,8 +18,6 @@ public abstract class AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest : protected override string GetLanguage() => LanguageNames.CSharp; protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters) - => CreateWorkspaceFromFile(initialMarkup, parameters, rootFilePath: null); - protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters, string rootFilePath = null) - => TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions, rootFilePath: rootFilePath); + => TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions); } } diff --git a/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs index 2b49110732cf8..cace82f08e68d 100644 --- a/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs +++ b/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs @@ -88,12 +88,18 @@ public TestParameters WithIncludeDiagnosticsOutsideSelection(bool includeDiagnos => new TestParameters(parseOptions, compilationOptions, options, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title); } + private const string AutoGeneratedAnalyzerConfigHeader = @"# auto-generated .editorconfig for code style options"; + protected abstract string GetLanguage(); protected abstract ParseOptions GetScriptOptions(); protected TestWorkspace CreateWorkspaceFromOptions( string initialMarkup, TestParameters parameters) { + var workspace = TestWorkspace.IsWorkspaceElement(initialMarkup) + ? TestWorkspace.Create(initialMarkup, openDocuments: false) + : CreateWorkspaceFromFile(initialMarkup, parameters); + // For CodeStyle layer testing, we create an .editorconfig at project root // to apply the options as workspace options are not available in CodeStyle layer. // Otherwise, we apply the options directly to the workspace. @@ -102,22 +108,54 @@ protected TestWorkspace CreateWorkspaceFromOptions( // We need to ensure that our projects/documents are rooted for // execution from CodeStyle layer as we will be adding a rooted .editorconfig to each project // to apply the options. - var workspace = CreateWorkspace(rootFilePath: @"z:\"); if (parameters.options != null) { + MakeProjectsAndDocumentsRooted(workspace); AddAnalyzerConfigDocumentWithOptions(workspace, parameters.options); } #else - var workspace = CreateWorkspace(rootFilePath: null); workspace.ApplyOptions(parameters.options); #endif return workspace; + } - TestWorkspace CreateWorkspace(string rootFilePath) - => TestWorkspace.IsWorkspaceElement(initialMarkup) - ? TestWorkspace.Create(initialMarkup, openDocuments: false) - : CreateWorkspaceFromFile(initialMarkup, parameters, rootFilePath); + private static void MakeProjectsAndDocumentsRooted(TestWorkspace workspace) + { + const string defaultRootFilePath = @"z:\"; + var newSolution = workspace.CurrentSolution; + foreach (var projectId in workspace.CurrentSolution.ProjectIds) + { + var project = newSolution.GetProject(projectId); + + string projectRootFilePath; + if (!PathUtilities.IsAbsolute(project.FilePath)) + { + projectRootFilePath = defaultRootFilePath; + newSolution = newSolution.WithProjectFilePath(projectId, Path.Combine(projectRootFilePath, project.FilePath)); + } + else + { + projectRootFilePath = PathUtilities.GetPathRoot(project.FilePath); + } + + foreach (var documentId in project.DocumentIds) + { + var document = newSolution.GetDocument(documentId); + if (!PathUtilities.IsAbsolute(document.FilePath)) + { + newSolution = newSolution.WithDocumentFilePath(documentId, Path.Combine(projectRootFilePath, document.FilePath)); + } + else + { + Assert.Equal(projectRootFilePath, PathUtilities.GetPathRoot(document.FilePath)); + } + } + } + + var applied = workspace.TryApplyChanges(newSolution); + Assert.True(applied); + return; } private static void AddAnalyzerConfigDocumentWithOptions(TestWorkspace workspace, IDictionary options) @@ -138,12 +176,18 @@ private static void AddAnalyzerConfigDocumentWithOptions(TestWorkspace workspace filePath: Path.Combine(projectRootFilePath, ".editorconfig")); } - workspace.TryApplyChanges(newSolution); + var applied = workspace.TryApplyChanges(newSolution); + Assert.True(applied); return; static string GenerateAnalyzerConfigText(IDictionary options) { var textBuilder = new StringBuilder(); + + // Add an auto-generated header at the top so we can skip this file in expected baseline validation. + textBuilder.AppendLine(AutoGeneratedAnalyzerConfigHeader); + textBuilder.AppendLine(); + foreach (var (optionKey, value) in options) { foreach (var location in optionKey.Option.StorageLocations) @@ -186,11 +230,6 @@ static string GetSectionHeader(OptionKey optionKey) protected abstract TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters); - protected virtual TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters, string rootFilePath = null) - { - throw new NotImplementedException(); - } - private TestParameters WithRegularOptions(TestParameters parameters) => parameters.WithParseOptions(parameters.parseOptions?.WithKind(SourceCodeKind.Regular)); @@ -581,9 +620,17 @@ private static async Task VerifyAgainstWorkspaceDefinitionAsync(string expectedT foreach (var analyzerConfigDoc in project.AnalyzerConfigDocuments) { var root = await analyzerConfigDoc.GetTextAsync(); + var actualString = root.ToString(); + if (actualString.StartsWith(AutoGeneratedAnalyzerConfigHeader)) + { + // Skip validation for analyzer config file that is auto-generated by test framework + // for applying code style options. + continue; + } + var expectedDocument = expectedProject.AnalyzerConfigDocuments.Single(d => d.FilePath == analyzerConfigDoc.FilePath); var expectedRoot = await expectedDocument.GetTextAsync(); - VerifyExpectedDocumentText(expectedRoot.ToString(), root.ToString()); + VerifyExpectedDocumentText(expectedRoot.ToString(), actualString); } } } diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestHostProject.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestHostProject.cs index d6334f9063827..a2e12211a78a2 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestHostProject.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestHostProject.cs @@ -27,7 +27,6 @@ public class TestHostProject private readonly string _assemblyName; private readonly Type _hostObjectType; private readonly VersionStamp _version; - private readonly string _filePath; private readonly string _outputFilePath; private readonly string _defaultNamespace; @@ -35,6 +34,7 @@ public class TestHostProject public IEnumerable AdditionalDocuments; public IEnumerable AnalyzerConfigDocuments; public IEnumerable ProjectReferences; + private string _filePath; public string Name { @@ -325,6 +325,9 @@ internal void RemoveAnalyzerConfigDocument(TestHostDocument document) this.AnalyzerConfigDocuments = this.AnalyzerConfigDocuments.Where(d => d != document); } + internal void OnProjectFilePathChanged(string filePath) + => _filePath = filePath; + public string Language { get diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs index af9059ed2cbba..ef4e17acedda6 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs @@ -354,6 +354,18 @@ protected override void ApplyAnalyzerConfigDocumentRemoved(DocumentId documentId this.OnAnalyzerConfigDocumentRemoved(documentId); } + protected override void ApplyProjectChanges(ProjectChanges projectChanges) + { + if (projectChanges.OldProject.FilePath != projectChanges.NewProject.FilePath) + { + var hostProject = this.GetTestProject(projectChanges.NewProject.Id); + hostProject.OnProjectFilePathChanged(projectChanges.NewProject.FilePath); + base.OnProjectNameChanged(projectChanges.NewProject.Id, projectChanges.NewProject.Name, projectChanges.NewProject.FilePath); + } + + base.ApplyProjectChanges(projectChanges); + } + internal override void SetDocumentContext(DocumentId documentId) { OnDocumentContextUpdated(documentId); diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs index 5ca6b69253a30..1401a914e9cee 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs @@ -130,11 +130,8 @@ internal static TestWorkspace Create( return Create(language, compilationOptions, parseOptions, files, exportProvider: null, workspaceKind: workspaceKind); } - internal static string GetDefaultTestSourceDocumentName(int index, string extension, string rootFilePath) - { - var fileName = "test" + (index + 1) + extension; - return rootFilePath != null ? Path.Combine(rootFilePath, fileName) : fileName; - } + internal static string GetDefaultTestSourceDocumentName(int index, string extension) + => "test" + (index + 1) + extension; internal static TestWorkspace Create( string language, @@ -145,7 +142,6 @@ internal static TestWorkspace Create( string[] metadataReferences = null, string workspaceKind = null, string extension = null, - string rootFilePath = null, bool commonReferences = true, bool openDocuments = false) { @@ -161,7 +157,7 @@ internal static TestWorkspace Create( foreach (var file in files) { - documentElements.Add(CreateDocumentElement(file, GetDefaultTestSourceDocumentName(index++, extension, rootFilePath), parseOptions)); + documentElements.Add(CreateDocumentElement(file, GetDefaultTestSourceDocumentName(index++, extension), parseOptions)); } metadataReferences = metadataReferences ?? Array.Empty(); @@ -171,7 +167,7 @@ internal static TestWorkspace Create( } var workspaceElement = CreateWorkspaceElement( - CreateProjectElement(compilationOptions?.ModuleName ?? "Test", language, commonReferences, parseOptions, compilationOptions, rootFilePath, documentElements)); + CreateProjectElement(compilationOptions?.ModuleName ?? "Test", language, commonReferences, parseOptions, compilationOptions, documentElements)); return Create(workspaceElement, openDocuments: openDocuments, exportProvider: exportProvider, workspaceKind: workspaceKind); } @@ -181,8 +177,7 @@ internal static TestWorkspace Create( CompilationOptions compilationOptions, ParseOptions[] parseOptions, string[] files, - ExportProvider exportProvider, - string rootFilePath = null) + ExportProvider exportProvider) { Debug.Assert(parseOptions == null || (files.Length == parseOptions.Length), "Please specify a parse option for each file."); @@ -209,11 +204,11 @@ internal static TestWorkspace Create( extension = language; } - documentElements.Add(CreateDocumentElement(files[i], GetDefaultTestSourceDocumentName(index++, extension, rootFilePath), parseOptions == null ? null : parseOptions[i])); + documentElements.Add(CreateDocumentElement(files[i], GetDefaultTestSourceDocumentName(index++, extension), parseOptions == null ? null : parseOptions[i])); } var workspaceElement = CreateWorkspaceElement( - CreateProjectElement("Test", language, true, parseOptions.FirstOrDefault(), compilationOptions, rootFilePath, documentElements)); + CreateProjectElement("Test", language, true, parseOptions.FirstOrDefault(), compilationOptions, documentElements)); return Create(workspaceElement, exportProvider: exportProvider); } @@ -226,10 +221,9 @@ public static TestWorkspace CreateCSharp( CompilationOptions compilationOptions = null, ExportProvider exportProvider = null, string[] metadataReferences = null, - string rootFilePath = null, bool openDocuments = false) { - return CreateCSharp(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences, rootFilePath, openDocuments); + return CreateCSharp(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences, openDocuments); } public static TestWorkspace CreateCSharp( @@ -238,10 +232,9 @@ public static TestWorkspace CreateCSharp( CompilationOptions compilationOptions = null, ExportProvider exportProvider = null, string[] metadataReferences = null, - string rootFilePath = null, bool openDocuments = false) { - return Create(LanguageNames.CSharp, compilationOptions, parseOptions, files, exportProvider, metadataReferences, rootFilePath: rootFilePath, openDocuments: openDocuments); + return Create(LanguageNames.CSharp, compilationOptions, parseOptions, files, exportProvider, metadataReferences, openDocuments: openDocuments); } public static TestWorkspace CreateCSharp2( @@ -263,10 +256,9 @@ public static TestWorkspace CreateVisualBasic( CompilationOptions compilationOptions = null, ExportProvider exportProvider = null, string[] metadataReferences = null, - string rootFilePath = null, bool openDocuments = false) { - return CreateVisualBasic(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences, rootFilePath, openDocuments); + return CreateVisualBasic(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences, openDocuments); } public static TestWorkspace CreateVisualBasic( @@ -275,10 +267,9 @@ public static TestWorkspace CreateVisualBasic( CompilationOptions compilationOptions = null, ExportProvider exportProvider = null, string[] metadataReferences = null, - string rootFilePath = null, bool openDocuments = false) { - return Create(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider, metadataReferences, openDocuments: openDocuments, rootFilePath: rootFilePath); + return Create(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider, metadataReferences, openDocuments: openDocuments); } /// Can pass in multiple file contents with individual source kind: files will be named test1.vb, test2.vbx, etc. diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs index f4592f567159b..0180216712e89 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs @@ -23,17 +23,8 @@ protected static XElement CreateProjectElement( bool commonReferences, ParseOptions parseOptions, CompilationOptions compilationOptions, - string rootFilePath, params object[] elements) { - string filePath = null; - if (rootFilePath != null) - { - filePath = Path.Combine(rootFilePath, assemblyName + - (language == LanguageNames.CSharp ? ".csproj" : - language == LanguageNames.VisualBasic ? ".vbproj" : ("." + language))); - } - return new XElement(ProjectElementName, new XAttribute(AssemblyNameAttributeName, assemblyName), new XAttribute(LanguageAttributeName, language), @@ -42,7 +33,6 @@ protected static XElement CreateProjectElement( parseOptions == null ? null : CreateDocumentationModeAttribute(parseOptions), parseOptions == null ? null : CreateFeaturesAttribute(parseOptions), compilationOptions == null ? null : CreateCompilationOptionsElement(compilationOptions), - filePath == null ? null : new XAttribute(FilePathAttributeName, filePath), elements); } diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb index 45dbddf133956..52968e28632c2 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb @@ -19,15 +19,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics End Function Protected Overrides Function CreateWorkspaceFromFile(initialMarkup As String, parameters As TestParameters) As TestWorkspace - Return CreateWorkspaceFromFile(initialMarkup, parameters, rootFilePath:=Nothing) - End Function - - Protected Overrides Function CreateWorkspaceFromFile(initialMarkup As String, parameters As TestParameters, Optional rootFilePath As String = Nothing) As TestWorkspace Return TestWorkspace.CreateVisualBasic( initialMarkup, parameters.parseOptions, - If(parameters.compilationOptions, New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary)), - rootFilePath:=rootFilePath) + If(parameters.compilationOptions, New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary))) End Function Friend Overloads Async Function TestAsync( diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs index 5124aa03305f8..d69501e91da70 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/ITypeSymbolExtensions.cs @@ -21,17 +21,6 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions { internal static partial class ITypeSymbolExtensions { - [return: NotNullIfNotNull(parameterName: "symbol")] - public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol) - { - if (symbol.IsNullable()) - { - return symbol.GetTypeArguments().Single(); - } - - return symbol; - } - /// /// Returns the corresponding symbol in this type or a base type that implements /// interfaceMember (either implicitly or explicitly), or null if no such symbol exists diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems index 899f375826343..f31f0d6406250 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems @@ -12,14 +12,25 @@ + + + + + + - - + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyleHelper.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/TypeStyle/TypeStyleHelper.cs similarity index 98% rename from src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyleHelper.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/TypeStyle/TypeStyleHelper.cs index 7c82dd7e7c710..57cdafb1d5abf 100644 --- a/src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyleHelper.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/TypeStyle/TypeStyleHelper.cs @@ -7,10 +7,19 @@ using System.Threading; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; +#if CODE_STYLE +using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +#else +using Microsoft.CodeAnalysis.Options; +#endif + +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle.TypeStyle +#else namespace Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle +#endif { internal static class TypeStyleHelper { diff --git a/src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/TypeStyle/UseVarPreference.cs similarity index 73% rename from src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyle.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/TypeStyle/UseVarPreference.cs index 1d70220980340..37f554f2a8392 100644 --- a/src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyle.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/TypeStyle/UseVarPreference.cs @@ -3,14 +3,12 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis.CSharp.Syntax; +#if CODE_STYLE +namespace Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle.TypeStyle +#else namespace Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle +#endif { [Flags] internal enum UseVarPreference diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/AssignmentExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/AssignmentExpressionSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/AssignmentExpressionSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/AssignmentExpressionSyntaxExtensions.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/ExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/ExpressionSyntaxExtensions.cs new file mode 100644 index 0000000000000..5704c6e7e64ba --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/ExpressionSyntaxExtensions.cs @@ -0,0 +1,897 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Threading; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.CSharp.Utilities; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Simplification; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.CSharp.Extensions +{ + internal static partial class ExpressionSyntaxExtensions + { + public static ExpressionSyntax WalkUpParentheses(this ExpressionSyntax expression) + { + while (expression.IsParentKind(SyntaxKind.ParenthesizedExpression)) + { + expression = (ExpressionSyntax)expression.Parent; + } + + return expression; + } + + public static ExpressionSyntax WalkDownParentheses(this ExpressionSyntax expression) + { + while (expression.IsKind(SyntaxKind.ParenthesizedExpression)) + { + expression = ((ParenthesizedExpressionSyntax)expression).Expression; + } + + return expression; + } + + public static bool IsQualifiedCrefName(this ExpressionSyntax expression) + { + return expression.IsParentKind(SyntaxKind.NameMemberCref) && expression.Parent.IsParentKind(SyntaxKind.QualifiedCref); + } + + public static bool IsMemberAccessExpressionName(this ExpressionSyntax expression) + { + return (expression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) && ((MemberAccessExpressionSyntax)expression.Parent).Name == expression) || + IsMemberBindingExpressionName(expression); + } + + public static bool IsAnyMemberAccessExpressionName(this ExpressionSyntax expression) + { + if (expression == null) + { + return false; + } + + return expression == (expression.Parent as MemberAccessExpressionSyntax)?.Name || + expression.IsMemberBindingExpressionName(); + } + + private static bool IsMemberBindingExpressionName(this ExpressionSyntax expression) + { + return expression.IsParentKind(SyntaxKind.MemberBindingExpression) && + ((MemberBindingExpressionSyntax)expression.Parent).Name == expression; + } + + public static bool IsRightSideOfQualifiedName(this ExpressionSyntax expression) + { + return expression.IsParentKind(SyntaxKind.QualifiedName) && ((QualifiedNameSyntax)expression.Parent).Right == expression; + } + + public static bool IsRightSideOfColonColon(this ExpressionSyntax expression) + { + return expression.IsParentKind(SyntaxKind.AliasQualifiedName) && ((AliasQualifiedNameSyntax)expression.Parent).Name == expression; + } + + public static bool IsRightSideOfDot(this ExpressionSyntax name) + { + return IsMemberAccessExpressionName(name) || IsRightSideOfQualifiedName(name) || IsQualifiedCrefName(name); + } + + public static bool IsRightSideOfDotOrArrow(this ExpressionSyntax name) + { + return IsAnyMemberAccessExpressionName(name) || IsRightSideOfQualifiedName(name); + } + + public static bool IsRightSideOfDotOrColonColon(this ExpressionSyntax name) + { + return IsRightSideOfDot(name) || IsRightSideOfColonColon(name); + } + + public static bool IsRightSideOfDotOrArrowOrColonColon(this ExpressionSyntax name) + { + return IsRightSideOfDotOrArrow(name) || IsRightSideOfColonColon(name); + } + + public static bool IsRightOfCloseParen(this ExpressionSyntax expression) + { + var firstToken = expression.GetFirstToken(); + return firstToken.Kind() != SyntaxKind.None + && firstToken.GetPreviousToken().Kind() == SyntaxKind.CloseParenToken; + } + + public static bool IsLeftSideOfDot(this ExpressionSyntax expression) + { + if (expression == null) + { + return false; + } + + return IsLeftSideOfQualifiedName(expression) || + IsLeftSideOfSimpleMemberAccessExpression(expression); + } + + public static bool IsLeftSideOfSimpleMemberAccessExpression(this ExpressionSyntax expression) + => (expression?.Parent).IsKind(SyntaxKind.SimpleMemberAccessExpression, out MemberAccessExpressionSyntax memberAccess) && + memberAccess.Expression == expression; + + public static bool IsLeftSideOfDotOrArrow(this ExpressionSyntax expression) + => IsLeftSideOfQualifiedName(expression) || + (expression.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Expression == expression); + + public static bool IsLeftSideOfQualifiedName(this ExpressionSyntax expression) + => (expression?.Parent).IsKind(SyntaxKind.QualifiedName, out QualifiedNameSyntax qualifiedName) && qualifiedName.Left == expression; + + public static bool IsLeftSideOfExplicitInterfaceSpecifier(this NameSyntax name) + => name.IsParentKind(SyntaxKind.ExplicitInterfaceSpecifier); + + public static bool IsExpressionOfInvocation(this ExpressionSyntax expression) + => (expression?.Parent).IsKind(SyntaxKind.InvocationExpression, out InvocationExpressionSyntax invocation) && + invocation.Expression == expression; + + public static bool TryGetNameParts(this ExpressionSyntax expression, out IList parts) + { + var partsList = new List(); + if (!TryGetNameParts(expression, partsList)) + { + parts = null; + return false; + } + + parts = partsList; + return true; + } + + public static bool TryGetNameParts(this ExpressionSyntax expression, List parts) + { + if (expression.IsKind(SyntaxKind.SimpleMemberAccessExpression, out MemberAccessExpressionSyntax memberAccess)) + { + if (!TryGetNameParts(memberAccess.Expression, parts)) + { + return false; + } + + return AddSimpleName(memberAccess.Name, parts); + } + else if (expression.IsKind(SyntaxKind.QualifiedName, out QualifiedNameSyntax qualifiedName)) + { + if (!TryGetNameParts(qualifiedName.Left, parts)) + { + return false; + } + + return AddSimpleName(qualifiedName.Right, parts); + } + else if (expression is SimpleNameSyntax simpleName) + { + return AddSimpleName(simpleName, parts); + } + else + { + return false; + } + } + + private static bool AddSimpleName(SimpleNameSyntax simpleName, List parts) + { + if (!simpleName.IsKind(SyntaxKind.IdentifierName)) + { + return false; + } + + parts.Add(simpleName.Identifier.ValueText); + return true; + } + + public static bool IsAnyLiteralExpression(this ExpressionSyntax expression) + { + return + expression.IsKind(SyntaxKind.CharacterLiteralExpression) || + expression.IsKind(SyntaxKind.FalseLiteralExpression) || + expression.IsKind(SyntaxKind.NullLiteralExpression) || + expression.IsKind(SyntaxKind.NumericLiteralExpression) || + expression.IsKind(SyntaxKind.StringLiteralExpression) || + expression.IsKind(SyntaxKind.TrueLiteralExpression); + } + + public static bool IsInConstantContext(this ExpressionSyntax expression) + { + if (expression.GetAncestor() != null) + { + return true; + } + + var attributeArgument = expression.GetAncestor(); + if (attributeArgument != null) + { + if (attributeArgument.NameEquals == null || + expression != attributeArgument.NameEquals.Name) + { + return true; + } + } + + if (expression.IsParentKind(SyntaxKind.ConstantPattern)) + { + return true; + } + + // note: the above list is not intended to be exhaustive. If more cases + // are discovered that should be considered 'constant' contexts in the + // language, then this should be updated accordingly. + return false; + } + + public static bool IsInOutContext(this ExpressionSyntax expression) + { + return + expression?.Parent is ArgumentSyntax argument && + argument.Expression == expression && + argument.RefOrOutKeyword.Kind() == SyntaxKind.OutKeyword; + } + + public static bool IsInRefContext(this ExpressionSyntax expression) + => expression.IsParentKind(SyntaxKind.RefExpression) || + (expression?.Parent as ArgumentSyntax)?.RefOrOutKeyword.Kind() == SyntaxKind.RefKeyword; + + public static bool IsInInContext(this ExpressionSyntax expression) + => (expression?.Parent as ArgumentSyntax)?.RefKindKeyword.Kind() == SyntaxKind.InKeyword; + + private static ExpressionSyntax GetExpressionToAnalyzeForWrites(ExpressionSyntax expression) + { + if (expression.IsRightSideOfDotOrArrow()) + { + expression = expression.Parent as ExpressionSyntax; + } + + expression = expression.WalkUpParentheses(); + + return expression; + } + + public static bool IsOnlyWrittenTo(this ExpressionSyntax expression) + { + expression = GetExpressionToAnalyzeForWrites(expression); + + if (expression != null) + { + if (expression.IsInOutContext()) + { + return true; + } + + if (expression.Parent != null) + { + if (expression.IsLeftSideOfAssignExpression()) + { + return true; + } + + if (expression.IsAttributeNamedArgumentIdentifier()) + { + return true; + } + } + + if (IsExpressionOfArgumentInDeconstruction(expression)) + { + return true; + } + } + + return false; + } + + /// + /// If this declaration or identifier is part of a deconstruction, find the deconstruction. + /// If found, returns either an assignment expression or a foreach variable statement. + /// Returns null otherwise. + /// + /// copied from SyntaxExtensions.GetContainingDeconstruction + /// + private static bool IsExpressionOfArgumentInDeconstruction(ExpressionSyntax expr) + { + if (!expr.IsParentKind(SyntaxKind.Argument)) + { + return false; + } + + while (true) + { + var parent = expr.Parent; + if (parent == null) + { + return false; + } + + switch (parent.Kind()) + { + case SyntaxKind.Argument: + if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) + { + expr = (TupleExpressionSyntax)parent.Parent; + continue; + } + + return false; + case SyntaxKind.SimpleAssignmentExpression: + if (((AssignmentExpressionSyntax)parent).Left == expr) + { + return true; + } + + return false; + case SyntaxKind.ForEachVariableStatement: + if (((ForEachVariableStatementSyntax)parent).Variable == expr) + { + return true; + } + + return false; + + default: + return false; + } + } + } + + public static bool IsWrittenTo(this ExpressionSyntax expression) + { + expression = GetExpressionToAnalyzeForWrites(expression); + + if (expression.IsOnlyWrittenTo()) + { + return true; + } + + if (expression.IsInRefContext()) + { + return true; + } + + // We're written if we're used in a ++, or -- expression. + if (expression.IsOperandOfIncrementOrDecrementExpression()) + { + return true; + } + + if (expression.IsLeftSideOfAnyAssignExpression()) + { + return true; + } + + return false; + } + + public static bool IsAttributeNamedArgumentIdentifier(this ExpressionSyntax expression) + { + var nameEquals = expression?.Parent as NameEqualsSyntax; + return nameEquals.IsParentKind(SyntaxKind.AttributeArgument); + } + + public static bool IsOperandOfIncrementOrDecrementExpression(this ExpressionSyntax expression) + { + if (expression != null) + { + switch (expression.Parent.Kind()) + { + case SyntaxKind.PostIncrementExpression: + case SyntaxKind.PreIncrementExpression: + case SyntaxKind.PostDecrementExpression: + case SyntaxKind.PreDecrementExpression: + return true; + } + } + + return false; + } + + public static bool IsNamedArgumentIdentifier(this ExpressionSyntax expression) + { + return expression is IdentifierNameSyntax && expression.Parent is NameColonSyntax; + } + + public static bool IsInsideNameOfExpression( + this ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken) + { + var invocation = expression?.GetAncestor(); + if (invocation?.Expression is IdentifierNameSyntax name && + name.Identifier.Text == SyntaxFacts.GetText(SyntaxKind.NameOfKeyword)) + { + return semanticModel.GetMemberGroup(name, cancellationToken).IsDefaultOrEmpty; + } + + return false; + } + + private static bool CanReplace(ISymbol symbol) + { + switch (symbol.Kind) + { + case SymbolKind.Field: + case SymbolKind.Local: + case SymbolKind.Method: + case SymbolKind.Parameter: + case SymbolKind.Property: + case SymbolKind.RangeVariable: + return true; + } + + return false; + } + + public static bool CanReplaceWithRValue( + this ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken) + { + // An RValue can't be written into. + // i.e. you can't replace "a" in "a = b" with "Goo() = b". + return + expression != null && + !expression.IsWrittenTo() && + CanReplaceWithLValue(expression, semanticModel, cancellationToken); + } + + public static bool CanReplaceWithLValue( + this ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken) + { + if (expression.IsKind(SyntaxKind.StackAllocArrayCreationExpression)) + { + // Stack alloc is very interesting. While it appears to be an expression, it is only + // such so it can appear in a variable decl. It is not a normal expression that can + // go anywhere. + return false; + } + + if (expression.IsKind(SyntaxKind.BaseExpression) || + expression.IsKind(SyntaxKind.CollectionInitializerExpression) || + expression.IsKind(SyntaxKind.ObjectInitializerExpression) || + expression.IsKind(SyntaxKind.ComplexElementInitializerExpression)) + { + return false; + } + + // literal can be always replaced. + if (expression is LiteralExpressionSyntax && !expression.IsParentKind(SyntaxKind.UnaryMinusExpression)) + { + return true; + } + + if (expression is TupleExpressionSyntax) + { + return true; + } + + if (!(expression is ObjectCreationExpressionSyntax) && + !(expression is AnonymousObjectCreationExpressionSyntax) && + !expression.IsLeftSideOfAssignExpression()) + { + var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken); + if (!symbolInfo.GetBestOrAllSymbols().All(CanReplace)) + { + // If the expression is actually a reference to a type, then it can't be replaced + // with an arbitrary expression. + return false; + } + } + + // If we are a conditional access expression: + // case (1) : obj?.Method(), obj1.obj2?.Property + // case (2) : obj?.GetAnotherObj()?.Length, obj?.AnotherObj?.Length + // in case (1), the entire expression forms the conditional access expression, which can be replaced with an LValue. + // in case (2), the nested conditional access expression is ".GetAnotherObj()?.Length" or ".AnotherObj()?.Length" + // essentially, the first expression (before the operator) in a nested conditional access expression + // is some form of member binding expression and they cannot be replaced with an LValue. + if (expression.IsKind(SyntaxKind.ConditionalAccessExpression)) + { + return expression.Parent.Kind() != SyntaxKind.ConditionalAccessExpression; + } + + switch (expression.Parent.Kind()) + { + case SyntaxKind.InvocationExpression: + // Technically, you could introduce an LValue for "Goo" in "Goo()" even if "Goo" binds + // to a method. (i.e. by assigning to a Func<...> type). However, this is so contrived + // and none of the features that use this extension consider this replaceable. + if (expression.IsKind(SyntaxKind.IdentifierName) || expression is MemberAccessExpressionSyntax) + { + // If it looks like a method then we don't allow it to be replaced if it is a + // method (or if it doesn't bind). + + var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken); + return symbolInfo.GetBestOrAllSymbols().Any() && !symbolInfo.GetBestOrAllSymbols().Any(s => s is IMethodSymbol); + } + else + { + // It doesn't look like a method, we allow this to be replaced. + return true; + } + + // If the parent is a conditional access expression, we could introduce an LValue + // for the given expression, unless it is itself a MemberBindingExpression or starts with one. + // Case (1) : The WhenNotNull clause always starts with a MemberBindingExpression. + // expression '.Method()' in a?.Method() + // Case (2) : The Expression clause always starts with a MemberBindingExpression if + // the grandparent is a conditional access expression. + // expression '.Method' in a?.Method()?.Length + // Case (3) : The child Conditional access expression always starts with a MemberBindingExpression if + // the parent is a conditional access expression. This case is already covered before the parent kind switch + case SyntaxKind.ConditionalAccessExpression: + var parentConditionalAccessExpression = (ConditionalAccessExpressionSyntax)expression.Parent; + return expression != parentConditionalAccessExpression.WhenNotNull && + !parentConditionalAccessExpression.Parent.IsKind(SyntaxKind.ConditionalAccessExpression); + + case SyntaxKind.IsExpression: + case SyntaxKind.AsExpression: + // Can't introduce a variable for the type portion of an is/as check. + var isOrAsExpression = (BinaryExpressionSyntax)expression.Parent; + return expression == isOrAsExpression.Left; + case SyntaxKind.EqualsValueClause: + case SyntaxKind.ExpressionStatement: + case SyntaxKind.ArrayInitializerExpression: + case SyntaxKind.CollectionInitializerExpression: + case SyntaxKind.Argument: + case SyntaxKind.AttributeArgument: + case SyntaxKind.AnonymousObjectMemberDeclarator: + case SyntaxKind.ArrowExpressionClause: + case SyntaxKind.AwaitExpression: + case SyntaxKind.ReturnStatement: + case SyntaxKind.YieldReturnStatement: + case SyntaxKind.ParenthesizedLambdaExpression: + case SyntaxKind.SimpleLambdaExpression: + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.ArrayRankSpecifier: + case SyntaxKind.ConditionalExpression: + case SyntaxKind.IfStatement: + case SyntaxKind.CatchFilterClause: + case SyntaxKind.WhileStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.ThrowStatement: + case SyntaxKind.SwitchStatement: + case SyntaxKind.InterpolatedStringExpression: + case SyntaxKind.ComplexElementInitializerExpression: + case SyntaxKind.Interpolation: + case SyntaxKind.RefExpression: + case SyntaxKind.LockStatement: + case SyntaxKind.ElementAccessExpression: + // Direct parent kind checks. + return true; + } + + if (expression.Parent is PrefixUnaryExpressionSyntax) + { + if (!(expression is LiteralExpressionSyntax && expression.IsParentKind(SyntaxKind.UnaryMinusExpression))) + { + return true; + } + } + + var parentNonExpression = expression.GetAncestors().SkipWhile(n => n is ExpressionSyntax).FirstOrDefault(); + var topExpression = expression; + while (topExpression.Parent is TypeSyntax) + { + topExpression = (TypeSyntax)topExpression.Parent; + } + + if (parentNonExpression != null && + parentNonExpression.IsKind(SyntaxKind.FromClause) && + topExpression != null && + ((FromClauseSyntax)parentNonExpression).Type == topExpression) + { + return false; + } + + // Parent type checks. + if (expression.Parent is PostfixUnaryExpressionSyntax || + expression.Parent is BinaryExpressionSyntax || + expression.Parent is AssignmentExpressionSyntax || + expression.Parent is QueryClauseSyntax || + expression.Parent is SelectOrGroupClauseSyntax || + expression.Parent is CheckedExpressionSyntax) + { + return true; + } + + // Specific child checks. + if (expression.CheckParent(f => f.Expression == expression) || + expression.CheckParent(m => m.Expression == expression) || + expression.CheckParent(c => c.Expression == expression)) + { + return true; + } + + // Misc checks. + if ((expression.IsParentKind(SyntaxKind.NameEquals) && expression.Parent.IsParentKind(SyntaxKind.AttributeArgument)) || + expression.IsLeftSideOfAnyAssignExpression()) + { + return true; + } + + return false; + } + + public static bool CanAccessInstanceAndStaticMembersOffOf( + this ExpressionSyntax expression, + SemanticModel semanticModel, + CancellationToken cancellationToken) + { + // Check for the Color Color case. + // + // color color: if you bind "A" and you get a symbol and the type of that symbol is + // Q; and if you bind "A" *again* as a type and you get type Q, then both A.static + // and A.instance are permitted + if (expression is IdentifierNameSyntax) + { + var instanceSymbol = semanticModel.GetSymbolInfo(expression, cancellationToken).GetAnySymbol(); + + if (!(instanceSymbol is INamespaceOrTypeSymbol)) + { + var instanceType = instanceSymbol.GetSymbolType(); + if (instanceType != null) + { + var speculativeSymbolInfo = semanticModel.GetSpeculativeSymbolInfo(expression.SpanStart, expression, SpeculativeBindingOption.BindAsTypeOrNamespace); + if (speculativeSymbolInfo.CandidateReason != CandidateReason.NotATypeOrNamespace) + { + var staticType = speculativeSymbolInfo.GetAnySymbol().GetSymbolType(); + + return SymbolEquivalenceComparer.Instance.Equals(instanceType, staticType); + } + } + } + } + + return false; + } + + public static bool IsNameOfArgumentExpression(this ExpressionSyntax expression) + { + return expression.IsParentKind(SyntaxKind.Argument) && + expression.Parent.IsParentKind(SyntaxKind.ArgumentList) && + expression.Parent.Parent.Parent is InvocationExpressionSyntax invocation && + invocation.IsNameOfInvocation(); + } + + public static bool IsNameOfInvocation(this InvocationExpressionSyntax invocation) + { + return invocation.Expression is IdentifierNameSyntax identifierName && + identifierName.Identifier.IsKindOrHasMatchingText(SyntaxKind.NameOfKeyword); + } + + public static SimpleNameSyntax GetRightmostName(this ExpressionSyntax node) + { + if (node is MemberAccessExpressionSyntax memberAccess && memberAccess.Name != null) + { + return memberAccess.Name; + } + + if (node is QualifiedNameSyntax qualified && qualified.Right != null) + { + return qualified.Right; + } + + if (node is SimpleNameSyntax simple) + { + return simple; + } + + if (node is ConditionalAccessExpressionSyntax conditional) + { + return conditional.WhenNotNull.GetRightmostName(); + } + + if (node is MemberBindingExpressionSyntax memberBinding) + { + return memberBinding.Name; + } + + if (node is AliasQualifiedNameSyntax aliasQualifiedName && aliasQualifiedName.Name != null) + { + return aliasQualifiedName.Name; + } + + return null; + } + + public static OperatorPrecedence GetOperatorPrecedence(this ExpressionSyntax expression) + { + switch (expression.Kind()) + { + case SyntaxKind.SimpleMemberAccessExpression: + case SyntaxKind.ConditionalAccessExpression: + case SyntaxKind.InvocationExpression: + case SyntaxKind.ElementAccessExpression: + case SyntaxKind.PostIncrementExpression: + case SyntaxKind.PostDecrementExpression: + case SyntaxKind.ObjectCreationExpression: + case SyntaxKind.TypeOfExpression: + case SyntaxKind.DefaultExpression: + case SyntaxKind.CheckedExpression: + case SyntaxKind.UncheckedExpression: + case SyntaxKind.AnonymousMethodExpression: + // unsafe code + case SyntaxKind.SizeOfExpression: + case SyntaxKind.PointerMemberAccessExpression: + // From C# spec, 7.3.1: + // Primary: x.y x?.y x?[y] f(x) a[x] x++ x-- new typeof default checked unchecked delegate + + return OperatorPrecedence.Primary; + + case SyntaxKind.UnaryPlusExpression: + case SyntaxKind.UnaryMinusExpression: + case SyntaxKind.LogicalNotExpression: + case SyntaxKind.BitwiseNotExpression: + case SyntaxKind.PreIncrementExpression: + case SyntaxKind.PreDecrementExpression: + case SyntaxKind.CastExpression: + case SyntaxKind.AwaitExpression: + // unsafe code. + case SyntaxKind.PointerIndirectionExpression: + case SyntaxKind.AddressOfExpression: + + // From C# spec, 7.3.1: + // Unary: + - ! ~ ++x --x (T)x await Task + + return OperatorPrecedence.Unary; + + case SyntaxKind.MultiplyExpression: + case SyntaxKind.DivideExpression: + case SyntaxKind.ModuloExpression: + // From C# spec, 7.3.1: + // Multiplicative: * / % + + return OperatorPrecedence.Multiplicative; + + case SyntaxKind.AddExpression: + case SyntaxKind.SubtractExpression: + // From C# spec, 7.3.1: + // Additive: + - + + return OperatorPrecedence.Additive; + + case SyntaxKind.LeftShiftExpression: + case SyntaxKind.RightShiftExpression: + // From C# spec, 7.3.1: + // Shift: << >> + + return OperatorPrecedence.Shift; + + case SyntaxKind.LessThanExpression: + case SyntaxKind.GreaterThanExpression: + case SyntaxKind.LessThanOrEqualExpression: + case SyntaxKind.GreaterThanOrEqualExpression: + case SyntaxKind.IsExpression: + case SyntaxKind.AsExpression: + case SyntaxKind.IsPatternExpression: + // From C# spec, 7.3.1: + // Relational and type testing: < > <= >= is as + + return OperatorPrecedence.RelationalAndTypeTesting; + + case SyntaxKind.EqualsExpression: + case SyntaxKind.NotEqualsExpression: + // From C# spec, 7.3.1: + // Equality: == != + + return OperatorPrecedence.Equality; + + case SyntaxKind.BitwiseAndExpression: + // From C# spec, 7.3.1: + // Logical AND: & + + return OperatorPrecedence.LogicalAnd; + + case SyntaxKind.ExclusiveOrExpression: + // From C# spec, 7.3.1: + // Logical XOR: ^ + + return OperatorPrecedence.LogicalXor; + + case SyntaxKind.BitwiseOrExpression: + // From C# spec, 7.3.1: + // Logical OR: | + + return OperatorPrecedence.LogicalOr; + + case SyntaxKind.LogicalAndExpression: + // From C# spec, 7.3.1: + // Conditional AND: && + + return OperatorPrecedence.ConditionalAnd; + + case SyntaxKind.LogicalOrExpression: + // From C# spec, 7.3.1: + // Conditional AND: || + + return OperatorPrecedence.ConditionalOr; + + case SyntaxKind.CoalesceExpression: + // From C# spec, 7.3.1: + // Null coalescing: ?? + + return OperatorPrecedence.NullCoalescing; + + case SyntaxKind.ConditionalExpression: + // From C# spec, 7.3.1: + // Conditional: ?: + + return OperatorPrecedence.Conditional; + + case SyntaxKind.SimpleAssignmentExpression: + case SyntaxKind.MultiplyAssignmentExpression: + case SyntaxKind.DivideAssignmentExpression: + case SyntaxKind.ModuloAssignmentExpression: + case SyntaxKind.AddAssignmentExpression: + case SyntaxKind.SubtractAssignmentExpression: + case SyntaxKind.LeftShiftAssignmentExpression: + case SyntaxKind.RightShiftAssignmentExpression: + case SyntaxKind.AndAssignmentExpression: + case SyntaxKind.ExclusiveOrAssignmentExpression: + case SyntaxKind.OrAssignmentExpression: + case SyntaxKind.SimpleLambdaExpression: + case SyntaxKind.ParenthesizedLambdaExpression: + // From C# spec, 7.3.1: + // Conditional: ?: + + return OperatorPrecedence.AssignmentAndLambdaExpression; + + default: + return OperatorPrecedence.None; + } + } + + public static bool TryConvertToStatement( + this ExpressionSyntax expression, + SyntaxToken? semicolonTokenOpt, + bool createReturnStatementForExpression, + out StatementSyntax statement) + { + // It's tricky to convert an arrow expression with directives over to a block. + // We'd need to find and remove the directives *after* the arrow expression and + // move them accordingly. So, for now, we just disallow this. + if (expression.GetLeadingTrivia().Any(t => t.IsDirective)) + { + statement = null; + return false; + } + + var semicolonToken = semicolonTokenOpt ?? SyntaxFactory.Token(SyntaxKind.SemicolonToken); + + statement = ConvertToStatement(expression, semicolonToken, createReturnStatementForExpression); + return true; + } + + private static StatementSyntax ConvertToStatement(ExpressionSyntax expression, SyntaxToken semicolonToken, bool createReturnStatementForExpression) + { + if (expression.IsKind(SyntaxKind.ThrowExpression, out ThrowExpressionSyntax throwExpression)) + { + return SyntaxFactory.ThrowStatement(throwExpression.ThrowKeyword, throwExpression.Expression, semicolonToken); + } + else if (createReturnStatementForExpression) + { + if (expression.GetLeadingTrivia().Any(t => t.IsSingleOrMultiLineComment())) + { + return SyntaxFactory.ReturnStatement(expression.WithLeadingTrivia(SyntaxFactory.ElasticSpace)) + .WithSemicolonToken(semicolonToken) + .WithLeadingTrivia(expression.GetLeadingTrivia()) + .WithPrependedLeadingTrivia(SyntaxFactory.ElasticMarker); + } + else + { + return SyntaxFactory.ReturnStatement(expression) + .WithSemicolonToken(semicolonToken); + } + } + else + { + return SyntaxFactory.ExpressionStatement(expression) + .WithSemicolonToken(semicolonToken); + } + } + + public static bool IsDirectChildOfMemberAccessExpression(this ExpressionSyntax expression) => + expression?.Parent is MemberAccessExpressionSyntax; + + public static bool InsideCrefReference(this ExpressionSyntax expression) + => expression.FirstAncestorOrSelf() != null; + } +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/OperatorPrecedence.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/OperatorPrecedence.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/OperatorPrecedence.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/OperatorPrecedence.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SimpleNameSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SimpleNameSyntaxExtensions.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SimpleNameSyntaxExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SimpleNameSyntaxExtensions.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions.cs similarity index 71% rename from src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions.cs index 2a848399fe5f1..17084a79b341c 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions_SharedWithCodeStyle.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; -using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; @@ -36,16 +35,16 @@ public static bool IsKind([NotNullWhen(returnValue: true)] this SyntaxNod return false; } - public static bool IsParentKind(this SyntaxNode node, SyntaxKind kind) + public static bool IsParentKind([NotNullWhen(returnValue: true)] this SyntaxNode? node, SyntaxKind kind) => CodeAnalysis.CSharpExtensions.IsKind(node?.Parent, kind); - public static bool IsParentKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2) + public static bool IsParentKind([NotNullWhen(returnValue: true)] this SyntaxNode? node, SyntaxKind kind1, SyntaxKind kind2) => IsKind(node?.Parent, kind1, kind2); - public static bool IsParentKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3) + public static bool IsParentKind([NotNullWhen(returnValue: true)] this SyntaxNode? node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3) => IsKind(node?.Parent, kind1, kind2, kind3); - public static bool IsParentKind(this SyntaxNode node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3, SyntaxKind kind4) + public static bool IsParentKind([NotNullWhen(returnValue: true)] this SyntaxNode? node, SyntaxKind kind1, SyntaxKind kind2, SyntaxKind kind3, SyntaxKind kind4) => IsKind(node?.Parent, kind1, kind2, kind3, kind4); public static bool IsKind([NotNullWhen(returnValue: true)] this SyntaxNode? node, SyntaxKind kind1, SyntaxKind kind2) @@ -245,5 +244,106 @@ public static SyntaxList GetAttributeLists(this SyntaxNode CompilationUnitSyntax compilationUnit => compilationUnit.AttributeLists, _ => default, }; + + public static ConditionalAccessExpressionSyntax? GetParentConditionalAccessExpression(this SyntaxNode node) + { + var current = node; + while (current?.Parent != null) + { + if (current.IsParentKind(SyntaxKind.ConditionalAccessExpression) && + ((ConditionalAccessExpressionSyntax)current.Parent).WhenNotNull == current) + { + return (ConditionalAccessExpressionSyntax)current.Parent; + } + + current = current.Parent; + } + + return null; + } + + public static ConditionalAccessExpressionSyntax? GetInnerMostConditionalAccessExpression(this SyntaxNode node) + { + if (!(node is ConditionalAccessExpressionSyntax)) + { + return null; + } + + var result = (ConditionalAccessExpressionSyntax)node; + while (result.WhenNotNull is ConditionalAccessExpressionSyntax) + { + result = (ConditionalAccessExpressionSyntax)result.WhenNotNull; + } + + return result; + } + + public static bool IsAsyncSupportingFunctionSyntax([NotNullWhen(returnValue: true)] this SyntaxNode? node) + { + return node.IsKind(SyntaxKind.MethodDeclaration) + || node.IsAnyLambdaOrAnonymousMethod() + || node.IsKind(SyntaxKind.LocalFunctionStatement); + } + + public static bool IsAnyLambda([NotNullWhen(returnValue: true)] this SyntaxNode? node) + { + return + node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) || + node.IsKind(SyntaxKind.SimpleLambdaExpression); + } + + public static bool IsAnyLambdaOrAnonymousMethod([NotNullWhen(returnValue: true)] this SyntaxNode? node) + => node.IsAnyLambda() || node.IsKind(SyntaxKind.AnonymousMethodExpression); + + public static bool IsAnyAssignExpression(this SyntaxNode node) + => SyntaxFacts.IsAssignmentExpression(node.Kind()); + + public static bool IsCompoundAssignExpression(this SyntaxNode node) + { + switch (node.Kind()) + { + case SyntaxKind.CoalesceAssignmentExpression: + case SyntaxKind.AddAssignmentExpression: + case SyntaxKind.SubtractAssignmentExpression: + case SyntaxKind.MultiplyAssignmentExpression: + case SyntaxKind.DivideAssignmentExpression: + case SyntaxKind.ModuloAssignmentExpression: + case SyntaxKind.AndAssignmentExpression: + case SyntaxKind.ExclusiveOrAssignmentExpression: + case SyntaxKind.OrAssignmentExpression: + case SyntaxKind.LeftShiftAssignmentExpression: + case SyntaxKind.RightShiftAssignmentExpression: + return true; + } + + return false; + } + + public static bool IsLeftSideOfAssignExpression([NotNullWhen(returnValue: true)] this SyntaxNode? node) + { + return node.IsParentKind(SyntaxKind.SimpleAssignmentExpression) && + ((AssignmentExpressionSyntax)node.Parent!).Left == node; + } + + public static bool IsLeftSideOfAnyAssignExpression(this SyntaxNode node) + { + return node?.Parent != null && + node.Parent.IsAnyAssignExpression() && + ((AssignmentExpressionSyntax)node.Parent).Left == node; + } + + public static bool IsRightSideOfAnyAssignExpression(this SyntaxNode node) + { + return node?.Parent != null && + node.Parent.IsAnyAssignExpression() && + ((AssignmentExpressionSyntax)node.Parent).Right == node; + } + + public static bool IsLeftSideOfCompoundAssignExpression(this SyntaxNode node) + { + return node?.Parent != null && + node.Parent.IsCompoundAssignExpression() && + ((AssignmentExpressionSyntax)node.Parent).Left == node; + } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions.cs similarity index 76% rename from src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions.cs index 880454bc2807f..14853695830b7 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions_SharedWithCodeStyle.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxTokenExtensions.cs @@ -70,5 +70,29 @@ public static bool IsOpenBraceOfAccessorList(this SyntaxToken token) { return token.IsKind(SyntaxKind.OpenBraceToken) && token.Parent.IsKind(SyntaxKind.AccessorList); } + + /// + /// Returns true if this token is something that looks like a C# keyword. This includes + /// actual keywords, contextual keywords, and even 'var' and 'dynamic' + /// + /// + /// + public static bool CouldBeKeyword(this SyntaxToken token) + { + if (token.IsKeyword()) + { + return true; + } + + if (token.Kind() == SyntaxKind.IdentifierToken) + { + var simpleNameText = token.ValueText; + return simpleNameText == "var" || + simpleNameText == "dynamic" || + SyntaxFacts.GetContextualKeywordKind(simpleNameText) != SyntaxKind.None; + } + + return false; + } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/TypeSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/TypeSyntaxExtensions.cs new file mode 100644 index 0000000000000..fdeb730e2d698 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/TypeSyntaxExtensions.cs @@ -0,0 +1,55 @@ +// 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 Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Microsoft.CodeAnalysis.CSharp.Extensions +{ + internal static partial class TypeSyntaxExtensions + { + public static bool IsVoid(this TypeSyntax typeSyntax) + { + return typeSyntax.IsKind(SyntaxKind.PredefinedType) && + ((PredefinedTypeSyntax)typeSyntax).Keyword.IsKind(SyntaxKind.VoidKeyword); + } + + public static bool IsPartial(this TypeSyntax typeSyntax) + { + return typeSyntax is IdentifierNameSyntax && + ((IdentifierNameSyntax)typeSyntax).Identifier.IsKind(SyntaxKind.PartialKeyword); + } + + /// + /// Determines whether the specified TypeSyntax is actually 'var'. + /// + public static bool IsTypeInferred(this TypeSyntax typeSyntax, SemanticModel semanticModel) + { + if (!typeSyntax.IsVar) + { + return false; + } + + if (semanticModel.GetAliasInfo(typeSyntax) != null) + { + return false; + } + + var type = semanticModel.GetTypeInfo(typeSyntax).Type; + if (type == null) + { + return false; + } + + if (type.Name == "var") + { + return false; + } + + return true; + } + + public static TypeSyntax StripRefIfNeeded(this TypeSyntax type) + => type is RefTypeSyntax refType ? refType.Type : type; + } +} diff --git a/src/Workspaces/CSharp/Portable/Utilities/CSharpTypeStyleHelper.State.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpTypeStyleHelper.State.cs similarity index 96% rename from src/Workspaces/CSharp/Portable/Utilities/CSharpTypeStyleHelper.State.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpTypeStyleHelper.State.cs index 7fea1e81d1dd9..2b3539250ac2c 100644 --- a/src/Workspaces/CSharp/Portable/Utilities/CSharpTypeStyleHelper.State.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpTypeStyleHelper.State.cs @@ -3,13 +3,20 @@ // See the LICENSE file in the project root for more information. using System.Threading; -using Microsoft.CodeAnalysis.CSharp.CodeStyle; -using Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; +#if CODE_STYLE +using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle; +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle.TypeStyle; +#else +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.CSharp.CodeStyle; +using Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle; +#endif + namespace Microsoft.CodeAnalysis.CSharp.Utilities { internal partial class CSharpTypeStyleHelper diff --git a/src/Workspaces/CSharp/Portable/Utilities/CSharpTypeStyleHelper.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpTypeStyleHelper.cs similarity index 97% rename from src/Workspaces/CSharp/Portable/Utilities/CSharpTypeStyleHelper.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpTypeStyleHelper.cs index dcb083989d6cf..2de0862f3d2c2 100644 --- a/src/Workspaces/CSharp/Portable/Utilities/CSharpTypeStyleHelper.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpTypeStyleHelper.cs @@ -7,7 +7,13 @@ using System.Threading; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; + +#if CODE_STYLE +using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +using Microsoft.CodeAnalysis.Internal.Options; +#else using Microsoft.CodeAnalysis.Options; +#endif namespace Microsoft.CodeAnalysis.CSharp.Utilities { diff --git a/src/Workspaces/CSharp/Portable/Utilities/CSharpUseExplicitTypeHelper.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpUseExplicitTypeHelper.cs similarity index 97% rename from src/Workspaces/CSharp/Portable/Utilities/CSharpUseExplicitTypeHelper.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpUseExplicitTypeHelper.cs index 29f142d69c934..7228a1a803fe1 100644 --- a/src/Workspaces/CSharp/Portable/Utilities/CSharpUseExplicitTypeHelper.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpUseExplicitTypeHelper.cs @@ -4,12 +4,18 @@ using System.Threading; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; +#if CODE_STYLE +using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle.TypeStyle; +#else +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle; +#endif + namespace Microsoft.CodeAnalysis.CSharp.Utilities { internal sealed class CSharpUseExplicitTypeHelper : CSharpTypeStyleHelper diff --git a/src/Workspaces/CSharp/Portable/Utilities/CSharpUseImplicitTypeHelper.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpUseImplicitTypeHelper.cs similarity index 98% rename from src/Workspaces/CSharp/Portable/Utilities/CSharpUseImplicitTypeHelper.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpUseImplicitTypeHelper.cs index 2c1a29c8707a2..97c794630d148 100644 --- a/src/Workspaces/CSharp/Portable/Utilities/CSharpUseImplicitTypeHelper.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Utilities/TypeStyle/CSharpUseImplicitTypeHelper.cs @@ -6,14 +6,20 @@ using System.Linq; using System.Threading; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Simplification; +#if CODE_STYLE +using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle.TypeStyle; +#else +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle; +#endif + namespace Microsoft.CodeAnalysis.CSharp.Utilities { internal sealed class CSharpUseImplicitTypeHelper : CSharpTypeStyleHelper diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 9813fff26aca7..536fa84baaa83 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -187,6 +187,11 @@ + + + + + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.cs index 004e62345414a..0e4c1ff2edcd3 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ITypeSymbolExtensions.cs @@ -726,5 +726,16 @@ public static ITypeSymbol WithNullableAnnotation(this ITypeSymbol type, Nullable return type.WithNullableAnnotation(nullableAnnotation); #endif } + + [return: NotNullIfNotNull(parameterName: "symbol")] + public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol) + { + if (symbol.IsNullable()) + { + return symbol.GetTypeArguments().Single(); + } + + return symbol; + } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/AliasAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/AliasAnnotation.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/AliasAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/AliasAnnotation.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/DoNotAddImportsAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/DoNotAddImportsAnnotation.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/DoNotAddImportsAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/DoNotAddImportsAnnotation.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/DoNotAllowVarAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/DoNotAllowVarAnnotation.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/DoNotAllowVarAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/DoNotAllowVarAnnotation.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SpecialTypeAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/SpecialTypeAnnotation.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SpecialTypeAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/SpecialTypeAnnotation.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SymbolAnnotation.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/SymbolAnnotation.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SymbolAnnotation.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Simplification/SymbolAnnotation.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems index 81fbe939e47b1..f7cf9ccc55958 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems @@ -11,7 +11,6 @@ - @@ -40,12 +39,10 @@ - - diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs index 465b52bf00c72..c35172c8b0a42 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ExpressionSyntaxExtensions.cs @@ -2,40 +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.Collections.Generic; -using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Utilities; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Simplification; -using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.Extensions { internal static partial class ExpressionSyntaxExtensions { - public static ExpressionSyntax WalkUpParentheses(this ExpressionSyntax expression) - { - while (expression.IsParentKind(SyntaxKind.ParenthesizedExpression)) - { - expression = (ExpressionSyntax)expression.Parent; - } - - return expression; - } - - public static ExpressionSyntax WalkDownParentheses(this ExpressionSyntax expression) - { - while (expression.IsKind(SyntaxKind.ParenthesizedExpression)) - { - expression = ((ParenthesizedExpressionSyntax)expression).Expression; - } - - return expression; - } - public static ExpressionSyntax Parenthesize( this ExpressionSyntax expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true) { @@ -133,863 +109,6 @@ public static ExpressionSyntax CastIfPossible( return castExpression; } - - public static bool IsQualifiedCrefName(this ExpressionSyntax expression) - { - return expression.IsParentKind(SyntaxKind.NameMemberCref) && expression.Parent.IsParentKind(SyntaxKind.QualifiedCref); - } - - public static bool IsMemberAccessExpressionName(this ExpressionSyntax expression) - { - return (expression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) && ((MemberAccessExpressionSyntax)expression.Parent).Name == expression) || - IsMemberBindingExpressionName(expression); - } - - public static bool IsAnyMemberAccessExpressionName(this ExpressionSyntax expression) - { - if (expression == null) - { - return false; - } - - return expression == (expression.Parent as MemberAccessExpressionSyntax)?.Name || - expression.IsMemberBindingExpressionName(); - } - - private static bool IsMemberBindingExpressionName(this ExpressionSyntax expression) - { - return expression.IsParentKind(SyntaxKind.MemberBindingExpression) && - ((MemberBindingExpressionSyntax)expression.Parent).Name == expression; - } - - public static bool IsRightSideOfQualifiedName(this ExpressionSyntax expression) - { - return expression.IsParentKind(SyntaxKind.QualifiedName) && ((QualifiedNameSyntax)expression.Parent).Right == expression; - } - - public static bool IsRightSideOfColonColon(this ExpressionSyntax expression) - { - return expression.IsParentKind(SyntaxKind.AliasQualifiedName) && ((AliasQualifiedNameSyntax)expression.Parent).Name == expression; - } - - public static bool IsRightSideOfDot(this ExpressionSyntax name) - { - return IsMemberAccessExpressionName(name) || IsRightSideOfQualifiedName(name) || IsQualifiedCrefName(name); - } - - public static bool IsRightSideOfDotOrArrow(this ExpressionSyntax name) - { - return IsAnyMemberAccessExpressionName(name) || IsRightSideOfQualifiedName(name); - } - - public static bool IsRightSideOfDotOrColonColon(this ExpressionSyntax name) - { - return IsRightSideOfDot(name) || IsRightSideOfColonColon(name); - } - - public static bool IsRightSideOfDotOrArrowOrColonColon(this ExpressionSyntax name) - { - return IsRightSideOfDotOrArrow(name) || IsRightSideOfColonColon(name); - } - - public static bool IsRightOfCloseParen(this ExpressionSyntax expression) - { - var firstToken = expression.GetFirstToken(); - return firstToken.Kind() != SyntaxKind.None - && firstToken.GetPreviousToken().Kind() == SyntaxKind.CloseParenToken; - } - - public static bool IsLeftSideOfDot(this ExpressionSyntax expression) - { - if (expression == null) - { - return false; - } - - return IsLeftSideOfQualifiedName(expression) || - IsLeftSideOfSimpleMemberAccessExpression(expression); - } - - public static bool IsLeftSideOfSimpleMemberAccessExpression(this ExpressionSyntax expression) - => (expression?.Parent).IsKind(SyntaxKind.SimpleMemberAccessExpression, out MemberAccessExpressionSyntax memberAccess) && - memberAccess.Expression == expression; - - public static bool IsLeftSideOfDotOrArrow(this ExpressionSyntax expression) - => IsLeftSideOfQualifiedName(expression) || - (expression.Parent is MemberAccessExpressionSyntax memberAccess && memberAccess.Expression == expression); - - public static bool IsLeftSideOfQualifiedName(this ExpressionSyntax expression) - => (expression?.Parent).IsKind(SyntaxKind.QualifiedName, out QualifiedNameSyntax qualifiedName) && qualifiedName.Left == expression; - - public static bool IsLeftSideOfExplicitInterfaceSpecifier(this NameSyntax name) - => name.IsParentKind(SyntaxKind.ExplicitInterfaceSpecifier); - - public static bool IsExpressionOfInvocation(this ExpressionSyntax expression) - => (expression?.Parent).IsKind(SyntaxKind.InvocationExpression, out InvocationExpressionSyntax invocation) && - invocation.Expression == expression; - - public static bool TryGetNameParts(this ExpressionSyntax expression, out IList parts) - { - var partsList = new List(); - if (!TryGetNameParts(expression, partsList)) - { - parts = null; - return false; - } - - parts = partsList; - return true; - } - - public static bool TryGetNameParts(this ExpressionSyntax expression, List parts) - { - if (expression.IsKind(SyntaxKind.SimpleMemberAccessExpression, out MemberAccessExpressionSyntax memberAccess)) - { - if (!TryGetNameParts(memberAccess.Expression, parts)) - { - return false; - } - - return AddSimpleName(memberAccess.Name, parts); - } - else if (expression.IsKind(SyntaxKind.QualifiedName, out QualifiedNameSyntax qualifiedName)) - { - if (!TryGetNameParts(qualifiedName.Left, parts)) - { - return false; - } - - return AddSimpleName(qualifiedName.Right, parts); - } - else if (expression is SimpleNameSyntax simpleName) - { - return AddSimpleName(simpleName, parts); - } - else - { - return false; - } - } - - private static bool AddSimpleName(SimpleNameSyntax simpleName, List parts) - { - if (!simpleName.IsKind(SyntaxKind.IdentifierName)) - { - return false; - } - - parts.Add(simpleName.Identifier.ValueText); - return true; - } - - public static bool IsAnyLiteralExpression(this ExpressionSyntax expression) - { - return - expression.IsKind(SyntaxKind.CharacterLiteralExpression) || - expression.IsKind(SyntaxKind.FalseLiteralExpression) || - expression.IsKind(SyntaxKind.NullLiteralExpression) || - expression.IsKind(SyntaxKind.NumericLiteralExpression) || - expression.IsKind(SyntaxKind.StringLiteralExpression) || - expression.IsKind(SyntaxKind.TrueLiteralExpression); - } - - public static bool IsInConstantContext(this ExpressionSyntax expression) - { - if (expression.GetAncestor() != null) - { - return true; - } - - var attributeArgument = expression.GetAncestor(); - if (attributeArgument != null) - { - if (attributeArgument.NameEquals == null || - expression != attributeArgument.NameEquals.Name) - { - return true; - } - } - - if (expression.IsParentKind(SyntaxKind.ConstantPattern)) - { - return true; - } - - // note: the above list is not intended to be exhaustive. If more cases - // are discovered that should be considered 'constant' contexts in the - // language, then this should be updated accordingly. - return false; - } - - public static bool IsInOutContext(this ExpressionSyntax expression) - { - return - expression?.Parent is ArgumentSyntax argument && - argument.Expression == expression && - argument.RefOrOutKeyword.Kind() == SyntaxKind.OutKeyword; - } - - public static bool IsInRefContext(this ExpressionSyntax expression) - => expression.IsParentKind(SyntaxKind.RefExpression) || - (expression?.Parent as ArgumentSyntax)?.RefOrOutKeyword.Kind() == SyntaxKind.RefKeyword; - - public static bool IsInInContext(this ExpressionSyntax expression) - => (expression?.Parent as ArgumentSyntax)?.RefKindKeyword.Kind() == SyntaxKind.InKeyword; - - private static ExpressionSyntax GetExpressionToAnalyzeForWrites(ExpressionSyntax expression) - { - if (expression.IsRightSideOfDotOrArrow()) - { - expression = expression.Parent as ExpressionSyntax; - } - - expression = expression.WalkUpParentheses(); - - return expression; - } - - public static bool IsOnlyWrittenTo(this ExpressionSyntax expression) - { - expression = GetExpressionToAnalyzeForWrites(expression); - - if (expression != null) - { - if (expression.IsInOutContext()) - { - return true; - } - - if (expression.Parent != null) - { - if (expression.IsLeftSideOfAssignExpression()) - { - return true; - } - - if (expression.IsAttributeNamedArgumentIdentifier()) - { - return true; - } - } - - if (IsExpressionOfArgumentInDeconstruction(expression)) - { - return true; - } - } - - return false; - } - - /// - /// If this declaration or identifier is part of a deconstruction, find the deconstruction. - /// If found, returns either an assignment expression or a foreach variable statement. - /// Returns null otherwise. - /// - /// copied from SyntaxExtensions.GetContainingDeconstruction - /// - private static bool IsExpressionOfArgumentInDeconstruction(ExpressionSyntax expr) - { - if (!expr.IsParentKind(SyntaxKind.Argument)) - { - return false; - } - - while (true) - { - var parent = expr.Parent; - if (parent == null) - { - return false; - } - - switch (parent.Kind()) - { - case SyntaxKind.Argument: - if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) - { - expr = (TupleExpressionSyntax)parent.Parent; - continue; - } - - return false; - case SyntaxKind.SimpleAssignmentExpression: - if (((AssignmentExpressionSyntax)parent).Left == expr) - { - return true; - } - - return false; - case SyntaxKind.ForEachVariableStatement: - if (((ForEachVariableStatementSyntax)parent).Variable == expr) - { - return true; - } - - return false; - - default: - return false; - } - } - } - - public static bool IsWrittenTo(this ExpressionSyntax expression) - { - expression = GetExpressionToAnalyzeForWrites(expression); - - if (expression.IsOnlyWrittenTo()) - { - return true; - } - - if (expression.IsInRefContext()) - { - return true; - } - - // We're written if we're used in a ++, or -- expression. - if (expression.IsOperandOfIncrementOrDecrementExpression()) - { - return true; - } - - if (expression.IsLeftSideOfAnyAssignExpression()) - { - return true; - } - - return false; - } - - public static bool IsAttributeNamedArgumentIdentifier(this ExpressionSyntax expression) - { - var nameEquals = expression?.Parent as NameEqualsSyntax; - return nameEquals.IsParentKind(SyntaxKind.AttributeArgument); - } - - public static bool IsOperandOfIncrementOrDecrementExpression(this ExpressionSyntax expression) - { - if (expression != null) - { - switch (expression.Parent.Kind()) - { - case SyntaxKind.PostIncrementExpression: - case SyntaxKind.PreIncrementExpression: - case SyntaxKind.PostDecrementExpression: - case SyntaxKind.PreDecrementExpression: - return true; - } - } - - return false; - } - - public static bool IsNamedArgumentIdentifier(this ExpressionSyntax expression) - { - return expression is IdentifierNameSyntax && expression.Parent is NameColonSyntax; - } - - public static bool IsInsideNameOfExpression( - this ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken) - { - var invocation = expression?.GetAncestor(); - if (invocation?.Expression is IdentifierNameSyntax name && - name.Identifier.Text == SyntaxFacts.GetText(SyntaxKind.NameOfKeyword)) - { - return semanticModel.GetMemberGroup(name, cancellationToken).IsDefaultOrEmpty; - } - - return false; - } - - private static bool CanReplace(ISymbol symbol) - { - switch (symbol.Kind) - { - case SymbolKind.Field: - case SymbolKind.Local: - case SymbolKind.Method: - case SymbolKind.Parameter: - case SymbolKind.Property: - case SymbolKind.RangeVariable: - return true; - } - - return false; - } - - public static bool CanReplaceWithRValue( - this ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken) - { - // An RValue can't be written into. - // i.e. you can't replace "a" in "a = b" with "Goo() = b". - return - expression != null && - !expression.IsWrittenTo() && - CanReplaceWithLValue(expression, semanticModel, cancellationToken); - } - - public static bool CanReplaceWithLValue( - this ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken) - { - if (expression.IsKind(SyntaxKind.StackAllocArrayCreationExpression)) - { - // Stack alloc is very interesting. While it appears to be an expression, it is only - // such so it can appear in a variable decl. It is not a normal expression that can - // go anywhere. - return false; - } - - if (expression.IsKind(SyntaxKind.BaseExpression) || - expression.IsKind(SyntaxKind.CollectionInitializerExpression) || - expression.IsKind(SyntaxKind.ObjectInitializerExpression) || - expression.IsKind(SyntaxKind.ComplexElementInitializerExpression)) - { - return false; - } - - // literal can be always replaced. - if (expression is LiteralExpressionSyntax && !expression.IsParentKind(SyntaxKind.UnaryMinusExpression)) - { - return true; - } - - if (expression is TupleExpressionSyntax) - { - return true; - } - - if (!(expression is ObjectCreationExpressionSyntax) && - !(expression is AnonymousObjectCreationExpressionSyntax) && - !expression.IsLeftSideOfAssignExpression()) - { - var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken); - if (!symbolInfo.GetBestOrAllSymbols().All(CanReplace)) - { - // If the expression is actually a reference to a type, then it can't be replaced - // with an arbitrary expression. - return false; - } - } - - // If we are a conditional access expression: - // case (1) : obj?.Method(), obj1.obj2?.Property - // case (2) : obj?.GetAnotherObj()?.Length, obj?.AnotherObj?.Length - // in case (1), the entire expression forms the conditional access expression, which can be replaced with an LValue. - // in case (2), the nested conditional access expression is ".GetAnotherObj()?.Length" or ".AnotherObj()?.Length" - // essentially, the first expression (before the operator) in a nested conditional access expression - // is some form of member binding expression and they cannot be replaced with an LValue. - if (expression.IsKind(SyntaxKind.ConditionalAccessExpression)) - { - return expression.Parent.Kind() != SyntaxKind.ConditionalAccessExpression; - } - - switch (expression.Parent.Kind()) - { - case SyntaxKind.InvocationExpression: - // Technically, you could introduce an LValue for "Goo" in "Goo()" even if "Goo" binds - // to a method. (i.e. by assigning to a Func<...> type). However, this is so contrived - // and none of the features that use this extension consider this replaceable. - if (expression.IsKind(SyntaxKind.IdentifierName) || expression is MemberAccessExpressionSyntax) - { - // If it looks like a method then we don't allow it to be replaced if it is a - // method (or if it doesn't bind). - - var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken); - return symbolInfo.GetBestOrAllSymbols().Any() && !symbolInfo.GetBestOrAllSymbols().Any(s => s is IMethodSymbol); - } - else - { - // It doesn't look like a method, we allow this to be replaced. - return true; - } - - // If the parent is a conditional access expression, we could introduce an LValue - // for the given expression, unless it is itself a MemberBindingExpression or starts with one. - // Case (1) : The WhenNotNull clause always starts with a MemberBindingExpression. - // expression '.Method()' in a?.Method() - // Case (2) : The Expression clause always starts with a MemberBindingExpression if - // the grandparent is a conditional access expression. - // expression '.Method' in a?.Method()?.Length - // Case (3) : The child Conditional access expression always starts with a MemberBindingExpression if - // the parent is a conditional access expression. This case is already covered before the parent kind switch - case SyntaxKind.ConditionalAccessExpression: - var parentConditionalAccessExpression = (ConditionalAccessExpressionSyntax)expression.Parent; - return expression != parentConditionalAccessExpression.WhenNotNull && - !parentConditionalAccessExpression.Parent.IsKind(SyntaxKind.ConditionalAccessExpression); - - case SyntaxKind.IsExpression: - case SyntaxKind.AsExpression: - // Can't introduce a variable for the type portion of an is/as check. - var isOrAsExpression = (BinaryExpressionSyntax)expression.Parent; - return expression == isOrAsExpression.Left; - case SyntaxKind.EqualsValueClause: - case SyntaxKind.ExpressionStatement: - case SyntaxKind.ArrayInitializerExpression: - case SyntaxKind.CollectionInitializerExpression: - case SyntaxKind.Argument: - case SyntaxKind.AttributeArgument: - case SyntaxKind.AnonymousObjectMemberDeclarator: - case SyntaxKind.ArrowExpressionClause: - case SyntaxKind.AwaitExpression: - case SyntaxKind.ReturnStatement: - case SyntaxKind.YieldReturnStatement: - case SyntaxKind.ParenthesizedLambdaExpression: - case SyntaxKind.SimpleLambdaExpression: - case SyntaxKind.ParenthesizedExpression: - case SyntaxKind.ArrayRankSpecifier: - case SyntaxKind.ConditionalExpression: - case SyntaxKind.IfStatement: - case SyntaxKind.CatchFilterClause: - case SyntaxKind.WhileStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.ThrowStatement: - case SyntaxKind.SwitchStatement: - case SyntaxKind.InterpolatedStringExpression: - case SyntaxKind.ComplexElementInitializerExpression: - case SyntaxKind.Interpolation: - case SyntaxKind.RefExpression: - case SyntaxKind.LockStatement: - case SyntaxKind.ElementAccessExpression: - // Direct parent kind checks. - return true; - } - - if (expression.Parent is PrefixUnaryExpressionSyntax) - { - if (!(expression is LiteralExpressionSyntax && expression.IsParentKind(SyntaxKind.UnaryMinusExpression))) - { - return true; - } - } - - var parentNonExpression = expression.GetAncestors().SkipWhile(n => n is ExpressionSyntax).FirstOrDefault(); - var topExpression = expression; - while (topExpression.Parent is TypeSyntax) - { - topExpression = (TypeSyntax)topExpression.Parent; - } - - if (parentNonExpression != null && - parentNonExpression.IsKind(SyntaxKind.FromClause) && - topExpression != null && - ((FromClauseSyntax)parentNonExpression).Type == topExpression) - { - return false; - } - - // Parent type checks. - if (expression.Parent is PostfixUnaryExpressionSyntax || - expression.Parent is BinaryExpressionSyntax || - expression.Parent is AssignmentExpressionSyntax || - expression.Parent is QueryClauseSyntax || - expression.Parent is SelectOrGroupClauseSyntax || - expression.Parent is CheckedExpressionSyntax) - { - return true; - } - - // Specific child checks. - if (expression.CheckParent(f => f.Expression == expression) || - expression.CheckParent(m => m.Expression == expression) || - expression.CheckParent(c => c.Expression == expression)) - { - return true; - } - - // Misc checks. - if ((expression.IsParentKind(SyntaxKind.NameEquals) && expression.Parent.IsParentKind(SyntaxKind.AttributeArgument)) || - expression.IsLeftSideOfAnyAssignExpression()) - { - return true; - } - - return false; - } - - public static bool CanAccessInstanceAndStaticMembersOffOf( - this ExpressionSyntax expression, - SemanticModel semanticModel, - CancellationToken cancellationToken) - { - // Check for the Color Color case. - // - // color color: if you bind "A" and you get a symbol and the type of that symbol is - // Q; and if you bind "A" *again* as a type and you get type Q, then both A.static - // and A.instance are permitted - if (expression is IdentifierNameSyntax) - { - var instanceSymbol = semanticModel.GetSymbolInfo(expression, cancellationToken).GetAnySymbol(); - - if (!(instanceSymbol is INamespaceOrTypeSymbol)) - { - var instanceType = instanceSymbol.GetSymbolType(); - if (instanceType != null) - { - var speculativeSymbolInfo = semanticModel.GetSpeculativeSymbolInfo(expression.SpanStart, expression, SpeculativeBindingOption.BindAsTypeOrNamespace); - if (speculativeSymbolInfo.CandidateReason != CandidateReason.NotATypeOrNamespace) - { - var staticType = speculativeSymbolInfo.GetAnySymbol().GetSymbolType(); - - return SymbolEquivalenceComparer.Instance.Equals(instanceType, staticType); - } - } - } - } - - return false; - } - - public static bool IsNameOfArgumentExpression(this ExpressionSyntax expression) - { - return expression.IsParentKind(SyntaxKind.Argument) && - expression.Parent.IsParentKind(SyntaxKind.ArgumentList) && - expression.Parent.Parent.Parent is InvocationExpressionSyntax invocation && - invocation.IsNameOfInvocation(); - } - - public static bool IsNameOfInvocation(this InvocationExpressionSyntax invocation) - { - return invocation.Expression is IdentifierNameSyntax identifierName && - identifierName.Identifier.IsKindOrHasMatchingText(SyntaxKind.NameOfKeyword); - } - - public static SimpleNameSyntax GetRightmostName(this ExpressionSyntax node) - { - if (node is MemberAccessExpressionSyntax memberAccess && memberAccess.Name != null) - { - return memberAccess.Name; - } - - if (node is QualifiedNameSyntax qualified && qualified.Right != null) - { - return qualified.Right; - } - - if (node is SimpleNameSyntax simple) - { - return simple; - } - - if (node is ConditionalAccessExpressionSyntax conditional) - { - return conditional.WhenNotNull.GetRightmostName(); - } - - if (node is MemberBindingExpressionSyntax memberBinding) - { - return memberBinding.Name; - } - - if (node is AliasQualifiedNameSyntax aliasQualifiedName && aliasQualifiedName.Name != null) - { - return aliasQualifiedName.Name; - } - - return null; - } - - public static OperatorPrecedence GetOperatorPrecedence(this ExpressionSyntax expression) - { - switch (expression.Kind()) - { - case SyntaxKind.SimpleMemberAccessExpression: - case SyntaxKind.ConditionalAccessExpression: - case SyntaxKind.InvocationExpression: - case SyntaxKind.ElementAccessExpression: - case SyntaxKind.PostIncrementExpression: - case SyntaxKind.PostDecrementExpression: - case SyntaxKind.ObjectCreationExpression: - case SyntaxKind.TypeOfExpression: - case SyntaxKind.DefaultExpression: - case SyntaxKind.CheckedExpression: - case SyntaxKind.UncheckedExpression: - case SyntaxKind.AnonymousMethodExpression: - // unsafe code - case SyntaxKind.SizeOfExpression: - case SyntaxKind.PointerMemberAccessExpression: - // From C# spec, 7.3.1: - // Primary: x.y x?.y x?[y] f(x) a[x] x++ x-- new typeof default checked unchecked delegate - - return OperatorPrecedence.Primary; - - case SyntaxKind.UnaryPlusExpression: - case SyntaxKind.UnaryMinusExpression: - case SyntaxKind.LogicalNotExpression: - case SyntaxKind.BitwiseNotExpression: - case SyntaxKind.PreIncrementExpression: - case SyntaxKind.PreDecrementExpression: - case SyntaxKind.CastExpression: - case SyntaxKind.AwaitExpression: - // unsafe code. - case SyntaxKind.PointerIndirectionExpression: - case SyntaxKind.AddressOfExpression: - - // From C# spec, 7.3.1: - // Unary: + - ! ~ ++x --x (T)x await Task - - return OperatorPrecedence.Unary; - - case SyntaxKind.MultiplyExpression: - case SyntaxKind.DivideExpression: - case SyntaxKind.ModuloExpression: - // From C# spec, 7.3.1: - // Multiplicative: * / % - - return OperatorPrecedence.Multiplicative; - - case SyntaxKind.AddExpression: - case SyntaxKind.SubtractExpression: - // From C# spec, 7.3.1: - // Additive: + - - - return OperatorPrecedence.Additive; - - case SyntaxKind.LeftShiftExpression: - case SyntaxKind.RightShiftExpression: - // From C# spec, 7.3.1: - // Shift: << >> - - return OperatorPrecedence.Shift; - - case SyntaxKind.LessThanExpression: - case SyntaxKind.GreaterThanExpression: - case SyntaxKind.LessThanOrEqualExpression: - case SyntaxKind.GreaterThanOrEqualExpression: - case SyntaxKind.IsExpression: - case SyntaxKind.AsExpression: - case SyntaxKind.IsPatternExpression: - // From C# spec, 7.3.1: - // Relational and type testing: < > <= >= is as - - return OperatorPrecedence.RelationalAndTypeTesting; - - case SyntaxKind.EqualsExpression: - case SyntaxKind.NotEqualsExpression: - // From C# spec, 7.3.1: - // Equality: == != - - return OperatorPrecedence.Equality; - - case SyntaxKind.BitwiseAndExpression: - // From C# spec, 7.3.1: - // Logical AND: & - - return OperatorPrecedence.LogicalAnd; - - case SyntaxKind.ExclusiveOrExpression: - // From C# spec, 7.3.1: - // Logical XOR: ^ - - return OperatorPrecedence.LogicalXor; - - case SyntaxKind.BitwiseOrExpression: - // From C# spec, 7.3.1: - // Logical OR: | - - return OperatorPrecedence.LogicalOr; - - case SyntaxKind.LogicalAndExpression: - // From C# spec, 7.3.1: - // Conditional AND: && - - return OperatorPrecedence.ConditionalAnd; - - case SyntaxKind.LogicalOrExpression: - // From C# spec, 7.3.1: - // Conditional AND: || - - return OperatorPrecedence.ConditionalOr; - - case SyntaxKind.CoalesceExpression: - // From C# spec, 7.3.1: - // Null coalescing: ?? - - return OperatorPrecedence.NullCoalescing; - - case SyntaxKind.ConditionalExpression: - // From C# spec, 7.3.1: - // Conditional: ?: - - return OperatorPrecedence.Conditional; - - case SyntaxKind.SimpleAssignmentExpression: - case SyntaxKind.MultiplyAssignmentExpression: - case SyntaxKind.DivideAssignmentExpression: - case SyntaxKind.ModuloAssignmentExpression: - case SyntaxKind.AddAssignmentExpression: - case SyntaxKind.SubtractAssignmentExpression: - case SyntaxKind.LeftShiftAssignmentExpression: - case SyntaxKind.RightShiftAssignmentExpression: - case SyntaxKind.AndAssignmentExpression: - case SyntaxKind.ExclusiveOrAssignmentExpression: - case SyntaxKind.OrAssignmentExpression: - case SyntaxKind.SimpleLambdaExpression: - case SyntaxKind.ParenthesizedLambdaExpression: - // From C# spec, 7.3.1: - // Conditional: ?: - - return OperatorPrecedence.AssignmentAndLambdaExpression; - - default: - return OperatorPrecedence.None; - } - } - - public static bool TryConvertToStatement( - this ExpressionSyntax expression, - SyntaxToken? semicolonTokenOpt, - bool createReturnStatementForExpression, - out StatementSyntax statement) - { - // It's tricky to convert an arrow expression with directives over to a block. - // We'd need to find and remove the directives *after* the arrow expression and - // move them accordingly. So, for now, we just disallow this. - if (expression.GetLeadingTrivia().Any(t => t.IsDirective)) - { - statement = null; - return false; - } - - var semicolonToken = semicolonTokenOpt ?? SyntaxFactory.Token(SyntaxKind.SemicolonToken); - - statement = ConvertToStatement(expression, semicolonToken, createReturnStatementForExpression); - return true; - } - - private static StatementSyntax ConvertToStatement(ExpressionSyntax expression, SyntaxToken semicolonToken, bool createReturnStatementForExpression) - { - if (expression.IsKind(SyntaxKind.ThrowExpression, out ThrowExpressionSyntax throwExpression)) - { - return SyntaxFactory.ThrowStatement(throwExpression.ThrowKeyword, throwExpression.Expression, semicolonToken); - } - else if (createReturnStatementForExpression) - { - if (expression.GetLeadingTrivia().Any(t => t.IsSingleOrMultiLineComment())) - { - return SyntaxFactory.ReturnStatement(expression.WithLeadingTrivia(SyntaxFactory.ElasticSpace)) - .WithSemicolonToken(semicolonToken) - .WithLeadingTrivia(expression.GetLeadingTrivia()) - .WithPrependedLeadingTrivia(SyntaxFactory.ElasticMarker); - } - else - { - return SyntaxFactory.ReturnStatement(expression) - .WithSemicolonToken(semicolonToken); - } - } - else - { - return SyntaxFactory.ExpressionStatement(expression) - .WithSemicolonToken(semicolonToken); - } - } - - public static bool IsDirectChildOfMemberAccessExpression(this ExpressionSyntax expression) => - expression?.Parent is MemberAccessExpressionSyntax; - - public static bool InsideCrefReference(this ExpressionSyntax expression) - => expression.FirstAncestorOrSelf() != null; } } + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.cs index 0243cc0268b00..a903c224a27b7 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ITypeSymbolExtensions.cs @@ -10,11 +10,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.CodeStyle; -using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.ErrorReporting; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Simplification; using Roslyn.Utilities; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs index 3b5bca300225e..f59006bef8d87 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs @@ -15,6 +15,10 @@ using Roslyn.Utilities; using SyntaxNodeOrTokenExtensions = Microsoft.CodeAnalysis.Shared.Extensions.SyntaxNodeOrTokenExtensions; +#if CODE_STYLE +#else +#endif + namespace Microsoft.CodeAnalysis.CSharp.Extensions { internal static partial class SyntaxNodeExtensions @@ -187,23 +191,6 @@ public static TNode ConvertToSingleLine(this TNode node, bool useElasticT return (TNode)rewriter.Visit(node); } - public static bool IsAsyncSupportingFunctionSyntax(this SyntaxNode node) - { - return node.IsKind(SyntaxKind.MethodDeclaration) - || node.IsAnyLambdaOrAnonymousMethod() - || node.IsKind(SyntaxKind.LocalFunctionStatement); - } - - public static bool IsAnyLambda(this SyntaxNode node) - { - return - node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) || - node.IsKind(SyntaxKind.SimpleLambdaExpression); - } - - public static bool IsAnyLambdaOrAnonymousMethod(this SyntaxNode node) - => node.IsAnyLambda() || node.IsKind(SyntaxKind.AnonymousMethodExpression); - /// /// Returns true if the passed in node contains an interleaved pp directive. /// @@ -413,56 +400,6 @@ public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives(this TSyntaxNode node, out ImmutableArray strippedTrivia) where TSyntaxNode : SyntaxNode => CSharpSyntaxFactsService.Instance.GetNodeWithoutLeadingBannerAndPreprocessorDirectives(node, out strippedTrivia); - public static bool IsAnyAssignExpression(this SyntaxNode node) - => SyntaxFacts.IsAssignmentExpression(node.Kind()); - - public static bool IsCompoundAssignExpression(this SyntaxNode node) - { - switch (node.Kind()) - { - case SyntaxKind.CoalesceAssignmentExpression: - case SyntaxKind.AddAssignmentExpression: - case SyntaxKind.SubtractAssignmentExpression: - case SyntaxKind.MultiplyAssignmentExpression: - case SyntaxKind.DivideAssignmentExpression: - case SyntaxKind.ModuloAssignmentExpression: - case SyntaxKind.AndAssignmentExpression: - case SyntaxKind.ExclusiveOrAssignmentExpression: - case SyntaxKind.OrAssignmentExpression: - case SyntaxKind.LeftShiftAssignmentExpression: - case SyntaxKind.RightShiftAssignmentExpression: - return true; - } - - return false; - } - - public static bool IsLeftSideOfAssignExpression(this SyntaxNode node) - { - return node.IsParentKind(SyntaxKind.SimpleAssignmentExpression) && - ((AssignmentExpressionSyntax)node.Parent).Left == node; - } - - public static bool IsLeftSideOfAnyAssignExpression(this SyntaxNode node) - { - return node != null && - node.Parent.IsAnyAssignExpression() && - ((AssignmentExpressionSyntax)node.Parent).Left == node; - } - - public static bool IsRightSideOfAnyAssignExpression(this SyntaxNode node) - { - return node.Parent.IsAnyAssignExpression() && - ((AssignmentExpressionSyntax)node.Parent).Right == node; - } - - public static bool IsLeftSideOfCompoundAssignExpression(this SyntaxNode node) - { - return node != null && - node.Parent.IsCompoundAssignExpression() && - ((AssignmentExpressionSyntax)node.Parent).Left == node; - } - public static bool IsVariableDeclaratorValue(this SyntaxNode node) { return @@ -676,39 +613,6 @@ public static IEnumerable GetMembers(this SyntaxNode no return SpecializedCollections.EmptyEnumerable(); } - public static ConditionalAccessExpressionSyntax GetParentConditionalAccessExpression(this SyntaxNode node) - { - var current = node; - while (current?.Parent != null) - { - if (current.IsParentKind(SyntaxKind.ConditionalAccessExpression) && - ((ConditionalAccessExpressionSyntax)current.Parent).WhenNotNull == current) - { - return (ConditionalAccessExpressionSyntax)current.Parent; - } - - current = current.Parent; - } - - return null; - } - - public static ConditionalAccessExpressionSyntax GetInnerMostConditionalAccessExpression(this SyntaxNode node) - { - if (!(node is ConditionalAccessExpressionSyntax)) - { - return null; - } - - var result = (ConditionalAccessExpressionSyntax)node; - while (result.WhenNotNull is ConditionalAccessExpressionSyntax) - { - result = (ConditionalAccessExpressionSyntax)result.WhenNotNull; - } - - return result; - } - public static bool IsInExpressionTree( this SyntaxNode node, SemanticModel semanticModel, INamedTypeSymbol expressionTypeOpt, CancellationToken cancellationToken) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTokenExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTokenExtensions.cs index 8e4bf2b911b65..b43985c6e68c6 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTokenExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTokenExtensions.cs @@ -229,30 +229,6 @@ public static bool IsValidAttributeTarget(this SyntaxToken token) } } - /// - /// Returns true if this token is something that looks like a C# keyword. This includes - /// actual keywords, contextual keywords, and even 'var' and 'dynamic' - /// - /// - /// - public static bool CouldBeKeyword(this SyntaxToken token) - { - if (token.IsKeyword()) - { - return true; - } - - if (token.Kind() == SyntaxKind.IdentifierToken) - { - var simpleNameText = token.ValueText; - return simpleNameText == "var" || - simpleNameText == "dynamic" || - SyntaxFacts.GetContextualKeywordKind(simpleNameText) != SyntaxKind.None; - } - - return false; - } - public static SyntaxToken WithCommentsFrom( this SyntaxToken token, IEnumerable leadingTrivia, diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs index 7313fe809fb9d..0cc415634ed01 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Threading; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Shared.Extensions; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeSyntaxExtensions.cs index 0204416bcd94d..e1852b684411d 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeSyntaxExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/TypeSyntaxExtensions.cs @@ -10,20 +10,8 @@ namespace Microsoft.CodeAnalysis.CSharp.Extensions { - internal static class TypeSyntaxExtensions + internal static partial class TypeSyntaxExtensions { - public static bool IsVoid(this TypeSyntax typeSyntax) - { - return typeSyntax.IsKind(SyntaxKind.PredefinedType) && - ((PredefinedTypeSyntax)typeSyntax).Keyword.IsKind(SyntaxKind.VoidKeyword); - } - - public static bool IsPartial(this TypeSyntax typeSyntax) - { - return typeSyntax is IdentifierNameSyntax && - ((IdentifierNameSyntax)typeSyntax).Identifier.IsKind(SyntaxKind.PartialKeyword); - } - public static bool IsPotentialTypeName(this TypeSyntax typeSyntax, SemanticModel semanticModelOpt, CancellationToken cancellationToken) { if (typeSyntax == null) @@ -63,35 +51,6 @@ typeSyntax is PointerTypeSyntax || && !typeSymbol.IsErrorType(); } - /// - /// Determines whether the specified TypeSyntax is actually 'var'. - /// - public static bool IsTypeInferred(this TypeSyntax typeSyntax, SemanticModel semanticModel) - { - if (!typeSyntax.IsVar) - { - return false; - } - - if (semanticModel.GetAliasInfo(typeSyntax) != null) - { - return false; - } - - var type = semanticModel.GetTypeInfo(typeSyntax).Type; - if (type == null) - { - return false; - } - - if (type.Name == "var") - { - return false; - } - - return true; - } - public static TypeSyntax GenerateReturnTypeSyntax(this IMethodSymbol method) { var returnType = method.ReturnType; @@ -109,8 +68,5 @@ public static TypeSyntax GenerateReturnTypeSyntax(this IMethodSymbol method) return returnType.GenerateTypeSyntax(); } } - - public static TypeSyntax StripRefIfNeeded(this TypeSyntax type) - => type is RefTypeSyntax refType ? refType.Type : type; } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Helpers/SimplificationHelpers.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/Simplification/SimplificationHelpers.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Helpers/SimplificationHelpers.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems index 907033503e0bc..43ddc9a76e1b6 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems @@ -10,6 +10,7 @@ + @@ -32,12 +33,6 @@ - - - - - - @@ -90,7 +85,4 @@ - - - \ No newline at end of file From a6579cca87122296b0cdee2c1eb931f20b4fafbd Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Sun, 2 Feb 2020 02:23:41 -0800 Subject: [PATCH 05/26] Port RemoveUnnecessaryImports analyzer/fixer to code style layer --- .../Analyzers/CSharpAnalyzers.projitems | 1 + ...oveUnnecessaryImportsDiagnosticAnalyzer.cs | 20 ++++++-- .../CodeFixes/CSharpCodeFixes.projitems | 1 + ...RemoveUnnecessaryImportsCodeFixProvider.cs | 8 ++- .../Tests/CSharpAnalyzers.UnitTests.projitems | 2 + .../RemoveUnnecessaryImportsTests.cs | 0 ...moveUnnecessaryImportsTests_FixAllTests.cs | 0 .../Core/Analyzers/Analyzers.projitems | 1 + ...oveUnnecessaryImportsDiagnosticAnalyzer.cs | 44 +++++++++------- .../Core/CodeFixes/CodeFixes.projitems | 1 + ...RemoveUnnecessaryImportsCodeFixProvider.cs | 2 +- ...oveUnnecessaryImportsDiagnosticAnalyzer.vb | 19 ++++++- .../Analyzers/VisualBasicAnalyzers.projitems | 1 + ...RemoveUnnecessaryImportsCodeFixProvider.vb | 7 ++- .../CodeFixes/VisualBasicCodeFixes.projitems | 1 + .../RemoveUnnecessaryImportsTests.vb | 0 ...moveUnnecessaryImportsTests_FixAllTests.vb | 0 .../VisualBasicAnalyzers.UnitTests.projitems | 2 + .../CSharpCodeStyleResources.Designer.cs | 9 ++++ .../Analyzers/CSharpCodeStyleResources.resx | 3 ++ .../xlf/CSharpCodeStyleResources.cs.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.de.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.es.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.fr.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.it.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.ja.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.ko.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.pl.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.pt-BR.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.ru.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.tr.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.zh-Hans.xlf | 5 ++ .../xlf/CSharpCodeStyleResources.zh-Hant.xlf | 5 ++ .../CSharpCodeStyleFixesResources.Designer.cs | 9 ++++ .../CSharpCodeStyleFixesResources.resx | 3 ++ .../xlf/CSharpCodeStyleFixesResources.cs.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.de.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.es.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.fr.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.it.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.ja.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.ko.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.pl.xlf | 5 ++ .../CSharpCodeStyleFixesResources.pt-BR.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.ru.xlf | 5 ++ .../xlf/CSharpCodeStyleFixesResources.tr.xlf | 5 ++ .../CSharpCodeStyleFixesResources.zh-Hans.xlf | 5 ++ .../CSharpCodeStyleFixesResources.zh-Hant.xlf | 5 ++ .../CodeStyleFixesResources.Designer.cs | 19 +++++++ .../CodeFixes/CodeStyleFixesResources.resx | 6 +++ .../xlf/CodeStyleFixesResources.cs.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.de.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.es.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.fr.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.it.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.ja.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.ko.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.pl.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.pt-BR.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.ru.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.tr.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.zh-Hans.xlf | 10 ++++ .../xlf/CodeStyleFixesResources.zh-Hant.xlf | 10 ++++ .../VBCodeStyleResources.Designer.vb | 11 ++-- .../Analyzers/VBCodeStyleResources.resx | 5 +- .../Analyzers/xlf/VBCodeStyleResources.cs.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.de.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.es.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.fr.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.it.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.ja.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.ko.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.pl.xlf | 8 +-- .../xlf/VBCodeStyleResources.pt-BR.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.ru.xlf | 8 +-- .../Analyzers/xlf/VBCodeStyleResources.tr.xlf | 8 +-- .../xlf/VBCodeStyleResources.zh-Hans.xlf | 8 +-- .../xlf/VBCodeStyleResources.zh-Hant.xlf | 8 +-- ...nalysis.VisualBasic.CodeStyle.Fixes.vbproj | 1 + .../VBCodeStyleFixesResources.Designer.vb | 11 ++-- .../CodeFixes/VBCodeStyleFixesResources.resx | 5 +- .../xlf/VBCodeStyleFixesResources.cs.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.de.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.es.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.fr.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.it.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.ja.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.ko.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.pl.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.pt-BR.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.ru.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.tr.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.zh-Hans.xlf | 8 +-- .../xlf/VBCodeStyleFixesResources.zh-Hant.xlf | 8 +-- .../EditSessionActiveStatementsTests.cs | 2 +- .../Shared/Extensions/DocumentExtensions.cs | 10 ---- .../Core/Portable/CodeFixes/CodeFix.cs | 2 +- .../Shared/Extensions/SolutionExtensions.cs | 25 ---------- .../CSharp/CSharpCompilerExtensions.projitems | 1 + .../CSharpUnnecessaryImportsProvider.cs | 50 +++++++++++++++++++ .../Core/CompilerExtensions.projitems | 3 ++ .../Compiler/Core}/Fading/FadingOptions.cs | 7 +++ .../AbstractUnnecessaryImportsProvider.cs | 39 +++++++++++++++ .../IUnnecessaryImportsProvider.cs | 21 ++++++++ .../VisualBasicUnnecessaryImportsProvider.vb} | 44 ++++------------ .../VisualBasicCompilerExtensions.projitems | 1 + .../CSharpWorkspaceExtensions.projitems | 4 ++ ...emoveUnnecessaryImportsService.Rewriter.cs | 1 - ...ctCSharpRemoveUnnecessaryImportsService.cs | 31 ++---------- .../CSharpRemoveUnnecessaryImportsService.cs | 0 .../CSharpUnnecessaryImportsService.cs | 0 .../Core/Extensions/DocumentExtensions.cs | 10 ++++ .../Core/Extensions/ISolutionExtensions.cs | 32 ++++++++++++ ...AbstractRemoveUnnecessaryImportsService.cs | 24 ++++----- .../IRemoveUnnecessaryImportsService.cs | 0 .../IUnnecessaryImportsService.cs | 0 .../Core/WorkspaceExtensions.projitems | 3 ++ ...emoveUnnecessaryImportsService.Rewriter.vb | 1 - ...ualBasicRemoveUnnecessaryImportsService.vb | 47 +++++++++++++++++ ...ualBasicRemoveUnnecessaryImportsService.vb | 0 .../VisualBasicUnnecessaryImportsService.vb | 0 .../VisualBasicWorkspaceExtensions.projitems | 4 ++ 122 files changed, 760 insertions(+), 262 deletions(-) rename src/{Features/CSharp/Portable => Analyzers/CSharp/Analyzers}/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (75%) rename src/{Features/CSharp/Portable => Analyzers/CSharp/CodeFixes}/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs (83%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.cs (100%) rename src/{EditorFeatures/CSharpTest => Analyzers/CSharp/Tests}/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.cs (100%) rename src/{Features/Core/Portable => Analyzers/Core/Analyzers}/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (89%) rename src/{Features/Core/Portable => Analyzers/Core/CodeFixes}/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsCodeFixProvider.cs (96%) rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/Analyzers}/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb (78%) rename src/{Features/VisualBasic/Portable => Analyzers/VisualBasic/CodeFixes}/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb (78%) rename src/{EditorFeatures/VisualBasicTest => Analyzers/VisualBasic/Tests}/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb (100%) rename src/{EditorFeatures/VisualBasicTest => Analyzers/VisualBasic/Tests}/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.vb (100%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Helpers/RemoveUnnecessaryImports/CSharpUnnecessaryImportsProvider.cs rename src/{Features/Core/Portable => Workspaces/SharedUtilitiesAndExtensions/Compiler/Core}/Fading/FadingOptions.cs (88%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Helpers/RemoveUnnecessaryImports/AbstractUnnecessaryImportsProvider.cs create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Helpers/RemoveUnnecessaryImports/IUnnecessaryImportsProvider.cs rename src/{Features/VisualBasic/Portable/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb => Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Helpers/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsProvider.vb} (71%) rename src/{Features/CSharp/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices}/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs (99%) rename src/{Features/CSharp/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices}/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs (79%) rename src/{Features/CSharp/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices}/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs (100%) rename src/{Features/CSharp/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices}/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs (100%) rename src/{Features/Core/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs (80%) rename src/{Features/Core/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/RemoveUnnecessaryImports/IRemoveUnnecessaryImportsService.cs (100%) rename src/{Features/Core/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices}/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs (100%) rename src/{Features/VisualBasic/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices}/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb (99%) create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb rename src/{Features/VisualBasic/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices}/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb (100%) rename src/{Features/VisualBasic/Portable => Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices}/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb (100%) diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index 186569098bd22..c2a54ecb321d6 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -12,6 +12,7 @@ + diff --git a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs similarity index 75% rename from src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs rename to src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs index f43c85716648b..735b5090dc121 100644 --- a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs @@ -6,6 +6,8 @@ using System.Collections.Immutable; using System.Linq; using System.Threading; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.RemoveUnnecessaryImports; @@ -15,15 +17,21 @@ namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports { +#if CODE_STYLE + using Resources = CSharpCodeStyleResources; +#else + using Resources = CSharpFeaturesResources; +#endif + [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer : AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer { - private static readonly LocalizableString s_TitleAndMessageFormat = - new LocalizableResourceString(nameof(CSharpFeaturesResources.Using_directive_is_unnecessary), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources)); + private static readonly LocalizableString s_titleAndMessageFormat = + new LocalizableResourceString(nameof(Resources.Using_directive_is_unnecessary), Resources.ResourceManager, typeof(Resources)); protected override LocalizableString GetTitleAndMessageFormatForClassificationIdDescriptor() - => s_TitleAndMessageFormat; + => s_titleAndMessageFormat; // C# has no need to do any merging of using statements. Only VB needs to // merge import clauses to an import statement if it all the import clauses @@ -31,6 +39,12 @@ protected override LocalizableString GetTitleAndMessageFormatForClassificationId protected override ImmutableArray MergeImports(ImmutableArray unnecessaryImports) => unnecessaryImports; + protected override IUnnecessaryImportsProvider UnnecessaryImportsProvider + => CSharpUnnecessaryImportsProvider.Instance; + + protected override bool IsRegularCommentOrDocComment(SyntaxTrivia trivia) + => trivia.IsRegularComment() || trivia.IsDocComment(); + protected override IEnumerable GetFixableDiagnosticSpans( IEnumerable nodes, SyntaxTree tree, CancellationToken cancellationToken) { diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index 22cdb7d604eaf..e9d02c35a3926 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -12,6 +12,7 @@ + diff --git a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs similarity index 83% rename from src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs index 279270cdedacb..df527c591973a 100644 --- a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs @@ -8,6 +8,12 @@ namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports { +#if CODE_STYLE + using Resources = CSharpCodeStyleFixesResources; +#else + using Resources = CSharpFeaturesResources; +#endif + [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.RemoveUnnecessaryImports), Shared] [ExtensionOrder(After = PredefinedCodeFixProviderNames.AddMissingReference)] internal class CSharpRemoveUnnecessaryImportsCodeFixProvider : AbstractRemoveUnnecessaryImportsCodeFixProvider @@ -18,6 +24,6 @@ public CSharpRemoveUnnecessaryImportsCodeFixProvider() } protected override string GetTitle() - => CSharpFeaturesResources.Remove_Unnecessary_Usings; + => Resources.Remove_Unnecessary_Usings; } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index a774dfcb82e01..fe7ed340241a6 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -12,6 +12,8 @@ + + diff --git a/src/EditorFeatures/CSharpTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.cs b/src/Analyzers/CSharp/Tests/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.cs similarity index 100% rename from src/EditorFeatures/CSharpTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.cs rename to src/Analyzers/CSharp/Tests/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.cs diff --git a/src/EditorFeatures/CSharpTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.cs similarity index 100% rename from src/EditorFeatures/CSharpTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.cs rename to src/Analyzers/CSharp/Tests/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.cs diff --git a/src/Analyzers/Core/Analyzers/Analyzers.projitems b/src/Analyzers/Core/Analyzers/Analyzers.projitems index f0f48dbc53d7a..324016773bdc9 100644 --- a/src/Analyzers/Core/Analyzers/Analyzers.projitems +++ b/src/Analyzers/Core/Analyzers/Analyzers.projitems @@ -20,6 +20,7 @@ + diff --git a/src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs similarity index 89% rename from src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs rename to src/Analyzers/Core/Analyzers/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs index 4202cd21ae4f8..b5565de6b502f 100644 --- a/src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs @@ -8,13 +8,19 @@ using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Fading; using Microsoft.CodeAnalysis.LanguageServices; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Fading; +using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; +#else +using Microsoft.CodeAnalysis.Fading; +using Microsoft.CodeAnalysis.Options; +#endif + namespace Microsoft.CodeAnalysis.RemoveUnnecessaryImports { internal abstract class AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer @@ -34,6 +40,9 @@ internal abstract class AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer customTags: WellKnownDiagnosticTags.NotConfigurable); protected abstract LocalizableString GetTitleAndMessageFormatForClassificationIdDescriptor(); + protected abstract ImmutableArray MergeImports(ImmutableArray unnecessaryImports); + protected abstract bool IsRegularCommentOrDocComment(SyntaxTrivia trivia); + protected abstract IUnnecessaryImportsProvider UnnecessaryImportsProvider { get; } private DiagnosticDescriptor _unnecessaryClassificationIdDescriptor; private DiagnosticDescriptor _classificationIdDescriptor; @@ -111,17 +120,9 @@ private void AnalyzeSemanticModel(SemanticModelAnalysisContext context) { var tree = context.SemanticModel.SyntaxTree; var cancellationToken = context.CancellationToken; + var language = context.SemanticModel.Language; - if (!(context.Options is WorkspaceAnalyzerOptions workspaceOptions)) - { - return; - } - - var language = context.SemanticModel.Compilation.Language; - var service = workspaceOptions.Services.GetLanguageServices(language) - .GetService(); - - var unnecessaryImports = service.GetUnnecessaryImports(context.SemanticModel, cancellationToken); + var unnecessaryImports = UnnecessaryImportsProvider.GetUnnecessaryImports(context.SemanticModel, cancellationToken); if (unnecessaryImports.Any()) { // The IUnnecessaryImportsService will return individual import pieces that @@ -132,11 +133,10 @@ private void AnalyzeSemanticModel(SemanticModelAnalysisContext context) unnecessaryImports = MergeImports(unnecessaryImports); EnsureClassificationIdDescriptors(); - var fadeOut = workspaceOptions.Services.Workspace.Options.GetOption(FadingOptions.FadeOutUnusedImports, language); + var fadeOut = ShouldFade(context.Options, tree, language, cancellationToken); DiagnosticDescriptor descriptor; - var syntaxFacts = workspaceOptions.Services.GetLanguageServices(language).GetRequiredService(); - if (GeneratedCodeUtilities.IsGeneratedCode(tree, t => syntaxFacts.IsRegularComment(t) || syntaxFacts.IsDocumentationComment(t), context.CancellationToken)) + if (GeneratedCodeUtilities.IsGeneratedCode(tree, IsRegularCommentOrDocComment, cancellationToken)) { descriptor = fadeOut ? _unnecessaryGeneratedCodeClassificationIdDescriptor : _generatedCodeClassificationIdDescriptor; } @@ -156,9 +156,19 @@ private void AnalyzeSemanticModel(SemanticModelAnalysisContext context) context.ReportDiagnostic(diagnostic); } } - } - protected abstract ImmutableArray MergeImports(ImmutableArray unnecessaryImports); + static bool ShouldFade(AnalyzerOptions options, SyntaxTree tree, string language, CancellationToken cancellationToken) + { + var optionSet = options.GetOptions(tree, cancellationToken); + if (optionSet == null) + { + return false; + } + + return optionSet.GetOption(FadingOptions.FadeOutUnusedImports, language); + + } + } protected virtual Func GetLastTokenDelegateForContiguousSpans() { diff --git a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems index a61b40fd657f0..d02ed2e62e0c6 100644 --- a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems +++ b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems @@ -10,6 +10,7 @@ + \ No newline at end of file diff --git a/src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsCodeFixProvider.cs similarity index 96% rename from src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsCodeFixProvider.cs rename to src/Analyzers/Core/CodeFixes/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsCodeFixProvider.cs index 3c1b3d10990a3..7aa2b9eb3d862 100644 --- a/src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsCodeFixProvider.cs +++ b/src/Analyzers/Core/CodeFixes/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsCodeFixProvider.cs @@ -39,7 +39,7 @@ private Task RemoveUnnecessaryImportsAsync( return service.RemoveUnnecessaryImportsAsync(document, cancellationToken); } - private class MyCodeAction : CodeAction.DocumentChangeAction + private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(string title, Func> createChangedDocument) : base(title, createChangedDocument) diff --git a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb b/src/Analyzers/VisualBasic/Analyzers/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb similarity index 78% rename from src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb rename to src/Analyzers/VisualBasic/Analyzers/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb index 9a66b8322661d..c560e59ba54a1 100644 --- a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb +++ b/src/Analyzers/VisualBasic/Analyzers/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb @@ -4,6 +4,7 @@ Imports System.Collections.Immutable Imports System.Threading +Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Diagnostics Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.RemoveUnnecessaryImports @@ -11,24 +12,38 @@ Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports - Friend NotInheritable Class VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer Inherits AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer +#If CODE_STYLE Then + Private Shared ReadOnly s_TitleAndMessageFormat As LocalizableString = + New LocalizableResourceString(NameOf(VBCodeStyleResources.Imports_statement_is_unnecessary), VBCodeStyleResources.ResourceManager, GetType(VBCodeStyleResources.VBCodeStyleResources)) +#Else Private Shared ReadOnly s_TitleAndMessageFormat As LocalizableString = New LocalizableResourceString(NameOf(VBFeaturesResources.Imports_statement_is_unnecessary), VBFeaturesResources.ResourceManager, GetType(VBFeaturesResources.VBFeaturesResources)) +#End If Protected Overrides Function GetTitleAndMessageFormatForClassificationIdDescriptor() As LocalizableString Return s_TitleAndMessageFormat End Function + Protected Overrides ReadOnly Property UnnecessaryImportsProvider As IUnnecessaryImportsProvider + Get + Return VisualBasicUnnecessaryImportsProvider.Instance + End Get + End Property + + Protected Overrides Function IsRegularCommentOrDocComment(trivia As SyntaxTrivia) As Boolean + Return trivia.IsRegularOrDocComment() + End Function + ''' Takes the import clauses we want to remove and returns them *or* their ''' containing ImportsStatements *if* we wanted to remove all the clauses of ''' that ImportStatement. Protected Overrides Function MergeImports(unnecessaryImports As ImmutableArray(Of SyntaxNode)) As ImmutableArray(Of SyntaxNode) Dim result = ArrayBuilder(Of SyntaxNode).GetInstance() - Dim importsClauses = unnecessaryImports.CastArray(Of ImportsClauseSyntax) + Dim importsClauses = unnecessaryImports.ToImmutableHashSet() For Each clause In importsClauses If Not result.Contains(clause.Parent) Then diff --git a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems index 2898a4029907c..b923810b4c3f5 100644 --- a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems +++ b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems @@ -9,6 +9,7 @@ Microsoft.CodeAnalysis.VisualBasic.Analyzers + \ No newline at end of file diff --git a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb b/src/Analyzers/VisualBasic/CodeFixes/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb similarity index 78% rename from src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb rename to src/Analyzers/VisualBasic/CodeFixes/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb index 7989daab5a04c..770ee1a3c9c8f 100644 --- a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb +++ b/src/Analyzers/VisualBasic/CodeFixes/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb @@ -6,6 +6,11 @@ Imports System.Composition Imports Microsoft.CodeAnalysis.CodeFixes Imports Microsoft.CodeAnalysis.RemoveUnnecessaryImports +#If CODE_STYLE Then +Imports Resources = Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleFixesResources +#Else +Imports Resources = Microsoft.CodeAnalysis.VisualBasic.VBFeaturesResources +#End If Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports @@ -18,7 +23,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports End Sub Protected Overrides Function GetTitle() As String - Return VBFeaturesResources.Remove_Unnecessary_Imports + Return Resources.Remove_Unnecessary_Imports End Function End Class End Namespace diff --git a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems index 4d491da212f9b..0b94d2e32e378 100644 --- a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems +++ b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems @@ -9,6 +9,7 @@ Microsoft.CodeAnalysis.VisualBasic.CodeFixes + \ No newline at end of file diff --git a/src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb b/src/Analyzers/VisualBasic/Tests/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb similarity index 100% rename from src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb rename to src/Analyzers/VisualBasic/Tests/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb diff --git a/src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.vb b/src/Analyzers/VisualBasic/Tests/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.vb similarity index 100% rename from src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.vb rename to src/Analyzers/VisualBasic/Tests/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests_FixAllTests.vb diff --git a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems index e7acc0bf7b114..b448add097f85 100644 --- a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems +++ b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems @@ -19,6 +19,8 @@ + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs index 130af45a508ad..54afb1516779e 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.Designer.cs @@ -177,6 +177,15 @@ internal static string use_var_instead_of_explicit_type { } } + /// + /// Looks up a localized string similar to Using directive is unnecessary.. + /// + internal static string Using_directive_is_unnecessary { + get { + return ResourceManager.GetString("Using_directive_is_unnecessary", resourceCulture); + } + } + /// /// Looks up a localized string similar to 'using' directive preferences. /// diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx index 7ad9e4d340de1..adce271f2998e 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx @@ -167,4 +167,7 @@ Use implicit type + + Using directive is unnecessary. + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf index 51d1be5ed27f9..1dd1aa0d686ff 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Předvolby zalamování diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf index 03a77a2157f3b..ddc3928ad77d2 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Umbrucheinstellungen diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf index 87acb180754ec..a77f56fac13c3 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Preferencias de ajuste diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf index c3fff48e74f1e..3a6a1abff961d 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Préférences d'enveloppement diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf index ced68355c9fd6..06149748f646b 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Preferenze per ritorno a capo diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf index 3cf84bdca8218..93bea1d41a1b8 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences 折り返しの設定 diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf index ad89daf9acf3d..c756c86ffc03c 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences 기본 설정 래핑 diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf index bb77e89f8236a..235b6efa36ec2 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Preferencje zawijania diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf index 9eb924bd222a3..ea27ed9b8823f 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Preferências de quebra de linha diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf index fe0b65909b0f7..4ac961c07aa49 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Параметры переноса diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf index a3fdbc0f608ae..5c15bd54660cb 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences Kaydırma tercihleri diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf index b6af58480a339..a5af9ca82ff29 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences 包装首选项 diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf index e19fda203a786..d0d5c0baf696f 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf @@ -62,6 +62,11 @@ Use 'switch' expression + + Using directive is unnecessary. + Using directive is unnecessary. + + Wrapping preferences 換行喜好設定 diff --git a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs index c7be050ea1bc5..fd3bc473bb51d 100644 --- a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs +++ b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.Designer.cs @@ -77,5 +77,14 @@ internal static string Expected_string_or_char_literal { return ResourceManager.GetString("Expected_string_or_char_literal", resourceCulture); } } + + /// + /// Looks up a localized string similar to Remove Unnecessary Usings. + /// + internal static string Remove_Unnecessary_Usings { + get { + return ResourceManager.GetString("Remove_Unnecessary_Usings", resourceCulture); + } + } } } diff --git a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx index bc5fcf47a3bb3..4b15d2f16aaca 100644 --- a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx +++ b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx @@ -123,4 +123,7 @@ Convert switch statement to expression + + Remove Unnecessary Usings + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf index 0b0ab48f744d0..d60c8540e33b3 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf index 640a769f554c2..d54196863535d 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf index e010f3be44063..483426fabc919 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf index ae81a4aa7d7e2..7748c47bf284f 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf index ef06d8f9b8933..30ac5a27a6cbe 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf index 1d746adf9daa8..161be734f1648 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf index cbddbdc67f77e..afdcabb083eb1 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf index 9bac2da4dba1e..c318b9ed41033 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf index 999ade09e06f2..54efc6d5cd1e0 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf index 8fc6598f3d694..b4bace98e454f 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf index b57c3e78c9bef..c17204fad4a61 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf index b672463d70243..fb3063a29be3e 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf index 57f31f4c3a451..33ed83489f19c 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf @@ -12,6 +12,11 @@ Expected string or char literal + + Remove Unnecessary Usings + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.Designer.cs b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.Designer.cs index 70277b73a44f3..a179f6613491a 100644 --- a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.Designer.cs +++ b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.Designer.cs @@ -96,6 +96,16 @@ internal static string Fix_all_0_in_Solution { } } + /// + /// Looks up a localized string similar to Project of ID {0} is required to accomplish the task but is not available from the solution. + /// + internal static string Project_of_ID_0_is_required_to_accomplish_the_task_but_is_not_available_from_the_solution { + get { + return ResourceManager.GetString("Project_of_ID_0_is_required_to_accomplish_the_task_but_is_not_available_from_the_" + + "solution", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remove unused member. /// @@ -122,5 +132,14 @@ internal static string SyntaxTree_is_required_to_accomplish_the_task_but_is_not_ return ResourceManager.GetString("SyntaxTree_is_required_to_accomplish_the_task_but_is_not_supported_by_document_0", resourceCulture); } } + + /// + /// Looks up a localized string similar to The solution does not contain the specified document.. + /// + internal static string The_solution_does_not_contain_the_specified_document { + get { + return ResourceManager.GetString("The_solution_does_not_contain_the_specified_document", resourceCulture); + } + } } } diff --git a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx index aa9f45d59bb4e..80cb905c80e9f 100644 --- a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx +++ b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx @@ -135,6 +135,12 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + Project of ID {0} is required to accomplish the task but is not available from the solution + + + The solution does not contain the specified document. + Remove unused member diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf index 8c55eec8ef625..42b2bacd4e483 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf index e0e1cc514ca11..bfe83940ce775 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf index 9202d3e4de20e..48d118d1ad0b8 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf index 7e1fd990a2912..fc0682064dd6b 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf index 6212d308851d4..7ea81ca778b26 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf index e461127223a1e..618ac9b7edd34 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf index 991a11dff4db2..7a2ee21e14c60 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf index 301ee0f5b9883..6fc6960ddd30f 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf index 0f5b73bdb74ef..d994d6517cb59 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf index 633c7bb03ea8b..def04413ca791 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf index 4e38524d221db..fa919eb7a0c6a 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf index 4e3cefa35a416..7a195f93239ec 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf index d06b543d92842..2608915859b8a 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf @@ -22,6 +22,11 @@ Fix all '{0}' in Solution + + Project of ID {0} is required to accomplish the task but is not available from the solution + Project of ID {0} is required to accomplish the task but is not available from the solution + + Remove unused member Remove unused member @@ -37,6 +42,11 @@ Syntax tree is required to accomplish the task but is not supported by document {0}. + + The solution does not contain the specified document. + The solution does not contain the specified document. + + \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.Designer.vb b/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.Designer.vb index 324b9fb0458f3..e64f99491c812 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.Designer.vb +++ b/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.Designer.vb @@ -12,7 +12,6 @@ Option Strict On Option Explicit On Imports System -Imports System.Reflection Namespace Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleResources @@ -23,7 +22,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleResources ''' ''' A strongly-typed resource class, for looking up localized strings, etc. ''' - _ @@ -40,7 +39,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleResources Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Get If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VBCodeStyleResources", GetType(VBCodeStyleResources).GetTypeInfo.Assembly) + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VBCodeStyleResources", GetType(VBCodeStyleResources).Assembly) resourceMan = temp End If Return resourceMan @@ -62,11 +61,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleResources End Property ''' - ''' Looks up a localized string similar to Remove this value when another is added.. + ''' Looks up a localized string similar to Imports statement is unnecessary.. ''' - Friend ReadOnly Property EmptyResource() As String + Friend ReadOnly Property Imports_statement_is_unnecessary() As String Get - Return ResourceManager.GetString("EmptyResource", resourceCulture) + Return ResourceManager.GetString("Imports_statement_is_unnecessary", resourceCulture) End Get End Property End Module diff --git a/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.resx b/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.resx index 14ed010cf9ebb..6cf27cf64b08e 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.resx +++ b/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.resx @@ -117,8 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Remove this value when another is added. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.cs.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.cs.xlf index 1ee0e68ad1a94..5c4b765c76edd 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.cs.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.cs.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Odebrat tuto hodnotu, když se přidá jiná - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.de.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.de.xlf index 99b3f10583c20..5e3f30fd7dd0e 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.de.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.de.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Dieser Wert wird entfernt, wenn ein anderer hinzugefügt wird. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.es.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.es.xlf index 8aa42988759c7..8452dfb5ceebc 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.es.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.es.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Quite este valor cuando se agregue otro. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.fr.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.fr.xlf index 4634371cdc62b..2092f75405f52 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.fr.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.fr.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Supprimer cette valeur quand une autre est ajoutée. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.it.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.it.xlf index d19ff3feee410..8413dac4f68c4 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.it.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.it.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Rimuovere questo valore quando ne viene aggiunto un altro. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ja.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ja.xlf index c8af538b8bf9b..7d8ebfd485210 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ja.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ja.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 別の値が追加されたら、この値を削除します。 - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ko.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ko.xlf index b0790f0101343..4bb8b082bca49 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ko.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ko.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 다른 값을 추가할 때 이 값을 제거하세요. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pl.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pl.xlf index c1bb87eab5e2b..e20b77257637b 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pl.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pl.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Usuń tę wartość, gdy dodawana jest kolejna. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pt-BR.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pt-BR.xlf index 17951a56a9f7c..7221d04a19013 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pt-BR.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Remover este valor quando outro for adicionado. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ru.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ru.xlf index ab8ee10782fc2..ebefc0529157e 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ru.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ru.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Удалите это значение при добавлении другого значения. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.tr.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.tr.xlf index d35891016275c..62474fc2a3de6 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.tr.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.tr.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Başka bir değer eklendiğinde bu değeri kaldırın. - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hans.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hans.xlf index 37d7c99d03180..b7f1e373e4526 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hans.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 在添加其他值时删除此值。 - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hant.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hant.xlf index 2f99525762e7a..034cb1eb82968 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hant.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 當新增另一個值時移除此值。 - https://github.com/Microsoft/msbuild/issues/1661 + + Imports statement is unnecessary. + Imports statement is unnecessary. + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj b/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj index c09ee580b474f..c9562c8964221 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj +++ b/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj @@ -5,6 +5,7 @@ Library netstandard2.0 + $(DefineConstants),CODE_STYLE true diff --git a/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.Designer.vb b/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.Designer.vb index 53db2ae4b35e0..3ab5a6b953824 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.Designer.vb +++ b/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.Designer.vb @@ -12,7 +12,6 @@ Option Strict On Option Explicit On Imports System -Imports System.Reflection Namespace Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleFixesResources @@ -23,7 +22,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleFixesResources ''' ''' A strongly-typed resource class, for looking up localized strings, etc. ''' - _ @@ -40,7 +39,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleFixesResources Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Get If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VBCodeStyleFixesResources", GetType(VBCodeStyleFixesResources).GetTypeInfo.Assembly) + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VBCodeStyleFixesResources", GetType(VBCodeStyleFixesResources).Assembly) resourceMan = temp End If Return resourceMan @@ -62,11 +61,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleFixesResources End Property ''' - ''' Looks up a localized string similar to Remove this value when another is added.. + ''' Looks up a localized string similar to Remove Unnecessary Imports. ''' - Friend ReadOnly Property EmptyResource() As String + Friend ReadOnly Property Remove_Unnecessary_Imports() As String Get - Return ResourceManager.GetString("EmptyResource", resourceCulture) + Return ResourceManager.GetString("Remove_Unnecessary_Imports", resourceCulture) End Get End Property End Module diff --git a/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.resx b/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.resx index 14ed010cf9ebb..09b97e6c440a9 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.resx +++ b/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.resx @@ -117,8 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Remove this value when another is added. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.cs.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.cs.xlf index bf069199a868a..36730eb2d92ec 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.cs.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Odebrat tuto hodnotu, když se přidá jiná - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.de.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.de.xlf index 4aaa654e93268..0bf74ab33dca9 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.de.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Dieser Wert wird entfernt, wenn ein anderer hinzugefügt wird. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.es.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.es.xlf index d348da1699902..7bbc3bb25e3bf 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.es.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Quite este valor cuando se agregue otro. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.fr.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.fr.xlf index 3f76a635c7886..32d23dde4d55e 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.fr.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Supprimer cette valeur quand une autre est ajoutée. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.it.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.it.xlf index 589952b571ce7..d04beb6ac4478 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.it.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Rimuovere questo valore quando ne viene aggiunto un altro. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ja.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ja.xlf index 729c694202737..90debbdd41c91 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ja.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 別の値が追加されたら、この値を削除します。 - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ko.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ko.xlf index 31d2d215a31d6..abebe69b2c0d4 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ko.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 다른 값을 추가할 때 이 값을 제거하세요. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pl.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pl.xlf index 9b475a809c7df..76e9ca3bace1f 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pl.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Usuń tę wartość, gdy dodawana jest kolejna. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pt-BR.xlf index 7999064a8defa..41ed1293e8c4f 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pt-BR.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Remover este valor quando outro for adicionado. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ru.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ru.xlf index 826c7dc4343bc..5a7fba30554a0 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ru.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Удалите это значение при добавлении другого значения. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.tr.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.tr.xlf index cb54eb755ab7b..ff699e88c7db0 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.tr.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - Başka bir değer eklendiğinde bu değeri kaldırın. - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hans.xlf index 37da7ae8e7ea4..9bc01636485dc 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hans.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 在添加其他值时删除此值。 - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hant.xlf index ecb8712ecf42d..f0b8bfbfd9203 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hant.xlf @@ -2,10 +2,10 @@ - - Remove this value when another is added. - 當新增另一個值時移除此值。 - https://github.com/Microsoft/msbuild/issues/1661 + + Remove Unnecessary Imports + Remove Unnecessary Imports + diff --git a/src/EditorFeatures/Test/EditAndContinue/EditSessionActiveStatementsTests.cs b/src/EditorFeatures/Test/EditAndContinue/EditSessionActiveStatementsTests.cs index 48a64721bb7f2..4720545ea87c0 100644 --- a/src/EditorFeatures/Test/EditAndContinue/EditSessionActiveStatementsTests.cs +++ b/src/EditorFeatures/Test/EditAndContinue/EditSessionActiveStatementsTests.cs @@ -50,7 +50,7 @@ internal static ImmutableArray GetActiveStatementDebug var sourceIndex = 0; foreach (var markedSource in markedSources) { - var documentName = TestWorkspace.GetDefaultTestSourceDocumentName(sourceIndex, extension, rootFilePath: null); + var documentName = TestWorkspace.GetDefaultTestSourceDocumentName(sourceIndex, extension); var documentId = DocumentId.CreateNewId(ProjectId.CreateNewId(), documentName); var text = SourceText.From(markedSource); diff --git a/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs b/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs index 4113c6661128c..1ae466c2be264 100644 --- a/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs +++ b/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs @@ -90,16 +90,6 @@ public static async Task IsValidContextForDocumentOrLinkedDocumentsAsync( return false; } - public static IEnumerable GetLinkedDocuments(this Document document) - { - var solution = document.Project.Solution; - - foreach (var linkedDocumentId in document.GetLinkedDocumentIds()) - { - yield return solution.GetDocument(linkedDocumentId); - } - } - /// /// Get the user-specified naming rules, then add standard default naming rules (if provided). The standard /// naming rules (fallback rules) are added at the end so they will only be used if the user hasn't specified diff --git a/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs b/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs index 082bd6897f08d..928ba3c1a6221 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/CodeFix.cs @@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes /// Represents a single fix. This is essentially a tuple /// that holds on to a and the set of /// s that this will fix. - // + /// internal sealed class CodeFix { internal readonly Project Project; diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/SolutionExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/SolutionExtensions.cs index 16b17bdded518..836631781bd16 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/SolutionExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/SolutionExtensions.cs @@ -15,30 +15,5 @@ public static void WriteTo(this IObjectWritable @object, ObjectWriter writer) { @object.WriteTo(writer); } - - public static Document GetRequiredDocument(this Solution solution, SyntaxTree syntaxTree) - => solution.GetDocument(syntaxTree) ?? throw new InvalidOperationException(); - - public static Project GetRequiredProject(this Solution solution, ProjectId projectId) - { - var project = solution.GetProject(projectId); - if (project == null) - { - throw new InvalidOperationException(string.Format(WorkspacesResources.Project_of_ID_0_is_required_to_accomplish_the_task_but_is_not_available_from_the_solution, projectId)); - } - - return project; - } - - public static Document GetRequiredDocument(this Solution solution, DocumentId documentId) - { - var document = solution.GetDocument(documentId); - if (document == null) - { - throw new InvalidOperationException(WorkspacesResources.The_solution_does_not_contain_the_specified_document); - } - - return document; - } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems index f31f0d6406250..c28596624d3d3 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems @@ -28,6 +28,7 @@ + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Helpers/RemoveUnnecessaryImports/CSharpUnnecessaryImportsProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Helpers/RemoveUnnecessaryImports/CSharpUnnecessaryImportsProvider.cs new file mode 100644 index 0000000000000..9b31242c31cb2 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Helpers/RemoveUnnecessaryImports/CSharpUnnecessaryImportsProvider.cs @@ -0,0 +1,50 @@ +// 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.Threading; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.RemoveUnnecessaryImports +{ + internal sealed class CSharpUnnecessaryImportsProvider + : AbstractUnnecessaryImportsProvider + { + public static readonly CSharpUnnecessaryImportsProvider Instance = new CSharpUnnecessaryImportsProvider(); + + private CSharpUnnecessaryImportsProvider() + { + } + + protected override ImmutableArray GetUnnecessaryImports( + SemanticModel model, SyntaxNode root, + Func predicate, CancellationToken cancellationToken) + { + predicate ??= Functions.True; + var diagnostics = model.GetDiagnostics(cancellationToken: cancellationToken); + if (diagnostics.IsEmpty) + { + return ImmutableArray.Empty; + } + + var unnecessaryImports = new HashSet(); + + foreach (var diagnostic in diagnostics) + { + if (diagnostic.Id == "CS8019") + { + if (root.FindNode(diagnostic.Location.SourceSpan) is UsingDirectiveSyntax node && predicate(node)) + { + unnecessaryImports.Add(node); + } + } + } + + return unnecessaryImports.ToImmutableArray(); + } + } +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 536fa84baaa83..d86c03eae0333 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -187,6 +187,9 @@ + + + diff --git a/src/Features/Core/Portable/Fading/FadingOptions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Fading/FadingOptions.cs similarity index 88% rename from src/Features/Core/Portable/Fading/FadingOptions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Fading/FadingOptions.cs index 8c81a73ae868c..3ca3a2478baef 100644 --- a/src/Features/Core/Portable/Fading/FadingOptions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Fading/FadingOptions.cs @@ -2,10 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if CODE_STYLE +using Microsoft.CodeAnalysis.Internal.Options; + +namespace Microsoft.CodeAnalysis.Internal.Fading +{ +#else using Microsoft.CodeAnalysis.Options; namespace Microsoft.CodeAnalysis.Fading { +#endif internal static class FadingOptions { public static readonly PerLanguageOption FadeOutUnusedImports = new PerLanguageOption( diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Helpers/RemoveUnnecessaryImports/AbstractUnnecessaryImportsProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Helpers/RemoveUnnecessaryImports/AbstractUnnecessaryImportsProvider.cs new file mode 100644 index 0000000000000..baa7193cb05cd --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Helpers/RemoveUnnecessaryImports/AbstractUnnecessaryImportsProvider.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. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Threading; + +namespace Microsoft.CodeAnalysis.RemoveUnnecessaryImports +{ + internal abstract class AbstractUnnecessaryImportsProvider + : IUnnecessaryImportsProvider, IEqualityComparer where T : SyntaxNode + { + public ImmutableArray GetUnnecessaryImports( + SemanticModel model, CancellationToken cancellationToken) + { + var root = model.SyntaxTree.GetRoot(cancellationToken); + return GetUnnecessaryImports(model, root, predicate: null, cancellationToken: cancellationToken); + } + + protected abstract ImmutableArray GetUnnecessaryImports( + SemanticModel model, SyntaxNode root, + Func predicate, CancellationToken cancellationToken); + + ImmutableArray IUnnecessaryImportsProvider.GetUnnecessaryImports(SemanticModel model, SyntaxNode root, Func predicate, CancellationToken cancellationToken) + => GetUnnecessaryImports(model, root, predicate, cancellationToken); + + bool IEqualityComparer.Equals(T x, T y) + { + return x.Span == y.Span; + } + + int IEqualityComparer.GetHashCode(T obj) + { + return obj.Span.GetHashCode(); + } + } +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Helpers/RemoveUnnecessaryImports/IUnnecessaryImportsProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Helpers/RemoveUnnecessaryImports/IUnnecessaryImportsProvider.cs new file mode 100644 index 0000000000000..938a48b827075 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Helpers/RemoveUnnecessaryImports/IUnnecessaryImportsProvider.cs @@ -0,0 +1,21 @@ +// 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.Immutable; +using System.Threading; + +namespace Microsoft.CodeAnalysis.RemoveUnnecessaryImports +{ + internal interface IUnnecessaryImportsProvider + { + ImmutableArray GetUnnecessaryImports(SemanticModel model, CancellationToken cancellationToken); + + ImmutableArray GetUnnecessaryImports( + SemanticModel model, + SyntaxNode root, + Func predicate, + CancellationToken cancellationToken); + } +} diff --git a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Helpers/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsProvider.vb similarity index 71% rename from src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Helpers/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsProvider.vb index 30b5c4728224f..938c8e20b5ebe 100644 --- a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Helpers/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsProvider.vb @@ -4,55 +4,33 @@ Imports System.Collections.Immutable Imports System.Threading -Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Formatting -Imports Microsoft.CodeAnalysis.Internal.Log Imports Microsoft.CodeAnalysis.RemoveUnnecessaryImports Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports - Partial Friend MustInherit Class AbstractVisualBasicRemoveUnnecessaryImportsService - Inherits AbstractRemoveUnnecessaryImportsService(Of ImportsClauseSyntax) + Friend NotInheritable Class VisualBasicUnnecessaryImportsProvider + Inherits AbstractUnnecessaryImportsProvider(Of ImportsClauseSyntax) - Public Overrides Async Function RemoveUnnecessaryImportsAsync( - document As Document, - predicate As Func(Of SyntaxNode, Boolean), - cancellationToken As CancellationToken) As Task(Of Document) - - predicate = If(predicate, Functions(Of SyntaxNode).True) - Using Logger.LogBlock(FunctionId.Refactoring_RemoveUnnecessaryImports_VisualBasic, cancellationToken) - - Dim unnecessaryImports = Await GetCommonUnnecessaryImportsOfAllContextAsync( - document, predicate, cancellationToken).ConfigureAwait(False) - If unnecessaryImports.Any(Function(import) import.OverlapsHiddenPosition(cancellationToken)) Then - Return document - End If + Public Shared Instance As New VisualBasicUnnecessaryImportsProvider - Dim root = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False) - - Dim oldRoot = DirectCast(root, CompilationUnitSyntax) - Dim newRoot = New Rewriter(Me, document, unnecessaryImports, cancellationToken).Visit(oldRoot) - newRoot = newRoot.WithAdditionalAnnotations(Formatter.Annotation) - - cancellationToken.ThrowIfCancellationRequested() - Return document.WithSyntaxRoot(newRoot) - End Using - End Function + Private Sub New() + End Sub Protected Overrides Function GetUnnecessaryImports( model As SemanticModel, root As SyntaxNode, predicate As Func(Of SyntaxNode, Boolean), - cancellationToken As CancellationToken) As ImmutableArray(Of ImportsClauseSyntax) + cancellationToken As CancellationToken) As ImmutableArray(Of SyntaxNode) predicate = If(predicate, Functions(Of SyntaxNode).True) Dim diagnostics = model.GetDiagnostics(cancellationToken:=cancellationToken) - Dim unnecessaryImports = New HashSet(Of ImportsClauseSyntax) + Dim unnecessaryImports = New HashSet(Of SyntaxNode) For Each diagnostic In diagnostics If diagnostic.Id = "BC50000" Then Dim node = root.FindNode(diagnostic.Location.SourceSpan) If node IsNot Nothing AndAlso predicate(node) Then - unnecessaryImports.Add(DirectCast(node, ImportsClauseSyntax)) + unnecessaryImports.Add(node) End If End If @@ -73,7 +51,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports Private Shared Sub AddRedundantImports( compilationUnit As CompilationUnitSyntax, semanticModel As SemanticModel, - unnecessaryImports As HashSet(Of ImportsClauseSyntax), + unnecessaryImports As HashSet(Of SyntaxNode), predicate As Func(Of SyntaxNode, Boolean), cancellationToken As CancellationToken) ' Now that we've visited the tree, add any imports that bound to project level @@ -97,7 +75,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports Private Shared Sub AddRedundantAliasImportsClause( clause As SimpleImportsClauseSyntax, semanticModel As SemanticModel, - unnecessaryImports As HashSet(Of ImportsClauseSyntax), + unnecessaryImports As HashSet(Of SyntaxNode), predicate As Func(Of SyntaxNode, Boolean), cancellationToken As CancellationToken) @@ -120,7 +98,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports Private Shared Sub AddRedundantMemberImportsClause( clause As SimpleImportsClauseSyntax, semanticModel As SemanticModel, - unnecessaryImports As HashSet(Of ImportsClauseSyntax), + unnecessaryImports As HashSet(Of SyntaxNode), predicate As Func(Of SyntaxNode, Boolean), cancellationToken As CancellationToken) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems index 5dfe47addd944..6c2c15196b340 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems @@ -12,6 +12,7 @@ + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems index f7cf9ccc55958..3461d61f3f578 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems @@ -67,6 +67,10 @@ + + + + diff --git a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs similarity index 99% rename from src/Features/CSharp/Portable/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs index 0ee723b3f5dbb..926033fe24c18 100644 --- a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.CSharp.Extensions; -using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; diff --git a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs similarity index 79% rename from src/Features/CSharp/Portable/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs index f608477c2f28a..5ea971e5008da 100644 --- a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs @@ -21,6 +21,9 @@ namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports internal partial class AbstractCSharpRemoveUnnecessaryImportsService : AbstractRemoveUnnecessaryImportsService { + protected override IUnnecessaryImportsProvider UnnecessaryImportsProvider + => CSharpUnnecessaryImportsProvider.Instance; + public override async Task RemoveUnnecessaryImportsAsync( Document document, Func predicate, @@ -46,34 +49,6 @@ public override async Task RemoveUnnecessaryImportsAsync( } } - protected override ImmutableArray GetUnnecessaryImports( - SemanticModel model, SyntaxNode root, - Func predicate, CancellationToken cancellationToken) - { - predicate ??= Functions.True; - var diagnostics = model.GetDiagnostics(cancellationToken: cancellationToken); - if (!diagnostics.Any()) - { - return ImmutableArray.Empty; - } - - var unnecessaryImports = new HashSet(); - - foreach (var diagnostic in diagnostics) - { - if (diagnostic.Id == "CS8019") - { - - if (root.FindNode(diagnostic.Location.SourceSpan) is UsingDirectiveSyntax node && predicate(node)) - { - unnecessaryImports.Add(node); - } - } - } - - return unnecessaryImports.ToImmutableArray(); - } - private async Task FormatResultAsync(Document document, CompilationUnitSyntax newRoot, CancellationToken cancellationToken) { var spans = new List(); diff --git a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs similarity index 100% rename from src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs diff --git a/src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs similarity index 100% rename from src/Features/CSharp/Portable/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs index 629473773bf1b..d27e92dc1e68e 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs @@ -185,5 +185,15 @@ public static async Task RequireSemanticModelAsync(this Document var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); return model ?? throw new InvalidOperationException(); } + + public static IEnumerable GetLinkedDocuments(this Document document) + { + var solution = document.Project.Solution; + + foreach (var linkedDocumentId in document.GetLinkedDocumentIds()) + { + yield return solution.GetRequiredDocument(linkedDocumentId); + } + } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs index 92299c83f44bb..b2f7aefb541d8 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs @@ -4,10 +4,17 @@ #nullable enable +using System; using System.Collections.Generic; namespace Microsoft.CodeAnalysis.Shared.Extensions { +#if CODE_STYLE + using Resources = CodeStyleFixesResources; +#else + using Resources = WorkspacesResources; +#endif + internal static partial class ISolutionExtensions { public static IEnumerable GetChangedDocuments(this Solution? newSolution, Solution oldSolution) @@ -30,5 +37,30 @@ public static IEnumerable GetChangedDocuments(this Solution? newSolu { return solution.GetDocument(documentId) ?? solution.GetAdditionalDocument(documentId) ?? solution.GetAnalyzerConfigDocument(documentId); } + + public static Document GetRequiredDocument(this Solution solution, SyntaxTree syntaxTree) + => solution.GetDocument(syntaxTree) ?? throw new InvalidOperationException(); + + public static Project GetRequiredProject(this Solution solution, ProjectId projectId) + { + var project = solution.GetProject(projectId); + if (project == null) + { + throw new InvalidOperationException(string.Format(Resources.Project_of_ID_0_is_required_to_accomplish_the_task_but_is_not_available_from_the_solution, projectId)); + } + + return project; + } + + public static Document GetRequiredDocument(this Solution solution, DocumentId documentId) + { + var document = solution.GetDocument(documentId); + if (document == null) + { + throw new InvalidOperationException(Resources.The_solution_does_not_contain_the_specified_document); + } + + return document; + } } } diff --git a/src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs similarity index 80% rename from src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs index 96c843dfffcb5..69a8f806c61ba 100644 --- a/src/Features/Core/Portable/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs @@ -19,18 +19,13 @@ internal abstract class AbstractRemoveUnnecessaryImportsService : IUnnecessaryImportsService, IEqualityComparer where T : SyntaxNode { + protected abstract IUnnecessaryImportsProvider UnnecessaryImportsProvider { get; } + public Task RemoveUnnecessaryImportsAsync(Document document, CancellationToken cancellationToken) => RemoveUnnecessaryImportsAsync(document, predicate: null, cancellationToken: cancellationToken); public abstract Task RemoveUnnecessaryImportsAsync(Document fromDocument, Func predicate, CancellationToken cancellationToken); - public ImmutableArray GetUnnecessaryImports( - SemanticModel model, CancellationToken cancellationToken) - { - var root = model.SyntaxTree.GetRoot(cancellationToken); - return GetUnnecessaryImports(model, root, predicate: null, cancellationToken: cancellationToken).CastArray(); - } - protected SyntaxToken StripNewLines(Document document, SyntaxToken token) { var syntaxFacts = document.GetLanguageService(); @@ -49,10 +44,6 @@ protected SyntaxToken StripNewLines(Document document, SyntaxToken token) return token.WithLeadingTrivia(trimmedLeadingTrivia); } - protected abstract ImmutableArray GetUnnecessaryImports( - SemanticModel model, SyntaxNode root, - Func predicate, CancellationToken cancellationToken); - protected async Task> GetCommonUnnecessaryImportsOfAllContextAsync( Document document, Func predicate, CancellationToken cancellationToken) { @@ -60,15 +51,15 @@ protected async Task> GetCommonUnnecessaryImportsOfAllContextAsync( var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var unnecessaryImports = new HashSet(this); - unnecessaryImports.AddRange(GetUnnecessaryImports( - model, root, predicate, cancellationToken)); + unnecessaryImports.AddRange(UnnecessaryImportsProvider.GetUnnecessaryImports( + model, root, predicate, cancellationToken).Cast()); foreach (var current in document.GetLinkedDocuments()) { var currentModel = await current.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var currentRoot = await current.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - unnecessaryImports.IntersectWith(GetUnnecessaryImports( - currentModel, currentRoot, predicate, cancellationToken)); + unnecessaryImports.IntersectWith(UnnecessaryImportsProvider.GetUnnecessaryImports( + currentModel, currentRoot, predicate, cancellationToken).Cast()); } return unnecessaryImports; @@ -83,5 +74,8 @@ int IEqualityComparer.GetHashCode(T obj) { return obj.Span.GetHashCode(); } + + ImmutableArray IUnnecessaryImportsService.GetUnnecessaryImports(SemanticModel semanticModel, CancellationToken cancellationToken) + => UnnecessaryImportsProvider.GetUnnecessaryImports(semanticModel, cancellationToken); } } diff --git a/src/Features/Core/Portable/RemoveUnnecessaryImports/IRemoveUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/IRemoveUnnecessaryImportsService.cs similarity index 100% rename from src/Features/Core/Portable/RemoveUnnecessaryImports/IRemoveUnnecessaryImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/IRemoveUnnecessaryImportsService.cs diff --git a/src/Features/Core/Portable/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs similarity index 100% rename from src/Features/Core/Portable/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems index 43ddc9a76e1b6..f64f093771b15 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems @@ -33,6 +33,9 @@ + + + diff --git a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb similarity index 99% rename from src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb index 6b09ee1443326..2dea25c49e254 100644 --- a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb @@ -4,7 +4,6 @@ Imports System.Threading Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.VisualBasic Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb new file mode 100644 index 0000000000000..40065ebab784c --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb @@ -0,0 +1,47 @@ +' 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. + +Imports System.Threading +Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.Formatting +Imports Microsoft.CodeAnalysis.Internal.Log +Imports Microsoft.CodeAnalysis.RemoveUnnecessaryImports +Imports Microsoft.CodeAnalysis.VisualBasic.Syntax + +Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports + Partial Friend MustInherit Class AbstractVisualBasicRemoveUnnecessaryImportsService + Inherits AbstractRemoveUnnecessaryImportsService(Of ImportsClauseSyntax) + + Protected NotOverridable Overrides ReadOnly Property UnnecessaryImportsProvider As IUnnecessaryImportsProvider + Get + Return VisualBasicUnnecessaryImportsProvider.Instance + End Get + End Property + + Public Overrides Async Function RemoveUnnecessaryImportsAsync( + document As Document, + predicate As Func(Of SyntaxNode, Boolean), + cancellationToken As CancellationToken) As Task(Of Document) + + predicate = If(predicate, Functions(Of SyntaxNode).True) + Using Logger.LogBlock(FunctionId.Refactoring_RemoveUnnecessaryImports_VisualBasic, cancellationToken) + + Dim unnecessaryImports = Await GetCommonUnnecessaryImportsOfAllContextAsync( + document, predicate, cancellationToken).ConfigureAwait(False) + If unnecessaryImports.Any(Function(import) import.OverlapsHiddenPosition(cancellationToken)) Then + Return document + End If + + Dim root = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False) + + Dim oldRoot = DirectCast(root, CompilationUnitSyntax) + Dim newRoot = New Rewriter(Me, document, unnecessaryImports, cancellationToken).Visit(oldRoot) + newRoot = newRoot.WithAdditionalAnnotations(Formatter.Annotation) + + cancellationToken.ThrowIfCancellationRequested() + Return document.WithSyntaxRoot(newRoot) + End Using + End Function + End Class +End Namespace diff --git a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb similarity index 100% rename from src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb diff --git a/src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb similarity index 100% rename from src/Features/VisualBasic/Portable/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems index 0829be27fce94..b23c24f8f42f3 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems @@ -49,6 +49,10 @@ + + + + From c4ebb305e0f7808ab8b7706b84f4dfb0c3248e5b Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Thu, 6 Feb 2020 16:13:53 -0800 Subject: [PATCH 06/26] Refactor remove unncessary imports service --- .../CSharpWorkspaceExtensions.projitems | 6 ++---- ...moveUnnecessaryImportsService.Rewriter.cs} | 6 +++--- ... CSharpRemoveUnnecessaryImportsService.cs} | 13 +++++++++++-- .../CSharpRemoveUnnecessaryImportsService.cs | 19 ------------------- .../CSharpUnnecessaryImportsService.cs | 19 ------------------- ...AbstractRemoveUnnecessaryImportsService.cs | 4 ---- .../IUnnecessaryImportsService.cs | 15 --------------- .../Core/WorkspaceExtensions.projitems | 1 - ...ualBasicRemoveUnnecessaryImportsService.vb | 18 ------------------ .../VisualBasicUnnecessaryImportsService.vb | 18 ------------------ ...moveUnnecessaryImportsService.Rewriter.vb} | 6 +++--- ...alBasicRemoveUnnecessaryImportsService.vb} | 11 +++++++++-- .../VisualBasicWorkspaceExtensions.projitems | 6 ++---- 13 files changed, 30 insertions(+), 112 deletions(-) rename src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/{RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs => CSharpRemoveUnnecessaryImportsService.Rewriter.cs} (97%) rename src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/{RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs => CSharpRemoveUnnecessaryImportsService.cs} (89%) delete mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs delete mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs delete mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs delete mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb delete mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb rename src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/{RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb => VisualBasicRemoveUnnecessaryImportsService.Rewriter.vb} (96%) rename src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/{RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb => VisualBasicRemoveUnnecessaryImportsService.vb} (82%) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems index 3461d61f3f578..ff10cf43f47de 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems @@ -67,10 +67,8 @@ - - - - + + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.Rewriter.cs similarity index 97% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.Rewriter.cs index 926033fe24c18..65f4dd841c749 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.Rewriter.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.Rewriter.cs @@ -13,17 +13,17 @@ namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports { - internal partial class AbstractCSharpRemoveUnnecessaryImportsService + internal partial class CSharpRemoveUnnecessaryImportsService { private class Rewriter : CSharpSyntaxRewriter { private readonly ISet _unnecessaryUsingsDoNotAccessDirectly; private readonly CancellationToken _cancellationToken; - private readonly AbstractCSharpRemoveUnnecessaryImportsService _importsService; + private readonly CSharpRemoveUnnecessaryImportsService _importsService; private readonly Document _document; public Rewriter( - AbstractCSharpRemoveUnnecessaryImportsService importsService, + CSharpRemoveUnnecessaryImportsService importsService, Document document, ISet unnecessaryUsings, CancellationToken cancellationToken) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.cs similarity index 89% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.cs index 5ea971e5008da..ae64c12e97ece 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/AbstractCSharpRemoveUnnecessaryImportsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.cs @@ -4,12 +4,13 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; +using System.Composition; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Formatting; +using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.RemoveUnnecessaryImports; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -18,9 +19,17 @@ namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports { - internal partial class AbstractCSharpRemoveUnnecessaryImportsService : + [ExportLanguageService(typeof(IRemoveUnnecessaryImportsService), LanguageNames.CSharp), Shared] + internal partial class CSharpRemoveUnnecessaryImportsService : AbstractRemoveUnnecessaryImportsService { + public static readonly CSharpRemoveUnnecessaryImportsService Instance = new CSharpRemoveUnnecessaryImportsService(); + + [ImportingConstructor] + public CSharpRemoveUnnecessaryImportsService() + { + } + protected override IUnnecessaryImportsProvider UnnecessaryImportsProvider => CSharpUnnecessaryImportsProvider.Instance; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs deleted file mode 100644 index 7466f7994c519..0000000000000 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsService.cs +++ /dev/null @@ -1,19 +0,0 @@ -// 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.Composition; -using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.RemoveUnnecessaryImports; - -namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports -{ - [ExportLanguageService(typeof(IRemoveUnnecessaryImportsService), LanguageNames.CSharp), Shared] - internal partial class CSharpRemoveUnnecessaryImportsService : AbstractCSharpRemoveUnnecessaryImportsService - { - [ImportingConstructor] - public CSharpRemoveUnnecessaryImportsService() - { - } - } -} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs deleted file mode 100644 index c5a38ee54f9b3..0000000000000 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/RemoveUnnecessaryImports/CSharpUnnecessaryImportsService.cs +++ /dev/null @@ -1,19 +0,0 @@ -// 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.Composition; -using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.RemoveUnnecessaryImports; - -namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports -{ - [ExportLanguageService(typeof(IUnnecessaryImportsService), LanguageNames.CSharp), Shared] - internal partial class CSharpUnnecessaryImportsService : AbstractCSharpRemoveUnnecessaryImportsService - { - [ImportingConstructor] - public CSharpUnnecessaryImportsService() - { - } - } -} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs index 69a8f806c61ba..c3150a83e60c5 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/AbstractRemoveUnnecessaryImportsService.cs @@ -16,7 +16,6 @@ namespace Microsoft.CodeAnalysis.RemoveUnnecessaryImports { internal abstract class AbstractRemoveUnnecessaryImportsService : IRemoveUnnecessaryImportsService, - IUnnecessaryImportsService, IEqualityComparer where T : SyntaxNode { protected abstract IUnnecessaryImportsProvider UnnecessaryImportsProvider { get; } @@ -74,8 +73,5 @@ int IEqualityComparer.GetHashCode(T obj) { return obj.Span.GetHashCode(); } - - ImmutableArray IUnnecessaryImportsService.GetUnnecessaryImports(SemanticModel semanticModel, CancellationToken cancellationToken) - => UnnecessaryImportsProvider.GetUnnecessaryImports(semanticModel, cancellationToken); } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs deleted file mode 100644 index c7834a6bfc8ae..0000000000000 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/RemoveUnnecessaryImports/IUnnecessaryImportsService.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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.Collections.Immutable; -using System.Threading; -using Microsoft.CodeAnalysis.Host; - -namespace Microsoft.CodeAnalysis.RemoveUnnecessaryImports -{ - internal interface IUnnecessaryImportsService : ILanguageService - { - ImmutableArray GetUnnecessaryImports(SemanticModel semanticModel, CancellationToken cancellationToken); - } -} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems index f64f093771b15..209c9a5e3a99d 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems @@ -35,7 +35,6 @@ - diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb deleted file mode 100644 index c0f9f6a6bad94..0000000000000 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsService.vb +++ /dev/null @@ -1,18 +0,0 @@ -' 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. - -Imports System.Composition -Imports Microsoft.CodeAnalysis.Host.Mef -Imports Microsoft.CodeAnalysis.RemoveUnnecessaryImports - -Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports - - Friend Class VisualBasicRemoveUnnecessaryImportsService - Inherits AbstractVisualBasicRemoveUnnecessaryImportsService - - - Public Sub New() - End Sub - End Class -End Namespace diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb deleted file mode 100644 index bc6a61fde002b..0000000000000 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/VisualBasicUnnecessaryImportsService.vb +++ /dev/null @@ -1,18 +0,0 @@ -' 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. - -Imports System.Composition -Imports Microsoft.CodeAnalysis.Host.Mef -Imports Microsoft.CodeAnalysis.RemoveUnnecessaryImports - -Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports - - Friend Class VisualBasicUnnecessaryImportsService - Inherits AbstractVisualBasicRemoveUnnecessaryImportsService - - - Public Sub New() - End Sub - End Class -End Namespace diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicRemoveUnnecessaryImportsService.Rewriter.vb similarity index 96% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicRemoveUnnecessaryImportsService.Rewriter.vb index 2dea25c49e254..1f51535541845 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.Rewriter.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicRemoveUnnecessaryImportsService.Rewriter.vb @@ -7,17 +7,17 @@ Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports - Partial Friend Class AbstractVisualBasicRemoveUnnecessaryImportsService + Partial Friend Class VisualBasicRemoveUnnecessaryImportsService Private Class Rewriter Inherits VisualBasicSyntaxRewriter Private ReadOnly _unnecessaryImports As ISet(Of ImportsClauseSyntax) Private ReadOnly _cancellationToken As CancellationToken Private ReadOnly _annotation As New SyntaxAnnotation() - Private ReadOnly _importsService As AbstractVisualBasicRemoveUnnecessaryImportsService + Private ReadOnly _importsService As VisualBasicRemoveUnnecessaryImportsService Private ReadOnly _document As Document - Public Sub New(importsService As AbstractVisualBasicRemoveUnnecessaryImportsService, + Public Sub New(importsService As VisualBasicRemoveUnnecessaryImportsService, document As Document, unnecessaryImports As ISet(Of ImportsClauseSyntax), cancellationToken As CancellationToken) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicRemoveUnnecessaryImportsService.vb similarity index 82% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicRemoveUnnecessaryImportsService.vb index 40065ebab784c..2e0b8534447ec 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/RemoveUnnecessaryImports/AbstractVisualBasicRemoveUnnecessaryImportsService.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicRemoveUnnecessaryImportsService.vb @@ -2,18 +2,25 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports System.Composition Imports System.Threading Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Formatting +Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.Internal.Log Imports Microsoft.CodeAnalysis.RemoveUnnecessaryImports Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports - Partial Friend MustInherit Class AbstractVisualBasicRemoveUnnecessaryImportsService + + Partial Friend NotInheritable Class VisualBasicRemoveUnnecessaryImportsService Inherits AbstractRemoveUnnecessaryImportsService(Of ImportsClauseSyntax) - Protected NotOverridable Overrides ReadOnly Property UnnecessaryImportsProvider As IUnnecessaryImportsProvider + + Public Sub New() + End Sub + + Protected Overrides ReadOnly Property UnnecessaryImportsProvider As IUnnecessaryImportsProvider Get Return VisualBasicUnnecessaryImportsProvider.Instance End Get diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems index b23c24f8f42f3..81545c5e5aadb 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems @@ -49,10 +49,8 @@ - - - - + + From 46ef3bbf510c5b380b99ccfbcf0f431dfe53c5d8 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 06:57:43 -0800 Subject: [PATCH 07/26] Disable some nullable related unit tests for CodeStyle layer as they validate product behavior based on a new nullable API that is not yet available in CodeStyle layer. Also skip a failing test with #41484 --- .../Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs | 3 +++ .../VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs index 18c4b74a0609e..0feb92f188e4e 100644 --- a/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs +++ b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs @@ -476,6 +476,8 @@ void Method(Program? x) await TestInRegularAndScriptAsync(before, after, options: ExplicitTypeExceptWhereApparent()); } +#if !CODE_STYLE // Tests depending on product code which need new nullable APIs are disabled for Code Style layer + [WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExplicitType)] [WorkItem(40477, "https://github.com/dotnet/roslyn/issues/40477")] public async Task NullableType() @@ -969,6 +971,7 @@ void Method(System.Collections.Generic.IEnumerable<(Program, Program)> x) await TestMissingInRegularAndScriptAsync(before, new TestParameters(options: ExplicitTypeForBuiltInTypesOnly())); await TestInRegularAndScriptAsync(before, after, options: ExplicitTypeExceptWhereApparent()); } +#endif [WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExplicitType)] [WorkItem(23907, "https://github.com/dotnet/roslyn/issues/23907")] diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb index 264681165516e..a4b6d04f73902 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb @@ -76,7 +76,7 @@ Namespace SomeNamespace End Namespace") End Function - + Public Async Function TestAddImportWithCaseChange() As Task Await TestAsync( From 53fdfe09c9625885328014597150411b5a1e1840 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 07:01:36 -0800 Subject: [PATCH 08/26] Add clarification comment --- ...elWorkspaceServiceFactory.SemanticModelWorkspaceService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs b/src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs index e32b6a7ebabd4..0df4e5a2e93fa 100644 --- a/src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs +++ b/src/CodeStyle/Core/CodeFixes/LanguageServices/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs @@ -16,7 +16,9 @@ private sealed class SemanticModelService : ISemanticModelService { public Task GetSemanticModelForNodeAsync(Document document, SyntaxNode node, CancellationToken cancellationToken = default) { - // get the base one + // TODO: port the GetSemanticModelForNodeAsync implementation from Workspaces layer, + // which currently relies on a bunch of internal APIs. + // For now, we fall back to the public API to fetch document's SemanticModel. return document.GetSemanticModelAsync(cancellationToken); } } From cc3910c8bfa4c03ccb44aa936bd6146a9f811bb5 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 07:36:40 -0800 Subject: [PATCH 09/26] Remove the last remaining extern alias. --- src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs | 4 ---- src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs | 3 +-- .../CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs index f327a831ef84c..5128562557cfc 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs @@ -2,10 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if CODE_STYLE -extern alias CodeStyle; -#endif - using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Text; diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs index 7977af5cd312f..cfe696a634900 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs @@ -16,8 +16,7 @@ namespace Microsoft.CodeAnalysis.CodeStyle { - extern alias CodeStyle; - using Formatter = Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; + using Formatter = Formatting.Formatter; using ISyntaxFormattingService = ISyntaxFormattingService; internal abstract class AbstractFormattingCodeFixProvider : CodeFixProvider diff --git a/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj b/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj index fd7e853fcb0f5..77179947b294b 100644 --- a/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj +++ b/src/CodeStyle/Core/CodeFixes/Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj @@ -14,7 +14,7 @@ - + From 677d29208fb710cfee7171a69772f586ec55e4dd Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 07:40:32 -0800 Subject: [PATCH 10/26] Remove stale xlf files. --- src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf | 12 ------------ src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf | 12 ------------ .../Core/Analyzers/xlf/Resource1.zh-Hans.xlf | 12 ------------ .../Core/Analyzers/xlf/Resource1.zh-Hant.xlf | 12 ------------ 13 files changed, 156 deletions(-) delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hans.xlf delete mode 100644 src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hant.xlf diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf deleted file mode 100644 index 734bfa216be5b..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.cs.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf deleted file mode 100644 index 98b02ae2b71ae..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.de.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf deleted file mode 100644 index 4f199594fc154..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.es.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf deleted file mode 100644 index 45bbac7b66029..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.fr.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf deleted file mode 100644 index 1e18cf210a5d2..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.it.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf deleted file mode 100644 index cebf12e83dded..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ja.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf deleted file mode 100644 index d3fc7046a9f56..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ko.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf deleted file mode 100644 index 10fb669a87adb..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.pl.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf deleted file mode 100644 index b98d9fc6a08e7..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.pt-BR.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf deleted file mode 100644 index e15b0a4f7e31d..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.ru.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf deleted file mode 100644 index a57f23d4c86dc..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.tr.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hans.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hans.xlf deleted file mode 100644 index 042f4608614e1..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hans.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hant.xlf b/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hant.xlf deleted file mode 100644 index fd863bcc718c7..0000000000000 --- a/src/CodeStyle/Core/Analyzers/xlf/Resource1.zh-Hant.xlf +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - - \ No newline at end of file From 3e69af57d493d651f5ce7b3aecde1dbd39188eff Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 08:06:10 -0800 Subject: [PATCH 11/26] Revert changes to DocumentBasedFixAllProvider and AbstractFormattingCodeFixProvider --- .../CodeFixes/FormattingCodeFixProvider.cs | 6 +-- .../CodeFixes/DocumentBasedFixAllProvider.cs | 48 +++++++++++++------ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs index cfe696a634900..0260fe2e59876 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs @@ -76,14 +76,14 @@ public FixAll(AbstractFormattingCodeFixProvider formattingCodeFixProvider) _formattingCodeFixProvider = formattingCodeFixProvider; } - protected override string GetCodeActionTitle(FixAllContext fixAllContext) => CodeStyleResources.Fix_formatting; + protected override string CodeActionTitle => CodeStyleResources.Fix_formatting; - protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) { var options = await _formattingCodeFixProvider.GetOptionsAsync(document, fixAllContext.CancellationToken).ConfigureAwait(false); var syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); var updatedSyntaxRoot = Formatter.Format(syntaxRoot, _formattingCodeFixProvider.SyntaxFormattingService, options, fixAllContext.CancellationToken); - return document.WithSyntaxRoot(updatedSyntaxRoot); + return updatedSyntaxRoot; } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs index 21e9d82d1aa55..f385341b6c0d3 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs @@ -18,7 +18,10 @@ namespace Microsoft.CodeAnalysis.CodeStyle /// internal abstract class DocumentBasedFixAllProvider : FixAllProvider { - protected abstract string GetCodeActionTitle(FixAllContext fixAllContext); + protected abstract string CodeActionTitle + { + get; + } public override Task GetFixAsync(FixAllContext fixAllContext) { @@ -27,21 +30,21 @@ public override Task GetFixAsync(FixAllContext fixAllContext) { case FixAllScope.Document: fixAction = CodeAction.Create( - GetCodeActionTitle(fixAllContext), + CodeActionTitle, cancellationToken => GetDocumentFixesAsync(fixAllContext.WithCancellationToken(cancellationToken)), nameof(DocumentBasedFixAllProvider)); break; case FixAllScope.Project: fixAction = CodeAction.Create( - GetCodeActionTitle(fixAllContext), + CodeActionTitle, cancellationToken => GetProjectFixesAsync(fixAllContext.WithCancellationToken(cancellationToken), fixAllContext.Project), nameof(DocumentBasedFixAllProvider)); break; case FixAllScope.Solution: fixAction = CodeAction.Create( - GetCodeActionTitle(fixAllContext), + CodeActionTitle, cancellationToken => GetSolutionFixesAsync(fixAllContext.WithCancellationToken(cancellationToken)), nameof(DocumentBasedFixAllProvider)); break; @@ -61,8 +64,12 @@ public override Task GetFixAsync(FixAllContext fixAllContext) /// The context for the Fix All operation. /// The document to fix. /// The diagnostics to fix in the document. - /// New fixed or original document if no changes were made to the document. - protected abstract Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics); + /// + /// The new representing the root of the fixed document. + /// -or- + /// , if no changes were made to the document. + /// + protected abstract Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics); private async Task GetDocumentFixesAsync(FixAllContext fixAllContext) { @@ -72,7 +79,13 @@ private async Task GetDocumentFixesAsync(FixAllContext fixAllContext) return fixAllContext.Document; } - return await FixAllInDocumentAsync(fixAllContext, fixAllContext.Document, diagnostics).ConfigureAwait(false); + var newRoot = await FixAllInDocumentAsync(fixAllContext, fixAllContext.Document, diagnostics).ConfigureAwait(false); + if (newRoot == null) + { + return fixAllContext.Document; + } + + return fixAllContext.Document.WithSyntaxRoot(newRoot); } private async Task GetSolutionFixesAsync(FixAllContext fixAllContext, ImmutableArray documents) @@ -80,20 +93,27 @@ private async Task GetSolutionFixesAsync(FixAllContext fixAllContext, var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext, progressTrackerOpt: null).ConfigureAwait(false); var solution = fixAllContext.Solution; - var newDocuments = new Dictionary>(documents.Length); + var newDocuments = new List>(documents.Length); foreach (var document in documents) { - if (documentDiagnosticsToFix.TryGetValue(document, out var diagnostics)) + if (!documentDiagnosticsToFix.TryGetValue(document, out var diagnostics)) { - newDocuments.Add(document.Id, FixAllInDocumentAsync(fixAllContext, document, diagnostics)); + newDocuments.Add(document.GetSyntaxRootAsync(fixAllContext.CancellationToken)); + continue; } + + newDocuments.Add(FixAllInDocumentAsync(fixAllContext, document, diagnostics)); } - foreach (var documentIdAndTask in newDocuments) + for (var i = 0; i < documents.Length; i++) { - var newDocument = await documentIdAndTask.Value.ConfigureAwait(false); - var newDocumentRoot = await newDocument.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); - solution = solution.WithDocumentSyntaxRoot(documentIdAndTask.Key, newDocumentRoot); + var newDocumentRoot = await newDocuments[i].ConfigureAwait(false); + if (newDocumentRoot == null) + { + continue; + } + + solution = solution.WithDocumentSyntaxRoot(documents[i].Id, newDocumentRoot); } return solution; From 1e8b5d09396eb83c708ec395031da75654032004 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 10:45:52 -0800 Subject: [PATCH 12/26] Remove CodeStyle layer from Compiler.sln due to dependencies on project missing from this solution. --- Compilers.sln | 98 ++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 80 deletions(-) diff --git a/Compilers.sln b/Compilers.sln index f64f8fed7d47a..51915cf42f962 100644 --- a/Compilers.sln +++ b/Compilers.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27102.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29731.156 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.UnitTests", "src\Compilers\Core\CodeAnalysisTest\Microsoft.CodeAnalysis.UnitTests.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}" EndProject @@ -118,26 +118,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSha EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Workspaces", "src\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj", "{57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeStyle", "CodeStyle", "{B20208C3-D3A6-4020-A274-6BE3786D29FB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle", "src\CodeStyle\Core\Analyzers\Microsoft.CodeAnalysis.CodeStyle.csproj", "{275812EE-DEDB-4232-9439-91C9757D2AE4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.Fixes", "src\CodeStyle\Core\CodeFixes\Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj", "{5FF1E493-69CC-4D0B-83F2-039F469A04E1}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.UnitTests", "src\CodeStyle\Core\Tests\Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj", "{9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle", "src\CodeStyle\CSharp\Analyzers\Microsoft.CodeAnalysis.CSharp.CodeStyle.csproj", "{AA87BFED-089A-4096-B8D5-690BDC7D5B24}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes", "src\CodeStyle\CSharp\CodeFixes\Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes.csproj", "{A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests", "src\CodeStyle\CSharp\Tests\Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj", "{5018D049-5870-465A-889B-C742CE1E31CB}" -EndProject -Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle", "src\CodeStyle\VisualBasic\Analyzers\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.vbproj", "{2531A8C4-97DD-47BC-A79C-B7846051E137}" -EndProject -Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes", "src\CodeStyle\VisualBasic\CodeFixes\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj", "{0141285D-8F6C-42C7-BAF3-3C0CCD61C716}" -EndProject -Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests", "src\CodeStyle\VisualBasic\Tests\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj", "{E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}" -EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzerDriver", "src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.shproj", "{54E08BF5-F819-404F-A18D-0AB9EA81EA04}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "BasicAnalyzerDriver", "src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.shproj", "{E8F0BAA5-7327-43D1-9A51-644E81AE55F1}" @@ -162,24 +142,27 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Net.Compilers.Too EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution - src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 - src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 - src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 - src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4 - src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 4 + src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 + src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 + src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5 + src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 5 + src\Compilers\Core\CommandLine\CommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{54e08bf5-f819-404f-a18d-0ab9ea81ea04}*SharedItemsImports = 13 - src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4 - src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 4 - src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4 - src\Compilers\Server\ServerShared\ServerShared.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 4 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 + src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 + src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 5 + src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 5 + src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 5 src\Compilers\Core\CommandLine\CommandLine.projitems*{ad6f474e-e6d4-4217-91f3-b7af1be31ccc}*SharedItemsImports = 13 - src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4 - src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4 - src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 4 + src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 5 src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13 - src\Compilers\Core\CommandLine\CommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 4 + src\Compilers\Core\CommandLine\CommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{e8f0baa5-7327-43d1-9a51-644e81ae55f1}*SharedItemsImports = 13 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -367,42 +350,6 @@ Global {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Debug|Any CPU.Build.0 = Debug|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Release|Any CPU.ActiveCfg = Release|Any CPU {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C}.Release|Any CPU.Build.0 = Release|Any CPU - {275812EE-DEDB-4232-9439-91C9757D2AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {275812EE-DEDB-4232-9439-91C9757D2AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {275812EE-DEDB-4232-9439-91C9757D2AE4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {275812EE-DEDB-4232-9439-91C9757D2AE4}.Release|Any CPU.Build.0 = Release|Any CPU - {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5FF1E493-69CC-4D0B-83F2-039F469A04E1}.Release|Any CPU.Build.0 = Release|Any CPU - {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}.Release|Any CPU.Build.0 = Release|Any CPU - {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AA87BFED-089A-4096-B8D5-690BDC7D5B24}.Release|Any CPU.Build.0 = Release|Any CPU - {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73}.Release|Any CPU.Build.0 = Release|Any CPU - {5018D049-5870-465A-889B-C742CE1E31CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5018D049-5870-465A-889B-C742CE1E31CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5018D049-5870-465A-889B-C742CE1E31CB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5018D049-5870-465A-889B-C742CE1E31CB}.Release|Any CPU.Build.0 = Release|Any CPU - {2531A8C4-97DD-47BC-A79C-B7846051E137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2531A8C4-97DD-47BC-A79C-B7846051E137}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2531A8C4-97DD-47BC-A79C-B7846051E137}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2531A8C4-97DD-47BC-A79C-B7846051E137}.Release|Any CPU.Build.0 = Release|Any CPU - {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0141285D-8F6C-42C7-BAF3-3C0CCD61C716}.Release|Any CPU.Build.0 = Release|Any CPU - {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510}.Release|Any CPU.Build.0 = Release|Any CPU {15FEBD1B-55CE-4EBD-85E3-04898260A25B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {15FEBD1B-55CE-4EBD-85E3-04898260A25B}.Debug|Any CPU.Build.0 = Debug|Any CPU {15FEBD1B-55CE-4EBD-85E3-04898260A25B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -489,15 +436,6 @@ Global {5F8D2414-064A-4B3A-9B42-8E2A04246BE5} = {D9591377-7868-4D64-9314-83E0C92A871B} {21B239D0-D144-430F-A394-C066D58EE267} = {D9591377-7868-4D64-9314-83E0C92A871B} {57CA988D-F010-4BF2-9A2E-07D6DCD2FF2C} = {D9591377-7868-4D64-9314-83E0C92A871B} - {275812EE-DEDB-4232-9439-91C9757D2AE4} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} - {5FF1E493-69CC-4D0B-83F2-039F469A04E1} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} - {9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} - {AA87BFED-089A-4096-B8D5-690BDC7D5B24} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} - {A07ABCF5-BC43-4EE9-8FD8-B2D77FD54D73} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} - {5018D049-5870-465A-889B-C742CE1E31CB} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} - {2531A8C4-97DD-47BC-A79C-B7846051E137} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} - {0141285D-8F6C-42C7-BAF3-3C0CCD61C716} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} - {E512C6C1-F085-4AD7-B0D9-E8F1A0A2A510} = {B20208C3-D3A6-4020-A274-6BE3786D29FB} {54E08BF5-F819-404F-A18D-0AB9EA81EA04} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {E8F0BAA5-7327-43D1-9A51-644E81AE55F1} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {15FEBD1B-55CE-4EBD-85E3-04898260A25B} = {274B96B7-F815-47E3-9CA4-4024A57A478F} From f1c5abe37b032f9a9070e34258b8e3967bfa3e52 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 10:46:32 -0800 Subject: [PATCH 13/26] Revert unnecessary code changes --- .../TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs | 1 - .../Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs index 0180216712e89..b5c66af8d27f6 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs @@ -2,7 +2,6 @@ // 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.IO; using System.Linq; using System.Xml.Linq; using Roslyn.Utilities; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs index f59006bef8d87..e6ec871ac93d3 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxNodeExtensions.cs @@ -15,10 +15,6 @@ using Roslyn.Utilities; using SyntaxNodeOrTokenExtensions = Microsoft.CodeAnalysis.Shared.Extensions.SyntaxNodeOrTokenExtensions; -#if CODE_STYLE -#else -#endif - namespace Microsoft.CodeAnalysis.CSharp.Extensions { internal static partial class SyntaxNodeExtensions From 26540d459108b4543e1111efd020a59fc0445bf7 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 11:07:43 -0800 Subject: [PATCH 14/26] Project changes to avoid C# and VB CodeStyle unit test projects depending on another unit test project (core CodeStyle test project, which did not have any tests). --- Roslyn.sln | 8 +------- .../Core/Tests/Analyzers.UnitTests.projitems | 11 ----------- .../Core/Tests/Analyzers.UnitTests.shproj | 13 ------------- ....CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj | 2 +- ...odeAnalysis.CodeStyle.UnitTestUtilities.csproj} | 1 - .../Core/Tests/Properties/launchSettings.json | 14 -------------- ...Analysis.VisualBasic.CodeStyle.UnitTests.vbproj | 2 +- ...ft.CodeAnalysis.EditorFeatures.UnitTests.csproj | 1 - .../Roslyn.Services.Test.Utilities.csproj | 2 +- .../Portable/Roslyn.Test.Utilities.csproj | 2 +- .../Microsoft.CodeAnalysis.Workspaces.csproj | 2 +- 11 files changed, 6 insertions(+), 52 deletions(-) delete mode 100644 src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems delete mode 100644 src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj rename src/CodeStyle/Core/Tests/{Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj => Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj} (95%) delete mode 100644 src/CodeStyle/Core/Tests/Properties/launchSettings.json diff --git a/Roslyn.sln b/Roslyn.sln index c40ef4fe370f5..195ddaf086105 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -330,7 +330,7 @@ Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.Visu EndProject Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes", "src\CodeStyle\VisualBasic\CodeFixes\Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj", "{0141285D-8F6C-42C7-BAF3-3C0CCD61C716}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.UnitTests", "src\CodeStyle\Core\Tests\Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj", "{9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities", "src\CodeStyle\Core\Tests\Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj", "{9FF1205F-1D7C-4EE4-B038-3456FE6EBEAF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests", "src\CodeStyle\CSharp\Tests\Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj", "{5018D049-5870-465A-889B-C742CE1E31CB}" EndProject @@ -428,8 +428,6 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CompilerExtensions", "src\W EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "WorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.shproj", "{99F594B1-3916-471D-A761-A6731FC50E9A}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Analyzers.UnitTests", "src\Analyzers\Core\Tests\Analyzers.UnitTests.shproj", "{0C9A3C46-C74B-4528-AF62-7288AE131AF3}" -EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpCompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.shproj", "{699FEA05-AEA7-403D-827E-53CF4E826955}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpWorkspaceExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.shproj", "{438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787}" @@ -465,7 +463,6 @@ Global src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{0be66736-cdaa-4989-88b1-b3f46ebdca4a}*SharedItemsImports = 5 - src\Analyzers\Core\Tests\Analyzers.UnitTests.projitems*{0c9a3c46-c74b-4528-af62-7288ae131af3}*SharedItemsImports = 13 src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{1b6c4a1a-413b-41fb-9f85-5c09118e541b}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 @@ -502,12 +499,10 @@ Global src\Analyzers\Core\Analyzers\Analyzers.projitems*{76e96966-4780-4040-8197-bde2879516f4}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{7b7f4153-ae93-4908-b8f0-430871589f83}*SharedItemsImports = 13 - src\Analyzers\Core\Tests\Analyzers.UnitTests.projitems*{8cee3609-a5a9-4a9b-86d7-33118f5d6b33}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{94faf461-2e74-4dbb-9813-6b2cde6f1880}*SharedItemsImports = 13 src\Compilers\Core\CommandLine\CommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{99f594b1-3916-471d-a761-a6731fc50e9a}*SharedItemsImports = 13 src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{9f9ccc78-7487-4127-9d46-db23e501f001}*SharedItemsImports = 13 - src\Analyzers\Core\Tests\Analyzers.UnitTests.projitems*{9ff1205f-1d7c-4ee4-b038-3456fe6ebeaf}*SharedItemsImports = 5 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5 @@ -1404,7 +1399,6 @@ Global {4A49D526-1644-4819-AA4F-95B348D447D4} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6} {EC946164-1E17-410B-B7D9-7DE7E6268D63} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} {99F594B1-3916-471D-A761-A6731FC50E9A} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} - {0C9A3C46-C74B-4528-AF62-7288AE131AF3} = {4A49D526-1644-4819-AA4F-95B348D447D4} {699FEA05-AEA7-403D-827E-53CF4E826955} = {7A69EA65-4411-4CD0-B439-035E720C1BD3} {438DB8AF-F3F0-4ED9-80B5-13FDDD5B8787} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E} {58969243-7F59-4236-93D0-C93B81F569B3} = {4A49D526-1644-4819-AA4F-95B348D447D4} diff --git a/src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems b/src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems deleted file mode 100644 index 016b07d950552..0000000000000 --- a/src/Analyzers/Core/Tests/Analyzers.UnitTests.projitems +++ /dev/null @@ -1,11 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - ec946164-1e17-410b-b7d9-7de7e6268d63 - - - Microsoft.CodeAnalysis.Analyzers.UnitTests - - \ No newline at end of file diff --git a/src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj b/src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj deleted file mode 100644 index fac6264b5b558..0000000000000 --- a/src/Analyzers/Core/Tests/Analyzers.UnitTests.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - {0C9A3C46-C74B-4528-AF62-7288AE131AF3} - 14.0 - - - - - - - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj index a558b01c62003..ae8d2c8d78030 100644 --- a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj similarity index 95% rename from src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj rename to src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj index 73d610eab9912..99f1fa686e4b9 100644 --- a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj @@ -27,5 +27,4 @@ - \ No newline at end of file diff --git a/src/CodeStyle/Core/Tests/Properties/launchSettings.json b/src/CodeStyle/Core/Tests/Properties/launchSettings.json deleted file mode 100644 index 037383dc96d4f..0000000000000 --- a/src/CodeStyle/Core/Tests/Properties/launchSettings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "profiles": { - "xUnit.net Console (32-bit)": { - "commandName": "Executable", - "executablePath": "$(NuGetPackageRoot)xunit.runner.console\\$(XUnitVersion)\\tools\\net452\\xunit.console.x86.exe", - "commandLineArgs": "$(TargetPath) -noshadow -verbose" - }, - "xUnit.net Console (64-bit)": { - "commandName": "Executable", - "executablePath": "$(NuGetPackageRoot)xunit.runner.console\\$(XUnitVersion)\\tools\\net452\\xunit.console.exe", - "commandLineArgs": "$(TargetPath) -noshadow -verbose" - } - } -} \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj index aaeab1e0243f7..9c998a0a89fd1 100644 --- a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj +++ b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj @@ -19,7 +19,7 @@ - + diff --git a/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj b/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj index 348f24f765c54..948e2be434df3 100644 --- a/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj +++ b/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj @@ -69,5 +69,4 @@ - \ No newline at end of file diff --git a/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj b/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj index 961ac37f17cc4..6dc48a5e56baf 100644 --- a/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj +++ b/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj @@ -100,7 +100,7 @@ - + diff --git a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj index 7309918b4ed2f..7aac547c0edc3 100644 --- a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj +++ b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj @@ -61,7 +61,7 @@ - + diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index 34f770f14d901..31bb0c3c681b8 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -124,7 +124,7 @@ - + From 3050f34d1ae3a27036929ef7c348588700c04286 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 12:19:37 -0800 Subject: [PATCH 15/26] Mark CodeStyle test projects as non-Shipping. --- .../Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj | 1 + .../Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj | 1 + ...Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj | 1 + 3 files changed, 3 insertions(+) diff --git a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj index ae8d2c8d78030..eb0aa98ca4b61 100644 --- a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj @@ -6,6 +6,7 @@ Microsoft.CodeAnalysis.CSharp $(DefineConstants),CODE_STYLE net472 + false true diff --git a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj index 99f1fa686e4b9..0e3117b2ad3fc 100644 --- a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj +++ b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj @@ -6,6 +6,7 @@ Microsoft.CodeAnalysis $(DefineConstants),CODE_STYLE net472 + false diff --git a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj index 9c998a0a89fd1..d3bd4c2665b8f 100644 --- a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj +++ b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj @@ -6,6 +6,7 @@ net472 $(DefineConstants),CODE_STYLE + false true From 868886af5e357b5339fc4540d161940f55712a40 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 14:08:12 -0800 Subject: [PATCH 16/26] Test code refactoring to avoid C# and VB EditorFeatures UnitTests projects from requiring to reference EditorFeatures UnitTests project - unit test projects referencing other unit test projects are not allowed by our Correctness builds. --- Roslyn.sln | 7 +++ ...nalysis.CodeStyle.UnitTestUtilities.csproj | 8 +-- ...is.CSharp.EditorFeatures2.UnitTests.csproj | 1 + ...oft.CodeAnalysis.EditorFeatures.Wpf.csproj | 1 + ...crosoft.CodeAnalysis.EditorFeatures.csproj | 1 + .../AbstractChangeSignatureTests.cs | 0 .../ChangeSignatureTestState.cs | 0 .../AbstractCodeActionOrUserDiagnosticTest.cs | 0 ...ionOrUserDiagnosticTest_TestAddDocument.cs | 0 .../CodeActions/AbstractCodeActionTest.cs | 0 ...agnosticProviderBasedUserDiagnosticTest.cs | 0 ...edUserDiagnosticTest_ParenthesesOptions.cs | 0 .../AbstractSuppressionAllCodeTests.cs | 0 .../AbstractSuppressionDiagnosticTest.cs | 0 ...DiagnosticTest.FixAllDiagnosticProvider.cs | 0 .../Diagnostics/AbstractUserDiagnosticTest.cs | 0 ...ctUserDiagnosticTest_GenerateTypeDialog.cs | 0 ...Features.DiagnosticsTests.Utilities.csproj | 62 +++++++++++++++++++ .../MoveType/AbstractMoveTypeTest.cs | 0 ...deAnalysis.EditorFeatures.UnitTests.csproj | 1 + .../Roslyn.Services.Test.Utilities.csproj | 1 + ...isualBasic.EditorFeatures.UnitTests.vbproj | 2 +- ...rosoft.CodeAnalysis.CSharp.Features.csproj | 1 + .../Microsoft.CodeAnalysis.Features.csproj | 1 + ...t.CodeAnalysis.VisualBasic.Features.vbproj | 1 + ...soft.CodeAnalysis.CSharp.Workspaces.csproj | 1 + .../Microsoft.CodeAnalysis.Workspaces.csproj | 1 + ...CodeAnalysis.VisualBasic.Workspaces.vbproj | 1 + 28 files changed, 85 insertions(+), 5 deletions(-) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/ChangeSignature/AbstractChangeSignatureTests.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/ChangeSignature/ChangeSignatureTestState.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/CodeActions/AbstractCodeActionTest.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/Diagnostics/AbstractSuppressionAllCodeTests.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/Diagnostics/AbstractSuppressionDiagnosticTest.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/Diagnostics/AbstractUserDiagnosticTest.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs (100%) create mode 100644 src/EditorFeatures/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/MoveType/AbstractMoveTypeTest.cs (100%) diff --git a/Roslyn.sln b/Roslyn.sln index 195ddaf086105..006dc5ba17a8f 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -458,6 +458,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compiler", "Compiler", "{7A EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspace", "Workspace", "{9C1BE25C-5926-4E56-84AE-D2242CB0627E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities", "src\EditorFeatures\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj", "{1C2DAB75-D024-4C04-9F3F-B2F881D805EE}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 @@ -1201,6 +1203,10 @@ Global {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Debug|Any CPU.Build.0 = Debug|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.Build.0 = Release|Any CPU + {1C2DAB75-D024-4C04-9F3F-B2F881D805EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C2DAB75-D024-4C04-9F3F-B2F881D805EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C2DAB75-D024-4C04-9F3F-B2F881D805EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C2DAB75-D024-4C04-9F3F-B2F881D805EE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1414,6 +1420,7 @@ Global {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5} {7A69EA65-4411-4CD0-B439-035E720C1BD3} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} {9C1BE25C-5926-4E56-84AE-D2242CB0627E} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B} + {1C2DAB75-D024-4C04-9F3F-B2F881D805EE} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29} diff --git a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj index 0e3117b2ad3fc..c86d1148f5de4 100644 --- a/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj +++ b/src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj @@ -9,10 +9,10 @@ false - - - - + + + + diff --git a/src/EditorFeatures/CSharpTest2/Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests.csproj b/src/EditorFeatures/CSharpTest2/Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests.csproj index f415088dcefba..7247cdceb9219 100644 --- a/src/EditorFeatures/CSharpTest2/Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests.csproj +++ b/src/EditorFeatures/CSharpTest2/Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests.csproj @@ -24,6 +24,7 @@ + diff --git a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj index 90b1acc4d3310..458f86012fcaf 100644 --- a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj +++ b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj @@ -51,6 +51,7 @@ + diff --git a/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj b/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj index dfeb35fcbe69e..8ad145b777450 100644 --- a/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj +++ b/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj @@ -79,6 +79,7 @@ + diff --git a/src/EditorFeatures/Test/ChangeSignature/AbstractChangeSignatureTests.cs b/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs similarity index 100% rename from src/EditorFeatures/Test/ChangeSignature/AbstractChangeSignatureTests.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs diff --git a/src/EditorFeatures/Test/ChangeSignature/ChangeSignatureTestState.cs b/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/ChangeSignatureTestState.cs similarity index 100% rename from src/EditorFeatures/Test/ChangeSignature/ChangeSignatureTestState.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/ChangeSignatureTestState.cs diff --git a/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs similarity index 100% rename from src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs diff --git a/src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs similarity index 100% rename from src/EditorFeatures/Test/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs diff --git a/src/EditorFeatures/Test/CodeActions/AbstractCodeActionTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs similarity index 100% rename from src/EditorFeatures/Test/CodeActions/AbstractCodeActionTest.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs similarity index 100% rename from src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs similarity index 100% rename from src/EditorFeatures/Test/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest_ParenthesesOptions.cs diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractSuppressionAllCodeTests.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractSuppressionAllCodeTests.cs similarity index 100% rename from src/EditorFeatures/Test/Diagnostics/AbstractSuppressionAllCodeTests.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractSuppressionAllCodeTests.cs diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractSuppressionDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractSuppressionDiagnosticTest.cs similarity index 100% rename from src/EditorFeatures/Test/Diagnostics/AbstractSuppressionDiagnosticTest.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractSuppressionDiagnosticTest.cs diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs similarity index 100% rename from src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs similarity index 100% rename from src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs diff --git a/src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs similarity index 100% rename from src/EditorFeatures/Test/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj b/src/EditorFeatures/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj new file mode 100644 index 0000000000000..b33cff258d214 --- /dev/null +++ b/src/EditorFeatures/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj @@ -0,0 +1,62 @@ + + + + + Library + Microsoft.CodeAnalysis.Test.Utilities + net472 + true + true + false + + + + + + + + + + + + + + + global,WORKSPACES + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/EditorFeatures/Test/MoveType/AbstractMoveTypeTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/MoveType/AbstractMoveTypeTest.cs similarity index 100% rename from src/EditorFeatures/Test/MoveType/AbstractMoveTypeTest.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/MoveType/AbstractMoveTypeTest.cs diff --git a/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj b/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj index 948e2be434df3..fcc4cfe2fd582 100644 --- a/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj +++ b/src/EditorFeatures/Test/Microsoft.CodeAnalysis.EditorFeatures.UnitTests.csproj @@ -34,6 +34,7 @@ + diff --git a/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj b/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj index 6dc48a5e56baf..02fa1e12ed867 100644 --- a/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj +++ b/src/EditorFeatures/TestUtilities/Roslyn.Services.Test.Utilities.csproj @@ -103,6 +103,7 @@ + diff --git a/src/EditorFeatures/VisualBasicTest/Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj b/src/EditorFeatures/VisualBasicTest/Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj index fe9b97f6fd0c8..a8289e092090d 100644 --- a/src/EditorFeatures/VisualBasicTest/Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj +++ b/src/EditorFeatures/VisualBasicTest/Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests.vbproj @@ -37,8 +37,8 @@ + - diff --git a/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj b/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj index f34a6e41dc567..5ac8ef18d009a 100644 --- a/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj +++ b/src/Features/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Features.csproj @@ -43,6 +43,7 @@ + diff --git a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj index 5ce0dcfb2f205..c75b1fe56c5a6 100644 --- a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj +++ b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj @@ -78,6 +78,7 @@ + diff --git a/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj b/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj index 446144358e19d..cccedd4c421ef 100644 --- a/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj +++ b/src/Features/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Features.vbproj @@ -38,6 +38,7 @@ + diff --git a/src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj b/src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj index 3b5166a34b459..b780280e77c5f 100644 --- a/src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj +++ b/src/Workspaces/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.Workspaces.csproj @@ -41,6 +41,7 @@ + diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index 31bb0c3c681b8..3aa0da2e6fbbf 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -96,6 +96,7 @@ + diff --git a/src/Workspaces/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj b/src/Workspaces/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj index fc7287b21bfb8..9deadc9d3833c 100644 --- a/src/Workspaces/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj +++ b/src/Workspaces/VisualBasic/Portable/Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj @@ -38,6 +38,7 @@ + From 23dc0c011b07b184adce0cef833eabcf7b9811a6 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 14:22:11 -0800 Subject: [PATCH 17/26] Add direct project references in UnitTest projects to please BuildBoss --- ...Analysis.CSharp.CodeStyle.UnitTests.csproj | 29 +++++++++++++++++-- ...sis.VisualBasic.CodeStyle.UnitTests.vbproj | 29 +++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj index eb0aa98ca4b61..d898a47176dcf 100644 --- a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj @@ -22,9 +22,34 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj index d3bd4c2665b8f..93a0ec5e90b26 100644 --- a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj +++ b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj @@ -23,9 +23,34 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + From f70503dafe0b8c0a8e1165749e0a659d465c684e Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 15:22:31 -0800 Subject: [PATCH 18/26] Fix some more test project references --- ...icrosoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj | 2 +- .../MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs | 0 .../MoveToNamespace/AbstractMoveToNamespaceTests.cs | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs (100%) rename src/EditorFeatures/{Test => DiagnosticsTestUtilities}/MoveToNamespace/AbstractMoveToNamespaceTests.cs (100%) diff --git a/src/EditorFeatures/CSharpTest/Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj b/src/EditorFeatures/CSharpTest/Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj index 93873238b0607..5da1c530a64c0 100644 --- a/src/EditorFeatures/CSharpTest/Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj +++ b/src/EditorFeatures/CSharpTest/Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests.csproj @@ -28,7 +28,6 @@ - @@ -39,6 +38,7 @@ + diff --git a/src/EditorFeatures/Test/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs b/src/EditorFeatures/DiagnosticsTestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs similarity index 100% rename from src/EditorFeatures/Test/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.TestState.cs diff --git a/src/EditorFeatures/Test/MoveToNamespace/AbstractMoveToNamespaceTests.cs b/src/EditorFeatures/DiagnosticsTestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs similarity index 100% rename from src/EditorFeatures/Test/MoveToNamespace/AbstractMoveToNamespaceTests.cs rename to src/EditorFeatures/DiagnosticsTestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs From 216ab581812bdc404ad8f2d1973d4315e762cd65 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 7 Feb 2020 15:50:13 -0800 Subject: [PATCH 19/26] Change signature for IncludeDiagnosticDuringFixAll --- .../Nullable/CSharpDeclareAsNullableCodeFixProvider.cs | 6 +++--- .../AddRequiredParenthesesCodeFixProvider.cs | 4 ++-- .../PreferFrameworkTypeCodeFixProvider.cs | 2 +- .../AbstractRemoveUnusedValuesCodeFixProvider.cs | 6 +++--- .../SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs | 2 +- .../Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs b/src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs index 7c15ecbd3e765..8a198deb4c37a 100644 --- a/src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs @@ -77,10 +77,10 @@ protected override Task FixAllAsync( return Task.CompletedTask; } - protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) + protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string equivalenceKey, CancellationToken cancellationToken) { - var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, fixAllContext.CancellationToken); - return fixAllContext.CodeActionEquivalenceKey == GetEquivalenceKey(node); + var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); + return equivalenceKey == GetEquivalenceKey(node); } private static void MakeDeclarationNullable(SyntaxEditor editor, SyntaxNode node, HashSet alreadyHandled) diff --git a/src/Features/Core/Portable/AddRequiredParentheses/AddRequiredParenthesesCodeFixProvider.cs b/src/Features/Core/Portable/AddRequiredParentheses/AddRequiredParenthesesCodeFixProvider.cs index a846525dac55b..3538a0b2fc9a5 100644 --- a/src/Features/Core/Portable/AddRequiredParentheses/AddRequiredParenthesesCodeFixProvider.cs +++ b/src/Features/Core/Portable/AddRequiredParentheses/AddRequiredParenthesesCodeFixProvider.cs @@ -29,9 +29,9 @@ public override ImmutableArray FixableDiagnosticIds internal sealed override CodeFixCategory CodeFixCategory => CodeFixCategory.CodeStyle; - protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) + protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string equivalenceKey, CancellationToken cancellationToken) => diagnostic.Properties.ContainsKey(AddRequiredParenthesesConstants.IncludeInFixAll) && - diagnostic.Properties[AddRequiredParenthesesConstants.EquivalenceKey] == fixAllContext.CodeActionEquivalenceKey; + diagnostic.Properties[AddRequiredParenthesesConstants.EquivalenceKey] == equivalenceKey; public override Task RegisterCodeFixesAsync(CodeFixContext context) { diff --git a/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeCodeFixProvider.cs b/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeCodeFixProvider.cs index e211752069104..9726385acd28b 100644 --- a/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeCodeFixProvider.cs +++ b/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeCodeFixProvider.cs @@ -63,7 +63,7 @@ protected override async Task FixAllAsync( } } - protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) + protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic) => diagnostic.Properties.ContainsKey(PreferFrameworkTypeConstants.PreferFrameworkType); private class PreferFrameworkTypeCodeAction : CodeAction.DocumentChangeAction diff --git a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs index d9a9bdc618ca3..60af0f86589cc 100644 --- a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs +++ b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedValuesCodeFixProvider.cs @@ -199,10 +199,10 @@ private static string GetEquivalenceKey(Diagnostic diagnostic) private static bool NeedsToMoveNewLocalDeclarationsNearReference(string diagnosticId) => diagnosticId == IDEDiagnosticIds.ValueAssignedIsUnusedDiagnosticId; - protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) + protected override bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string equivalenceKey, CancellationToken cancellationToken) { - return fixAllContext.CodeActionEquivalenceKey == GetEquivalenceKey(diagnostic) && - !IsForEachIterationVariableDiagnostic(diagnostic, fixAllContext.Document, fixAllContext.CancellationToken); + return equivalenceKey == GetEquivalenceKey(diagnostic) && + !IsForEachIterationVariableDiagnostic(diagnostic, document, cancellationToken); } private IEnumerable> GetDiagnosticsGroupedByMember( diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs index 25ec9dd7124a1..213d6ec0a5df8 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.FixAllProvider.cs @@ -87,7 +87,7 @@ private async Task FixDocumentAsync( // Also ensure that we do not pass in duplicates by invoking Distinct. // See https://github.com/dotnet/roslyn/issues/31381, that seems to be causing duplicate diagnostics. var filteredDiagnostics = diagnostics.Distinct() - .WhereAsArray(d => _codeFixProvider.IncludeDiagnosticDuringFixAll(d, fixAllContext)) + .WhereAsArray(d => _codeFixProvider.IncludeDiagnosticDuringFixAll(d, fixAllContext.Document, fixAllContext.CodeActionEquivalenceKey, fixAllContext.CancellationToken)) .Sort((d1, d2) => d1.Location.SourceSpan.Start - d2.Location.SourceSpan.Start); // PERF: Do not invoke FixAllAsync on the code fix provider if there are no diagnostics to be fixed. diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs index 58bdc4ff8449f..42a3fb5e25c66 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/SyntaxEditorBasedCodeFixProvider.cs @@ -69,7 +69,7 @@ protected abstract Task FixAllAsync( /// Only one of these two overloads needs to be overridden if you want to customize /// behavior. /// - protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixAllContext fixAllContext) + protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, Document document, string equivalenceKey, CancellationToken cancellationToken) => IncludeDiagnosticDuringFixAll(diagnostic); /// @@ -83,7 +83,7 @@ protected virtual bool IncludeDiagnosticDuringFixAll(Diagnostic diagnostic, FixA /// here. If only the diagnostic needs to be queried to make this determination, only this /// overload needs to be overridden. However, if information from /// is needed (for example ), then + /// cref="IncludeDiagnosticDuringFixAll(Diagnostic, Document, string, CancellationToken)"/> /// should be overridden instead. /// /// Only one of these two overloads needs to be overridden if you want to customize From f1b4a01366744784e8a91928b4616fe7ef9f2307 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Mon, 10 Feb 2020 09:54:37 -0800 Subject: [PATCH 20/26] Delete duplicate file added by automatic merge conflict resolution --- ...bstractDeclaredSymbolInfoFactoryService.cs | 104 ------------------ 1 file changed, 104 deletions(-) delete mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/AbstractDeclaredSymbolInfoFactoryService.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/AbstractDeclaredSymbolInfoFactoryService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/AbstractDeclaredSymbolInfoFactoryService.cs deleted file mode 100644 index 291699ea90195..0000000000000 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/AbstractDeclaredSymbolInfoFactoryService.cs +++ /dev/null @@ -1,104 +0,0 @@ -// 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.Collections.Generic; -using System.Collections.Immutable; -using System.Diagnostics; -using System.Globalization; -using System.Text; -using Microsoft.CodeAnalysis.FindSymbols; -using Microsoft.CodeAnalysis.PooledObjects; -using Roslyn.Utilities; - -namespace Microsoft.CodeAnalysis.LanguageServices -{ - internal abstract class AbstractDeclaredSymbolInfoFactoryService : IDeclaredSymbolInfoFactoryService - { - private const string GenericTypeNameManglingString = "`"; - private static readonly string[] s_aritySuffixesOneToNine = { "`1", "`2", "`3", "`4", "`5", "`6", "`7", "`8", "`9" }; - - private readonly static ObjectPool>> s_aliasMapListPool - = SharedPools.Default>>(); - - // Note: these names are stored case insensitively. That way the alias mapping works - // properly for VB. It will mean that our inheritance maps may store more links in them - // for C#. However, that's ok. It will be rare in practice, and all it means is that - // we'll end up examining slightly more types (likely 0) when doing operations like - // Find all references. - private readonly static ObjectPool> s_aliasMapPool - = SharedPools.StringIgnoreCaseDictionary(); - - protected static List> AllocateAliasMapList() - => s_aliasMapListPool.Allocate(); - - protected static void FreeAliasMapList(List> list) - { - if (list != null) - { - foreach (var aliasMap in list) - { - FreeAliasMap(aliasMap); - } - - s_aliasMapListPool.ClearAndFree(list); - } - } - - protected static void FreeAliasMap(Dictionary aliasMap) - { - if (aliasMap != null) - { - s_aliasMapPool.ClearAndFree(aliasMap); - } - } - - protected static Dictionary AllocateAliasMap() - => s_aliasMapPool.Allocate(); - - protected static void AppendTokens(SyntaxNode node, StringBuilder builder) - { - foreach (var child in node.ChildNodesAndTokens()) - { - if (child.IsToken) - { - builder.Append(child.AsToken().Text); - } - else - { - AppendTokens(child.AsNode(), builder); - } - } - } - - protected static void Intern(StringTable stringTable, ArrayBuilder builder) - { - for (int i = 0, n = builder.Count; i < n; i++) - { - builder[i] = stringTable.Add(builder[i]); - } - } - - public static string GetMetadataAritySuffix(int arity) - { - Debug.Assert(arity > 0); - return (arity <= s_aritySuffixesOneToNine.Length) - ? s_aritySuffixesOneToNine[arity - 1] - : string.Concat(GenericTypeNameManglingString, arity.ToString(CultureInfo.InvariantCulture)); - } - - public abstract bool TryGetDeclaredSymbolInfo(StringTable stringTable, SyntaxNode node, string rootNamespace, out DeclaredSymbolInfo declaredSymbolInfo); - - /// - /// Get the name of the target type of specified extension method declaration. - /// The node provided must be an extension method declaration, i.e. calling `TryGetDeclaredSymbolInfo()` - /// on `node` should return a `DeclaredSymbolInfo` of kind `ExtensionMethod`. - /// If the return value is null, then it means this is a "complex" method (as described at ). - /// - public abstract string GetTargetTypeName(SyntaxNode node); - - public abstract bool TryGetAliasesFromUsingDirective(SyntaxNode node, out ImmutableArray<(string aliasName, string name)> aliases); - - public abstract string GetRootNamespace(CompilationOptions compilationOptions); - } -} From f2f18c0f95e528eddc68f0f5bcb3c94991c4bf15 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Tue, 11 Feb 2020 17:17:07 -0800 Subject: [PATCH 21/26] Fixes from conflicts --- .../Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj | 1 - ...CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj | 10 ++++++++++ .../Portable/Microsoft.CodeAnalysis.Workspaces.csproj | 1 - .../Compiler/Core/CompilerExtensions.projitems | 3 --- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj index 2fd17b15decbe..a5a282e106a2e 100644 --- a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj +++ b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj @@ -7,7 +7,6 @@ netstandard2.0 $(DefineConstants),CODE_STYLE true - true diff --git a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj index 93a0ec5e90b26..760c92d3a1a5e 100644 --- a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj +++ b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj @@ -56,5 +56,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index e3143cd3f2b6b..3aa0da2e6fbbf 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -8,7 +8,6 @@ netstandard2.0 $(DefineConstants);WORKSPACE partial - true true diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 625255d5cbcd0..e0986ea94e5e7 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -8,9 +8,6 @@ Microsoft.CodeAnalysis.Shared - - - From 8e0fe0d27c53a874826379a1f9c51ef931c8808d Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Tue, 11 Feb 2020 19:05:54 -0800 Subject: [PATCH 22/26] Revert unwanted changes and remove usage of extern aliases --- .../UseExplicitTypeTests.cs | 1 + .../Core/Analyzers/Analyzers.projitems | 3 -- ...Analysis.CSharp.CodeStyle.UnitTests.csproj | 1 - .../Core/Analyzers/Formatting/Formatter.cs | 6 +++- .../Analyzers/FormattingAnalyzerHelper.cs | 2 +- .../Microsoft.CodeAnalysis.CodeStyle.csproj | 1 + .../Core/CodeFixes/FormattingCodeFixHelper.cs | 2 +- .../CodeFixes/FormattingCodeFixProvider.cs | 2 +- ...nalysis.VisualBasic.CodeStyle.Fixes.vbproj | 2 +- ...sis.VisualBasic.CodeStyle.UnitTests.vbproj | 1 - .../Portable/Serialization/ObjectWriter.cs | 1 - .../EncapsulateField/EncapsulateFieldTests.cs | 4 +-- .../ExtractLocalFunctionTests.cs | 32 +++++++++---------- .../ExtractMethod/ExtractMethodTests.cs | 32 +++++++++---------- .../OverrideCompletionProviderTests.cs | 4 +-- .../SpeculativeTCompletionProviderTests.cs | 6 ++-- .../SymbolCompletionProviderTests.cs | 10 +++--- .../GenerateDefaultConstructorsTests.cs | 4 +-- .../ImplementInterfaceTests.cs | 10 +++--- .../Workspaces/TestWorkspace_Create.cs | 8 +++-- .../ExtractMethod/ExtractMethodTests.vb | 12 +++---- ...agnosticProviderBasedUserDiagnosticTest.vb | 1 + .../FixAllOccurrences/BatchFixAllProvider.cs | 2 +- ...bstractDeclaredSymbolInfoFactoryService.cs | 7 ---- .../Microsoft.CodeAnalysis.Workspaces.csproj | 1 + .../Core/CompilerExtensions.projitems | 1 - 26 files changed, 77 insertions(+), 79 deletions(-) diff --git a/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs index 0feb92f188e4e..2a0d8fa07f40e 100644 --- a/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs +++ b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseExplicitTypeTests.cs @@ -477,6 +477,7 @@ void Method(Program? x) } #if !CODE_STYLE // Tests depending on product code which need new nullable APIs are disabled for Code Style layer + // https://github.com/dotnet/roslyn/issues/41462 tracks enabling these tests for Code Style layer [WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExplicitType)] [WorkItem(40477, "https://github.com/dotnet/roslyn/issues/40477")] diff --git a/src/Analyzers/Core/Analyzers/Analyzers.projitems b/src/Analyzers/Core/Analyzers/Analyzers.projitems index 324016773bdc9..13db44687fb4d 100644 --- a/src/Analyzers/Core/Analyzers/Analyzers.projitems +++ b/src/Analyzers/Core/Analyzers/Analyzers.projitems @@ -23,7 +23,4 @@ - - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj index d898a47176dcf..1f69ee6cdb58a 100644 --- a/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj +++ b/src/CodeStyle/CSharp/Tests/Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests.csproj @@ -6,7 +6,6 @@ Microsoft.CodeAnalysis.CSharp $(DefineConstants),CODE_STYLE net472 - false true diff --git a/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs b/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs index 6a056e9f13923..b47d2c4151bc2 100644 --- a/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs +++ b/src/CodeStyle/Core/Analyzers/Formatting/Formatter.cs @@ -12,11 +12,15 @@ using Roslyn.Utilities; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; -namespace Microsoft.CodeAnalysis.CodeStyle.Formatting +namespace Microsoft.CodeAnalysis.Internal.Formatting { /// /// Formats whitespace in documents or syntax trees. /// + /// + /// This utility class is only to be used by the formatting analyzer and formatting code fixer in Code Style layer. + /// Other components should use the public "Formatter" type defined in "Microsoft.CodeAnalysis.Formatting" namespace. + /// internal static class Formatter { /// diff --git a/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs b/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs index a97a001d9c739..5aba5abd6aa31 100644 --- a/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs +++ b/src/CodeStyle/Core/Analyzers/FormattingAnalyzerHelper.cs @@ -8,7 +8,7 @@ #if CODE_STYLE using FormatterState = Microsoft.CodeAnalysis.Formatting.ISyntaxFormattingService; -using Formatter = Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; +using Formatter = Microsoft.CodeAnalysis.Internal.Formatting.Formatter; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; #else using Microsoft.CodeAnalysis.Options; diff --git a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj index a5a282e106a2e..2fd17b15decbe 100644 --- a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj +++ b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj @@ -7,6 +7,7 @@ netstandard2.0 $(DefineConstants),CODE_STYLE true + true diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs index 5128562557cfc..55b2b1a9a7c1e 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixHelper.cs @@ -7,7 +7,7 @@ using Microsoft.CodeAnalysis.Text; #if CODE_STYLE -using Formatter = Microsoft.CodeAnalysis.CodeStyle.Formatting.Formatter; +using Formatter = Microsoft.CodeAnalysis.Internal.Formatting.Formatter; using FormatterState = Microsoft.CodeAnalysis.Formatting.ISyntaxFormattingService; using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions; #else diff --git a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs index 0260fe2e59876..e590dbdfffbb2 100644 --- a/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs +++ b/src/CodeStyle/Core/CodeFixes/FormattingCodeFixProvider.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.CodeStyle { - using Formatter = Formatting.Formatter; + using Formatter = Internal.Formatting.Formatter; using ISyntaxFormattingService = ISyntaxFormattingService; internal abstract class AbstractFormattingCodeFixProvider : CodeFixProvider diff --git a/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj b/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj index c9562c8964221..c65493af391db 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj +++ b/src/CodeStyle/VisualBasic/CodeFixes/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes.vbproj @@ -38,7 +38,7 @@ - + diff --git a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj index 760c92d3a1a5e..1276ed38fb716 100644 --- a/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj +++ b/src/CodeStyle/VisualBasic/Tests/Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests.vbproj @@ -6,7 +6,6 @@ net472 $(DefineConstants),CODE_STYLE - false true diff --git a/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs b/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs index b7ed033140b33..1cc51a4ff78fa 100644 --- a/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs +++ b/src/Compilers/Core/Portable/Serialization/ObjectWriter.cs @@ -17,7 +17,6 @@ namespace Roslyn.Utilities { using System.Collections.Immutable; using System.Threading.Tasks; - #if COMPILERCORE using Resources = CodeAnalysisResources; #elif CODE_STYLE diff --git a/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs index d647c212c0f84..6c36e83082ba9 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs @@ -1387,7 +1387,7 @@ public int I }", options: Option(CodeStyleOptions.QualifyFieldAccess, true, NotificationOption.Error)); } - [Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTuple() { var text = @" @@ -1430,7 +1430,7 @@ await TestAllOptionsOffAsync( text, expected, index: 1); } - [Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TupleWithNames() { var text = @" diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs index 8b9d1bf20648c..fb45c46132e21 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs @@ -904,7 +904,7 @@ static void NewMethod(out Construct obj1, out Construct obj2, out Construct obj3 }", CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTuple() { await TestInRegularAndScriptAsync( @@ -931,7 +931,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTupleDeclarationWithNames() { await TestInRegularAndScriptAsync( @@ -958,7 +958,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTupleDeclarationWithSomeNames() { await TestInRegularAndScriptAsync( @@ -985,7 +985,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTupleWith1Arity() { await TestInRegularAndScriptAsync( @@ -1014,7 +1014,7 @@ static void NewMethod(ValueTuple y) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTupleLiteralWithNames() { await TestInRegularAndScriptAsync( @@ -1041,7 +1041,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTupleDeclarationAndLiteralWithNames() { await TestInRegularAndScriptAsync( @@ -1068,7 +1068,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTupleIntoVar() { await TestInRegularAndScriptAsync( @@ -1095,7 +1095,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task RefactorWithoutSystemValueTuple() { await TestInRegularAndScriptAsync( @@ -1122,7 +1122,7 @@ static void Main(string[] args) }", CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestTupleWithNestedNamedTuple() { // This is not the best refactoring, but this is an edge case @@ -1150,7 +1150,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestDeconstruction() { await TestInRegularAndScriptAsync( @@ -1177,7 +1177,7 @@ static void Main(string[] args) }" + TestResources.NetFX.ValueTuple.tuplelib_cs, CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestDeconstruction2() { await TestInRegularAndScriptAsync( @@ -1207,7 +1207,7 @@ static int NewMethod() } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [CompilerTrait(CompilerFeature.OutVar)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.OutVar)] public async Task TestOutVar() { await TestInRegularAndScriptAsync( @@ -1238,7 +1238,7 @@ static void NewMethod(int i, out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [CompilerTrait(CompilerFeature.Patterns)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] public async Task TestIsPattern() { await TestInRegularAndScriptAsync( @@ -1269,7 +1269,7 @@ static void NewMethod(int i, out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [CompilerTrait(CompilerFeature.Patterns)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] public async Task TestOutVarAndIsPattern() { await TestInRegularAndScriptAsync( @@ -1300,7 +1300,7 @@ static void NewMethod(out int r, out int y, out int z) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [CompilerTrait(CompilerFeature.Patterns)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] public async Task ConflictingOutVarLocals() { await TestInRegularAndScriptAsync( @@ -1341,7 +1341,7 @@ static void NewMethod(out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction)] - [CompilerTrait(CompilerFeature.Patterns)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] public async Task ConflictingPatternLocals() { await TestInRegularAndScriptAsync( diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs index 17825a860902e..ec77c4483edf8 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs @@ -919,7 +919,7 @@ private static void NewMethod(out Construct obj1, out Construct obj2, out Constr }"); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTuple() { @@ -947,7 +947,7 @@ private static (int, int) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleDeclarationWithNames() { @@ -975,7 +975,7 @@ private static (int a, int b) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleDeclarationWithSomeNames() { @@ -1003,7 +1003,7 @@ private static (int a, int) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")] public async Task TestTupleWith1Arity() { @@ -1033,7 +1033,7 @@ private static void NewMethod(ValueTuple y) }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleLiteralWithNames() { @@ -1061,7 +1061,7 @@ private static (int, int) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleDeclarationAndLiteralWithNames() { @@ -1089,7 +1089,7 @@ private static (int a, int b) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleIntoVar() { @@ -1117,7 +1117,7 @@ private static (int c, int d) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task RefactorWithoutSystemValueTuple() { @@ -1145,7 +1145,7 @@ private static (int c, int d) NewMethod() }"); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] [WorkItem(11196, "https://github.com/dotnet/roslyn/issues/11196")] public async Task TestTupleWithNestedNamedTuple() { @@ -1174,7 +1174,7 @@ private static (int, int, int, int, int, int, int, string, string) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestDeconstruction() { await TestInRegularAndScriptAsync( @@ -1201,7 +1201,7 @@ private static (int, int) NewMethod() }" + TestResources.NetFX.ValueTuple.tuplelib_cs); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TestDeconstruction2() { await TestInRegularAndScriptAsync( @@ -1231,7 +1231,7 @@ private static int NewMethod() } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [CompilerTrait(CompilerFeature.OutVar)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.OutVar)] public async Task TestOutVar() { await TestInRegularAndScriptAsync( @@ -1262,7 +1262,7 @@ private static void NewMethod(int i, out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [CompilerTrait(CompilerFeature.Patterns)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] public async Task TestIsPattern() { await TestInRegularAndScriptAsync( @@ -1293,7 +1293,7 @@ private static void NewMethod(int i, out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [CompilerTrait(CompilerFeature.Patterns)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] public async Task TestOutVarAndIsPattern() { await TestInRegularAndScriptAsync( @@ -1324,7 +1324,7 @@ private static void NewMethod(out int r, out int y, out int z) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [CompilerTrait(CompilerFeature.Patterns)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] public async Task ConflictingOutVarLocals() { await TestInRegularAndScriptAsync( @@ -1365,7 +1365,7 @@ private static void NewMethod(out int r, out int y) } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractMethod)] - [CompilerTrait(CompilerFeature.Patterns)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Patterns)] public async Task ConflictingPatternLocals() { await TestInRegularAndScriptAsync( diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs index 8569241ce49d6..674c1d5c48fcf 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs @@ -2903,7 +2903,7 @@ public virtual void Bar() {} // CompilationExtensions is in the Microsoft.CodeAnalysis.Test.Utilities namespace // which has a "Traits" type that conflicts with the one in Roslyn.Test.Utilities - var reference = MetadataReference.CreateFromImage(CompilationExtensions.EmitToArray(compilation)); + var reference = MetadataReference.CreateFromImage(Test.Utilities.CompilationExtensions.EmitToArray(compilation)); var p1 = workspace.CurrentSolution.Projects.First(p => p.Name == "P1"); var updatedP1 = p1.AddMetadataReference(reference); workspace.ChangeSolution(updatedP1.Solution); @@ -2954,7 +2954,7 @@ public override void M(in int x) var origComp = await workspace.CurrentSolution.Projects.Single().GetCompilationAsync(); var options = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Latest); var libComp = origComp.RemoveAllSyntaxTrees().AddSyntaxTrees(CSharpSyntaxTree.ParseText(before, options: options)); - var libRef = MetadataReference.CreateFromImage(CompilationExtensions.EmitToArray(libComp)); + var libRef = MetadataReference.CreateFromImage(Test.Utilities.CompilationExtensions.EmitToArray(libComp)); var project = workspace.CurrentSolution.Projects.Single(); var updatedProject = project.AddMetadataReference(libRef); diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs index 9fd5d7e550bd7..f298d7c414117 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs @@ -927,7 +927,7 @@ async Task<$$> [WorkItem(13480, "https://github.com/dotnet/roslyn/issues/13480")] [Fact] - [CompilerTrait(CompilerFeature.LocalFunctions)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] public async Task LocalFunctionReturnType() { var markup = @" @@ -942,7 +942,7 @@ public void M() } [Fact(Skip = "https://github.com/dotnet/roslyn/issues/14525")] - [CompilerTrait(CompilerFeature.LocalFunctions)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] public async Task LocalFunctionAfterAyncTask() { var markup = @" @@ -957,7 +957,7 @@ async Task<$$> } [Fact(Skip = "https://github.com/dotnet/roslyn/issues/14525")] - [CompilerTrait(CompilerFeature.LocalFunctions)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] public async Task LocalFunctionAfterAsync() { var markup = @" diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs index 872af231e9be5..5c87290351a91 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs @@ -9623,7 +9623,7 @@ void goo() [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [CompilerTrait(CompilerFeature.LocalFunctions)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] [WorkItem(13480, "https://github.com/dotnet/roslyn/issues/13480")] public async Task NoCompletionInLocalFuncGenericParamList() { @@ -9639,7 +9639,7 @@ void M() [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [CompilerTrait(CompilerFeature.LocalFunctions)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] [WorkItem(13480, "https://github.com/dotnet/roslyn/issues/13480")] public async Task CompletionForAwaitWithoutAsync() { @@ -9743,7 +9743,7 @@ void M() [WorkItem(14163, "https://github.com/dotnet/roslyn/issues/14163")] [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [CompilerTrait(CompilerFeature.LocalFunctions)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] public async Task LocalFunctionDescription() { await VerifyItemExistsAsync(@" @@ -9761,7 +9761,7 @@ void Local() { } [WorkItem(14163, "https://github.com/dotnet/roslyn/issues/14163")] [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [CompilerTrait(CompilerFeature.LocalFunctions)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] public async Task LocalFunctionDescription2() { await VerifyItemExistsAsync(@" @@ -10548,7 +10548,7 @@ public void M(string s) [WorkItem(38074, "https://github.com/dotnet/roslyn/issues/38074")] [Fact] [Trait(Traits.Feature, Traits.Features.Completion)] - [CompilerTrait(CompilerFeature.LocalFunctions)] + [Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.LocalFunctions)] public async Task LocalFunctionInStaticMethod() { await VerifyItemExistsAsync(@" diff --git a/src/EditorFeatures/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs b/src/EditorFeatures/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs index bcd3c9f4a4e2b..178989372228c 100644 --- a/src/EditorFeatures/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs +++ b/src/EditorFeatures/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs @@ -750,7 +750,7 @@ static void Main(string[] args) index: 2); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task Tuple() { await TestInRegularAndScriptAsync( @@ -779,7 +779,7 @@ public B((int, string) x) }"); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TupleWithNames() { await TestInRegularAndScriptAsync( diff --git a/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs b/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs index 0ff606464e710..1be39a5d88ded 100644 --- a/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs +++ b/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs @@ -235,7 +235,7 @@ public sealed class TupleElementNamesAttribute : Attribute { } } "; - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TupleWithNamesInMethod() { await TestWithAllCodeStyleOptionsOffAsync( @@ -264,7 +264,7 @@ class Class : IInterface " + s_tupleElementNamesAttribute); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TupleWithNamesInMethod_Explicitly() { await TestWithAllCodeStyleOptionsOffAsync( @@ -294,7 +294,7 @@ class Class : IInterface index: 1); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TupleWithNamesInProperty() { await TestWithAllCodeStyleOptionsOffAsync( @@ -331,7 +331,7 @@ class Class : IInterface " + s_tupleElementNamesAttribute); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task TupleWithNamesInEvent() { await TestWithAllCodeStyleOptionsOffAsync( @@ -6733,7 +6733,7 @@ IEnumerator IEnumerable.GetEnumerator() index: 1); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), CompilerTrait(CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] public async Task LongTuple() { await TestWithAllCodeStyleOptionsOffAsync( diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs index 1401a914e9cee..e36438d51adf6 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_Create.cs @@ -5,10 +5,14 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.VisualStudio.Composition; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Utilities; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces { @@ -131,7 +135,7 @@ internal static TestWorkspace Create( } internal static string GetDefaultTestSourceDocumentName(int index, string extension) - => "test" + (index + 1) + extension; + => "test" + (index + 1) + extension; internal static TestWorkspace Create( string language, diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb index d7a1eb4a077dd..78dfa4c7cda3e 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb @@ -438,7 +438,7 @@ End Class .Value.Replace(vbLf, vbCrLf)) End Function - + Public Async Function TestTuples() As Task @@ -475,7 +475,7 @@ End Namespace") End Function - + Public Async Function TestTupleDeclarationWithNames() As Task @@ -507,7 +507,7 @@ End Namespace") End Function - + Public Async Function TestTupleDeclarationWithSomeNames() As Task @@ -539,7 +539,7 @@ End Namespace") End Function - + Public Async Function TestTupleWith1Arity() As Task @@ -573,7 +573,7 @@ End Structure") End Function - + Public Async Function TestTupleWithInferredNames() As Task Await TestAsync( "Class Program @@ -605,7 +605,7 @@ End Namespace", TestOptions.Regular.WithLanguageVersion(LanguageVersion.VisualBa End Function - + Public Async Function TestTupleWithInferredNames_WithVB15() As Task Await TestAsync( "Class Program diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb index 52968e28632c2..b4be17b788a7d 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb @@ -2,6 +2,7 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports System.Xml.Linq Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics Imports Microsoft.CodeAnalysis.CodeActions diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs index 84f6d67113293..373f869efeb85 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/BatchFixAllProvider.cs @@ -25,7 +25,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes /// internal partial class BatchFixAllProvider : FixAllProvider { - public static readonly BatchFixAllProvider Instance = new BatchFixAllProvider(); + public static readonly FixAllProvider Instance = new BatchFixAllProvider(); protected BatchFixAllProvider() { } diff --git a/src/Workspaces/Core/Portable/LanguageServices/DeclaredSymbolFactoryService/AbstractDeclaredSymbolInfoFactoryService.cs b/src/Workspaces/Core/Portable/LanguageServices/DeclaredSymbolFactoryService/AbstractDeclaredSymbolInfoFactoryService.cs index 1a02acd6c6d4c..291699ea90195 100644 --- a/src/Workspaces/Core/Portable/LanguageServices/DeclaredSymbolFactoryService/AbstractDeclaredSymbolInfoFactoryService.cs +++ b/src/Workspaces/Core/Portable/LanguageServices/DeclaredSymbolFactoryService/AbstractDeclaredSymbolInfoFactoryService.cs @@ -2,20 +2,13 @@ // 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.Diagnostics.CodeAnalysis; using System.Globalization; -using System.Linq; using System.Text; -using System.Threading; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; -using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServices diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index 3aa0da2e6fbbf..e3143cd3f2b6b 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -8,6 +8,7 @@ netstandard2.0 $(DefineConstants);WORKSPACE partial + true true diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index e0986ea94e5e7..089c561b6a6ce 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -15,7 +15,6 @@ - From 7f9d9e1d5b4c73dfb3d2e2a2757e038c5cebc0fc Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 12 Feb 2020 12:32:57 -0800 Subject: [PATCH 23/26] Use shared resource files in shared projects. --- .../Analyzers/CSharpAnalyzers.projitems | 3 + .../Analyzers/CSharpAnalyzersResources.resx | 145 ++++++++++++++++++ ...StatementToExpressionDiagnosticAnalyzer.cs | 6 +- ...eStructFieldsWritableDiagnosticAnalyzer.cs | 10 +- ...oveUnnecessaryImportsDiagnosticAnalyzer.cs | 8 +- ...CSharpUseExplicitTypeDiagnosticAnalyzer.cs | 10 +- ...CSharpUseImplicitTypeDiagnosticAnalyzer.cs | 10 +- .../xlf/CSharpAnalyzersResources.cs.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.de.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.es.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.fr.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.it.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.ja.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.ko.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.pl.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.pt-BR.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.ru.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.tr.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.zh-Hans.xlf | 47 ++++++ .../xlf/CSharpAnalyzersResources.zh-Hant.xlf | 47 ++++++ .../CodeFixes/CSharpCodeFixes.projitems | 3 + .../CodeFixes/CSharpCodeFixesResources.resx | 123 +++++++++++++++ ...tchStatementToExpressionCodeFixProvider.cs | 7 +- ...MakeStructFieldsWritableCodeFixProvider.cs | 8 +- ...RemoveUnnecessaryImportsCodeFixProvider.cs | 8 +- .../UseExplicitTypeCodeFixProvider.cs | 10 +- .../UseImplicitTypeCodeFixProvider.cs | 10 +- .../xlf/CSharpCodeFixesResources.cs.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.de.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.es.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.fr.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.it.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.ja.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.ko.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.pl.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.pt-BR.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.ru.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.tr.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.zh-Hans.xlf | 12 ++ .../xlf/CSharpCodeFixesResources.zh-Hant.xlf | 12 ++ .../RemoveUnusedMembersTests.cs | 8 +- .../Core/Analyzers/Analyzers.projitems | 3 + .../Core/Analyzers/AnalyzersResources.resx | 138 +++++++++++++++++ ...ctRemoveUnusedMembersDiagnosticAnalyzer.cs | 17 +- .../Analyzers/xlf/AnalyzersResources.cs.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.de.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.es.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.fr.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.it.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.ja.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.ko.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.pl.xlf | 37 +++++ .../xlf/AnalyzersResources.pt-BR.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.ru.xlf | 37 +++++ .../Analyzers/xlf/AnalyzersResources.tr.xlf | 37 +++++ .../xlf/AnalyzersResources.zh-Hans.xlf | 37 +++++ .../xlf/AnalyzersResources.zh-Hant.xlf | 37 +++++ .../Core/CodeFixes/CodeFixes.projitems | 3 + .../Core/CodeFixes/CodeFixesResources.resx | 123 +++++++++++++++ ...tractRemoveUnusedMembersCodeFixProvider.cs | 8 +- .../CodeFixes/xlf/CodeFixesResources.cs.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.de.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.es.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.fr.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.it.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.ja.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.ko.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.pl.xlf | 12 ++ .../xlf/CodeFixesResources.pt-BR.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.ru.xlf | 12 ++ .../CodeFixes/xlf/CodeFixesResources.tr.xlf | 12 ++ .../xlf/CodeFixesResources.zh-Hans.xlf | 12 ++ .../xlf/CodeFixesResources.zh-Hant.xlf | 12 ++ ...oveUnnecessaryImportsDiagnosticAnalyzer.vb | 7 +- .../Analyzers/VisualBasicAnalyzers.projitems | 3 + .../VisualBasicAnalyzersResources.resx | 123 +++++++++++++++ .../xlf/VisualBasicAnalyzersResources.cs.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.de.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.es.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.fr.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.it.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.ja.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.ko.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.pl.xlf | 12 ++ .../VisualBasicAnalyzersResources.pt-BR.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.ru.xlf | 12 ++ .../xlf/VisualBasicAnalyzersResources.tr.xlf | 12 ++ .../VisualBasicAnalyzersResources.zh-Hans.xlf | 12 ++ .../VisualBasicAnalyzersResources.zh-Hant.xlf | 12 ++ ...RemoveUnnecessaryImportsCodeFixProvider.vb | 7 +- .../CodeFixes/VisualBasicCodeFixes.projitems | 3 + .../VisualBasicCodeFixesResources.resx | 123 +++++++++++++++ .../xlf/VisualBasicCodeFixesResources.cs.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.de.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.es.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.fr.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.it.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.ja.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.ko.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.pl.xlf | 12 ++ .../VisualBasicCodeFixesResources.pt-BR.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.ru.xlf | 12 ++ .../xlf/VisualBasicCodeFixesResources.tr.xlf | 12 ++ .../VisualBasicCodeFixesResources.zh-Hans.xlf | 12 ++ .../VisualBasicCodeFixesResources.zh-Hant.xlf | 12 ++ .../Analyzers/CSharpCodeStyleResources.resx | 44 ------ .../xlf/CSharpCodeStyleResources.cs.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.de.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.es.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.fr.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.it.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.ja.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.ko.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.pl.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.pt-BR.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.ru.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.tr.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.zh-Hans.xlf | 70 --------- .../xlf/CSharpCodeStyleResources.zh-Hant.xlf | 70 --------- .../CSharpCodeStyleFixesResources.resx | 11 +- .../xlf/CSharpCodeStyleFixesResources.cs.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.de.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.es.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.fr.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.it.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.ja.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.ko.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.pl.xlf | 18 +-- .../CSharpCodeStyleFixesResources.pt-BR.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.ru.xlf | 18 +-- .../xlf/CSharpCodeStyleFixesResources.tr.xlf | 18 +-- .../CSharpCodeStyleFixesResources.zh-Hans.xlf | 18 +-- .../CSharpCodeStyleFixesResources.zh-Hant.xlf | 18 +-- .../Analyzers/CodeStyleResources.Designer.cs | 127 --------------- .../Core/Analyzers/CodeStyleResources.resx | 42 ----- .../Analyzers/xlf/CodeStyleResources.cs.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.de.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.es.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.fr.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.it.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.ja.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.ko.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.pl.xlf | 70 --------- .../xlf/CodeStyleResources.pt-BR.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.ru.xlf | 70 --------- .../Analyzers/xlf/CodeStyleResources.tr.xlf | 70 --------- .../xlf/CodeStyleResources.zh-Hans.xlf | 70 --------- .../xlf/CodeStyleResources.zh-Hant.xlf | 70 --------- .../CodeFixes/CodeStyleFixesResources.resx | 3 - .../xlf/CodeStyleFixesResources.cs.xlf | 5 - .../xlf/CodeStyleFixesResources.de.xlf | 5 - .../xlf/CodeStyleFixesResources.es.xlf | 5 - .../xlf/CodeStyleFixesResources.fr.xlf | 5 - .../xlf/CodeStyleFixesResources.it.xlf | 5 - .../xlf/CodeStyleFixesResources.ja.xlf | 5 - .../xlf/CodeStyleFixesResources.ko.xlf | 5 - .../xlf/CodeStyleFixesResources.pl.xlf | 5 - .../xlf/CodeStyleFixesResources.pt-BR.xlf | 5 - .../xlf/CodeStyleFixesResources.ru.xlf | 5 - .../xlf/CodeStyleFixesResources.tr.xlf | 5 - .../xlf/CodeStyleFixesResources.zh-Hans.xlf | 5 - .../xlf/CodeStyleFixesResources.zh-Hant.xlf | 5 - .../Analyzers/VBCodeStyleResources.resx | 5 +- .../Analyzers/xlf/VBCodeStyleResources.cs.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.de.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.es.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.fr.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.it.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.ja.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.ko.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.pl.xlf | 8 +- .../xlf/VBCodeStyleResources.pt-BR.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.ru.xlf | 8 +- .../Analyzers/xlf/VBCodeStyleResources.tr.xlf | 8 +- .../xlf/VBCodeStyleResources.zh-Hans.xlf | 8 +- .../xlf/VBCodeStyleResources.zh-Hant.xlf | 8 +- .../CodeFixes/VBCodeStyleFixesResources.resx | 5 +- .../xlf/VBCodeStyleFixesResources.cs.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.de.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.es.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.fr.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.it.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.ja.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.ko.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.pl.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.pt-BR.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.ru.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.tr.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.zh-Hans.xlf | 8 +- .../xlf/VBCodeStyleFixesResources.zh-Hant.xlf | 8 +- .../Squiggles/ErrorSquiggleProducerTests.cs | 4 +- .../Squiggles/ErrorSquiggleProducerTests.vb | 2 +- .../CSharpFeaturesResources.Designer.cs | 72 --------- .../Portable/CSharpFeaturesResources.resx | 24 --- .../UseExplicitTypeCodeRefactoringProvider.cs | 2 +- .../UseImplicitTypeCodeRefactoringProvider.cs | 2 +- .../UseExplicitTypeForConstCodeFixProvider.cs | 2 +- .../xlf/CSharpFeaturesResources.cs.xlf | 40 ----- .../xlf/CSharpFeaturesResources.de.xlf | 40 ----- .../xlf/CSharpFeaturesResources.es.xlf | 40 ----- .../xlf/CSharpFeaturesResources.fr.xlf | 40 ----- .../xlf/CSharpFeaturesResources.it.xlf | 40 ----- .../xlf/CSharpFeaturesResources.ja.xlf | 40 ----- .../xlf/CSharpFeaturesResources.ko.xlf | 40 ----- .../xlf/CSharpFeaturesResources.pl.xlf | 40 ----- .../xlf/CSharpFeaturesResources.pt-BR.xlf | 40 ----- .../xlf/CSharpFeaturesResources.ru.xlf | 40 ----- .../xlf/CSharpFeaturesResources.tr.xlf | 40 ----- .../xlf/CSharpFeaturesResources.zh-Hans.xlf | 40 ----- .../xlf/CSharpFeaturesResources.zh-Hant.xlf | 40 ----- .../Portable/FeaturesResources.Designer.cs | 18 --- .../Core/Portable/FeaturesResources.resx | 7 - .../Portable/xlf/FeaturesResources.cs.xlf | 10 -- .../Portable/xlf/FeaturesResources.de.xlf | 10 -- .../Portable/xlf/FeaturesResources.es.xlf | 10 -- .../Portable/xlf/FeaturesResources.fr.xlf | 10 -- .../Portable/xlf/FeaturesResources.it.xlf | 10 -- .../Portable/xlf/FeaturesResources.ja.xlf | 10 -- .../Portable/xlf/FeaturesResources.ko.xlf | 10 -- .../Portable/xlf/FeaturesResources.pl.xlf | 10 -- .../Portable/xlf/FeaturesResources.pt-BR.xlf | 10 -- .../Portable/xlf/FeaturesResources.ru.xlf | 10 -- .../Portable/xlf/FeaturesResources.tr.xlf | 10 -- .../xlf/FeaturesResources.zh-Hans.xlf | 10 -- .../xlf/FeaturesResources.zh-Hant.xlf | 10 -- .../CodeActions/CodeActionsTests.cs | 4 +- .../Portable/VBFeaturesResources.resx | 6 - .../Portable/xlf/VBFeaturesResources.cs.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.de.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.es.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.fr.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.it.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.ja.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.ko.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.pl.xlf | 10 -- .../xlf/VBFeaturesResources.pt-BR.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.ru.xlf | 10 -- .../Portable/xlf/VBFeaturesResources.tr.xlf | 10 -- .../xlf/VBFeaturesResources.zh-Hans.xlf | 10 -- .../xlf/VBFeaturesResources.zh-Hant.xlf | 10 -- .../LiveShare/Test/PreviewCodeActionsTests.cs | 2 +- .../Test/RunCodeActionsHandlerTests.cs | 2 +- .../CSharpWorkspaceResources.Designer.cs | 63 -------- .../Portable/CSharpWorkspaceResources.resx | 22 --- .../xlf/CSharpWorkspaceResources.cs.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.de.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.es.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.fr.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.it.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.ja.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.ko.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.pl.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.pt-BR.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.ru.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.tr.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.zh-Hans.xlf | 35 ----- .../xlf/CSharpWorkspaceResources.zh-Hant.xlf | 35 ----- .../Portable/CodeStyle/CodeStyleOptions.cs | 23 ++- .../Core/Portable/WorkspacesResources.resx | 24 --- .../Portable/xlf/WorkspacesResources.cs.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.de.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.es.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.fr.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.it.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.ja.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.ko.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.pl.xlf | 40 ----- .../xlf/WorkspacesResources.pt-BR.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.ru.xlf | 40 ----- .../Portable/xlf/WorkspacesResources.tr.xlf | 40 ----- .../xlf/WorkspacesResources.zh-Hans.xlf | 40 ----- .../xlf/WorkspacesResources.zh-Hant.xlf | 40 ----- .../CSharp/CSharpCompilerExtensions.projitems | 3 + .../CSharpCompilerExtensionsResources.resx | 139 +++++++++++++++++ .../CodeStyle/CSharpCodeStyleOptions.cs | 20 +-- .../CSharpCompilerExtensionsResources.cs.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.de.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.es.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.fr.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.it.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.ja.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.ko.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.pl.xlf | 37 +++++ ...SharpCompilerExtensionsResources.pt-BR.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.ru.xlf | 37 +++++ .../CSharpCompilerExtensionsResources.tr.xlf | 37 +++++ ...arpCompilerExtensionsResources.zh-Hans.xlf | 37 +++++ ...arpCompilerExtensionsResources.zh-Hant.xlf | 37 +++++ .../Core/CompilerExtensions.projitems | 5 +- .../Core/CompilerExtensionsResources.resx | 144 +++++++++++++++++ .../xlf/CompilerExtensionsResources.cs.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.de.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.es.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.fr.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.it.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.ja.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.ko.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.pl.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.pt-BR.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.ru.xlf | 47 ++++++ .../xlf/CompilerExtensionsResources.tr.xlf | 47 ++++++ .../CompilerExtensionsResources.zh-Hans.xlf | 47 ++++++ .../CompilerExtensionsResources.zh-Hant.xlf | 47 ++++++ .../VisualBasicCompilerExtensions.projitems | 3 + ...isualBasicCompilerExtensionsResources.resx | 124 +++++++++++++++ ...ualBasicCompilerExtensionsResources.cs.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.de.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.es.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.fr.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.it.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.ja.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.ko.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.pl.xlf | 12 ++ ...BasicCompilerExtensionsResources.pt-BR.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.ru.xlf | 12 ++ ...ualBasicCompilerExtensionsResources.tr.xlf | 12 ++ ...sicCompilerExtensionsResources.zh-Hans.xlf | 12 ++ ...sicCompilerExtensionsResources.zh-Hant.xlf | 12 ++ .../CSharpWorkspaceExtensions.projitems | 3 + .../CSharpWorkspaceExtensionsResources.resx | 123 +++++++++++++++ .../CSharp/Extensions/SyntaxTreeExtensions.cs | 2 +- .../CSharpWorkspaceExtensionsResources.cs.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.de.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.es.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.fr.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.it.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.ja.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.ko.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.pl.xlf | 12 ++ ...harpWorkspaceExtensionsResources.pt-BR.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.ru.xlf | 12 ++ .../CSharpWorkspaceExtensionsResources.tr.xlf | 12 ++ ...rpWorkspaceExtensionsResources.zh-Hans.xlf | 12 ++ ...rpWorkspaceExtensionsResources.zh-Hant.xlf | 12 ++ .../Core/WorkspaceExtensions.projitems | 3 + .../Core/WorkspaceExtensionsResources.resx | 124 +++++++++++++++ .../xlf/WorkspaceExtensionsResources.cs.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.de.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.es.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.fr.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.it.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.ja.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.ko.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.pl.xlf | 12 ++ .../WorkspaceExtensionsResources.pt-BR.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.ru.xlf | 12 ++ .../xlf/WorkspaceExtensionsResources.tr.xlf | 12 ++ .../WorkspaceExtensionsResources.zh-Hans.xlf | 12 ++ .../WorkspaceExtensionsResources.zh-Hant.xlf | 12 ++ .../VisualBasicWorkspaceExtensions.projitems | 3 + ...sualBasicWorkspaceExtensionsResources.resx | 124 +++++++++++++++ ...alBasicWorkspaceExtensionsResources.cs.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.de.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.es.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.fr.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.it.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.ja.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.ko.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.pl.xlf | 12 ++ ...asicWorkspaceExtensionsResources.pt-BR.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.ru.xlf | 12 ++ ...alBasicWorkspaceExtensionsResources.tr.xlf | 12 ++ ...icWorkspaceExtensionsResources.zh-Hans.xlf | 12 ++ ...icWorkspaceExtensionsResources.zh-Hant.xlf | 12 ++ .../CodeStyle/VisualBasicCodeStyleOptions.vb | 4 +- 365 files changed, 5243 insertions(+), 4538 deletions(-) create mode 100644 src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf create mode 100644 src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.de.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.es.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.fr.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.it.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ja.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ko.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pl.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pt-BR.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ru.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.tr.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hans.xlf create mode 100644 src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hant.xlf create mode 100644 src/Analyzers/Core/Analyzers/AnalyzersResources.resx create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.cs.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf create mode 100644 src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf create mode 100644 src/Analyzers/Core/CodeFixes/CodeFixesResources.resx create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.cs.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.de.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.es.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.fr.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.it.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ja.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ko.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pl.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pt-BR.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ru.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.tr.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hans.xlf create mode 100644 src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hant.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzersResources.resx create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.cs.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.de.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.es.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.fr.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.it.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ja.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ko.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.pl.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.pt-BR.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ru.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.tr.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.zh-Hans.xlf create mode 100644 src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.zh-Hant.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixesResources.resx create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.cs.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.de.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.es.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.fr.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.it.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ja.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ko.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.pl.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.pt-BR.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ru.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.tr.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.zh-Hans.xlf create mode 100644 src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.zh-Hant.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensionsResources.resx create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.cs.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.de.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.es.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.fr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.it.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ja.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ko.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.pl.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.pt-BR.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ru.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.tr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.zh-Hans.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.zh-Hant.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensionsResources.resx create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.cs.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.de.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.es.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.fr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.it.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ja.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ko.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.pl.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.pt-BR.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ru.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.tr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.zh-Hans.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.zh-Hant.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensionsResources.resx create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.cs.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.de.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.es.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.fr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.it.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ja.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ko.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.pl.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.pt-BR.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ru.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.tr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.zh-Hans.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.zh-Hant.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensionsResources.resx create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.cs.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.de.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.es.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.fr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.it.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ja.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ko.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.pl.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.pt-BR.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ru.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.tr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.zh-Hans.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.zh-Hant.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensionsResources.resx create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.cs.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.de.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.es.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.fr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.it.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ja.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ko.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.pl.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.pt-BR.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ru.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.tr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.zh-Hans.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.zh-Hant.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensionsResources.resx create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.cs.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.de.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.es.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.fr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.it.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ja.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ko.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.pl.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.pt-BR.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ru.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.tr.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.zh-Hans.xlf create mode 100644 src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.zh-Hant.xlf diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems index c2a54ecb321d6..75cbcb90b5e1b 100644 --- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems @@ -19,4 +19,7 @@ + + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx new file mode 100644 index 0000000000000..7a3a5136e48e1 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Convert switch statement to expression + + + Use 'switch' expression + + + Use explicit type instead of 'var' + + + Use explicit type + + + use 'var' instead of explicit type + + + Use implicit type + + + Using directive is unnecessary. + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs index 62e1f2082c2d3..6479740ef837c 100644 --- a/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs @@ -12,11 +12,9 @@ #if CODE_STYLE using Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle; -using Resources = Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources; #else using Microsoft.CodeAnalysis.CSharp.CodeStyle; using Microsoft.CodeAnalysis.Options; -using Resources = Microsoft.CodeAnalysis.CSharp.CSharpFeaturesResources; #endif namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression @@ -30,8 +28,8 @@ public ConvertSwitchStatementToExpressionDiagnosticAnalyzer() : base(IDEDiagnosticIds.ConvertSwitchStatementToExpressionDiagnosticId, CSharpCodeStyleOptions.PreferSwitchExpression, LanguageNames.CSharp, - new LocalizableResourceString(nameof(Resources.Convert_switch_statement_to_expression), Resources.ResourceManager, typeof(Resources)), - new LocalizableResourceString(nameof(Resources.Use_switch_expression), Resources.ResourceManager, typeof(Resources))) + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Convert_switch_statement_to_expression), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)), + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Use_switch_expression), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources))) { } diff --git a/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs index 65a55d69cf820..c7f873fc7fc50 100644 --- a/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs @@ -10,19 +10,13 @@ namespace Microsoft.CodeAnalysis.CSharp.MakeStructFieldsWritable { -#if CODE_STYLE - using Resources = CSharpCodeStyleResources; -#else - using Resources = FeaturesResources; -#endif - [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpMakeStructFieldsWritableDiagnosticAnalyzer : AbstractCodeQualityDiagnosticAnalyzer { private static readonly DiagnosticDescriptor s_diagnosticDescriptor = CreateDescriptor( IDEDiagnosticIds.MakeStructFieldsWritable, - new LocalizableResourceString(nameof(Resources.Make_readonly_fields_writable), Resources.ResourceManager, typeof(Resources)), - new LocalizableResourceString(nameof(Resources.Make_readonly_fields_writable), Resources.ResourceManager, typeof(Resources)), + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Make_readonly_fields_writable), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)), + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Make_readonly_fields_writable), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)), isUnneccessary: false); public CSharpMakeStructFieldsWritableDiagnosticAnalyzer() diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs index 735b5090dc121..690f4bc1913d5 100644 --- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs @@ -17,18 +17,12 @@ namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports { -#if CODE_STYLE - using Resources = CSharpCodeStyleResources; -#else - using Resources = CSharpFeaturesResources; -#endif - [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer : AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer { private static readonly LocalizableString s_titleAndMessageFormat = - new LocalizableResourceString(nameof(Resources.Using_directive_is_unnecessary), Resources.ResourceManager, typeof(Resources)); + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Using_directive_is_unnecessary), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)); protected override LocalizableString GetTitleAndMessageFormatForClassificationIdDescriptor() => s_titleAndMessageFormat; diff --git a/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseExplicitTypeDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseExplicitTypeDiagnosticAnalyzer.cs index 4f12aba29de83..5a8016473b58e 100644 --- a/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseExplicitTypeDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseExplicitTypeDiagnosticAnalyzer.cs @@ -7,20 +7,14 @@ namespace Microsoft.CodeAnalysis.CSharp.Diagnostics.TypeStyle { -#if CODE_STYLE - using Resources = CSharpCodeStyleResources; -#else - using Resources = CSharpFeaturesResources; -#endif - [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpUseExplicitTypeDiagnosticAnalyzer : CSharpTypeStyleDiagnosticAnalyzerBase { private static readonly LocalizableString s_Title = - new LocalizableResourceString(nameof(Resources.Use_explicit_type), Resources.ResourceManager, typeof(Resources)); + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Use_explicit_type), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)); private static readonly LocalizableString s_Message = - new LocalizableResourceString(nameof(Resources.Use_explicit_type_instead_of_var), Resources.ResourceManager, typeof(Resources)); + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Use_explicit_type_instead_of_var), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)); protected override CSharpTypeStyleHelper Helper => CSharpUseExplicitTypeHelper.Instance; diff --git a/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseImplicitTypeDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseImplicitTypeDiagnosticAnalyzer.cs index 116e3fe034fbb..ddd863b4d86e5 100644 --- a/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseImplicitTypeDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/UseImplicitOrExplicitType/CSharpUseImplicitTypeDiagnosticAnalyzer.cs @@ -7,20 +7,14 @@ namespace Microsoft.CodeAnalysis.CSharp.Diagnostics.TypeStyle { -#if CODE_STYLE - using Resources = CSharpCodeStyleResources; -#else - using Resources = CSharpFeaturesResources; -#endif - [DiagnosticAnalyzer(LanguageNames.CSharp)] internal sealed class CSharpUseImplicitTypeDiagnosticAnalyzer : CSharpTypeStyleDiagnosticAnalyzerBase { private static readonly LocalizableString s_Title = - new LocalizableResourceString(nameof(Resources.Use_implicit_type), Resources.ResourceManager, typeof(Resources)); + new LocalizableResourceString(nameof(CSharpAnalyzersResources.Use_implicit_type), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)); private static readonly LocalizableString s_Message = - new LocalizableResourceString(nameof(Resources.use_var_instead_of_explicit_type), Resources.ResourceManager, typeof(Resources)); + new LocalizableResourceString(nameof(CSharpAnalyzersResources.use_var_instead_of_explicit_type), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)); protected override CSharpTypeStyleHelper Helper => CSharpUseImplicitTypeHelper.Instance; diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf new file mode 100644 index 0000000000000..41e4343826eef --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..1fa732976bc70 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..e86b6fd743550 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..91e381942a969 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..f8127025883aa --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..493c9858e58ea --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..0670bd07fdf91 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..313c3713ae648 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..b60b78635247a --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..51a6c4515b829 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..ab24c1f9d8194 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..a137e0031ea66 --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ 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 new file mode 100644 index 0000000000000..528244822866b --- /dev/null +++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf @@ -0,0 +1,47 @@ + + + + + + Convert switch statement to expression + Convert switch statement to expression + + + + Make readonly fields writable + Make readonly fields writable + {Locked="readonly"} "readonly" is C# keyword and should not be localized. + + + Use explicit type + Use explicit type + + + + Use explicit type instead of 'var' + Use explicit type instead of 'var' + + + + Use implicit type + Use implicit type + + + + Use 'switch' expression + Use 'switch' expression + + + + Using directive is unnecessary. + Using directive is unnecessary. + + + + use 'var' instead of explicit type + use 'var' instead of explicit type + + + + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index e9d02c35a3926..426f864366797 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -17,4 +17,7 @@ + + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx new file mode 100644 index 0000000000000..0fa3bc0af6cdf --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Remove Unnecessary Usings + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs index e715ec7aa6936..ce99a31c5e424 100644 --- a/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs @@ -23,11 +23,6 @@ namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression { using Constants = ConvertSwitchStatementToExpressionConstants; -#if CODE_STYLE - using Resources = CSharpCodeStyleFixesResources; -#else - using Resources = CSharpFeaturesResources; -#endif [ExportCodeFixProvider(LanguageNames.CSharp), Shared] internal sealed partial class ConvertSwitchStatementToExpressionCodeFixProvider : SyntaxEditorBasedCodeFixProvider @@ -102,7 +97,7 @@ protected override async Task FixAllAsync(Document document, ImmutableArray> createChangedDocument) - : base(Resources.Convert_switch_statement_to_expression, createChangedDocument) + : base(CSharpAnalyzersResources.Convert_switch_statement_to_expression, createChangedDocument) { } } diff --git a/src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs index caa560c344bb3..32e1d43f720b0 100644 --- a/src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableCodeFixProvider.cs @@ -17,12 +17,6 @@ namespace Microsoft.CodeAnalysis.CSharp.MakeStructFieldsWritable { -#if CODE_STYLE - using Resources = CSharpCodeStyleResources; -#else - using Resources = FeaturesResources; -#endif - [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.MakeStructFieldsWritable), Shared] internal class CSharpMakeStructFieldsWritableCodeFixProvider : SyntaxEditorBasedCodeFixProvider { @@ -81,7 +75,7 @@ protected override Task FixAllAsync( private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(Resources.Make_readonly_fields_writable, createChangedDocument) + : base(CSharpAnalyzersResources.Make_readonly_fields_writable, createChangedDocument) { } } diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs index df527c591973a..086959c98c7b5 100644 --- a/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsCodeFixProvider.cs @@ -8,12 +8,6 @@ namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports { -#if CODE_STYLE - using Resources = CSharpCodeStyleFixesResources; -#else - using Resources = CSharpFeaturesResources; -#endif - [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.RemoveUnnecessaryImports), Shared] [ExtensionOrder(After = PredefinedCodeFixProviderNames.AddMissingReference)] internal class CSharpRemoveUnnecessaryImportsCodeFixProvider : AbstractRemoveUnnecessaryImportsCodeFixProvider @@ -24,6 +18,6 @@ public CSharpRemoveUnnecessaryImportsCodeFixProvider() } protected override string GetTitle() - => Resources.Remove_Unnecessary_Usings; + => CSharpCodeFixesResources.Remove_Unnecessary_Usings; } } diff --git a/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs index c288c97db7ab7..de0bd69146452 100644 --- a/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs @@ -20,12 +20,6 @@ namespace Microsoft.CodeAnalysis.CSharp.TypeStyle { -#if CODE_STYLE - using Resources = CSharpCodeStyleResources; -#else - using Resources = CSharpFeaturesResources; -#endif - [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseExplicitType), Shared] internal class UseExplicitTypeCodeFixProvider : SyntaxEditorBasedCodeFixProvider { @@ -167,9 +161,9 @@ private static ExpressionSyntax GenerateTupleDeclaration(ITypeSymbol typeSymbol, private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(Resources.Use_explicit_type_instead_of_var, + : base(CSharpAnalyzersResources.Use_explicit_type_instead_of_var, createChangedDocument, - Resources.Use_explicit_type_instead_of_var) + CSharpAnalyzersResources.Use_explicit_type_instead_of_var) { } } diff --git a/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseImplicitTypeCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseImplicitTypeCodeFixProvider.cs index c0e3da2b2542a..68d0b39828e3d 100644 --- a/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseImplicitTypeCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseImplicitTypeCodeFixProvider.cs @@ -16,12 +16,6 @@ namespace Microsoft.CodeAnalysis.CSharp.TypeStyle { -#if CODE_STYLE - using Resources = CSharpCodeStyleResources; -#else - using Resources = CSharpFeaturesResources; -#endif - [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseImplicitType), Shared] internal class UseImplicitTypeCodeFixProvider : SyntaxEditorBasedCodeFixProvider { @@ -70,9 +64,9 @@ internal static void ReplaceTypeWithVar(SyntaxEditor editor, SyntaxNode node) private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(Resources.use_var_instead_of_explicit_type, + : base(CSharpAnalyzersResources.use_var_instead_of_explicit_type, createChangedDocument, - Resources.use_var_instead_of_explicit_type) + CSharpAnalyzersResources.use_var_instead_of_explicit_type) { } } diff --git a/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf new file mode 100644 index 0000000000000..83634e639a670 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..04a6b5b230d99 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.de.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..a497d47ea7999 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.es.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..e6ca85c182096 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..40223718d3388 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.it.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..371fbaad95807 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..0e536c63f1947 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..bbc685aaae351 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..94d6b21e2a368 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..0ca6a99e6fc4d --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..86a6aa1579fe4 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..b412e0b764e21 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ 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 new file mode 100644 index 0000000000000..91ebe54d92312 --- /dev/null +++ b/src/Analyzers/CSharp/CodeFixes/xlf/CSharpCodeFixesResources.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Usings + Remove Unnecessary Usings + + + + + \ No newline at end of file diff --git a/src/Analyzers/CSharp/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.cs b/src/Analyzers/CSharp/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.cs index 1eb7fff6064c8..02c38d24a9646 100644 --- a/src/Analyzers/CSharp/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.cs +++ b/src/Analyzers/CSharp/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.cs @@ -16,12 +16,6 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.RemoveUnusedMembers { -#if CODE_STYLE - using AnalyzerResources = CodeStyleResources; -#else - using AnalyzerResources = FeaturesResources; -#endif - public class RemoveUnusedMembersTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest { internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace) @@ -1102,7 +1096,7 @@ public void M() using var workspace = CreateWorkspaceFromOptions(source, testParameters); var diagnostics = await GetDiagnosticsAsync(workspace, testParameters).ConfigureAwait(false); diagnostics.Verify(Diagnostic("IDE0052", "P").WithLocation(3, 17)); - var expectedMessage = string.Format(AnalyzerResources.Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked, "MyClass.P"); + var expectedMessage = string.Format(AnalyzersResources.Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked, "MyClass.P"); Assert.Equal(expectedMessage, diagnostics.Single().GetMessage()); } diff --git a/src/Analyzers/Core/Analyzers/Analyzers.projitems b/src/Analyzers/Core/Analyzers/Analyzers.projitems index 13db44687fb4d..cdfe32e390e3d 100644 --- a/src/Analyzers/Core/Analyzers/Analyzers.projitems +++ b/src/Analyzers/Core/Analyzers/Analyzers.projitems @@ -23,4 +23,7 @@ + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/AnalyzersResources.resx b/src/Analyzers/Core/Analyzers/AnalyzersResources.resx new file mode 100644 index 0000000000000..006db427523aa --- /dev/null +++ b/src/Analyzers/Core/Analyzers/AnalyzersResources.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Private member '{0}' is unused. + + + Remove unused private members + + + Remove unread private members + + + Private member '{0}' can be removed as the value assigned to it is never read. + + + Private method '{0}' can be removed as it is never invoked. + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs index aef4b84c780f8..f972fc0498de3 100644 --- a/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs @@ -17,11 +17,6 @@ namespace Microsoft.CodeAnalysis.RemoveUnusedMembers { -#if CODE_STYLE - using Resources = CodeStyleResources; -#else - using Resources = FeaturesResources; -#endif internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer : AbstractCodeQualityDiagnosticAnalyzer @@ -31,15 +26,15 @@ internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf new file mode 100644 index 0000000000000..498d962bf5a16 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.de.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf new file mode 100644 index 0000000000000..410d344c3fabc --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.es.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf new file mode 100644 index 0000000000000..6e6ff02f36fc4 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.fr.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf new file mode 100644 index 0000000000000..7b63778518f78 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.it.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf new file mode 100644 index 0000000000000..a7372b064ff71 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ja.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf new file mode 100644 index 0000000000000..1cd95ca2ad1f5 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ko.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf new file mode 100644 index 0000000000000..3bcf3e59a4d1a --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pl.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf new file mode 100644 index 0000000000000..7a51052aedcf2 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.pt-BR.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf new file mode 100644 index 0000000000000..66c1ebc9c910b --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.ru.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf new file mode 100644 index 0000000000000..f79dd2881321c --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.tr.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf new file mode 100644 index 0000000000000..065c3fe73b297 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hans.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf new file mode 100644 index 0000000000000..ffb2c56a92fa6 --- /dev/null +++ b/src/Analyzers/Core/Analyzers/xlf/AnalyzersResources.zh-Hant.xlf @@ -0,0 +1,37 @@ + + + + + + Private member '{0}' can be removed as the value assigned to it is never read. + Private member '{0}' can be removed as the value assigned to it is never read. + + + + Private member '{0}' is unused. + Private member '{0}' is unused. + + + + Private method '{0}' can be removed as it is never invoked. + Private method '{0}' can be removed as it is never invoked. + + + + Private property '{0}' can be converted to a method as its get accessor is never invoked. + Private property '{0}' can be converted to a method as its get accessor is never invoked. + + + + Remove unread private members + Remove unread private members + + + + Remove unused private members + Remove unused private members + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems index d02ed2e62e0c6..f35655448b391 100644 --- a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems +++ b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems @@ -13,4 +13,7 @@ + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/CodeFixesResources.resx b/src/Analyzers/Core/CodeFixes/CodeFixesResources.resx new file mode 100644 index 0000000000000..6286bd89d8bda --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/CodeFixesResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Remove unused member + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs index 1494cc7355063..a89a61a4a4fb4 100644 --- a/src/Analyzers/Core/CodeFixes/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs +++ b/src/Analyzers/Core/CodeFixes/RemoveUnusedMembers/AbstractRemoveUnusedMembersCodeFixProvider.cs @@ -19,12 +19,6 @@ namespace Microsoft.CodeAnalysis.RemoveUnusedMembers { -#if CODE_STYLE - using Resources = CodeStyleFixesResources; -#else - using Resources = FeaturesResources; -#endif - internal abstract class AbstractRemoveUnusedMembersCodeFixProvider : SyntaxEditorBasedCodeFixProvider where TFieldDeclarationSyntax : SyntaxNode { @@ -132,7 +126,7 @@ protected static void AdjustAndAddAppropriateDeclaratorsToRemove(SyntaxNode pare private class MyCodeAction : CustomCodeActions.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(Resources.Remove_unused_member, createChangedDocument) + : base(CodeFixesResources.Remove_unused_member, createChangedDocument) { } } diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.cs.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.cs.xlf new file mode 100644 index 0000000000000..0aadbca67849d --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.de.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.de.xlf new file mode 100644 index 0000000000000..75df42ce49ffe --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.de.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.es.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.es.xlf new file mode 100644 index 0000000000000..591606cd23a71 --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.es.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.fr.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.fr.xlf new file mode 100644 index 0000000000000..1ad3e99f44ea2 --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.it.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.it.xlf new file mode 100644 index 0000000000000..c4dcd2abb708d --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.it.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ja.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ja.xlf new file mode 100644 index 0000000000000..a0073c0953ab4 --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ko.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ko.xlf new file mode 100644 index 0000000000000..a5a7a4cda4a89 --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pl.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pl.xlf new file mode 100644 index 0000000000000..6fff60f559211 --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pt-BR.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pt-BR.xlf new file mode 100644 index 0000000000000..624207c5b5e5f --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ru.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ru.xlf new file mode 100644 index 0000000000000..3422358616da9 --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.tr.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.tr.xlf new file mode 100644 index 0000000000000..e20e1000cd04a --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hans.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hans.xlf new file mode 100644 index 0000000000000..a10943cbb611f --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hant.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hant.xlf new file mode 100644 index 0000000000000..147cd90852095 --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Remove unused member + Remove unused member + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb b/src/Analyzers/VisualBasic/Analyzers/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb index c560e59ba54a1..b0cb99a0c513e 100644 --- a/src/Analyzers/VisualBasic/Analyzers/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb +++ b/src/Analyzers/VisualBasic/Analyzers/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb @@ -16,13 +16,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports Friend NotInheritable Class VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer Inherits AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer -#If CODE_STYLE Then Private Shared ReadOnly s_TitleAndMessageFormat As LocalizableString = - New LocalizableResourceString(NameOf(VBCodeStyleResources.Imports_statement_is_unnecessary), VBCodeStyleResources.ResourceManager, GetType(VBCodeStyleResources.VBCodeStyleResources)) -#Else - Private Shared ReadOnly s_TitleAndMessageFormat As LocalizableString = - New LocalizableResourceString(NameOf(VBFeaturesResources.Imports_statement_is_unnecessary), VBFeaturesResources.ResourceManager, GetType(VBFeaturesResources.VBFeaturesResources)) -#End If + New LocalizableResourceString(NameOf(VisualBasicAnalyzersResources.Imports_statement_is_unnecessary), VisualBasicAnalyzersResources.ResourceManager, GetType(VisualBasicAnalyzersResources)) Protected Overrides Function GetTitleAndMessageFormatForClassificationIdDescriptor() As LocalizableString Return s_TitleAndMessageFormat diff --git a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems index b923810b4c3f5..79bdb1bfc56f9 100644 --- a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems +++ b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzers.projitems @@ -12,4 +12,7 @@ + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzersResources.resx b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzersResources.resx new file mode 100644 index 0000000000000..6cf27cf64b08e --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/VisualBasicAnalyzersResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Imports statement is unnecessary. + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.cs.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.cs.xlf new file mode 100644 index 0000000000000..579abb858302d --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.de.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.de.xlf new file mode 100644 index 0000000000000..31120dfc6584d --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.de.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.es.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.es.xlf new file mode 100644 index 0000000000000..a911d3a74b874 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.es.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.fr.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.fr.xlf new file mode 100644 index 0000000000000..f3658e0106798 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.it.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.it.xlf new file mode 100644 index 0000000000000..bf12bd6fef681 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.it.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ja.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ja.xlf new file mode 100644 index 0000000000000..4b5f2770f970d --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ko.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ko.xlf new file mode 100644 index 0000000000000..bfe754350a3c2 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.pl.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.pl.xlf new file mode 100644 index 0000000000000..9eee58372b626 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.pt-BR.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.pt-BR.xlf new file mode 100644 index 0000000000000..1284298bed50b --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ru.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ru.xlf new file mode 100644 index 0000000000000..74cabc8569602 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.tr.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.tr.xlf new file mode 100644 index 0000000000000..5b1641f003ba4 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.zh-Hans.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.zh-Hans.xlf new file mode 100644 index 0000000000000..5a4f2857e3eae --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.zh-Hant.xlf b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.zh-Hant.xlf new file mode 100644 index 0000000000000..595dcb9968dd7 --- /dev/null +++ b/src/Analyzers/VisualBasic/Analyzers/xlf/VisualBasicAnalyzersResources.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Imports statement is unnecessary. + Imports statement is unnecessary. + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb b/src/Analyzers/VisualBasic/CodeFixes/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb index 770ee1a3c9c8f..e5aa91550bc86 100644 --- a/src/Analyzers/VisualBasic/CodeFixes/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb +++ b/src/Analyzers/VisualBasic/CodeFixes/RemoveUnnecessaryImports/VisualBasicRemoveUnnecessaryImportsCodeFixProvider.vb @@ -6,11 +6,6 @@ Imports System.Composition Imports Microsoft.CodeAnalysis.CodeFixes Imports Microsoft.CodeAnalysis.RemoveUnnecessaryImports -#If CODE_STYLE Then -Imports Resources = Microsoft.CodeAnalysis.VisualBasic.VBCodeStyleFixesResources -#Else -Imports Resources = Microsoft.CodeAnalysis.VisualBasic.VBFeaturesResources -#End If Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports @@ -23,7 +18,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryImports End Sub Protected Overrides Function GetTitle() As String - Return Resources.Remove_Unnecessary_Imports + Return VisualBasicCodeFixesResources.Remove_Unnecessary_Imports End Function End Class End Namespace diff --git a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems index 0b94d2e32e378..e700dab7a348d 100644 --- a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems +++ b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems @@ -12,4 +12,7 @@ + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixesResources.resx b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixesResources.resx new file mode 100644 index 0000000000000..09b97e6c440a9 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixesResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Remove Unnecessary Imports + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.cs.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.cs.xlf new file mode 100644 index 0000000000000..555342ffe1150 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.de.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.de.xlf new file mode 100644 index 0000000000000..a9d89d9445ab5 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.de.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.es.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.es.xlf new file mode 100644 index 0000000000000..dd2518cc469d9 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.es.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.fr.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.fr.xlf new file mode 100644 index 0000000000000..dedadf4d1f2ee --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.it.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.it.xlf new file mode 100644 index 0000000000000..e74df4226f7e4 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.it.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ja.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ja.xlf new file mode 100644 index 0000000000000..35076ab1c8898 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ko.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ko.xlf new file mode 100644 index 0000000000000..e74347336c0bc --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.pl.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.pl.xlf new file mode 100644 index 0000000000000..5e43bbedbe6c0 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.pt-BR.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.pt-BR.xlf new file mode 100644 index 0000000000000..2f1cd7930c0d0 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ru.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ru.xlf new file mode 100644 index 0000000000000..bc92945efc796 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.tr.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.tr.xlf new file mode 100644 index 0000000000000..0333553460761 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.zh-Hans.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.zh-Hans.xlf new file mode 100644 index 0000000000000..b3d956ab71d5c --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.zh-Hant.xlf b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.zh-Hant.xlf new file mode 100644 index 0000000000000..ddacccfc2a1e6 --- /dev/null +++ b/src/Analyzers/VisualBasic/CodeFixes/xlf/VisualBasicCodeFixesResources.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Remove Unnecessary Imports + Remove Unnecessary Imports + + + + + \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx index adce271f2998e..4ba473044c43d 100644 --- a/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx +++ b/src/CodeStyle/CSharp/Analyzers/CSharpCodeStyleResources.resx @@ -126,48 +126,4 @@ Wrapping preferences - - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Convert switch statement to expression - - - Use 'switch' expression - - - var preferences - - - Expression-bodied members - - - Pattern matching preferences - - - Null-checking preferences - - - Code-block preferences - - - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - Use explicit type instead of 'var' - - - Use explicit type - - - use 'var' instead of explicit type - - - Use implicit type - - - Using directive is unnecessary. - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf index 1dd1aa0d686ff..2d96a25c0d3c4 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.cs.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Předvolby odsazení - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Předvolby mezer - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Předvolby zalamování - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf index ddc3928ad77d2..0d83ba440a00e 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.de.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Einstellungen für Einrückung - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Einstellungen für Abstände - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Umbrucheinstellungen - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf index a77f56fac13c3..77af241413a49 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.es.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Preferencias de indentación - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Preferencias de espacio - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Preferencias de ajuste - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf index 3a6a1abff961d..8fa3b735f7686 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.fr.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Préférences de mise en retrait - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Préférences d'espace - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Préférences d'enveloppement - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf index 06149748f646b..27c12bd4e0b95 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.it.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Preferenze per rientro - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Preferenze per spazi - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Preferenze per ritorno a capo - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf index 93bea1d41a1b8..83fe539cd4cb7 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ja.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences インデント設定 - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences スペース設定 - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences 折り返しの設定 - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf index c756c86ffc03c..31c5055f766bf 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ko.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences 들여쓰기 기본 설정 - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences 공간 기본 설정 - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences 기본 설정 래핑 - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf index 235b6efa36ec2..a5b06c9301fa7 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pl.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Preferencje wcięć - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Preferencje dotyczące odstępów - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Preferencje zawijania - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf index ea27ed9b8823f..c5d3f65ea7a49 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.pt-BR.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Preferências de recuo - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Preferências de espaço - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Preferências de quebra de linha - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf index 4ac961c07aa49..2f8dba0638db7 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.ru.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Параметры отступов - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Предпочтения для интервалов - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Параметры переноса - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf index 5c15bd54660cb..494145da415f3 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.tr.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences Girinti tercihleri - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences Boşluk tercihleri - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences Kaydırma tercihleri - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf index a5af9ca82ff29..1a9702dd40ad3 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hans.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences 缩进首选项 - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences 空格键首选项 - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences 包装首选项 - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf index d0d5c0baf696f..0135365fa24e6 100644 --- a/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/Analyzers/xlf/CSharpCodeStyleResources.zh-Hant.xlf @@ -2,91 +2,21 @@ - - Code-block preferences - Code-block preferences - - - - Convert switch statement to expression - Convert switch statement to expression - - - - Expression-bodied members - Expression-bodied members - - Indentation preferences 縮排喜好設定 - - Make readonly fields writable - Make readonly fields writable - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - - - Null-checking preferences - Null-checking preferences - - - - Pattern matching preferences - Pattern matching preferences - - Space preferences 空格喜好設定 - - Use explicit type - Use explicit type - - - - Use explicit type instead of 'var' - Use explicit type instead of 'var' - - - - Use implicit type - Use implicit type - - - - Use 'switch' expression - Use 'switch' expression - - - - Using directive is unnecessary. - Using directive is unnecessary. - - Wrapping preferences 換行喜好設定 - - use 'var' instead of explicit type - use 'var' instead of explicit type - - - - 'using' directive preferences - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var preferences - - \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx index 4b15d2f16aaca..14ed010cf9ebb 100644 --- a/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx +++ b/src/CodeStyle/CSharp/CodeFixes/CSharpCodeStyleFixesResources.resx @@ -117,13 +117,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Expected string or char literal - - - Convert switch statement to expression - - - Remove Unnecessary Usings + + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 \ No newline at end of file diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf index d60c8540e33b3..09e16175e8135 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.cs.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf index d54196863535d..036233e7dfffe 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.de.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf index 483426fabc919..39997e977d2e9 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.es.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf index 7748c47bf284f..d1d9ec1ca4fdc 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.fr.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf index 30ac5a27a6cbe..0a605965058a1 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.it.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf index 161be734f1648..0f32c9e649e41 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ja.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf index afdcabb083eb1..bf8710ae41ec4 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ko.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf index c318b9ed41033..00099a3217091 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pl.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf index 54efc6d5cd1e0..4749986bfc9c8 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.pt-BR.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf index b4bace98e454f..f11932234113a 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.ru.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf index c17204fad4a61..0e444a4ea7587 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.tr.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf index fb3063a29be3e..dde51a473e211 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hans.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf index 33ed83489f19c..d80ad5734d427 100644 --- a/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/CSharp/CodeFixes/xlf/CSharpCodeStyleFixesResources.zh-Hant.xlf @@ -2,20 +2,10 @@ - - Convert switch statement to expression - Convert switch statement to expression - - - - Expected string or char literal - Expected string or char literal - - - - Remove Unnecessary Usings - Remove Unnecessary Usings - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs b/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs index 4cc76a750348a..de4afea35844f 100644 --- a/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs +++ b/src/CodeStyle/Core/Analyzers/CodeStyleResources.Designer.cs @@ -132,24 +132,6 @@ internal static string Error { } } - /// - /// Looks up a localized string similar to Expression-level preferences. - /// - internal static string Expression_level_preferences { - get { - return ResourceManager.GetString("Expression_level_preferences", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Field preferences. - /// - internal static string Field_preferences { - get { - return ResourceManager.GetString("Field_preferences", resourceCulture); - } - } - /// /// Looks up a localized string similar to Fix formatting. /// @@ -168,24 +150,6 @@ internal static string Indentation_and_spacing { } } - /// - /// Looks up a localized string similar to Language keywords vs BCL types preferences. - /// - internal static string Language_keywords_vs_BCL_types_preferences { - get { - return ResourceManager.GetString("Language_keywords_vs_BCL_types_preferences", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Modifier preferences. - /// - internal static string Modifier_preferences { - get { - return ResourceManager.GetString("Modifier_preferences", resourceCulture); - } - } - /// /// Looks up a localized string similar to New line preferences. /// @@ -204,70 +168,6 @@ internal static string None { } } - /// - /// Looks up a localized string similar to Organize usings. - /// - internal static string Organize_usings { - get { - return ResourceManager.GetString("Organize_usings", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter preferences. - /// - internal static string Parameter_preferences { - get { - return ResourceManager.GetString("Parameter_preferences", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parentheses preferences. - /// - internal static string Parentheses_preferences { - get { - return ResourceManager.GetString("Parentheses_preferences", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Private member '{0}' can be removed as the value assigned to it is never read.. - /// - internal static string Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read { - get { - return ResourceManager.GetString("Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Private member '{0}' is unused.. - /// - internal static string Private_member_0_is_unused { - get { - return ResourceManager.GetString("Private_member_0_is_unused", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Private method '{0}' can be removed as it is never invoked.. - /// - internal static string Private_method_0_can_be_removed_as_it_is_never_invoked { - get { - return ResourceManager.GetString("Private_method_0_can_be_removed_as_it_is_never_invoked", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Private property '{0}' can be converted to a method as its get accessor is never invoked.. - /// - internal static string Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invoked { - get { - return ResourceManager.GetString("Private_property_0_can_be_converted_to_a_method_as_its_get_accessor_is_never_invo" + - "ked", resourceCulture); - } - } - /// /// Looks up a localized string similar to Refactoring Only. /// @@ -277,24 +177,6 @@ internal static string Refactoring_Only { } } - /// - /// Looks up a localized string similar to Remove unread private members. - /// - internal static string Remove_unread_private_members { - get { - return ResourceManager.GetString("Remove_unread_private_members", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove unused private members. - /// - internal static string Remove_unused_private_members { - get { - return ResourceManager.GetString("Remove_unused_private_members", resourceCulture); - } - } - /// /// Looks up a localized string similar to Stream is too long.. /// @@ -322,15 +204,6 @@ internal static string The_type_0_is_not_understood_by_the_serialization_binder } } - /// - /// Looks up a localized string similar to this. and Me. preferences. - /// - internal static string this_dot_and_Me_dot_preferences { - get { - return ResourceManager.GetString("this_dot_and_Me_dot_preferences", resourceCulture); - } - } - /// /// Looks up a localized string similar to Value too large to be represented as a 30 bit unsigned integer.. /// diff --git a/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx b/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx index 649d85e945b46..c36f70d6fe47c 100644 --- a/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx +++ b/src/CodeStyle/Core/Analyzers/CodeStyleResources.resx @@ -171,46 +171,4 @@ An element with the same key but a different value already exists. - - Private member '{0}' is unused. - - - Remove unused private members - - - Remove unread private members - - - Private member '{0}' can be removed as the value assigned to it is never read. - - - Private method '{0}' can be removed as it is never invoked. - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - - Organize usings - - - this. and Me. preferences - - - Language keywords vs BCL types preferences - - - Parentheses preferences - - - Modifier preferences - - - Expression-level preferences - - - Field preferences - - - Parameter preferences - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf index 0de8394ab1ee9..e3de211f8a7ce 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.cs.xlf @@ -42,16 +42,6 @@ Chyba - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Opravit formátování @@ -62,16 +52,6 @@ Odsazení a mezery - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Předvolby nových řádků @@ -82,56 +62,11 @@ žádné - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Pouze refaktoring - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Upozornění - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf index 163026e34feeb..aadf8cede01b4 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.de.xlf @@ -42,16 +42,6 @@ Fehler - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Formatierung korrigieren @@ -62,16 +52,6 @@ Einzüge und Abstände - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Einstellungen für neue Zeilen @@ -82,56 +62,11 @@ NONE - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Nur Refactoring - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Warnung - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf index 4c78a77841195..3be3f19e7c529 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.es.xlf @@ -42,16 +42,6 @@ Error - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Fijar formato @@ -62,16 +52,6 @@ Sangría y espaciado - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Nuevas preferencias de línea @@ -82,56 +62,11 @@ NONE - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Solo refactorización - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Advertencia - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf index ca55f21d41982..a80e605768d6f 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.fr.xlf @@ -42,16 +42,6 @@ Erreur - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Corriger la mise en forme @@ -62,16 +52,6 @@ Indentation et espacement - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Préférences de nouvelle ligne @@ -82,56 +62,11 @@ Aucun(e) - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Refactoring Only - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Avertissement - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf index 4468c2a5dba46..4317dca9e54b6 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.it.xlf @@ -42,16 +42,6 @@ Errore - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Correggi formattazione @@ -62,16 +52,6 @@ Rientro e spaziatura - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Preferenze per nuova riga @@ -82,56 +62,11 @@ Nessuno - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Refactoring Only - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Avviso - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf index 587dee50933f1..3287b09f74c8f 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ja.xlf @@ -42,16 +42,6 @@ エラー - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting 書式設定を修正 @@ -62,16 +52,6 @@ インデントと間隔 - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences 改行設定 @@ -82,56 +62,11 @@ なし - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only リファクタリングのみ - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ 警告 - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf index b5b6d2627be6c..9d866d09abc5b 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ko.xlf @@ -42,16 +42,6 @@ 오류 - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting 서식 수정 @@ -62,16 +52,6 @@ 들여쓰기 및 간격 - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences 새 줄 기본 설정 @@ -82,56 +62,11 @@ None - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only 리팩터링만 - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ 경고 - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf index 63be3252e2682..28f7c64a5b185 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pl.xlf @@ -42,16 +42,6 @@ Błąd - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Napraw formatowanie @@ -62,16 +52,6 @@ Wcięcia i odstępy - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Preferencje nowego wiersza @@ -82,56 +62,11 @@ brak - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Tylko refaktoryzacja - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Ostrzeżenie - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf index a966ec205f654..1ebd657ef6487 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.pt-BR.xlf @@ -42,16 +42,6 @@ Erro - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Corrigir a formatação @@ -62,16 +52,6 @@ Recuo e espaçamento - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Preferências de nova linha @@ -82,56 +62,11 @@ NENHUM - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Somente Refatoração - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Aviso - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf index 01f01fa48e427..3b3d2601d84d5 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.ru.xlf @@ -42,16 +42,6 @@ Ошибка - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Исправить форматирование @@ -62,16 +52,6 @@ Отступы и интервалы - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Предпочтения для новых строк @@ -82,56 +62,11 @@ NONE - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Только рефакторинг - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Предупреждение - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf index df0e5e54a1491..1a7db9d99eac8 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.tr.xlf @@ -42,16 +42,6 @@ Hata - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting Biçimlendirme Düzeltme @@ -62,16 +52,6 @@ Girinti ve aralığı - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences Yeni satır tercihleri @@ -82,56 +62,11 @@ yok - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only Sadece Yeniden Düzenlenme - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ Uyarı - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf index 316ad22ea7ce4..9faacee3c97f8 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hans.xlf @@ -42,16 +42,6 @@ 错误 - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting 修正格式 @@ -62,16 +52,6 @@ 缩进和间距 - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences 新行首选项 @@ -82,56 +62,11 @@ - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only 仅重构 - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ 警告 - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf index 2799448296a9d..c58eee81f20cc 100644 --- a/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/Core/Analyzers/xlf/CodeStyleResources.zh-Hant.xlf @@ -42,16 +42,6 @@ 錯誤 - - Expression-level preferences - Expression-level preferences - - - - Field preferences - Field preferences - - Fix formatting 修正格式化 @@ -62,16 +52,6 @@ 縮排和間距 - - Language keywords vs BCL types preferences - Language keywords vs BCL types preferences - - - - Modifier preferences - Modifier preferences - - New line preferences 新行喜好設定 @@ -82,56 +62,11 @@ - - Organize usings - Organize usings - - - - Parameter preferences - Parameter preferences - - - - Parentheses preferences - Parentheses preferences - - - - Private member '{0}' can be removed as the value assigned to it is never read. - Private member '{0}' can be removed as the value assigned to it is never read. - - - - Private member '{0}' is unused. - Private member '{0}' is unused. - - - - Private method '{0}' can be removed as it is never invoked. - Private method '{0}' can be removed as it is never invoked. - - - - Private property '{0}' can be converted to a method as its get accessor is never invoked. - Private property '{0}' can be converted to a method as its get accessor is never invoked. - - Refactoring Only 僅重構 - - Remove unread private members - Remove unread private members - - - - Remove unused private members - Remove unused private members - - Stream is too long. Stream is too long. @@ -157,11 +92,6 @@ 警告 - - this. and Me. preferences - this. and Me. preferences - - \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx index 80cb905c80e9f..c0e7a15f35fd8 100644 --- a/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx +++ b/src/CodeStyle/Core/CodeFixes/CodeStyleFixesResources.resx @@ -141,7 +141,4 @@ The solution does not contain the specified document. - - Remove unused member - \ No newline at end of file diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf index 42b2bacd4e483..df1e3449a6eae 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.cs.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf index bfe83940ce775..a54bae1cacfdc 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.de.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf index 48d118d1ad0b8..8468ce78e62a8 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.es.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf index fc0682064dd6b..a7f64f2308311 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.fr.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf index 7ea81ca778b26..54410937dfdc1 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.it.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf index 618ac9b7edd34..6cbc6ebeb485f 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ja.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf index 7a2ee21e14c60..61a16c798bea4 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ko.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf index 6fc6960ddd30f..92b372ee9d9d0 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pl.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf index d994d6517cb59..fe151b79a0588 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.pt-BR.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf index def04413ca791..822f99568a1be 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.ru.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf index fa919eb7a0c6a..0218922387e70 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.tr.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf index 7a195f93239ec..b9847f95eb635 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hans.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf index 2608915859b8a..63c5119ae6ff7 100644 --- a/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/Core/CodeFixes/xlf/CodeStyleFixesResources.zh-Hant.xlf @@ -27,11 +27,6 @@ Project of ID {0} is required to accomplish the task but is not available from the solution - - Remove unused member - Remove unused member - - Supplied diagnostic cannot be null. Supplied diagnostic cannot be null. diff --git a/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.resx b/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.resx index 6cf27cf64b08e..14ed010cf9ebb 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.resx +++ b/src/CodeStyle/VisualBasic/Analyzers/VBCodeStyleResources.resx @@ -117,7 +117,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Imports statement is unnecessary. + + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.cs.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.cs.xlf index 5c4b765c76edd..822ec68aebddb 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.cs.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.cs.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.de.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.de.xlf index 5e3f30fd7dd0e..db97f6a1e53a3 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.de.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.de.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.es.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.es.xlf index 8452dfb5ceebc..64164183f7dfd 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.es.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.es.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.fr.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.fr.xlf index 2092f75405f52..7234bc34e7d1d 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.fr.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.fr.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.it.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.it.xlf index 8413dac4f68c4..10516fc35a164 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.it.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.it.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ja.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ja.xlf index 7d8ebfd485210..bdbe1fcc774ee 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ja.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ja.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ko.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ko.xlf index 4bb8b082bca49..bef266e0aa2ba 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ko.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ko.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pl.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pl.xlf index e20b77257637b..5f0deec4c6512 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pl.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pl.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pt-BR.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pt-BR.xlf index 7221d04a19013..dac32ba01c3b6 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pt-BR.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.pt-BR.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ru.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ru.xlf index ebefc0529157e..33ee0dc7f4bea 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ru.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.ru.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.tr.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.tr.xlf index 62474fc2a3de6..defa7d7f4eb4d 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.tr.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.tr.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hans.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hans.xlf index b7f1e373e4526..4e8d2b4227b60 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hans.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hans.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hant.xlf b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hant.xlf index 034cb1eb82968..150e603a9666f 100644 --- a/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hant.xlf +++ b/src/CodeStyle/VisualBasic/Analyzers/xlf/VBCodeStyleResources.zh-Hant.xlf @@ -2,10 +2,10 @@ - - Imports statement is unnecessary. - Imports statement is unnecessary. - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.resx b/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.resx index 09b97e6c440a9..14ed010cf9ebb 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.resx +++ b/src/CodeStyle/VisualBasic/CodeFixes/VBCodeStyleFixesResources.resx @@ -117,7 +117,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Remove Unnecessary Imports + + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 \ No newline at end of file diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.cs.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.cs.xlf index 36730eb2d92ec..5126048b1e908 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.cs.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.cs.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.de.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.de.xlf index 0bf74ab33dca9..a5dd43d52897e 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.de.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.de.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.es.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.es.xlf index 7bbc3bb25e3bf..0eb315ebc378d 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.es.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.es.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.fr.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.fr.xlf index 32d23dde4d55e..0b2654babf4fa 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.fr.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.fr.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.it.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.it.xlf index d04beb6ac4478..7d5951426a8ab 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.it.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.it.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ja.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ja.xlf index 90debbdd41c91..348b7b15e88a5 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ja.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ja.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ko.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ko.xlf index abebe69b2c0d4..70e9c838cbe17 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ko.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ko.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pl.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pl.xlf index 76e9ca3bace1f..0b400e8888ee3 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pl.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pl.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pt-BR.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pt-BR.xlf index 41ed1293e8c4f..8affd0e0238d0 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pt-BR.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.pt-BR.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ru.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ru.xlf index 5a7fba30554a0..aa098a45afb68 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ru.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.ru.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.tr.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.tr.xlf index ff699e88c7db0..3185f715acba0 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.tr.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.tr.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hans.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hans.xlf index 9bc01636485dc..39b97d777e54c 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hans.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hans.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hant.xlf b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hant.xlf index f0b8bfbfd9203..f23c770be485e 100644 --- a/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hant.xlf +++ b/src/CodeStyle/VisualBasic/CodeFixes/xlf/VBCodeStyleFixesResources.zh-Hant.xlf @@ -2,10 +2,10 @@ - - Remove Unnecessary Imports - Remove Unnecessary Imports - + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 diff --git a/src/EditorFeatures/CSharpTest/Squiggles/ErrorSquiggleProducerTests.cs b/src/EditorFeatures/CSharpTest/Squiggles/ErrorSquiggleProducerTests.cs index 17edddd17cb58..69c821beb3337 100644 --- a/src/EditorFeatures/CSharpTest/Squiggles/ErrorSquiggleProducerTests.cs +++ b/src/EditorFeatures/CSharpTest/Squiggles/ErrorSquiggleProducerTests.cs @@ -134,12 +134,12 @@ void Test() var third = spans[2]; Assert.Equal(PredefinedErrorTypeNames.Suggestion, first.Tag.ErrorType); - Assert.Equal(CSharpFeaturesResources.Using_directive_is_unnecessary, first.Tag.ToolTipContent); + Assert.Equal(CSharpAnalyzersResources.Using_directive_is_unnecessary, first.Tag.ToolTipContent); Assert.Equal(40, first.Span.Start); Assert.Equal(25, first.Span.Length); Assert.Equal(PredefinedErrorTypeNames.Suggestion, second.Tag.ErrorType); - Assert.Equal(CSharpFeaturesResources.Using_directive_is_unnecessary, second.Tag.ToolTipContent); + Assert.Equal(CSharpAnalyzersResources.Using_directive_is_unnecessary, second.Tag.ToolTipContent); Assert.Equal(82, second.Span.Start); Assert.Equal(60, second.Span.Length); diff --git a/src/EditorFeatures/VisualBasicTest/Squiggles/ErrorSquiggleProducerTests.vb b/src/EditorFeatures/VisualBasicTest/Squiggles/ErrorSquiggleProducerTests.vb index 3ab2421034551..62e6e4fb02153 100644 --- a/src/EditorFeatures/VisualBasicTest/Squiggles/ErrorSquiggleProducerTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Squiggles/ErrorSquiggleProducerTests.vb @@ -118,7 +118,7 @@ End Class" Dim second = spans(1) Assert.Equal(PredefinedErrorTypeNames.Suggestion, first.Tag.ErrorType) - Assert.Equal(VBFeaturesResources.Imports_statement_is_unnecessary, CType(first.Tag.ToolTipContent, String)) + Assert.Equal(VisualBasicAnalyzersResources.Imports_statement_is_unnecessary, CType(first.Tag.ToolTipContent, String)) Assert.Equal(Of Integer)(79, first.Span.Start) Assert.Equal(83, first.Span.Length) diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs b/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs index c6dd0853355c9..bd269d2aa0fab 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs @@ -448,15 +448,6 @@ internal static string conversion_operator { } } - /// - /// Looks up a localized string similar to Convert switch statement to expression. - /// - internal static string Convert_switch_statement_to_expression { - get { - return ResourceManager.GetString("Convert_switch_statement_to_expression", resourceCulture); - } - } - /// /// Looks up a localized string similar to Convert to 'for'. /// @@ -1105,15 +1096,6 @@ internal static string Remove_unnecessary_casts { } } - /// - /// Looks up a localized string similar to Remove Unnecessary Usings. - /// - internal static string Remove_Unnecessary_Usings { - get { - return ResourceManager.GetString("Remove_Unnecessary_Usings", resourceCulture); - } - } - /// /// Looks up a localized string similar to Remove unused function. /// @@ -1440,33 +1422,6 @@ internal static string Use_0 { } } - /// - /// Looks up a localized string similar to Use explicit type. - /// - internal static string Use_explicit_type { - get { - return ResourceManager.GetString("Use_explicit_type", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use explicit type instead of 'var'. - /// - internal static string Use_explicit_type_instead_of_var { - get { - return ResourceManager.GetString("Use_explicit_type_instead_of_var", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use implicit type. - /// - internal static string Use_implicit_type { - get { - return ResourceManager.GetString("Use_implicit_type", resourceCulture); - } - } - /// /// Looks up a localized string similar to Use 'is null' check. /// @@ -1476,24 +1431,6 @@ internal static string Use_is_null_check { } } - /// - /// Looks up a localized string similar to Use 'switch' expression. - /// - internal static string Use_switch_expression { - get { - return ResourceManager.GetString("Use_switch_expression", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to use 'var' instead of explicit type. - /// - internal static string use_var_instead_of_explicit_type { - get { - return ResourceManager.GetString("use_var_instead_of_explicit_type", resourceCulture); - } - } - /// /// Looks up a localized string similar to using declaration. /// @@ -1512,15 +1449,6 @@ internal static string using_directive { } } - /// - /// Looks up a localized string similar to Using directive is unnecessary.. - /// - internal static string Using_directive_is_unnecessary { - get { - return ResourceManager.GetString("Using_directive_is_unnecessary", resourceCulture); - } - } - /// /// Looks up a localized string similar to Using directives must be placed inside of a namespace declaration. /// diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx index 7a4ddbdd52562..c9339b6528a7f 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx @@ -138,9 +138,6 @@ Simplify all occurrences - - Remove Unnecessary Usings - <lambda expression> @@ -279,9 +276,6 @@ TODO: uncomment the following line if the finalizer is overridden above. - - Using directive is unnecessary. - try block {Locked="try"} "try" is a C# keyword and should not be localized. @@ -466,18 +460,6 @@ Properties - - Use explicit type instead of 'var' - - - Use explicit type - - - use 'var' instead of explicit type - - - Use implicit type - Autoselect disabled due to namespace declaration. @@ -613,12 +595,6 @@ Make 'ref struct' {Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized. - - Convert switch statement to expression - - - Use 'switch' expression - Misplaced using directive {Locked="using"} "using" is a C# keyword and should not be localized. diff --git a/src/Features/CSharp/Portable/CodeRefactorings/UseExplicitOrImplicitType/UseExplicitTypeCodeRefactoringProvider.cs b/src/Features/CSharp/Portable/CodeRefactorings/UseExplicitOrImplicitType/UseExplicitTypeCodeRefactoringProvider.cs index 18a1c84012bbd..3d1059db0b19b 100644 --- a/src/Features/CSharp/Portable/CodeRefactorings/UseExplicitOrImplicitType/UseExplicitTypeCodeRefactoringProvider.cs +++ b/src/Features/CSharp/Portable/CodeRefactorings/UseExplicitOrImplicitType/UseExplicitTypeCodeRefactoringProvider.cs @@ -24,7 +24,7 @@ public UseExplicitTypeCodeRefactoringProvider() } protected override string Title - => CSharpFeaturesResources.Use_explicit_type; + => CSharpAnalyzersResources.Use_explicit_type; protected override TypeSyntax FindAnalyzableType(SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken) => CSharpUseExplicitTypeHelper.Instance.FindAnalyzableType(node, semanticModel, cancellationToken); diff --git a/src/Features/CSharp/Portable/CodeRefactorings/UseExplicitOrImplicitType/UseImplicitTypeCodeRefactoringProvider.cs b/src/Features/CSharp/Portable/CodeRefactorings/UseExplicitOrImplicitType/UseImplicitTypeCodeRefactoringProvider.cs index 2d802360bfe02..f38f6458e01ab 100644 --- a/src/Features/CSharp/Portable/CodeRefactorings/UseExplicitOrImplicitType/UseImplicitTypeCodeRefactoringProvider.cs +++ b/src/Features/CSharp/Portable/CodeRefactorings/UseExplicitOrImplicitType/UseImplicitTypeCodeRefactoringProvider.cs @@ -24,7 +24,7 @@ public UseImplicitTypeCodeRefactoringProvider() } protected override string Title - => CSharpFeaturesResources.Use_implicit_type; + => CSharpAnalyzersResources.Use_implicit_type; protected override TypeSyntax FindAnalyzableType(SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken) => CSharpUseImplicitTypeHelper.Instance.FindAnalyzableType(node, semanticModel, cancellationToken); diff --git a/src/Features/CSharp/Portable/UseExplicitTypeForConst/UseExplicitTypeForConstCodeFixProvider.cs b/src/Features/CSharp/Portable/UseExplicitTypeForConst/UseExplicitTypeForConstCodeFixProvider.cs index 395b945108028..49ac97bdbc9ff 100644 --- a/src/Features/CSharp/Portable/UseExplicitTypeForConst/UseExplicitTypeForConstCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/UseExplicitTypeForConst/UseExplicitTypeForConstCodeFixProvider.cs @@ -67,7 +67,7 @@ private static async Task FixAsync( private sealed class MyCodeAction : CodeAction.DocumentChangeAction { public MyCodeAction(Func> createChangedDocument) - : base(CSharpFeaturesResources.Use_explicit_type_instead_of_var, + : base(CSharpAnalyzersResources.Use_explicit_type_instead_of_var, createChangedDocument) { } diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf index 2c4b780198b3b..1f54020787319 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf @@ -72,11 +72,6 @@ Přiřadit parametry out (při spuštění) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Převést příkaz switch na výraz - - Convert to method Převést na metodu @@ -152,11 +147,6 @@ Zjednodušit všechny výskyty - - Remove Unnecessary Usings - Odebrat nepotřebné direktivy using - - Sort accessibility modifiers Seřadit modifikátory dostupnosti @@ -167,11 +157,6 @@ Rozpečetit třídu {0} - - Use 'switch' expression - Použít výraz switch - - Warning: Inlining temporary into conditional method call. Upozornění: dočasné vkládání do volání podmíněné metody. @@ -432,11 +417,6 @@ TODO: Zrušte komentář následujícího řádku, pokud se výše přepisuje finalizační metoda. - - Using directive is unnecessary. - Direktiva Using není potřebná. - - switch statement příkaz switch @@ -677,26 +657,6 @@ Vlastnosti - - Use explicit type instead of 'var' - Použít explicitní typ místo var - - - - Use explicit type - Použít explicitní typ - - - - use 'var' instead of explicit type - Použít var místo explicitního typu - - - - Use implicit type - Použít implicitní typ - - Autoselect disabled due to namespace declaration. Automatický výběr je zakázaný kvůli deklaraci oboru názvů. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf index 8de0e269ca438..b3e1707332c38 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf @@ -72,11 +72,6 @@ out-Parameter zuweisen (beim Start) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Switch-Anweisung in Ausdruck konvertieren - - Convert to method In Methode konvertieren @@ -152,11 +147,6 @@ Alle Vorkommen vereinfachen - - Remove Unnecessary Usings - Nicht benötigte Using-Direktiven entfernen - - Sort accessibility modifiers Zugriffsmodifizierer sortieren @@ -167,11 +157,6 @@ Versiegelung der Klasse "{0}" aufheben - - Use 'switch' expression - Switch-Ausdruck verwenden - - Warning: Inlining temporary into conditional method call. Warnung: temporäres Inlining in bedingtem Methodenaufruf. @@ -432,11 +417,6 @@ TODO: Auskommentierung der folgenden Zeile aufheben, wenn der Finalizer weiter oben überschrieben wird. - - Using directive is unnecessary. - Using-Direktive ist unnötig. - - switch statement switch-Anweisung @@ -677,26 +657,6 @@ Eigenschaften - - Use explicit type instead of 'var' - Expliziten Typ anstelle von "var" verwenden - - - - Use explicit type - Expliziten Typ verwenden - - - - use 'var' instead of explicit type - "var" anstelle des expliziten Typs verwenden - - - - Use implicit type - Impliziten Typ verwenden - - Autoselect disabled due to namespace declaration. Die automatische Auswahl ist aufgrund der Namespacedeklaration deaktiviert. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf index 184fc09570595..fd17bea704b12 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf @@ -72,11 +72,6 @@ Asignar parámetros "out" (al inicio) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Convertir una instrucción switch en expresión - - Convert to method Convertir al método @@ -152,11 +147,6 @@ Simplificar todas las repeticiones - - Remove Unnecessary Usings - Eliminar instrucciones Using innecesarias - - Sort accessibility modifiers Ordenar modificadores de accesibilidad @@ -167,11 +157,6 @@ Quitar el sello de la clase "{0}" - - Use 'switch' expression - Usar la expresión "switch" - - Warning: Inlining temporary into conditional method call. Advertencia: Inserción de una llamada temporal en otra de método condicional. @@ -432,11 +417,6 @@ TODO: quite la marca de comentario de la siguiente línea si el finalizador se ha reemplazado antes. - - Using directive is unnecessary. - El uso de la directiva no es necesario. - - switch statement instrucción switch @@ -677,26 +657,6 @@ Propiedades - - Use explicit type instead of 'var' - Usar un tipo explícito en lugar de 'var' - - - - Use explicit type - Usar un tipo explícito - - - - use 'var' instead of explicit type - Usar 'var' en lugar de un tipo explícito - - - - Use implicit type - Usar un tipo implícito - - Autoselect disabled due to namespace declaration. Se ha deshabilitado la selección automática durante la declaración del espacio de nombres. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf index 35d37e2a05e0e..68c90454345ef 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf @@ -72,11 +72,6 @@ Assigner des paramètres 'out' (au début) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Convertir l'instruction switch en expression - - Convert to method Convertir en méthode @@ -152,11 +147,6 @@ Simplifier toutes les occurrences - - Remove Unnecessary Usings - Supprimer les Usings inutiles - - Sort accessibility modifiers Trier les modificateurs d'accessibilité @@ -167,11 +157,6 @@ Classe unsealed '{0}' - - Use 'switch' expression - Utiliser l'expression 'switch' - - Warning: Inlining temporary into conditional method call. Avertissement : Inlining temporaire dans un appel de méthode conditionnel. @@ -432,11 +417,6 @@ TODO: supprimer les marques de commentaire pour la ligne suivante si le finaliseur est remplacé ci-dessus. - - Using directive is unnecessary. - La directive using n'est pas nécessaire. - - switch statement instruction switch @@ -677,26 +657,6 @@ Propriétés - - Use explicit type instead of 'var' - Utiliser un type explicite au lieu de 'var' - - - - Use explicit type - Utiliser un type explicite - - - - use 'var' instead of explicit type - utiliser 'var' au lieu d'un type explicite - - - - Use implicit type - Utiliser un type implicite - - Autoselect disabled due to namespace declaration. Sélection automatique désactivée en raison d'une déclaration d'espace de noms. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf index 4eebac0efbcef..74a33080553fe 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf @@ -72,11 +72,6 @@ Assegnare parametri 'out' (all'inizio) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Converti l'istruzione switch in espressione - - Convert to method Converti in metodo @@ -152,11 +147,6 @@ Semplifica tutte le occorrenze - - Remove Unnecessary Usings - Rimuovi istruzioni using non necessarie - - Sort accessibility modifiers Ordina i modificatori di accessibilità @@ -167,11 +157,6 @@ Rimuovi seal dalla classe '{0}' - - Use 'switch' expression - Usa l'espressione 'switch' - - Warning: Inlining temporary into conditional method call. Avviso: incorporamento dell'elemento temporaneo nella chiamata a un metodo condizionale. @@ -432,11 +417,6 @@ TODO: rimuovere il commento dalla riga seguente se è stato eseguito l'override del finalizzatore. - - Using directive is unnecessary. - La direttiva using non è necessaria. - - switch statement istruzione switch @@ -677,26 +657,6 @@ Proprietà - - Use explicit type instead of 'var' - Usa il tipo esplicito invece di 'var' - - - - Use explicit type - Usa il tipo esplicito - - - - use 'var' instead of explicit type - usa 'var' invece del tipo esplicito - - - - Use implicit type - Usa il tipo implicito - - Autoselect disabled due to namespace declaration. La selezione automatica è disabilitata a causa della dichiarazione dello spazio dei nomi. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf index b87d0c0f0a002..73a7fcc7581bc 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf @@ -72,11 +72,6 @@ 'out' パラメーターの割り当て (開始時) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - switch ステートメントを式に変換します - - Convert to method メソッドに変換 @@ -152,11 +147,6 @@ すべての出現箇所を簡素化します - - Remove Unnecessary Usings - 不要な using の削除 - - Sort accessibility modifiers アクセシビリティ修飾子を並べ替える @@ -167,11 +157,6 @@ クラス '{0}' のシールを解除 - - Use 'switch' expression - 'switch' 式を使用します - - Warning: Inlining temporary into conditional method call. 警告: 一時メソッド呼び出しを条件付きメソッド呼び出しにインライン展開しています。 @@ -432,11 +417,6 @@ TODO: 上のファイナライザーがオーバーライドされる場合は、次の行のコメントを解除してください。 - - Using directive is unnecessary. - Using ディレクティブは必要ありません。 - - switch statement switch ステートメント @@ -677,26 +657,6 @@ プロパティ - - Use explicit type instead of 'var' - var' ではなく明示的な型を使用します - - - - Use explicit type - 明示的な型の使用 - - - - use 'var' instead of explicit type - 明示的な型ではなく 'var' を使用します - - - - Use implicit type - 暗黙的な型の使用 - - Autoselect disabled due to namespace declaration. 名前空間宣言により、Autoselect は無効です。 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf index f2786fb05eacd..1feebc3bcf9c1 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf @@ -72,11 +72,6 @@ 'out' 매개 변수 할당(시작 시) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - switch 문을 식으로 변환 - - Convert to method 메서드로 변환 @@ -152,11 +147,6 @@ 모든 항목 단순화 - - Remove Unnecessary Usings - 불필요한 Using 제거 - - Sort accessibility modifiers 접근성 한정자 정렬 @@ -167,11 +157,6 @@ '{0}' 클래스 봉인 해제 - - Use 'switch' expression - 'switch' 식 사용 - - Warning: Inlining temporary into conditional method call. 경고: 임시 작업을 조건부 메서드 호출로 인라인 처리합니다. @@ -432,11 +417,6 @@ TODO: 위의 종료자가 재정의된 경우 다음 코드 줄의 주석 처리를 제거합니다. - - Using directive is unnecessary. - Using 지시문은 필요하지 않습니다. - - switch statement switch 문 @@ -677,26 +657,6 @@ 속성 - - Use explicit type instead of 'var' - var' 대신에 명시적 형식을 사용합니다. - - - - Use explicit type - 명시적 형식 사용 - - - - use 'var' instead of explicit type - 대신 명시적 형식의 'var'을 사용합니다. - - - - Use implicit type - 암시적 형식 사용 - - Autoselect disabled due to namespace declaration. 네임스페이스 선언으로 인해 자동 선택을 사용할 수 없습니다. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf index a8600ac7a6021..667594f592367 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf @@ -72,11 +72,6 @@ Przypisz parametry „out” (na początku) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Konwertuj instrukcję switch na wyrażenie - - Convert to method Konwertuj na metodę @@ -152,11 +147,6 @@ Uprość wszystkie wystąpienia - - Remove Unnecessary Usings - Usuń niepotrzebne użycia - - Sort accessibility modifiers Sortuj modyfikatory dostępności @@ -167,11 +157,6 @@ Odpieczętuj klasę „{0}” - - Use 'switch' expression - Użyj wyrażenia „switch” - - Warning: Inlining temporary into conditional method call. Ostrzeżenie: tymczasowe wbudowywanie do wywołania metody warunkowej. @@ -432,11 +417,6 @@ TODO: Usunąć komentarz z poniższego wiersza, jeśli finalizator został przesłonięty powyżej. - - Using directive is unnecessary. - Dyrektywa using jest niepotrzebna. - - switch statement instrukcja switch @@ -677,26 +657,6 @@ Właściwości - - Use explicit type instead of 'var' - Użyj jawnego typu zamiast deklaracji „var” - - - - Use explicit type - Użyj jawnego typu - - - - use 'var' instead of explicit type - użyj deklaracji „var” zamiast jawnego typu - - - - Use implicit type - Użyj niejawnego typu - - Autoselect disabled due to namespace declaration. Automatyczne zaznaczanie zostało wyłączone z powodu deklaracji przestrzeni nazw. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf index 1dd4fdd0681f3..00cb6453b9269 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf @@ -72,11 +72,6 @@ Atribuir parâmetros 'out' (no início) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Converter a instrução switch em expressão - - Convert to method Converter em método @@ -152,11 +147,6 @@ Simplificar todas as ocorrências - - Remove Unnecessary Usings - Remover Usos Desnecessários - - Sort accessibility modifiers Classificar modificadores de acessibilidade @@ -167,11 +157,6 @@ Desselar a classe '{0}' - - Use 'switch' expression - Usar a expressão 'switch' - - Warning: Inlining temporary into conditional method call. Aviso: embutindo a chamada de método temporária na condicional. @@ -432,11 +417,6 @@ TODO: remover marca de comentário da linha a seguir se o finalizador for substituído acima. - - Using directive is unnecessary. - O uso da diretiva é desnecessário. - - switch statement instrução switch @@ -677,26 +657,6 @@ Propriedades - - Use explicit type instead of 'var' - Usar o tipo explícito em vez de 'var' - - - - Use explicit type - Usar o tipo explícito - - - - use 'var' instead of explicit type - usar 'var' em vez do tipo explícito - - - - Use implicit type - Usar o tipo implícito - - Autoselect disabled due to namespace declaration. Seleção automática desabilitada devido à declaração de namespace. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf index d1ef86ae9dd04..06f89a7ce6536 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf @@ -72,11 +72,6 @@ Присвоение значений параметров "out" (при запуске) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Преобразовать оператор switch в выражение - - Convert to method Преобразовать в метод @@ -152,11 +147,6 @@ Упростить все вхождения - - Remove Unnecessary Usings - Удалить ненужные директивы using - - Sort accessibility modifiers Сортировать модификаторы доступности @@ -167,11 +157,6 @@ Распечатать класс "{0}" - - Use 'switch' expression - Использовать выражение switch - - Warning: Inlining temporary into conditional method call. Предупреждение: встраивание временных элементов в условный вызов метода. @@ -432,11 +417,6 @@ TODO: раскомментировать следующую строку, если метод завершения переопределен выше. - - Using directive is unnecessary. - Директива using не нужна. - - switch statement оператор switch @@ -677,26 +657,6 @@ Свойства - - Use explicit type instead of 'var' - Использовать явный тип вместо var - - - - Use explicit type - Использование явного типа - - - - use 'var' instead of explicit type - Использовать var вместо явного типа - - - - Use implicit type - Использование неявного типа - - Autoselect disabled due to namespace declaration. Автовыбор отключен из-за объявления пространства имен. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf index 4ef34a3ce8af4..52e8f23df9e31 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf @@ -72,11 +72,6 @@ 'out' parametreleri ata (başlangıçta) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - Switch deyimini ifadeye dönüştür - - Convert to method Yönteme dönüştür @@ -152,11 +147,6 @@ Tüm yinelemeleri basitleştir - - Remove Unnecessary Usings - Gereksiz Kullanımları Kaldır - - Sort accessibility modifiers Erişilebilirlik değiştiricilerini sırala @@ -167,11 +157,6 @@ '{0}' sınıfının mührünü aç - - Use 'switch' expression - 'Switch' ifadesini kullan - - Warning: Inlining temporary into conditional method call. Uyarı: Koşullu yöntem çağrısında geçici öğe satır içinde kullanılıyor. @@ -432,11 +417,6 @@ TODO: sonlandırıcı yukarıda geçersiz kılınırsa aşağıdaki satırın açıklamasını kaldırın. - - Using directive is unnecessary. - Using yönergesi gerekli değildir. - - switch statement switch deyimi @@ -677,26 +657,6 @@ Özellikler - - Use explicit type instead of 'var' - Var' yerine açık tür kullan - - - - Use explicit type - Açık tür kullanma - - - - use 'var' instead of explicit type - açık tür yerine 'var' kullan - - - - Use implicit type - Örtük tür kullanma - - Autoselect disabled due to namespace declaration. Ad alanı bildirimi nedeniyle otomatik seçme devre dışı bırakıldı. diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf index b3e4fdea70675..d765263d14d13 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf @@ -72,11 +72,6 @@ 分配 "out" (在开始处) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - 将 switch 语句转换为表达式 - - Convert to method 转换为方法 @@ -152,11 +147,6 @@ 简化所有事件 - - Remove Unnecessary Usings - 删除不必要的 Using - - Sort accessibility modifiers 对可访问性修饰符排序 @@ -167,11 +157,6 @@ Unseal 类 "{0}" - - Use 'switch' expression - 使用 "switch" 表达式 - - Warning: Inlining temporary into conditional method call. 警告: 即将在条件方法调用中内联临时内容。 @@ -432,11 +417,6 @@ TODO: 如果在以上内容中替代了终结器,则取消注释以下行。 - - Using directive is unnecessary. - Using 指令是不需要的。 - - switch statement switch 语句 @@ -677,26 +657,6 @@ 属性 - - Use explicit type instead of 'var' - 用显式类型代替 "var" - - - - Use explicit type - 使用显式类型 - - - - use 'var' instead of explicit type - 用 "var" 代替显式类型 - - - - Use implicit type - 使用隐式类型 - - Autoselect disabled due to namespace declaration. 自动选择由于命名空间声明而被禁用。 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf index 92f07214fa73e..2f89d97cf058c 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf @@ -72,11 +72,6 @@ 指派 'out' 參數 (開始時) {Locked="out"} "out" is a C# keyword and should not be localized. - - Convert switch statement to expression - 將 switch 陳述式轉換為運算式 - - Convert to method 轉換為方法 @@ -152,11 +147,6 @@ 簡化所有項目 - - Remove Unnecessary Usings - 移除不必要的 Using - - Sort accessibility modifiers 排序協助工具修飾元 @@ -167,11 +157,6 @@ 為類別 '{0}' 解密 - - Use 'switch' expression - 使用 'switch' 運算式 - - Warning: Inlining temporary into conditional method call. 警告: 內嵌臨時加入條件式方法呼叫。 @@ -432,11 +417,6 @@ TODO: 如果上方的完成項已被覆寫,即取消下行的註解狀態。 - - Using directive is unnecessary. - 無須使用指示詞。 - - switch statement switch 陳述式 @@ -677,26 +657,6 @@ 屬性 - - Use explicit type instead of 'var' - 使用明確類型,而非 'var' - - - - Use explicit type - 使用明確類型 - - - - use 'var' instead of explicit type - 使用 'var',而非明確類型 - - - - Use implicit type - 使用隱含類型 - - Autoselect disabled due to namespace declaration. 由於命名空間宣告,所以停用自動選取。 diff --git a/src/Features/Core/Portable/FeaturesResources.Designer.cs b/src/Features/Core/Portable/FeaturesResources.Designer.cs index 4e4f24ee065c7..e31578a974b59 100644 --- a/src/Features/Core/Portable/FeaturesResources.Designer.cs +++ b/src/Features/Core/Portable/FeaturesResources.Designer.cs @@ -2588,15 +2588,6 @@ internal static string Make_method_synchronous { } } - /// - /// Looks up a localized string similar to Make readonly fields writable. - /// - internal static string Make_readonly_fields_writable { - get { - return ResourceManager.GetString("Make_readonly_fields_writable", resourceCulture); - } - } - /// /// Looks up a localized string similar to Member name can be simplified. /// @@ -3435,15 +3426,6 @@ internal static string Remove_unread_private_members { } } - /// - /// Looks up a localized string similar to Remove unused member. - /// - internal static string Remove_unused_member { - get { - return ResourceManager.GetString("Remove_unused_member", resourceCulture); - } - } - /// /// Looks up a localized string similar to Remove unused parameter. /// diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 02aea7add61d9..4ba4b2719fb7c 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -1388,9 +1388,6 @@ This version used in: {2} Adding a method with an explicit interface specifier will prevent the debug session from continuing. - - Remove unused member - Private member '{0}' is unused. @@ -1622,10 +1619,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... diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index 65a7c3f0bda05..844ec594369a3 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -362,11 +362,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 @@ -497,11 +492,6 @@ Odebrat nepřečtené soukromé členy - - Remove unused member - Odebrat nepoužitý člen - - Remove unused parameter Odebrat nepoužívaný parametr diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 5ea0a6af4bea7..46108b69658ec 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -362,11 +362,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 @@ -497,11 +492,6 @@ Ungelesene private Member entfernen - - Remove unused member - Nicht verwendete Member entfernen - - Remove unused parameter Nicht verwendete Parameter entfernen diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index 3fe0e62d3ee86..e8174688cacb2 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -362,11 +362,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 @@ -497,11 +492,6 @@ Quitar miembros privados no leídos - - Remove unused member - Quitar miembros sin usar - - Remove unused parameter Quitar el parámetro no utilizado diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 0ed8c9a36cfaa..4bfcf322ecff1 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -362,11 +362,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 @@ -497,11 +492,6 @@ Supprimer les membres privés non lus - - Remove unused member - Supprimer les membres non utilisés - - Remove unused parameter Supprimer le paramètre inutilisé diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index 59604fa2a42f3..f8071f515cdd9 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -362,11 +362,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 @@ -497,11 +492,6 @@ Rimuovi i membri privati non letti - - Remove unused member - Rimuovi il membro inutilizzato - - Remove unused parameter Rimuovere il parametro inutilizzato diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index ff8d036230be3..0c4bffd6f6424 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -362,11 +362,6 @@ 静的にする - - Make readonly fields writable - readonly フィールドを書き込み可能にします - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional 条件を反転します @@ -497,11 +492,6 @@ 読み取られていないプライベート メンバーを削除 - - Remove unused member - 未使用のメンバーを削除 - - Remove unused parameter 未使用のパラメーターを削除します diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 026b0aef40405..72a5ea9a7698f 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -362,11 +362,6 @@ 정적으로 만들기 - - Make readonly fields writable - readonly 필드를 쓰기 가능으로 지정 - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional 조건 반전 @@ -497,11 +492,6 @@ 읽지 않은 private 멤버 제거 - - Remove unused member - 사용되지 않은 멤버 제거 - - Remove unused parameter 사용하지 않는 매개 변수를 제거하세요. diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 35f8531753f11..0ee0a6b40382f 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -362,11 +362,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 @@ -497,11 +492,6 @@ Usuń nieodczytywane składowe prywatne - - Remove unused member - Usuń nieużywaną składową - - Remove unused parameter Usuń nieużywany parametr diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 1a29a17fb5f69..3063d9cf6ec6e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -362,11 +362,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 @@ -497,11 +492,6 @@ Remover membros particulares não lidos - - Remove unused member - Remover membro não utilizado - - Remove unused parameter Remover o parâmetro não utilizado diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 79a4ea6ad38c3..a63960a7b79d9 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -362,11 +362,6 @@ Сделать статическим - - Make readonly fields writable - Сделать поля readonly доступными для записи - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional Инвертировать условный оператор @@ -497,11 +492,6 @@ Удалить непрочитанные закрытые члены - - Remove unused member - Удалить неиспользуемый член - - Remove unused parameter Удалите неиспользуемый параметр diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index d9cae62a3498a..1e37cc10be9b0 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -362,11 +362,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 @@ -497,11 +492,6 @@ Okunmamış özel üyeleri kaldır - - Remove unused member - Kullanılmayan üye kaldırma - - Remove unused parameter Kullanılmayan parametreyi kaldırma diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 3c25405931f16..c150c0cf5f81c 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -362,11 +362,6 @@ 设为静态 - - Make readonly fields writable - 使 readonly 字段可写 - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional 反转条件 @@ -497,11 +492,6 @@ 删除未读的私有成员 - - Remove unused member - 删除未使用的成员 - - Remove unused parameter 删除未使用的参数 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index 9c4a041412e80..06aff5b43591a 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -362,11 +362,6 @@ 使其變成靜態 - - Make readonly fields writable - 將 readonly 欄位設為可寫入 - {Locked="readonly"} "readonly" is C# keyword and should not be localized. - Invert conditional 反轉條件 @@ -497,11 +492,6 @@ 刪除未讀取的私用成員 - - Remove unused member - 移除未使用的成員 - - Remove unused parameter 移除未使用的參數 diff --git a/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs index a77ecb7284b48..fb380bb92e6d4 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs @@ -27,11 +27,11 @@ void M() } }"; var (solution, locations) = CreateTestSolution(markup); - var expected = CreateCommand(CSharpFeaturesResources.Use_implicit_type, locations["caret"].Single()); + var expected = CreateCommand(CSharpAnalyzersResources.Use_implicit_type, locations["caret"].Single()); var clientCapabilities = CreateClientCapabilitiesWithExperimentalValue("supportsWorkspaceEdits", JToken.FromObject(false)); var results = await RunGetCodeActionsAsync(solution, locations["caret"].Single(), clientCapabilities); - var useImplicitTypeResult = results.Single(r => r.Title == CSharpFeaturesResources.Use_implicit_type); + var useImplicitTypeResult = results.Single(r => r.Title == CSharpAnalyzersResources.Use_implicit_type); AssertJsonEquals(expected, useImplicitTypeResult); } diff --git a/src/Features/VisualBasic/Portable/VBFeaturesResources.resx b/src/Features/VisualBasic/Portable/VBFeaturesResources.resx index ebc1ffe031536..02b6ccc1e4026 100644 --- a/src/Features/VisualBasic/Portable/VBFeaturesResources.resx +++ b/src/Features/VisualBasic/Portable/VBFeaturesResources.resx @@ -153,9 +153,6 @@ Delete the '{0}' statement. - - Remove Unnecessary Imports - Type a name here to declare a new field. @@ -1012,9 +1009,6 @@ Sub(<parameterList>) <statement> TODO: uncomment the following line if Finalize() is overridden above. - - Imports statement is unnecessary. - Try block {Locked="Try"} "Try" is a VB keyword and should not be localized. diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.cs.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.cs.xlf index 0d3273f25546f..c5b7721070a3a 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.cs.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.cs.xlf @@ -92,11 +92,6 @@ <Víc typů> - - Remove Unnecessary Imports - Odebrat nepotřebné importy - - Type a name here to declare a new field. Sem vložte název, kterým deklarujete novou položku. @@ -1537,11 +1532,6 @@ Sub(<seznam_parametrů>) <výraz> TODO: Zrušte komentář následujícího řádku, pokud se výše přepisuje metoda Finalize(). - - Imports statement is unnecessary. - Příkaz Imports není potřebný. - - Try block Blok Try diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.de.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.de.xlf index dfdac24f1df19..510d245a5f235 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.de.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.de.xlf @@ -92,11 +92,6 @@ <Mehrere Typen> - - Remove Unnecessary Imports - Unnötige Import-Direktiven entfernen - - Type a name here to declare a new field. Geben Sie hier einen Namen ein, um ein neues Feld zu deklarieren. @@ -1537,11 +1532,6 @@ Sub(<Parameterliste>) <Ausdruck> TODO: Auskommentierung der folgenden Zeile aufheben, wenn Finalize() oben überschrieben wird. - - Imports statement is unnecessary. - Imports-Anweisung ist unnötig. - - Try block Try-Block diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.es.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.es.xlf index c9306403e79ff..fe8a1f17b2990 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.es.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.es.xlf @@ -92,11 +92,6 @@ <Varios tipos> - - Remove Unnecessary Imports - Quitar instrucciones Import innecesarias - - Type a name here to declare a new field. Escriba aquí un nombre para declarar un nuevo campo. @@ -1537,11 +1532,6 @@ Sub(<listaDeParámetros>) <instrucción> TODO: quite la marca de comentario de la siguiente línea si Finalize() se ha reemplazado antes. - - Imports statement is unnecessary. - La declaración de importaciones no es necesaria. - - Try block Bloque Try diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.fr.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.fr.xlf index 318181f1cd2e5..c5ce2100a3041 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.fr.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.fr.xlf @@ -92,11 +92,6 @@ <Plusieurs types> - - Remove Unnecessary Imports - Supprimer les importations superflues - - Type a name here to declare a new field. Tapez un nom ici pour déclarer un nouveau champ. @@ -1537,11 +1532,6 @@ Sub(<parameterList>) <statement> TODO: supprimer les marques de commentaire pour la ligne suivante si Finalize() est remplacé ci-dessus. - - Imports statement is unnecessary. - L'instruction Imports n'est pas utile. - - Try block Bloc Try diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.it.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.it.xlf index 040601d324035..be83e1bffdafd 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.it.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.it.xlf @@ -92,11 +92,6 @@ <Più tipi> - - Remove Unnecessary Imports - Rimuovi Import non necessari - - Type a name here to declare a new field. Digitare qui un nome per dichiarare un nuovo campo. @@ -1537,11 +1532,6 @@ Sub(<elencoParametri>) <istruzione> TODO: rimuovere il commento dalla riga seguente se è stato eseguito l'override di Finalize(). - - Imports statement is unnecessary. - L'istruzione Imports non è necessaria. - - Try block blocco Try diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ja.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ja.xlf index f97023cf54191..0910e7d0119aa 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ja.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ja.xlf @@ -92,11 +92,6 @@ <複数の種類> - - Remove Unnecessary Imports - 不要なインポートの削除 - - Type a name here to declare a new field. 新しいフィールドを宣言するには、ここに名前を入力します。 @@ -1537,11 +1532,6 @@ Sub(<parameterList>) <statement> TODO: 上の Finalize() がオーバーライドされている場合は、次の行のコメントを解除してください。 - - Imports statement is unnecessary. - Imports ステートメントは不要です。 - - Try block Try ブロック diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ko.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ko.xlf index f524bcbdd78a7..5da8aa9a7781a 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ko.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ko.xlf @@ -92,11 +92,6 @@ <여러 형식> - - Remove Unnecessary Imports - 불필요한 Imports 제거 - - Type a name here to declare a new field. 여기에 이름을 입력하여 새 필드를 선언하세요. @@ -1537,11 +1532,6 @@ Sub(<parameterList>) <statement> TODO: 위의 Finalize()가 재정의된 경우 다음 줄의 주석 처리를 제거합니다. - - Imports statement is unnecessary. - Imports 문은 필요하지 않습니다. - - Try block Try 블록 diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pl.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pl.xlf index 9427095f507a8..5c439500b1290 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pl.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pl.xlf @@ -92,11 +92,6 @@ <Wiele typów> - - Remove Unnecessary Imports - Usuń niepotrzebne importy - - Type a name here to declare a new field. Wpisz tutaj nazwę, aby utworzyć deklarację nowego pola. @@ -1537,11 +1532,6 @@ Sub(<listaParametrów>) <instrukcja> TODO: usuń komentarz z poniższego wiersza, jeśli powyższa metoda Finalize() została przesłonięta. - - Imports statement is unnecessary. - Instrukcja imports jest niepotrzebna. - - Try block Blok Try diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pt-BR.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pt-BR.xlf index 3f2074de04761..edf910539cce3 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pt-BR.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.pt-BR.xlf @@ -92,11 +92,6 @@ <Vários Tipos> - - Remove Unnecessary Imports - Remover Importações Desnecessárias - - Type a name here to declare a new field. Digite um nome aqui para declarar um novo campo. @@ -1537,11 +1532,6 @@ Sub(<parameterList>) <statement> TODO: remover marca de comentário da linha a seguir se Finalize() for substituído acima. - - Imports statement is unnecessary. - A instrução Imports é desnecessária. - - Try block Bloco Try diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ru.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ru.xlf index 1f85c8c78fa25..2ddb6090fa2d2 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ru.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.ru.xlf @@ -92,11 +92,6 @@ <Несколько типов> - - Remove Unnecessary Imports - Удалить ненужные импорты - - Type a name here to declare a new field. Введите здесь имя для объявления нового поля. @@ -1537,11 +1532,6 @@ Sub(<parameterList>) <statement> TODO: раскомментировать следующую строку, если Finalize() переопределен выше. - - Imports statement is unnecessary. - Оператор Imports не нужен. - - Try block Блок Try diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.tr.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.tr.xlf index 9d0ca347d7f9b..b66b5d9e82d55 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.tr.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.tr.xlf @@ -92,11 +92,6 @@ <Multiple Types> - - Remove Unnecessary Imports - Gereksiz İçeri Aktarmaları Kaldır - - Type a name here to declare a new field. Yeni bir alan bildirmek için buraya bir ad yazın. @@ -1537,11 +1532,6 @@ Sub(<parameterList>) <statement> TODO: Finalize() yukarıda geçersiz kılınırsa aşağıdaki satırın açıklamasını kaldırın. - - Imports statement is unnecessary. - Imports deyimi gerekli değildir. - - Try block Try bloğu diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hans.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hans.xlf index 0dd85f6c2a024..8915c682b0d2e 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hans.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hans.xlf @@ -92,11 +92,6 @@ <多种类型> - - Remove Unnecessary Imports - 删除不必要的导入 - - Type a name here to declare a new field. 请在此处键入名称以声明新字段。 @@ -1537,11 +1532,6 @@ Sub(<parameterList>) <statement> TODO: 如果在以上内容中替代了 Finalize(),则取消注释以下行。 - - Imports statement is unnecessary. - Imports 语句是不需要的。 - - Try block Try 块 diff --git a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hant.xlf b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hant.xlf index e4d1718dbc4bb..0841dafece934 100644 --- a/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hant.xlf +++ b/src/Features/VisualBasic/Portable/xlf/VBFeaturesResources.zh-Hant.xlf @@ -92,11 +92,6 @@ <多項類型> - - Remove Unnecessary Imports - 移除不必要的匯入 - - Type a name here to declare a new field. 於此輸入名稱以宣告新的欄位。 @@ -1537,11 +1532,6 @@ Sub(<parameterList>) <statement> TODO: 覆寫上列 Finalize() 時,取消下行的註解狀態。 - - Imports statement is unnecessary. - 無須 Imports 陳述式。 - - Try block Try 區塊 diff --git a/src/VisualStudio/LiveShare/Test/PreviewCodeActionsTests.cs b/src/VisualStudio/LiveShare/Test/PreviewCodeActionsTests.cs index 7a3c6c85ec217..6be210fe276f5 100644 --- a/src/VisualStudio/LiveShare/Test/PreviewCodeActionsTests.cs +++ b/src/VisualStudio/LiveShare/Test/PreviewCodeActionsTests.cs @@ -27,7 +27,7 @@ void M() var (solution, locations) = CreateTestSolution(markup); var expected = CreateTextEdit("var", locations["edit"].First().Range); - var results = await TestHandleAsync(solution, CreateRunCodeActionParams(CSharpFeaturesResources.Use_implicit_type, locations["caret"].First())); + var results = await TestHandleAsync(solution, CreateRunCodeActionParams(CSharpAnalyzersResources.Use_implicit_type, locations["caret"].First())); AssertJsonEquals(new LSP.TextEdit[] { expected }, results); } diff --git a/src/VisualStudio/LiveShare/Test/RunCodeActionsHandlerTests.cs b/src/VisualStudio/LiveShare/Test/RunCodeActionsHandlerTests.cs index d527faf48896f..45c35e1a76534 100644 --- a/src/VisualStudio/LiveShare/Test/RunCodeActionsHandlerTests.cs +++ b/src/VisualStudio/LiveShare/Test/RunCodeActionsHandlerTests.cs @@ -29,7 +29,7 @@ void M() var (solution, ranges) = CreateTestSolution(markup); var codeActionLocation = ranges["caret"].First(); - var results = await TestHandleAsync(solution, CreateExecuteCommandParams(codeActionLocation, CSharpFeaturesResources.Use_implicit_type)); + var results = await TestHandleAsync(solution, CreateExecuteCommandParams(codeActionLocation, CSharpAnalyzersResources.Use_implicit_type)); Assert.True((bool)results); } diff --git a/src/Workspaces/CSharp/Portable/CSharpWorkspaceResources.Designer.cs b/src/Workspaces/CSharp/Portable/CSharpWorkspaceResources.Designer.cs index 0849218f7b212..3f126f465690a 100644 --- a/src/Workspaces/CSharp/Portable/CSharpWorkspaceResources.Designer.cs +++ b/src/Workspaces/CSharp/Portable/CSharpWorkspaceResources.Designer.cs @@ -69,33 +69,6 @@ internal static string Cannot_retrieve_the_Span_of_a_null_syntax_reference { } } - /// - /// Looks up a localized string similar to Code-block preferences. - /// - internal static string Code_block_preferences { - get { - return ResourceManager.GetString("Code_block_preferences", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expected string or char literal. - /// - internal static string Expected_string_or_char_literal { - get { - return ResourceManager.GetString("Expected_string_or_char_literal", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expression-bodied members. - /// - internal static string Expression_bodied_members { - get { - return ResourceManager.GetString("Expression_bodied_members", resourceCulture); - } - } - /// /// Looks up a localized string similar to Implement Interface. /// @@ -150,15 +123,6 @@ internal static string Node_not_in_parent_s_child_list { } } - /// - /// Looks up a localized string similar to Null-checking preferences. - /// - internal static string Null_checking_preferences { - get { - return ResourceManager.GetString("Null_checking_preferences", resourceCulture); - } - } - /// /// Looks up a localized string similar to Only attributes, constructor initializers, expressions or statements can be made explicit. /// @@ -169,15 +133,6 @@ internal static string Only_attributes_constructor_initializers_expressions_or_s } } - /// - /// Looks up a localized string similar to Pattern matching preferences. - /// - internal static string Pattern_matching_preferences { - get { - return ResourceManager.GetString("Pattern_matching_preferences", resourceCulture); - } - } - /// /// Looks up a localized string similar to R&emove and Sort Usings. /// @@ -214,24 +169,6 @@ internal static string Trivia_is_not_associated_with_token { } } - /// - /// Looks up a localized string similar to 'using' directive preferences. - /// - internal static string using_directive_preferences { - get { - return ResourceManager.GetString("using_directive_preferences", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to var preferences. - /// - internal static string var_preferences { - get { - return ResourceManager.GetString("var_preferences", resourceCulture); - } - } - /// /// Looks up a localized string similar to Wrapping preferences. /// diff --git a/src/Workspaces/CSharp/Portable/CSharpWorkspaceResources.resx b/src/Workspaces/CSharp/Portable/CSharpWorkspaceResources.resx index 54e6d99229a41..a4643510f319d 100644 --- a/src/Workspaces/CSharp/Portable/CSharpWorkspaceResources.resx +++ b/src/Workspaces/CSharp/Portable/CSharpWorkspaceResources.resx @@ -123,9 +123,6 @@ Namespace can not be added in this destination. - - Expected string or char literal - Node does not descend from root. @@ -144,34 +141,15 @@ Implement Interface - - Code-block preferences - - - Expression-bodied members - Indentation preferences - - Null-checking preferences - - - Pattern matching preferences - Space preferences - - var preferences - Wrapping preferences - - 'using' directive preferences - {Locked="using"} "using" is a C# keyword and should not be localized. - R&emove and Sort Usings diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.cs.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.cs.xlf index 132b288b59eb3..6727a9f9e98fa 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.cs.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.cs.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Předvolby bloků kódu - - - - Expression-bodied members - Členy s výrazem v těle - - Indentation preferences Předvolby odsazení @@ -27,11 +17,6 @@ Obor názvů nejde přidat do tohoto cílového umístění. - - Expected string or char literal - Očekával se řetězcový nebo znakový literál. - - Node does not descend from root. Uzel nesestupuje z kořene. @@ -42,16 +27,6 @@ Uzel není v seznamu podřízených položek u nadřazené položky. - - Null-checking preferences - Předvolby kontrol hodnoty null - - - - Pattern matching preferences - Předvolby porovnávání vzorů - - R&emove and Sort Usings Od&ebrat a seřadit direktivy Using @@ -92,16 +67,6 @@ Předvolby zalamování - - 'using' directive preferences - Předvolby direktivy using - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - Předvolby pro var - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.de.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.de.xlf index 59903b263e65c..aa15dc7b1e9ff 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.de.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.de.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Einstellungen für Codeblöcke - - - - Expression-bodied members - Ausdruckskörpermember - - Indentation preferences Einstellungen für Einrückung @@ -27,11 +17,6 @@ Namespace kann zu diesem Ziel nicht hinzugefügt werden. - - Expected string or char literal - Erwartete Zeichenfolge oder Zeichenliteral - - Node does not descend from root. Knoten steigt nicht vom Stamm ab. @@ -42,16 +27,6 @@ Knoten befindet sich nicht in der untergeordneten Liste des übergeordneten Elements - - Null-checking preferences - Einstellungen für NULL-Überprüfung - - - - Pattern matching preferences - Einstellungen für den Musterabgleich - - R&emove and Sort Usings &Unnötige Using-Direktiven entfernen und sortieren @@ -92,16 +67,6 @@ Umbrucheinstellungen - - 'using' directive preferences - Einstellungen für using-Anweisungen - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - Var-Einstellungen - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.es.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.es.xlf index c7ae94379ecb4..2aa4dd86a4f2e 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.es.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.es.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Preferencias de bloque de código - - - - Expression-bodied members - Miembros en cuerpo de expresión - - Indentation preferences Preferencias de indentación @@ -27,11 +17,6 @@ El espacio de nombres no se puede agregar en este destino. - - Expected string or char literal - Cadena o carácter literal esperados - - Node does not descend from root. El nodo no desciende de la raíz. @@ -42,16 +27,6 @@ El nodo no está en una lista secundaria de la primaria - - Null-checking preferences - Preferencias de comprobación de nulo - - - - Pattern matching preferences - Preferencias de coincidencia de patrón - - R&emove and Sort Usings Q&uitar y ordenar usos @@ -92,16 +67,6 @@ Preferencias de encapsulado - - 'using' directive preferences - Preferencias de directiva "using" - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - Preferencias de var - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.fr.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.fr.xlf index d36b84bb9c882..d81fff37a4442 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.fr.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.fr.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Préférences de bloc de code - - - - Expression-bodied members - Membres expression-bodied - - Indentation preferences Préférences de mise en retrait @@ -27,11 +17,6 @@ L'espace de noms ne peut pas être ajouté dans cette destination. - - Expected string or char literal - Littéral char ou string attendu - - Node does not descend from root. Le nœud ne provient pas de la racine. @@ -42,16 +27,6 @@ Le nœud ne figure pas dans la liste des enfants du parent - - Null-checking preferences - Préférences de vérification de valeur Null - - - - Pattern matching preferences - Préférences correspondants au modèle - - R&emove and Sort Usings Supprim&er et trier les instructions using @@ -92,16 +67,6 @@ Préférences d'enveloppement - - 'using' directive preferences - Préférences pour la directive 'using' - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - Préférences de var - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.it.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.it.xlf index e9aa19bc79792..e680643c12376 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.it.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.it.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Preferenze per blocchi di codice - - - - Expression-bodied members - Membri con corpo di espressione - - Indentation preferences Preferenze per rientro @@ -27,11 +17,6 @@ Non è possibile aggiungere lo spazio dei nomi in questa destinazione. - - Expected string or char literal - È previsto un valore letterale di tipo stringa o char - - Node does not descend from root. Il nodo non discende dalla radice. @@ -42,16 +27,6 @@ Il nodo non è incluso nell'elenco degli elementi figlio dell'elemento padre - - Null-checking preferences - Preference per controllo valori Null - - - - Pattern matching preferences - Preferenze per criteri di ricerca - - R&emove and Sort Usings Ri&muovi e ordina using @@ -92,16 +67,6 @@ Preferenze per ritorno a capo - - 'using' directive preferences - Preferenze per direttive 'using' - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - Preferenze per var - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ja.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ja.xlf index c7176159a842d..698d74492b5f6 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ja.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ja.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - コード ブロックの設定 - - - - Expression-bodied members - 式のようなメンバー - - Indentation preferences インデント設定 @@ -27,11 +17,6 @@ 名前空間は、このターゲットでは追加できません。 - - Expected string or char literal - 文字列または文字リテラルが必要です - - Node does not descend from root. ノードがルートから派生していません。 @@ -42,16 +27,6 @@ ノードが親の子リストにありません - - Null-checking preferences - Null チェック設定 - - - - Pattern matching preferences - パターン マッチング設定 - - R&emove and Sort Usings Using の削除と並び替え(&E) @@ -92,16 +67,6 @@ 折り返しの設定 - - 'using' directive preferences - 'using' ディレクティブの基本設定 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var を優先 - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ko.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ko.xlf index b526270bc1160..a624d957ff701 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ko.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ko.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - 코드 블록 기본 설정 - - - - Expression-bodied members - 식 본문 멤버 - - Indentation preferences 들여쓰기 기본 설정 @@ -27,11 +17,6 @@ 이 대상에는 네임스페이스를 추가할 수 없습니다. - - Expected string or char literal - 문자열 또는 문자 리터럴이 필요합니다. - - Node does not descend from root. 노드가 루트의 내림차순이 아닙니다. @@ -42,16 +27,6 @@ 부모의 자식 목록에 노드가 없습니다. - - Null-checking preferences - Null 검사 기본 설정 - - - - Pattern matching preferences - 패턴 일치 기본 설정 - - R&emove and Sort Usings Using 제거 및 정렬(&E) @@ -92,16 +67,6 @@ 기본 설정 래핑 - - 'using' directive preferences - 'using' 지시문 기본 설정 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var 기본 설정 - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.pl.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.pl.xlf index cc127ab53cf1d..f71b516b0979d 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.pl.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.pl.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Preferencje bloku kodu - - - - Expression-bodied members - Składowe z wyrażeniem w treści - - Indentation preferences Preferencje wcięć @@ -27,11 +17,6 @@ Do tego miejsca docelowego nie można dodać przestrzeni nazw. - - Expected string or char literal - Oczekiwano ciągu lub literału znakowego - - Node does not descend from root. Węzeł nie jest elementem podrzędnym elementu głównego. @@ -42,16 +27,6 @@ Węzeł nie znajduje się na liście elementów podrzędnych elementu nadrzędnego - - Null-checking preferences - Preferencje sprawdzania wartości null - - - - Pattern matching preferences - Preferencje dopasowywania do wzorca - - R&emove and Sort Usings &Usuń i sortuj instrukcje using @@ -92,16 +67,6 @@ Preferencje zawijania - - 'using' directive preferences - Preferencje dyrektywy „using” - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - Preferencje zmiennych - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.pt-BR.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.pt-BR.xlf index 141bd9a09f486..bdbdcb506c524 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.pt-BR.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.pt-BR.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Preferências do bloco de código - - - - Expression-bodied members - Membros aptos para expressão - - Indentation preferences Preferências de recuo @@ -27,11 +17,6 @@ Namespace não pode ser adicionado nesse destino. - - Expected string or char literal - Cadeia de caracteres esperada ou literal char - - Node does not descend from root. Nó não deriva da raiz. @@ -42,16 +27,6 @@ Nó não está na lista de filhos do pai - - Null-checking preferences - Preferências de verificação nula - - - - Pattern matching preferences - Preferências de correspondência de padrões - - R&emove and Sort Usings R&emover e Classificar Usos @@ -92,16 +67,6 @@ Preferências de quebra de linha - - 'using' directive preferences - Preferências da diretiva 'using' - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - preferências de var - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ru.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ru.xlf index e490b07a224ba..15d6ed6646df2 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ru.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.ru.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Предпочтения для блоков кода - - - - Expression-bodied members - Члены, заданные выражениями - - Indentation preferences Предпочтения для отступов @@ -27,11 +17,6 @@ Не удается добавить пространство имен в этот конечный объект. - - Expected string or char literal - Требуется строка или знаковый литерал - - Node does not descend from root. Узел не является корневым. @@ -42,16 +27,6 @@ Узел не входит в родительский список дочерних узлов - - Null-checking preferences - Настройки проверки на null - - - - Pattern matching preferences - Настройки соответствия шаблонов - - R&emove and Sort Usings У&далить и отсортировать директивы using @@ -92,16 +67,6 @@ Предпочтения переноса - - 'using' directive preferences - предпочтения для директивы using - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - Предпочтения var - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.tr.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.tr.xlf index f654029681ee3..b1c3ab31384ca 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.tr.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.tr.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - Kod bloğu tercihleri - - - - Expression-bodied members - İfade gövdeli Üyeler - - Indentation preferences Girinti tercihleri @@ -27,11 +17,6 @@ Ad alanı bu hedefe eklenemez. - - Expected string or char literal - Beklenen dize veya karakter sabiti değeri - - Node does not descend from root. Düğüm kökten azalmaz. @@ -42,16 +27,6 @@ Düğüm üst öğenin alt öğe listesinde değil - - Null-checking preferences - Null denetimi tercihleri - - - - Pattern matching preferences - Desen eşleştirme tercihleri - - R&emove and Sort Usings &Kaldır ve Sıralama Usings @@ -92,16 +67,6 @@ Kaydırma tercihleri - - 'using' directive preferences - 'using' yönergesi tercihleri - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var tercihleri - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.zh-Hans.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.zh-Hans.xlf index 0573a886900be..f3aa0d431c08a 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.zh-Hans.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.zh-Hans.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - 代码块首选项 - - - - Expression-bodied members - Expression-bodied 成员 - - Indentation preferences 缩进首选项 @@ -27,11 +17,6 @@ 不能在此目标中添加命名空间。 - - Expected string or char literal - 预期的字符串或字符文本 - - Node does not descend from root. 节点并非源自根。 @@ -42,16 +27,6 @@ 节点不在父级的子列表中 - - Null-checking preferences - Null 检查首选项 - - - - Pattern matching preferences - 模式匹配首选项 - - R&emove and Sort Usings 删除 Using 和对其排序(&E) @@ -92,16 +67,6 @@ 包装首选项 - - 'using' directive preferences - "using" 指令首选项 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var 首选项 - - \ No newline at end of file diff --git a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.zh-Hant.xlf b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.zh-Hant.xlf index 5fe3512eb85e0..9e24387134fb9 100644 --- a/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.zh-Hant.xlf +++ b/src/Workspaces/CSharp/Portable/xlf/CSharpWorkspaceResources.zh-Hant.xlf @@ -2,16 +2,6 @@ - - Code-block preferences - 程式碼區塊喜好設定 - - - - Expression-bodied members - 運算式主體成員 - - Indentation preferences 縮排喜好設定 @@ -27,11 +17,6 @@ 無法將命名空間加入此目的地。 - - Expected string or char literal - 必須是字串或字元常值 - - Node does not descend from root. 節點不是根的子系。 @@ -42,16 +27,6 @@ 節點不在父代的子清單中 - - Null-checking preferences - Null 檢查喜好設定 - - - - Pattern matching preferences - 模式比對喜好設定 - - R&emove and Sort Usings 移除和排序 Using(&E) @@ -92,16 +67,6 @@ 換行喜好設定 - - 'using' directive preferences - 'using' 指示詞的喜好設定 - {Locked="using"} "using" is a C# keyword and should not be localized. - - - var preferences - var 喜好設定 - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs b/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs index 6ffa9630a5b12..76945d4e385fa 100644 --- a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs +++ b/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs @@ -8,15 +8,10 @@ using static Microsoft.CodeAnalysis.CodeStyle.CodeStyleHelpers; #if CODE_STYLE -using Resources = Microsoft.CodeAnalysis.CodeStyleResources; +namespace Microsoft.CodeAnalysis.Internal.Options #else using Microsoft.CodeAnalysis.Options; -using Resources = Microsoft.CodeAnalysis.WorkspacesResources; -#endif -#if CODE_STYLE -namespace Microsoft.CodeAnalysis.Internal.Options -#else namespace Microsoft.CodeAnalysis.CodeStyle #endif { @@ -416,13 +411,13 @@ private static string GetUnusedParametersPreferenceEditorConfigString(CodeStyleO internal static class CodeStyleOptionGroups { - public static readonly OptionGroup Usings = new OptionGroup(Resources.Organize_usings, priority: 1); - public static readonly OptionGroup ThisOrMe = new OptionGroup(Resources.this_dot_and_Me_dot_preferences, priority: 2); - public static readonly OptionGroup PredefinedTypeNameUsage = new OptionGroup(Resources.Language_keywords_vs_BCL_types_preferences, priority: 3); - public static readonly OptionGroup Parentheses = new OptionGroup(Resources.Parentheses_preferences, priority: 4); - public static readonly OptionGroup Modifier = new OptionGroup(Resources.Modifier_preferences, priority: 5); - public static readonly OptionGroup ExpressionLevelPreferences = new OptionGroup(Resources.Expression_level_preferences, priority: 6); - public static readonly OptionGroup Field = new OptionGroup(Resources.Field_preferences, priority: 7); - public static readonly OptionGroup Parameter = new OptionGroup(Resources.Parameter_preferences, priority: 8); + public static readonly OptionGroup Usings = new OptionGroup(CompilerExtensionsResources.Organize_usings, priority: 1); + public static readonly OptionGroup ThisOrMe = new OptionGroup(CompilerExtensionsResources.this_dot_and_Me_dot_preferences, priority: 2); + public static readonly OptionGroup PredefinedTypeNameUsage = new OptionGroup(CompilerExtensionsResources.Language_keywords_vs_BCL_types_preferences, priority: 3); + public static readonly OptionGroup Parentheses = new OptionGroup(CompilerExtensionsResources.Parentheses_preferences, priority: 4); + public static readonly OptionGroup Modifier = new OptionGroup(CompilerExtensionsResources.Modifier_preferences, priority: 5); + public static readonly OptionGroup ExpressionLevelPreferences = new OptionGroup(CompilerExtensionsResources.Expression_level_preferences, priority: 6); + public static readonly OptionGroup Field = new OptionGroup(CompilerExtensionsResources.Field_preferences, priority: 7); + public static readonly OptionGroup Parameter = new OptionGroup(CompilerExtensionsResources.Parameter_preferences, priority: 8); } } diff --git a/src/Workspaces/Core/Portable/WorkspacesResources.resx b/src/Workspaces/Core/Portable/WorkspacesResources.resx index fe92413f9188c..00252d4e8ba5d 100644 --- a/src/Workspaces/Core/Portable/WorkspacesResources.resx +++ b/src/Workspaces/Core/Portable/WorkspacesResources.resx @@ -1425,42 +1425,18 @@ Zero-width positive lookbehind assertions are typically used at the beginning of .NET Coding Conventions - - Expression-level preferences - - - Field preferences - Indentation and spacing - - Language keywords vs BCL types preferences - - - Modifier preferences - New line preferences - - Organize usings - - - Parentheses preferences - - - this. and Me. preferences - Visual Basic files Changing document '{0}' is not supported. - - Parameter preferences - Prefix '{0}' does not match expected prefix '{1}' diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf index 935f8cbae6810..fbfe336bbd4ee 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf @@ -57,16 +57,6 @@ Při čtení obsahu zdrojového souboru {0} došlo k chybě -- {1} - - Expression-level preferences - Předvolby na úrovni výrazů - - - - Field preferences - Předvolby polí - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Odsazení a mezery - - Language keywords vs BCL types preferences - Předvolby klíčových slov jazyka a typů BCL - - - - Modifier preferences - Předvolby modifikátorů - - Naming rules Pravidla pojmenování @@ -117,16 +97,6 @@ Možnosti nepocházely ze zadaného řešení. - - Organize usings - Uspořádat direktivy using - - - - Parentheses preferences - Předvolby závorek - - Prefix '{0}' does not match expected prefix '{1}' Předpona {0} neodpovídá očekávané předponě {1}. @@ -2217,11 +2187,6 @@ Pozitivní kontrolní výrazy zpětného vyhledávání s nulovou délkou se obv Konvence kódování v .NET - - this. and Me. preferences - Předvolby pro this. a Me. - - [x-y] range in reverse order Rozsah [x-y] je v obráceném pořadí. @@ -2237,11 +2202,6 @@ Pozitivní kontrolní výrazy zpětného vyhledávání s nulovou délkou se obv Problém s regulárním výrazem: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Předvolby parametrů - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf index ca42add249a69..e7f65390c58ec 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf @@ -57,16 +57,6 @@ Fehler beim Lesen des Inhalts der Quelldatei "{0}": "{1}". - - Expression-level preferences - Einstellungen für Ausdrucksebene - - - - Field preferences - Einstellungen für Felder - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Einzüge und Abstände - - Language keywords vs BCL types preferences - Einstellungen für Sprachschlüsselwörter und BCL-Typen - - - - Modifier preferences - Einstellungen für Modifizierer - - Naming rules Benennungsregeln @@ -117,16 +97,6 @@ Optionen stammen nicht aus der angegebenen Projektmappe. - - Organize usings - Using-Direktiven organisieren - - - - Parentheses preferences - Einstellungen für Klammern - - Prefix '{0}' does not match expected prefix '{1}' Das Präfix "{0}" entspricht nicht dem erwarteten Präfix "{1}". @@ -2217,11 +2187,6 @@ Positive Lookbehindassertionen mit Nullbreite werden normalerweise am Anfang reg .NET-Codierungskonventionen - - this. and Me. preferences - this.- und Me.-Einstellungen - - [x-y] range in reverse order [x-y]-Bereich in umgekehrter Reihenfolge @@ -2237,11 +2202,6 @@ Positive Lookbehindassertionen mit Nullbreite werden normalerweise am Anfang reg RegEx-Fehler: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Einstellungen für Parameter - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf index 9dfa2fb3a6214..b5ed6628c2ffc 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf @@ -57,16 +57,6 @@ Error al leer el contenido del archivo de origen "{0}"--"{1}". - - Expression-level preferences - Preferencias de nivel de expresión - - - - Field preferences - Preferencias de campo - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Sangría y espaciado - - Language keywords vs BCL types preferences - Preferencias de palabras clave frente a tipos de BCL - - - - Modifier preferences - Preferencias de modificador - - Naming rules Reglas de nomenclatura @@ -117,16 +97,6 @@ Las opciones no procedían de la solución especificada. - - Organize usings - Organizar instrucciones Using - - - - Parentheses preferences - Preferencias de paréntesis - - Prefix '{0}' does not match expected prefix '{1}' El prefijo "{0}" no coincide con el prefijo esperado "{1}". @@ -2217,11 +2187,6 @@ Las aserciones de búsqueda retrasada (lookbehind) positivas de ancho cero se us Convenciones de codificación .NET - - this. and Me. preferences - Preferencias de this. y .me - - [x-y] range in reverse order rango [x-y] en orden inverso @@ -2237,11 +2202,6 @@ Las aserciones de búsqueda retrasada (lookbehind) positivas de ancho cero se us Problema de Regex: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Preferencias de parámetro - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf index 91395155aa4ad..5fb03465492ea 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf @@ -57,16 +57,6 @@ Erreur durant la lecture du contenu du fichier source '{0}' -- '{1}'. - - Expression-level preferences - Préférences de niveau expression - - - - Field preferences - Préférences de champ - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Indentation et espacement - - Language keywords vs BCL types preferences - Préférences des mots clés de langage par rapport aux types BCL - - - - Modifier preferences - Préférences de modificateur - - Naming rules Règles de nommage @@ -117,16 +97,6 @@ Les options ne proviennent pas de la solution spécifiée - - Organize usings - Organiser les instructions Using - - - - Parentheses preferences - Préférences de parenthèses - - Prefix '{0}' does not match expected prefix '{1}' Le préfixe « {0} » ne correspond pas au préfixe attendu « {1} » @@ -2217,11 +2187,6 @@ Les assertions arrière positives de largeur nulle sont généralement utilisée Conventions de codage .NET - - this. and Me. preferences - Préférences de this. et Me. - - [x-y] range in reverse order Intervalle [x-y] dans l'ordre inverse @@ -2237,11 +2202,6 @@ Les assertions arrière positives de largeur nulle sont généralement utilisée Problème de regex : {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Préférences de paramètre - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf index cb1c9845ca047..ecc5e632ff93b 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf @@ -57,16 +57,6 @@ Si è verificato un errore durante la lettura del contenuto del file di origine '{0}' - '{1}'. - - Expression-level preferences - Preferenze a livello di espressione - - - - Field preferences - Preferenze per campi - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Rientro e spaziatura - - Language keywords vs BCL types preferences - Preferenze per parole chiave linguaggio rispetto a tipi BCL - - - - Modifier preferences - Preferenze per modificatore - - Naming rules Regole di denominazione @@ -117,16 +97,6 @@ Le opzioni non provengono dalla soluzione specificata - - Organize usings - Organizza using - - - - Parentheses preferences - Preferenze per parentesi - - Prefix '{0}' does not match expected prefix '{1}' Il prefisso '{0}' non corrisponde al prefisso previsto '{1}' @@ -2217,11 +2187,6 @@ Le asserzioni lookbehind positive di larghezza zero vengono usate in genere all' Convenzioni di scrittura codice .NET - - this. and Me. preferences - Preferenze per this. e Me. - - [x-y] range in reverse order Intervallo [x-y] in ordine inverso @@ -2237,11 +2202,6 @@ Le asserzioni lookbehind positive di larghezza zero vengono usate in genere all' Problema di regex: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Preferenze per parametri - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf index 960f97074b570..d490ebac80a24 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf @@ -57,16 +57,6 @@ ソース ファイル '{0}' のコンテンツの読み取りでエラーが発生しました -- '{1}'。 - - Expression-level preferences - 式レベルの設定 - - - - Field preferences - フィールド設定 - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ インデントと間隔 - - Language keywords vs BCL types preferences - 言語キーワードと BCL の種類の設定 - - - - Modifier preferences - 修飾子設定 - - Naming rules 名前付けルール @@ -117,16 +97,6 @@ オプションは指定されたソリューションに由来するものではありません - - Organize usings - using の整理 - - - - Parentheses preferences - かっこの設定 - - Prefix '{0}' does not match expected prefix '{1}' プレフィックス '{0}' が予想されるプレフィックス '{1}' と一致しません @@ -2217,11 +2187,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of .NET コーディング規則 - - this. and Me. preferences - this. と Me. の設定 - - [x-y] range in reverse order [x-y] 範囲の順序が逆です @@ -2237,11 +2202,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 正規表現の問題: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - パラメーターの設定 - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf index 361ffb742a6a1..b306794dbfae1 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf @@ -57,16 +57,6 @@ 소스 파일 '{0}'의 콘텐츠를 읽는 동안 오류가 발생했습니다. -- '{1}'. - - Expression-level preferences - 식 수준 기본 설정 - - - - Field preferences - 필드 기본 설정 - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ 들여쓰기 및 간격 - - Language keywords vs BCL types preferences - 언어 키워드 및 BCL 형식 기본 설정 - - - - Modifier preferences - 한정자 기본 설정 - - Naming rules 명명 규칙 @@ -117,16 +97,6 @@ 옵션을 지정된 솔루션에서 가져오지 않음 - - Organize usings - Using 구성 - - - - Parentheses preferences - 괄호 기본 설정 - - Prefix '{0}' does not match expected prefix '{1}' 접두사 '{0}'이(가) 필요한 접두사 '{1}'과(와) 일치하지 않습니다. @@ -2217,11 +2187,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of .NET 코딩 규칙 - - this. and Me. preferences - this. 및 Me. 기본 설정 - - [x-y] range in reverse order [x-y] 범위가 역순으로 되어 있습니다. @@ -2237,11 +2202,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Regex 문제: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - 매개 변수 기본 설정 - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf index e398a8d9ce774..f9e1e10e9e5e3 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf @@ -57,16 +57,6 @@ Błąd podczas odczytywania zawartości pliku źródłowego „{0}”--„{1}”. - - Expression-level preferences - Preferencje na poziomie wyrażeń - - - - Field preferences - Preferencje pól - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Wcięcia i odstępy - - Language keywords vs BCL types preferences - Słowa kluczowe języka a preferencje typów BCL - - - - Modifier preferences - Preferencje modyfikatora - - Naming rules Reguły nazewnictwa @@ -117,16 +97,6 @@ Opcje nie pochodziły z określonego rozwiązania - - Organize usings - Organizuj użycia - - - - Parentheses preferences - Preferencje dotyczące nawiasów - - Prefix '{0}' does not match expected prefix '{1}' Prefiks „{0}” jest inny niż oczekiwany prefiks „{1}” @@ -2217,11 +2187,6 @@ Pozytywne asercje wsteczne o zerowej szerokości są zwykle używane na początk Konwencje kodowania .NET - - this. and Me. preferences - Preferencje dotyczące słów kluczowych this. i Me. - - [x-y] range in reverse order Zakres [x-y] w odwrotnej kolejności @@ -2237,11 +2202,6 @@ Pozytywne asercje wsteczne o zerowej szerokości są zwykle używane na początk Problem z wyrażeniem regularnym: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Preferencje dotyczące parametrów - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf index f9e1de84c8d26..c1c597c953c74 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf @@ -57,16 +57,6 @@ Erro ao ler o conteúdo do arquivo de origem '{0}' – '{1}'. - - Expression-level preferences - Preferências de nível de expressão - - - - Field preferences - Preferências de campo - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Recuo e espaçamento - - Language keywords vs BCL types preferences - Preferências de tipos BCL contra palavras-chave do idioma - - - - Modifier preferences - Preferências de modificador - - Naming rules Regras de nomenclatura @@ -117,16 +97,6 @@ As opções não vieram da Solução especificada - - Organize usings - Organizar Usos - - - - Parentheses preferences - Preferências de parênteses - - Prefix '{0}' does not match expected prefix '{1}' O prefixo '{0}' não coincide com prefixo esperado '{1}' @@ -2217,11 +2187,6 @@ As declarações de lookbehind positivas de largura zero normalmente são usadas Convenções de codificação .NET - - this. and Me. preferences - Preferências - - [x-y] range in reverse order intervalo [x-y] em ordem inversa @@ -2237,11 +2202,6 @@ As declarações de lookbehind positivas de largura zero normalmente são usadas Problema do Regex: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Preferências de parâmetro - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf index 916a4b4827e18..decf6dcbc7b07 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf @@ -57,16 +57,6 @@ Ошибка при чтении содержимого исходного файла "{0}" — "{1}". - - Expression-level preferences - Выражения уровень предпочтения - - - - Field preferences - Предпочтения для полей - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Отступы и интервалы - - Language keywords vs BCL types preferences - Параметры использования ключевых слов языка и типов BCL - - - - Modifier preferences - Предпочтения модификатора - - Naming rules Правила именования @@ -117,16 +97,6 @@ Параметры получены не из указанного решения. - - Organize usings - Упорядочение Using - - - - Parentheses preferences - Предпочтения для скобок - - Prefix '{0}' does not match expected prefix '{1}' Префикс '{0}' не соответствует ожидаемому префиксу '{1}' @@ -2217,11 +2187,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Рекомендации по написанию кода .NET - - this. and Me. preferences - Предпочтения для this. и Me. - - [x-y] range in reverse order Диапазон [x-y] в обратном порядке @@ -2237,11 +2202,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Проблема с регулярным выражением: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Настройки параметров - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf index fc7f46f33a779..fae37ab8b93b0 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf @@ -57,16 +57,6 @@ '{0}' kaynak dosyasının içeriği okunurken hata oluştu -- '{1}'. - - Expression-level preferences - İfade düzey tercihleri - - - - Field preferences - Alan tercihleri - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ Girinti ve aralığı - - Language keywords vs BCL types preferences - Dil anahtar kelimeler vs BCL türleri tercihleri - - - - Modifier preferences - Değiştirici tercihleri - - Naming rules Adlandırma kuralları @@ -117,16 +97,6 @@ Seçenekler belirtilen Çözümden gelmedi - - Organize usings - Kullanımları Düzenle - - - - Parentheses preferences - Parantez tercihleri - - Prefix '{0}' does not match expected prefix '{1}' '{0}' öneki 'beklenen {1}' öneki eşleşmiyor @@ -2217,11 +2187,6 @@ Sıfır genişlikli pozitif geri yönlü onaylamalar genellikle normal ifadeleri .NET kodlama kuralları - - this. and Me. preferences - Bu. ve bana tercihleri - - [x-y] range in reverse order [x-y] aralığı ters sırada @@ -2237,11 +2202,6 @@ Sıfır genişlikli pozitif geri yönlü onaylamalar genellikle normal ifadeleri Regex sorunu: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - Parametre tercihleri - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf index 75559d48d31b5..8137dc4bce876 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf @@ -57,16 +57,6 @@ 读取源文件“{0}”中的内容时出错 -“{1}”。 - - Expression-level preferences - 表达式级首选项 - - - - Field preferences - 字段首选项 - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ 缩进和间距 - - Language keywords vs BCL types preferences - 语言关键字与 bcl 类型首选项 - - - - Modifier preferences - 修饰符首选项 - - Naming rules 命名规则 @@ -117,16 +97,6 @@ 选项并非来自指定的解决方案 - - Organize usings - 组织 Using - - - - Parentheses preferences - 括号首选项 - - Prefix '{0}' does not match expected prefix '{1}' 前缀 "{0}" 与预期前缀 "{1}" 不匹配 @@ -2217,11 +2187,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of .NET 编码约定 - - this. and Me. preferences - this. 和 Me. 首选项 - - [x-y] range in reverse order 按相反顺序排列的 [x-y] 范围 @@ -2237,11 +2202,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 正则表达式问题: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - 参数首选项 - - \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf index 0095df987bd1b..e4fb7f1122d2f 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf @@ -57,16 +57,6 @@ 讀取來源檔案 '{0}' 的內容時發生錯誤 -- '{1}'。 - - Expression-level preferences - 運算式層級喜好設定 - - - - Field preferences - 欄位喜好設定 - - Fix all '{0}' Fix all '{0}' @@ -87,16 +77,6 @@ 縮排和間距 - - Language keywords vs BCL types preferences - 語言關鍵字與 BCL 類型喜好設定 - - - - Modifier preferences - 修飾元喜好設定 - - Naming rules 命名規則 @@ -117,16 +97,6 @@ 選項並非來自指定的解決方案 - - Organize usings - 組合管理 Using - - - - Parentheses preferences - 括號喜好設定 - - Prefix '{0}' does not match expected prefix '{1}' 前置詞 '{0}' 不符合預期的前置詞 '{1}' @@ -2217,11 +2187,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of .NET 編碼慣例 - - this. and Me. preferences - this. 和 Me. 喜好設定 - - [x-y] range in reverse order 反向排序的 [x-y] 範圍 @@ -2237,11 +2202,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Regex 問題: {0} This is an error message shown to the user when they write an invalid Regular Expression. {0} will be the actual text of one of the above Regular Expression errors. - - Parameter preferences - 參數喜好設定 - - \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems index c28596624d3d3..11f4cda5467d8 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems @@ -34,4 +34,7 @@ + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensionsResources.resx b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensionsResources.resx new file mode 100644 index 0000000000000..e4d5efbb4f352 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensionsResources.resx @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + var preferences + + + Expression-bodied members + + + Pattern matching preferences + + + Null-checking preferences + + + Code-block preferences + + + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions.cs index e7b853ed60b75..fba1c072eb015 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CodeStyle/CSharpCodeStyleOptions.cs @@ -10,15 +10,11 @@ #if CODE_STYLE using Microsoft.CodeAnalysis.Internal.Options; -using CSharpResources = Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources; -using Resources = Microsoft.CodeAnalysis.CodeStyleResources; namespace Microsoft.CodeAnalysis.CSharp.Internal.CodeStyle { #else using Microsoft.CodeAnalysis.Options; -using CSharpResources = Microsoft.CodeAnalysis.CSharp.CSharpWorkspaceResources; -using Resources = Microsoft.CodeAnalysis.WorkspacesResources; namespace Microsoft.CodeAnalysis.CSharp.CodeStyle { @@ -343,13 +339,13 @@ public static IEnumerable>> Get internal static class CSharpCodeStyleOptionGroups { - public static readonly OptionGroup VarPreferences = new OptionGroup(CSharpResources.var_preferences, priority: 1); - public static readonly OptionGroup ExpressionBodiedMembers = new OptionGroup(CSharpResources.Expression_bodied_members, priority: 2); - public static readonly OptionGroup PatternMatching = new OptionGroup(CSharpResources.Pattern_matching_preferences, priority: 3); - public static readonly OptionGroup NullCheckingPreferences = new OptionGroup(CSharpResources.Null_checking_preferences, priority: 4); - public static readonly OptionGroup Modifier = new OptionGroup(Resources.Modifier_preferences, priority: 5); - public static readonly OptionGroup CodeBlockPreferences = new OptionGroup(CSharpResources.Code_block_preferences, priority: 6); - public static readonly OptionGroup ExpressionLevelPreferences = new OptionGroup(Resources.Expression_level_preferences, priority: 7); - public static readonly OptionGroup UsingDirectivePreferences = new OptionGroup(CSharpResources.using_directive_preferences, priority: 8); + public static readonly OptionGroup VarPreferences = new OptionGroup(CSharpCompilerExtensionsResources.var_preferences, priority: 1); + public static readonly OptionGroup ExpressionBodiedMembers = new OptionGroup(CSharpCompilerExtensionsResources.Expression_bodied_members, priority: 2); + public static readonly OptionGroup PatternMatching = new OptionGroup(CSharpCompilerExtensionsResources.Pattern_matching_preferences, priority: 3); + public static readonly OptionGroup NullCheckingPreferences = new OptionGroup(CSharpCompilerExtensionsResources.Null_checking_preferences, priority: 4); + public static readonly OptionGroup Modifier = new OptionGroup(CompilerExtensionsResources.Modifier_preferences, priority: 5); + public static readonly OptionGroup CodeBlockPreferences = new OptionGroup(CSharpCompilerExtensionsResources.Code_block_preferences, priority: 6); + public static readonly OptionGroup ExpressionLevelPreferences = new OptionGroup(CompilerExtensionsResources.Expression_level_preferences, priority: 7); + public static readonly OptionGroup UsingDirectivePreferences = new OptionGroup(CSharpCompilerExtensionsResources.using_directive_preferences, priority: 8); } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.cs.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.cs.xlf new file mode 100644 index 0000000000000..840caa574801a --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.cs.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.de.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.de.xlf new file mode 100644 index 0000000000000..b9b4f50fc9b5f --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.de.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.es.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.es.xlf new file mode 100644 index 0000000000000..a843a8eae9332 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.es.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.fr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.fr.xlf new file mode 100644 index 0000000000000..506424dcbd7c9 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.fr.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.it.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.it.xlf new file mode 100644 index 0000000000000..e1ae6acd84db1 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.it.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ja.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ja.xlf new file mode 100644 index 0000000000000..72d3f9fbc694c --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ja.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ko.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ko.xlf new file mode 100644 index 0000000000000..02771d99b66a2 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ko.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.pl.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.pl.xlf new file mode 100644 index 0000000000000..ddfc53e7a668c --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.pl.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.pt-BR.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.pt-BR.xlf new file mode 100644 index 0000000000000..0f8b5ca88d106 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.pt-BR.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ru.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ru.xlf new file mode 100644 index 0000000000000..bcfd711cc1c65 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.ru.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.tr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.tr.xlf new file mode 100644 index 0000000000000..14dd6228f3b70 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.tr.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.zh-Hans.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.zh-Hans.xlf new file mode 100644 index 0000000000000..330916eeb7535 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.zh-Hans.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.zh-Hant.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.zh-Hant.xlf new file mode 100644 index 0000000000000..e47bbbcd7ee76 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/xlf/CSharpCompilerExtensionsResources.zh-Hant.xlf @@ -0,0 +1,37 @@ + + + + + + Code-block preferences + Code-block preferences + + + + Expression-bodied members + Expression-bodied members + + + + Null-checking preferences + Null-checking preferences + + + + Pattern matching preferences + Pattern matching preferences + + + + 'using' directive preferences + 'using' directive preferences + {Locked="using"} "using" is a C# keyword and should not be localized. + + + var preferences + var preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 089c561b6a6ce..b0aa3860eb148 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -127,7 +127,7 @@ InternalUtilities\OneOrMany.cs - + InternalUtilities\PerformanceSensitiveAttribute.cs @@ -306,4 +306,7 @@ + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensionsResources.resx b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensionsResources.resx new file mode 100644 index 0000000000000..bca908d76c1b8 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensionsResources.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Organize usings + + + this. and Me. preferences + + + Language keywords vs BCL types preferences + + + Parentheses preferences + + + Modifier preferences + + + Expression-level preferences + + + Field preferences + + + Parameter preferences + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.cs.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.cs.xlf new file mode 100644 index 0000000000000..5c0793351922b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.cs.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.de.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.de.xlf new file mode 100644 index 0000000000000..6a64690ba2a25 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.de.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.es.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.es.xlf new file mode 100644 index 0000000000000..df92598bc7d7b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.es.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.fr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.fr.xlf new file mode 100644 index 0000000000000..7cf4d5c3a1161 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.fr.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.it.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.it.xlf new file mode 100644 index 0000000000000..f65cfbb8927f4 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.it.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ja.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ja.xlf new file mode 100644 index 0000000000000..c9fc5c89efb7b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ja.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ko.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ko.xlf new file mode 100644 index 0000000000000..1c04fbddb7d04 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ko.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.pl.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.pl.xlf new file mode 100644 index 0000000000000..fa0d22c9787b2 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.pl.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.pt-BR.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.pt-BR.xlf new file mode 100644 index 0000000000000..d92398b0510a5 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.pt-BR.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ru.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ru.xlf new file mode 100644 index 0000000000000..ad6ed3d8e3cc9 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.ru.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.tr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.tr.xlf new file mode 100644 index 0000000000000..a276f107d8949 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.tr.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.zh-Hans.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.zh-Hans.xlf new file mode 100644 index 0000000000000..a033b3b7653a1 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.zh-Hans.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.zh-Hant.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.zh-Hant.xlf new file mode 100644 index 0000000000000..a0117c2cc4f86 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/xlf/CompilerExtensionsResources.zh-Hant.xlf @@ -0,0 +1,47 @@ + + + + + + Expression-level preferences + Expression-level preferences + + + + Field preferences + Field preferences + + + + Language keywords vs BCL types preferences + Language keywords vs BCL types preferences + + + + Modifier preferences + Modifier preferences + + + + Organize usings + Organize usings + + + + Parameter preferences + Parameter preferences + + + + Parentheses preferences + Parentheses preferences + + + + this. and Me. preferences + this. and Me. preferences + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems index 5b41368565e7b..7d8f52eaf2ac5 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems @@ -14,4 +14,7 @@ + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensionsResources.resx b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensionsResources.resx new file mode 100644 index 0000000000000..14ed010cf9ebb --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensionsResources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.cs.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.cs.xlf new file mode 100644 index 0000000000000..e861c2a9743c7 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.de.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.de.xlf new file mode 100644 index 0000000000000..0b8ef141587ad --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.de.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.es.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.es.xlf new file mode 100644 index 0000000000000..be7eb40cbcc6a --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.es.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.fr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.fr.xlf new file mode 100644 index 0000000000000..2786f5abb593f --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.it.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.it.xlf new file mode 100644 index 0000000000000..9c1625bef17d4 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.it.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ja.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ja.xlf new file mode 100644 index 0000000000000..7ce69a38361d6 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ko.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ko.xlf new file mode 100644 index 0000000000000..28f5ec6d15843 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.pl.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.pl.xlf new file mode 100644 index 0000000000000..74fd33d1db1d1 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.pt-BR.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.pt-BR.xlf new file mode 100644 index 0000000000000..6a67c820be8e2 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ru.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ru.xlf new file mode 100644 index 0000000000000..557dcf343e960 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.tr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.tr.xlf new file mode 100644 index 0000000000000..349f8edfe77d3 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.zh-Hans.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.zh-Hans.xlf new file mode 100644 index 0000000000000..694669fddab38 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.zh-Hant.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.zh-Hant.xlf new file mode 100644 index 0000000000000..c4c842ae81855 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/xlf/VisualBasicCompilerExtensionsResources.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems index ff10cf43f47de..e18f6f3029e26 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems @@ -80,4 +80,7 @@ + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensionsResources.resx b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensionsResources.resx new file mode 100644 index 0000000000000..98c8b413e306f --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensionsResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Expected string or char literal + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTreeExtensions.cs index d89ef0814370b..7ffcb0218e973 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTreeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/SyntaxTreeExtensions.cs @@ -381,7 +381,7 @@ private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int { if (!token.IsKind(SyntaxKind.StringLiteralToken, SyntaxKind.CharacterLiteralToken)) { - throw new ArgumentException(Resources.Expected_string_or_char_literal, nameof(token)); + throw new ArgumentException(CSharpWorkspaceExtensionsResources.Expected_string_or_char_literal, nameof(token)); } var startLength = 1; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.cs.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.cs.xlf new file mode 100644 index 0000000000000..f37688ced355b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.de.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.de.xlf new file mode 100644 index 0000000000000..d3edde46bc024 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.de.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.es.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.es.xlf new file mode 100644 index 0000000000000..293d2f31c9dc4 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.es.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.fr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.fr.xlf new file mode 100644 index 0000000000000..f6aa157316b24 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.it.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.it.xlf new file mode 100644 index 0000000000000..8580d0ab503e5 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.it.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ja.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ja.xlf new file mode 100644 index 0000000000000..fdd115883dd17 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ko.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ko.xlf new file mode 100644 index 0000000000000..93cdb0507618c --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.pl.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.pl.xlf new file mode 100644 index 0000000000000..562e7f938e7b2 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.pt-BR.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.pt-BR.xlf new file mode 100644 index 0000000000000..b4d9d2e6aca63 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ru.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ru.xlf new file mode 100644 index 0000000000000..207d9439daf4d --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.tr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.tr.xlf new file mode 100644 index 0000000000000..4276f51ba0bc8 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.zh-Hans.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.zh-Hans.xlf new file mode 100644 index 0000000000000..955fe5ef65453 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.zh-Hant.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.zh-Hant.xlf new file mode 100644 index 0000000000000..585950702a808 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/xlf/CSharpWorkspaceExtensionsResources.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Expected string or char literal + Expected string or char literal + + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems index 209c9a5e3a99d..72f10c024895b 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems @@ -87,4 +87,7 @@ + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensionsResources.resx b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensionsResources.resx new file mode 100644 index 0000000000000..14ed010cf9ebb --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensionsResources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.cs.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.cs.xlf new file mode 100644 index 0000000000000..e84bab9f14f74 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.de.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.de.xlf new file mode 100644 index 0000000000000..d564284df4ee6 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.de.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.es.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.es.xlf new file mode 100644 index 0000000000000..f48a453decf3c --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.es.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.fr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.fr.xlf new file mode 100644 index 0000000000000..3428c9e318143 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.it.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.it.xlf new file mode 100644 index 0000000000000..846ab0e508a37 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.it.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ja.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ja.xlf new file mode 100644 index 0000000000000..c38f0d60a252c --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ko.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ko.xlf new file mode 100644 index 0000000000000..cd7b21b945295 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.pl.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.pl.xlf new file mode 100644 index 0000000000000..0d6dd768c9182 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.pt-BR.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.pt-BR.xlf new file mode 100644 index 0000000000000..24b4456d434d7 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ru.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ru.xlf new file mode 100644 index 0000000000000..80fe469af388a --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.tr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.tr.xlf new file mode 100644 index 0000000000000..4c4273ed41ba9 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.zh-Hans.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.zh-Hans.xlf new file mode 100644 index 0000000000000..c4fb3ffde5fe3 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.zh-Hant.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.zh-Hant.xlf new file mode 100644 index 0000000000000..39b1ddf3ede83 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/xlf/WorkspaceExtensionsResources.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems index 81545c5e5aadb..eb468df823e3e 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems @@ -88,4 +88,7 @@ + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensionsResources.resx b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensionsResources.resx new file mode 100644 index 0000000000000..14ed010cf9ebb --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensionsResources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.cs.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.cs.xlf new file mode 100644 index 0000000000000..b3e07b4269548 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.cs.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.de.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.de.xlf new file mode 100644 index 0000000000000..bf424db27a3ca --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.de.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.es.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.es.xlf new file mode 100644 index 0000000000000..07d1946c8d89b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.es.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.fr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.fr.xlf new file mode 100644 index 0000000000000..32ca3e5240be0 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.fr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.it.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.it.xlf new file mode 100644 index 0000000000000..d9820d5714245 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.it.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ja.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ja.xlf new file mode 100644 index 0000000000000..a15a700fe4aba --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ja.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ko.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ko.xlf new file mode 100644 index 0000000000000..4ddb966c5597b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ko.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.pl.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.pl.xlf new file mode 100644 index 0000000000000..dfe0a59d4e67b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.pl.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.pt-BR.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.pt-BR.xlf new file mode 100644 index 0000000000000..9df7a49298777 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.pt-BR.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ru.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ru.xlf new file mode 100644 index 0000000000000..7ecc3a2f20862 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.ru.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.tr.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.tr.xlf new file mode 100644 index 0000000000000..428070411396b --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.tr.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.zh-Hans.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.zh-Hans.xlf new file mode 100644 index 0000000000000..523683b18b013 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.zh-Hans.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.zh-Hant.xlf b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.zh-Hant.xlf new file mode 100644 index 0000000000000..d9e90c0ce72f3 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/xlf/VisualBasicWorkspaceExtensionsResources.zh-Hant.xlf @@ -0,0 +1,12 @@ + + + + + + Remove this value when another is added. + Remove this value when another is added. + https://github.com/Microsoft/msbuild/issues/1661 + + + + \ No newline at end of file diff --git a/src/Workspaces/VisualBasic/Portable/CodeStyle/VisualBasicCodeStyleOptions.vb b/src/Workspaces/VisualBasic/Portable/CodeStyle/VisualBasicCodeStyleOptions.vb index 1a80daff06074..5c5691b6b4575 100644 --- a/src/Workspaces/VisualBasic/Portable/CodeStyle/VisualBasicCodeStyleOptions.vb +++ b/src/Workspaces/VisualBasic/Portable/CodeStyle/VisualBasicCodeStyleOptions.vb @@ -56,7 +56,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeStyle End Class Friend NotInheritable Class VisualBasicCodeStyleOptionGroups - Public Shared ReadOnly Modifier As New OptionGroup(WorkspacesResources.Modifier_preferences, priority:=1) - Public Shared ReadOnly ExpressionLevelPreferences As New OptionGroup(WorkspacesResources.Expression_level_preferences, priority:=2) + Public Shared ReadOnly Modifier As New OptionGroup(CompilerExtensionsResources.Modifier_preferences, priority:=1) + Public Shared ReadOnly ExpressionLevelPreferences As New OptionGroup(CompilerExtensionsResources.Expression_level_preferences, priority:=2) End Class End Namespace From 1e1b9a7ed9dced6ce41aa5bbc87cbfcde2c0bdca Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 12 Feb 2020 13:11:12 -0800 Subject: [PATCH 24/26] Revert some unrelated changes --- .../UseImplicitTypeTests_FixAllTests.cs | 1 + .../AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs | 1 - .../Core/Analyzers/Options/AnalyzerOptionsExtensions.cs | 2 +- .../CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs | 2 +- .../AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs | 1 + .../TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs | 1 + src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs | 3 --- src/Workspaces/Core/Portable/Options/OptionKey.cs | 3 --- .../VisualBasic/Extensions/ExpressionSyntaxExtensions.vb | 1 - .../LanguageServices/VisualBasicPrecedenceService.vb | 1 - .../LanguageServices/VisualBasicSemanticFactsService.vb | 2 -- .../Workspace/VisualBasic/Utilities/SpeculationAnalyzer.vb | 4 ---- .../Portable/Formatting/DefaultOperationProvider.vb | 1 + 13 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs index 6db867339450d..403bb3d92984d 100644 --- a/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs +++ b/src/Analyzers/CSharp/Tests/UseImplicitOrExplicitType/UseImplicitTypeTests_FixAllTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; diff --git a/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs index f972fc0498de3..86fbd5abddd0c 100644 --- a/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs @@ -17,7 +17,6 @@ namespace Microsoft.CodeAnalysis.RemoveUnusedMembers { - internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer : AbstractCodeQualityDiagnosticAnalyzer where TDocumentationCommentTriviaSyntax : SyntaxNode diff --git a/src/CodeStyle/Core/Analyzers/Options/AnalyzerOptionsExtensions.cs b/src/CodeStyle/Core/Analyzers/Options/AnalyzerOptionsExtensions.cs index 149dff0bc7c79..ba085918e9776 100644 --- a/src/CodeStyle/Core/Analyzers/Options/AnalyzerOptionsExtensions.cs +++ b/src/CodeStyle/Core/Analyzers/Options/AnalyzerOptionsExtensions.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Diagnostics { internal static partial class AnalyzerOptionsExtensions { - public static AnalyzerConfigOptions GetOptions(this AnalyzerOptions analyzerOptions, SyntaxTree syntaxTree, CancellationToken _) + public static AnalyzerConfigOptions GetOptions(this AnalyzerOptions analyzerOptions, SyntaxTree syntaxTree, CancellationToken cancellationToken) => analyzerOptions.AnalyzerConfigOptionsProvider.GetOptions(syntaxTree); } } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs index fb45c46132e21..6d1336c2a9e31 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractLocalFunctionTests.cs @@ -904,7 +904,7 @@ static void NewMethod(out Construct obj1, out Construct obj2, out Construct obj3 }", CodeActionIndex); } - [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsExtractLocalFunction), CompilerTrait(CompilerFeature.Tuples)] public async Task TestTuple() { await TestInRegularAndScriptAsync( diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs index 90b6c2b7629ac..d57e439688a90 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.UnitTests.Diagnostics; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs index b5c66af8d27f6..65546b73a0645 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Xml.Linq; +using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces diff --git a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs b/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs index 76945d4e385fa..4147259ea812b 100644 --- a/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs +++ b/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs @@ -15,9 +15,6 @@ namespace Microsoft.CodeAnalysis.Internal.Options namespace Microsoft.CodeAnalysis.CodeStyle #endif { - /// - /// Code style options - /// public class CodeStyleOptions { private static readonly ImmutableArray.Builder s_allOptionsBuilder = ImmutableArray.CreateBuilder(); diff --git a/src/Workspaces/Core/Portable/Options/OptionKey.cs b/src/Workspaces/Core/Portable/Options/OptionKey.cs index 4f1a22559a773..34730dc6538a7 100644 --- a/src/Workspaces/Core/Portable/Options/OptionKey.cs +++ b/src/Workspaces/Core/Portable/Options/OptionKey.cs @@ -14,9 +14,6 @@ namespace Microsoft.CodeAnalysis.Internal.Options namespace Microsoft.CodeAnalysis.Options #endif { - /// - /// Option key. - /// public readonly struct OptionKey : IEquatable { public IOption Option { get; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb index aa3f472821d6a..ace041bdc6f1b 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb @@ -12,7 +12,6 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Imports Microsoft.CodeAnalysis.VisualBasic.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions - Friend Module ExpressionSyntaxExtensions Public ReadOnly typeNameFormatWithGenerics As New SymbolDisplayFormat( diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicPrecedenceService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicPrecedenceService.vb index a11d35f955896..a893263fdbffc 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicPrecedenceService.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicPrecedenceService.vb @@ -5,7 +5,6 @@ Imports System.Composition Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageServices -Imports Microsoft.CodeAnalysis.VisualBasic.Extensions Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSemanticFactsService.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSemanticFactsService.vb index 9b17812814c22..23a07a8e30c36 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSemanticFactsService.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSemanticFactsService.vb @@ -10,8 +10,6 @@ Imports Microsoft.CodeAnalysis.Host Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageServices Imports Microsoft.CodeAnalysis.PooledObjects -Imports Microsoft.CodeAnalysis.Shared.Extensions -Imports Microsoft.CodeAnalysis.VisualBasic.Extensions Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery Imports Microsoft.CodeAnalysis.VisualBasic.Syntax diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SpeculationAnalyzer.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SpeculationAnalyzer.vb index 51f6810f1b189..20b897c4e0cc3 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SpeculationAnalyzer.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Utilities/SpeculationAnalyzer.vb @@ -4,11 +4,7 @@ Imports System.Collections.Immutable Imports System.Threading -Imports Microsoft.CodeAnalysis.VisualBasic.Extensions Imports Microsoft.CodeAnalysis.VisualBasic.Syntax -Imports Microsoft.CodeAnalysis.Shared.Extensions -Imports Microsoft.CodeAnalysis.Shared.Utilities -Imports Roslyn.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities ''' diff --git a/src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb b/src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb index de4b5f0b42cf6..2b98425f79e01 100644 --- a/src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb +++ b/src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb @@ -3,6 +3,7 @@ ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting.Rules Imports Microsoft.CodeAnalysis.VisualBasic.Syntax From fee840fff2ac64b68984456ae6c840b9e4e05153 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 12 Feb 2020 13:26:47 -0800 Subject: [PATCH 25/26] Make analyzer diagnostics in CodeStyle layer be warnings by default. --- .../Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs | 9 ++++++++- .../Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs index 87213aa4bd507..96b0f76a65c5c 100644 --- a/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs @@ -15,6 +15,13 @@ namespace Microsoft.CodeAnalysis.CodeQuality internal abstract class AbstractCodeQualityDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer { + // Diagnostics in CodeStyle layer should be warnings by default. +#if CODE_STYLE + private const DiagnosticSeverity DefaultSeverity = DiagnosticSeverity.Warning; +#else + private const DiagnosticSeverity DefaultSeverity = DiagnosticSeverity.Info; +#endif + private readonly GeneratedCodeAnalysisFlags _generatedCodeAnalysisFlags; protected AbstractCodeQualityDiagnosticAnalyzer( @@ -54,7 +61,7 @@ protected static DiagnosticDescriptor CreateDescriptor( => new DiagnosticDescriptor( id, title, messageFormat, DiagnosticCategory.CodeQuality, - DiagnosticSeverity.Info, + DefaultSeverity, isEnabledByDefault, description, customTags: DiagnosticCustomTags.Create(isUnneccessary, isConfigurable, customTags)); diff --git a/src/Analyzers/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs index 43d61fbbadbef..69f35b0f840a7 100644 --- a/src/Analyzers/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/AbstractCodeStyleDiagnosticAnalyzer.cs @@ -9,6 +9,13 @@ namespace Microsoft.CodeAnalysis.CodeStyle { internal abstract class AbstractCodeStyleDiagnosticAnalyzer : DiagnosticAnalyzer { + // Diagnostics in CodeStyle layer should be warnings by default. +#if CODE_STYLE + private const DiagnosticSeverity DefaultSeverity = DiagnosticSeverity.Warning; +#else + private const DiagnosticSeverity DefaultSeverity = DiagnosticSeverity.Hidden; +#endif + protected readonly string DescriptorId; protected readonly DiagnosticDescriptor Descriptor; @@ -88,7 +95,7 @@ protected static DiagnosticDescriptor CreateDescriptorWithId( => new DiagnosticDescriptor( id, title, messageFormat, DiagnosticCategory.Style, - DiagnosticSeverity.Hidden, + !isUnneccessary ? DefaultSeverity : DiagnosticSeverity.Hidden, isEnabledByDefault: true, description: description, customTags: DiagnosticCustomTags.Create(isUnneccessary, isConfigurable, customTags)); From d22e50c2ff238d2cb75a015d61a03ab147eefc51 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Wed, 12 Feb 2020 13:31:06 -0800 Subject: [PATCH 26/26] Add comment --- .../Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs index 96b0f76a65c5c..3594b9219eef9 100644 --- a/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs @@ -13,6 +13,7 @@ namespace Microsoft.CodeAnalysis.CodeQuality using OptionSet = Options.OptionSet; #endif + // Consider moving all the CodeQuality diagnostic analyzers into analyzer repo as CA rules. internal abstract class AbstractCodeQualityDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer { // Diagnostics in CodeStyle layer should be warnings by default.