From 63339b3dda39cd172d29de3f78d8318f4afeb085 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 21 May 2019 19:55:39 -0700 Subject: [PATCH] Make fields readonly --- .../Core.Wpf/InlineRename/Dashboard/Dashboard.xaml.cs | 2 +- src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs | 2 +- .../NavigateTo/DefaultNavigateToPreviewServiceFactory.cs | 2 +- .../Core.Wpf/Notification/EditorNotificationServiceFactory.cs | 2 +- ...LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs | 2 +- .../Core.Wpf/Structure/AbstractStructureTaggerProvider.cs | 2 +- .../Core.Wpf/SymbolSearch/SymbolSearchUpdateEngine.cs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/Dashboard.xaml.cs b/src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/Dashboard.xaml.cs index aafc3cf36d0..3d33d11d823 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/Dashboard.xaml.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/Dashboard.xaml.cs @@ -29,7 +29,7 @@ internal partial class Dashboard : UserControl, IDisposable internal bool ShouldReceiveKeyboardNavigation { get; set; } - private IEnumerable _renameAccessKeys = new[] + private readonly IEnumerable _renameAccessKeys = new[] { RenameShortcutKey.RenameOverloads, RenameShortcutKey.SearchInComments, diff --git a/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs b/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs index f10a0552c50..0b26470e7bf 100644 --- a/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs +++ b/src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs @@ -50,7 +50,7 @@ internal partial class InlineRenameSession : ForegroundThreadAffinitizedObject, private bool _isApplyingEdit; private string _replacementText; private OptionSet _optionSet; - private Dictionary _openTextBuffers = new Dictionary(); + private readonly Dictionary _openTextBuffers = new Dictionary(); /// /// If non-null, the current text of the replacement. Linked spans added will automatically be updated with this diff --git a/src/EditorFeatures/Core.Wpf/NavigateTo/DefaultNavigateToPreviewServiceFactory.cs b/src/EditorFeatures/Core.Wpf/NavigateTo/DefaultNavigateToPreviewServiceFactory.cs index b28524f853c..a9a89242518 100644 --- a/src/EditorFeatures/Core.Wpf/NavigateTo/DefaultNavigateToPreviewServiceFactory.cs +++ b/src/EditorFeatures/Core.Wpf/NavigateTo/DefaultNavigateToPreviewServiceFactory.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo [ExportWorkspaceServiceFactory(typeof(INavigateToPreviewService), ServiceLayer.Editor), Shared] internal sealed class DefaultNavigateToPreviewServiceFactory : IWorkspaceServiceFactory { - private Lazy _singleton = + private readonly Lazy _singleton = new Lazy(() => new DefaultNavigateToPreviewService()); public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) diff --git a/src/EditorFeatures/Core.Wpf/Notification/EditorNotificationServiceFactory.cs b/src/EditorFeatures/Core.Wpf/Notification/EditorNotificationServiceFactory.cs index 8614fa169d5..66d8c58b2a6 100644 --- a/src/EditorFeatures/Core.Wpf/Notification/EditorNotificationServiceFactory.cs +++ b/src/EditorFeatures/Core.Wpf/Notification/EditorNotificationServiceFactory.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Notification [Shared] internal class EditorNotificationServiceFactory : IWorkspaceServiceFactory { - private static object s_gate = new object(); + private static readonly object s_gate = new object(); private static EditorDialogService s_singleton; diff --git a/src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs b/src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs index be428d4e670..f5778e412d6 100644 --- a/src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs +++ b/src/EditorFeatures/Core.Wpf/Options/LegacyEditorConfigDocumentOptionsProvider.DocumentOptions.cs @@ -15,7 +15,7 @@ internal sealed partial class LegacyEditorConfigDocumentOptionsProvider : IDocum { private class DocumentOptions : IDocumentOptions { - private ICodingConventionsSnapshot _codingConventionSnapshot; + private readonly ICodingConventionsSnapshot _codingConventionSnapshot; private readonly IErrorLoggerService _errorLogger; private static readonly ConditionalWeakTable, IReadOnlyDictionary> s_convertedDictionaryCache = new ConditionalWeakTable, IReadOnlyDictionary>(); diff --git a/src/EditorFeatures/Core.Wpf/Structure/AbstractStructureTaggerProvider.cs b/src/EditorFeatures/Core.Wpf/Structure/AbstractStructureTaggerProvider.cs index 684e68df796..8ff6df188c6 100644 --- a/src/EditorFeatures/Core.Wpf/Structure/AbstractStructureTaggerProvider.cs +++ b/src/EditorFeatures/Core.Wpf/Structure/AbstractStructureTaggerProvider.cs @@ -35,7 +35,7 @@ internal abstract partial class AbstractStructureTaggerProvider : AsynchronousTaggerProvider where TRegionTag : class, ITag { - private static IComparer s_blockSpanComparer = + private static readonly IComparer s_blockSpanComparer = Comparer.Create((s1, s2) => s1.TextSpan.Start - s2.TextSpan.Start); protected readonly ITextEditorFactoryService TextEditorFactoryService; diff --git a/src/EditorFeatures/Core.Wpf/SymbolSearch/SymbolSearchUpdateEngine.cs b/src/EditorFeatures/Core.Wpf/SymbolSearch/SymbolSearchUpdateEngine.cs index 2bc83cd9a6c..76249089358 100644 --- a/src/EditorFeatures/Core.Wpf/SymbolSearch/SymbolSearchUpdateEngine.cs +++ b/src/EditorFeatures/Core.Wpf/SymbolSearch/SymbolSearchUpdateEngine.cs @@ -25,7 +25,7 @@ namespace Microsoft.CodeAnalysis.SymbolSearch /// internal partial class SymbolSearchUpdateEngine : ISymbolSearchUpdateEngine { - private ConcurrentDictionary _sourceToDatabase = + private readonly ConcurrentDictionary _sourceToDatabase = new ConcurrentDictionary(); public SymbolSearchUpdateEngine( -- GitLab