From 4df36d229964be229030f729e812c6205c487bce Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 24 Sep 2020 00:21:31 -0700 Subject: [PATCH] Use implicit object creation in VS layer. --- .../InternalUtilities/ConcurrentLruCache.cs | 2 +- .../VisualStudioExperimentationService.cs | 2 +- .../UnitTestingRemoteHostOptionsAccessor.cs | 2 +- src/VisualStudio/Core/Def/Guids.cs | 54 +++++++++---------- .../Core/Def/ID.InteractiveCommands.cs | 4 +- .../AnalyzerDependencyCheckingService.cs | 10 ++-- .../AnalyzerDependencyResults.cs | 2 +- .../AnalyzerFileWatcherService.cs | 10 ++-- .../CallHierarchy/CallHierarchyItem.cs | 6 +-- .../Finders/AbstractCallFinder.cs | 2 +- .../AddParameterDialog.xaml.cs | 2 +- .../AddParameterDialogViewModel.cs | 2 +- .../ChangeSignatureDialog.xaml.cs | 2 +- .../ChangeSignatureDialogViewModel.cs | 8 +-- ...lorSchemeApplier.ClassificationVerifier.cs | 2 +- .../ColorSchemeApplier.ColorSchemeReader.cs | 2 +- .../ContainedLanguageRefactorNotifyService.cs | 2 +- ...DebuggerTextView.HACK_CompletionSession.cs | 2 +- .../VisualStudioDesignerAttributeService.cs | 2 +- .../Diagnostics/DiagnosticProgressReporter.cs | 2 +- .../EditAndContinue/DebuggerComponent.cs | 4 +- .../EditAndContinue/ModuleUtilities.cs | 6 +-- ...ualStudioDebuggeeModuleMetadataProvider.cs | 2 +- ...VisualStudioManagedModuleUpdateProvider.cs | 2 +- .../KeybindingResetDetector.cs | 6 +-- .../Experimentation/KeybindingResetOptions.cs | 6 +-- .../VisualStudioWorkspaceImplExtensions.cs | 2 +- .../ExtractInterfaceDialog.xaml.cs | 2 +- .../F1Help/AbstractHelpContextService.cs | 6 +-- ...bstractTableDataSourceFindUsagesContext.cs | 8 +-- .../FindReferences/FindUsagesOptions.cs | 2 +- .../StreamingFindUsagesPresenter.cs | 2 +- .../GenerateType/GenerateTypeDialog.xaml.cs | 2 +- .../CSharpResetInteractiveMenuCommand.cs | 2 +- .../VisualBasicResetInteractiveMenuCommand.cs | 2 +- .../LanguageClient/InProcLanguageServer.cs | 6 +-- ...vice`2.IVsImmediateStatementCompletion2.cs | 2 +- .../AbstractDescriptionBuilder.cs | 2 +- .../ObjectBrowser/AbstractListItemFactory.cs | 14 ++--- .../AbstractObjectBrowserLibraryManager.cs | 2 +- .../Library/ObjectBrowser/Extensions.cs | 4 +- .../Def/Implementation/Log/LoggerOptions.cs | 6 +-- .../MoveToNamespaceDialog.xaml.cs | 2 +- ...sualStudioMoveToNamespaceOptionsService.cs | 2 +- ...alStudioNavigateToPreviewServiceFactory.cs | 2 +- .../NavigationBar/NavigationBarClient.cs | 2 +- .../VSNotificationServiceFactory.cs | 2 +- .../LocalUserRegistryOptionPersister.cs | 2 +- ...amingVisualStudioProfileOptionPersister.cs | 4 +- .../PickMembers/PickMembersDialog.xaml.cs | 2 +- .../Def/Implementation/Preview/ChangeList.cs | 2 +- .../PreviewPane/PreviewPane.xaml.cs | 2 +- .../Progression/GraphBuilder.cs | 10 ++-- .../Progression/GraphProvider.cs | 8 +-- .../Progression/GraphQueryManager.cs | 4 +- .../DefaultProjectInfoServiceFactory.cs | 2 +- .../ProjectSystem/AbstractEntryPointFinder.cs | 2 +- ...yzerConfigDocumentAsSolutionItemHandler.cs | 2 +- .../ProjectSystem/FileChangeTracker.cs | 4 +- .../ProjectSystem/FileChangeWatcher.cs | 8 +-- .../FileChangeWatcherProvider.cs | 2 +- .../Legacy/AbstractLegacyProject.cs | 2 +- .../AbstractLegacyProject_IProjectSiteEx.cs | 2 +- ...tchedPortableExecutableReferenceFactory.cs | 6 +-- ...oMetadataReferenceManager.MetadataCache.cs | 4 +- .../VisualStudioMetadataReferenceManager.cs | 6 +-- .../MiscellaneousFilesWorkspace.cs | 2 +- .../VisualStudioRuleSetManager.RuleSetFile.cs | 2 +- .../RuleSets/VisualStudioRuleSetManager.cs | 2 +- .../SolutionChangeAccumulator.cs | 2 +- .../VisualStudioAddSolutionItemService.cs | 2 +- .../ProjectSystem/VisualStudioAnalyzer.cs | 2 +- .../VisualStudioMefHostServices.cs | 2 +- .../ProjectSystem/VisualStudioProject.cs | 32 +++++------ .../VisualStudioProjectOptionsProcessor.cs | 2 +- .../VisualStudioProjectTracker.cs | 2 +- ...sualStudioWorkspaceImpl.OpenFileTracker.cs | 6 +-- .../VisualStudioWorkspaceImpl.cs | 18 +++---- .../Snippets/AbstractSnippetInfoService.cs | 2 +- ...tractTableControlEventProcessorProvider.cs | 2 +- .../TableDataSource/DiagnosticTableItem.cs | 4 +- .../TableDataSource/OpenDocumentTracker.cs | 4 +- .../TableDataSource/TableEntriesFactory.cs | 4 +- .../TableDataSource/TodoTableItem.cs | 4 +- .../TableDataSource/ValueTypeCache.cs | 4 +- ...iagnosticListTable.BuildTableDataSource.cs | 2 +- .../ExternalErrorDiagnosticUpdateSource.cs | 20 +++---- .../TaskList/HostDiagnosticUpdateSource.cs | 4 +- .../VisualStudioTodoCommentsService.cs | 4 +- .../Utilities/SymbolViewModel.cs | 4 +- ...ntainedDocument.DocumentServiceProvider.cs | 2 +- .../Implementation/Venus/ContainedDocument.cs | 4 +- .../Implementation/Watson/WatsonReporter.cs | 2 +- .../Workspace/SourceGeneratedFileManager.cs | 4 +- ...ualStudioDocumentTrackingServiceFactory.cs | 2 +- .../VisualStudioNavigationOptions.cs | 2 +- ...ualStudioProjectCacheHostServiceFactory.cs | 2 +- ...sualStudioWorkspaceStatusServiceFactory.cs | 2 +- .../PackageInstallerService.ProjectState.cs | 2 +- .../PackageInstallerServiceFactory.cs | 4 +- .../Core/Def/RoslynActivityLogger.cs | 2 +- .../Shared/VisualStudioImageMonikerService.cs | 2 +- .../Core/Def/SolutionEventMonitor.cs | 2 +- .../AbstractDelayStartedService.cs | 2 +- ...ualStudioSymbolSearchService.LogService.cs | 2 +- .../VisualStudioSymbolSearchService.cs | 2 +- .../Core/Def/Telemetry/CodeMarkerLogger.cs | 6 +-- .../Core/Def/Telemetry/VSTelemetryCache.cs | 4 +- 108 files changed, 237 insertions(+), 237 deletions(-) diff --git a/src/Compilers/Core/Portable/InternalUtilities/ConcurrentLruCache.cs b/src/Compilers/Core/Portable/InternalUtilities/ConcurrentLruCache.cs index a5925685681..d6653ae287d 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/ConcurrentLruCache.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/ConcurrentLruCache.cs @@ -30,7 +30,7 @@ private struct CacheValue private readonly Dictionary _cache; private readonly LinkedList _nodeList; // This is a naive course-grained lock, it can probably be optimized - private readonly object _lockObject = new object(); + private readonly object _lockObject = new(); public ConcurrentLruCache(int capacity) { diff --git a/src/VisualStudio/Core/Def/Experimentation/VisualStudioExperimentationService.cs b/src/VisualStudio/Core/Def/Experimentation/VisualStudioExperimentationService.cs index f425d79ab7a..08f3ef993f1 100644 --- a/src/VisualStudio/Core/Def/Experimentation/VisualStudioExperimentationService.cs +++ b/src/VisualStudio/Core/Def/Experimentation/VisualStudioExperimentationService.cs @@ -27,7 +27,7 @@ internal class VisualStudioExperimentationService : ForegroundThreadAffinitizedO /// lifetime of the session, so it's fine for us to cache things to avoid the heavy cost of querying for them /// over and over. /// - private readonly Dictionary _experimentEnabledMap = new Dictionary(); + private readonly Dictionary _experimentEnabledMap = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/VisualStudio/Core/Def/ExternalAccess/UnitTesting/Api/UnitTestingRemoteHostOptionsAccessor.cs b/src/VisualStudio/Core/Def/ExternalAccess/UnitTesting/Api/UnitTestingRemoteHostOptionsAccessor.cs index 84a7c1bbc25..6faf0fc50f3 100644 --- a/src/VisualStudio/Core/Def/ExternalAccess/UnitTesting/Api/UnitTestingRemoteHostOptionsAccessor.cs +++ b/src/VisualStudio/Core/Def/ExternalAccess/UnitTesting/Api/UnitTestingRemoteHostOptionsAccessor.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api { internal static class UnitTestingRemoteHostOptionsAccessor { - public static Option OOP64Bit => new Option( + public static Option OOP64Bit => new( RemoteHostOptions.OOP64Bit.Feature, RemoteHostOptions.OOP64Bit.Name, defaultValue: RemoteHostOptions.OOP64Bit.DefaultValue, storageLocations: RemoteHostOptions.OOP64Bit.StorageLocations.ToArray()); } diff --git a/src/VisualStudio/Core/Def/Guids.cs b/src/VisualStudio/Core/Def/Guids.cs index 826cf7ab983..71e58c8b019 100644 --- a/src/VisualStudio/Core/Def/Guids.cs +++ b/src/VisualStudio/Core/Def/Guids.cs @@ -37,25 +37,25 @@ internal static class Guids /// A that is set if there is a C# project in the . /// public const string CSharpProjectExistsInWorkspaceUIContextString = "CA719A03-D55C-48F9-85DE-D934346E7F70"; - public static readonly Guid CSharpProjectExistsInWorkspaceUIContext = new Guid(CSharpProjectExistsInWorkspaceUIContextString); + public static readonly Guid CSharpProjectExistsInWorkspaceUIContext = new(CSharpProjectExistsInWorkspaceUIContextString); public const string CSharpProjectRootIdString = "C7FEDB89-B36D-4a62-93F4-DC7A95999921"; // from debugger\idl\makeapi\guid.c public const string CSharpDebuggerLanguageIdString = "3f5162f8-07c6-11d3-9053-00c04fa302a1"; - public static readonly Guid CSharpPackageId = new Guid(CSharpPackageIdString); - public static readonly Guid CSharpProjectId = new Guid(CSharpProjectIdString); - public static readonly Guid CSharpLanguageServiceId = new Guid(CSharpLanguageServiceIdString); - public static readonly Guid CSharpEditorFactoryId = new Guid(CSharpEditorFactoryIdString); - public static readonly Guid CSharpCodePageEditorFactoryId = new Guid(CSharpCodePageEditorFactoryIdString); - public static readonly Guid CSharpCommandSetId = new Guid(CSharpCommandSetIdString); // guidCSharpCmdId - public static readonly Guid CSharpGroupId = new Guid(CSharpGroupIdString); // guidCSharpGrpId - public static readonly Guid CSharpRefactorIconId = new Guid(CSharpRefactorIconIdString); // guidCSharpRefactorIcon - public static readonly Guid CSharpGenerateIconId = new Guid(CSharpGenerateIconIdString); // guidCSharpGenerateIcon - public static readonly Guid CSharpOrganizeIconId = new Guid(CSharpOrganizeIconIdString); // guidCSharpOrganizeIcon - public static readonly Guid CSharpDebuggerLanguageId = new Guid(CSharpDebuggerLanguageIdString); - public static readonly Guid CSharpLibraryId = new Guid(CSharpLibraryIdString); + public static readonly Guid CSharpPackageId = new(CSharpPackageIdString); + public static readonly Guid CSharpProjectId = new(CSharpProjectIdString); + public static readonly Guid CSharpLanguageServiceId = new(CSharpLanguageServiceIdString); + public static readonly Guid CSharpEditorFactoryId = new(CSharpEditorFactoryIdString); + public static readonly Guid CSharpCodePageEditorFactoryId = new(CSharpCodePageEditorFactoryIdString); + public static readonly Guid CSharpCommandSetId = new(CSharpCommandSetIdString); // guidCSharpCmdId + public static readonly Guid CSharpGroupId = new(CSharpGroupIdString); // guidCSharpGrpId + public static readonly Guid CSharpRefactorIconId = new(CSharpRefactorIconIdString); // guidCSharpRefactorIcon + public static readonly Guid CSharpGenerateIconId = new(CSharpGenerateIconIdString); // guidCSharpGenerateIcon + public static readonly Guid CSharpOrganizeIconId = new(CSharpOrganizeIconIdString); // guidCSharpOrganizeIcon + public static readonly Guid CSharpDebuggerLanguageId = new(CSharpDebuggerLanguageIdString); + public static readonly Guid CSharpLibraryId = new(CSharpLibraryIdString); // option page guids from csharp\rad\pkg\guids.h public const string CSharpOptionPageAdvancedIdString = "8FD0B177-B244-4A97-8E37-6FB7B27DE3AF"; @@ -88,19 +88,19 @@ internal static class Guids /// A that is set if there is a Visual Basic project in the . /// public const string VisualBasicProjectExistsInWorkspaceUIContextString = "EEC3DF0D-6D3F-4544-ABF9-8E26E6A90275"; - public static readonly Guid VisualBasicProjectExistsInWorkspaceUIContext = new Guid(VisualBasicProjectExistsInWorkspaceUIContextString); + public static readonly Guid VisualBasicProjectExistsInWorkspaceUIContext = new(VisualBasicProjectExistsInWorkspaceUIContextString); - public static readonly Guid VisualBasicPackageId = new Guid(VisualBasicPackageIdString); - public static readonly Guid VisualBasicCompilerServiceId = new Guid(VisualBasicCompilerServiceIdString); - public static readonly Guid VisualBasicLanguageServiceId = new Guid(VisualBasicLanguageServiceIdString); - public static readonly Guid VisualBasicEditorFactoryId = new Guid(VisualBasicEditorFactoryIdString); - public static readonly Guid VisualBasicCodePageEditorFactoryId = new Guid(VisualBasicCodePageEditorFactoryIdString); - public static readonly Guid VisualBasicLibraryId = new Guid(VisualBasicLibraryIdString); + public static readonly Guid VisualBasicPackageId = new(VisualBasicPackageIdString); + public static readonly Guid VisualBasicCompilerServiceId = new(VisualBasicCompilerServiceIdString); + public static readonly Guid VisualBasicLanguageServiceId = new(VisualBasicLanguageServiceIdString); + public static readonly Guid VisualBasicEditorFactoryId = new(VisualBasicEditorFactoryIdString); + public static readonly Guid VisualBasicCodePageEditorFactoryId = new(VisualBasicCodePageEditorFactoryIdString); + public static readonly Guid VisualBasicLibraryId = new(VisualBasicLibraryIdString); - public static readonly Guid VisualBasicProjectId = new Guid(VisualBasicProjectIdString); + public static readonly Guid VisualBasicProjectId = new(VisualBasicProjectIdString); // from debugger\idl\makeapi\guid.c - public static readonly Guid VisualBasicDebuggerLanguageId = new Guid(VisualBasicDebuggerLanguageIdString); + public static readonly Guid VisualBasicDebuggerLanguageId = new(VisualBasicDebuggerLanguageIdString); // option page guid from setupauthoring\vb\components\vblanguageservice.pkgdef public const string VisualBasicOptionPageVBSpecificIdString = "F1E1021E-A781-4862-9F4B-88746A288A67"; @@ -109,7 +109,7 @@ internal static class Guids public const string FSharpPackageIdString = "871D2A70-12A2-4e42-9440-425DD92A4116"; - public static readonly Guid FSharpPackageId = new Guid(FSharpPackageIdString); + public static readonly Guid FSharpPackageId = new(FSharpPackageIdString); // from vscommon\inc\textmgruuids.h public const string TextManagerPackageString = "F5E7E720-1401-11D1-883B-0000F87579D2"; @@ -127,13 +127,13 @@ internal static class Guids public const string RoslynOptionPageInternalSolutionCrawlerIdString = "9702D3BD-F06C-4A6A-974B-7D0C2BC89A72"; public const string RoslynOptionPageExperimentationIdString = "D5AA7ED7-85E2-42A0-9BF6-22AEF1C1ED8C"; - public static readonly Guid RoslynPackageId = new Guid(RoslynPackageIdString); - public static readonly Guid RoslynCommandSetId = new Guid(RoslynCommandSetIdString); - public static readonly Guid RoslynGroupId = new Guid(RoslynGroupIdString); + public static readonly Guid RoslynPackageId = new(RoslynPackageIdString); + public static readonly Guid RoslynCommandSetId = new(RoslynCommandSetIdString); + public static readonly Guid RoslynGroupId = new(RoslynGroupIdString); // TODO: Remove pending https://github.com/dotnet/roslyn/issues/8927 . // Interactive guids public const string InteractiveCommandSetIdString = "00B8868B-F9F5-4970-A048-410B05508506"; - public static readonly Guid InteractiveCommandSetId = new Guid(InteractiveCommandSetIdString); + public static readonly Guid InteractiveCommandSetId = new(InteractiveCommandSetIdString); } } diff --git a/src/VisualStudio/Core/Def/ID.InteractiveCommands.cs b/src/VisualStudio/Core/Def/ID.InteractiveCommands.cs index a08a9d3160a..60ce0f5c68d 100644 --- a/src/VisualStudio/Core/Def/ID.InteractiveCommands.cs +++ b/src/VisualStudio/Core/Def/ID.InteractiveCommands.cs @@ -17,10 +17,10 @@ internal static class InteractiveCommands public const int ExecuteInInteractiveWindow = 0x0010C; public const string CSharpInteractiveCommandSetIdString = "1492DB0A-85A2-4E43-BF0D-CE55B89A8CC6"; - public static readonly Guid CSharpInteractiveCommandSetId = new Guid(CSharpInteractiveCommandSetIdString); + public static readonly Guid CSharpInteractiveCommandSetId = new(CSharpInteractiveCommandSetIdString); public const string VisualBasicInteractiveCommandSetIdString = "93DF185E-D75B-4FDB-9D47-E90F111971C5"; - public static readonly Guid VisualBasicInteractiveCommandSetId = new Guid(VisualBasicInteractiveCommandSetIdString); + public static readonly Guid VisualBasicInteractiveCommandSetId = new(VisualBasicInteractiveCommandSetIdString); } } } diff --git a/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerDependencyCheckingService.cs b/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerDependencyCheckingService.cs index b367314358f..8fbe2c8bd8e 100644 --- a/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerDependencyCheckingService.cs +++ b/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerDependencyCheckingService.cs @@ -24,7 +24,7 @@ internal sealed class AnalyzerDependencyCheckingService /// /// Object given as key for . /// - private static readonly object s_dependencyConflictErrorId = new object(); + private static readonly object s_dependencyConflictErrorId = new(); private static readonly IIgnorableAssemblyList s_systemPrefixList = new IgnorableAssemblyNamePrefixList("System"); private static readonly IIgnorableAssemblyList s_codeAnalysisPrefixList = new IgnorableAssemblyNamePrefixList("Microsoft.CodeAnalysis"); private static readonly IIgnorableAssemblyList s_explicitlyIgnoredAssemblyList = new IgnorableAssemblyIdentityList(GetExplicitlyIgnoredAssemblyIdentities()); @@ -37,8 +37,8 @@ internal sealed class AnalyzerDependencyCheckingService /// /// Object given to synchronize access to the mutable fields in this class. /// - private readonly object _gate = new object(); - private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); + private readonly object _gate = new(); + private CancellationTokenSource _cancellationTokenSource = new(); /// /// The most recently started analysis task; if we start a new analysis we will cancel the previous one and start the next one @@ -47,7 +47,7 @@ internal sealed class AnalyzerDependencyCheckingService private Task _task = Task.CompletedTask; private ImmutableHashSet _previousAnalyzerPaths = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase); - private static readonly DiagnosticDescriptor s_missingAnalyzerReferenceRule = new DiagnosticDescriptor( + private static readonly DiagnosticDescriptor s_missingAnalyzerReferenceRule = new( id: IDEDiagnosticIds.MissingAnalyzerReferenceId, title: ServicesVSResources.MissingAnalyzerReference, messageFormat: ServicesVSResources.Analyzer_assembly_0_depends_on_1_but_it_was_not_found_Analyzers_may_not_run_correctly_unless_the_missing_assembly_is_added_as_an_analyzer_reference_as_well, @@ -55,7 +55,7 @@ internal sealed class AnalyzerDependencyCheckingService defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true); - private static readonly DiagnosticDescriptor s_analyzerDependencyConflictRule = new DiagnosticDescriptor( + private static readonly DiagnosticDescriptor s_analyzerDependencyConflictRule = new( id: IDEDiagnosticIds.AnalyzerDependencyConflictId, title: ServicesVSResources.AnalyzerDependencyConflict, messageFormat: ServicesVSResources.Analyzer_assemblies_0_and_1_both_have_identity_2_but_different_contents_Only_one_will_be_loaded_and_analyzers_using_these_assemblies_may_not_run_correctly, diff --git a/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerDependencyResults.cs b/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerDependencyResults.cs index 8224ed8040c..5f6b12f5868 100644 --- a/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerDependencyResults.cs +++ b/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerDependencyResults.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation { internal sealed class AnalyzerDependencyResults { - public static readonly AnalyzerDependencyResults Empty = new AnalyzerDependencyResults(ImmutableArray.Empty, ImmutableArray.Empty); + public static readonly AnalyzerDependencyResults Empty = new(ImmutableArray.Empty, ImmutableArray.Empty); public AnalyzerDependencyResults(ImmutableArray conflicts, ImmutableArray missingDependencies) { diff --git a/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerFileWatcherService.cs b/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerFileWatcherService.cs index 358a74fc215..7567b0390a7 100644 --- a/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerFileWatcherService.cs +++ b/src/VisualStudio/Core/Def/Implementation/AnalyzerDependency/AnalyzerFileWatcherService.cs @@ -23,23 +23,23 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation [Export(typeof(AnalyzerFileWatcherService))] internal sealed class AnalyzerFileWatcherService { - private static readonly object s_analyzerChangedErrorId = new object(); + private static readonly object s_analyzerChangedErrorId = new(); private readonly VisualStudioWorkspaceImpl _workspace; private readonly HostDiagnosticUpdateSource _updateSource; private readonly IVsFileChangeEx _fileChangeService; - private readonly Dictionary _fileChangeTrackers = new Dictionary(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _fileChangeTrackers = new(StringComparer.OrdinalIgnoreCase); /// /// Holds a list of assembly modified times that we can use to detect a file change prior to the being in place. /// Once it's in place and subscribed, we'll remove the entry because any further changes will be detected that way. /// - private readonly Dictionary _assemblyUpdatedTimesUtc = new Dictionary(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _assemblyUpdatedTimesUtc = new(StringComparer.OrdinalIgnoreCase); - private readonly object _guard = new object(); + private readonly object _guard = new(); - private readonly DiagnosticDescriptor _analyzerChangedRule = new DiagnosticDescriptor( + private readonly DiagnosticDescriptor _analyzerChangedRule = new( id: IDEDiagnosticIds.AnalyzerChangedId, title: ServicesVSResources.AnalyzerChangedOnDisk, messageFormat: ServicesVSResources.The_analyzer_assembly_0_has_changed_Diagnostics_may_be_incorrect_until_Visual_Studio_is_restarted, diff --git a/src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyItem.cs b/src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyItem.cs index ec8a1915092..4e21fc4e46c 100644 --- a/src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyItem.cs +++ b/src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyItem.cs @@ -42,7 +42,7 @@ public CallHierarchyItem(ISymbol symbol, ProjectId projectId, IEnumerable new TestAccessor(this); + => new(this); internal readonly struct TestAccessor { diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs index 266acf21a23..c90ce80f11a 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs @@ -52,7 +52,7 @@ public AddParameterDialogViewModel(Document document, int positionForTypeBinding public string CallSiteValue { get; set; } - private static readonly SymbolDisplayFormat s_symbolDisplayFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_symbolDisplayFormat = new( genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes); diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialog.xaml.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialog.xaml.cs index 4103cb17f2d..18e94e3098d 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialog.xaml.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialog.xaml.cs @@ -276,7 +276,7 @@ private void ToggleRemovedState(object sender, ExecutedRoutedEventArgs e) } internal TestAccessor GetTestAccessor() - => new TestAccessor(this); + => new(this); internal readonly struct TestAccessor { diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialogViewModel.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialogViewModel.cs index 9137114ef5f..fad2c1776a9 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialogViewModel.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialogViewModel.cs @@ -38,7 +38,7 @@ internal partial class ChangeSignatureDialogViewModel : AbstractNotifyPropertyCh // This can be changed to ParameterViewModel if we will allow adding 'params' parameter. private readonly ExistingParameterViewModel? _paramsParameter; - private readonly HashSet _disabledParameters = new HashSet(); + private readonly HashSet _disabledParameters = new(); private ImmutableArray _declarationParts; private bool _previewChanges; @@ -145,7 +145,7 @@ private void UpdateNameConflictMarkers() } public AddParameterDialogViewModel CreateAddParameterDialogViewModel() - => new AddParameterDialogViewModel(_document, _positionForTypeBinding); + => new(_document, _positionForTypeBinding); private List CreateParameterViewModels(ImmutableArray parameters, ref int initialIndex) { @@ -304,7 +304,7 @@ internal ParameterConfiguration GetParameterConfiguration() selectedIndex: -1); } - private static readonly SymbolDisplayFormat s_symbolDeclarationDisplayFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_symbolDeclarationDisplayFormat = new( genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers | @@ -318,7 +318,7 @@ internal ParameterConfiguration GetParameterConfiguration() SymbolDisplayMemberOptions.IncludeModifiers | SymbolDisplayMemberOptions.IncludeRef); - private static readonly SymbolDisplayFormat s_parameterDisplayFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_parameterDisplayFormat = new( genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers | diff --git a/src/VisualStudio/Core/Def/Implementation/ColorSchemes/ColorSchemeApplier.ClassificationVerifier.cs b/src/VisualStudio/Core/Def/Implementation/ColorSchemes/ColorSchemeApplier.ClassificationVerifier.cs index c90c5647e0d..a62bc9f36fc 100644 --- a/src/VisualStudio/Core/Def/Implementation/ColorSchemes/ColorSchemeApplier.ClassificationVerifier.cs +++ b/src/VisualStudio/Core/Def/Implementation/ColorSchemes/ColorSchemeApplier.ClassificationVerifier.cs @@ -27,7 +27,7 @@ private sealed class ClassificationVerifier : ForegroundThreadAffinitizedObject private readonly IServiceProvider _serviceProvider; private readonly ImmutableDictionary>> _colorSchemes; - private static readonly Guid TextEditorMEFItemsColorCategory = new Guid("75a05685-00a8-4ded-bae5-e7a50bfa929a"); + private static readonly Guid TextEditorMEFItemsColorCategory = new("75a05685-00a8-4ded-bae5-e7a50bfa929a"); // These classification colors (0x00BBGGRR) should match the VS\EditorColors.xml file. // They are not in the scheme files because they are core classifications. diff --git a/src/VisualStudio/Core/Def/Implementation/ColorSchemes/ColorSchemeApplier.ColorSchemeReader.cs b/src/VisualStudio/Core/Def/Implementation/ColorSchemes/ColorSchemeApplier.ColorSchemeReader.cs index 4608b7542ad..306db5861d2 100644 --- a/src/VisualStudio/Core/Def/Implementation/ColorSchemes/ColorSchemeApplier.ColorSchemeReader.cs +++ b/src/VisualStudio/Core/Def/Implementation/ColorSchemes/ColorSchemeApplier.ColorSchemeReader.cs @@ -20,7 +20,7 @@ internal partial class ColorSchemeApplier { private static class ColorSchemeReader { - private static readonly XmlReaderSettings s_xmlSettings = new XmlReaderSettings { DtdProcessing = DtdProcessing.Prohibit }; + private static readonly XmlReaderSettings s_xmlSettings = new() { DtdProcessing = DtdProcessing.Prohibit }; private const string RawColorType = nameof(__VSCOLORTYPE.CT_RAW); private const string SystemColorType = nameof(__VSCOLORTYPE.CT_SYSCOLOR); diff --git a/src/VisualStudio/Core/Def/Implementation/ContainedLanguageRefactorNotifyService.cs b/src/VisualStudio/Core/Def/Implementation/ContainedLanguageRefactorNotifyService.cs index 7035b0d4611..55099fe0a69 100644 --- a/src/VisualStudio/Core/Def/Implementation/ContainedLanguageRefactorNotifyService.cs +++ b/src/VisualStudio/Core/Def/Implementation/ContainedLanguageRefactorNotifyService.cs @@ -20,7 +20,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation [Export(typeof(IRefactorNotifyService))] internal sealed class ContainedLanguageRefactorNotifyService : IRefactorNotifyService { - private static readonly SymbolDisplayFormat s_qualifiedDisplayFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_qualifiedDisplayFormat = new( globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted, typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces); diff --git a/src/VisualStudio/Core/Def/Implementation/DebuggerIntelliSense/DebuggerTextView.HACK_CompletionSession.cs b/src/VisualStudio/Core/Def/Implementation/DebuggerIntelliSense/DebuggerTextView.HACK_CompletionSession.cs index b4efb973a2a..d7ae80a8483 100644 --- a/src/VisualStudio/Core/Def/Implementation/DebuggerIntelliSense/DebuggerTextView.HACK_CompletionSession.cs +++ b/src/VisualStudio/Core/Def/Implementation/DebuggerIntelliSense/DebuggerTextView.HACK_CompletionSession.cs @@ -20,7 +20,7 @@ internal partial class DebuggerTextView { // HACK HACK HACK HACK HACK: We'll use this fake ICompletionSession to trick them into // routing commands to us for both completion and sighelp - private readonly HACK_CompletionSession _hackCompletionSession = new HACK_CompletionSession(); + private readonly HACK_CompletionSession _hackCompletionSession = new(); public void HACK_StartCompletionSession(IIntellisenseSession editorSessionOpt) { diff --git a/src/VisualStudio/Core/Def/Implementation/DesignerAttribute/VisualStudioDesignerAttributeService.cs b/src/VisualStudio/Core/Def/Implementation/DesignerAttribute/VisualStudioDesignerAttributeService.cs index b00ce35c3a9..a7ab105123d 100644 --- a/src/VisualStudio/Core/Def/Implementation/DesignerAttribute/VisualStudioDesignerAttributeService.cs +++ b/src/VisualStudio/Core/Def/Implementation/DesignerAttribute/VisualStudioDesignerAttributeService.cs @@ -52,7 +52,7 @@ internal class VisualStudioDesignerAttributeService /// that project. /// private readonly ConcurrentDictionary _cpsProjects - = new ConcurrentDictionary(); + = new(); /// /// Cached designer service for notifying legacy projects about designer attributes. diff --git a/src/VisualStudio/Core/Def/Implementation/Diagnostics/DiagnosticProgressReporter.cs b/src/VisualStudio/Core/Def/Implementation/Diagnostics/DiagnosticProgressReporter.cs index ba529b6e9de..5ec36544677 100644 --- a/src/VisualStudio/Core/Def/Implementation/Diagnostics/DiagnosticProgressReporter.cs +++ b/src/VisualStudio/Core/Def/Implementation/Diagnostics/DiagnosticProgressReporter.cs @@ -30,7 +30,7 @@ internal sealed class TaskCenterSolutionAnalysisProgressReporter /// Gate access to reporting sln crawler events so we cannot /// report UI changes concurrently. /// - private readonly object _lock = new object(); + private readonly object _lock = new(); /// /// Task used to trigger throttled UI updates in an interval diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/DebuggerComponent.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/DebuggerComponent.cs index 0d2af5a6c70..3382bed92e2 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/DebuggerComponent.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/DebuggerComponent.cs @@ -13,10 +13,10 @@ internal static class DebuggerComponent /// /// Component id as specified in ManagedEditAndContinueService.vsdconfigxml. /// - private static readonly Guid ManagedEditAndContinueServiceId = new Guid("A96BBE03-0408-41E3-8613-6086FD494B43"); + private static readonly Guid ManagedEditAndContinueServiceId = new("A96BBE03-0408-41E3-8613-6086FD494B43"); public static ThreadInitializer ManagedEditAndContinueService() - => new ThreadInitializer(ManagedEditAndContinueServiceId); + => new(ManagedEditAndContinueServiceId); public struct ThreadInitializer : IDisposable { diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ModuleUtilities.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ModuleUtilities.cs index b2e2577408e..48ea53a55a5 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ModuleUtilities.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ModuleUtilities.cs @@ -77,14 +77,14 @@ internal static LinePositionSpan ToLinePositionSpan(this DkmTextSpan span) } internal static DkmTextSpan ToDebuggerSpan(this LinePositionSpan span, int lineDelta = 0) - => new DkmTextSpan( + => new( StartLine: span.Start.Line + lineDelta + 1, EndLine: span.End.Line + lineDelta + 1, StartColumn: span.Start.Character + 1, EndColumn: span.End.Character + 1); internal static EnC.ActiveStatementDebugInfo ToActiveStatementDebugInfo(this ActiveStatementDebugInfo info) - => new EnC.ActiveStatementDebugInfo( + => new( new EnC.ActiveInstructionId(info.InstructionId.MethodId.ModuleId, info.InstructionId.MethodId.Token, info.InstructionId.MethodId.Version, info.InstructionId.ILOffset), info.DocumentNameOpt, info.TextSpan.ToLinePositionSpan(), @@ -125,7 +125,7 @@ internal static DkmManagedModuleUpdate ToModuleUpdate(this EnC.Deltas delta) } internal static ReadOnlyCollection ToReadOnlyCollection(this ImmutableArray array) - => new ReadOnlyCollection(array.DangerousGetUnderlyingArray()); + => new(array.DangerousGetUnderlyingArray()); internal static ManagedModuleUpdateStatus ToModuleUpdateStatus(this EnC.SolutionUpdateStatus status) => status switch diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VisualStudioDebuggeeModuleMetadataProvider.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VisualStudioDebuggeeModuleMetadataProvider.cs index cb7395df7de..58284bce80e 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VisualStudioDebuggeeModuleMetadataProvider.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VisualStudioDebuggeeModuleMetadataProvider.cs @@ -34,7 +34,7 @@ private sealed class DebuggerService : IDkmCustomMessageForwardReceiver /// /// Message source id as specified in ManagedEditAndContinueService.vsdconfigxml. /// - public static readonly Guid MessageSourceId = new Guid("58CDF976-1923-48F7-8288-B4189F5700B1"); + public static readonly Guid MessageSourceId = new("58CDF976-1923-48F7-8288-B4189F5700B1"); private sealed class DataItem : DkmDataItem { diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VisualStudioManagedModuleUpdateProvider.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VisualStudioManagedModuleUpdateProvider.cs index 7c470001e3c..54059f5adcb 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VisualStudioManagedModuleUpdateProvider.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VisualStudioManagedModuleUpdateProvider.cs @@ -38,7 +38,7 @@ public VisualStudioManagedModuleUpdateProvider(VisualStudioWorkspace workspace) } private SolutionActiveStatementSpanProvider GetActiveStatementSpanProvider(Solution solution) - => new SolutionActiveStatementSpanProvider((documentId, cancellationToken) => + => new((documentId, cancellationToken) => _activeStatementTrackingService.GetSpansAsync(solution.GetRequiredDocument(documentId), cancellationToken)); /// diff --git a/src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetDetector.cs b/src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetDetector.cs index cf6a7ed59d1..803605e9668 100644 --- a/src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetDetector.cs +++ b/src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetDetector.cs @@ -56,8 +56,8 @@ internal sealed class KeybindingResetDetector : ForegroundThreadAffinitizedObjec private const uint ResumeId = 707; private const uint SuspendId = 708; private const uint ToggleSuspendId = 709; - private static readonly Guid ReSharperPackageGuid = new Guid("0C6E6407-13FC-4878-869A-C8B4016C57FE"); - private static readonly Guid ReSharperCommandGroup = new Guid("{47F03277-5055-4922-899C-0F7F30D26BF1}"); + private static readonly Guid ReSharperPackageGuid = new("0C6E6407-13FC-4878-869A-C8B4016C57FE"); + private static readonly Guid ReSharperCommandGroup = new("{47F03277-5055-4922-899C-0F7F30D26BF1}"); private readonly VisualStudioWorkspace _workspace; private readonly System.IServiceProvider _serviceProvider; @@ -70,7 +70,7 @@ internal sealed class KeybindingResetDetector : ForegroundThreadAffinitizedObjec private OleComponent _oleComponent; private uint _priorityCommandTargetCookie = VSConstants.VSCOOKIE_NIL; - private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); + private CancellationTokenSource _cancellationTokenSource = new(); /// /// If false, ReSharper is either not installed, or has been disabled in the extension manager. /// If true, the ReSharper extension is enabled. ReSharper's internal status could be either suspended or enabled. diff --git a/src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetOptions.cs b/src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetOptions.cs index 4c0950182d8..cb082e37439 100644 --- a/src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetOptions.cs +++ b/src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetOptions.cs @@ -10,15 +10,15 @@ internal static class KeybindingResetOptions { private const string LocalRegistryPath = @"Roslyn\Internal\KeybindingsStatus\"; - public static readonly Option ReSharperStatus = new Option(nameof(KeybindingResetOptions), + public static readonly Option ReSharperStatus = new(nameof(KeybindingResetOptions), nameof(ReSharperStatus), defaultValue: Experimentation.ReSharperStatus.NotInstalledOrDisabled, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(ReSharperStatus))); - public static readonly Option NeedsReset = new Option(nameof(KeybindingResetOptions), + public static readonly Option NeedsReset = new(nameof(KeybindingResetOptions), nameof(NeedsReset), defaultValue: false, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(NeedsReset))); - public static readonly Option NeverShowAgain = new Option(nameof(KeybindingResetOptions), + public static readonly Option NeverShowAgain = new(nameof(KeybindingResetOptions), nameof(NeverShowAgain), defaultValue: false, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(NeverShowAgain))); } diff --git a/src/VisualStudio/Core/Def/Implementation/Extensions/VisualStudioWorkspaceImplExtensions.cs b/src/VisualStudio/Core/Def/Implementation/Extensions/VisualStudioWorkspaceImplExtensions.cs index a9b7f4a72d7..33ad58478fd 100644 --- a/src/VisualStudio/Core/Def/Implementation/Extensions/VisualStudioWorkspaceImplExtensions.cs +++ b/src/VisualStudio/Core/Def/Implementation/Extensions/VisualStudioWorkspaceImplExtensions.cs @@ -19,7 +19,7 @@ internal static class VisualStudioWorkspaceImplExtensions // hierarchy we're getting them for. To do this, we attach them to the hierarchy with a // conditional weak table. private static readonly ConditionalWeakTable> s_hierarchyToItemIdToImageHandle = - new ConditionalWeakTable>(); + new(); private static readonly ConditionalWeakTable>.CreateValueCallback s_createValue = _ => new Dictionary(); diff --git a/src/VisualStudio/Core/Def/Implementation/ExtractInterface/ExtractInterfaceDialog.xaml.cs b/src/VisualStudio/Core/Def/Implementation/ExtractInterface/ExtractInterfaceDialog.xaml.cs index 14eaf8a0932..9d334369ec4 100644 --- a/src/VisualStudio/Core/Def/Implementation/ExtractInterface/ExtractInterfaceDialog.xaml.cs +++ b/src/VisualStudio/Core/Def/Implementation/ExtractInterface/ExtractInterfaceDialog.xaml.cs @@ -111,7 +111,7 @@ private void ToggleCheckSelection() } internal TestAccessor GetTestAccessor() - => new TestAccessor(this); + => new(this); internal readonly struct TestAccessor { diff --git a/src/VisualStudio/Core/Def/Implementation/F1Help/AbstractHelpContextService.cs b/src/VisualStudio/Core/Def/Implementation/F1Help/AbstractHelpContextService.cs index 7c8e025823d..7a7d3425d93 100644 --- a/src/VisualStudio/Core/Def/Implementation/F1Help/AbstractHelpContextService.cs +++ b/src/VisualStudio/Core/Def/Implementation/F1Help/AbstractHelpContextService.cs @@ -16,7 +16,7 @@ internal abstract class AbstractHelpContextService : IHelpContextService // C`1.M``2 // constructors: Parent.Type.#ctor protected static readonly SymbolDisplayFormat TypeFormat = - new SymbolDisplayFormat( + new( globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted, typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, propertyStyle: SymbolDisplayPropertyStyle.NameOnly, @@ -24,7 +24,7 @@ internal abstract class AbstractHelpContextService : IHelpContextService miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers); protected static readonly SymbolDisplayFormat SpecialTypeFormat = - new SymbolDisplayFormat( + new( globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted, typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly, genericsOptions: SymbolDisplayGenericsOptions.None, @@ -33,7 +33,7 @@ internal abstract class AbstractHelpContextService : IHelpContextService SymbolDisplayMiscellaneousOptions.UseSpecialTypes); protected static readonly SymbolDisplayFormat NameFormat = - new SymbolDisplayFormat( + new( globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted, typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes); diff --git a/src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs b/src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs index e0fc7532e2b..08ed75f2339 100644 --- a/src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs +++ b/src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs @@ -29,7 +29,7 @@ internal partial class StreamingFindUsagesPresenter private abstract class AbstractTableDataSourceFindUsagesContext : FindUsagesContext, ITableDataSource, ITableEntriesSnapshotFactory { - private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); + private readonly CancellationTokenSource _cancellationTokenSource = new(); private ITableDataSink _tableDataSink; @@ -39,7 +39,7 @@ private abstract class AbstractTableDataSourceFindUsagesContext : private readonly AsyncBatchingWorkQueue<(int current, int maximum)> _progressQueue; - protected readonly object Gate = new object(); + protected readonly object Gate = new(); #region Fields that should be locked by _gate @@ -56,7 +56,7 @@ private abstract class AbstractTableDataSourceFindUsagesContext : /// us to not display it if it has no references, and we don't run into any /// references for it (common with implicitly declared symbols). /// - protected readonly List Definitions = new List(); + protected readonly List Definitions = new(); /// /// We will hear about the same definition over and over again. i.e. for each reference @@ -67,7 +67,7 @@ private abstract class AbstractTableDataSourceFindUsagesContext : /// and then always return that for all future references found. /// private readonly Dictionary _definitionToBucket = - new Dictionary(); + new(); /// /// We want to hide declarations of a symbol if the user is grouping by definition. diff --git a/src/VisualStudio/Core/Def/Implementation/FindReferences/FindUsagesOptions.cs b/src/VisualStudio/Core/Def/Implementation/FindReferences/FindUsagesOptions.cs index 27b45f9d183..a30dce5d121 100644 --- a/src/VisualStudio/Core/Def/Implementation/FindReferences/FindUsagesOptions.cs +++ b/src/VisualStudio/Core/Def/Implementation/FindReferences/FindUsagesOptions.cs @@ -21,7 +21,7 @@ internal static class FindUsagesOptions /// and we want to restore the value back to its original state when the user does the /// next FindReferences call. /// - public static readonly Option DefinitionGroupingPriority = new Option( + public static readonly Option DefinitionGroupingPriority = new( nameof(FindUsagesOptions), nameof(DefinitionGroupingPriority), defaultValue: -1, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(DefinitionGroupingPriority))); } diff --git a/src/VisualStudio/Core/Def/Implementation/FindReferences/StreamingFindUsagesPresenter.cs b/src/VisualStudio/Core/Def/Implementation/FindReferences/StreamingFindUsagesPresenter.cs index 03377e255fc..2428c329c7e 100644 --- a/src/VisualStudio/Core/Def/Implementation/FindReferences/StreamingFindUsagesPresenter.cs +++ b/src/VisualStudio/Core/Def/Implementation/FindReferences/StreamingFindUsagesPresenter.cs @@ -42,7 +42,7 @@ internal partial class StreamingFindUsagesPresenter : private readonly Workspace _workspace; private readonly HashSet _currentContexts = - new HashSet(); + new(); private readonly ImmutableArray _customColumns; [ImportingConstructor] diff --git a/src/VisualStudio/Core/Def/Implementation/GenerateType/GenerateTypeDialog.xaml.cs b/src/VisualStudio/Core/Def/Implementation/GenerateType/GenerateTypeDialog.xaml.cs index 9ae246a877a..cc537b48ab2 100644 --- a/src/VisualStudio/Core/Def/Implementation/GenerateType/GenerateTypeDialog.xaml.cs +++ b/src/VisualStudio/Core/Def/Implementation/GenerateType/GenerateTypeDialog.xaml.cs @@ -110,7 +110,7 @@ private void Cancel_Click(object sender, RoutedEventArgs e) => DialogResult = false; internal TestAccessor GetTestAccessor() - => new TestAccessor(this); + => new(this); internal readonly struct TestAccessor { diff --git a/src/VisualStudio/Core/Def/Implementation/Interactive/CSharpResetInteractiveMenuCommand.cs b/src/VisualStudio/Core/Def/Implementation/Interactive/CSharpResetInteractiveMenuCommand.cs index cdadbb2c7bb..60ba886924f 100644 --- a/src/VisualStudio/Core/Def/Implementation/Interactive/CSharpResetInteractiveMenuCommand.cs +++ b/src/VisualStudio/Core/Def/Implementation/Interactive/CSharpResetInteractiveMenuCommand.cs @@ -24,6 +24,6 @@ internal sealed class CSharpResetInteractiveMenuCommand protected override string ProjectKind => VSLangProj.PrjKind.prjKindCSharpProject; protected override CommandID GetResetInteractiveFromProjectCommandID() - => new CommandID(ID.InteractiveCommands.CSharpInteractiveCommandSetId, ID.InteractiveCommands.ResetInteractiveFromProject); + => new(ID.InteractiveCommands.CSharpInteractiveCommandSetId, ID.InteractiveCommands.ResetInteractiveFromProject); } } diff --git a/src/VisualStudio/Core/Def/Implementation/Interactive/VisualBasicResetInteractiveMenuCommand.cs b/src/VisualStudio/Core/Def/Implementation/Interactive/VisualBasicResetInteractiveMenuCommand.cs index 726deea228b..453d101763b 100644 --- a/src/VisualStudio/Core/Def/Implementation/Interactive/VisualBasicResetInteractiveMenuCommand.cs +++ b/src/VisualStudio/Core/Def/Implementation/Interactive/VisualBasicResetInteractiveMenuCommand.cs @@ -24,6 +24,6 @@ internal sealed class VisualBasicResetInteractiveMenuCommand protected override string ProjectKind => VSLangProj.PrjKind.prjKindVBProject; protected override CommandID GetResetInteractiveFromProjectCommandID() - => new CommandID(ID.InteractiveCommands.VisualBasicInteractiveCommandSetId, ID.InteractiveCommands.ResetInteractiveFromProject); + => new(ID.InteractiveCommands.VisualBasicInteractiveCommandSetId, ID.InteractiveCommands.ResetInteractiveFromProject); } } diff --git a/src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs b/src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs index e10cc0a5b54..5f2d147989b 100644 --- a/src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs +++ b/src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs @@ -332,7 +332,7 @@ private void RequestExecutionQueue_Errored(object sender, RequestShutdownEventAr /// union the currently computed diagnostics (e.g. for dA) with previously computed diagnostics (e.g. from dB). /// private readonly Dictionary>> _publishedFileToDiagnostics = - new Dictionary>>(); + new(); /// /// Stores the mapping of a document to the uri(s) of diagnostics previously produced for this document. @@ -342,7 +342,7 @@ private void RequestExecutionQueue_Errored(object sender, RequestShutdownEventAr /// While it's not necessary to publish a document's mapped file diagnostics in a particular order, /// it does make it much easier to write tests and debug issues if we have a consistent ordering. /// - private readonly Dictionary> _documentsToPublishedUris = new Dictionary>(); + private readonly Dictionary> _documentsToPublishedUris = new(); /// /// Basic comparer for Uris used by when publishing notifications. @@ -483,7 +483,7 @@ static LanguageServer.Protocol.Diagnostic ConvertToLspDiagnostic(DiagnosticData return ProtocolConversions.LinePositionToRange(linePositionSpan); } - internal TestAccessor GetTestAccessor() => new TestAccessor(this); + internal TestAccessor GetTestAccessor() => new(this); internal readonly struct TestAccessor { diff --git a/src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractLanguageService`2.IVsImmediateStatementCompletion2.cs b/src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractLanguageService`2.IVsImmediateStatementCompletion2.cs index 95c58534458..7df909ff14d 100644 --- a/src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractLanguageService`2.IVsImmediateStatementCompletion2.cs +++ b/src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractLanguageService`2.IVsImmediateStatementCompletion2.cs @@ -18,7 +18,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService internal abstract partial class AbstractLanguageService : IVsImmediateStatementCompletion2 { protected Dictionary filters = - new Dictionary(); + new(); int IVsImmediateStatementCompletion2.EnableStatementCompletion(int enable, int startIndex, int endIndex, IVsTextView textView) { diff --git a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractDescriptionBuilder.cs b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractDescriptionBuilder.cs index f51ef8f47c6..d7d9dcdd598 100644 --- a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractDescriptionBuilder.cs +++ b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractDescriptionBuilder.cs @@ -20,7 +20,7 @@ internal abstract partial class AbstractDescriptionBuilder private readonly ObjectListItem _listItem; private readonly Project _project; - private static readonly SymbolDisplayFormat s_typeDisplay = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_typeDisplay = new( miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes); protected AbstractDescriptionBuilder( diff --git a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractListItemFactory.cs b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractListItemFactory.cs index 0488e5023dc..38e57bc08a3 100644 --- a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractListItemFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractListItemFactory.cs @@ -21,34 +21,34 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Library.ObjectB internal abstract class AbstractListItemFactory { private static readonly SymbolDisplayFormat s_searchFormat = - new SymbolDisplayFormat(typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly); + new(typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly); private static readonly SymbolDisplayFormat s_simplePredefinedTypeDisplay = - new SymbolDisplayFormat( + new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes); private static readonly SymbolDisplayFormat s_simpleNormalTypeDisplay = - new SymbolDisplayFormat( + new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes, genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters | SymbolDisplayGenericsOptions.IncludeVariance, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes); private static readonly SymbolDisplayFormat s_simplePredefinedTypeFullName = - new SymbolDisplayFormat( + new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces); private static readonly SymbolDisplayFormat s_simpleNormalTypeFullName = - new SymbolDisplayFormat( + new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters | SymbolDisplayGenericsOptions.IncludeVariance, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes); private static readonly SymbolDisplayFormat s_predefinedTypeDisplay = - new SymbolDisplayFormat( + new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces); private static readonly SymbolDisplayFormat s_normalTypeDisplay = - new SymbolDisplayFormat( + new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters | SymbolDisplayGenericsOptions.IncludeVariance, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes); diff --git a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs index 516e731a003..21d4b0433e6 100644 --- a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs @@ -36,7 +36,7 @@ internal abstract partial class AbstractObjectBrowserLibraryManager : AbstractLi private ObjectListItem _activeListItem; private AbstractListItemFactory _listItemFactory; - private readonly object _classMemberGate = new object(); + private readonly object _classMemberGate = new(); private readonly IStreamingFindUsagesPresenter _streamingPresenter; diff --git a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/Extensions.cs b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/Extensions.cs index 1f16c720f0f..52702178747 100644 --- a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/Extensions.cs +++ b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/Extensions.cs @@ -12,11 +12,11 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Library.ObjectB { internal static class Extensions { - private static readonly SymbolDisplayFormat s_typeDisplayFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_typeDisplayFormat = new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes, genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters | SymbolDisplayGenericsOptions.IncludeVariance); - private static readonly SymbolDisplayFormat s_memberDisplayFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_memberDisplayFormat = new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters | SymbolDisplayGenericsOptions.IncludeVariance, memberOptions: SymbolDisplayMemberOptions.IncludeExplicitInterface | SymbolDisplayMemberOptions.IncludeParameters, diff --git a/src/VisualStudio/Core/Def/Implementation/Log/LoggerOptions.cs b/src/VisualStudio/Core/Def/Implementation/Log/LoggerOptions.cs index df66d26b44b..44bb0f80dcb 100644 --- a/src/VisualStudio/Core/Def/Implementation/Log/LoggerOptions.cs +++ b/src/VisualStudio/Core/Def/Implementation/Log/LoggerOptions.cs @@ -15,13 +15,13 @@ internal static class LoggerOptions { private const string LocalRegistryPath = @"Roslyn\Internal\Performance\Logger\"; - public static readonly Option EtwLoggerKey = new Option(nameof(LoggerOptions), nameof(EtwLoggerKey), defaultValue: true, + public static readonly Option EtwLoggerKey = new(nameof(LoggerOptions), nameof(EtwLoggerKey), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "EtwLogger")); - public static readonly Option TraceLoggerKey = new Option(nameof(LoggerOptions), nameof(TraceLoggerKey), defaultValue: false, + public static readonly Option TraceLoggerKey = new(nameof(LoggerOptions), nameof(TraceLoggerKey), defaultValue: false, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "TraceLogger")); - public static readonly Option OutputWindowLoggerKey = new Option(nameof(LoggerOptions), nameof(OutputWindowLoggerKey), defaultValue: false, + public static readonly Option OutputWindowLoggerKey = new(nameof(LoggerOptions), nameof(OutputWindowLoggerKey), defaultValue: false, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "OutputWindowLogger")); } diff --git a/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/MoveToNamespaceDialog.xaml.cs b/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/MoveToNamespaceDialog.xaml.cs index ae691122758..340be69b10e 100644 --- a/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/MoveToNamespaceDialog.xaml.cs +++ b/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/MoveToNamespaceDialog.xaml.cs @@ -37,7 +37,7 @@ internal MoveToNamespaceDialog(MoveToNamespaceDialogViewModel viewModel) private void Cancel_Click(object sender, RoutedEventArgs e) => DialogResult = false; - internal TestAccessor GetTestAccessor() => new TestAccessor(this); + internal TestAccessor GetTestAccessor() => new(this); private void OK_Click(object sender, RoutedEventArgs e) { diff --git a/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/VisualStudioMoveToNamespaceOptionsService.cs b/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/VisualStudioMoveToNamespaceOptionsService.cs index 401c8193a02..a982f1df5ad 100644 --- a/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/VisualStudioMoveToNamespaceOptionsService.cs +++ b/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/VisualStudioMoveToNamespaceOptionsService.cs @@ -20,7 +20,7 @@ internal class VisualStudioMoveToNamespaceOptionsService : IMoveToNamespaceOptio { private const int HistorySize = 3; - public readonly LinkedList History = new LinkedList(); + public readonly LinkedList History = new(); private readonly Func _showDialog; [ImportingConstructor] diff --git a/src/VisualStudio/Core/Def/Implementation/NavigateTo/VisualStudioNavigateToPreviewServiceFactory.cs b/src/VisualStudio/Core/Def/Implementation/NavigateTo/VisualStudioNavigateToPreviewServiceFactory.cs index 23db26042eb..6a05f23279f 100644 --- a/src/VisualStudio/Core/Def/Implementation/NavigateTo/VisualStudioNavigateToPreviewServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/NavigateTo/VisualStudioNavigateToPreviewServiceFactory.cs @@ -15,7 +15,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.NavigateTo internal sealed class VisualStudioNavigateToPreviewServiceFactory : IWorkspaceServiceFactory { private readonly Lazy _singleton = - new Lazy(() => new VisualStudioNavigateToPreviewService()); + new(() => new VisualStudioNavigateToPreviewService()); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/VisualStudio/Core/Def/Implementation/NavigationBar/NavigationBarClient.cs b/src/VisualStudio/Core/Def/Implementation/NavigationBar/NavigationBarClient.cs index 136927c048c..b1c0d86e925 100644 --- a/src/VisualStudio/Core/Def/Implementation/NavigationBar/NavigationBarClient.cs +++ b/src/VisualStudio/Core/Def/Implementation/NavigationBar/NavigationBarClient.cs @@ -35,7 +35,7 @@ internal class NavigationBarClient : private readonly ComEventSink _codeWindowEventsSink; private readonly IVsEditorAdaptersFactoryService _editorAdaptersFactoryService; private readonly IVsImageService2 _imageService; - private readonly Dictionary _trackedTextViews = new Dictionary(); + private readonly Dictionary _trackedTextViews = new(); private IVsDropdownBar _dropdownBar; private IList _projectItems; private IList _currentTypeItems; diff --git a/src/VisualStudio/Core/Def/Implementation/Notification/VSNotificationServiceFactory.cs b/src/VisualStudio/Core/Def/Implementation/Notification/VSNotificationServiceFactory.cs index be1ea98c30d..6024570fbe0 100644 --- a/src/VisualStudio/Core/Def/Implementation/Notification/VSNotificationServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/Notification/VSNotificationServiceFactory.cs @@ -19,7 +19,7 @@ internal class VSNotificationServiceFactory : IWorkspaceServiceFactory { private readonly IVsUIShell _uiShellService; - private static readonly object s_gate = new object(); + private static readonly object s_gate = new(); private static VSDialogService s_singleton; diff --git a/src/VisualStudio/Core/Def/Implementation/Options/LocalUserRegistryOptionPersister.cs b/src/VisualStudio/Core/Def/Implementation/Options/LocalUserRegistryOptionPersister.cs index 9442a5b638b..602952c9c53 100644 --- a/src/VisualStudio/Core/Def/Implementation/Options/LocalUserRegistryOptionPersister.cs +++ b/src/VisualStudio/Core/Def/Implementation/Options/LocalUserRegistryOptionPersister.cs @@ -25,7 +25,7 @@ internal sealed class LocalUserRegistryOptionPersister : IOptionPersister /// /// An object to gate access to . /// - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly RegistryKey _registryKey; [ImportingConstructor] diff --git a/src/VisualStudio/Core/Def/Implementation/Options/RoamingVisualStudioProfileOptionPersister.cs b/src/VisualStudio/Core/Def/Implementation/Options/RoamingVisualStudioProfileOptionPersister.cs index 7ad2fd1d313..4007531ca92 100644 --- a/src/VisualStudio/Core/Def/Implementation/Options/RoamingVisualStudioProfileOptionPersister.cs +++ b/src/VisualStudio/Core/Def/Implementation/Options/RoamingVisualStudioProfileOptionPersister.cs @@ -41,8 +41,8 @@ private class SVsSettingsPersistenceManager { }; /// if a later change happens, we know to refresh that value. This is synchronized with monitor locks on /// . /// - private readonly Dictionary> _optionsToMonitorForChanges = new Dictionary>(); - private readonly object _optionsToMonitorForChangesGate = new object(); + private readonly Dictionary> _optionsToMonitorForChanges = new(); + private readonly object _optionsToMonitorForChangesGate = new(); /// /// We make sure this code is from the UI by asking for all in diff --git a/src/VisualStudio/Core/Def/Implementation/PickMembers/PickMembersDialog.xaml.cs b/src/VisualStudio/Core/Def/Implementation/PickMembers/PickMembersDialog.xaml.cs index e54cd15b74f..ccb98dfc067 100644 --- a/src/VisualStudio/Core/Def/Implementation/PickMembers/PickMembersDialog.xaml.cs +++ b/src/VisualStudio/Core/Def/Implementation/PickMembers/PickMembersDialog.xaml.cs @@ -137,7 +137,7 @@ private void ToggleCheckSelection() } internal TestAccessor GetTestAccessor() - => new TestAccessor(this); + => new(this); internal readonly struct TestAccessor { diff --git a/src/VisualStudio/Core/Def/Implementation/Preview/ChangeList.cs b/src/VisualStudio/Core/Def/Implementation/Preview/ChangeList.cs index ba205f99136..5098d021c64 100644 --- a/src/VisualStudio/Core/Def/Implementation/Preview/ChangeList.cs +++ b/src/VisualStudio/Core/Def/Implementation/Preview/ChangeList.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Preview { internal partial class ChangeList : IVsPreviewChangesList, IVsLiteTreeList { - public static readonly ChangeList Empty = new ChangeList(Array.Empty()); + public static readonly ChangeList Empty = new(Array.Empty()); internal AbstractChange[] Changes { get; } diff --git a/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPane.xaml.cs b/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPane.xaml.cs index 6ed2cafb0cd..d1b18908fad 100644 --- a/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPane.xaml.cs +++ b/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPane.xaml.cs @@ -23,7 +23,7 @@ internal partial class PreviewPane : UserControl, IDisposable private const double DefaultWidth = 400; private static readonly string s_dummyThreeLineTitle = "A" + Environment.NewLine + "A" + Environment.NewLine + "A"; - private static readonly Size s_infiniteSize = new Size(double.PositiveInfinity, double.PositiveInfinity); + private static readonly Size s_infiniteSize = new(double.PositiveInfinity, double.PositiveInfinity); private readonly string _id; private readonly bool _logIdVerbatimInTelemetry; diff --git a/src/VisualStudio/Core/Def/Implementation/Progression/GraphBuilder.cs b/src/VisualStudio/Core/Def/Implementation/Progression/GraphBuilder.cs index 56dca8dfa12..56d4253bfd7 100644 --- a/src/VisualStudio/Core/Def/Implementation/Progression/GraphBuilder.cs +++ b/src/VisualStudio/Core/Def/Implementation/Progression/GraphBuilder.cs @@ -25,17 +25,17 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Progression { internal sealed partial class GraphBuilder { - private readonly Graph _graph = new Graph(); - private readonly SemaphoreSlim _gate = new SemaphoreSlim(initialCount: 1); + private readonly Graph _graph = new(); + private readonly SemaphoreSlim _gate = new(initialCount: 1); private readonly ISet _createdNodes = new HashSet(); private readonly IList> _deferredPropertySets = new List>(); private readonly CancellationToken _cancellationToken; - private readonly Dictionary _nodeToContextProjectMap = new Dictionary(); - private readonly Dictionary _nodeToContextDocumentMap = new Dictionary(); - private readonly Dictionary _nodeToSymbolMap = new Dictionary(); + private readonly Dictionary _nodeToContextProjectMap = new(); + private readonly Dictionary _nodeToContextDocumentMap = new(); + private readonly Dictionary _nodeToSymbolMap = new(); /// /// The input solution. Never null. diff --git a/src/VisualStudio/Core/Def/Implementation/Progression/GraphProvider.cs b/src/VisualStudio/Core/Def/Implementation/Progression/GraphProvider.cs index c294d4d1c34..4c7731d7e07 100644 --- a/src/VisualStudio/Core/Def/Implementation/Progression/GraphProvider.cs +++ b/src/VisualStudio/Core/Def/Implementation/Progression/GraphProvider.cs @@ -327,16 +327,16 @@ private bool IsAnyTypeKind(GraphNode node, params TypeKind[] typeKinds) => typeKinds.Any(k => node[RoslynGraphProperties.TypeKind].Equals(k)); private static readonly GraphCommandDefinition s_overridesCommandDefinition = - new GraphCommandDefinition("Overrides", ServicesVSResources.Overrides_, GraphContextDirection.Target, 700); + new("Overrides", ServicesVSResources.Overrides_, GraphContextDirection.Target, 700); private static readonly GraphCommandDefinition s_overriddenByCommandDefinition = - new GraphCommandDefinition("OverriddenBy", ServicesVSResources.Overridden_By, GraphContextDirection.Source, 700); + new("OverriddenBy", ServicesVSResources.Overridden_By, GraphContextDirection.Source, 700); private static readonly GraphCommandDefinition s_implementsCommandDefinition = - new GraphCommandDefinition("Implements", ServicesVSResources.Implements_, GraphContextDirection.Target, 600); + new("Implements", ServicesVSResources.Implements_, GraphContextDirection.Target, 600); private static readonly GraphCommandDefinition s_implementedByCommandDefinition = - new GraphCommandDefinition("ImplementedBy", ServicesVSResources.Implemented_By, GraphContextDirection.Source, 600); + new("ImplementedBy", ServicesVSResources.Implemented_By, GraphContextDirection.Source, 600); public T GetExtension(GraphObject graphObject, T previous) where T : class { diff --git a/src/VisualStudio/Core/Def/Implementation/Progression/GraphQueryManager.cs b/src/VisualStudio/Core/Def/Implementation/Progression/GraphQueryManager.cs index 33999268782..1043f0419a5 100644 --- a/src/VisualStudio/Core/Def/Implementation/Progression/GraphQueryManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/Progression/GraphQueryManager.cs @@ -28,8 +28,8 @@ internal class GraphQueryManager /// /// This gate locks manipulation of . /// - private readonly object _gate = new object(); - private readonly List, List>> _trackedQueries = new List, List>>(); + private readonly object _gate = new(); + private readonly List, List>> _trackedQueries = new(); // We update all of our tracked queries when this delay elapses. private ResettableDelay? _delay; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectInfo/DefaultProjectInfoServiceFactory.cs b/src/VisualStudio/Core/Def/Implementation/ProjectInfo/DefaultProjectInfoServiceFactory.cs index 7df01847782..1524a044adc 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectInfo/DefaultProjectInfoServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectInfo/DefaultProjectInfoServiceFactory.cs @@ -18,7 +18,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectInfoServ internal sealed class DefaultProjectInfoServiceFactory : IWorkspaceServiceFactory { private readonly Lazy _singleton = - new Lazy(() => new DefaultProjectInfoService()); + new(() => new DefaultProjectInfoService()); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractEntryPointFinder.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractEntryPointFinder.cs index f3b414dbdd2..99b364be1a8 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractEntryPointFinder.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractEntryPointFinder.cs @@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem { internal abstract class AbstractEntryPointFinder : SymbolVisitor { - protected readonly HashSet EntryPoints = new HashSet(); + protected readonly HashSet EntryPoints = new(); public override void VisitNamespace(INamespaceSymbol symbol) { diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AnalyzerConfigDocumentAsSolutionItemHandler.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AnalyzerConfigDocumentAsSolutionItemHandler.cs index d840d1dbb99..66652cc1d86 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AnalyzerConfigDocumentAsSolutionItemHandler.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AnalyzerConfigDocumentAsSolutionItemHandler.cs @@ -27,7 +27,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem internal partial class AnalyzerConfigDocumentAsSolutionItemHandler : IDisposable { private static readonly string LocalRegistryPath = $@"Roslyn\Internal\{nameof(AnalyzerConfigDocumentAsSolutionItemHandler)}\"; - private static readonly Option NeverShowAgain = new Option(nameof(AnalyzerConfigDocumentAsSolutionItemHandler), nameof(NeverShowAgain), + private static readonly Option NeverShowAgain = new(nameof(AnalyzerConfigDocumentAsSolutionItemHandler), nameof(NeverShowAgain), defaultValue: false, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(NeverShowAgain))); private readonly VisualStudioWorkspace _workspace; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeTracker.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeTracker.cs index e21e4d5bb9d..4031b1597a9 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeTracker.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeTracker.cs @@ -18,7 +18,7 @@ internal sealed class FileChangeTracker : IVsFreeThreadedFileChangeEvents2, IDis { private const _VSFILECHANGEFLAGS DefaultFileChangeFlags = _VSFILECHANGEFLAGS.VSFILECHG_Time | _VSFILECHANGEFLAGS.VSFILECHG_Add | _VSFILECHANGEFLAGS.VSFILECHG_Del | _VSFILECHANGEFLAGS.VSFILECHG_Size; - private static readonly AsyncLazy s_none = new AsyncLazy(value: null); + private static readonly AsyncLazy s_none = new(value: null); private readonly IVsFileChangeEx _fileChangeService; private readonly string _filePath; @@ -49,7 +49,7 @@ internal sealed class FileChangeTracker : IVsFreeThreadedFileChangeEvents2, IDis /// and easy to delete if this lock has contention itself. Given we tend to call on the UI /// thread, I don't expect to see contention. /// - private static readonly object s_lastBackgroundTaskGate = new object(); + private static readonly object s_lastBackgroundTaskGate = new(); public FileChangeTracker(IVsFileChangeEx fileChangeService, string filePath, _VSFILECHANGEFLAGS fileChangeFlags = DefaultFileChangeFlags) { diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcher.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcher.cs index d7d25414717..caf142f9440 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcher.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcher.cs @@ -27,7 +27,7 @@ internal sealed class FileChangeWatcher /// /// Gate that is used to guard modifications to . /// - private readonly object _taskQueueGate = new object(); + private readonly object _taskQueueGate = new(); /// /// We create a queue of tasks against the IVsFileChangeEx service for two reasons. First, we are obtaining the service asynchronously, and don't want to @@ -160,9 +160,9 @@ private sealed class Context : IVsFreeThreadedFileChangeEvents2, IContext /// /// Gate to guard mutable fields in this class and any mutation of any s. /// - private readonly object _gate = new object(); + private readonly object _gate = new(); private bool _disposed = false; - private readonly HashSet _activeFileWatchingTokens = new HashSet(); + private readonly HashSet _activeFileWatchingTokens = new(); /// /// The list of cookies we used to make watchers for . @@ -171,7 +171,7 @@ private sealed class Context : IVsFreeThreadedFileChangeEvents2, IContext /// This does not need to be used under , as it's only used inside the actual queue of file watcher /// actions. /// - private readonly List _directoryWatchCookies = new List(); + private readonly List _directoryWatchCookies = new(); public Context(FileChangeWatcher fileChangeWatcher, ImmutableArray watchedDirectories) { diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcherProvider.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcherProvider.cs index ba33552b9e6..ddc27c965b2 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcherProvider.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcherProvider.cs @@ -18,7 +18,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem [Export(typeof(FileChangeWatcherProvider))] internal sealed class FileChangeWatcherProvider { - private readonly TaskCompletionSource _fileChangeService = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + private readonly TaskCompletionSource _fileChangeService = new(TaskCreationOptions.RunContinuationsAsynchronously); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs index a6b4e3b3e3a..f075dc849f3 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs @@ -304,7 +304,7 @@ private static Guid GetProjectIDGuid(IVsHierarchy hierarchy) /// /// Using item IDs as a key like this in a long-lived way is considered unsupported by CPS and other /// IVsHierarchy providers, but this code (which is fairly old) still makes the assumptions anyways. - private readonly Dictionary> _folderNameMap = new Dictionary>(); + private readonly Dictionary> _folderNameMap = new(); private ImmutableArray GetFolderNamesForDocument(uint documentItemID) { diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject_IProjectSiteEx.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject_IProjectSiteEx.cs index a9f77e44e8c..f7cb5b273f7 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject_IProjectSiteEx.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject_IProjectSiteEx.cs @@ -12,7 +12,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.L { internal abstract partial class AbstractLegacyProject : IProjectSiteEx { - private readonly Stack _batchScopes = new Stack(); + private readonly Stack _batchScopes = new(); public void StartBatch() => _batchScopes.Push(VisualStudioProject.CreateBatchScope()); diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/FileWatchedPortableExecutableReferenceFactory.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/FileWatchedPortableExecutableReferenceFactory.cs index 60cd68bba2d..f2e6ab67f5e 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/FileWatchedPortableExecutableReferenceFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/FileWatchedPortableExecutableReferenceFactory.cs @@ -18,7 +18,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.M [Export] internal sealed class FileWatchedPortableExecutableReferenceFactory { - private readonly object _gate = new object(); + private readonly object _gate = new(); /// /// This right now acquires the entire VisualStudioWorkspace because right now the production @@ -37,14 +37,14 @@ internal sealed class FileWatchedPortableExecutableReferenceFactory /// File watching tokens from that are watching metadata references. These are only created once we are actually applying a batch because /// we don't determine until the batch is applied if the file reference will actually be a file reference or it'll be a converted project reference. /// - private readonly Dictionary _metadataReferenceFileWatchingTokens = new Dictionary(); + private readonly Dictionary _metadataReferenceFileWatchingTokens = new(); /// /// s for in-flight refreshing of metadata references. When we see a file change, we wait a bit before trying to actually /// update the workspace. We need cancellation tokens for those so we can cancel them either when a flurry of events come in (so we only do the delay after the last /// modification), or when we know the project is going away entirely. /// - private readonly Dictionary _metadataReferenceRefreshCancellationTokenSources = new Dictionary(); + private readonly Dictionary _metadataReferenceRefreshCancellationTokenSources = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.MetadataCache.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.MetadataCache.cs index 80ecf427db0..f38351a9cff 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.MetadataCache.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.MetadataCache.cs @@ -18,10 +18,10 @@ private sealed class MetadataCache private const int InitialCapacity = 64; private const int CapacityMultiplier = 2; - private readonly object _gate = new object(); + private readonly object _gate = new(); // value is ValueSource so that how metadata is re-acquired back are different per entry. - private readonly Dictionary>> _metadataCache = new Dictionary>>(); + private readonly Dictionary>> _metadataCache = new(); private int _capacity = InitialCapacity; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs index c0028485b26..e53edbec025 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs @@ -33,8 +33,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem /// internal sealed partial class VisualStudioMetadataReferenceManager : IWorkspaceService { - private static readonly Guid s_IID_IMetaDataImport = new Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44"); - private static readonly ConditionalWeakTable s_lifetimeMap = new ConditionalWeakTable(); + private static readonly Guid s_IID_IMetaDataImport = new("7DAC8207-D3AE-4c75-9B67-92801A497D44"); + private static readonly ConditionalWeakTable s_lifetimeMap = new(); private readonly MetadataCache _metadataCache; private readonly ImmutableArray _runtimeDirectories; @@ -52,7 +52,7 @@ internal sealed partial class VisualStudioMetadataReferenceManager : IWorkspaceS internal IVsFileChangeEx FileChangeService { get; } - private readonly ReaderWriterLockSlim _readerWriterLock = new ReaderWriterLockSlim(); + private readonly ReaderWriterLockSlim _readerWriterLock = new(); internal VisualStudioMetadataReferenceManager(IServiceProvider serviceProvider, ITemporaryStorageService temporaryStorageService) { diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs index d42933bc167..1ee89cf4911 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs @@ -34,7 +34,7 @@ internal sealed partial class MiscellaneousFilesWorkspace : Workspace, IRunningD private readonly RunningDocumentTableEventTracker _runningDocumentTableEventTracker; - private readonly Dictionary _languageInformationByLanguageGuid = new Dictionary(); + private readonly Dictionary _languageInformationByLanguageGuid = new(); /// /// instances for all open buffers being tracked by by this object diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/RuleSets/VisualStudioRuleSetManager.RuleSetFile.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/RuleSets/VisualStudioRuleSetManager.RuleSetFile.cs index 5d5836f87de..53f147109bb 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/RuleSets/VisualStudioRuleSetManager.RuleSetFile.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/RuleSets/VisualStudioRuleSetManager.RuleSetFile.cs @@ -16,7 +16,7 @@ internal sealed partial class VisualStudioRuleSetManager private sealed class RuleSetFile : IRuleSetFile, IDisposable { private readonly VisualStudioRuleSetManager _ruleSetManager; - private readonly object _gate = new object(); + private readonly object _gate = new(); private FileChangeWatcher.IContext _fileChangeContext; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/RuleSets/VisualStudioRuleSetManager.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/RuleSets/VisualStudioRuleSetManager.cs index 44557a8c799..5b1cf07b572 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/RuleSets/VisualStudioRuleSetManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/RuleSets/VisualStudioRuleSetManager.cs @@ -17,7 +17,7 @@ internal sealed partial class VisualStudioRuleSetManager : IWorkspaceService private readonly IForegroundNotificationService _foregroundNotificationService; private readonly IAsynchronousOperationListener _listener; - private readonly ReferenceCountedDisposableCache _ruleSetFileMap = new ReferenceCountedDisposableCache(); + private readonly ReferenceCountedDisposableCache _ruleSetFileMap = new(); public VisualStudioRuleSetManager( FileChangeWatcher fileChangeWatcher, IForegroundNotificationService foregroundNotificationService, IAsynchronousOperationListener listener) diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/SolutionChangeAccumulator.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/SolutionChangeAccumulator.cs index 264a74f7731..aedacaa1537 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/SolutionChangeAccumulator.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/SolutionChangeAccumulator.cs @@ -22,7 +22,7 @@ internal class SolutionChangeAccumulator /// if we can't give a more precise type. /// private WorkspaceChangeKind? _workspaceChangeKind; - private readonly List _documentIdsRemoved = new List(); + private readonly List _documentIdsRemoved = new(); public SolutionChangeAccumulator(Solution startingSolution) => Solution = startingSolution; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioAddSolutionItemService.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioAddSolutionItemService.cs index 4668e5212c2..977016acd53 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioAddSolutionItemService.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioAddSolutionItemService.cs @@ -27,7 +27,7 @@ internal partial class VisualStudioAddSolutionItemService : IAddSolutionItemServ { private const string SolutionItemsFolderName = "Solution Items"; - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly IThreadingContext _threadingContext; private readonly ConcurrentDictionary _fileChangeTrackers; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioAnalyzer.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioAnalyzer.cs index 43ce0dc333b..b112acbff40 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioAnalyzer.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioAnalyzer.cs @@ -28,7 +28,7 @@ internal sealed class VisualStudioAnalyzer : IDisposable private readonly string _language; // these 2 are mutable states that must be guarded under the _gate. - private readonly object _gate = new object(); + private readonly object _gate = new(); private AnalyzerReference? _analyzerReference; private ImmutableArray _analyzerLoadErrors = ImmutableArray.Empty; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioMefHostServices.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioMefHostServices.cs index 4f85da07739..a68fcb5d2f6 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioMefHostServices.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioMefHostServices.cs @@ -35,7 +35,7 @@ private VisualStudioMefHostServices(ExportProvider exportProvider) } public static VisualStudioMefHostServices Create(ExportProvider exportProvider) - => new VisualStudioMefHostServices(exportProvider); + => new(exportProvider); /// /// Creates a new associated with the specified workspace. diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProject.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProject.cs index f9f4e74e608..f6e15801dfd 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProject.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProject.cs @@ -39,23 +39,23 @@ internal sealed class VisualStudioProject /// /// This is, for now, intentionally pessimistic. There are no doubt ways that we could allow more to run in parallel, /// but the current tradeoff is for simplicity of code and "obvious correctness" than something that is subtle, fast, and wrong. - private readonly object _gate = new object(); + private readonly object _gate = new(); /// /// The number of active batch scopes. If this is zero, we are not batching, non-zero means we are batching. /// private int _activeBatchScopes = 0; - private readonly List<(string path, MetadataReferenceProperties properties)> _metadataReferencesAddedInBatch = new List<(string path, MetadataReferenceProperties properties)>(); - private readonly List<(string path, MetadataReferenceProperties properties)> _metadataReferencesRemovedInBatch = new List<(string path, MetadataReferenceProperties properties)>(); - private readonly List _projectReferencesAddedInBatch = new List(); - private readonly List _projectReferencesRemovedInBatch = new List(); + private readonly List<(string path, MetadataReferenceProperties properties)> _metadataReferencesAddedInBatch = new(); + private readonly List<(string path, MetadataReferenceProperties properties)> _metadataReferencesRemovedInBatch = new(); + private readonly List _projectReferencesAddedInBatch = new(); + private readonly List _projectReferencesRemovedInBatch = new(); - private readonly Dictionary _analyzerPathsToAnalyzers = new Dictionary(); - private readonly List _analyzersAddedInBatch = new List(); - private readonly List _analyzersRemovedInBatch = new List(); + private readonly Dictionary _analyzerPathsToAnalyzers = new(); + private readonly List _analyzersAddedInBatch = new(); + private readonly List _analyzersRemovedInBatch = new(); - private readonly List> _projectPropertyModificationsInBatch = new List>(); + private readonly List> _projectPropertyModificationsInBatch = new(); private string _assemblyName; private string _displayName; @@ -83,13 +83,13 @@ internal sealed class VisualStudioProject // Effective boolean value to determine if analyzers should be executed based on _runAnalyzersPropertyValue and _runAnalyzersDuringLiveAnalysisPropertyValue. private bool _runAnalyzers = true; - private readonly Dictionary> _allMetadataReferences = new Dictionary>(); + private readonly Dictionary> _allMetadataReferences = new(); /// /// The file watching tokens for the documents in this project. We get the tokens even when we're in a batch, so the files here /// may not be in the actual workspace yet. /// - private readonly Dictionary _documentFileWatchingTokens = new Dictionary(); + private readonly Dictionary _documentFileWatchingTokens = new(); /// /// A file change context used to watch source files, additional files, and analyzer config files for this project. It's automatically set to watch the user's project @@ -100,7 +100,7 @@ internal sealed class VisualStudioProject /// /// track whether we have been subscribed to event /// - private readonly HashSet _eventSubscriptionTracker = new HashSet(); + private readonly HashSet _eventSubscriptionTracker = new(); /// /// Map of the original dynamic file path to the that was associated with it. @@ -114,7 +114,7 @@ internal sealed class VisualStudioProject /// The workspace snapshot will only have a document with (the value) but not the /// original dynamic file path (the key). /// - private readonly Dictionary _dynamicFilePathMaps = new Dictionary(); + private readonly Dictionary _dynamicFilePathMaps = new(); private readonly BatchingDocumentCollection _sourceFiles; private readonly BatchingDocumentCollection _additionalFiles; @@ -1141,7 +1141,7 @@ private sealed class BatchingDocumentCollection /// The map of file paths to the underlying . This document may exist in or has been /// pushed to the actual workspace. /// - private readonly Dictionary _documentPathsToDocumentIds = new Dictionary(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _documentPathsToDocumentIds = new(StringComparer.OrdinalIgnoreCase); /// /// A map of explicitly-added "always open" and their associated . This does not contain @@ -1152,7 +1152,7 @@ private sealed class BatchingDocumentCollection /// /// The map of to whose got added into /// - private readonly Dictionary _documentIdToDynamicFileInfoProvider = new Dictionary(); + private readonly Dictionary _documentIdToDynamicFileInfoProvider = new(); /// /// The current list of documents that are to be added in this batch. @@ -1162,7 +1162,7 @@ private sealed class BatchingDocumentCollection /// /// The current list of documents that are being removed in this batch. Once the document is in this list, it is no longer in . /// - private readonly List _documentsRemovedInBatch = new List(); + private readonly List _documentsRemovedInBatch = new(); /// /// The current list of document file paths that will be ordered in a batch. diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectOptionsProcessor.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectOptionsProcessor.cs index 7b91757ee8c..2ce37ca6361 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectOptionsProcessor.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectOptionsProcessor.cs @@ -26,7 +26,7 @@ internal class VisualStudioProjectOptionsProcessor : IDisposable /// Gate to guard all mutable fields in this class. /// The lock hierarchy means you are allowed to call out of this class and into while holding the lock. /// - private readonly object _gate = new object(); + private readonly object _gate = new(); /// /// A hashed checksum of the last command line we were set to. We use this diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs index b197fd80b4c..25faeffe571 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs @@ -24,7 +24,7 @@ internal sealed partial class VisualStudioProjectTracker internal HostWorkspaceServices WorkspaceServices => _workspace.Services; [Obsolete("This is a compatibility shim for TypeScript; please do not use it.")] - private readonly Dictionary _projects = new Dictionary(); + private readonly Dictionary _projects = new(); [Obsolete("This is a compatibility shim; please do not use it.")] public VisualStudioProjectTracker(Workspace workspace, VisualStudioProjectFactory projectFactory, IThreadingContext threadingContext) diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.OpenFileTracker.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.OpenFileTracker.cs index a2bb37c9085..ca9fac27b72 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.OpenFileTracker.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.OpenFileTracker.cs @@ -46,7 +46,7 @@ public sealed class OpenFileTracker : IRunningDocumentTableEventListener /// and . These are the only mutable fields /// in this class that are modified from multiple threads. /// - private readonly object _gate = new object(); + private readonly object _gate = new(); private HashSet? _fileNamesToCheckForOpenDocuments; /// @@ -62,14 +62,14 @@ public sealed class OpenFileTracker : IRunningDocumentTableEventListener #region Fields read/and written to only on the UI thread to track active context for files - private readonly ReferenceCountedDisposableCache _hierarchyEventSinkCache = new ReferenceCountedDisposableCache(); + private readonly ReferenceCountedDisposableCache _hierarchyEventSinkCache = new(); /// /// The IVsHierarchies we have subscribed to to watch for any changes to this moniker. We track this per moniker, so /// when a document is closed we know what we have to incrementally unsubscribe from rather than having to unsubscribe from everything. /// private readonly MultiDictionary>> _watchedHierarchiesForDocumentMoniker - = new MultiDictionary>>(); + = new(); #endregion diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs index 897a01a2b9f..f879c2d3ca2 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs @@ -53,7 +53,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem /// internal abstract partial class VisualStudioWorkspaceImpl : VisualStudioWorkspace { - private static readonly IntPtr s_docDataExisting_Unknown = new IntPtr(-1); + private static readonly IntPtr s_docDataExisting_Unknown = new(-1); private const string AppCodeFolderName = "App_Code"; private readonly IThreadingContext _threadingContext; @@ -65,7 +65,7 @@ internal abstract partial class VisualStudioWorkspaceImpl : VisualStudioWorkspac private readonly ITextBufferCloneService _textBufferCloneService; - private readonly object _gate = new object(); + private readonly object _gate = new(); /// /// A to make assertions that stuff is on the right thread. @@ -74,18 +74,18 @@ internal abstract partial class VisualStudioWorkspaceImpl : VisualStudioWorkspac private ImmutableDictionary _projectToHierarchyMap = ImmutableDictionary.Empty; private ImmutableDictionary _projectToGuidMap = ImmutableDictionary.Empty; - private readonly Dictionary _projectToMaxSupportedLangVersionMap = new Dictionary(); + private readonly Dictionary _projectToMaxSupportedLangVersionMap = new(); /// /// A map to fetch the path to a rule set file for a project. This right now is only used to implement /// and any other use is extremely suspicious, since direct use of this is out of /// sync with the Workspace if there is active batching happening. /// - private readonly Dictionary> _projectToRuleSetFilePath = new Dictionary>(); + private readonly Dictionary> _projectToRuleSetFilePath = new(); - private readonly Dictionary> _projectSystemNameToProjectsMap = new Dictionary>(); + private readonly Dictionary> _projectSystemNameToProjectsMap = new(); - private readonly Dictionary _languageToProjectExistsUIContext = new Dictionary(); + private readonly Dictionary _languageToProjectExistsUIContext = new(); /// /// A set of documents that were added by , and aren't otherwise @@ -1559,7 +1559,7 @@ public void ApplyBatchChangeToWorkspace(Func _projectReferenceInfoMap = new Dictionary(); + private readonly Dictionary _projectReferenceInfoMap = new(); private ProjectReferenceInformation GetReferenceInfo_NoLock(ProjectId projectId) { @@ -1616,7 +1616,7 @@ protected internal override void OnProjectRemoved(ProjectId projectId) private sealed class ProjectReferenceInformation { - public readonly List OutputPaths = new List(); + public readonly List OutputPaths = new(); public readonly List<(string path, ProjectReference projectReference)> ConvertedProjectReferences = new List<(string path, ProjectReference)>(); } @@ -1626,7 +1626,7 @@ private sealed class ProjectReferenceInformation /// any bug by a project adding the wrong output path means we could end up with some duplication. /// In that case, we'll temporarily have two until (hopefully) somebody removes it. /// - private readonly Dictionary> _projectsByOutputPath = new Dictionary>(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary> _projectsByOutputPath = new(StringComparer.OrdinalIgnoreCase); public void AddProjectOutputPath(ProjectId projectId, string outputPath) { diff --git a/src/VisualStudio/Core/Def/Implementation/Snippets/AbstractSnippetInfoService.cs b/src/VisualStudio/Core/Def/Implementation/Snippets/AbstractSnippetInfoService.cs index 3018685972a..d01767eba6e 100644 --- a/src/VisualStudio/Core/Def/Implementation/Snippets/AbstractSnippetInfoService.cs +++ b/src/VisualStudio/Core/Def/Implementation/Snippets/AbstractSnippetInfoService.cs @@ -40,7 +40,7 @@ internal abstract class AbstractSnippetInfoService : ForegroundThreadAffinitized // Guard the snippets and snippetShortcut fields so that returned result sets are always // complete. - protected object cacheGuard = new object(); + protected object cacheGuard = new(); private readonly IAsynchronousOperationListener _waiter; private readonly IThreadingContext _threadingContext; diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableControlEventProcessorProvider.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableControlEventProcessorProvider.cs index 12fdce04269..cbc1bb319f8 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableControlEventProcessorProvider.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableControlEventProcessorProvider.cs @@ -14,7 +14,7 @@ public ITableControlEventProcessor GetAssociatedEventProcessor(IWpfTableControl => CreateEventProcessor(); protected virtual EventProcessor CreateEventProcessor() - => new EventProcessor(); + => new(); protected class EventProcessor : TableControlEventProcessorBase { diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/DiagnosticTableItem.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/DiagnosticTableItem.cs index 9b6086bfa06..749685c1ac9 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/DiagnosticTableItem.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/DiagnosticTableItem.cs @@ -44,7 +44,7 @@ public override ProjectId ProjectId => Data.ProjectId; public override LinePosition GetOriginalPosition() - => new LinePosition(Data.DataLocation?.OriginalStartLine ?? 0, Data.DataLocation?.OriginalStartColumn ?? 0); + => new(Data.DataLocation?.OriginalStartLine ?? 0, Data.DataLocation?.OriginalStartColumn ?? 0); public override string GetOriginalFilePath() => Data.DataLocation?.OriginalFilePath; @@ -78,7 +78,7 @@ public override bool EqualsIgnoringLocation(TableItem other) /// internal sealed class GroupingComparer : IEqualityComparer, IEqualityComparer { - public static readonly GroupingComparer Instance = new GroupingComparer(); + public static readonly GroupingComparer Instance = new(); public bool Equals(DiagnosticData left, DiagnosticData right) { diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/OpenDocumentTracker.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/OpenDocumentTracker.cs index 94fee1672ed..9e1909ddf08 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/OpenDocumentTracker.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/OpenDocumentTracker.cs @@ -12,9 +12,9 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource internal class OpenDocumentTracker where TItem : TableItem { - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly Dictionary>>> _map = - new Dictionary>>>(); + new(); private readonly Workspace _workspace; diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs index 20ea2554c93..5d7f0ccde83 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs @@ -15,11 +15,11 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource internal class TableEntriesFactory : ITableEntriesSnapshotFactory where TItem : TableItem { - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly AbstractTableDataSource _tableSource; private readonly AggregatedEntriesSource _entriesSources; - private readonly WeakReference _lastSnapshotWeakReference = new WeakReference(null); + private readonly WeakReference _lastSnapshotWeakReference = new(null); private int _lastVersion = 0; diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/TodoTableItem.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/TodoTableItem.cs index 1918513d3b7..cdffcec5234 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/TodoTableItem.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/TodoTableItem.cs @@ -44,7 +44,7 @@ public override ProjectId ProjectId => Data.DocumentId.ProjectId; public override LinePosition GetOriginalPosition() - => new LinePosition(Data.OriginalLine, Data.OriginalColumn); + => new(Data.OriginalLine, Data.OriginalColumn); public override string GetOriginalFilePath() => Data.OriginalFilePath; @@ -68,7 +68,7 @@ public override bool EqualsIgnoringLocation(TableItem other) /// internal sealed class GroupingComparer : IEqualityComparer, IEqualityComparer { - public static readonly GroupingComparer Instance = new GroupingComparer(); + public static readonly GroupingComparer Instance = new(); public bool Equals(TodoCommentData left, TodoCommentData right) { diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/ValueTypeCache.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/ValueTypeCache.cs index ff0fd1bab19..854e6cfa278 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/ValueTypeCache.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/ValueTypeCache.cs @@ -22,13 +22,13 @@ internal static class ValueTypeCache private class Cache where T : struct { - public static readonly Cache Instance = new Cache(); + public static readonly Cache Instance = new(); private static readonly Func s_boxer = v => (object)v; // this will be never released, must be used only for fixed size set private readonly ConcurrentDictionary _map = - new ConcurrentDictionary(concurrencyLevel: 2, capacity: 5); + new(concurrencyLevel: 2, capacity: 5); public object GetOrCreate(T value) => _map.GetOrAdd(value, s_boxer); diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs index 3c8cfc83f26..7c220da59dd 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs @@ -27,7 +27,7 @@ internal partial class VisualStudioDiagnosticListTable : VisualStudioBaseDiagnos /// private class BuildTableDataSource : AbstractTableDataSource { - private readonly object _key = new object(); + private readonly object _key = new(); private readonly ExternalErrorDiagnosticUpdateSource _buildErrorSource; diff --git a/src/VisualStudio/Core/Def/Implementation/TaskList/ExternalErrorDiagnosticUpdateSource.cs b/src/VisualStudio/Core/Def/Implementation/TaskList/ExternalErrorDiagnosticUpdateSource.cs index fc2cc533035..fdf25f36d20 100644 --- a/src/VisualStudio/Core/Def/Implementation/TaskList/ExternalErrorDiagnosticUpdateSource.cs +++ b/src/VisualStudio/Core/Def/Implementation/TaskList/ExternalErrorDiagnosticUpdateSource.cs @@ -53,7 +53,7 @@ internal sealed class ExternalErrorDiagnosticUpdateSource : IDiagnosticUpdateSou private readonly TaskQueue _taskQueue; // Gate for concurrent access and fields guarded with this gate. - private readonly object _gate = new object(); + private readonly object _gate = new(); private InProgressState? _stateDoNotAccessDirectly; private CancellationTokenSource? _activeCancellationSourceDoNotAccessDirectly; @@ -506,7 +506,7 @@ private void RaiseDiagnosticsRemoved(object? id, Solution solution, ProjectId? p CreateArgumentKey(id), _workspace, solution, projectId, documentId)); } - private static ArgumentKey CreateArgumentKey(object? id) => new ArgumentKey(id); + private static ArgumentKey CreateArgumentKey(object? id) => new(id); private void RaiseBuildProgressChanged(BuildProgress progress) => BuildProgressChanged?.Invoke(this, progress); @@ -538,7 +538,7 @@ private sealed class InProgressState /// /// This map may be accessed concurrently, so needs to ensure thread safety by using locks. /// - private readonly Dictionary> _allDiagnosticIdMap = new Dictionary>(); + private readonly Dictionary> _allDiagnosticIdMap = new(); /// /// Map from project ID to all the possible intellisense analyzer diagnostic IDs that can be reported in the project. @@ -549,7 +549,7 @@ private sealed class InProgressState /// /// This map may be accessed concurrently, so needs to ensure thread safety by using locks. /// - private readonly Dictionary> _liveDiagnosticIdMap = new Dictionary>(); + private readonly Dictionary> _liveDiagnosticIdMap = new(); // Fields that are used only from APIs invoked from serialized task queue, hence don't need to be thread safe. #region Serialized fields @@ -560,7 +560,7 @@ private sealed class InProgressState /// Integral counter value for each diagnostic is used to order the reported diagnostics in error list /// based on the order in which they were reported during build. /// - private readonly Dictionary> _projectMap = new Dictionary>(); + private readonly Dictionary> _projectMap = new(); /// /// Map from document ID to a dictionary of reported document level diagnostics to an integral counter. @@ -568,23 +568,23 @@ private sealed class InProgressState /// Integral counter value for each diagnostic is used to order the reported diagnostics in error list /// based on the order in which they were reported during build. /// - private readonly Dictionary> _documentMap = new Dictionary>(); + private readonly Dictionary> _documentMap = new(); /// /// Set of projects for which we have already cleared the build and intellisense diagnostics in the error list. /// - private readonly HashSet _projectsWithErrorsCleared = new HashSet(); + private readonly HashSet _projectsWithErrorsCleared = new(); /// /// Set of projects for which we have reported all intellisense/live diagnostics. /// - private readonly HashSet _projectsWithAllLiveErrorsReported = new HashSet(); + private readonly HashSet _projectsWithAllLiveErrorsReported = new(); /// /// Set of projects which have at least one project or document diagnostic in /// and/or . /// - private readonly HashSet _projectsWithErrors = new HashSet(); + private readonly HashSet _projectsWithErrors = new(); /// /// Last project for which build reported an error through one of the methods. @@ -909,7 +909,7 @@ public override int GetHashCode() private sealed class DiagnosticDataComparer : IEqualityComparer { - public static readonly DiagnosticDataComparer Instance = new DiagnosticDataComparer(); + public static readonly DiagnosticDataComparer Instance = new(); public bool Equals(DiagnosticData item1, DiagnosticData item2) { diff --git a/src/VisualStudio/Core/Def/Implementation/TaskList/HostDiagnosticUpdateSource.cs b/src/VisualStudio/Core/Def/Implementation/TaskList/HostDiagnosticUpdateSource.cs index 78b8550fcd7..f87c7c26e13 100644 --- a/src/VisualStudio/Core/Def/Implementation/TaskList/HostDiagnosticUpdateSource.cs +++ b/src/VisualStudio/Core/Def/Implementation/TaskList/HostDiagnosticUpdateSource.cs @@ -21,8 +21,8 @@ internal sealed class HostDiagnosticUpdateSource : AbstractHostDiagnosticUpdateS { private readonly Lazy _workspace; - private readonly object _gate = new object(); - private readonly Dictionary> _diagnosticMap = new Dictionary>(); + private readonly object _gate = new(); + private readonly Dictionary> _diagnosticMap = new(); [ImportingConstructor] [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] diff --git a/src/VisualStudio/Core/Def/Implementation/TodoComments/VisualStudioTodoCommentsService.cs b/src/VisualStudio/Core/Def/Implementation/TodoComments/VisualStudioTodoCommentsService.cs index 55f4b0dcde9..cbf70f3f7ee 100644 --- a/src/VisualStudio/Core/Def/Implementation/TodoComments/VisualStudioTodoCommentsService.cs +++ b/src/VisualStudio/Core/Def/Implementation/TodoComments/VisualStudioTodoCommentsService.cs @@ -43,7 +43,7 @@ internal class VisualStudioTodoCommentsService private readonly EventListenerTracker _eventListenerTracker; private readonly ConcurrentDictionary> _documentToInfos - = new ConcurrentDictionary>(); + = new(); /// /// Remote service connection. Created on demand when we startup and then @@ -55,7 +55,7 @@ internal class VisualStudioTodoCommentsService /// Queue where we enqueue the information we get from OOP to process in batch in the future. /// private readonly TaskCompletionSource> _workQueueSource - = new TaskCompletionSource>(); + = new(); public event EventHandler? TodoListUpdated; diff --git a/src/VisualStudio/Core/Def/Implementation/Utilities/SymbolViewModel.cs b/src/VisualStudio/Core/Def/Implementation/Utilities/SymbolViewModel.cs index cf787535fc5..01be1e3b79b 100644 --- a/src/VisualStudio/Core/Def/Implementation/Utilities/SymbolViewModel.cs +++ b/src/VisualStudio/Core/Def/Implementation/Utilities/SymbolViewModel.cs @@ -15,13 +15,13 @@ internal class SymbolViewModel : AbstractNotifyPropertyChanged where T : ISym public T Symbol { get; } - private static readonly SymbolDisplayFormat s_symbolDisplayFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_symbolDisplayFormat = new( genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, memberOptions: SymbolDisplayMemberOptions.IncludeParameters, parameterOptions: SymbolDisplayParameterOptions.IncludeType | SymbolDisplayParameterOptions.IncludeParamsRefOut | SymbolDisplayParameterOptions.IncludeOptionalBrackets, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers | SymbolDisplayMiscellaneousOptions.UseSpecialTypes | SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier); - private static readonly SymbolDisplayFormat s_symbolAutomationFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_symbolAutomationFormat = new( genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, memberOptions: SymbolDisplayMemberOptions.IncludeParameters, parameterOptions: SymbolDisplayParameterOptions.IncludeType | SymbolDisplayParameterOptions.IncludeParamsRefOut | SymbolDisplayParameterOptions.IncludeOptionalBrackets, diff --git a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.DocumentServiceProvider.cs b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.DocumentServiceProvider.cs index 325acc1c63f..e3783d425f0 100644 --- a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.DocumentServiceProvider.cs +++ b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.DocumentServiceProvider.cs @@ -293,7 +293,7 @@ private static (SourceText, TextSpan) GetContentAndMappedSpan(ExcerptMode mode, } private static TextSpan GetSpanOnContent(TextSpan targetSpan, TextSpan excerptSpan) - => new TextSpan(targetSpan.Start - excerptSpan.Start, targetSpan.Length); + => new(targetSpan.Start - excerptSpan.Start, targetSpan.Length); } } } diff --git a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs index fb668d6dbcb..e74947bb387 100644 --- a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs +++ b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs @@ -55,13 +55,13 @@ internal sealed partial class ContainedDocument : ForegroundThreadAffinitizedObj private const string FunctionsRazor = "functions"; private const string CodeRazor = "code"; - private static readonly EditOptions s_venusEditOptions = new EditOptions(new StringDifferenceOptions + private static readonly EditOptions s_venusEditOptions = new(new StringDifferenceOptions { DifferenceType = StringDifferenceTypes.Character, IgnoreTrimWhiteSpace = false }); - private static readonly ConcurrentDictionary s_containedDocuments = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary s_containedDocuments = new(); public static ContainedDocument TryGetContainedDocument(DocumentId id) { diff --git a/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs b/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs index e51c5e7179a..1d70d3f2d9c 100644 --- a/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs +++ b/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs @@ -21,7 +21,7 @@ internal static class WatsonReporter { private static Dictionary? s_capturedFileContent; - private static readonly object _guard = new object(); + private static readonly object _guard = new(); private static ImmutableArray s_telemetrySessions = ImmutableArray.Empty; private static ImmutableArray s_loggers = ImmutableArray.Empty; diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/SourceGeneratedFileManager.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/SourceGeneratedFileManager.cs index 92b99935519..3b4672f17d0 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/SourceGeneratedFileManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/SourceGeneratedFileManager.cs @@ -54,7 +54,7 @@ internal sealed class SourceGeneratedFileManager : IRunningDocumentTableEventLis /// /// Map of currently open generated files; the key is the generated full file path. /// - private readonly Dictionary _openFiles = new Dictionary(); + private readonly Dictionary _openFiles = new(); private readonly VisualStudioWorkspace _visualStudioWorkspace; [ImportingConstructor] @@ -216,7 +216,7 @@ private class OpenSourceGeneratedFile : ForegroundThreadAffinitizedObject, IDisp /// A cancellation token used for any background updating of this file; this is cancelled on the UI thread /// when the file is closed. /// - private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); + private readonly CancellationTokenSource _cancellationTokenSource = new(); /// /// A queue used to batch updates to the file. diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioDocumentTrackingServiceFactory.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioDocumentTrackingServiceFactory.cs index 195e95d9ff9..e79d8acf668 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioDocumentTrackingServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioDocumentTrackingServiceFactory.cs @@ -35,7 +35,7 @@ public VisualStudioDocumentTrackingService(VisualStudioActiveDocumentTracker act _workspace = workspace; } - private readonly object _gate = new object(); + private readonly object _gate = new(); private int _subscriptions = 0; private event EventHandler _activeDocumentChangedEventHandler; diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioNavigationOptions.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioNavigationOptions.cs index a8b0124619b..3d9e02d4898 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioNavigationOptions.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioNavigationOptions.cs @@ -10,7 +10,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation { internal static class VisualStudioNavigationOptions { - public static readonly PerLanguageOption2 NavigateToObjectBrowser = new PerLanguageOption2(nameof(VisualStudioNavigationOptions), nameof(NavigateToObjectBrowser), defaultValue: false, + public static readonly PerLanguageOption2 NavigateToObjectBrowser = new(nameof(VisualStudioNavigationOptions), nameof(NavigateToObjectBrowser), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.NavigateToObjectBrowser")); } } diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioProjectCacheHostServiceFactory.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioProjectCacheHostServiceFactory.cs index 7c6d291898a..f0ecfce2943 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioProjectCacheHostServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioProjectCacheHostServiceFactory.cs @@ -87,7 +87,7 @@ internal static void ConnectProjectCacheServiceToDocumentTracking(HostWorkspaceS private class ActiveProjectCacheManager { private readonly ProjectCacheService _projectCacheService; - private readonly object _guard = new object(); + private readonly object _guard = new(); private ProjectId _mostRecentActiveProjectId; private IDisposable _mostRecentCache; diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioWorkspaceStatusServiceFactory.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioWorkspaceStatusServiceFactory.cs index 5c0a194ea81..f71a4979687 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioWorkspaceStatusServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioWorkspaceStatusServiceFactory.cs @@ -63,7 +63,7 @@ public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) /// private class Service : IWorkspaceStatusService { - private readonly SemaphoreSlim _initializationGate = new SemaphoreSlim(initialCount: 1); + private readonly SemaphoreSlim _initializationGate = new(initialCount: 1); private readonly IAsyncServiceProvider2 _serviceProvider; private bool _initialized = false; diff --git a/src/VisualStudio/Core/Def/Packaging/PackageInstallerService.ProjectState.cs b/src/VisualStudio/Core/Def/Packaging/PackageInstallerService.ProjectState.cs index 7d16436e569..503bdeacb0e 100644 --- a/src/VisualStudio/Core/Def/Packaging/PackageInstallerService.ProjectState.cs +++ b/src/VisualStudio/Core/Def/Packaging/PackageInstallerService.ProjectState.cs @@ -13,7 +13,7 @@ internal partial class PackageInstallerService { private struct ProjectState { - public static readonly ProjectState Disabled = new ProjectState(isEnabled: false, ImmutableDictionary.Empty); + public static readonly ProjectState Disabled = new(isEnabled: false, ImmutableDictionary.Empty); public readonly bool IsEnabled; diff --git a/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs b/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs index de547b16d50..e337d5b0d99 100644 --- a/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs @@ -77,12 +77,12 @@ internal partial class PackageInstallerService : AbstractDelayStartedService, IP private readonly AsyncBatchingWorkQueue<(bool solutionChanged, ProjectId? changedProject)>? _workQueue; private readonly ConcurrentDictionary _projectToInstalledPackageAndVersion = - new ConcurrentDictionary(); + new(); /// /// Lock used to protect reads and writes of . /// - private readonly object _gate = new object(); + private readonly object _gate = new(); /// /// Task uses to compute the set of package sources on demand when asked the first time. The value will be diff --git a/src/VisualStudio/Core/Def/RoslynActivityLogger.cs b/src/VisualStudio/Core/Def/RoslynActivityLogger.cs index 22aad96cc45..a7ace4333c8 100644 --- a/src/VisualStudio/Core/Def/RoslynActivityLogger.cs +++ b/src/VisualStudio/Core/Def/RoslynActivityLogger.cs @@ -23,7 +23,7 @@ namespace Microsoft.VisualStudio.LanguageServices /// internal static class RoslynActivityLogger { - private static readonly object s_gate = new object(); + private static readonly object s_gate = new(); public static void SetLogger(TraceSource traceSource) { diff --git a/src/VisualStudio/Core/Def/Shared/VisualStudioImageMonikerService.cs b/src/VisualStudio/Core/Def/Shared/VisualStudioImageMonikerService.cs index 0e3a2110ccd..6feda621e72 100644 --- a/src/VisualStudio/Core/Def/Shared/VisualStudioImageMonikerService.cs +++ b/src/VisualStudio/Core/Def/Shared/VisualStudioImageMonikerService.cs @@ -41,7 +41,7 @@ internal class VisualStudioImageMonikerService : ForegroundThreadAffinitizedObje private readonly IVsImageService2 _imageService; // We have to keep the image handles around to keep the compound glyph alive. - private readonly List _compositeImages = new List(); + private readonly List _compositeImages = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/VisualStudio/Core/Def/SolutionEventMonitor.cs b/src/VisualStudio/Core/Def/SolutionEventMonitor.cs index 3b1eda83f63..fe638052c59 100644 --- a/src/VisualStudio/Core/Def/SolutionEventMonitor.cs +++ b/src/VisualStudio/Core/Def/SolutionEventMonitor.cs @@ -19,7 +19,7 @@ internal sealed class SolutionEventMonitor : IDisposable private const string SolutionOpening = "Solution Opening"; private IGlobalOperationNotificationService _notificationService; - private readonly Dictionary _operations = new Dictionary(); + private readonly Dictionary _operations = new(); public SolutionEventMonitor(VisualStudioWorkspace workspace) { diff --git a/src/VisualStudio/Core/Def/SymbolSearch/AbstractDelayStartedService.cs b/src/VisualStudio/Core/Def/SymbolSearch/AbstractDelayStartedService.cs index 62ecaa2f5ac..e6c312ba6c4 100644 --- a/src/VisualStudio/Core/Def/SymbolSearch/AbstractDelayStartedService.cs +++ b/src/VisualStudio/Core/Def/SymbolSearch/AbstractDelayStartedService.cs @@ -21,7 +21,7 @@ namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch /// internal abstract class AbstractDelayStartedService : ForegroundThreadAffinitizedObject { - private readonly List _registeredLanguageNames = new List(); + private readonly List _registeredLanguageNames = new(); protected readonly Workspace Workspace; diff --git a/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.LogService.cs b/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.LogService.cs index 8a6be3647de..665946756e5 100644 --- a/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.LogService.cs +++ b/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.LogService.cs @@ -15,7 +15,7 @@ internal partial class VisualStudioSymbolSearchService { private class LogService : ForegroundThreadAffinitizedObject, ISymbolSearchLogService { - private static readonly LinkedList s_log = new LinkedList(); + private static readonly LinkedList s_log = new(); private readonly IVsActivityLog _activityLog; diff --git a/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.cs b/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.cs index 05295bdd9cd..2cb0c1a139c 100644 --- a/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.cs +++ b/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.cs @@ -34,7 +34,7 @@ namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch [ExportWorkspaceService(typeof(ISymbolSearchService), ServiceLayer.Host), Shared] internal partial class VisualStudioSymbolSearchService : AbstractDelayStartedService, ISymbolSearchService { - private readonly SemaphoreSlim _gate = new SemaphoreSlim(initialCount: 1); + private readonly SemaphoreSlim _gate = new(initialCount: 1); // Note: A remote engine is disposable as it maintains a connection with ServiceHub, // but we want to keep it alive until the VS is closed, so we don't dispose it. diff --git a/src/VisualStudio/Core/Def/Telemetry/CodeMarkerLogger.cs b/src/VisualStudio/Core/Def/Telemetry/CodeMarkerLogger.cs index d193b8d3250..0fec26e65ab 100644 --- a/src/VisualStudio/Core/Def/Telemetry/CodeMarkerLogger.cs +++ b/src/VisualStudio/Core/Def/Telemetry/CodeMarkerLogger.cs @@ -13,10 +13,10 @@ namespace Microsoft.VisualStudio.LanguageServices.Telemetry { internal sealed class CodeMarkerLogger : ILogger { - public static readonly CodeMarkerLogger Instance = new CodeMarkerLogger(); + public static readonly CodeMarkerLogger Instance = new(); private static readonly Dictionary>> s_blockMap - = new Dictionary>>() + = new() { { FunctionId.NavigateTo_Search, new List>() { @@ -111,7 +111,7 @@ internal sealed class CodeMarkerLogger : ILogger }; private static readonly Dictionary> s_map - = new Dictionary>() + = new() { { FunctionId.Rename_InlineSession, new List() { CodeMarkerEvent.perfVBRenameSymbolEnd } }, { FunctionId.BackgroundCompiler_BuildCompilationsAsync, new List() { CodeMarkerEvent.perfVBCompilerReachedBoundState, CodeMarkerEvent.perfVBCompilerReachedCompiledState } }, diff --git a/src/VisualStudio/Core/Def/Telemetry/VSTelemetryCache.cs b/src/VisualStudio/Core/Def/Telemetry/VSTelemetryCache.cs index e29aebf85f5..1573ac4a9b0 100644 --- a/src/VisualStudio/Core/Def/Telemetry/VSTelemetryCache.cs +++ b/src/VisualStudio/Core/Def/Telemetry/VSTelemetryCache.cs @@ -16,8 +16,8 @@ internal static class VSTelemetryCache // these don't have concurrency limit on purpose to reduce chance of lock contention. // if that becomes a problem - by showing up in our perf investigation, then we will consider adding concurrency limit. - private static readonly ConcurrentDictionary s_eventMap = new ConcurrentDictionary(); - private static readonly ConcurrentDictionary s_propertyMap = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary s_eventMap = new(); + private static readonly ConcurrentDictionary s_propertyMap = new(); public static string GetEventName(this FunctionId functionId, string eventKey = null) => s_eventMap.GetOrAdd(new Key(functionId, eventKey), CreateEventName); -- GitLab