diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptBreakpointResolutionResultWrapper.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptBreakpointResolutionResultWrapper.cs index 8815102d0c9d3a5781efa3874cc9863438da039d..4479d9ead20e253b615ffb88359d21ae17838db4 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptBreakpointResolutionResultWrapper.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptBreakpointResolutionResultWrapper.cs @@ -22,9 +22,9 @@ private VSTypeScriptBreakpointResolutionResultWrapper(BreakpointResolutionResult public bool IsLineBreakpoint => UnderlyingObject.IsLineBreakpoint; public static VSTypeScriptBreakpointResolutionResultWrapper CreateSpanResult(Document document, TextSpan textSpan, string? locationNameOpt = null) - => new VSTypeScriptBreakpointResolutionResultWrapper(BreakpointResolutionResult.CreateSpanResult(document, textSpan, locationNameOpt)); + => new(BreakpointResolutionResult.CreateSpanResult(document, textSpan, locationNameOpt)); public static VSTypeScriptBreakpointResolutionResultWrapper CreateLineResult(Document document, string? locationNameOpt = null) - => new VSTypeScriptBreakpointResolutionResultWrapper(BreakpointResolutionResult.CreateLineResult(document, locationNameOpt)); + => new(BreakpointResolutionResult.CreateLineResult(document, locationNameOpt)); } } diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptEditorFormattingServiceWrapper.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptEditorFormattingServiceWrapper.cs index 8633b8c8338a1192daf3c4342b9aa9fbfd09c1c1..8917299f951a552305a49b5d5d43111ab218db04 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptEditorFormattingServiceWrapper.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptEditorFormattingServiceWrapper.cs @@ -20,7 +20,7 @@ private VSTypeScriptEditorFormattingServiceWrapper(IEditorFormattingService unde => _underlyingObject = underlyingObject; public static VSTypeScriptEditorFormattingServiceWrapper Create(Document document) - => new VSTypeScriptEditorFormattingServiceWrapper(document.Project.LanguageServices.GetRequiredService()); + => new(document.Project.LanguageServices.GetRequiredService()); public Task> GetFormattingChangesAsync(Document document, TextSpan? textSpan, CancellationToken cancellationToken) => _underlyingObject.GetFormattingChangesAsync(document, textSpan, cancellationToken); diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptIndentationServiceWrapper.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptIndentationServiceWrapper.cs index 02107fd0e580a30a094f33124eaf1441d80e4ef0..4afe0684f6f7d744530a0c7b42e771bec62b1e69 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptIndentationServiceWrapper.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptIndentationServiceWrapper.cs @@ -20,7 +20,7 @@ private VSTypeScriptIndentationServiceWrapper(IIndentationService underlyingObje => _underlyingObject = underlyingObject; public static VSTypeScriptIndentationServiceWrapper Create(Document document) - => new VSTypeScriptIndentationServiceWrapper(document.Project.LanguageServices.GetRequiredService()); + => new(document.Project.LanguageServices.GetRequiredService()); [SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "External access API.")] public async Task GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken) diff --git a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.DefinitionTrackingContext.cs b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.DefinitionTrackingContext.cs index d015f0cc1b3febac64fa186034c7edac4ef7c719..fe6d06cc807d5af10568e3e267bb1da3fb93f6c0 100644 --- a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.DefinitionTrackingContext.cs +++ b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.DefinitionTrackingContext.cs @@ -25,8 +25,8 @@ internal abstract partial class AbstractFindUsagesService private class DefinitionTrackingContext : IFindUsagesContext { private readonly IFindUsagesContext _underlyingContext; - private readonly object _gate = new object(); - private readonly List _definitions = new List(); + private readonly object _gate = new(); + private readonly List _definitions = new(); public DefinitionTrackingContext(IFindUsagesContext underlyingContext) => _underlyingContext = underlyingContext; diff --git a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs index d3ac21dece7cb671cb40205be7292d38cd88d778..b00b4aa697da48fa418472745f5ce94e86047ff3 100644 --- a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs +++ b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs @@ -65,9 +65,9 @@ private class FindReferencesProgressAdapter : IStreamingFindReferencesProgress /// all future callbacks. /// private readonly Dictionary _definitionToItem = - new Dictionary(MetadataUnifyingEquivalenceComparer.Instance); + new(MetadataUnifyingEquivalenceComparer.Instance); - private readonly SemaphoreSlim _gate = new SemaphoreSlim(initialCount: 1); + private readonly SemaphoreSlim _gate = new(initialCount: 1); public IStreamingProgressTracker ProgressTracker => _context.ProgressTracker; diff --git a/src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs b/src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs index 351b205a4b28b7ca1ebe1473108b676cb8dcda25..8f117faf6487aeef509d8a4c51ea02608fad1e34 100644 --- a/src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs +++ b/src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs @@ -60,7 +60,7 @@ private static SymbolDisplayFormat GetFormat(ISymbol definition) } private static readonly SymbolDisplayFormat s_definitionFormat = - new SymbolDisplayFormat( + new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly, genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, parameterOptions: SymbolDisplayParameterOptions.IncludeType, diff --git a/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs b/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs index f8727cf83a28c0be583c8cc1a9cbffd3e63f0a2f..fa97170a0832b5027803933974e1f0ceb22be6ee 100644 --- a/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs +++ b/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs @@ -52,7 +52,7 @@ public DefaultDefinitionsAndReferencesFactory() internal static class DefinitionItemExtensions { - private static readonly SymbolDisplayFormat s_namePartsFormat = new SymbolDisplayFormat( + private static readonly SymbolDisplayFormat s_namePartsFormat = new( memberOptions: SymbolDisplayMemberOptions.IncludeContainingType); public static DefinitionItem ToNonClassifiedDefinitionItem( diff --git a/src/EditorFeatures/Core/FindUsages/SimpleFindUsagesContext.cs b/src/EditorFeatures/Core/FindUsages/SimpleFindUsagesContext.cs index c8cf6b849ad90a23bc553f113b637a9ce8db5532..2062bde699e25159f482680371de07c56d97e428 100644 --- a/src/EditorFeatures/Core/FindUsages/SimpleFindUsagesContext.cs +++ b/src/EditorFeatures/Core/FindUsages/SimpleFindUsagesContext.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Editor.FindUsages /// internal class SimpleFindUsagesContext : FindUsagesContext { - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly ImmutableArray.Builder _definitionItems = ImmutableArray.CreateBuilder(); diff --git a/src/EditorFeatures/Core/GoToDefinition/GoToSymbolContext.cs b/src/EditorFeatures/Core/GoToDefinition/GoToSymbolContext.cs index 362789a8538f88db4ec068cd1ca6b6ba20d9cc79..043e808e77016d5d591e5049fc8b7b83d71b77ff 100644 --- a/src/EditorFeatures/Core/GoToDefinition/GoToSymbolContext.cs +++ b/src/EditorFeatures/Core/GoToDefinition/GoToSymbolContext.cs @@ -12,9 +12,9 @@ namespace Microsoft.CodeAnalysis.Editor.GoToDefinition { internal class GoToSymbolContext { - private readonly object _gate = new object(); + private readonly object _gate = new(); - private readonly MultiDictionary _items = new MultiDictionary(); + private readonly MultiDictionary _items = new(); public GoToSymbolContext(Document document, int position, CancellationToken cancellationToken) { diff --git a/src/EditorFeatures/Core/Implementation/BraceMatching/BraceHighlightTag.cs b/src/EditorFeatures/Core/Implementation/BraceMatching/BraceHighlightTag.cs index 8815e5afd598f5419f8babfc0a448585cb8ab350..fba20bbdcacb00e2daa5913393eb2c2681da9a9d 100644 --- a/src/EditorFeatures/Core/Implementation/BraceMatching/BraceHighlightTag.cs +++ b/src/EditorFeatures/Core/Implementation/BraceMatching/BraceHighlightTag.cs @@ -8,8 +8,8 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.BraceMatching { internal class BraceHighlightTag : TextMarkerTag { - public static readonly BraceHighlightTag StartTag = new BraceHighlightTag(navigateToStart: true); - public static readonly BraceHighlightTag EndTag = new BraceHighlightTag(navigateToStart: false); + public static readonly BraceHighlightTag StartTag = new(navigateToStart: true); + public static readonly BraceHighlightTag EndTag = new(navigateToStart: false); public bool NavigateToStart { get; } diff --git a/src/EditorFeatures/Core/Implementation/Classification/ClassificationUtilities.cs b/src/EditorFeatures/Core/Implementation/Classification/ClassificationUtilities.cs index 48ba12d153208f2ecb26e668c91eda993c7af72a..bc6eda5e79c65738a8f2d8e3db03af8787778740 100644 --- a/src/EditorFeatures/Core/Implementation/Classification/ClassificationUtilities.cs +++ b/src/EditorFeatures/Core/Implementation/Classification/ClassificationUtilities.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Classification { internal static class ClassificationUtilities { - private static readonly ConcurrentQueue> s_spanCache = new ConcurrentQueue>(); + private static readonly ConcurrentQueue> s_spanCache = new(); public static List GetOrCreateClassifiedSpanList() { diff --git a/src/EditorFeatures/Core/Implementation/Classification/SemanticClassificationUtilities.cs b/src/EditorFeatures/Core/Implementation/Classification/SemanticClassificationUtilities.cs index 789739d3d32e25174b8df70b563d89c6ecf670c8..9611039f4b2baf5c2e4694409cecb360b83b17c6 100644 --- a/src/EditorFeatures/Core/Implementation/Classification/SemanticClassificationUtilities.cs +++ b/src/EditorFeatures/Core/Implementation/Classification/SemanticClassificationUtilities.cs @@ -36,7 +36,7 @@ internal static class SemanticClassificationUtilities /// actually transitioned to a loaded state. /// private static readonly ConditionalWeakTable s_workspaceToFullyLoadedStateTask = - new ConditionalWeakTable(); + new(); public static async Task ProduceTagsAsync( TaggerContext context, diff --git a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.LastLineCache.cs b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.LastLineCache.cs index c45487eeb4de52adc695252d672ace04820c618c..42733adadb89f3c637d6226d402fb428b36e70f4 100644 --- a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.LastLineCache.cs +++ b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.LastLineCache.cs @@ -20,7 +20,7 @@ private class LastLineCache // this helper class is primarily to improve active typing perf. don't bother to cache // something very big. private const int MaxClassificationNumber = 32; - private readonly object _gate = new object(); + private readonly object _gate = new(); // mutating state private SnapshotSpan _span; diff --git a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs index 64f298b6637883b303f73ad306c65a354dfc471b..e99258eb8e07bff13ee0ff407377ce5ecdea03c7 100644 --- a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs +++ b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs @@ -56,7 +56,7 @@ internal partial class TagComputer // Note: we cache this data once we've retrieved the actual syntax tree for a document. This // way, when we call into the actual classification service, it should be very quick for the // it to get the tree if it needs it. - private readonly object _gate = new object(); + private readonly object _gate = new(); private ITextSnapshot _lastProcessedSnapshot; private Document _lastProcessedDocument; diff --git a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.cs index 655c61f59e59595e34baccb8da72af2bda91d45e..28fc7a4c67fe47a4638a0151df533367f3927ec9 100644 --- a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.cs +++ b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.cs @@ -27,7 +27,7 @@ internal partial class SyntacticClassificationTaggerProvider : ITaggerProvider private readonly IAsynchronousOperationListener _listener; private readonly ClassificationTypeMap _typeMap; - private readonly ConditionalWeakTable _tagComputers = new ConditionalWeakTable(); + private readonly ConditionalWeakTable _tagComputers = 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/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs b/src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs index 65f86d4a9913d8fbf0245ffb614f71609e16c3b7..67439110731cdccd61196240d1f34f36ca9796da 100644 --- a/src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs +++ b/src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs @@ -38,7 +38,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes internal partial class CodeFixService : ForegroundThreadAffinitizedObject, ICodeFixService { private static readonly Comparison s_diagnosticDataComparisonById = - new Comparison((d1, d2) => DiagnosticId.CompareOrdinal(d1.Id, d2.Id)); + new((d1, d2) => DiagnosticId.CompareOrdinal(d1.Id, d2.Id)); private readonly IDiagnosticAnalyzerService _diagnosticService; diff --git a/src/EditorFeatures/Core/Implementation/CommentSelection/AbstractToggleBlockCommentBase.cs b/src/EditorFeatures/Core/Implementation/CommentSelection/AbstractToggleBlockCommentBase.cs index 1deee85ca0b4c5ea3245f3500a10d7f8e52decb2..4c48b209013d52680522e980a8966094c04e67aa 100644 --- a/src/EditorFeatures/Core/Implementation/CommentSelection/AbstractToggleBlockCommentBase.cs +++ b/src/EditorFeatures/Core/Implementation/CommentSelection/AbstractToggleBlockCommentBase.cs @@ -29,7 +29,7 @@ internal abstract class AbstractToggleBlockCommentBase : ICommandHandler { private static readonly CommentSelectionResult s_emptyCommentSelectionResult = - new CommentSelectionResult(new List(), new List(), Operation.Uncomment); + new(new List(), new List(), Operation.Uncomment); private readonly ITextStructureNavigatorSelectorService _navigatorSelectorService; diff --git a/src/EditorFeatures/Core/Implementation/CommentSelection/ToggleLineCommentCommandHandler.cs b/src/EditorFeatures/Core/Implementation/CommentSelection/ToggleLineCommentCommandHandler.cs index f32838c584199eb9739d072a219b184a3ca9b3a7..ff15a500eb83793f3d98680f1d8690838bab503a 100644 --- a/src/EditorFeatures/Core/Implementation/CommentSelection/ToggleLineCommentCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/CommentSelection/ToggleLineCommentCommandHandler.cs @@ -34,7 +34,7 @@ internal class ToggleLineCommentCommandHandler : ICommandHandler { private static readonly CommentSelectionResult s_emptyCommentSelectionResult = - new CommentSelectionResult(new List(), new List(), Operation.Uncomment); + new(new List(), new List(), Operation.Uncomment); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs index 32aaa84b9a2a1e3c5e7a7ebe561ce7b7cba5cda0..08531334d73ec186d4c915738d19e0041e99b42d 100644 --- a/src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs +++ b/src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs @@ -52,7 +52,7 @@ internal abstract partial class AbstractDiagnosticsTaggerProvider : Asynch /// we're tagging. /// private static readonly ConditionalWeakTable _diagnosticIdToTextSnapshot = - new ConditionalWeakTable(); + new(); protected AbstractDiagnosticsTaggerProvider( IThreadingContext threadingContext, diff --git a/src/EditorFeatures/Core/Implementation/EditAndContinue/ActiveStatementTag.cs b/src/EditorFeatures/Core/Implementation/EditAndContinue/ActiveStatementTag.cs index c72e56781a41938c2d66310c88ee3c035791af29..ddf38b5007532a15e3f7b9ba9e4faa6736b80ecb 100644 --- a/src/EditorFeatures/Core/Implementation/EditAndContinue/ActiveStatementTag.cs +++ b/src/EditorFeatures/Core/Implementation/EditAndContinue/ActiveStatementTag.cs @@ -12,7 +12,7 @@ internal sealed class ActiveStatementTag : TextMarkerTag { internal const string TagId = "RoslynActiveStatementTag"; - public static readonly ActiveStatementTag Instance = new ActiveStatementTag(); + public static readonly ActiveStatementTag Instance = new(); private ActiveStatementTag() : base(TagId) diff --git a/src/EditorFeatures/Core/Implementation/ForegroundNotification/ForegroundNotificationService.cs b/src/EditorFeatures/Core/Implementation/ForegroundNotification/ForegroundNotificationService.cs index b874c2921cdab43eebfdc94650dafe0dd0e41037..83f4869aba381f4cd303492c3ba88da2e5e790bc 100644 --- a/src/EditorFeatures/Core/Implementation/ForegroundNotification/ForegroundNotificationService.cs +++ b/src/EditorFeatures/Core/Implementation/ForegroundNotification/ForegroundNotificationService.cs @@ -250,18 +250,18 @@ public PendingWork(int minimumRunPointInMS, Func work, IAsyncToken asyncTo } public PendingWork UpdateToCurrentTime() - => new PendingWork(Environment.TickCount, DoWorkAction, DoWorkFunc, AsyncToken, CancellationToken); + => new(Environment.TickCount, DoWorkAction, DoWorkFunc, AsyncToken, CancellationToken); } private class PriorityQueue { // use pool to share linked list nodes rather than re-create them every time private static readonly ObjectPool> s_pool = - new ObjectPool>(() => new LinkedListNode(default), 100); + new(() => new LinkedListNode(default), 100); - private readonly object _gate = new object(); - private readonly LinkedList _list = new LinkedList(); - private readonly SemaphoreSlim _hasItemsGate = new SemaphoreSlim(initialCount: 0); + private readonly object _gate = new(); + private readonly LinkedList _list = new(); + private readonly SemaphoreSlim _hasItemsGate = new(initialCount: 0); public Task WaitForItemsAsync() { diff --git a/src/EditorFeatures/Core/Implementation/Formatting/FormatCommandHandler.cs b/src/EditorFeatures/Core/Implementation/Formatting/FormatCommandHandler.cs index 9f4f651c853ec10e7f94c2e0ca96da16ea34d702..90eb94b91e42f8b4d94c9d37f4102c00420f752c 100644 --- a/src/EditorFeatures/Core/Implementation/Formatting/FormatCommandHandler.cs +++ b/src/EditorFeatures/Core/Implementation/Formatting/FormatCommandHandler.cs @@ -188,6 +188,6 @@ public void ExecuteReturnOrTypeCommand(EditorCommandArgs args, Action nextHandle } private CaretPreservingEditTransaction CreateEditTransaction(ITextView view, string description) - => new CaretPreservingEditTransaction(description, view, _undoHistoryRegistry, _editorOperationsFactoryService); + => new(description, view, _undoHistoryRegistry, _editorOperationsFactoryService); } } diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/AsyncCompletionLogger.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/AsyncCompletionLogger.cs index 0c42b362aedaca54ac8de3503b1ebe5c4e3d5d12..eaa5c5a5e08e6ca200fa634e3617a10f49965918 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/AsyncCompletionLogger.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/AsyncCompletionLogger.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis { internal class AsyncCompletionLogger { - private static readonly LogAggregator s_logAggregator = new LogAggregator(); + private static readonly LogAggregator s_logAggregator = new(); internal enum ActionInfo { diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs index 4853670780f462526b94e14a29a45c99a638a7aa..ce217ef3e829d5b7614a1af1e605a54bce4f0cce 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs @@ -27,7 +27,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncComplet internal sealed class CommitManager : ForegroundThreadAffinitizedObject, IAsyncCompletionCommitManager { private static readonly AsyncCompletionData.CommitResult CommitResultUnhandled = - new AsyncCompletionData.CommitResult(isHandled: false, AsyncCompletionData.CommitBehavior.None); + new(isHandled: false, AsyncCompletionData.CommitBehavior.None); private readonly RecentItemsManager _recentItemsManager; private readonly ITextView _textView; diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CompletionSource.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CompletionSource.cs index 14b9398d6e4db386f150b8c0d9ecfd73f6b3ad90..ef5f13bb79bb736c4c8f348aa2285b777c2f38df 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CompletionSource.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CompletionSource.cs @@ -52,11 +52,11 @@ internal sealed class CompletionSource : ForegroundThreadAffinitizedObject, IAsy private static readonly ImmutableArray s_WarningImageAttributeImagesArray = ImmutableArray.Create(new ImageElement(Glyph.CompletionWarning.GetImageId(), EditorFeaturesResources.Warning_image_element)); - private static readonly EditorOptionKey NonBlockingCompletionEditorOption = new EditorOptionKey(NonBlockingCompletion); + private static readonly EditorOptionKey NonBlockingCompletionEditorOption = new(NonBlockingCompletion); // Use CWT to cache data needed to create VSCompletionItem, so the table would be cleared when Roslyn completion item cache is cleared. private static readonly ConditionalWeakTable> s_roslynItemToVsItemData = - new ConditionalWeakTable>(); + new(); private readonly ITextView _textView; private readonly bool _isDebuggerTextView; diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs index 73c7dd4c8133445a50cf064f4f994b66604145a9..f7d212bd90f87c9ebf784842536b3451495bb3f5 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs @@ -38,7 +38,7 @@ internal class ItemManager : IAsyncCompletionItemManager /// /// For telemetry. /// - private readonly object _targetTypeCompletionFilterChosenMarker = new object(); + private readonly object _targetTypeCompletionFilterChosenMarker = new(); internal ItemManager(RecentItemsManager recentItemsManager) { diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/RecentItemsManager.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/RecentItemsManager.cs index 6577eec2add7048f22f8d0178bc913f555de1420..c648d4f008c6039724ca3f12aef2107ebf831758 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/RecentItemsManager.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/RecentItemsManager.cs @@ -17,7 +17,7 @@ internal class RecentItemsManager /// /// Guard for /// - private readonly object _mruUpdateLock = new object(); + private readonly object _mruUpdateLock = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/PrioritizedTaskScheduler.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/PrioritizedTaskScheduler.cs index ace9413675623c0a816a6302f8f2d19e55fc4a8e..71511c632cf700448d6ce48991c533094a117b21 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/PrioritizedTaskScheduler.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/PrioritizedTaskScheduler.cs @@ -15,7 +15,7 @@ internal class PrioritizedTaskScheduler : TaskScheduler public static readonly TaskScheduler AboveNormalInstance = new PrioritizedTaskScheduler(ThreadPriority.AboveNormal); private readonly Thread _thread; - private readonly BlockingCollection _tasks = new BlockingCollection(); + private readonly BlockingCollection _tasks = new(); private PrioritizedTaskScheduler(ThreadPriority priority) { diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Controller.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Controller.cs index b78e4c854ddabaae5bb699b4496a3f031355d914..f59e7b2f0cfd2ff6d80c4d08641000815549e800 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Controller.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Controller.cs @@ -27,7 +27,7 @@ internal partial class Controller : IChainedCommandHandler, IChainedCommandHandler { - private static readonly object s_controllerPropertyKey = new object(); + private static readonly object s_controllerPropertyKey = new(); private readonly IAsyncCompletionBroker _completionBroker; private readonly IList> _allProviders; diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/Parameter.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/Parameter.cs index a46c198c97023349cec602231256a19392351938..856d4b632b50e89c4bb00c1514af3d63aeeea6ff 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/Parameter.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/Parameter.cs @@ -20,8 +20,8 @@ internal class Parameter : IParameter public string Documentation => _documentation ?? (_documentation = _parameter.DocumentationFactory(CancellationToken.None).GetFullText()); public string Name => _parameter.Name; - public Span Locus => new Span(_index, _contentLength); - public Span PrettyPrintedLocus => new Span(_prettyPrintedIndex, _contentLength); + public Span Locus => new(_index, _contentLength); + public Span PrettyPrintedLocus => new(_prettyPrintedIndex, _contentLength); public ISignature Signature { get; } public Parameter( diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/SignatureHelpPresenter.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/SignatureHelpPresenter.cs index ab80f2aedb7564778a22c39e320ab7ad471d8f25..9de6f06da8898ad76ca14231a8692d3bab58a441 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/SignatureHelpPresenter.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/SignatureHelpPresenter.cs @@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.SignatureHel [ContentType(ContentTypeNames.RoslynContentType)] internal partial class SignatureHelpPresenter : ForegroundThreadAffinitizedObject, IIntelliSensePresenter, ISignatureHelpSourceProvider { - private static readonly object s_augmentSessionKey = new object(); + private static readonly object s_augmentSessionKey = new(); private readonly ISignatureHelpBroker _sigHelpBroker; diff --git a/src/EditorFeatures/Core/Implementation/Interactive/Completion/GlobalAssemblyCacheCompletionHelper.cs b/src/EditorFeatures/Core/Implementation/Interactive/Completion/GlobalAssemblyCacheCompletionHelper.cs index 357bccee461ed22cf8b98e2595221ada14223560..653166f0a7d20ace2f1da0cdda230a52f6b23bec 100644 --- a/src/EditorFeatures/Core/Implementation/Interactive/Completion/GlobalAssemblyCacheCompletionHelper.cs +++ b/src/EditorFeatures/Core/Implementation/Interactive/Completion/GlobalAssemblyCacheCompletionHelper.cs @@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Editor.Completion.FileSystem internal sealed class GlobalAssemblyCacheCompletionHelper { private static readonly Lazy> s_lazyAssemblySimpleNames = - new Lazy>(() => GlobalAssemblyCache.Instance.GetAssemblySimpleNames().ToList()); + new(() => GlobalAssemblyCache.Instance.GetAssemblySimpleNames().ToList()); private readonly CompletionItemRules _itemRules; diff --git a/src/EditorFeatures/Core/Implementation/KeywordHighlighting/AbstractKeywordHighlighter.cs b/src/EditorFeatures/Core/Implementation/KeywordHighlighting/AbstractKeywordHighlighter.cs index 436280b0ff401831780b3294c07cf0dbbd760e71..1644bda1d97bc1fb66092788ee3dfd61d73c575c 100644 --- a/src/EditorFeatures/Core/Implementation/KeywordHighlighting/AbstractKeywordHighlighter.cs +++ b/src/EditorFeatures/Core/Implementation/KeywordHighlighting/AbstractKeywordHighlighter.cs @@ -23,8 +23,8 @@ protected sealed override void AddHighlightsForNode(SyntaxNode node, List> s_textSpanListPool = new ObjectPool>(() => new List()); - private static readonly ObjectPool> s_tokenListPool = new ObjectPool>(() => new List()); + private static readonly ObjectPool> s_textSpanListPool = new(() => new List()); + private static readonly ObjectPool> s_tokenListPool = new(() => new List()); protected abstract bool IsHighlightableNode(SyntaxNode node); @@ -72,7 +72,7 @@ private static bool AnyIntersects(int position, List highlights) protected abstract void AddHighlightsForNode(SyntaxNode node, List highlights, CancellationToken cancellationToken); protected static TextSpan EmptySpan(int position) - => new TextSpan(position, 0); + => new(position, 0); internal static void AddTouchingTokens(SyntaxNode root, int position, List tokens) { diff --git a/src/EditorFeatures/Core/Implementation/KeywordHighlighting/HighlighterViewTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/KeywordHighlighting/HighlighterViewTaggerProvider.cs index 5a96fa7b44a8394a28de5cdda3aa7578b1c8b595..454db662a670b0efeaf125e7571f4572adac2570 100644 --- a/src/EditorFeatures/Core/Implementation/KeywordHighlighting/HighlighterViewTaggerProvider.cs +++ b/src/EditorFeatures/Core/Implementation/KeywordHighlighting/HighlighterViewTaggerProvider.cs @@ -31,7 +31,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Highlighting internal class HighlighterViewTaggerProvider : AsynchronousViewTaggerProvider { private readonly IHighlightingService _highlightingService; - private static readonly PooledObjects.ObjectPool> s_listPool = new PooledObjects.ObjectPool>(() => new List()); + private static readonly PooledObjects.ObjectPool> s_listPool = new(() => new List()); // Whenever an edit happens, clear all highlights. When moving the caret, preserve // highlights if the caret stays within an existing tag. diff --git a/src/EditorFeatures/Core/Implementation/KeywordHighlighting/HighlightingService.cs b/src/EditorFeatures/Core/Implementation/KeywordHighlighting/HighlightingService.cs index 82864ec0543dbaa1c24e25b3a093771249e1a147..df932ab52912653ef65a1f4c8be3e08c54154492 100644 --- a/src/EditorFeatures/Core/Implementation/KeywordHighlighting/HighlightingService.cs +++ b/src/EditorFeatures/Core/Implementation/KeywordHighlighting/HighlightingService.cs @@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Highlighting internal class HighlightingService : IHighlightingService { private readonly List> _highlighters; - private static readonly PooledObjects.ObjectPool> s_listPool = new PooledObjects.ObjectPool>(() => new List()); + private static readonly PooledObjects.ObjectPool> s_listPool = new(() => new List()); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/EditorFeatures/Core/Implementation/KeywordHighlighting/KeywordHighlightTag.cs b/src/EditorFeatures/Core/Implementation/KeywordHighlighting/KeywordHighlightTag.cs index ade4c0124ba1b520177ae3ee5a1544ed3df1b64d..f346ec66ef11628bde078af6d2a8d7c776ef0137 100644 --- a/src/EditorFeatures/Core/Implementation/KeywordHighlighting/KeywordHighlightTag.cs +++ b/src/EditorFeatures/Core/Implementation/KeywordHighlighting/KeywordHighlightTag.cs @@ -10,7 +10,7 @@ internal class KeywordHighlightTag : NavigableHighlightTag { internal const string TagId = "MarkerFormatDefinition/HighlightedReference"; - public static readonly KeywordHighlightTag Instance = new KeywordHighlightTag(); + public static readonly KeywordHighlightTag Instance = new(); private KeywordHighlightTag() : base(TagId) diff --git a/src/EditorFeatures/Core/Implementation/NavigationBar/NavigationBarController_ModelComputation.cs b/src/EditorFeatures/Core/Implementation/NavigationBar/NavigationBarController_ModelComputation.cs index 09fa50a88b710aebf3e5a97772eec8018461a440..552ad1b246f8a020581af639cde0d1d094beb41c 100644 --- a/src/EditorFeatures/Core/Implementation/NavigationBar/NavigationBarController_ModelComputation.cs +++ b/src/EditorFeatures/Core/Implementation/NavigationBar/NavigationBarController_ModelComputation.cs @@ -24,7 +24,7 @@ internal partial class NavigationBarController /// private Task _modelTask; private NavigationBarModel _lastCompletedModel; - private CancellationTokenSource _modelTaskCancellationSource = new CancellationTokenSource(); + private CancellationTokenSource _modelTaskCancellationSource = new(); /// /// Starts a new task to compute the model based on the current text. @@ -100,7 +100,7 @@ private async Task ComputeModelAsync(Document document, ITex } private Task _selectedItemInfoTask; - private CancellationTokenSource _selectedItemInfoTaskCancellationSource = new CancellationTokenSource(); + private CancellationTokenSource _selectedItemInfoTaskCancellationSource = new(); /// /// Starts a new task to compute what item should be selected. diff --git a/src/EditorFeatures/Core/Implementation/PasteTracking/PasteTrackingService.cs b/src/EditorFeatures/Core/Implementation/PasteTracking/PasteTrackingService.cs index fc0e44318ecb855e121e39179d9ee314f0a5401f..77ecb1ca3581da64b3974f46b98087167d3ab568 100644 --- a/src/EditorFeatures/Core/Implementation/PasteTracking/PasteTrackingService.cs +++ b/src/EditorFeatures/Core/Implementation/PasteTracking/PasteTrackingService.cs @@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.PasteTracking internal class PasteTrackingService : IPasteTrackingService { private readonly IThreadingContext _threadingContext; - private readonly object _pastedTextSpanKey = new object(); + private readonly object _pastedTextSpanKey = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/EditorFeatures/Core/Implementation/RenameTracking/RenameTrackingTag.cs b/src/EditorFeatures/Core/Implementation/RenameTracking/RenameTrackingTag.cs index 890a11584e6d76c0fd30f3d2af6b2d9105bcb77e..1fc245d2ea063f02cbb466a376f53e5150e50d64 100644 --- a/src/EditorFeatures/Core/Implementation/RenameTracking/RenameTrackingTag.cs +++ b/src/EditorFeatures/Core/Implementation/RenameTracking/RenameTrackingTag.cs @@ -10,7 +10,7 @@ internal class RenameTrackingTag : TextMarkerTag { internal const string TagId = "RenameTrackingTag"; - public static readonly RenameTrackingTag Instance = new RenameTrackingTag(); + public static readonly RenameTrackingTag Instance = new(); private RenameTrackingTag() : base(TagId) diff --git a/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs b/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs index 157c7f511e21bea3051f6adb50068a335fd8a278..39066232ac6d71cd1f841c65234b74ecb95a3afb 100644 --- a/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs +++ b/src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs @@ -43,7 +43,7 @@ public IndentationResult(int basePosition, int offset) : this() } public static implicit operator Indentation.IndentationResult(IndentationResult result) - => new Indentation.IndentationResult(result.BasePosition, result.Offset); + => new(result.BasePosition, result.Offset); } // Removal of this interface tracked with https://github.com/dotnet/roslyn/issues/35872 diff --git a/src/EditorFeatures/Core/Implementation/TextBufferAssociatedViewService.cs b/src/EditorFeatures/Core/Implementation/TextBufferAssociatedViewService.cs index adb6753d2d4a9d3482f75625a6d1d6ea065cc015..2ede5d0703cbe1926e042f74795e1854e47e96f1 100644 --- a/src/EditorFeatures/Core/Implementation/TextBufferAssociatedViewService.cs +++ b/src/EditorFeatures/Core/Implementation/TextBufferAssociatedViewService.cs @@ -24,12 +24,12 @@ namespace Microsoft.CodeAnalysis.Editor internal class TextBufferAssociatedViewService : ITextViewConnectionListener, ITextBufferAssociatedViewService { #if DEBUG - private static readonly HashSet s_registeredViews = new HashSet(); + private static readonly HashSet s_registeredViews = new(); #endif - private static readonly object s_gate = new object(); + private static readonly object s_gate = new(); private static readonly ConditionalWeakTable> s_map = - new ConditionalWeakTable>(); + new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/EditorFeatures/Core/Implementation/TextStructureNavigation/AbstractTextStructureNavigatorProvider.cs b/src/EditorFeatures/Core/Implementation/TextStructureNavigation/AbstractTextStructureNavigatorProvider.cs index 96dcf698ed2a6bf61bd199bf1a22a4721eb8ccb4..2b872964784fdb306409d754828ae51a6947e8fb 100644 --- a/src/EditorFeatures/Core/Implementation/TextStructureNavigation/AbstractTextStructureNavigatorProvider.cs +++ b/src/EditorFeatures/Core/Implementation/TextStructureNavigation/AbstractTextStructureNavigatorProvider.cs @@ -34,7 +34,7 @@ internal abstract partial class AbstractTextStructureNavigatorProvider : ITextSt protected abstract bool IsWithinNaturalLanguage(SyntaxToken token, int position); protected virtual TextExtent GetExtentOfWordFromToken(SyntaxToken token, SnapshotPoint position) - => new TextExtent(token.Span.ToSnapshotSpan(position.Snapshot), isSignificant: true); + => new(token.Span.ToSnapshotSpan(position.Snapshot), isSignificant: true); public ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer subjectBuffer) { diff --git a/src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.cs b/src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.cs index 6314b3e56072a95b549f3dffedcfe41f1b12b8d2..d2be3f42f4fc34bba12ed67783c564e8a0292564 100644 --- a/src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.cs +++ b/src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.cs @@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Editor.NavigableSymbols [ContentType(ContentTypeNames.RoslynContentType)] internal partial class NavigableSymbolService : INavigableSymbolSourceProvider { - private static readonly object s_key = new object(); + private static readonly object s_key = new(); private readonly IWaitIndicator _waitIndicator; private readonly IThreadingContext _threadingContext; private readonly IStreamingFindUsagesPresenter _streamingPresenter; diff --git a/src/EditorFeatures/Core/Options/BraceCompletionOptions.cs b/src/EditorFeatures/Core/Options/BraceCompletionOptions.cs index 8b7c916d6cc00e5935957da31ea3322bd658793b..7d826c6bd54f67d406fe3b3ea0100f7fa97a90fd 100644 --- a/src/EditorFeatures/Core/Options/BraceCompletionOptions.cs +++ b/src/EditorFeatures/Core/Options/BraceCompletionOptions.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Editor.Options internal static class BraceCompletionOptions { // This is serialized by the Visual Studio-specific LanguageSettingsPersister - public static readonly PerLanguageOption Enable = new PerLanguageOption(nameof(BraceCompletionOptions), nameof(Enable), defaultValue: true); + public static readonly PerLanguageOption Enable = new(nameof(BraceCompletionOptions), nameof(Enable), defaultValue: true); } [ExportOptionProvider, Shared] diff --git a/src/EditorFeatures/Core/Options/ColorSchemeOptions.cs b/src/EditorFeatures/Core/Options/ColorSchemeOptions.cs index c6148f822286385061c609ff1bca57a72fe93580..acbd2f40fecf64dd1174a4640fdb9cb0006eaa3c 100644 --- a/src/EditorFeatures/Core/Options/ColorSchemeOptions.cs +++ b/src/EditorFeatures/Core/Options/ColorSchemeOptions.cs @@ -16,12 +16,12 @@ internal static class ColorSchemeOptions { internal const string ColorSchemeSettingKey = "TextEditor.Roslyn.ColorScheme"; - public static readonly Option2 ColorScheme = new Option2(nameof(ColorSchemeOptions), + public static readonly Option2 ColorScheme = new(nameof(ColorSchemeOptions), nameof(ColorScheme), defaultValue: SchemeName.VisualStudio2019, storageLocations: new RoamingProfileStorageLocation(ColorSchemeSettingKey)); - public static readonly Option2 LegacyUseEnhancedColors = new Option2(nameof(ColorSchemeOptions), + public static readonly Option2 LegacyUseEnhancedColors = new(nameof(ColorSchemeOptions), nameof(LegacyUseEnhancedColors), defaultValue: UseEnhancedColors.Default, storageLocations: new RoamingProfileStorageLocation("WindowManagement.Options.UseEnhancedColorsForManagedLanguages")); diff --git a/src/EditorFeatures/Core/Options/ExtensionManagerOptions.cs b/src/EditorFeatures/Core/Options/ExtensionManagerOptions.cs index e3aef444210a33faf1e9f0600f9c10d769bed1af..40efebd508c10582f5d8c2371f10c4072a9c139d 100644 --- a/src/EditorFeatures/Core/Options/ExtensionManagerOptions.cs +++ b/src/EditorFeatures/Core/Options/ExtensionManagerOptions.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Editor.Options { internal partial class ExtensionManagerOptions { - public static readonly Option DisableCrashingExtensions = new Option(nameof(ExtensionManagerOptions), nameof(DisableCrashingExtensions), defaultValue: true); + public static readonly Option DisableCrashingExtensions = new(nameof(ExtensionManagerOptions), nameof(DisableCrashingExtensions), defaultValue: true); } [ExportOptionProvider, Shared] diff --git a/src/EditorFeatures/Core/Options/NavigationBarOptions.cs b/src/EditorFeatures/Core/Options/NavigationBarOptions.cs index eccb6bb500e002242a6393f9383f27aad5dfffd2..5dbc9363e613176a9024c3d84667e7b27d3c45a4 100644 --- a/src/EditorFeatures/Core/Options/NavigationBarOptions.cs +++ b/src/EditorFeatures/Core/Options/NavigationBarOptions.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.Options { internal static class NavigationBarOptions { - public static readonly PerLanguageOption ShowNavigationBar = new PerLanguageOption(nameof(NavigationBarOptions), nameof(ShowNavigationBar), defaultValue: true); + public static readonly PerLanguageOption ShowNavigationBar = new(nameof(NavigationBarOptions), nameof(ShowNavigationBar), defaultValue: true); } [ExportOptionProvider, Shared] diff --git a/src/EditorFeatures/Core/Options/SignatureHelpOptions.cs b/src/EditorFeatures/Core/Options/SignatureHelpOptions.cs index ae44b8a595acfa014794d4dd9b2e77116892216c..8380841fbf44add74668c2d46ccc76f863f82c43 100644 --- a/src/EditorFeatures/Core/Options/SignatureHelpOptions.cs +++ b/src/EditorFeatures/Core/Options/SignatureHelpOptions.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.Options { internal static class SignatureHelpOptions { - public static readonly PerLanguageOption2 ShowSignatureHelp = new PerLanguageOption2(nameof(SignatureHelpOptions), nameof(ShowSignatureHelp), defaultValue: true); + public static readonly PerLanguageOption2 ShowSignatureHelp = new(nameof(SignatureHelpOptions), nameof(ShowSignatureHelp), defaultValue: true); } [ExportOptionProvider, Shared] diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs index f89eb5cab5001065a37c1a288a9d4096629d8819..52886025a115250d1a3c667417cf1c1ef511fa91 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs +++ b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/DefinitionHighlightTag.cs @@ -10,7 +10,7 @@ internal class DefinitionHighlightTag : NavigableHighlightTag { public const string TagId = "MarkerFormatDefinition/HighlightedDefinition"; - public static readonly DefinitionHighlightTag Instance = new DefinitionHighlightTag(); + public static readonly DefinitionHighlightTag Instance = new(); private DefinitionHighlightTag() : base(TagId) diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs index 996ff488a520a6dc4bd2202902a3feedf9e6ddf2..21184216a80d8080b99b61f7c4cca4443bbb8a6b 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs +++ b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/ReferenceHighlightTag.cs @@ -10,7 +10,7 @@ internal class ReferenceHighlightTag : NavigableHighlightTag { internal const string TagId = "MarkerFormatDefinition/HighlightedReference"; - public static readonly ReferenceHighlightTag Instance = new ReferenceHighlightTag(); + public static readonly ReferenceHighlightTag Instance = new(); private ReferenceHighlightTag() : base(TagId) diff --git a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs index 19681a8503cb5e8dc89cfdfc6b06df48434d8e2a..c7de0308e5be1b075d36d5583250e5d09b09cc00 100644 --- a/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs +++ b/src/EditorFeatures/Core/ReferenceHighlighting/Tags/WrittenReferenceHighlightTag.cs @@ -10,7 +10,7 @@ internal class WrittenReferenceHighlightTag : NavigableHighlightTag { internal const string TagId = "MarkerFormatDefinition/HighlightedWrittenReference"; - public static readonly WrittenReferenceHighlightTag Instance = new WrittenReferenceHighlightTag(); + public static readonly WrittenReferenceHighlightTag Instance = new(); private WrittenReferenceHighlightTag() : base(TagId) diff --git a/src/EditorFeatures/Core/Shared/Extensions/GlyphExtensions.cs b/src/EditorFeatures/Core/Shared/Extensions/GlyphExtensions.cs index 36269affce4ded0642745e30897145d3ad09a8d8..f21bc193be32e83935bf80b3f5e5474c76c0eb87 100644 --- a/src/EditorFeatures/Core/Shared/Extensions/GlyphExtensions.cs +++ b/src/EditorFeatures/Core/Shared/Extensions/GlyphExtensions.cs @@ -18,7 +18,7 @@ internal static class GlyphExtensions private static readonly Guid ImageCatalogGuid = Guid.Parse("ae27a6b0-e345-4288-96df-5eaf394ee369"); public static ImageId GetImageCatalogImageId(int imageId) - => new ImageId(ImageCatalogGuid, imageId); + => new(ImageCatalogGuid, imageId); public static ImageId GetImageId(this Glyph glyph) { diff --git a/src/EditorFeatures/Core/Shared/Extensions/HostWorkspaceServicesExtensions.cs b/src/EditorFeatures/Core/Shared/Extensions/HostWorkspaceServicesExtensions.cs index 859f739392242c574c9ca6c1b4b518d306e1b16d..e7e139809a7e92aa099307fe401d08dde27d4076 100644 --- a/src/EditorFeatures/Core/Shared/Extensions/HostWorkspaceServicesExtensions.cs +++ b/src/EditorFeatures/Core/Shared/Extensions/HostWorkspaceServicesExtensions.cs @@ -41,7 +41,7 @@ internal static class HostWorkspaceServicesExtensions /// A cache of host services -> (language name -> content type name). /// private static readonly ConditionalWeakTable> s_hostServicesToContentTypeMap - = new ConditionalWeakTable>(); + = new(); private static string GetDefaultContentTypeName(HostWorkspaceServices workspaceServices, string language) { diff --git a/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.AutoClosingViewProperty.cs b/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.AutoClosingViewProperty.cs index da060b0cc3fd5e0e7b2c1f2ccb6bc347e80311e2..788e51a4158bb2a367d7912d399b0a453b468f8e 100644 --- a/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.AutoClosingViewProperty.cs +++ b/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.AutoClosingViewProperty.cs @@ -14,7 +14,7 @@ internal static partial class ITextViewExtensions private class AutoClosingViewProperty where TTextView : ITextView { private readonly TTextView _textView; - private readonly Dictionary _map = new Dictionary(); + private readonly Dictionary _map = new(); public static bool GetOrCreateValue( TTextView textView, diff --git a/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.PerSubjectBufferProperty.cs b/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.PerSubjectBufferProperty.cs index 5da917c8241d9452bc37b24ae141fb6a4d43025c..f040d91be74f74c537f71a9d67cee082f4675be7 100644 --- a/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.PerSubjectBufferProperty.cs +++ b/src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.PerSubjectBufferProperty.cs @@ -18,11 +18,11 @@ internal static partial class ITextViewExtensions private class PerSubjectBufferProperty where TTextView : ITextView { private readonly TTextView _textView; - private readonly Dictionary> _subjectBufferMap = new Dictionary>(); + private readonly Dictionary> _subjectBufferMap = new(); // Some other VS components (e.g. Razor) will temporarily disconnect out ITextBuffer from the ITextView. When listening to // BufferGraph.GraphBuffersChanged, we should allow buffers we previously knew about to be re-attached. - private readonly ConditionalWeakTable> _buffersRemovedFromTextViewBufferGraph = new ConditionalWeakTable>(); + private readonly ConditionalWeakTable> _buffersRemovedFromTextViewBufferGraph = new(); public static bool GetOrCreateValue( TTextView textView, diff --git a/src/EditorFeatures/Core/Shared/Extensions/SpanExtensions.cs b/src/EditorFeatures/Core/Shared/Extensions/SpanExtensions.cs index 653cc60007af0966f858e0a99d29e57246e794d4..c78ee9e28119a9db5d85bce91f30456fa3be70e3 100644 --- a/src/EditorFeatures/Core/Shared/Extensions/SpanExtensions.cs +++ b/src/EditorFeatures/Core/Shared/Extensions/SpanExtensions.cs @@ -18,7 +18,7 @@ internal static class SpanExtensions /// /// public static TextSpan ToTextSpan(this Span span) - => new TextSpan(span.Start, span.Length); + => new(span.Start, span.Length); public static bool IntersectsWith(this Span span, int position) => position >= span.Start && position <= span.End; diff --git a/src/EditorFeatures/Core/Shared/Extensions/TextChangeExtensions.cs b/src/EditorFeatures/Core/Shared/Extensions/TextChangeExtensions.cs index 90fca17dd64456ce327ce208f7a036cc4089e582..d7b508dfc489da1c8ddcd57e24e39877dacf8101 100644 --- a/src/EditorFeatures/Core/Shared/Extensions/TextChangeExtensions.cs +++ b/src/EditorFeatures/Core/Shared/Extensions/TextChangeExtensions.cs @@ -10,6 +10,6 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Extensions internal static class TextChangeExtensions { public static TextChangeRange ToTextChangeRange(this ITextChange textChange) - => new TextChangeRange(textChange.OldSpan.ToTextSpan(), textChange.NewLength); + => new(textChange.OldSpan.ToTextSpan(), textChange.NewLength); } } diff --git a/src/EditorFeatures/Core/Shared/Options/ComponentOnOffOptions.cs b/src/EditorFeatures/Core/Shared/Options/ComponentOnOffOptions.cs index 99555276efd8b48b0f97b4c7e064e0e00e136cc2..268920b3bfc908ee78abb45e6ef563527a87f73c 100644 --- a/src/EditorFeatures/Core/Shared/Options/ComponentOnOffOptions.cs +++ b/src/EditorFeatures/Core/Shared/Options/ComponentOnOffOptions.cs @@ -18,16 +18,16 @@ internal static class EditorComponentOnOffOptions { private const string LocalRegistryPath = @"Roslyn\Internal\OnOff\Components\"; - public static readonly Option2 Adornment = new Option2(nameof(EditorComponentOnOffOptions), nameof(Adornment), defaultValue: true, + public static readonly Option2 Adornment = new(nameof(EditorComponentOnOffOptions), nameof(Adornment), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Adornment")); - public static readonly Option2 Tagger = new Option2(nameof(EditorComponentOnOffOptions), nameof(Tagger), defaultValue: true, + public static readonly Option2 Tagger = new(nameof(EditorComponentOnOffOptions), nameof(Tagger), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Tagger")); - public static readonly Option2 CodeRefactorings = new Option2(nameof(EditorComponentOnOffOptions), nameof(CodeRefactorings), defaultValue: true, + public static readonly Option2 CodeRefactorings = new(nameof(EditorComponentOnOffOptions), nameof(CodeRefactorings), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Code Refactorings")); - public static readonly Option2 ShowCodeRefactoringsWhenQueriedForCodeFixes = new Option2( + public static readonly Option2 ShowCodeRefactoringsWhenQueriedForCodeFixes = new( nameof(EditorComponentOnOffOptions), nameof(ShowCodeRefactoringsWhenQueriedForCodeFixes), defaultValue: false, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(ShowCodeRefactoringsWhenQueriedForCodeFixes))); } diff --git a/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs b/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs index cefeb1d60f91a81c58ede405fd147048eeb701dc..9f1b9ff6b7d55003d19b229ded622c494690b6d4 100644 --- a/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs +++ b/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs @@ -15,53 +15,53 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Options { internal static class FeatureOnOffOptions { - public static readonly PerLanguageOption2 EndConstruct = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(EndConstruct), defaultValue: true, + public static readonly PerLanguageOption2 EndConstruct = new(nameof(FeatureOnOffOptions), nameof(EndConstruct), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.AutoEndInsert")); // This value is only used by Visual Basic, and so is using the old serialization name that was used by VB. - public static readonly PerLanguageOption2 AutomaticInsertionOfAbstractOrInterfaceMembers = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(AutomaticInsertionOfAbstractOrInterfaceMembers), defaultValue: true, + public static readonly PerLanguageOption2 AutomaticInsertionOfAbstractOrInterfaceMembers = new(nameof(FeatureOnOffOptions), nameof(AutomaticInsertionOfAbstractOrInterfaceMembers), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.AutoRequiredMemberInsert")); - public static readonly PerLanguageOption2 LineSeparator = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(LineSeparator), defaultValue: false, + public static readonly PerLanguageOption2 LineSeparator = new(nameof(FeatureOnOffOptions), nameof(LineSeparator), defaultValue: false, storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.DisplayLineSeparators" : "TextEditor.%LANGUAGE%.Specific.Line Separator")); - public static readonly PerLanguageOption2 Outlining = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(Outlining), defaultValue: true, + public static readonly PerLanguageOption2 Outlining = new(nameof(FeatureOnOffOptions), nameof(Outlining), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Outlining")); - public static readonly PerLanguageOption2 KeywordHighlighting = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(KeywordHighlighting), defaultValue: true, + public static readonly PerLanguageOption2 KeywordHighlighting = new(nameof(FeatureOnOffOptions), nameof(KeywordHighlighting), defaultValue: true, storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.EnableHighlightRelatedKeywords" : "TextEditor.%LANGUAGE%.Specific.Keyword Highlighting")); - public static readonly PerLanguageOption2 ReferenceHighlighting = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(ReferenceHighlighting), defaultValue: true, + public static readonly PerLanguageOption2 ReferenceHighlighting = new(nameof(FeatureOnOffOptions), nameof(ReferenceHighlighting), defaultValue: true, storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.EnableHighlightReferences" : "TextEditor.%LANGUAGE%.Specific.Reference Highlighting")); - public static readonly PerLanguageOption2 FormatOnPaste = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(FormatOnPaste), defaultValue: true, + public static readonly PerLanguageOption2 FormatOnPaste = new(nameof(FeatureOnOffOptions), nameof(FormatOnPaste), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.FormatOnPaste")); - public static readonly PerLanguageOption2 AutoXmlDocCommentGeneration = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(AutoXmlDocCommentGeneration), defaultValue: true, + public static readonly PerLanguageOption2 AutoXmlDocCommentGeneration = new(nameof(FeatureOnOffOptions), nameof(AutoXmlDocCommentGeneration), defaultValue: true, storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.AutoComment" : "TextEditor.%LANGUAGE%.Specific.Automatic XML Doc Comment Generation")); - public static readonly PerLanguageOption2 AutoInsertBlockCommentStartString = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(AutoInsertBlockCommentStartString), defaultValue: true, + public static readonly PerLanguageOption2 AutoInsertBlockCommentStartString = new(nameof(FeatureOnOffOptions), nameof(AutoInsertBlockCommentStartString), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Insert Block Comment Start String")); - public static readonly PerLanguageOption2 PrettyListing = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(PrettyListing), defaultValue: true, + public static readonly PerLanguageOption2 PrettyListing = new(nameof(FeatureOnOffOptions), nameof(PrettyListing), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.PrettyListing")); - public static readonly PerLanguageOption2 InlineParameterNameHints = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(InlineParameterNameHints), defaultValue: false, + public static readonly PerLanguageOption2 InlineParameterNameHints = new(nameof(FeatureOnOffOptions), nameof(InlineParameterNameHints), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints")); - public static readonly PerLanguageOption2 AutoFormattingOnTyping = new PerLanguageOption2( + public static readonly PerLanguageOption2 AutoFormattingOnTyping = new( nameof(FeatureOnOffOptions), nameof(AutoFormattingOnTyping), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Typing")); - public static readonly PerLanguageOption2 AutoFormattingOnCloseBrace = new PerLanguageOption2( + public static readonly PerLanguageOption2 AutoFormattingOnCloseBrace = new( nameof(FeatureOnOffOptions), nameof(AutoFormattingOnCloseBrace), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Close Brace")); - public static readonly PerLanguageOption2 AutoFormattingOnSemicolon = new PerLanguageOption2( + public static readonly PerLanguageOption2 AutoFormattingOnSemicolon = new( nameof(FeatureOnOffOptions), nameof(AutoFormattingOnSemicolon), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.Auto Formatting On Semicolon")); - public static readonly PerLanguageOption2 RenameTrackingPreview = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(RenameTrackingPreview), defaultValue: true, + public static readonly PerLanguageOption2 RenameTrackingPreview = new(nameof(FeatureOnOffOptions), nameof(RenameTrackingPreview), defaultValue: true, storageLocations: new RoamingProfileStorageLocation(language => language == LanguageNames.VisualBasic ? "TextEditor.%LANGUAGE%.Specific.RenameTrackingPreview" : "TextEditor.%LANGUAGE%.Specific.Rename Tracking Preview")); /// @@ -70,7 +70,7 @@ internal static class FeatureOnOffOptions /// maintain any customized value for this setting, even through versions that have not /// implemented this feature yet. /// - public static readonly PerLanguageOption2 RenameTracking = new PerLanguageOption2(nameof(FeatureOnOffOptions), nameof(RenameTracking), defaultValue: true); + public static readonly PerLanguageOption2 RenameTracking = new(nameof(FeatureOnOffOptions), nameof(RenameTracking), defaultValue: true); /// /// This option is currently used by Roslyn, but we might want to implement it in the @@ -78,17 +78,17 @@ internal static class FeatureOnOffOptions /// maintain any customized value for this setting, even through versions that have not /// implemented this feature yet. /// - public static readonly PerLanguageOption2 RefactoringVerification = new PerLanguageOption2( + public static readonly PerLanguageOption2 RefactoringVerification = new( nameof(FeatureOnOffOptions), nameof(RefactoringVerification), defaultValue: false); - public static readonly PerLanguageOption2 StreamingGoToImplementation = new PerLanguageOption2( + public static readonly PerLanguageOption2 StreamingGoToImplementation = new( nameof(FeatureOnOffOptions), nameof(StreamingGoToImplementation), defaultValue: true); - public static readonly Option2 NavigateToDecompiledSources = new Option2( + public static readonly Option2 NavigateToDecompiledSources = new( nameof(FeatureOnOffOptions), nameof(NavigateToDecompiledSources), defaultValue: false, storageLocations: new RoamingProfileStorageLocation($"TextEditor.{nameof(NavigateToDecompiledSources)}")); - public static readonly Option2 UseEnhancedColors = new Option2( + public static readonly Option2 UseEnhancedColors = new( nameof(FeatureOnOffOptions), nameof(UseEnhancedColors), defaultValue: 1, storageLocations: new RoamingProfileStorageLocation("WindowManagement.Options.UseEnhancedColorsForManagedLanguages")); } diff --git a/src/EditorFeatures/Core/Shared/Options/InternalFeatureOnOffOptions.cs b/src/EditorFeatures/Core/Shared/Options/InternalFeatureOnOffOptions.cs index 0f52fb98adc1d11bb88803466bb4c508af353c1d..9088b74c43e4ae75c982e6c77c3a8d4749201656 100644 --- a/src/EditorFeatures/Core/Shared/Options/InternalFeatureOnOffOptions.cs +++ b/src/EditorFeatures/Core/Shared/Options/InternalFeatureOnOffOptions.cs @@ -16,63 +16,63 @@ internal static class InternalFeatureOnOffOptions { internal const string LocalRegistryPath = StorageOptions.LocalRegistryPath; - public static readonly Option2 BraceMatching = new Option2(nameof(InternalFeatureOnOffOptions), nameof(BraceMatching), defaultValue: true, + public static readonly Option2 BraceMatching = new(nameof(InternalFeatureOnOffOptions), nameof(BraceMatching), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Brace Matching")); - public static readonly Option2 Classification = new Option2(nameof(InternalFeatureOnOffOptions), nameof(Classification), defaultValue: true, + public static readonly Option2 Classification = new(nameof(InternalFeatureOnOffOptions), nameof(Classification), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Classification")); - public static readonly Option2 SemanticColorizer = new Option2(nameof(InternalFeatureOnOffOptions), nameof(SemanticColorizer), defaultValue: true, + public static readonly Option2 SemanticColorizer = new(nameof(InternalFeatureOnOffOptions), nameof(SemanticColorizer), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Semantic Colorizer")); - public static readonly Option2 SyntacticColorizer = new Option2(nameof(InternalFeatureOnOffOptions), nameof(SyntacticColorizer), defaultValue: true, + public static readonly Option2 SyntacticColorizer = new(nameof(InternalFeatureOnOffOptions), nameof(SyntacticColorizer), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Syntactic Colorizer")); - public static readonly Option2 AutomaticPairCompletion = new Option2(nameof(InternalFeatureOnOffOptions), nameof(AutomaticPairCompletion), defaultValue: true, + public static readonly Option2 AutomaticPairCompletion = new(nameof(InternalFeatureOnOffOptions), nameof(AutomaticPairCompletion), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Automatic Pair Completion")); - public static readonly Option2 AutomaticLineEnder = new Option2(nameof(InternalFeatureOnOffOptions), nameof(AutomaticLineEnder), defaultValue: true, + public static readonly Option2 AutomaticLineEnder = new(nameof(InternalFeatureOnOffOptions), nameof(AutomaticLineEnder), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Automatic Line Ender")); - public static readonly Option2 SmartIndenter = new Option2(nameof(InternalFeatureOnOffOptions), nameof(SmartIndenter), defaultValue: true, + public static readonly Option2 SmartIndenter = new(nameof(InternalFeatureOnOffOptions), nameof(SmartIndenter), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Smart Indenter")); - public static readonly Option2 CompletionSet = new Option2(nameof(InternalFeatureOnOffOptions), nameof(CompletionSet), defaultValue: true, + public static readonly Option2 CompletionSet = new(nameof(InternalFeatureOnOffOptions), nameof(CompletionSet), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Completion Set")); - public static readonly Option2 KeywordHighlight = new Option2(nameof(InternalFeatureOnOffOptions), nameof(KeywordHighlight), defaultValue: true, + public static readonly Option2 KeywordHighlight = new(nameof(InternalFeatureOnOffOptions), nameof(KeywordHighlight), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Keyword Highlight")); - public static readonly Option2 QuickInfo = new Option2(nameof(InternalFeatureOnOffOptions), nameof(QuickInfo), defaultValue: true, + public static readonly Option2 QuickInfo = new(nameof(InternalFeatureOnOffOptions), nameof(QuickInfo), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Quick Info")); - public static readonly Option2 Squiggles = new Option2(nameof(InternalFeatureOnOffOptions), nameof(Squiggles), defaultValue: true, + public static readonly Option2 Squiggles = new(nameof(InternalFeatureOnOffOptions), nameof(Squiggles), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Squiggles")); - public static readonly Option2 FormatOnSave = new Option2(nameof(InternalFeatureOnOffOptions), nameof(FormatOnSave), defaultValue: true, + public static readonly Option2 FormatOnSave = new(nameof(InternalFeatureOnOffOptions), nameof(FormatOnSave), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "FormatOnSave")); - public static readonly Option2 RenameTracking = new Option2(nameof(InternalFeatureOnOffOptions), nameof(RenameTracking), defaultValue: true, + public static readonly Option2 RenameTracking = new(nameof(InternalFeatureOnOffOptions), nameof(RenameTracking), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Rename Tracking")); - public static readonly Option2 EventHookup = new Option2(nameof(InternalFeatureOnOffOptions), nameof(EventHookup), defaultValue: true, + public static readonly Option2 EventHookup = new(nameof(InternalFeatureOnOffOptions), nameof(EventHookup), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Event Hookup")); /// Due to https://github.com/dotnet/roslyn/issues/5393, the name "Snippets" is unusable for serialization. /// (Summary: Some builds incorrectly set it without providing a way to clear it so it exists in many registries.) - public static readonly Option2 Snippets = new Option2(nameof(InternalFeatureOnOffOptions), nameof(Snippets), defaultValue: true, + public static readonly Option2 Snippets = new(nameof(InternalFeatureOnOffOptions), nameof(Snippets), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Snippets2")); - public static readonly Option2 TodoComments = new Option2(nameof(InternalFeatureOnOffOptions), nameof(TodoComments), defaultValue: true, + public static readonly Option2 TodoComments = new(nameof(InternalFeatureOnOffOptions), nameof(TodoComments), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Todo Comments")); - public static readonly Option2 DesignerAttributes = new Option2(nameof(InternalFeatureOnOffOptions), nameof(DesignerAttributes), defaultValue: true, + public static readonly Option2 DesignerAttributes = new(nameof(InternalFeatureOnOffOptions), nameof(DesignerAttributes), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Designer Attribute")); - public static readonly Option2 BackgroundAnalysisMemoryMonitor = new Option2(nameof(InternalFeatureOnOffOptions), "FullSolutionAnalysisMemoryMonitor", defaultValue: true, + public static readonly Option2 BackgroundAnalysisMemoryMonitor = new(nameof(InternalFeatureOnOffOptions), "FullSolutionAnalysisMemoryMonitor", defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Full Solution Analysis Memory Monitor")); - public static readonly Option2 ProjectReferenceConversion = new Option2(nameof(InternalFeatureOnOffOptions), nameof(ProjectReferenceConversion), defaultValue: true, + public static readonly Option2 ProjectReferenceConversion = new(nameof(InternalFeatureOnOffOptions), nameof(ProjectReferenceConversion), defaultValue: true, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "Project Reference Conversion")); } diff --git a/src/EditorFeatures/Core/Shared/Preview/PredefinedPreviewTaggerKeys.cs b/src/EditorFeatures/Core/Shared/Preview/PredefinedPreviewTaggerKeys.cs index f21a33990f83fdcc87bab2600432668e248316af..372468c5a4c5b9d96ca7682667340d867b8138bf 100644 --- a/src/EditorFeatures/Core/Shared/Preview/PredefinedPreviewTaggerKeys.cs +++ b/src/EditorFeatures/Core/Shared/Preview/PredefinedPreviewTaggerKeys.cs @@ -6,12 +6,12 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Preview { internal static class PredefinedPreviewTaggerKeys { - public static readonly object DefinitionHighlightingSpansKey = new object(); - public static readonly object ReferenceHighlightingSpansKey = new object(); - public static readonly object WrittenReferenceHighlightingSpansKey = new object(); - public static readonly object ConflictSpansKey = new object(); - public static readonly object WarningSpansKey = new object(); - public static readonly object SuppressDiagnosticsSpansKey = new object(); - public static readonly object StaticClassificationSpansKey = new object(); + public static readonly object DefinitionHighlightingSpansKey = new(); + public static readonly object ReferenceHighlightingSpansKey = new(); + public static readonly object WrittenReferenceHighlightingSpansKey = new(); + public static readonly object ConflictSpansKey = new(); + public static readonly object WarningSpansKey = new(); + public static readonly object SuppressDiagnosticsSpansKey = new(); + public static readonly object StaticClassificationSpansKey = new(); } } diff --git a/src/EditorFeatures/Core/Shared/Tagging/EventSources/TaggerEventSources.CompletionClosedEventSource.cs b/src/EditorFeatures/Core/Shared/Tagging/EventSources/TaggerEventSources.CompletionClosedEventSource.cs index 1c6974a24546675f8c2b22dac9b2270e2707a626..09ca51564d5638e38c84d038a462854a9220d29e 100644 --- a/src/EditorFeatures/Core/Shared/Tagging/EventSources/TaggerEventSources.CompletionClosedEventSource.cs +++ b/src/EditorFeatures/Core/Shared/Tagging/EventSources/TaggerEventSources.CompletionClosedEventSource.cs @@ -18,7 +18,7 @@ internal partial class TaggerEventSources private class CompletionClosedEventSource : AbstractTaggerEventSource { private readonly IIntellisenseSessionStack _sessionStack; - private readonly HashSet _trackedSessions = new HashSet(); + private readonly HashSet _trackedSessions = new(); public CompletionClosedEventSource( IIntellisenseSessionStack sessionStack, diff --git a/src/EditorFeatures/Core/Shared/Tagging/Tags/ConflictTag.cs b/src/EditorFeatures/Core/Shared/Tagging/Tags/ConflictTag.cs index d4105822da5a0601c696c2efe98f3e4aec77e1f5..f8218c5014bca7c2d44be342c25b3b7c400546da 100644 --- a/src/EditorFeatures/Core/Shared/Tagging/Tags/ConflictTag.cs +++ b/src/EditorFeatures/Core/Shared/Tagging/Tags/ConflictTag.cs @@ -10,7 +10,7 @@ internal class ConflictTag : TextMarkerTag { public const string TagId = "RoslynConflictTag"; - public static readonly ConflictTag Instance = new ConflictTag(); + public static readonly ConflictTag Instance = new(); private ConflictTag() : base(TagId) diff --git a/src/EditorFeatures/Core/Shared/Tagging/Tags/PreviewWarningTag.cs b/src/EditorFeatures/Core/Shared/Tagging/Tags/PreviewWarningTag.cs index 2079686a3a8f231a8e991370ba9433ac5f685ccd..cd1e128bab1a4acb51bb7a982a938726817acdf5 100644 --- a/src/EditorFeatures/Core/Shared/Tagging/Tags/PreviewWarningTag.cs +++ b/src/EditorFeatures/Core/Shared/Tagging/Tags/PreviewWarningTag.cs @@ -10,7 +10,7 @@ internal class PreviewWarningTag : TextMarkerTag { public const string TagId = "RoslynPreviewWarningTag"; - public static readonly PreviewWarningTag Instance = new PreviewWarningTag(); + public static readonly PreviewWarningTag Instance = new(); private PreviewWarningTag() : base(TagId) diff --git a/src/EditorFeatures/Core/Shared/Threading/AsynchronousSerialWorkQueue.cs b/src/EditorFeatures/Core/Shared/Threading/AsynchronousSerialWorkQueue.cs index 21fbb11255780289558a11c4d0503be1749ca6ff..b2992fedfd0fa3b495d25af91f79b9a6b1551f99 100644 --- a/src/EditorFeatures/Core/Shared/Threading/AsynchronousSerialWorkQueue.cs +++ b/src/EditorFeatures/Core/Shared/Threading/AsynchronousSerialWorkQueue.cs @@ -32,14 +32,14 @@ internal class AsynchronousSerialWorkQueue : ForegroundThreadAffinitizedObject private readonly IAsynchronousOperationListener _asyncListener; // Lock for serializing access to these objects. - private readonly object _gate = new object(); + private readonly object _gate = new(); // The current task we are executing on the background. Kept around so we can serialize // background tasks by continually calling 'SafeContinueWith' on this task. private Task _currentBackgroundTask; // The cancellation source for the current chain of work. - private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); + private CancellationTokenSource _cancellationTokenSource = new(); #endregion diff --git a/src/EditorFeatures/Core/Shared/Utilities/AutomaticCodeChangeMergePolicy.cs b/src/EditorFeatures/Core/Shared/Utilities/AutomaticCodeChangeMergePolicy.cs index d9ac61f983ffdfb0a3b964d02e2306279de66044..ab088277dd08c8823fea54132cf650933b2a5656 100644 --- a/src/EditorFeatures/Core/Shared/Utilities/AutomaticCodeChangeMergePolicy.cs +++ b/src/EditorFeatures/Core/Shared/Utilities/AutomaticCodeChangeMergePolicy.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities /// internal class AutomaticCodeChangeMergePolicy : IMergeTextUndoTransactionPolicy { - public static readonly AutomaticCodeChangeMergePolicy Instance = new AutomaticCodeChangeMergePolicy(); + public static readonly AutomaticCodeChangeMergePolicy Instance = new(); public bool CanMerge(ITextUndoTransaction newerTransaction, ITextUndoTransaction olderTransaction) { diff --git a/src/EditorFeatures/Core/Shared/Utilities/LinkedEditsTracker.cs b/src/EditorFeatures/Core/Shared/Utilities/LinkedEditsTracker.cs index 06388f9307fa00d49f4fb724b705887135a1c38d..859d4d9537b32491ea070b276c7915efef063a19 100644 --- a/src/EditorFeatures/Core/Shared/Utilities/LinkedEditsTracker.cs +++ b/src/EditorFeatures/Core/Shared/Utilities/LinkedEditsTracker.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities { internal class LinkedEditsTracker { - private static readonly object s_propagateSpansEditTag = new object(); + private static readonly object s_propagateSpansEditTag = new(); private readonly ITextBuffer _subjectBuffer; diff --git a/src/EditorFeatures/Core/Shared/Utilities/ResettableDelay.cs b/src/EditorFeatures/Core/Shared/Utilities/ResettableDelay.cs index d3fc903e81181423a0ef9478c8c2c563dea9d2fd..3e8ee1da43dc2b12061e6dc253277bcea2db97a0 100644 --- a/src/EditorFeatures/Core/Shared/Utilities/ResettableDelay.cs +++ b/src/EditorFeatures/Core/Shared/Utilities/ResettableDelay.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities { internal class ResettableDelay { - public static readonly ResettableDelay CompletedDelay = new ResettableDelay(); + public static readonly ResettableDelay CompletedDelay = new(); private readonly int _delayInMilliseconds; private readonly IExpeditableDelaySource _expeditableDelaySource; diff --git a/src/EditorFeatures/Core/Shared/Utilities/ThreadingContext.cs b/src/EditorFeatures/Core/Shared/Utilities/ThreadingContext.cs index f88d5f6fcc7e994a1ec5c831b02467b9086459d7..45942a5b5f827def6f4516b1527f5f865f7140c2 100644 --- a/src/EditorFeatures/Core/Shared/Utilities/ThreadingContext.cs +++ b/src/EditorFeatures/Core/Shared/Utilities/ThreadingContext.cs @@ -25,7 +25,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities [Shared] internal sealed class ThreadingContext : IThreadingContext, IDisposable { - private readonly CancellationTokenSource _disposalTokenSource = new CancellationTokenSource(); + private readonly CancellationTokenSource _disposalTokenSource = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/EditorFeatures/Core/SymbolSearch/Patching/Delta.cs b/src/EditorFeatures/Core/SymbolSearch/Patching/Delta.cs index 61817cab91956deb2da4ed1ed6279ea4f10f7c6c..72b0299c158533fbabc8a5efc81b5f395f4db712 100644 --- a/src/EditorFeatures/Core/SymbolSearch/Patching/Delta.cs +++ b/src/EditorFeatures/Core/SymbolSearch/Patching/Delta.cs @@ -33,7 +33,7 @@ public DeltaInput(byte* pBuf_, int cbBuf_, bool editable_) : this() editable = editable_; } - public static DeltaInput Empty = new DeltaInput(); + public static DeltaInput Empty = new(); } [StructLayout(LayoutKind.Sequential)] diff --git a/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.Update.cs b/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.Update.cs index e7795035e3e58641b54841e056a6e4f5de7bcb22..9f3b347f2c3bd1c9bcd4894909df01c85ae65201 100644 --- a/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.Update.cs +++ b/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.Update.cs @@ -42,7 +42,7 @@ internal partial class SymbolSearchUpdateEngine private const int AddReferenceDatabaseTextFileFormatVersion = 1; private readonly ConcurrentDictionary _sourceToUpdateSentinel = - new ConcurrentDictionary(); + new(); // Interfaces that abstract out the external functionality we need. Used so we can easily // mock behavior during tests. diff --git a/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.cs b/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.cs index 077bf39342f07dea87d0061ac31f29ac48807f03..e4c0414e149cda7564e165ca425e883b7482d56d 100644 --- a/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.cs +++ b/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngine.cs @@ -28,7 +28,7 @@ namespace Microsoft.CodeAnalysis.SymbolSearch internal partial class SymbolSearchUpdateEngine : ISymbolSearchUpdateEngine { private readonly ConcurrentDictionary _sourceToDatabase = - new ConcurrentDictionary(); + new(); /// /// Don't call directly. Use instead. diff --git a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.BatchChangeNotifier.cs b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.BatchChangeNotifier.cs index 06af9722deef134d33d3414722dccdf0f87ce3b6..f9101b7dd838d270ea345c1af14d7aed7e3f1cdd 100644 --- a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.BatchChangeNotifier.cs +++ b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.BatchChangeNotifier.cs @@ -48,7 +48,7 @@ private class BatchChangeNotifier : ForegroundThreadAffinitizedObject // a list that will be updated all at once the timer actually runs. private bool _notificationRequestEnqueued; private readonly SortedDictionary _snapshotVersionToSpansMap = - new SortedDictionary(); + new(); /// /// True if we are currently suppressing UI updates. While suppressed we still continue diff --git a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource.cs b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource.cs index da65499780447399a9c82511eea09a3810f8557b..83c2393e00495c7d3d9d56869ce195a0c4c0e4dd 100644 --- a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource.cs +++ b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource.cs @@ -87,7 +87,7 @@ private sealed partial class TagSource : ForegroundThreadAffinitizedObject /// if our ref count actually reaches 0. Otherwise, we always try to compute the initial /// set of tags for our view/buffer. /// - private readonly CancellationTokenSource _initialComputationCancellationTokenSource = new CancellationTokenSource(); + private readonly CancellationTokenSource _initialComputationCancellationTokenSource = new(); public TaggerDelay AddedTagNotificationDelay => _dataSource.AddedTagNotificationDelay; public TaggerDelay RemovedTagNotificationDelay => _dataSource.RemovedTagNotificationDelay; diff --git a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.cs b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.cs index c021ff11119d8d245d058b88a1812280ed141a1f..3a6e7dbbd8942608669a5d5b3dfa4396e4571cd1 100644 --- a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.cs +++ b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.cs @@ -27,7 +27,7 @@ namespace Microsoft.CodeAnalysis.Editor.Tagging /// internal abstract partial class AbstractAsynchronousTaggerProvider : ForegroundThreadAffinitizedObject where TTag : ITag { - private readonly object _uniqueKey = new object(); + private readonly object _uniqueKey = new(); private readonly IForegroundNotificationService _notificationService; protected readonly IAsynchronousOperationListener AsyncListener; @@ -243,7 +243,7 @@ protected virtual void ProduceTagsSynchronously(TaggerContext context, Doc } internal TestAccessor GetTestAccessor() - => new TestAccessor(this); + => new(this); private struct DiffResult { diff --git a/src/EditorFeatures/Core/Undo/EditorSourceTextUndoService.cs b/src/EditorFeatures/Core/Undo/EditorSourceTextUndoService.cs index 9bf6ece3ea85e1cf5ebdf6e760fda686e465aa7c..9fad983ce3ecddf4379dd7046549f79706c53ac6 100644 --- a/src/EditorFeatures/Core/Undo/EditorSourceTextUndoService.cs +++ b/src/EditorFeatures/Core/Undo/EditorSourceTextUndoService.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.Editor.Undo [ExportWorkspaceService(typeof(ISourceTextUndoService), ServiceLayer.Editor), Shared] internal sealed class EditorSourceTextUndoService : ISourceTextUndoService { - private readonly Dictionary _transactions = new Dictionary(); + private readonly Dictionary _transactions = new(); private readonly ITextUndoHistoryRegistry _undoHistoryRegistry; diff --git a/src/EditorFeatures/Core/Undo/NoOpGlobalUndoServiceFactory.cs b/src/EditorFeatures/Core/Undo/NoOpGlobalUndoServiceFactory.cs index f51c20590009868ee5189c75206065dcf61b04b1..cb2b652cdf0753e628f44f76bfd94a3f1762ecb1 100644 --- a/src/EditorFeatures/Core/Undo/NoOpGlobalUndoServiceFactory.cs +++ b/src/EditorFeatures/Core/Undo/NoOpGlobalUndoServiceFactory.cs @@ -17,7 +17,7 @@ internal class NoOpGlobalUndoServiceFactory : IWorkspaceServiceFactory { public static readonly IWorkspaceGlobalUndoTransaction Transaction = new NoOpUndoTransaction(); - private readonly NoOpGlobalUndoService _singleton = new NoOpGlobalUndoService(); + private readonly NoOpGlobalUndoService _singleton = new(); [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]